Re: [PATCH v3 1/3] scsi: hisi_sas: Enable force phy when SATA disk directly connected

John Garry
2025-03-04T09:49:25Z

On 27/02/2025 08:33, yangxingui wrote:
> Hi, John
>
> On 2025/2/26 16:57, John Garry wrote:
>
>>
>> The lldd_dev_found CB is where you should set the itct, and it is only
>> possible to do that if you report the device gone first. So that seems
>> like a simpler solution.

Sure, something like that - you just need to get libsas to trigger the
proper hw port id assignment for the device. As for specific
implementation in the LLDD, that up to you guys.

Thanks,
John

> Solution as follow?
> +static bool hisi_sas_hw_port_id_changed(struct hisi_hba *hisi_hba, int
> phy_no)
> +{
> +       struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
> +       struct asd_sas_phy *sas_phy = &phy->sas_phy;
> +       struct device *dev = hisi_hba->dev;
> +       struct asd_sas_port *sas_port;
> +       struct hisi_sas_port *port;
> +
> +       if (!sas_phy->port)
> +               return false;
> +
> +       sas_port = sas_phy->port;
> +       port = to_hisi_sas_port(sas_port);
> +       if (phy->port_id == port->id)
> +               return false;
> +
> +       dev_info(dev, "phy%d's hw port id changed from %d to %llu\n",
> +                phy_no, port->id, phy->port_id);
> +
> +       return true;
> +}
> +
>  static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int
> slot_idx)
>  {
>         void *bitmap = hisi_hba->slot_index_tags;
> @@ -856,6 +878,14 @@ static void hisi_sas_phyup_work_common(struct
> work_struct *work,
>         struct asd_sas_phy *sas_phy = &phy->sas_phy;
>         int phy_no = sas_phy->id;
>
> +       if (hisi_sas_hw_port_id_changed(hisi_hba, phy_no)) {
> +               sas_phy_disconnected(sas_phy);
> +               phy->phy_attached = 0;
> +               sas_notify_port_event(sas_phy, PORTE_LINK_RESET_ERR,
> GFP_ATOMIC);
> +               hisi_sas_notify_phy_event(phy, HISI_PHYE_LINK_RESET);
> +               return;
> +       }
> +
>
> Thanks,
> Xingui