scsi: libsas: Fix the failure of adding phy with zero-address to port
Subsystems (2)
PATCH v4 1/1 scsi: libsas: Fix the failure of adding phy with zero-address to port
When connecting to the epander device, first disable and then enable the local phy. The following BUG() will be triggered with a small probability:
[562240.051046] sas: phy19 part of wide port with phy16 [562240.051197] sas: ex 500e004aaaaaaa1f phy19:U:0 attached: 0000000000000000 (no device) [562240.051203] sas: done REVALIDATING DOMAIN on port 0, pid:435909, res 0x0 <...> [562240.062536] sas: ex 500e004aaaaaaa1f phy0 new device attached [562240.062616] sas: ex 500e004aaaaaaa1f phy00:U:5 attached: 0000000000000000 (stp) [562240.062680] port-7:7:0: trying to add phy phy-7:7:19 fails: it's already part of another port [562240.085064] ------------[ cut here ]------------ [562240.096612] kernel BUG at drivers/scsi/scsi_transport_sas.c:1083! [562240.109611] Internal error: Oops - BUG: 0 [#1] SMP [562240.343518] Process kworker/u256:3 (pid: 435909, stack limit = 0x0000000003bcbebf) [562240.421714] Workqueue: 0000:b4:02.0_disco_q sas_revalidate_domain [libsas] [562240.437173] pstate: 40c00009 (nZcv daif +PAN +UAO) [562240.450478] pc : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.465283] lr : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.479751] sp : ffff0000300cfa70 [562240.674822] Call trace: [562240.682709] sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.694013] sas_ex_get_linkrate.isra.5+0xcc/0x128 [libsas] [562240.704957] sas_ex_discover_end_dev+0xfc/0x538 [libsas] [562240.715508] sas_ex_discover_dev+0x3cc/0x4b8 [libsas] [562240.725634] sas_ex_discover_devices+0x9c/0x1a8 [libsas] [562240.735855] sas_ex_revalidate_domain+0x2f0/0x450 [libsas] [562240.746123] sas_revalidate_domain+0x158/0x160 [libsas] [562240.756014] process_one_work+0x1b4/0x448 [562240.764548] worker_thread+0x54/0x468 [562240.772562] kthread+0x134/0x138 [562240.779989] ret_from_fork+0x10/0x18
What causes this problem:
1. When phy19 was initially added to the parent port, ex_phy->port was not set. As a result, when phy19 was removed from the parent wide port, it was not deleted from the phy_list of the parent port.
2. The rate of the newly connected SATA device to phy0 is less than 1.5G, and its sas_address was set to 0. After creating port 7:7:0, it attempts to add the expander's other zero-addressed phy to this port.
3. When adding phy19 to port-7:7:0, it is prompted that phy19 already belongs to another port, which triggers the current problem.
Fix the problem as follows:
1. When ex_phy is added to the parent port, set ex_phy->port to ex_dev->parent_port.
2. Set ex_dev->parent_port to NULL when the parent port's PHY count is 0.
3. When phy->attached_dev_type != NO_DEVICE, do not set the zero address for phy->attached_sas_addr.
---
v3 -> v4:
1. Update patch title and comments based on John's suggestion.
v2 -> v3:
1. Set ex_dev->parent_port to NULL when the number of PHYs of the parent port becomes 0
2. Update the comments
v1 -> v2:
1. Set ex_phy->port with parent_port when ex_phy is added to the parent port
2. Set ex_phy to NULL when free expander
3. Update the comments
--- drivers/scsi/libsas/sas_discover.c | 4 +++- drivers/scsi/libsas/sas_expander.c | 8 +++++--- drivers/scsi/libsas/sas_internal.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-)
drivers/scsi/libsas/sas_discover.c +3 -1
@@ -296,8 +296,10 @@ void sas_free_device(struct kref *kref) dev->phy =NULL ;/* remove the phys and ports, everything else should be gone */ -if (dev_is_expander (dev->dev_type)) +if (dev_is_expander (dev->dev_type)) {kfree (dev->ex_dev.ex_phy); + dev->ex_dev.ex_phy =NULL ; + }if (dev_is_sata (dev) && dev->sata_dev.ap) {ata_sas_tport_delete (dev->sata_dev.ap);
drivers/scsi/libsas/sas_expander.c +5 -3
@@ -239,8 +239,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id,/* help some expanders that fail to zero sas_address in the 'no * device' case */ -if (phy->attached_dev_type ==SAS_PHY_UNUSED || - phy->linkrate <SAS_LINK_RATE_1_5_GBPS ) +if (phy->attached_dev_type ==SAS_PHY_UNUSED )memset (phy->attached_sas_addr,0 ,SAS_ADDR_SIZE );else memcpy (phy->attached_sas_addr, dr->attached_sas_addr,SAS_ADDR_SIZE );
@@ -1844,9 +1843,12 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent,if (phy->port) {sas_port_delete_phy (phy->port, phy->phy);sas_device_set_phy (found, phy->port); -if (phy->port->num_phys ==0 ) +if (phy->port->num_phys ==0 ) {list_add_tail (&phy->port->del_list, &parent->port->sas_port_del_list); +if (ex_dev->parent_port == phy->port) + ex_dev->parent_port =NULL ; + } phy->port =NULL ; } }
drivers/scsi/libsas/sas_internal.h +1 -0
@@ -202,6 +202,7 @@ static inline void sas_add_parent_port(struct domain_device *dev, int phy_id)sas_port_mark_backlink (ex->parent_port); }sas_port_add_phy (ex->parent_port, ex_phy->phy); + ex_phy->port = ex->parent_port; }static inline struct domain_device *sas_alloc_device (void )
Signature · 1 line
2.17.1
John Garry
reviewerOn 17/11/2023 09:00, Xingui Yang wrote:
Sorry for being slow to come back to this. However I still have questions...
Quoted 1 line
When connecting to the epander device, first disable and then enable the
/s/epander/expander/
And connecting what to the expander? Is it a SATA disk?
Or the SATA disk is already attached to the expander and we are now attaching the expander to the host?
It is hard to follow this.
Quoted 1 line
local phy.
So is the local phy disabled initially? Or is was it initially enabled and we disable+re-enable just when attaching, so that there is a race?
Quoted 3 lines
The following
BUG()will be triggered with a small probability:[562240.051046] sas: phy19 part of wide port with phy16
Where is this print in the code? I see "part of a wide port with phy%02d" in sas_discover_dev()
Quoted 28 lines
[562240.051197] sas: ex 500e004aaaaaaa1f phy19:U:0 attached: 0000000000000000 (no device) [562240.051203] sas: done REVALIDATING DOMAIN on port 0, pid:435909, res 0x0 <...> [562240.062536] sas: ex 500e004aaaaaaa1f phy0 new device attached [562240.062616] sas: ex 500e004aaaaaaa1f phy00:U:5 attached: 0000000000000000 (stp) [562240.062680] port-7:7:0: trying to add phy phy-7:7:19 fails: it's already part of another port [562240.085064] ------------[ cut here ]------------ [562240.096612] kernel BUG at drivers/scsi/scsi_transport_sas.c:1083! [562240.109611] Internal error: Oops - BUG: 0 [#1] SMP [562240.343518] Process kworker/u256:3 (pid: 435909, stack limit = 0x0000000003bcbebf) [562240.421714] Workqueue: 0000:b4:02.0_disco_q sas_revalidate_domain [libsas] [562240.437173] pstate: 40c00009 (nZcv daif +PAN +UAO) [562240.450478] pc : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.465283] lr : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.479751] sp : ffff0000300cfa70 [562240.674822] Call trace: [562240.682709] sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.694013] sas_ex_get_linkrate.isra.5+0xcc/0x128 [libsas] [562240.704957] sas_ex_discover_end_dev+0xfc/0x538 [libsas] [562240.715508] sas_ex_discover_dev+0x3cc/0x4b8 [libsas] [562240.725634] sas_ex_discover_devices+0x9c/0x1a8 [libsas] [562240.735855] sas_ex_revalidate_domain+0x2f0/0x450 [libsas] [562240.746123] sas_revalidate_domain+0x158/0x160 [libsas] [562240.756014] process_one_work+0x1b4/0x448 [562240.764548] worker_thread+0x54/0x468 [562240.772562] kthread+0x134/0x138 [562240.779989] ret_from_fork+0x10/0x18
Quoted 2 lines
What causes this problem:
1. When phy19 was initially added to the parent port,ex_phy->portwas not
phy19 is the expander phy attached to the host, right?
Quoted 1 line
set. As a result, when phy19 was removed from the parent wide port,
You seem to be getting ahead of yourself. It has not been mentioned when phy19 is removed from the parent wide port.
Quoted 5 lines
it was
not deleted from thephy_listof the parent port.2. The rate of the newly connected SATA device to phy0 is less than 1.5G, and its
sas_addresswas set to 0. After creating port 7:7:0
is 7:7:0 the port which the SATA device is part of?
Quoted 4 lines
, it attempts to
add the expander's other zero-addressed phy to this port.3. When adding phy19 to port-7:7:0
Which would be the incorrect thing to do, right? I am basing that on my assumption that 7:7:0 is the port which the SATA device is part of.
Quoted 39 lines
, it is prompted that phy19 already
belongs to another port, which triggers the current problem.Fix the problem as follows:
1. Whenex_phyis added to the parent port, setex_phy->porttoex_dev->parent_port.2. Set
ex_dev->parent_portto NULL when the parent port's PHY count is 0.3. When
phy->attached_dev_type!=NO_DEVICE, do not set the zero address forphy->attached_sas_addr.Fixes 2908d778ab3e ("[SCSI] aic94xx: new driver")Fixes 7d1d86518118 ("[SCSI] libsas: fix false positive 'device attached' conditions")Signed-off-by Xingui Yang <[email protected]>---
v3 -> v4:
1. Update patch title and comments based on John's suggestion.v2 -> v3:
1. Setex_dev->parent_portto NULL when the number of PHYs of the parent port becomes 0
2. Update the commentsv1 -> v2:
1. Setex_phy->portwithparent_portwhenex_phyis added to the parent port
2. Setex_phyto NULL when free expander
3. Update the comments--- drivers/scsi/libsas/sas_discover.c | 4 +++- drivers/scsi/libsas/sas_expander.c | 8 +++++--- drivers/scsi/libsas/sas_internal.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-)drivers/scsi/libsas/sas_discover.c +0
-0
drivers/scsi/libsas/sas_discover.c void sas_free_device(struct kref *kref) · line 301
Quoted 7 lines
drivers/scsi/libsas/sas_discover.c +2
-1@@ -296,8 +296,10 @@ void sas_free_device(struct kref *kref) dev->phy =NULL ;/* remove the phys and ports, everything else should be gone */ -if (dev_is_expander (dev->dev_type)) +if (dev_is_expander (dev->dev_type)) {kfree (dev->ex_dev.ex_phy); + dev->ex_dev.ex_phy =NULL ;
This is strange, as we free the dev later. Where can dev->ex_dev.ex_phy be checked before dev is freed?
Quoted 37 lines
drivers/scsi/libsas/sas_discover.c +1
-0+ }if (dev_is_sata (dev) && dev->sata_dev.ap) {ata_sas_tport_delete (dev->sata_dev.ap);drivers/scsi/libsas/sas_expander.c +5
-3@@ -239,8 +239,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id,/* help some expanders that fail to zero sas_address in the 'no * device' case */ -if (phy->attached_dev_type ==SAS_PHY_UNUSED || - phy->linkrate <SAS_LINK_RATE_1_5_GBPS ) +if (phy->attached_dev_type ==SAS_PHY_UNUSED )memset (phy->attached_sas_addr,0 ,SAS_ADDR_SIZE );else memcpy (phy->attached_sas_addr, dr->attached_sas_addr,SAS_ADDR_SIZE );@@ -1844,9 +1843,12 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent,if (phy->port) {sas_port_delete_phy (phy->port, phy->phy);sas_device_set_phy (found, phy->port); -if (phy->port->num_phys ==0 ) +if (phy->port->num_phys ==0 ) {list_add_tail (&phy->port->del_list, &parent->port->sas_port_del_list); +if (ex_dev->parent_port == phy->port) + ex_dev->parent_port =NULL ; + } phy->port =NULL ; } }drivers/scsi/libsas/sas_internal.h +0
-0
drivers/scsi/libsas/sas_internal.h static inline void sas_add_parent_port(struct domain_device *dev, int phy_id) · line 205
Quoted 4 lines
drivers/scsi/libsas/sas_internal.h +1
-0@@ -202,6 +202,7 @@ static inline void sas_add_parent_port(struct domain_device *dev, int phy_id)sas_port_mark_backlink (ex->parent_port); }sas_port_add_phy (ex->parent_port, ex_phy->phy); + ex_phy->port = ex->parent_port;
We already do this in sas_ex_join_wide_port(), right?
I am not saying that what we do now does not have a problem - I am just trying to understand what currently happens
Thanks,
John
Quoted 3 lines
drivers/scsi/libsas/sas_internal.h +0
-0}static inline struct domain_device *sas_alloc_device (void )
Hi John,
Quoted 110 lines · John Garry
On 17/11/2023 09:00, Xingui Yang wrote:
Sorry for being slow to come back to this. However I still have questions...
Quoted 1 line
When connecting to the epander device, first disable and then enable the
/s/epander/expander/
And connecting what to the expander? Is it a SATA disk?
Or the SATA disk is already attached to the expander and we are now attaching the expander to the host?
It is hard to follow this.
Quoted 1 line
local phy.
So is the local phy disabled initially? Or is was it initially enabled and we disable+re-enable just when attaching, so that there is a race?
Quoted 3 lines
The following
BUG()will be triggered with a small probability:[562240.051046] sas: phy19 part of wide port with phy16Where is this print in the code? I see "part of a wide port with phy%02d" in
sas_discover_dev()Quoted 28 lines
[562240.051197] sas: ex 500e004aaaaaaa1f phy19:U:0 attached: 0000000000000000 (no device) [562240.051203] sas: done REVALIDATING DOMAIN on port 0, pid:435909, res 0x0 <...> [562240.062536] sas: ex 500e004aaaaaaa1f phy0 new device attached [562240.062616] sas: ex 500e004aaaaaaa1f phy00:U:5 attached: 0000000000000000 (stp) [562240.062680] port-7:7:0: trying to add phy phy-7:7:19 fails: it's already part of another port [562240.085064] ------------[ cut here ]------------ [562240.096612] kernel BUG at drivers/scsi/scsi_transport_sas.c:1083! [562240.109611] Internal error: Oops - BUG: 0 [#1] SMP [562240.343518] Process kworker/u256:3 (pid: 435909, stack limit = 0x0000000003bcbebf) [562240.421714] Workqueue: 0000:b4:02.0_disco_q sas_revalidate_domain [libsas] [562240.437173] pstate: 40c00009 (nZcv daif +PAN +UAO) [562240.450478] pc : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.465283] lr : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.479751] sp : ffff0000300cfa70 [562240.674822] Call trace: [562240.682709] sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.694013] sas_ex_get_linkrate.isra.5+0xcc/0x128 [libsas] [562240.704957] sas_ex_discover_end_dev+0xfc/0x538 [libsas] [562240.715508] sas_ex_discover_dev+0x3cc/0x4b8 [libsas] [562240.725634] sas_ex_discover_devices+0x9c/0x1a8 [libsas] [562240.735855] sas_ex_revalidate_domain+0x2f0/0x450 [libsas] [562240.746123] sas_revalidate_domain+0x158/0x160 [libsas] [562240.756014] process_one_work+0x1b4/0x448 [562240.764548] worker_thread+0x54/0x468 [562240.772562] kthread+0x134/0x138 [562240.779989] ret_from_fork+0x10/0x18Quoted 2 lines
What causes this problem:
1. When phy19 was initially added to the parent port,ex_phy->portwas notphy19 is the expander phy attached to the host, right?
Quoted 1 line
set. As a result, when phy19 was removed from the parent wide port,
You seem to be getting ahead of yourself. It has not been mentioned when phy19 is removed from the parent wide port.
Quoted 5 lines
it was
not deleted from thephy_listof the parent port.2. The rate of the newly connected SATA device to phy0 is less than 1.5G, and its
sas_addresswas set to 0. After creating port 7:7:0is 7:7:0 the port which the SATA device is part of?
Quoted 4 lines
, it attempts to
add the expander's other zero-addressed phy to this port.3. When adding phy19 to port-7:7:0
Which would be the incorrect thing to do, right? I am basing that on my assumption that 7:7:0 is the port which the SATA device is part of.
Quoted 34 lines
, it is prompted that phy19 already
belongs to another port, which triggers the current problem.Fix the problem as follows:
1. Whenex_phyis added to the parent port, setex_phy->porttoex_dev->parent_port.2. Set
ex_dev->parent_portto NULL when the parent port's PHY count is 0.3. When
phy->attached_dev_type!=NO_DEVICE, do not set the zero address forphy->attached_sas_addr.Fixes 2908d778ab3e ("[SCSI] aic94xx: new driver")Fixes 7d1d86518118 ("[SCSI] libsas: fix false positive 'device attached' conditions")Signed-off-by Xingui Yang <[email protected]>---
v3 -> v4:
1. Update patch title and comments based on John's suggestion.v2 -> v3:
1. Setex_dev->parent_portto NULL when the number of PHYs of the parent port becomes 0
2. Update the commentsv1 -> v2:
1. Setex_phy->portwithparent_portwhenex_phyis added to the parent port
2. Setex_phyto NULL when free expander
3. Update the comments
---drivers/scsi/libsas/sas_discover.c | 4 +++- drivers/scsi/libsas/sas_expander.c | 8 +++++--- drivers/scsi/libsas/sas_internal.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-)
Quoted 13 lines
drivers/scsi/libsas/sas_discover.c void sas_free_device(struct kref *kref) · line 300
Quoted 11 lines
drivers/scsi/libsas/sas_discover.c +2
-1@@ -296,8 +296,10 @@ void sas_free_device(struct kref *kref) dev->phy = NULL; /* remove the phys and ports, everything else should be gone */ - if (dev_is_expander(dev->dev_type)) + if (dev_is_expander(dev->dev_type)) { kfree(dev->ex_dev.ex_phy); + dev->ex_dev.ex_phy = NULL;This is strange, as we free the dev later. Where can
dev->ex_dev.ex_phybe checked before dev is freed?
Yes, I saw this when locating this problem and detecting resource release. Usually after calling kfree, we will set the pointer to null. It has little to do with the current problem. I can delete this part of the modification.
Quoted 38 lines
Quoted 38 lines
drivers/scsi/libsas/sas_discover.c +1
-0+ } if (dev_is_sata(dev) && dev->sata_dev.ap) { ata_sas_tport_delete(dev->sata_dev.ap);drivers/scsi/libsas/sas_expander.c +1
-2@@ -239,8 +239,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, /* help some expanders that fail to zero sas_address in the 'no * device' case */ - if (phy->attached_dev_type == SAS_PHY_UNUSED || - phy->linkrate < SAS_LINK_RATE_1_5_GBPS) + if (phy->attached_dev_type == SAS_PHY_UNUSED) memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);else
memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);drivers/scsi/libsas/sas_expander.c +4
-1@@ -1844,9 +1843,12 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent, if (phy->port) { sas_port_delete_phy(phy->port, phy->phy); sas_device_set_phy(found, phy->port); - if (phy->port->num_phys == 0) + if (phy->port->num_phys == 0) { list_add_tail(&phy->port->del_list, &parent->port->sas_port_del_list); + if (ex_dev->parent_port == phy->port) + ex_dev->parent_port = NULL; + } phy->port = NULL; }}
drivers/scsi/libsas/sas_internal.h +0
-0
Quoted 8 lines
drivers/scsi/libsas/sas_internal.h static inline void sas_add_parent_port(struct · line 206
Quoted 6 lines
drivers/scsi/libsas/sas_internal.h +1
-0@@ -202,6 +202,7 @@ static inline void sas_add_parent_port(struct domain_device *dev, int phy_id) sas_port_mark_backlink(ex->parent_port); } sas_port_add_phy(ex->parent_port, ex_phy->phy); + ex_phy->port = ex->parent_port;We already do this in
sas_ex_join_wide_port(), right?
No, If the addr of ex_phy matches dev->parent, sas_ex_join_wide_port() will not be called, but sas_add_parent_port() will be called as follows:
static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
{
struct expander_device *ex = &dev->ex_dev;
struct ex_phy *ex_phy = &ex->ex_phy[phy_id];
struct domain_device *child = NULL;
int res = 0;
<...>
/* Parent and domain coherency */
if (!dev->parent && sas_phy_match_port_addr(dev->port, ex_phy)) {
sas_add_parent_port(dev, phy_id);
return 0;
}
if (dev->parent && sas_phy_match_dev_addr(dev->parent, ex_phy)) {
sas_add_parent_port(dev, phy_id);
if (ex_phy->routing_attr == TABLE_ROUTING)
sas_configure_phy(dev, phy_id,
dev->port->sas_addr, 1);
return 0;
}
<...>
}Quoted 2 lines
I am not saying that what we do now does not have a problem - I am just trying to understand what currently happens
ok, because ex_phy->port is not set when calling sas_add_parent_port(), when deleting phy from the parent wide port, it is not removed from the phy_list of the parent wide port as follows:
static void sas_unregister_devs_sas_addr(struct domain_device *parent,
int phy_id, bool last)
{
<...>
// Since ex_phy->port is not set, this branch will not be enter
if (phy->port) {
sas_port_delete_phy(phy->port, phy->phy);
sas_device_set_phy(found, phy->port);
if (phy->port->num_phys == 0) {
list_add_tail(&phy->port->del_list,
&parent->port->sas_port_del_list);
if (ex_dev->parent_port == phy->port)
ex_dev->parent_port = NULL;
}
phy->port = NULL;
}
}Thanks,
Xingui
.
John Garry
reviewerQuoted 26 lines · yangxingui
Quoted 1 line
We already do this in
sas_ex_join_wide_port(), right?No, If the addr of
ex_phymatchesdev->parent,sas_ex_join_wide_port()will not be called, butsas_add_parent_port()will be called as follows:
static intsas_ex_discover_dev(struct domain_device *dev, int phy_id)
{
structexpander_device*ex =&dev->ex_dev;
structex_phy*ex_phy= &ex->ex_phy[phy_id];
structdomain_device*child = NULL;
int res = 0;<...>
/* Parent and domain coherency */
if (!dev->parent &&sas_phy_match_port_addr(dev->port, ex_phy)) {sas_add_parent_port(dev, phy_id);
return 0;
}
if (dev->parent&&sas_phy_match_dev_addr(dev->parent, ex_phy)) {sas_add_parent_port(dev, phy_id);
if (ex_phy->routing_attr==TABLE_ROUTING) sas_configure_phy(dev,phy_id,dev->port->sas_addr, 1);
return 0;
}
<...>
}Quoted 1 line
Quoted 8 lines
Quoted 1 line
I am not saying that what we do now does not have a problem - I am just trying to understand what currently happens
ok, because
ex_phy->portis not set when callingsas_add_parent_port(), when deleting phy from the parent wide port, it is not removed from thephy_listof the parent wide port as follows:
static void sas_unregister_devs_sas_addr(structdomain_device*parent,
intphy_id, bool last)
{
<...>
// Sinceex_phy->portis not set, this branch will not be enter
But then how does this ever work? It is because we follow path sas_rediscover_dev() -> sas_discover_new() -> sas_ex_discover_devices() -> sas_ex_discover_dev() -> sas_add_parent_port(), and not sas_rediscover_dev() -> sas_discover_new() -> sas_ex_join_wide_port()? If so, is that because ephy->sas_attached_phy == 0 in sas_discover_new() -> sas_ex_join_wide_port() and it fails?
BTW, about something mentioned earlier - adding the phy19 with SAS_ADDR = 0 ever to a sas_port seems wrong.
Quoted 4 lines
if (
phy->port) {sas_port_delete_phy(phy->port, phy->phy);sas_device_set_phy(found, phy->port); if (phy->port->num_phys== 0) {
Quoted 8 lines
list_add_tail(&phy->port->del_list, &parent->port->sas_port_del_list); if (ex_dev->parent_port==phy->port)ex_dev->parent_port= NULL; }
phy->port= NULL;
}
}
Thanks,
John
Hi John,
Quoted 35 lines · John Garry
Quoted 25 lines · yangxingui
Quoted 1 line
We already do this in
sas_ex_join_wide_port(), right?No, If the addr of
ex_phymatchesdev->parent,sas_ex_join_wide_port()will not be called, butsas_add_parent_port()will be called as follows:
static intsas_ex_discover_dev(struct domain_device *dev, int phy_id)
{
structexpander_device*ex =&dev->ex_dev;
structex_phy*ex_phy= &ex->ex_phy[phy_id];
structdomain_device*child = NULL;
int res = 0;<...>
/* Parent and domain coherency */
if (!dev->parent &&sas_phy_match_port_addr(dev->port, ex_phy)) {sas_add_parent_port(dev, phy_id);
return 0;
}
if (dev->parent&&sas_phy_match_dev_addr(dev->parent, ex_phy)) {sas_add_parent_port(dev, phy_id);
if (ex_phy->routing_attr==TABLE_ROUTING)sas_configure_phy(dev, phy_id, dev->port->sas_addr, 1); return 0;
}
<...>
}Quoted 1 line
Quoted 8 lines
Quoted 1 line
I am not saying that what we do now does not have a problem - I am just trying to understand what currently happens
ok, because
ex_phy->portis not set when callingsas_add_parent_port(), when deleting phy from the parent wide port, it is not removed from thephy_listof the parent wide port as follows:
static void sas_unregister_devs_sas_addr(structdomain_device*parent,
intphy_id, bool last)
{
<...>
// Sinceex_phy->portis not set, this branch will not be enter
Quoted 6 lines
But then how does this ever work? It is because we follow path
sas_rediscover_dev()->sas_discover_new()->sas_ex_discover_devices()->sas_ex_discover_dev()->sas_add_parent_port(), and notsas_rediscover_dev()->sas_discover_new()->sas_ex_join_wide_port()? If so, is that becauseephy->sas_attached_phy== 0 insas_discover_new()->sas_ex_join_wide_port()and it fails?BTW, about something mentioned earlier - adding the phy19 with
SAS_ADDR
Yes,
For phy19, when the phy is attached and added to the parent wide port, the path is:sas_rediscover()
->sas_discover_new() ->sas_ex_discover_devices() ->sas_ex_discover_dev() -> sas_add_parent_port(). And the path called when it is removed from parent wide port is: sas_rediscover() ->sas_unregister_devs_sas_addr() // The sas address of phy19 becomes 0.
Since ex_phy->port is NULL, phy19 is not removed from the parent wide port's phy_list.
For phy0, it is connected to a new sata device.sas_rediscover()
->sas_discover_new()->sas_ex_phy_discover() ->sas_ex_phy_discover_helper() ->sas_set_ex_phy() // The device type is stp. Since the linkrate is 5 and less than 1.5G, sas_address is set to 0. ->sas_ex_discover_devices() ->sas_ex_discover_dev() ->sas_ex_discover_end_dev() ->sas_port_alloc() // Create port-7:7:0 ->sas_ex_get_linkrate() ->sas_port_add_phy() // Try adding phy19 to port->7:7:0,
triggering BUG()
Thanks,
Xingui
.
John Garry
reviewerQuoted 41 lines · yangxingui
Quoted 35 lines · John Garry
Quoted 25 lines · yangxingui
Quoted 1 line
We already do this in
sas_ex_join_wide_port(), right?No, If the addr of
ex_phymatchesdev->parent,sas_ex_join_wide_port()will not be called, butsas_add_parent_port()will be called as follows:
static intsas_ex_discover_dev(struct domain_device *dev, int phy_id)
{
structexpander_device*ex =&dev->ex_dev;
structex_phy*ex_phy= &ex->ex_phy[phy_id];
structdomain_device*child = NULL;
int res = 0;<...>
/* Parent and domain coherency */
if (!dev->parent &&sas_phy_match_port_addr(dev->port, ex_phy)) {sas_add_parent_port(dev, phy_id);
return 0;
}
if (dev->parent&&sas_phy_match_dev_addr(dev->parent, ex_phy)) {sas_add_parent_port(dev, phy_id);
if (ex_phy->routing_attr==TABLE_ROUTING)sas_configure_phy(dev, phy_id, dev->port->sas_addr, 1); return 0;
}
<...>
}Quoted 1 line
Quoted 8 lines
Quoted 1 line
I am not saying that what we do now does not have a problem - I am just trying to understand what currently happens
ok, because
ex_phy->portis not set when callingsas_add_parent_port(), when deleting phy from the parent wide port, it is not removed from thephy_listof the parent wide port as follows:
static void sas_unregister_devs_sas_addr(structdomain_device*parent,
intphy_id, bool last)
{
<...>
// Sinceex_phy->portis not set, this branch will not be enterQuoted 3 lines
But then how does this ever work? It is because we follow path
sas_rediscover_dev()->sas_discover_new()->sas_ex_discover_devices()->sas_ex_discover_dev()->sas_add_parent_port(), and notsas_rediscover_dev()->sas_discover_new()->sas_ex_join_wide_port()? If so, is that becauseephy->sas_attached_phy== 0 insas_discover_new()->sas_ex_join_wide_port()and it fails?BTW, about something mentioned earlier - adding the phy19 with
SAS_ADDR
Quoted 7 lines
Yes,
For phy19, when the phy is attached and added to the parent wide port, the path is:sas_rediscover()
->sas_discover_new()
->sas_ex_discover_devices()
->sas_ex_discover_dev()
->sas_add_parent_port().
ok, so then the change to set ex_phy->port = ex->parent_port looks ok. Maybe we can put this in a helper with the sas_port_add_phy() call, as it is duplicated in sas_ex_join_wide_port()
Do we also need to set ex_phy->phy_state (like sas_ex_join_wide_port())?
Quoted 11 lines
And the path called when it is removed from parent wide port is:
sas_rediscover()
->sas_unregister_devs_sas_addr() // The sas address of phy19
becomes 0. Sinceex_phy->portis NULL, phy19 is not removed from the parent wide port'sphy_list.For phy0, it is connected to a new sata device.
sas_rediscover()
->sas_discover_new()->sas_ex_phy_discover() ->sas_ex_phy_discover_helper() ->sas_set_ex_phy() // The device type
is stp. Since the linkrate is 5 and less than 1.5G,sas_addressis set to 0.
Then when we get the proper linkrate later, will we then rediscover and set the proper SAS address? I am just wondering if this change is really required?
BTW, Even with the change to set ex_phy->port = ex->parent_port, are we still joining the host-attached expander phy (19) to a port with SAS address == 0?
Quoted 8 lines
->sas_ex_discover_devices() ->sas_ex_discover_dev() ->sas_ex_discover_end_dev() ->sas_port_alloc() // Create
port-7:7:0
->sas_ex_get_linkrate() ->sas_port_add_phy() // Try
adding phy19 to port->7:7:0, triggeringBUG()
Thanks,
John
Hi, John
Quoted 50 lines · John Garry
Quoted 41 lines · yangxingui
Quoted 35 lines · John Garry
Quoted 25 lines · yangxingui
Quoted 1 line
We already do this in
sas_ex_join_wide_port(), right?No, If the addr of
ex_phymatchesdev->parent,sas_ex_join_wide_port()will not be called, butsas_add_parent_port()will be called as follows:
static intsas_ex_discover_dev(struct domain_device *dev, int phy_id)
{
structexpander_device*ex =&dev->ex_dev;
structex_phy*ex_phy= &ex->ex_phy[phy_id];
structdomain_device*child = NULL;
int res = 0;<...>
/* Parent and domain coherency */
if (!dev->parent &&sas_phy_match_port_addr(dev->port, ex_phy)) {sas_add_parent_port(dev, phy_id);
return 0;
}
if (dev->parent&&sas_phy_match_dev_addr(dev->parent, ex_phy)) {sas_add_parent_port(dev, phy_id);
if (ex_phy->routing_attr==TABLE_ROUTING)sas_configure_phy(dev, phy_id, dev->port->sas_addr, 1); return 0;
}
<...>
}Quoted 1 line
Quoted 8 lines
Quoted 1 line
I am not saying that what we do now does not have a problem - I am just trying to understand what currently happens
ok, because
ex_phy->portis not set when callingsas_add_parent_port(), when deleting phy from the parent wide port, it is not removed from thephy_listof the parent wide port as follows:
static void sas_unregister_devs_sas_addr(structdomain_device*parent,
intphy_id, bool last)
{
<...>
// Sinceex_phy->portis not set, this branch will not be enterQuoted 3 lines
But then how does this ever work? It is because we follow path
sas_rediscover_dev()->sas_discover_new()->sas_ex_discover_devices()->sas_ex_discover_dev()->sas_add_parent_port(), and notsas_rediscover_dev()->sas_discover_new()->sas_ex_join_wide_port()? If so, is that becauseephy->sas_attached_phy== 0 insas_discover_new()->sas_ex_join_wide_port()and it fails?BTW, about something mentioned earlier - adding the phy19 with
SAS_ADDRQuoted 7 lines
Yes,
For phy19, when the phy is attached and added to the parent wide port, the path is:sas_rediscover()
->sas_discover_new()
->sas_ex_discover_devices()
->sas_ex_discover_dev()
->sas_add_parent_port().
Quoted 3 lines
ok, so then the change to set
ex_phy->port=ex->parent_portlooks ok. Maybe we can put this in a helper with thesas_port_add_phy()call, as it is duplicated insas_ex_join_wide_port()Do we also need to set
ex_phy->phy_state(likesas_ex_join_wide_port())?
Well, okay, as follows?
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -856,9 +856,7 @@ static bool sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
if (!memcmp(phy->attached_sas_addr,
ephy->attached_sas_addr,
SAS_ADDR_SIZE) && ephy->port) {
- sas_port_add_phy(ephy->port, phy->phy);
- phy->port = ephy->port;
- phy->phy_state = PHY_DEVICE_DISCOVERED;
+ sas_port_add_ex_phy(ephy->port, phy);
return true;
}
}drivers/scsi/libsas/sas_internal.h +7 -0
@@ -189,6 +189,13 @@ static inline void sas_phy_set_target(struct asd_sas_phy *p, struct domain_devic } } +static inline void sas_port_add_ex_phy (struct sas_port *port,struct ex_phy *ex_phy) +{ +sas_port_add_phy (port, ex_phy->phy); + ex_phy->port = port; + ex_phy->phy_state =PHY_DEVICE_DISCOVERED ; +} + static inline void sas_add_parent_port(struct domain_device *dev, int
phy_id)
{
struct expander_device *ex = &dev->ex_dev;
@@ -201,8 +208,7 @@ static inline void sas_add_parent_port(struct domain_device *dev, int phy_id)
BUG_ON(sas_port_add(ex->parent_port));
sas_port_mark_backlink(ex->parent_port);
}- sas_port_add_phy(ex->parent_port, ex_phy->phy);
+ sas_port_add_ex_phy(ex->parent_port, ex_phy);
}
Quoted 5 lines
Quoted 5 lines
And the path called when it is removed from parent wide port is:
sas_rediscover()
->sas_unregister_devs_sas_addr() // The sas address of phy19 becomes 0. Sinceex_phy->portis NULL, phy19 is not removed from the parent wide port'sphy_list.
Quoted 7 lines
Quoted 5 lines
For phy0, it is connected to a new sata device.
sas_rediscover()
->sas_discover_new()->sas_ex_phy_discover()
->sas_ex_phy_discover_helper()
->sas_set_ex_phy() // The device type is stp. Since the linkrate is 5 and less than 1.5G,sas_addressis set to 0.Then when we get the proper linkrate later, will we then rediscover and set the proper SAS address? I am just wondering if this change is really required?
Yes, but in fact it has not reached that stage yet. After setting the address to 0, it will continue to create a new port and try to add other phys with the same address as it to this new port.
Quoted 2 lines
BTW, Even with the change to set
ex_phy->port=ex->parent_port, are we still joining the host-attached expander phy (19) to a port with SAS address == 0?
Yes, in order to avoid this situation, in the current patch, we will not force the SAS address to be set to 0 when the device type is not NULL, but will still use the address obtained after requesting the expander.
Thanks,
Xingui
John Garry
reviewerQuoted 15 lines · yangxingui
Quoted 11 lines
Quoted 7 lines
For phy19, when the phy is attached and added to the parent wide port, the path is:
sas_rediscover()
->sas_discover_new()
->sas_ex_discover_devices()
->sas_ex_discover_dev()
->sas_add_parent_port().ok, so then the change to set
ex_phy->port=ex->parent_portlooks ok. Maybe we can put this in a helper with thesas_port_add_phy()call, as it is duplicated insas_ex_join_wide_port()Do we also need to set
ex_phy->phy_state(likesas_ex_join_wide_port())?Well, okay, as follows?
+++b/drivers/scsi/libsas/sas_expander.c
Review static bool sas_ex_join_wide_port(struct · line 862
Quoted 10 lines
(quoted diff) +1
-3@@ -856,9 +856,7 @@ static bool sas_ex_join_wide_port(struct domain_device *parent, int phy_id) if (!memcmp(phy->attached_sas_addr, ephy->attached_sas_addr, SAS_ADDR_SIZE) && ephy->port) { - sas_port_add_phy(ephy->port, phy->phy); - phy->port = ephy->port; - phy->phy_state = PHY_DEVICE_DISCOVERED; + sas_port_add_ex_phy(ephy->port, phy); return true;
this looks ok. How about adding this helper and using it in a separate change?
Quoted 13 lines
}
}drivers/scsi/libsas/sas_internal.h +0
-0@@ -189,6 +189,13 @@ static inline void sas_phy_set_target(struct
asd_sas_phy*p, structdomain_devic
}
}+static inline void
sas_port_add_ex_phy(struct sas_port *port, struct ex_phy *ex_phy)
drivers/scsi/libsas/sas_internal.h static inline void sas_phy_set_target(struct asd_sas_phy *p, struct domain_devic · line 197
Quoted 5 lines
drivers/scsi/libsas/sas_internal.h +5
-0+{ + sas_port_add_phy(port, ex_phy->phy); + ex_phy->port = port; + ex_phy->phy_state = PHY_DEVICE_DISCOVERED; +}
I'd prefer sas_expander.c, but sas_add_parent_port() is here... having said that, sas_add_parent_port() is only used in sas_expander.c
Quoted 19 lines
+
static inline void sas_add_parent_port(structdomain_device*dev, intphy_id)
{
structexpander_device*ex =&dev->ex_dev;drivers/scsi/libsas/sas_internal.h +1
-1@@ -201,8 +208,7 @@ static inline void sas_add_parent_port(struct domain_device *dev, int phy_id) BUG_ON(sas_port_add(ex->parent_port)); sas_port_mark_backlink(ex->parent_port); } - sas_port_add_phy(ex->parent_port, ex_phy->phy); + sas_port_add_ex_phy(ex->parent_port, ex_phy); }Quoted 5 lines
Quoted 5 lines
And the path called when it is removed from parent wide port is:
sas_rediscover()
->sas_unregister_devs_sas_addr() // The sas address of phy19 becomes 0. Sinceex_phy->portis NULL, phy19 is not removed from the parent wide port'sphy_list.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
For phy0, it is connected to a new sata device.
sas_rediscover()
->sas_discover_new()->sas_ex_phy_discover()
->sas_ex_phy_discover_helper()
->sas_set_ex_phy() // The device type is stp. Since the linkrate is 5 and less than 1.5G,sas_addressis set to 0.Then when we get the proper linkrate later, will we then rediscover and set the proper SAS address? I am just wondering if this change is really required?
Yes, but in fact it has not reached that stage yet. After setting the address to 0, it will continue to create a new port and try to add other phys with the same address as it to this new port.
creating a port for SAS address == 0 and adding phys seems incorrect, right?
Quoted 4 lines
Quoted 3 lines
BTW, Even with the change to set
ex_phy->port=ex->parent_port, are we still joining the host-attached expander phy (19) to a port with SAS address == 0?Yes, in order to avoid this situation, in the current patch, we will not force the SAS address to be set to 0 when the device type is not NULL, but will still use the address obtained after requesting the expander.
ok, let me check that again later today.
Thanks,
John
Hi, John
Quoted 18 lines · John Garry
Quoted 17 lines · yangxingui
Quoted 11 lines
Quoted 7 lines
For phy19, when the phy is attached and added to the parent wide port, the path is:
sas_rediscover()
->sas_discover_new()
->sas_ex_discover_devices()
->sas_ex_discover_dev()
->sas_add_parent_port().ok, so then the change to set
ex_phy->port=ex->parent_portlooks ok. Maybe we can put this in a helper with thesas_port_add_phy()call, as it is duplicated insas_ex_join_wide_port()Do we also need to set
ex_phy->phy_state(likesas_ex_join_wide_port())?Well, okay, as follows?
+++b/drivers/scsi/libsas/sas_expander.c(quoted diff) +0
-0@@ -856,9 +856,7 @@ static bool sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
Quoted 9 lines
Review static bool sas_ex_join_wide_port(struct · line 861
Quoted 7 lines
(quoted diff) +1
-3if (!memcmp(phy->attached_sas_addr, ephy->attached_sas_addr, SAS_ADDR_SIZE) && ephy->port) { - sas_port_add_phy(ephy->port, phy->phy); - phy->port = ephy->port; - phy->phy_state = PHY_DEVICE_DISCOVERED; + sas_port_add_ex_phy(ephy->port, phy); return true;this looks ok. How about adding this helper and using it in a separate change?
Okay, then I will update the version.
Quoted 12 lines
Quoted 12 lines
(quoted diff) +0
-0}}
drivers/scsi/libsas/sas_internal.h +0
-0@@ -189,6 +189,13 @@ static inline void sas_phy_set_target(struct
asd_sas_phy*p, structdomain_devic
}
}
Quoted 9 lines
drivers/scsi/libsas/sas_internal.h static inline void sas_phy_set_target(struct asd_sas_phy *p, struct domain_devic · line 197
Quoted 7 lines
+static inline void
sas_port_add_ex_phy(struct sas_port *port, struct ex_phy *ex_phy)drivers/scsi/libsas/sas_internal.h +5
-0+{ + sas_port_add_phy(port, ex_phy->phy); + ex_phy->port = port; + ex_phy->phy_state = PHY_DEVICE_DISCOVERED; +}I'd prefer
sas_expander.c, butsas_add_parent_port()is here... having said that,sas_add_parent_port()is only used insas_expander.c
Okay, then I will update the version and move it to sas_expander.c .
Quoted 25 lines
Quoted 25 lines
+
static inline voidsas_add_parent_port(struct domain_device *dev, int phy_id){
structexpander_device*ex =&dev->ex_dev;drivers/scsi/libsas/sas_internal.h +1
-1@@ -201,8 +208,7 @@ static inline void sas_add_parent_port(struct domain_device *dev, int phy_id) BUG_ON(sas_port_add(ex->parent_port)); sas_port_mark_backlink(ex->parent_port); } - sas_port_add_phy(ex->parent_port, ex_phy->phy); + sas_port_add_ex_phy(ex->parent_port, ex_phy); }Quoted 11 lines
Quoted 10 lines
And the path called when it is removed from parent wide port is:
sas_rediscover()
->sas_unregister_devs_sas_addr() // The sas address of phy19 becomes 0. Sinceex_phy->portis NULL, phy19 is not removed from the parent wide port'sphy_list.For phy0, it is connected to a new sata device.
sas_rediscover()
->sas_discover_new()->sas_ex_phy_discover()
->sas_ex_phy_discover_helper()
->sas_set_ex_phy() // The device type is stp. Since the linkrate is 5 and less than 1.5G,sas_addressis set to 0.
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
Then when we get the proper linkrate later, will we then rediscover and set the proper SAS address? I am just wondering if this change is really required?
Yes, but in fact it has not reached that stage yet. After setting the address to 0, it will continue to create a new port and try to add other phys with the same address as it to this new port.
creating a port for SAS address == 0 and adding phys seems incorrect, right?
Yes. There are three possible ways to solve the problem of creating a port with a zero address:
1. Use the sas address obtained by querying the expander instead of the zero address.
2. Forbid the phy with an address of 0 to create a port.
3. When the rate is less than 1.5G, do not let it enter sas_ex_discover_end_dev().
Because when the device type is not empty, its SAS address is legal, and we are currently using the first one.
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
BTW, Even with the change to set
ex_phy->port=ex->parent_port, are we still joining the host-attached expander phy (19) to a port with SAS address == 0?Yes, in order to avoid this situation, in the current patch, we will not force the SAS address to be set to 0 when the device type is not NULL, but will still use the address obtained after requesting the expander.
ok, let me check that again later today.
OK.
Thanks
Xingui
Hi, John
Sorry, I missed the reply to you. The improved version is as follows.
Quoted 10 lines · John Garry
On 17/11/2023 09:00, Xingui Yang wrote:
Sorry for being slow to come back to this. However I still have questions...
Quoted 1 line
When connecting to the epander device, first disable and then enable the
/s/epander/expander >
And connecting what to the expander? Is it a SATA disk?Or the SATA disk is already attached to the expander and we are now attaching the expander to the host?
Yes, the SATA disk is already attached to the expander.
Quoted 6 lines
It is hard to follow this.
Quoted 1 line
local phy.
So is the local phy disabled initially? Or is was it initially enabled and we disable+re-enable just when attaching, so that there is a race?
When local phy is enabled and disabled repeatedly, the ex_phy status causing the expander may change, such as being removed. And the link rate of the SATA device has also changed, such as becoming SAS_PHY_RESET_IN_PROGRESS.
Quoted 6 lines
Quoted 4 lines
The following
BUG()will be triggered with a small probability:[562240.051046] sas: phy19 part of wide port with phy16Where is this print in the code? I see "part of a wide port with phy%02d" in
sas_discover_dev()
In sas_rediscover() as follow, the latest printing has changed a bit, what I posted is an old version of the log. The latest version also has similar problems. static int sas_rediscover(struct domain_device *dev, const int phy_id)
{
struct expander_device *ex = &dev->ex_dev;
struct ex_phy *changed_phy = &ex->ex_phy[phy_id];
int i;
bool last = true; /* is this the last phy of the port */
for (i = 0; i < ex->num_phys; i++) {
struct ex_phy *phy = &ex->ex_phy[i];
if (i == phy_id)
continue;
if (SAS_ADDR(phy->attached_sas_addr) ==
SAS_ADDR(changed_phy->attached_sas_addr)) {
SAS_DPRINTK("phy%d part of wide port with "
"phy%d\n", phy_id, i);
last = false;
break;
}
}
return sas_rediscover_dev(dev, phy_id, last);
}Quoted 29 lines
Quoted 29 lines
[562240.051197] sas: ex 500e004aaaaaaa1f phy19:U:0 attached: 0000000000000000 (no device) [562240.051203] sas: done REVALIDATING DOMAIN on port 0, pid:435909, res 0x0 <...> [562240.062536] sas: ex 500e004aaaaaaa1f phy0 new device attached [562240.062616] sas: ex 500e004aaaaaaa1f phy00:U:5 attached: 0000000000000000 (stp) [562240.062680] port-7:7:0: trying to add phy phy-7:7:19 fails: it's already part of another port [562240.085064] ------------[ cut here ]------------ [562240.096612] kernel BUG at drivers/scsi/scsi_transport_sas.c:1083! [562240.109611] Internal error: Oops - BUG: 0 [#1] SMP [562240.343518] Process kworker/u256:3 (pid: 435909, stack limit = 0x0000000003bcbebf) [562240.421714] Workqueue: 0000:b4:02.0_disco_q sas_revalidate_domain [libsas] [562240.437173] pstate: 40c00009 (nZcv daif +PAN +UAO) [562240.450478] pc : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.465283] lr : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.479751] sp : ffff0000300cfa70 [562240.674822] Call trace: [562240.682709] sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] [562240.694013] sas_ex_get_linkrate.isra.5+0xcc/0x128 [libsas] [562240.704957] sas_ex_discover_end_dev+0xfc/0x538 [libsas] [562240.715508] sas_ex_discover_dev+0x3cc/0x4b8 [libsas] [562240.725634] sas_ex_discover_devices+0x9c/0x1a8 [libsas] [562240.735855] sas_ex_revalidate_domain+0x2f0/0x450 [libsas] [562240.746123] sas_revalidate_domain+0x158/0x160 [libsas] [562240.756014] process_one_work+0x1b4/0x448 [562240.764548] worker_thread+0x54/0x468 [562240.772562] kthread+0x134/0x138 [562240.779989] ret_from_fork+0x10/0x18
Quoted 4 lines
Quoted 2 lines
What causes this problem:
1. When phy19 was initially added to the parent port,ex_phy->portwas notphy19 is the expander phy attached to the host, right?
Yes.
Quoted 4 lines
Quoted 2 lines
set. As a result, when phy19 was removed from the parent wide port,
You seem to be getting ahead of yourself. It has not been mentioned when phy19 is removed from the parent wide port.
Expander broadcast event notification phy 19 has been disconnected as follows:
[562240.048606] sas: broadcast received: 0 [562240.048615] sas: REVALIDATING DOMAIN on port 0, pid:435909 [562240.048929] sas: Expander phy change count has changed [562240.051038] sas: ex 500e004aaaaaaa1f phy0 originated BROADCAST(CHANGE) [562240.051039] sas: ex 500e004aaaaaaa1f phy1 originated BROADCAST(CHANGE) [562240.051040] sas: ex 500e004aaaaaaa1f phy2 originated BROADCAST(CHANGE) [562240.051040] sas: ex 500e004aaaaaaa1f phy3 originated BROADCAST(CHANGE) [562240.051041] sas: ex 500e004aaaaaaa1f phy4 originated BROADCAST(CHANGE) [562240.051042] sas: ex 500e004aaaaaaa1f phy5 originated BROADCAST(CHANGE) [562240.051043] sas: ex 500e004aaaaaaa1f phy17 originated BROADCAST(CHANGE) [562240.051044] sas: ex 500e004aaaaaaa1f phy18 originated BROADCAST(CHANGE) [562240.051044] sas: ex 500e004aaaaaaa1f phy19 originated BROADCAST(CHANGE) [562240.051046] sas: phy19 part of wide port with phy16 [562240.051197] sas: ex 500e004aaaaaaa1f phy19:U:0 attached: 0000000000000000 (no device) [562240.051198] sas: ex 500e004aaaaaaa1f phy20 originated BROADCAST(CHANGE) [562240.051198] sas: ex 500e004aaaaaaa1f phy22 originated BROADCAST(CHANGE) [562240.051199] sas: ex 500e004aaaaaaa1f phy23 originated BROADCAST(CHANGE) [562240.051203] sas: done REVALIDATING DOMAIN on port 0, pid:435909, res 0x0 [562240.051221] sas: broadcast received: 0 [562240.051230] sas: REVALIDATING DOMAIN on port 0, pid:435909 [562240.051413] sas: Expander phy change count has changed [562240.053439] sas: ex 500e004aaaaaaa1f phy0 originated BROADCAST(CHANGE) [562240.053439] sas: ex 500e004aaaaaaa1f phy1 originated BROADCAST(CHANGE) [562240.053440] sas: ex 500e004aaaaaaa1f phy2 originated BROADCAST(CHANGE) [562240.053441] sas: ex 500e004aaaaaaa1f phy3 originated BROADCAST(CHANGE) [562240.053442] sas: ex 500e004aaaaaaa1f phy4 originated BROADCAST(CHANGE) [562240.053443] sas: ex 500e004aaaaaaa1f phy5 originated BROADCAST(CHANGE) [562240.053444] sas: ex 500e004aaaaaaa1f phy17 originated BROADCAST(CHANGE) [562240.053444] sas: ex 500e004aaaaaaa1f phy18 originated BROADCAST(CHANGE) [562240.053445] sas: ex 500e004aaaaaaa1f phy20 originated BROADCAST(CHANGE) [562240.053446] sas: ex 500e004aaaaaaa1f phy22 originated BROADCAST(CHANGE) [562240.053447] sas: ex 500e004aaaaaaa1f phy23 originated BROADCAST(CHANGE) [562240.053448] sas: ex 500e004aaaaaaa1f phy0 new device attached [562240.053521] sas: ex 500e004aaaaaaa1f phy00:U:5 attached: 0000000000000000 (no device) [562240.053522] sas: ex 500e004aaaaaaa1f phy1 new device attached [562240.053601] sas: ex 500e004aaaaaaa1f phy01:U:5 attached: 0000000000000000 (no device) [562240.053602] sas: ex 500e004aaaaaaa1f phy2 new device attached [562240.053682] sas: ex 500e004aaaaaaa1f phy02:U:5 attached: 0000000000000000 (no device) [562240.053684] sas: ex 500e004aaaaaaa1f phy3 new device attached [562240.053763] sas: ex 500e004aaaaaaa1f phy03:U:5 attached: 0000000000000000 (no device) [562240.053764] sas: ex 500e004aaaaaaa1f phy4 new device attached [562240.053843] sas: ex 500e004aaaaaaa1f phy04:U:5 attached: 0000000000000000 (no device) [562240.053844] sas: ex 500e004aaaaaaa1f phy5 new device attached [562240.053924] sas: ex 500e004aaaaaaa1f phy05:U:5 attached: 0000000000000000 (no device) [562240.053925] sas: ex 500e004aaaaaaa1f phy17 new device attached [562240.054008] sas: ex 500e004aaaaaaa1f phy17:U:B attached: 5001882016000002 (host) [562240.054015] sas: ex 500e004aaaaaaa1f phy18 new device attached [562240.054098] sas: ex 500e004aaaaaaa1f phy18:U:B attached: 5001882016000002 (host) [562240.054102] sas: ex 500e004aaaaaaa1f phy20 new device attached [562240.054186] sas: ex 500e004aaaaaaa1f phy20:U:B attached: 5001882016000002 (host) [562240.054190] sas: ex 500e004aaaaaaa1f phy22 new device attached [562240.054273] sas: ex 500e004aaaaaaa1f phy22:U:B attached: 5001882016000002 (host) [562240.054276] sas: ex 500e004aaaaaaa1f phy23 new device attached [562240.054360] sas: ex 500e004aaaaaaa1f phy23:U:B attached: 5001882016000002 (host) [562240.054364] sas: done REVALIDATING DOMAIN on port 0, pid:435909, res 0x0
Quoted 13 lines
Quoted 6 lines
it was
not deleted from thephy_listof the parent port.2. The rate of the newly connected SATA device to phy0 is less than 1.5G, and its
sas_addresswas set to 0. After creating port 7:7:0is 7:7:0 the port which the SATA device is part of?
Quoted 4 lines
, it attempts to
add the expander's other zero-addressed phy to this port.3. When adding phy19 to port-7:7:0
It's a new port create by phy00:U:5. after the log:
[562240.062536] sas: ex 500e004aaaaaaa1f phy0 new device attached [562240.062616] sas: ex 500e004aaaaaaa1f phy00:U:5 attached: 0000000000000000 (stp)
Quoted 2 lines
Which would be the incorrect thing to do, right? I am basing that on my assumption that 7:7:0 is the port which the SATA device is part of.
Yes. It is created by the sata device with zero address.
Thanks,
Xingui