[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20100118171437.14623.12197.sendpatchset@localhost>
Date: Mon, 18 Jan 2010 18:14:37 +0100
From: Bartlomiej Zolnierkiewicz <bzolnier@...il.com>
To: linux-ide@...r.kernel.org
Cc: Bartlomiej Zolnierkiewicz <bzolnier@...il.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 06/64] pata_atiixp: add locking for parallel scanning
From: Bartlomiej Zolnierkiewicz <bzolnier@...il.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@...il.com>
---
drivers/ata/pata_atiixp.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
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 = {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists