Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2204989rdb; Tue, 20 Feb 2024 23:33:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXM0+sLWFM5pgu1iZ37ztbaucXU9M5Ao2vPPFR/q0a7QJASKwEveiBUnpVP6vkZEotBQpJhAibIKnagWNJFtra40vYg96VztKLAwQo6Uw== X-Google-Smtp-Source: AGHT+IFpeZIDRgGwz1pQpoaPCALud6qbLWV3HhhNPQsEnvCiJqQ0yyjS5FsUS09zbA49G2Jsj90X X-Received: by 2002:a05:620a:4056:b0:787:83b3:2283 with SMTP id i22-20020a05620a405600b0078783b32283mr1784738qko.23.1708500821361; Tue, 20 Feb 2024 23:33:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708500821; cv=pass; d=google.com; s=arc-20160816; b=i/xKipNizlS+qUMi6ojUBYtyv7rf8xe2JqtbYvcQRUqc3w9XBFpCDvvwn7FAsAOGu/ 5RVtlUMrHwnc8FGjPElN/2lFu2Y++HfI+hKR0x3xgLIFvDsZ2UezK2zzFEclX2FdcuZu H+HDfXVlnE7z7PtheSQAkyji3xrehjQZMTikkjK7kprr0qHuCSH0LhbFJWUHEf56L+TK XeRtWxgVbDvLI7GTm5WCOixvTLq3D2ITSkl17iczBgyTlRNS88rum5LNKiEoEvwDJBHu uOOvpTw9hc5C770OSIjaqJfMtgK1VBtaiwBbiHlp2rOiJ5HjkYAVE6vZoO3Rvky3wBR6 hlEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from; bh=7GgEXXWCQZf22Lksd8+ncIxFu8TgO0CpQj3ssJUtF2o=; fh=PKov2v7mtZqWrG2ToL14QCqscLF6oofVifdomTnOWI8=; b=jMY6DAfjWi02hobZ2HWUumtpaZ7xgaEAWLfH66c1tVwgz+QoXR0L11EA+J5KXGEGM4 mBNCU5xGsA2TIMtyjJ1dPrrM6lXdutKjW8xkN+hD1Tu4ekKXTN2y7OC0BrRL2dMz96pC sfqmORdj/GMKk2ldjslS9XhasiUhOILSy7v9ZG0AyLO953G6RTVauPfF6XxABrXo3dTd ikYleHzPQAsKYGNL/GRR74wu0O8JZfuqEURhNi5af/UhHUjOj1xmZ3FeNW5hit2fFFAX 3z3Q048A4Hvv7twvTtYaUTsdBRLx9My5kPhPQTrv/HR6jbCyo1Zza+L29rI1kbu6O3oB DbHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-74238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i3-20020a05620a144300b0078769caed44si6127346qkl.414.2024.02.20.23.33.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 23:33:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-74238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 20AE31C23363 for ; Wed, 21 Feb 2024 07:33:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58F803AC1B; Wed, 21 Feb 2024 07:33:34 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45AF823C9; Wed, 21 Feb 2024 07:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708500813; cv=none; b=JRlUK4Rn5wc4+obzesvExZyT9Hi4G23hMtfUFzkLu8SzicMYSR2WAuC2HX9qIeVVY6HrSmZqql/HI+4W2eiPO3xv43OX4hmZZxLbOK0X+UDMg7o2RJ71nkEh/Ctu1DrW3UJ/Vz69wF/0LPSUD1Atu/kHrYvjFBWMfRteBXkOMAQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708500813; c=relaxed/simple; bh=PlY8APXUkmE6j7kWNFypEEvOafZlgJQqQ7toSvbcGM0=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=T9a0tI6PxL4FpueF23hQqgF0A1g89QKrzT+p7qG1BscqhcmNdEsPrUOg0Z7DNfHTMux9dX6hW/NERlpWvq0I+g3+Jfq4nUM5eXZvlE2PR1SrFaEVWxUM0695kc0KYyDVtkfyFJN+b092pLGHhlUP24h7ppMUGfFm3VsOFSILbEs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Tfnv16861z1FLF3; Wed, 21 Feb 2024 15:28:29 +0800 (CST) Received: from dggpemd100001.china.huawei.com (unknown [7.185.36.94]) by mail.maildlp.com (Postfix) with ESMTPS id 6FCD51A0172; Wed, 21 Feb 2024 15:33:21 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by dggpemd100001.china.huawei.com (7.185.36.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Wed, 21 Feb 2024 15:33:21 +0800 From: Xingui Yang To: , , , , CC: , , , , , Subject: [PATCH] scsi: libsas: Fix disk not being scanned in after being removed Date: Wed, 21 Feb 2024 07:31:59 +0000 Message-ID: <20240221073159.29408-1-yangxingui@huawei.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemd100001.china.huawei.com (7.185.36.94) As of commit d8649fc1c5e4 ("scsi: libsas: Do discovery on empty PHY to update PHY info"), do discovery will send a new SMP_DISCOVER and update phy->phy_change_count. We found that if the disk is reconnected and phy change_count changes at this time, the disk scanning process will not be triggered. So update the PHY info with the last query results. Fixes: d8649fc1c5e4 ("scsi: libsas: Do discovery on empty PHY to update PHY info") Signed-off-by: Xingui Yang --- drivers/scsi/libsas/sas_expander.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index a2204674b680..9563f5589948 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -1681,6 +1681,10 @@ int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id, if (*type == 0) memset(sas_addr, 0, SAS_ADDR_SIZE); } + + if ((SAS_ADDR(sas_addr) == 0) || (res == -ECOMM)) + sas_set_ex_phy(dev, phy_id, disc_resp); + kfree(disc_resp); return res; } @@ -1972,11 +1976,6 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, if ((SAS_ADDR(sas_addr) == 0) || (res == -ECOMM)) { phy->phy_state = PHY_EMPTY; sas_unregister_devs_sas_addr(dev, phy_id, last); - /* - * Even though the PHY is empty, for convenience we discover - * the PHY to update the PHY info, like negotiated linkrate. - */ - sas_ex_phy_discover(dev, phy_id); return res; } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) && dev_type_flutter(type, phy->attached_dev_type)) { -- 2.17.1