Commit:     423f7cf467045eab616f97309aed87a54b5e351d
Parent:     9abe16c670bd3d4ab5519257514f9f291383d104
Author:     Darrick J. Wong <[EMAIL PROTECTED]>
AuthorDate: Tue Jan 30 12:07:27 2007 -0800
Committer:  James Bottomley <[EMAIL PROTECTED]>
CommitDate: Sat Feb 3 08:15:15 2007 -0600

    [SCSI] libsas: Don't BUG when connecting two expanders via wide port
    libsas: Don't BUG when connecting two expanders via wide port
    When a device is connected to an expander, the discovery process goes 
    sas_ex_discover_dev to figure out what's attached to the phy.  If it is the
    case that the phy being discovered happens to be the second phy of a wide 
    to an expander, that discover_dev function will incorrectly call
    sas_ex_discover_expander, which creates another sas_port and tries to 
attach the
    other sas_phys to the new port, thus triggering a BUG.  The correct thing 
to do is
    to check the other ex_phys of the expander to see if there's a sas_port for 
    sas_phy, and attach the sas_phy to the existing sas_port.
    This is easily triggered if one enables the phys of a wide port between
    expanders one by one.
    This second version of the patch fixes a small regression in the case where
    all the phys show up at once and we accidentally try to attach to a port
    that hasn't been created yet.
    Signed-off-by: Darrick J. Wong <[EMAIL PROTECTED]>
    Signed-off-by: James Bottomley <[EMAIL PROTECTED]>
 drivers/scsi/libsas/sas_expander.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/libsas/sas_expander.c 
index d9b9a00..dc70c18 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -678,6 +678,29 @@ static struct domain_device *sas_ex_discover_end_dev(
        return NULL;
+/* See if this phy is part of a wide port */
+static int sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
+       struct ex_phy *phy = &parent->ex_dev.ex_phy[phy_id];
+       int i;
+       for (i = 0; i < parent->ex_dev.num_phys; i++) {
+               struct ex_phy *ephy = &parent->ex_dev.ex_phy[i];
+               if (ephy == phy)
+                       continue;
+               if (!memcmp(phy->attached_sas_addr, ephy->attached_sas_addr,
+                           SAS_ADDR_SIZE) && ephy->port) {
+                       sas_port_add_phy(ephy->port, phy->phy);
+                       phy->phy_state = PHY_DEVICE_DISCOVERED;
+                       return 0;
+               }
+       }
+       return -ENODEV;
 static struct domain_device *sas_ex_discover_expander(
        struct domain_device *parent, int phy_id)
@@ -810,6 +833,13 @@ static int sas_ex_discover_dev(struct domain_device *dev, 
int phy_id)
                return res;
+       res = sas_ex_join_wide_port(dev, phy_id);
+       if (!res) {
+               SAS_DPRINTK("Attaching ex phy%d to wide port %016llx\n",
+                           phy_id, SAS_ADDR(ex_phy->attached_sas_addr));
+               return res;
+       }
        switch (ex_phy->attached_dev_type) {
        case SAS_END_DEV:
                child = sas_ex_discover_end_dev(dev, phy_id);
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to