Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge patch series "scsi: libsas: Fix the failure of adding phy with zero-address to new port"

Xingui Yang <yangxingui@huawei.com> says:

This series is to solve the problem of a BUG() when adding phy with
zero address to a new port.

Link: https://lore.kernel.org/r/20240312141103.31358-1-yangxingui@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

+30 -23
+30 -8
drivers/scsi/libsas/sas_expander.c
··· 26 26 u8 *sas_addr, int include); 27 27 static int sas_disable_routing(struct domain_device *dev, u8 *sas_addr); 28 28 29 + static void sas_port_add_ex_phy(struct sas_port *port, struct ex_phy *ex_phy) 30 + { 31 + sas_port_add_phy(port, ex_phy->phy); 32 + ex_phy->port = port; 33 + ex_phy->phy_state = PHY_DEVICE_DISCOVERED; 34 + } 35 + 36 + static void sas_ex_add_parent_port(struct domain_device *dev, int phy_id) 37 + { 38 + struct expander_device *ex = &dev->ex_dev; 39 + struct ex_phy *ex_phy = &ex->ex_phy[phy_id]; 40 + 41 + if (!ex->parent_port) { 42 + ex->parent_port = sas_port_alloc(&dev->rphy->dev, phy_id); 43 + /* FIXME: error handling */ 44 + BUG_ON(!ex->parent_port); 45 + BUG_ON(sas_port_add(ex->parent_port)); 46 + sas_port_mark_backlink(ex->parent_port); 47 + } 48 + sas_port_add_ex_phy(ex->parent_port, ex_phy); 49 + } 50 + 29 51 /* ---------- SMP task management ---------- */ 30 52 31 53 /* Give it some long enough timeout. In seconds. */ ··· 261 239 /* help some expanders that fail to zero sas_address in the 'no 262 240 * device' case 263 241 */ 264 - if (phy->attached_dev_type == SAS_PHY_UNUSED || 265 - phy->linkrate < SAS_LINK_RATE_1_5_GBPS) 242 + if (phy->attached_dev_type == SAS_PHY_UNUSED) 266 243 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); 267 244 else 268 245 memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE); ··· 878 857 879 858 if (!memcmp(phy->attached_sas_addr, ephy->attached_sas_addr, 880 859 SAS_ADDR_SIZE) && ephy->port) { 881 - sas_port_add_phy(ephy->port, phy->phy); 882 - phy->port = ephy->port; 883 - phy->phy_state = PHY_DEVICE_DISCOVERED; 860 + sas_port_add_ex_phy(ephy->port, phy); 884 861 return true; 885 862 } 886 863 } ··· 982 963 983 964 /* Parent and domain coherency */ 984 965 if (!dev->parent && sas_phy_match_port_addr(dev->port, ex_phy)) { 985 - sas_add_parent_port(dev, phy_id); 966 + sas_ex_add_parent_port(dev, phy_id); 986 967 return 0; 987 968 } 988 969 if (dev->parent && sas_phy_match_dev_addr(dev->parent, ex_phy)) { 989 - sas_add_parent_port(dev, phy_id); 970 + sas_ex_add_parent_port(dev, phy_id); 990 971 if (ex_phy->routing_attr == TABLE_ROUTING) 991 972 sas_configure_phy(dev, phy_id, dev->port->sas_addr, 1); 992 973 return 0; ··· 1868 1849 if (phy->port) { 1869 1850 sas_port_delete_phy(phy->port, phy->phy); 1870 1851 sas_device_set_phy(found, phy->port); 1871 - if (phy->port->num_phys == 0) 1852 + if (phy->port->num_phys == 0) { 1872 1853 list_add_tail(&phy->port->del_list, 1873 1854 &parent->port->sas_port_del_list); 1855 + if (ex_dev->parent_port == phy->port) 1856 + ex_dev->parent_port = NULL; 1857 + } 1874 1858 phy->port = NULL; 1875 1859 } 1876 1860 }
-15
drivers/scsi/libsas/sas_internal.h
··· 189 189 } 190 190 } 191 191 192 - static inline void sas_add_parent_port(struct domain_device *dev, int phy_id) 193 - { 194 - struct expander_device *ex = &dev->ex_dev; 195 - struct ex_phy *ex_phy = &ex->ex_phy[phy_id]; 196 - 197 - if (!ex->parent_port) { 198 - ex->parent_port = sas_port_alloc(&dev->rphy->dev, phy_id); 199 - /* FIXME: error handling */ 200 - BUG_ON(!ex->parent_port); 201 - BUG_ON(sas_port_add(ex->parent_port)); 202 - sas_port_mark_backlink(ex->parent_port); 203 - } 204 - sas_port_add_phy(ex->parent_port, ex_phy->phy); 205 - } 206 - 207 192 static inline struct domain_device *sas_alloc_device(void) 208 193 { 209 194 struct domain_device *dev = kzalloc(sizeof(*dev), GFP_KERNEL);