Patchwork [06/64] pata_atiixp: add locking for parallel scanning

login
register
mail settings
Submitter Bartlomiej Zolnierkiewicz
Date Jan. 18, 2010, 5:14 p.m.
Message ID <20100118171437.14623.12197.sendpatchset@localhost>
Download mbox | patch
Permalink /patch/43147/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Bartlomiej Zolnierkiewicz - Jan. 18, 2010, 5:14 p.m.
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] pata_atiixp: add locking for parallel scanning

This is similar change as commit 60c3be3 for ata_piix host driver
and while pata_atiixp 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.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ata/pata_atiixp.c |   14 +++++++++++++-
 1 file changed, 13 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
Jeff Garzik - Jan. 21, 2010, 4:07 a.m.
On 01/18/2010 12:14 PM, Bartlomiej Zolnierkiewicz wrote:
> From: Bartlomiej Zolnierkiewicz<bzolnier@gmail.com>
> Subject: [PATCH] pata_atiixp: add locking for parallel scanning
>
> This is similar change as commit 60c3be3 for ata_piix host driver
> and while pata_atiixp 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.
>
> Signed-off-by: Bartlomiej Zolnierkiewicz<bzolnier@gmail.com>
> ---
>   drivers/ata/pata_atiixp.c |   14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)

did not apply to libata-dev.git#upstream, so skipped this and patch #7


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

Patch

Index: b/drivers/ata/pata_atiixp.c
===================================================================
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -1,7 +1,7 @@ 
 /*
  * pata_atiixp.c 	- ATI PATA for new ATA layer
  *			  (C) 2005 Red Hat Inc
- *			  (C) 2009 Bartlomiej Zolnierkiewicz
+ *			  (C) 2009-2010 Bartlomiej Zolnierkiewicz
  *
  * Based on
  *
@@ -71,6 +71,8 @@  static int atiixp_prereset(struct ata_li
 	return ata_sff_prereset(link, deadline);
 }
 
+static DEFINE_SPINLOCK(atiixp_lock);
+
 /**
  *	atiixp_set_piomode	-	set PIO mode data
  *	@ap: ATA interface
@@ -85,12 +87,15 @@  static void atiixp_set_piomode(struct at
 	static u8 pio_timings[5] = { 0x5D, 0x47, 0x34, 0x22, 0x20 };
 
 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+	unsigned long flags;
 	int dn = 2 * ap->port_no + adev->devno;
 	int timing_shift = (16 * ap->port_no) + 8 * (adev->devno ^ 1);
 	int pio = adev->pio_mode - XFER_PIO_0;
 	u32 pio_timing_data;
 	u16 pio_mode_data;
 
+	spin_lock_irqsave(&atiixp_lock, flags);
+
 	pci_read_config_word(pdev, ATIIXP_IDE_PIO_MODE, &pio_mode_data);
 	pio_mode_data &= ~(0x7 << (4 * dn));
 	pio_mode_data |= pio << (4 * dn);
@@ -100,6 +105,8 @@  static void atiixp_set_piomode(struct at
 	pio_timing_data &= ~(0xFF << timing_shift);
 	pio_timing_data |= (pio_timings[pio] << timing_shift);
 	pci_write_config_dword(pdev, ATIIXP_IDE_PIO_TIMING, pio_timing_data);
+
+	spin_unlock_irqrestore(&atiixp_lock, flags);
 }
 
 /**
@@ -115,10 +122,13 @@  static void atiixp_set_dmamode(struct at
 	static u8 mwdma_timings[5] = { 0x77, 0x21, 0x20 };
 
 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+	unsigned long flags;
 	int dma = adev->dma_mode;
 	int dn = 2 * ap->port_no + adev->devno;
 	u16 tmp16;
 
+	spin_lock_irqsave(&atiixp_lock, flags);
+
 	pci_read_config_word(pdev, ATIIXP_IDE_UDMA_CONTROL, &tmp16);
 
 	if (adev->dma_mode >= XFER_UDMA_0) {
@@ -149,6 +159,8 @@  static void atiixp_set_dmamode(struct at
 	}
 
 	pci_write_config_word(pdev, ATIIXP_IDE_UDMA_CONTROL, tmp16);
+
+	spin_unlock_irqrestore(&atiixp_lock, flags);
 }
 
 static struct scsi_host_template atiixp_sht = {