diff options
Diffstat (limited to 'drivers/scsi/libsas/sas_expander.c')
-rw-r--r-- | drivers/scsi/libsas/sas_expander.c | 71 |
1 files changed, 15 insertions, 56 deletions
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 9f7e2457360e..9fdb9c9fbda4 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Serial Attached SCSI (SAS) Expander discovery and configuration | 3 | * Serial Attached SCSI (SAS) Expander discovery and configuration |
3 | * | 4 | * |
@@ -5,21 +6,6 @@ | |||
5 | * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com> | 6 | * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com> |
6 | * | 7 | * |
7 | * This file is licensed under GPLv2. | 8 | * This file is licensed under GPLv2. |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License as | ||
11 | * published by the Free Software Foundation; either version 2 of the | ||
12 | * License, or (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | * | ||
23 | */ | 9 | */ |
24 | 10 | ||
25 | #include <linux/scatterlist.h> | 11 | #include <linux/scatterlist.h> |
@@ -1106,7 +1092,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id) | |||
1106 | SAS_ADDR(dev->sas_addr), | 1092 | SAS_ADDR(dev->sas_addr), |
1107 | phy_id); | 1093 | phy_id); |
1108 | sas_ex_disable_phy(dev, phy_id); | 1094 | sas_ex_disable_phy(dev, phy_id); |
1109 | break; | 1095 | return res; |
1110 | } else | 1096 | } else |
1111 | memcpy(dev->port->disc.fanout_sas_addr, | 1097 | memcpy(dev->port->disc.fanout_sas_addr, |
1112 | ex_phy->attached_sas_addr, SAS_ADDR_SIZE); | 1098 | ex_phy->attached_sas_addr, SAS_ADDR_SIZE); |
@@ -1118,27 +1104,9 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id) | |||
1118 | break; | 1104 | break; |
1119 | } | 1105 | } |
1120 | 1106 | ||
1121 | if (child) { | 1107 | if (!child) |
1122 | int i; | 1108 | pr_notice("ex %016llx phy%02d failed to discover\n", |
1123 | 1109 | SAS_ADDR(dev->sas_addr), phy_id); | |
1124 | for (i = 0; i < ex->num_phys; i++) { | ||
1125 | if (ex->ex_phy[i].phy_state == PHY_VACANT || | ||
1126 | ex->ex_phy[i].phy_state == PHY_NOT_PRESENT) | ||
1127 | continue; | ||
1128 | /* | ||
1129 | * Due to races, the phy might not get added to the | ||
1130 | * wide port, so we add the phy to the wide port here. | ||
1131 | */ | ||
1132 | if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) == | ||
1133 | SAS_ADDR(child->sas_addr)) { | ||
1134 | ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED; | ||
1135 | if (sas_ex_join_wide_port(dev, i)) | ||
1136 | pr_debug("Attaching ex phy%02d to wide port %016llx\n", | ||
1137 | i, SAS_ADDR(ex->ex_phy[i].attached_sas_addr)); | ||
1138 | } | ||
1139 | } | ||
1140 | } | ||
1141 | |||
1142 | return res; | 1110 | return res; |
1143 | } | 1111 | } |
1144 | 1112 | ||
@@ -1154,8 +1122,7 @@ static int sas_find_sub_addr(struct domain_device *dev, u8 *sub_addr) | |||
1154 | phy->phy_state == PHY_NOT_PRESENT) | 1122 | phy->phy_state == PHY_NOT_PRESENT) |
1155 | continue; | 1123 | continue; |
1156 | 1124 | ||
1157 | if ((phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1125 | if (dev_is_expander(phy->attached_dev_type) && |
1158 | phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE) && | ||
1159 | phy->routing_attr == SUBTRACTIVE_ROUTING) { | 1126 | phy->routing_attr == SUBTRACTIVE_ROUTING) { |
1160 | 1127 | ||
1161 | memcpy(sub_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); | 1128 | memcpy(sub_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); |
@@ -1173,8 +1140,7 @@ static int sas_check_level_subtractive_boundary(struct domain_device *dev) | |||
1173 | u8 sub_addr[SAS_ADDR_SIZE] = {0, }; | 1140 | u8 sub_addr[SAS_ADDR_SIZE] = {0, }; |
1174 | 1141 | ||
1175 | list_for_each_entry(child, &ex->children, siblings) { | 1142 | list_for_each_entry(child, &ex->children, siblings) { |
1176 | if (child->dev_type != SAS_EDGE_EXPANDER_DEVICE && | 1143 | if (!dev_is_expander(child->dev_type)) |
1177 | child->dev_type != SAS_FANOUT_EXPANDER_DEVICE) | ||
1178 | continue; | 1144 | continue; |
1179 | if (sub_addr[0] == 0) { | 1145 | if (sub_addr[0] == 0) { |
1180 | sas_find_sub_addr(child, sub_addr); | 1146 | sas_find_sub_addr(child, sub_addr); |
@@ -1259,8 +1225,7 @@ static int sas_check_ex_subtractive_boundary(struct domain_device *dev) | |||
1259 | phy->phy_state == PHY_NOT_PRESENT) | 1225 | phy->phy_state == PHY_NOT_PRESENT) |
1260 | continue; | 1226 | continue; |
1261 | 1227 | ||
1262 | if ((phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE || | 1228 | if (dev_is_expander(phy->attached_dev_type) && |
1263 | phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE) && | ||
1264 | phy->routing_attr == SUBTRACTIVE_ROUTING) { | 1229 | phy->routing_attr == SUBTRACTIVE_ROUTING) { |
1265 | 1230 | ||
1266 | if (!sub_sas_addr) | 1231 | if (!sub_sas_addr) |
@@ -1356,8 +1321,7 @@ static int sas_check_parent_topology(struct domain_device *child) | |||
1356 | if (!child->parent) | 1321 | if (!child->parent) |
1357 | return 0; | 1322 | return 0; |
1358 | 1323 | ||
1359 | if (child->parent->dev_type != SAS_EDGE_EXPANDER_DEVICE && | 1324 | if (!dev_is_expander(child->parent->dev_type)) |
1360 | child->parent->dev_type != SAS_FANOUT_EXPANDER_DEVICE) | ||
1361 | return 0; | 1325 | return 0; |
1362 | 1326 | ||
1363 | parent_ex = &child->parent->ex_dev; | 1327 | parent_ex = &child->parent->ex_dev; |
@@ -1653,8 +1617,7 @@ static int sas_ex_level_discovery(struct asd_sas_port *port, const int level) | |||
1653 | struct domain_device *dev; | 1617 | struct domain_device *dev; |
1654 | 1618 | ||
1655 | list_for_each_entry(dev, &port->dev_list, dev_list_node) { | 1619 | list_for_each_entry(dev, &port->dev_list, dev_list_node) { |
1656 | if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1620 | if (dev_is_expander(dev->dev_type)) { |
1657 | dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { | ||
1658 | struct sas_expander_device *ex = | 1621 | struct sas_expander_device *ex = |
1659 | rphy_to_expander_device(dev->rphy); | 1622 | rphy_to_expander_device(dev->rphy); |
1660 | 1623 | ||
@@ -1886,7 +1849,7 @@ static int sas_find_bcast_dev(struct domain_device *dev, | |||
1886 | SAS_ADDR(dev->sas_addr)); | 1849 | SAS_ADDR(dev->sas_addr)); |
1887 | } | 1850 | } |
1888 | list_for_each_entry(ch, &ex->children, siblings) { | 1851 | list_for_each_entry(ch, &ex->children, siblings) { |
1889 | if (ch->dev_type == SAS_EDGE_EXPANDER_DEVICE || ch->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { | 1852 | if (dev_is_expander(ch->dev_type)) { |
1890 | res = sas_find_bcast_dev(ch, src_dev); | 1853 | res = sas_find_bcast_dev(ch, src_dev); |
1891 | if (*src_dev) | 1854 | if (*src_dev) |
1892 | return res; | 1855 | return res; |
@@ -1903,8 +1866,7 @@ static void sas_unregister_ex_tree(struct asd_sas_port *port, struct domain_devi | |||
1903 | 1866 | ||
1904 | list_for_each_entry_safe(child, n, &ex->children, siblings) { | 1867 | list_for_each_entry_safe(child, n, &ex->children, siblings) { |
1905 | set_bit(SAS_DEV_GONE, &child->state); | 1868 | set_bit(SAS_DEV_GONE, &child->state); |
1906 | if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1869 | if (dev_is_expander(child->dev_type)) |
1907 | child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) | ||
1908 | sas_unregister_ex_tree(port, child); | 1870 | sas_unregister_ex_tree(port, child); |
1909 | else | 1871 | else |
1910 | sas_unregister_dev(port, child); | 1872 | sas_unregister_dev(port, child); |
@@ -1924,8 +1886,7 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent, | |||
1924 | if (SAS_ADDR(child->sas_addr) == | 1886 | if (SAS_ADDR(child->sas_addr) == |
1925 | SAS_ADDR(phy->attached_sas_addr)) { | 1887 | SAS_ADDR(phy->attached_sas_addr)) { |
1926 | set_bit(SAS_DEV_GONE, &child->state); | 1888 | set_bit(SAS_DEV_GONE, &child->state); |
1927 | if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1889 | if (dev_is_expander(child->dev_type)) |
1928 | child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) | ||
1929 | sas_unregister_ex_tree(parent->port, child); | 1890 | sas_unregister_ex_tree(parent->port, child); |
1930 | else | 1891 | else |
1931 | sas_unregister_dev(parent->port, child); | 1892 | sas_unregister_dev(parent->port, child); |
@@ -1954,8 +1915,7 @@ static int sas_discover_bfs_by_root_level(struct domain_device *root, | |||
1954 | int res = 0; | 1915 | int res = 0; |
1955 | 1916 | ||
1956 | list_for_each_entry(child, &ex_root->children, siblings) { | 1917 | list_for_each_entry(child, &ex_root->children, siblings) { |
1957 | if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1918 | if (dev_is_expander(child->dev_type)) { |
1958 | child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { | ||
1959 | struct sas_expander_device *ex = | 1919 | struct sas_expander_device *ex = |
1960 | rphy_to_expander_device(child->rphy); | 1920 | rphy_to_expander_device(child->rphy); |
1961 | 1921 | ||
@@ -2008,8 +1968,7 @@ static int sas_discover_new(struct domain_device *dev, int phy_id) | |||
2008 | list_for_each_entry(child, &dev->ex_dev.children, siblings) { | 1968 | list_for_each_entry(child, &dev->ex_dev.children, siblings) { |
2009 | if (SAS_ADDR(child->sas_addr) == | 1969 | if (SAS_ADDR(child->sas_addr) == |
2010 | SAS_ADDR(ex_phy->attached_sas_addr)) { | 1970 | SAS_ADDR(ex_phy->attached_sas_addr)) { |
2011 | if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1971 | if (dev_is_expander(child->dev_type)) |
2012 | child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) | ||
2013 | res = sas_discover_bfs_by_root(child); | 1972 | res = sas_discover_bfs_by_root(child); |
2014 | break; | 1973 | break; |
2015 | } | 1974 | } |