All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pata_oldpiix: add locking for parallel scanning
@ 2011-10-13 14:02 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; only message in thread
From: Bartlomiej Zolnierkiewicz @ 2011-10-13 14:02 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-ide, linux-kernel

From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
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 <alan@linux.intel.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
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(-)

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;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-10-13 14:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-13 14:02 [PATCH 1/2] pata_oldpiix: add locking for parallel scanning Bartlomiej Zolnierkiewicz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.