mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 12:17:12 +09:00
ata_piix: fix locking around SIDPR access
commit 213373cf97 upstream.
SIDPR window registers are shared across ports and as each access is
done in two steps, accesses to different ports under EH may race.
This primarily is caused by incorrect host locking in EH context and
should be fixed by defining locking requirements for each EH operation
which can be used during EH and enforcing them but for now work around
the problem by adding a dedicated SIDPR lock and grabbing it for each
SIDPR access.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Mark Knecht <markknecht@gmail.com>
Reported-by: Paul Check <paul@thechecks.ca>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e8abf660c9
commit
876b3a8185
@@ -157,6 +157,7 @@ struct piix_map_db {
|
||||
struct piix_host_priv {
|
||||
const int *map;
|
||||
u32 saved_iocfg;
|
||||
spinlock_t sidpr_lock; /* FIXME: remove once locking in EH is fixed */
|
||||
void __iomem *sidpr;
|
||||
};
|
||||
|
||||
@@ -948,12 +949,15 @@ static int piix_sidpr_scr_read(struct ata_link *link,
|
||||
unsigned int reg, u32 *val)
|
||||
{
|
||||
struct piix_host_priv *hpriv = link->ap->host->private_data;
|
||||
unsigned long flags;
|
||||
|
||||
if (reg >= ARRAY_SIZE(piix_sidx_map))
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock_irqsave(&hpriv->sidpr_lock, flags);
|
||||
piix_sidpr_sel(link, reg);
|
||||
*val = ioread32(hpriv->sidpr + PIIX_SIDPR_DATA);
|
||||
spin_unlock_irqrestore(&hpriv->sidpr_lock, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -961,12 +965,15 @@ static int piix_sidpr_scr_write(struct ata_link *link,
|
||||
unsigned int reg, u32 val)
|
||||
{
|
||||
struct piix_host_priv *hpriv = link->ap->host->private_data;
|
||||
unsigned long flags;
|
||||
|
||||
if (reg >= ARRAY_SIZE(piix_sidx_map))
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock_irqsave(&hpriv->sidpr_lock, flags);
|
||||
piix_sidpr_sel(link, reg);
|
||||
iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA);
|
||||
spin_unlock_irqrestore(&hpriv->sidpr_lock, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1555,6 +1562,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
|
||||
hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
|
||||
if (!hpriv)
|
||||
return -ENOMEM;
|
||||
spin_lock_init(&hpriv->sidpr_lock);
|
||||
|
||||
/* Save IOCFG, this will be used for cable detection, quirk
|
||||
* detection and restoration on detach. This is necessary
|
||||
|
||||
Reference in New Issue
Block a user