RE: Issue in sas_ex_discover_dev() for multiple level of SAS expanders in a domain

Li, Eric (Honggang)
2024-05-08T08:29:15Z

> -----Original Message-----
> From: John Garry <john.g.garry@oracle.com>
> Sent: Wednesday, May 8, 2024 3:48 PM
> To: Li, Eric (Honggang) <Eric.H.Li@Dell.com>; Jason Yan <yanaijie@huawei.com>;
> james.bottomley@hansenpartnership.com; Martin K . Petersen <martin.petersen@oracle.com>
> Cc: linux-scsi@vger.kernel.org
> Subject: Re: Issue in sas_ex_discover_dev() for multiple level of SAS expanders in a domain
>
>
> [EXTERNAL EMAIL]
>
> On 08/05/2024 01:59, Li, Eric (Honggang) wrote:
> >>> Call to sas_ex_join_wide_port() makes the rest PHYs associated with
> >>> that existing port
> >> (making it become wideport) and set up sysfs between the PHY and
> >> port. > Set PHY_STATE_DISCOVERED would make the rest PHYs not being
> >> scanned/discovered again (as this wide port is already scanned).
> >>
> >> If you can just confirm that re-adding the code to set phy_state =
> >> DISCOVERED is good enough to see the SAS disks again, then this can
> >> be further discussed. >>
> > OK. I will work on that and keep you updated.
>
> I expect a flow like this for scanning of the downstream expander:
>
> sas_discover_new(struct domain_device *dev [upstream expander], int
> phy_id_a) -> sas_ex_discover_devices(single = -1) ->
> sas_ex_discover_dev(phy_id_b) for each phy in @dev non-vacant and non-discovered ->
> sas_ex_discover_expander( [downstream expander]) for first phy scanned which belongs to
> downstream expander.
>
> And following that we have continue to scan phys in sas_ex_discover_devices(single = -1) ->
> sas_ex_discover_dev(phy_id_b) ->
> sas_ex_join_wide_port() -> for each non-vacant and non-discovered phy in phy_id_b which
> matches that downstream expander.
>
> Can you see why this does not actually work/occur?
>

before calling sas_ex_join_wide_port(), sas_dev_present_in_domain() finds the attached_sas_address of PHY (phy_id_b) is already in the domain of that root port, and then disable all PHYs to that downstream expander (in sas_ex_disable_port(dev, attached_sas_addr))
Therefore, I think we need to switch the order of function call to sas_ex_join_wide_port() and sas_dev_present_in_domain().