From: Xiang Chen chenxiang66@hisilicon.com
Use spin_lock/unlock for asd_sas_port->dev_list_lock and sas_ha->phy_port_lock.
Xiang Chen (2): {topost} scsi: libsas: Use spin_lock/unlock() for asd_sas_port->dev_list_lock {topost} scsi: libsas: Use spin_lock/unlock() for sas_ha->phy_port_lock
drivers/scsi/libsas/sas_ata.c | 4 ++-- drivers/scsi/libsas/sas_discover.c | 20 ++++++++++---------- drivers/scsi/libsas/sas_expander.c | 12 ++++++------ drivers/scsi/libsas/sas_port.c | 12 +++++------- drivers/scsi/libsas/sas_scsi_host.c | 10 ++++------ 5 files changed, 27 insertions(+), 31 deletions(-)
From: Xiang Chen chenxiang66@hisilicon.com
Spinlock asd_sas_port->dev_list_lock is used when domain_dev is added or removed. But some places use spin_lock()/spin_unlock() while other places use spin_lock_irq() /spin_unlock_irq(). Actually all those places are called in process context (workqueue) now, so use spin_lock/unlock() instead of spin_lock/unlock_irq().
Signed-off-by: Xiang Chen chenxiang66@hisilicon.com --- drivers/scsi/libsas/sas_discover.c | 16 ++++++++-------- drivers/scsi/libsas/sas_expander.c | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c index 2faa7a372284..7773b0e59877 100644 --- a/drivers/scsi/libsas/sas_discover.c +++ b/drivers/scsi/libsas/sas_discover.c @@ -152,9 +152,9 @@ static int sas_get_port_device(struct asd_sas_port *port) if (dev_is_sata(dev) || dev->dev_type == SAS_END_DEVICE) list_add_tail(&dev->disco_list_node, &port->disco_list); else { - spin_lock_irq(&port->dev_list_lock); + spin_lock(&port->dev_list_lock); list_add_tail(&dev->dev_list_node, &port->dev_list); - spin_unlock_irq(&port->dev_list_lock); + spin_unlock(&port->dev_list_lock); }
spin_lock(&port->phy_list_lock); @@ -211,9 +211,9 @@ static void sas_probe_devices(struct asd_sas_port *port)
/* devices must be domain members before link recovery and probe */ list_for_each_entry(dev, &port->disco_list, disco_list_node) { - spin_lock_irq(&port->dev_list_lock); + spin_lock(&port->dev_list_lock); list_add_tail(&dev->dev_list_node, &port->dev_list); - spin_unlock_irq(&port->dev_list_lock); + spin_unlock(&port->dev_list_lock); }
sas_probe_sata(port); @@ -321,11 +321,11 @@ static void sas_unregister_common_dev(struct asd_sas_port *port, struct domain_d else list_del_init(&dev->siblings);
- spin_lock_irq(&port->dev_list_lock); + spin_lock(&port->dev_list_lock); list_del_init(&dev->dev_list_node); if (dev_is_sata(dev)) sas_ata_end_eh(dev->sata_dev.ap); - spin_unlock_irq(&port->dev_list_lock); + spin_unlock(&port->dev_list_lock);
spin_lock_irq(&ha->lock); if (dev->dev_type == SAS_END_DEVICE && @@ -473,9 +473,9 @@ static void sas_discover_domain(struct work_struct *work) if (error) { sas_rphy_free(dev->rphy); list_del_init(&dev->disco_list_node); - spin_lock_irq(&port->dev_list_lock); + spin_lock(&port->dev_list_lock); list_del_init(&dev->dev_list_node); - spin_unlock_irq(&port->dev_list_lock); + spin_unlock(&port->dev_list_lock);
sas_put_device(dev); port->port_dev = NULL; diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index aa79ff1ff31a..58d1db404c64 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -902,9 +902,9 @@ static struct domain_device *sas_ex_discover_end_dev( out_list_del: sas_rphy_free(child->rphy); list_del(&child->disco_list_node); - spin_lock_irq(&parent->port->dev_list_lock); + spin_lock(&parent->port->dev_list_lock); list_del(&child->dev_list_node); - spin_unlock_irq(&parent->port->dev_list_lock); + spin_unlock(&parent->port->dev_list_lock); out_free: sas_port_delete(phy->port); out_err: @@ -997,16 +997,16 @@ static struct domain_device *sas_ex_discover_expander( sas_fill_in_rphy(child, rphy); sas_rphy_add(rphy);
- spin_lock_irq(&parent->port->dev_list_lock); + spin_lock(&parent->port->dev_list_lock); list_add_tail(&child->dev_list_node, &parent->port->dev_list); - spin_unlock_irq(&parent->port->dev_list_lock); + spin_unlock(&parent->port->dev_list_lock);
res = sas_discover_expander(child); if (res) { sas_rphy_delete(rphy); - spin_lock_irq(&parent->port->dev_list_lock); + spin_lock(&parent->port->dev_list_lock); list_del(&child->dev_list_node); - spin_unlock_irq(&parent->port->dev_list_lock); + spin_unlock(&parent->port->dev_list_lock); sas_put_device(child); sas_port_delete(phy->port); phy->port = NULL;
From: Xiang Chen chenxiang66@hisilicon.com
For spinlock sas_ha->phy_port_lock, some places use spin_lock_irq() / spin_unlock_irq() and other places use spin_lock_irqsave() / spin_unlock_irqrestore(). Actually all those places are called in process context (workqueue), so use spin_lock/unlock() instead.
Signed-off-by: Xiang Chen chenxiang66@hisilicon.com --- drivers/scsi/libsas/sas_ata.c | 4 ++-- drivers/scsi/libsas/sas_discover.c | 4 ++-- drivers/scsi/libsas/sas_port.c | 12 +++++------- drivers/scsi/libsas/sas_scsi_host.c | 10 ++++------ 4 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 6bd00f3809c0..937fc3d72611 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -774,7 +774,7 @@ void sas_ata_strategy_handler(struct Scsi_Host *shost) */ sas_disable_revalidation(sas_ha);
- spin_lock_irq(&sas_ha->phy_port_lock); + spin_lock(&sas_ha->phy_port_lock); for (i = 0; i < sas_ha->num_phys; i++) { struct asd_sas_port *port = sas_ha->sas_port[i]; struct domain_device *dev; @@ -794,7 +794,7 @@ void sas_ata_strategy_handler(struct Scsi_Host *shost) } spin_unlock(&port->dev_list_lock); } - spin_unlock_irq(&sas_ha->phy_port_lock); + spin_unlock(&sas_ha->phy_port_lock);
async_synchronize_full_domain(&async);
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c index 7773b0e59877..db1e1cfbdd94 100644 --- a/drivers/scsi/libsas/sas_discover.c +++ b/drivers/scsi/libsas/sas_discover.c @@ -407,12 +407,12 @@ void sas_device_set_phy(struct domain_device *dev, struct sas_port *port) new_phy = sas_port_get_phy(port);
/* pin and record last seen phy */ - spin_lock_irq(&ha->phy_port_lock); + spin_lock(&ha->phy_port_lock); if (new_phy) { sas_port_put_phy(dev->phy); dev->phy = new_phy; } - spin_unlock_irq(&ha->phy_port_lock); + spin_unlock(&ha->phy_port_lock); }
/* ---------- Discovery and Revalidation ---------- */ diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c index 67b429dcf1ff..dc17674034a3 100644 --- a/drivers/scsi/libsas/sas_port.c +++ b/drivers/scsi/libsas/sas_port.c @@ -82,7 +82,6 @@ static void sas_form_port(struct asd_sas_phy *phy) struct domain_device *port_dev; struct sas_internal *si = to_sas_internal(sas_ha->core.shost->transportt); - unsigned long flags;
if (port) { if (!phy_is_wideport_member(port, phy)) @@ -103,7 +102,7 @@ static void sas_form_port(struct asd_sas_phy *phy) }
/* see if the phy should be part of a wide port */ - spin_lock_irqsave(&sas_ha->phy_port_lock, flags); + spin_lock(&sas_ha->phy_port_lock); for (i = 0; i < sas_ha->num_phys; i++) { port = sas_ha->sas_port[i]; spin_lock(&port->phy_list_lock); @@ -133,7 +132,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
if (i >= sas_ha->num_phys) { pr_err("%s: couldn't find a free port, bug?\n", __func__); - spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); + spin_unlock(&sas_ha->phy_port_lock); return; }
@@ -156,7 +155,7 @@ static void sas_form_port(struct asd_sas_phy *phy) } else port->linkrate = max(port->linkrate, phy->linkrate); spin_unlock(&port->phy_list_lock); - spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); + spin_unlock(&sas_ha->phy_port_lock);
if (!port->port) { port->port = sas_port_alloc(phy->phy->dev.parent, port->id); @@ -203,7 +202,6 @@ void sas_deform_port(struct asd_sas_phy *phy, int gone) struct sas_internal *si = to_sas_internal(sas_ha->core.shost->transportt); struct domain_device *dev; - unsigned long flags;
if (!port) return; /* done by a phy event */ @@ -225,7 +223,7 @@ void sas_deform_port(struct asd_sas_phy *phy, int gone) if (si->dft->lldd_port_deformed) si->dft->lldd_port_deformed(phy);
- spin_lock_irqsave(&sas_ha->phy_port_lock, flags); + spin_lock(&sas_ha->phy_port_lock); spin_lock(&port->phy_list_lock);
list_del_init(&phy->port_phy_el); @@ -245,7 +243,7 @@ void sas_deform_port(struct asd_sas_phy *phy, int gone) port->phy_mask = 0; } spin_unlock(&port->phy_list_lock); - spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); + spin_unlock(&sas_ha->phy_port_lock);
/* Only insert revalidate event if the port still has members */ if (port->port && dev && dev_is_expander(dev->dev_type)) { diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index d337fdf1b9ca..7e135ad91cdc 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -371,17 +371,16 @@ struct sas_phy *sas_get_local_phy(struct domain_device *dev) { struct sas_ha_struct *ha = dev->port->ha; struct sas_phy *phy; - unsigned long flags;
/* a published domain device always has a valid phy, it may be * stale, but it is never NULL */ BUG_ON(!dev->phy);
- spin_lock_irqsave(&ha->phy_port_lock, flags); + spin_lock(&ha->phy_port_lock); phy = dev->phy; get_device(&phy->dev); - spin_unlock_irqrestore(&ha->phy_port_lock, flags); + spin_unlock(&ha->phy_port_lock);
return phy; } @@ -801,9 +800,8 @@ struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy) struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost); struct domain_device *found_dev = NULL; int i; - unsigned long flags;
- spin_lock_irqsave(&ha->phy_port_lock, flags); + spin_lock(&ha->phy_port_lock); for (i = 0; i < ha->num_phys; i++) { struct asd_sas_port *port = ha->sas_port[i]; struct domain_device *dev; @@ -819,7 +817,7 @@ struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy) spin_unlock(&port->dev_list_lock); } found: - spin_unlock_irqrestore(&ha->phy_port_lock, flags); + spin_unlock(&ha->phy_port_lock);
return found_dev; }