libsas: fix lockdep issue with ATA
Subsystems (2)
PATCH 1/1 libsas: fix lockdep issue with ATA
lockdep noticed that with ATA support the port->dev_list_lock was entangled at irq context, so it now needs to become IRQ safe
---
This applies against the aic94xx-sas-2.6 tree
James
drivers/scsi/libsas/sas_discover.c +6 -4
@@ -292,9 +292,9 @@ static int sas_get_port_device(struct asd_sas_port *port) port->disc.max_level =0 ; dev->rphy = rphy; -spin_lock (&port->dev_list_lock); +spin_lock_irqsave (&port->dev_list_lock, flags);list_add_tail (&dev->dev_list_node, &port->dev_list); -spin_unlock (&port->dev_list_lock); +spin_unlock_irqrestore (&port->dev_list_lock, flags);return 0 ; }
@@ -688,12 +688,14 @@ static void sas_discover_domain(struct work_struct *work) }if (error) { +unsigned long flags; +sas_rphy_free (dev->rphy); dev->rphy =NULL ; -spin_lock (&port->dev_list_lock); +spin_lock_irqsave (&port->dev_list_lock, flags);list_del_init (&dev->dev_list_node); -spin_unlock (&port->dev_list_lock); +spin_unlock_irqrestore (&port->dev_list_lock, flags);kfree (dev);/* not kobject_register-ed yet */ port->port_dev =NULL ;
drivers/scsi/libsas/sas_expander.c +8 -6
@@ -628,6 +628,7 @@ static struct domain_device *sas_ex_discover_end_dev(struct domain_device *child =NULL ;struct sas_rphy *rphy;int res; +unsigned long flags;if (phy->attached_sata_host || phy->attached_sata_ps)return NULL ;
@@ -677,9 +678,9 @@ static struct domain_device *sas_ex_discover_end_dev( child->rphy = rphy; -spin_lock (&parent->port->dev_list_lock); +spin_lock_irqsave (&parent->port->dev_list_lock, flags);list_add_tail (&child->dev_list_node, &parent->port->dev_list); -spin_unlock (&parent->port->dev_list_lock); +spin_unlock_irqrestore (&parent->port->dev_list_lock, flags); res =sas_discover_sata (child);if (res) {
@@ -701,9 +702,9 @@ static struct domain_device *sas_ex_discover_end_dev( child->rphy = rphy;sas_fill_in_rphy (child, rphy); -spin_lock (&parent->port->dev_list_lock); +spin_lock_irqsave (&parent->port->dev_list_lock, flags);list_add_tail (&child->dev_list_node, &parent->port->dev_list); -spin_unlock (&parent->port->dev_list_lock); +spin_unlock_irqrestore (&parent->port->dev_list_lock, flags); res =sas_discover_end_dev (child);if (res) {
@@ -767,6 +768,7 @@ static struct domain_device *sas_ex_discover_expander(struct sas_expander_device *edev;struct asd_sas_port *port;int res; +unsigned long flags;if (phy->routing_attr ==DIRECT_ROUTING ) { SAS_DPRINTK("ex %016llx:0x%x:D <--> ex %016llx:0x%x is not "
@@ -816,9 +818,9 @@ static struct domain_device *sas_ex_discover_expander(sas_fill_in_rphy (child, rphy);sas_rphy_add (rphy); -spin_lock (&parent->port->dev_list_lock); +spin_lock_irqsave (&parent->port->dev_list_lock, flags);list_add_tail (&child->dev_list_node, &parent->port->dev_list); -spin_unlock (&parent->port->dev_list_lock); +spin_unlock_irqrestore (&parent->port->dev_list_lock, flags); res =sas_discover_expander (child);if (res) {
Quoted 14 lines · James Bottomley
lockdep noticed that with ATA support the
port->dev_list_lockwas entangled at irq context, so it now needs to become IRQ safe---
This applies against the aic94xx-sas-2.6 treeJames
drivers/scsi/libsas/sas_discover.c +0
-0@@ -292,9 +292,9 @@ static int sas_get_port_device(struct asd_sas_port *port) port->disc.max_level =0 ;
drivers/scsi/libsas/sas_discover.c static int sas_get_port_device(struct asd_sas_port *port) · line 300
Quoted 10 lines
drivers/scsi/libsas/sas_discover.c +2
-2dev->rphy = rphy; -spin_lock (&port->dev_list_lock); +spin_lock_irqsave (&port->dev_list_lock, flags);list_add_tail (&dev->dev_list_node, &port->dev_list); -spin_unlock (&port->dev_list_lock); +spin_unlock_irqrestore (&port->dev_list_lock, flags);return 0 ; }
already uses GFP_KERNEL, so spin_lock_irq() suffices.
Quoted 7 lines
drivers/scsi/libsas/sas_discover.c +2
-0@@ -688,12 +688,14 @@ static void sas_discover_domain(struct work_struct *work) }if (error) { +unsigned long flags; +sas_rphy_free (dev->rphy);
drivers/scsi/libsas/sas_discover.c static void sas_discover_domain(struct work_struct *work) · line 701
Quoted 10 lines
drivers/scsi/libsas/sas_discover.c +2
-2dev->rphy =NULL ; -spin_lock (&port->dev_list_lock); +spin_lock_irqsave (&port->dev_list_lock, flags);list_del_init (&dev->dev_list_node); -spin_unlock (&port->dev_list_lock); +spin_unlock_irqrestore (&port->dev_list_lock, flags);kfree (dev);/* not kobject_register-ed yet */ port->port_dev =NULL ;
process context, no need to save flags here either.
Quoted 14 lines
drivers/scsi/libsas/sas_expander.c +1
-0@@ -628,6 +628,7 @@ static struct domain_device *sas_ex_discover_end_dev(struct domain_device *child =NULL ;struct sas_rphy *rphy;int res; +unsigned long flags;if (phy->attached_sata_host || phy->attached_sata_ps)return NULL ;@@ -677,9 +678,9 @@ static struct domain_device *sas_ex_discover_end_dev(
drivers/scsi/libsas/sas_expander.c static struct domain_device *sas_ex_discover_end_dev( · line 686
Quoted 10 lines
drivers/scsi/libsas/sas_expander.c +2
-2child->rphy = rphy; -spin_lock (&parent->port->dev_list_lock); +spin_lock_irqsave (&parent->port->dev_list_lock, flags);list_add_tail (&child->dev_list_node, &parent->port->dev_list); -spin_unlock (&parent->port->dev_list_lock); +spin_unlock_irqrestore (&parent->port->dev_list_lock, flags); res =sas_discover_sata (child);if (res) {
ditto
drivers/scsi/libsas/sas_expander.c static struct domain_device *sas_ex_discover_end_dev( · line 710
Quoted 12 lines
drivers/scsi/libsas/sas_expander.c +2
-2@@ -701,9 +702,9 @@ static struct domain_device *sas_ex_discover_end_dev( child->rphy = rphy;sas_fill_in_rphy (child, rphy); -spin_lock (&parent->port->dev_list_lock); +spin_lock_irqsave (&parent->port->dev_list_lock, flags);list_add_tail (&child->dev_list_node, &parent->port->dev_list); -spin_unlock (&parent->port->dev_list_lock); +spin_unlock_irqrestore (&parent->port->dev_list_lock, flags); res =sas_discover_end_dev (child);if (res) {
ditto
Quoted 10 lines
drivers/scsi/libsas/sas_expander.c +1
-0@@ -767,6 +768,7 @@ static struct domain_device *sas_ex_discover_expander(struct sas_expander_device *edev;struct asd_sas_port *port;int res; +unsigned long flags;if (phy->routing_attr ==DIRECT_ROUTING ) { SAS_DPRINTK("ex %016llx:0x%x:D <--> ex %016llx:0x%x is not "@@ -816,9 +818,9 @@ static struct domain_device *sas_ex_discover_expander(sas_fill_in_rphy (child, rphy);
drivers/scsi/libsas/sas_expander.c static struct domain_device *sas_ex_discover_expander( · line 826
Quoted 10 lines
drivers/scsi/libsas/sas_expander.c +2
-2sas_rphy_add (rphy); -spin_lock (&parent->port->dev_list_lock); +spin_lock_irqsave (&parent->port->dev_list_lock, flags);list_add_tail (&child->dev_list_node, &parent->port->dev_list); -spin_unlock (&parent->port->dev_list_lock); +spin_unlock_irqrestore (&parent->port->dev_list_lock, flags); res =sas_discover_expander (child);if (res) {
ditto :-)
Signature · 1 line
Jens Axboe
Quoted 43 lines · Jens Axboe
Quoted 14 lines · James Bottomley
lockdep noticed that with ATA support the
port->dev_list_lockwas entangled at irq context, so it now needs to become IRQ safe---
This applies against the aic94xx-sas-2.6 treeJames
drivers/scsi/libsas/sas_discover.c +0
-0@@ -292,9 +292,9 @@ static int sas_get_port_device(struct asd_sas_port *port) port->disc.max_level =0 ;drivers/scsi/libsas/sas_discover.c static int sas_get_port_device(struct asd_sas_port *port) · line 300
Quoted 10 lines
drivers/scsi/libsas/sas_discover.c +2
-2dev->rphy = rphy; -spin_lock (&port->dev_list_lock); +spin_lock_irqsave (&port->dev_list_lock, flags);list_add_tail (&dev->dev_list_node, &port->dev_list); -spin_unlock (&port->dev_list_lock); +spin_unlock_irqrestore (&port->dev_list_lock, flags);return 0 ; }already uses
GFP_KERNEL, sospin_lock_irq()suffices.Quoted 15 lines
drivers/scsi/libsas/sas_discover.c +4
-2@@ -688,12 +688,14 @@ static void sas_discover_domain(struct work_struct *work) }if (error) { +unsigned long flags; +sas_rphy_free (dev->rphy); dev->rphy =NULL ; -spin_lock (&port->dev_list_lock); +spin_lock_irqsave (&port->dev_list_lock, flags);list_del_init (&dev->dev_list_node); -spin_unlock (&port->dev_list_lock); +spin_unlock_irqrestore (&port->dev_list_lock, flags);
Quoted 4 lines
drivers/scsi/libsas/sas_discover.c static void sas_discover_domain(struct work_struct *work) · line 701
Quoted 2 lines
drivers/scsi/libsas/sas_discover.c +0
-0kfree (dev);/* not kobject_register-ed yet */ port->port_dev =NULL ;process context, no need to save flags here either.
OK, you caught me ... I was just doing the fastest thing I could to get lockdep to shut up. By the way, it dumps about 120KB of logs so it's fun to get an actual trace of this...
I'll make the fixes and resubmit
James
Quoted 7 lines · James Bottomley
Quoted 1 line
process context, no need to save flags here either.
OK, you caught me ... I was just doing the fastest thing I could to get lockdep to shut up. By the way, it dumps about 120KB of logs so it's fun to get an actual trace of this...
I'll make the fixes and resubmit
Here's the update.
James
---
Quoted 1 line
From
0852ea7aafd0368026e8dacd7810c2444adb8d19Mon Sep 17 00:00:00 2001
From: James Bottomley <[email protected]>
Date: Mon, 16 Jul 2007 13:15:51 -0500
Subject: [SCSI] libsas: fix lockdep issue with ATA
lockdep noticed that with ATA support the port->dev_list_lock was entangled at irq context, so it now needs to become IRQ safe
--- drivers/scsi/libsas/sas_discover.c | 10 ++++++---- drivers/scsi/libsas/sas_expander.c | 14 ++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-)
drivers/scsi/libsas/sas_discover.c +4 -4
@@ -304,9 +304,9 @@ static int sas_get_port_device(struct as port->disc.max_level =0 ; dev->rphy = rphy; -spin_lock (&port->dev_list_lock); +spin_lock_irq (&port->dev_list_lock);list_add_tail (&dev->dev_list_node, &port->dev_list); -spin_unlock (&port->dev_list_lock); +spin_unlock_irq (&port->dev_list_lock);return 0 ; }
@@ -703,9 +703,9 @@ static void sas_discover_domain(struct wsas_rphy_free (dev->rphy); dev->rphy =NULL ; -spin_lock (&port->dev_list_lock); +spin_lock_irq (&port->dev_list_lock);list_del_init (&dev->dev_list_node); -spin_unlock (&port->dev_list_lock); +spin_unlock_irq (&port->dev_list_lock);kfree (dev);/* not kobject_register-ed yet */ port->port_dev =NULL ;
drivers/scsi/libsas/sas_expander.c +6 -6
@@ -677,9 +677,9 @@ static struct domain_device *sas_ex_disc child->rphy = rphy; -spin_lock (&parent->port->dev_list_lock); +spin_lock_irq (&parent->port->dev_list_lock);list_add_tail (&child->dev_list_node, &parent->port->dev_list); -spin_unlock (&parent->port->dev_list_lock); +spin_unlock_irq (&parent->port->dev_list_lock); res =sas_discover_sata (child);if (res) {
@@ -701,9 +701,9 @@ static struct domain_device *sas_ex_disc child->rphy = rphy;sas_fill_in_rphy (child, rphy); -spin_lock (&parent->port->dev_list_lock); +spin_lock_irq (&parent->port->dev_list_lock);list_add_tail (&child->dev_list_node, &parent->port->dev_list); -spin_unlock (&parent->port->dev_list_lock); +spin_unlock_irq (&parent->port->dev_list_lock); res =sas_discover_end_dev (child);if (res) {
@@ -816,9 +816,9 @@ static struct domain_device *sas_ex_discsas_fill_in_rphy (child, rphy);sas_rphy_add (rphy); -spin_lock (&parent->port->dev_list_lock); +spin_lock_irq (&parent->port->dev_list_lock);list_add_tail (&child->dev_list_node, &parent->port->dev_list); -spin_unlock (&parent->port->dev_list_lock); +spin_unlock_irq (&parent->port->dev_list_lock); res =sas_discover_expander (child);if (res) {
Quoted 10 lines · James Bottomley
Quoted 7 lines · James Bottomley
Quoted 1 line
process context, no need to save flags here either.
OK, you caught me ... I was just doing the fastest thing I could to get lockdep to shut up. By the way, it dumps about 120KB of logs so it's fun to get an actual trace of this...
I'll make the fixes and resubmit
Here's the update.
Looks good James :-)
Signature · 1 line
Jens Axboe