phy->attached_sata_ps = dr->attached_sata_ps;
phy->attached_iproto = dr->iproto << 1;
phy->attached_tproto = dr->tproto << 1;
- /* help some expanders that fail to zero sas_address in the 'no
- * device' case
- */
- if (phy->attached_dev_type == NO_DEVICE ||
- phy->linkrate < SAS_LINK_RATE_1_5_GBPS)
- memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
- else
- memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);
+ memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);
phy->attached_phy_id = dr->attached_phy_id;
phy->phy_change_count = dr->change_count;
phy->routing_attr = dr->routing_attr;
phy->virtual = dr->virtual;
phy->last_da_index = -1;
- phy->phy->identify.sas_address = SAS_ADDR(phy->attached_sas_addr);
- phy->phy->identify.device_type = phy->attached_dev_type;
phy->phy->identify.initiator_port_protocols = phy->attached_iproto;
phy->phy->identify.target_port_protocols = phy->attached_tproto;
phy->phy->identify.phy_identifier = phy_id;
}
/* See if this phy is part of a wide port */
-static bool sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
+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;
sas_port_add_phy(ephy->port, phy->phy);
phy->port = ephy->port;
phy->phy_state = PHY_DEVICE_DISCOVERED;
- return true;
+ return 0;
}
}
- return false;
+ return -ENODEV;
}
static struct domain_device *sas_ex_discover_expander(
res = sas_discover_expander(child);
if (res) {
- spin_lock_irq(&parent->port->dev_list_lock);
- list_del(&child->dev_list_node);
- spin_unlock_irq(&parent->port->dev_list_lock);
kfree(child);
return NULL;
}
return res;
}
- if (sas_ex_join_wide_port(dev, phy_id)) {
+ 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;
if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) ==
SAS_ADDR(child->sas_addr)) {
ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED;
- if (sas_ex_join_wide_port(dev, i))
+ res = sas_ex_join_wide_port(dev, i);
+ if (!res)
SAS_DPRINTK("Attaching ex phy%d to wide port %016llx\n",
i, SAS_ADDR(ex->ex_phy[i].attached_sas_addr));
int phy_change_count = 0;
res = sas_get_phy_change_count(dev, i, &phy_change_count);
- switch (res) {
- case SMP_RESP_PHY_VACANT:
- case SMP_RESP_NO_PHY:
- continue;
- case SMP_RESP_FUNC_ACC:
- break;
- default:
- return res;
- }
-
- if (phy_change_count != ex->ex_phy[i].phy_change_count) {
+ if (res)
+ goto out;
+ else if (phy_change_count != ex->ex_phy[i].phy_change_count) {
if (update)
ex->ex_phy[i].phy_change_count =
phy_change_count;
return 0;
}
}
- return 0;
+out:
+ return res;
}
static int sas_get_ex_change_count(struct domain_device *dev, int *ecc)
list_for_each_entry(ch, &ex->children, siblings) {
if (ch->dev_type == EDGE_DEV || ch->dev_type == FANOUT_DEV) {
res = sas_find_bcast_dev(ch, src_dev);
- if (*src_dev)
+ if (src_dev)
return res;
}
}
sas_disable_routing(parent, phy->attached_sas_addr);
}
memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
- if (phy->port) {
- sas_port_delete_phy(phy->port, phy->phy);
- if (phy->port->num_phys == 0)
- sas_port_delete(phy->port);
- phy->port = NULL;
- }
+ sas_port_delete_phy(phy->port, phy->phy);
+ if (phy->port->num_phys == 0)
+ sas_port_delete(phy->port);
+ phy->port = NULL;
}
static int sas_discover_bfs_by_root_level(struct domain_device *root,
{
struct ex_phy *ex_phy = &dev->ex_dev.ex_phy[phy_id];
struct domain_device *child;
- int res;
+ bool found = false;
+ int res, i;
SAS_DPRINTK("ex %016llx phy%d new device attached\n",
SAS_ADDR(dev->sas_addr), phy_id);
res = sas_ex_phy_discover(dev, phy_id);
if (res)
- return res;
-
- if (sas_ex_join_wide_port(dev, phy_id))
+ goto out;
+ /* to support the wide port inserted */
+ for (i = 0; i < dev->ex_dev.num_phys; i++) {
+ struct ex_phy *ex_phy_temp = &dev->ex_dev.ex_phy[i];
+ if (i == phy_id)
+ continue;
+ if (SAS_ADDR(ex_phy_temp->attached_sas_addr) ==
+ SAS_ADDR(ex_phy->attached_sas_addr)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ sas_ex_join_wide_port(dev, phy_id);
return 0;
-
+ }
res = sas_ex_discover_devices(dev, phy_id);
- if (res)
- return res;
+ if (!res)
+ goto out;
list_for_each_entry(child, &dev->ex_dev.children, siblings) {
if (SAS_ADDR(child->sas_addr) ==
SAS_ADDR(ex_phy->attached_sas_addr)) {
break;
}
}
+out:
return res;
}
struct domain_device *dev = NULL;
res = sas_find_bcast_dev(port_dev, &dev);
- while (res == 0 && dev) {
+ if (res)
+ goto out;
+ if (dev) {
struct expander_device *ex = &dev->ex_dev;
int i = 0, phy_id;
res = sas_rediscover(dev, phy_id);
i = phy_id + 1;
} while (i < ex->num_phys);
-
- dev = NULL;
- res = sas_find_bcast_dev(port_dev, &dev);
}
+out:
return res;
}