From patchwork Thu Oct 13 14:02:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 119531 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1AA9FB6F7B for ; Fri, 14 Oct 2011 01:04:07 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754530Ab1JMOEE (ORCPT ); Thu, 13 Oct 2011 10:04:04 -0400 Received: from mail-gy0-f174.google.com ([209.85.160.174]:64772 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752635Ab1JMOED (ORCPT ); Thu, 13 Oct 2011 10:04:03 -0400 Received: by gyb13 with SMTP id 13so34269gyb.19 for ; Thu, 13 Oct 2011 07:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:mime-version:content-type :content-transfer-encoding:message-id; bh=PUqUx7lSGVpuOhF3vCCMOFltPg4ojpEePvoCjUrMvis=; b=Gz5olhwmLZdUuMlSe7deI6pIjjCNaZ+sU02+QD07oxYL7mpCy6+T+65w5DCOYnMow8 yWhAf1LlKl3+s4oz9keqWmkCe1oBU5DKmoEcmHkgxDrrLide0kZJJCoTO15JU6zNS3ID PCnnsTCfnghxzDtG8rPcpX3xhL2vZErkTVW/Y= Received: by 10.223.75.27 with SMTP id w27mr6359809faj.11.1318514642197; Thu, 13 Oct 2011 07:04:02 -0700 (PDT) Received: from linux-mhg7.site (89-74-122-41.dynamic.chello.pl. [89.74.122.41]) by mx.google.com with ESMTPS id r16sm10060585fam.8.2011.10.13.07.03.59 (version=SSLv3 cipher=OTHER); Thu, 13 Oct 2011 07:04:00 -0700 (PDT) From: Bartlomiej Zolnierkiewicz To: Jeff Garzik Subject: [PATCH 1/2] pata_oldpiix: add locking for parallel scanning Date: Thu, 13 Oct 2011 16:02:44 +0200 User-Agent: KMail/1.13.6 (Linux/2.6.37.6-0.7-desktop-dirty; KDE/4.6.0; x86_64; ; ) Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-Id: <201110131602.45265.bzolnier@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Bartlomiej Zolnierkiewicz Subject: [PATCH] pata_oldpiix: add locking for parallel scanning Add an extra locking for parallel scanning. This is similar change as commit 60c3be3 ("ata_piix: parallel scanning on PATA needs an extra locking") for ata_piix host driver and while pata_oldpiix doesn't enable parallel scan yet the race could probably also be triggered by requesting re-scanning of both ports at the same time using SCSI sysfs interface. Fix documentation while at it. Acked-by: Alan Cox Signed-off-by: Bartlomiej Zolnierkiewicz --- earlier references: https://lkml.org/lkml/2011/2/8/110 https://lkml.org/lkml/2010/2/18/274 drivers/ata/pata_oldpiix.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/ata/pata_oldpiix.c =================================================================== --- a/drivers/ata/pata_oldpiix.c +++ b/drivers/ata/pata_oldpiix.c @@ -1,7 +1,8 @@ /* - * pata_oldpiix.c - Intel PATA/SATA controllers + * pata_oldpiix.c - older Intel PATA controller * * (C) 2005 Red Hat + * (C) 2011 Bartlomiej Zolnierkiewicz * * Some parts based on ata_piix.c by Jeff Garzik and others. * @@ -50,6 +51,8 @@ static int oldpiix_pre_reset(struct ata_ return ata_sff_prereset(link, deadline); } +static DEFINE_SPINLOCK(oldpiix_lock); + /** * oldpiix_set_piomode - Initialize host controller PATA PIO timings * @ap: Port whose timings we are configuring @@ -65,6 +68,7 @@ static void oldpiix_set_piomode (struct { unsigned int pio = adev->pio_mode - XFER_PIO_0; struct pci_dev *dev = to_pci_dev(ap->host->dev); + unsigned long flags; unsigned int idetm_port= ap->port_no ? 0x42 : 0x40; u16 idetm_data; int control = 0; @@ -91,6 +95,8 @@ static void oldpiix_set_piomode (struct if (adev->class == ATA_DEV_ATA) control |= 4; /* PPE */ + spin_lock_irqsave(&oldpiix_lock, flags); + pci_read_config_word(dev, idetm_port, &idetm_data); /* @@ -108,6 +114,8 @@ static void oldpiix_set_piomode (struct (timings[pio][1] << 8); pci_write_config_word(dev, idetm_port, idetm_data); + spin_unlock_irqrestore(&oldpiix_lock, flags); + /* Track which port is configured */ ap->private_data = adev; } @@ -126,6 +134,7 @@ static void oldpiix_set_piomode (struct static void oldpiix_set_dmamode (struct ata_port *ap, struct ata_device *adev) { struct pci_dev *dev = to_pci_dev(ap->host->dev); + unsigned long flags; u8 idetm_port = ap->port_no ? 0x42 : 0x40; u16 idetm_data; @@ -149,6 +158,8 @@ static void oldpiix_set_dmamode (struct }; int pio = needed_pio[mwdma] - XFER_PIO_0; + spin_lock_irqsave(&oldpiix_lock, flags); + pci_read_config_word(dev, idetm_port, &idetm_data); control = 3; /* IORDY|TIME0 */ @@ -175,6 +186,8 @@ static void oldpiix_set_dmamode (struct idetm_data |= (timings[pio][0] << 12) | (timings[pio][1] << 8); pci_write_config_word(dev, idetm_port, idetm_data); + spin_unlock_irqrestore(&oldpiix_lock, flags); + /* Track which port is configured */ ap->private_data = adev; }