Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2701283rwd; Mon, 22 May 2023 03:02:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51KqTzmL+FGN9qurniCCU1MsriodSLq57z1/cfZ5m8Sk8osFyfE3JucVHapJxSrFVVp/N+ X-Received: by 2002:a05:6a20:4314:b0:10a:b812:bcc7 with SMTP id h20-20020a056a20431400b0010ab812bcc7mr5538966pzk.17.1684749751821; Mon, 22 May 2023 03:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684749751; cv=none; d=google.com; s=arc-20160816; b=c7biFu5HcrjGUWHRz3fGBnoKqHFlTlqRCAiFLjS4oAcK+QUnkKrVFFhBwXwd967xIT TJbUbiemFOKD7+Ev2nPtLXsaKg4qSfWQveG3Y9Fl1agyW4TRT8EZQwu36obafYpBbYas rFvcvGjS6Z5UsrpWYRTq7/Wd6hci00/pPdKSvpnf55gtsJFZw0+P+XofGxPgBT5kHhhZ YK48uq1luPdUaPa7A9zdEoyCyi1htwS/tV8rx2UkCFyaNbusf6pgwHAsF3ZY7wb7tKUA ZUJNneran/N2SLTCxkPXO9gOBXTojU9Zi2bI36CepgaPVwAuKuEQXKFJYpeNA3SRPJF9 EPLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=46mRmWpFEG2f+Ko05QXud158kvFlGSlPBFv2w3NEkOM=; b=IWKBpbg9bbtk4MjQwweJsfClw8JGUkkavDDc2HsKrqbv8F/d6NkwyPq3VfmZ8M1JpE H6bwK2vkOaigt6EghVIYG9EHhkZK/v8MzzyFBdH3D5uDoGL+0LlDojfb8lVQndgD7pkf bk1FFsP9pdm+6c/RgOJwlOGyX+E1rmiTrQOt/NlSe8CzSQJuxVr6bZh5rmFFYHLUEQUx YHzy6B45E7RdDv7vEk04f42WnHiuUUmOFc30yk1JEMBjKhjSEdfsnk/Vhyox8sV+mPD+ ewwRjGbDS38MfI0QvYxeStHctbhYTXp/nSjyCkD/LLpC/fCD2vPBtPKri4lJa/ejyLga mcmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j4HjcmHo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020aa79405000000b0064cc2c0c816si4519149pfo.218.2023.05.22.03.02.18; Mon, 22 May 2023 03:02:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j4HjcmHo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232621AbjEVJoZ (ORCPT + 99 others); Mon, 22 May 2023 05:44:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232648AbjEVJoV (ORCPT ); Mon, 22 May 2023 05:44:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62726F9; Mon, 22 May 2023 02:44:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 92C7760C1B; Mon, 22 May 2023 09:44:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1090C433D2; Mon, 22 May 2023 09:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684748656; bh=SVoYzzxZuFTGXh87Jk2YnPaJ8G3ijBqVH+39j9Y0BD4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=j4HjcmHoE11NThX3xZMpEsBFoaasEqREvcKGYj7W5KNBsA1RFh51lpq8O9GhYSrbw 6axF4z76Hon97BhDohwjxWKX+c1YI1G005Xxglj1YHOE86t5VpxGSEpKPB2L9r4kNL L+Sx5Az8cq0xSJD0cVQ/JDERZ00m3L9v3StMsxIpMh++hq4MsUZL0gzyjwindVLWMU EnwdkW2L3qFKVWz3jJ/7ODjFPz8wBIsf+e1L5JfXhs/Qcnuo22p1onEESS1oJYMbQE x72CqHg+Kfufd3tYMKwh6jYMf4rKQ83PxF2W+t3I6TYohGeZiALMZT231yN363AhOY yFkOkhCXKrfFg== Message-ID: <960e2aac-1769-6037-dd77-58999313fefc@kernel.org> Date: Mon, 22 May 2023 18:44:13 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2] ata: libata-scsi: Fix get identity data failed Content-Language: en-US To: Jason Yan , yangxingui , jejb@linux.ibm.com, martin.petersen@oracle.com, john.g.garry@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, prime.zeng@hisilicon.com, kangfenglong@huawei.com References: <20230505025712.19438-1-yangxingui@huawei.com> <291f1d97-9195-45ac-8e12-058f5c797277@kernel.org> <02d36ee9-cdad-454d-d822-95442d7bd67b@huawei.com> <938d6b5b-0271-977d-f046-5fd70d29b3ca@huawei.com> <68953040-1622-254b-f6f8-b279eccacfb1@kernel.org> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/22/23 17: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 >> 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; >> } else { >> if (unlikely(scsidev->id || scsidev->lun)) >> return NULL; >> >> And running this on my setup, it works. This makes libsas added ports/devices >> look like AHCI ones, where all devices have ID 0 for the !pmp case. >> >> However, I am not sure this would be OK for all setups... >> >> John, >> >> Any idea if there is any cases where libsas managed drives would endup not being >> correctly identified by this change ? As long as a device always has its own >> port, I do not see any issue. But is there a case where we could have multiple >> devices on the same port ? Per libata, max is 2, and that is only for the IDE >> master/slave case. Otherwise, it is always 1. >> > > AFAIK, libsas does not support multiple devices on the same port. So > this change is ok for libsas. Yes, for libsas it is OK. But as is, it will break master+slave IDE setups... So the fix needs to be finer than this. > >> Not that looking at the pmp case, I am not confident at all that the >> identification is correct for libsas. But I do not think that anyone would ever >> connect a pmp box to a libsas HBA... >> > > libsas's does not support pmp either, and I do not see any future plans > to support pmp. Good. Dealing with that one is always painful. > So the above change (needs a ATA_FLAG_SAS_HOST check) looks good to me. Yes, this flag check is needed to avoid breaking IDE/pata. > It's better to make libsas behave as other ata drivers so that we can > drop the ATA_FLAG_SAS_HOST check. But this need tons of work for libsas. Yes, getting rid of this special casing with this flag would be really nice. It should not be needed. I will try to write a proper fix not using it for now, to facilitate removing the flag later. -- Damien Le Moal Western Digital Research