public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: John Garry <john.g.garry@oracle.com>,
	Jason Yan <yanaijie@huawei.com>,
	yangxingui <yangxingui@huawei.com>,
	jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	linuxarm@huawei.com, prime.zeng@hisilicon.com,
	kangfenglong@huawei.com
Subject: Re: [PATCH v2] ata: libata-scsi: Fix get identity data failed
Date: Mon, 22 May 2023 20:47:54 +0900	[thread overview]
Message-ID: <2a5f6751-7120-1ea8-1a1e-d401b433a34a@kernel.org> (raw)
In-Reply-To: <43d5ba4a-efc7-09ae-74dc-81b19f635a19@oracle.com>

On 5/22/23 20:28, John Garry wrote:
> On 22/05/2023 09:00, Jason Yan wrote:
>>
>> OK, so the issue is that __ata_scsi_find_dev() calls ata_find_dev() with 
>> devno
>> == scsidev->id. This leads to devno being 0, 1, 2 and 3 for connected 
>> drives
> 
> This numbering comes from sas_rphy_add():
> ...
> if (identify->device_type == SAS_END_DEVICE &&
>      (identify->target_port_protocols &
>       (SAS_PROTOCOL_SSP | SAS_PROTOCOL_STP | SAS_PROTOCOL_SATA)))
> 	rphy->scsi_target_id = sas_host->next_target_id++;
> 
> ..
> 
> 	scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, lun,
> SCSI_SCAN_INITIAL);
> }
> 
> So libata and scsi_transport_sas just use different sdev id numbering 
> schemes for host scan.
> 
>> sdd, sd1, sdf and sdg, as shown by lsscsi. However, each drive has its own
>> port+link, with the link for each one having  ata_link_max_devices() == 
>> 1, so
>> ata_find_dev() works only for the first drive with scsidev->id == 0 and 
>> fails
>> for the others. A naive fix would be this:
>>
>> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
>> index 7bb12deab70c..e4d6f17d7ccc 100644
>> --- a/drivers/ata/libata-scsi.c
>> +++ b/drivers/ata/libata-scsi.c
>> @@ -2718,7 +2718,7 @@ static struct ata_device *__ata_scsi_find_dev(struct
>> ata_port *ap,
>>           if (!sata_pmp_attached(ap)) {
>>                   if (unlikely(scsidev->channel || scsidev->lun))
>>                           return NULL;
>> -               devno = scsidev->id;
>> +               devno = 0;
> Would this pattern work:
> 
> ata_for_each_dev(ata_dev, link, ALL) {
> 	if (ata_dev->sdev == sdev)
> 		return ata_dev;
> }

That would work too I think, even though a loop is a bit ugly...

> 
> If not, I think it's ok to have devno = 0 assignment under SAS_HOST 
> flag, even though it's far from ideal. Not both of these are not 
> preferred, then, as I mentioned before, some per-port callback to do the 
> conversion.

See the proper patch I posted a few min ago (I cc-ed you). I do not use SAS_HOST
flag :)

> 
> Thanks,
> John

-- 
Damien Le Moal
Western Digital Research


      reply	other threads:[~2023-05-22 11:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05  2:57 [PATCH v2] ata: libata-scsi: Fix get identity data failed Xingui Yang
2023-05-05  8:17 ` Damien Le Moal
2023-05-05  8:25   ` John Garry
2023-05-05  9:14     ` yangxingui
2023-05-05  9:51       ` John Garry
2023-05-06  9:57         ` yangxingui
2023-05-07 15:02         ` Damien Le Moal
2023-05-06  2:11       ` Jason Yan
2023-05-06  9:49         ` yangxingui
2023-05-07 14:59       ` Damien Le Moal
2023-05-05  9:06   ` yangxingui
2023-05-07 14:51     ` Damien Le Moal
2023-05-08  1:11       ` yangxingui
2023-05-22  1:35         ` Damien Le Moal
2023-05-22  7:02           ` Damien Le Moal
2023-05-22  8:00             ` Jason Yan
2023-05-22  9:44               ` Damien Le Moal
2023-05-22 11:28               ` John Garry
2023-05-22 11:47                 ` Damien Le Moal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a5f6751-7120-1ea8-1a1e-d401b433a34a@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=john.g.garry@oracle.com \
    --cc=kangfenglong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=martin.petersen@oracle.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=yanaijie@huawei.com \
    --cc=yangxingui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox