Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5025611rwj; Tue, 20 Dec 2022 19:15:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXtwKNoayR2xyfAcbS4eWmsSn/WSW14ZazYEvj6hkrLVFe/ZEy/BdVPH3d4d4HAz2Il74Vxm X-Received: by 2002:a17:90a:6c22:b0:220:987d:d28a with SMTP id x31-20020a17090a6c2200b00220987dd28amr376456pjj.47.1671592525003; Tue, 20 Dec 2022 19:15:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671592524; cv=none; d=google.com; s=arc-20160816; b=gE5F9+wr1vyPozU0iV+sDiReeCtITb2uT02G49Bm/KntwcQGOnLzDF0Pdz6UT9f9uJ BiVLH5RU1c6FNQNMw/Mq4v9hBIIdMx4ziyXhY2yedCC46RvwqBvRHptpTPNZ/PC5CzZE ELr6um1o3RsO75Cr/QA9AyG1CiXeWRhOAVSM+1+/wRch2gIz/Qy83xIbpMzR3dpX7AbP ulrKTr+1KoWWLi6Usa9Kswen+BFqoUVgpGMIgfp3AazX0f3z6PjjaFEtbKbvgar2MFC3 wFiCRnJ6eV/MaYETz5k+6UfkFwdgzB1QU4e+w2aUMrUI8k6KoaiTt9l7Px1tZxVR0QYR r77A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ZNnrLQ6SF7gRECOOWyAEd0Oc/l77UWL4ceo7wA/uVx0=; b=I3iP99zoXOa2auEEWT2YgzGoEhIcdXesthokMK2HgSAuHma9kAOZeDD3iUhXoaRYJA nrqdE0WFzjRQ/ZllPtxpJ00gadWkstKTcM62Arqt9X7Fhp7zfAMzT1SUkQdp10K1BbP0 /BvSCSsl6NRQnTYy00zYXmvOCHTr5aOn2VfksYjbwMy5EPyeZTsYxeATgEjj9oUjXPhX KxYmZAbEv4qO0+uvvxr7TfIFkcYmdBoOtmExdIiVB7mEcZ7nHrpOlEik5+sPRwQryk4w L8DSeeoDOrDzewALorQiDrFOYbHcCbgCfnX3DjjXmzI/x4OISWA/84Smm5fOZWMzTP4o 9XSQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb8-20020a17090ae7c800b00219ecd75b15si745041pjb.4.2022.12.20.19.15.15; Tue, 20 Dec 2022 19:15:24 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbiLUCnG (ORCPT + 70 others); Tue, 20 Dec 2022 21:43:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbiLUCm5 (ORCPT ); Tue, 20 Dec 2022 21:42:57 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B97111D0EE; Tue, 20 Dec 2022 18:42:55 -0800 (PST) Received: from canpemm500004.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NcHlP64hHzJqV3; Wed, 21 Dec 2022 10:41:53 +0800 (CST) Received: from [10.174.179.14] (10.174.179.14) by canpemm500004.china.huawei.com (7.192.104.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 21 Dec 2022 10:42:53 +0800 Subject: Re: [PATCH] scsi: libsas: Grab the host lock in sas_ata_device_link_abort() To: Damien Le Moal , John Garry , Xingui Yang , , , CC: , , , , References: <20221220125349.45091-1-yangxingui@huawei.com> <4ec9dbed-1758-d6b4-dc1d-ac42e8c22731@oracle.com> From: Jason Yan Message-ID: <7347d117-6e0b-dd18-90a8-25685f757689@huawei.com> Date: Wed, 21 Dec 2022 10:42:52 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.14] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500004.china.huawei.com (7.192.104.92) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 2022/12/21 8:36, Damien Le Moal wrote: > On 2022/12/20 23:59, John Garry wrote: >> On 20/12/2022 12:53, Xingui Yang wrote: >>> Grab the host lock in sas_ata_device_link_abort() before calling >> >> This is should be the ata port lock, right? I know that the ata comments >> say differently. >> >>> ata_link_abort(), as the comment in ata_link_abort() mentions. >>> >> >> Can you please add a fixes tag? >> >>> Signed-off-by: Xingui Yang >> >> Reviewed-by: John Garry >> >>> --- >>> drivers/scsi/libsas/sas_ata.c | 3 +++ >>> 1 file changed, 3 insertions(+) >>> >>> diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c >>> index f7439bf9cdc6..4f2017b21e6d 100644 >>> --- a/drivers/scsi/libsas/sas_ata.c >>> +++ b/drivers/scsi/libsas/sas_ata.c >>> @@ -889,7 +889,9 @@ void sas_ata_device_link_abort(struct domain_device *device, bool force_reset) >>> { >>> struct ata_port *ap = device->sata_dev.ap; >>> struct ata_link *link = &ap->link; >>> + unsigned long flags; >>> >>> + spin_lock_irqsave(ap->lock, flags); >>> device->sata_dev.fis[2] = ATA_ERR | ATA_DRDY; /* tf status */ >>> device->sata_dev.fis[3] = ATA_ABORTED; /* tf error */ >>> >>> @@ -897,6 +899,7 @@ void sas_ata_device_link_abort(struct domain_device *device, bool force_reset) >>> if (force_reset) >>> link->eh_info.action |= ATA_EH_RESET; >>> ata_link_abort(link); > > Really need to add lockdep annotations in libata to avoid/catch such bugs... > Will work on that. Actually in libata there are many places calling ata_link_abort() not holding port lock. And some places are holding the real host lock(ata_host->lock) while calling ata_link_abort(). So if you add the lockdep annotations, there may be too many warnings. If these are real issues, we should fix them first. Thanks, Jason