Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp762847rdb; Thu, 19 Oct 2023 20:25:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnbkVN6OMzEalHuY6yyTQhHlV5y1vlFixO5LXAKiPjo63MpOlAbIbT1Lly2dIjoMj+9cRq X-Received: by 2002:a17:90b:4d84:b0:25d:eca9:1621 with SMTP id oj4-20020a17090b4d8400b0025deca91621mr730592pjb.6.1697772320797; Thu, 19 Oct 2023 20:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697772320; cv=none; d=google.com; s=arc-20160816; b=LJv33JO2TnBCVEE3AbnP1EpFi4TLg5QVImv8DLEwoWVy9vCtL/x3ovWso1nkD3+ozE kuCjwgfOrsnsJAkkk8qK4bt1xa1HjTsF0WgPvGzYysFBbTOGnjfi8JgZN96NV5KaJajL 5FiZHYN0ZeAN3D5h+0TX+znqvbqo1raxVEtcJ7HyPgD4s2hyNwlYRwSsltHZO/hroTVJ xv9GiqNmNjN2wbuJgwRSGHOm+mhh8hob61wL0+giB0A3YgJJglw7DjNEEfOXnPKDlz64 K5DQDDzJtpSOznFLqyF3lNLvClFc+feBeQtO5Xf0kaiegIi/CFsxMpPCGK5tk/coUvg0 WZkQ== 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=qnDFfAWaxyZGoZTmoNZxw1HNAYVBoA401q3fuKZVvDU=; fh=31ILv3C66Vu8Os5wYQRk2/zBaEg3qw9UrWmtgv+ss/Y=; b=KqCmu3QMaeQnYBr0Bg70TjjFRChe6X2i7nLYWbh1QC0fUgpqQNn3lDVhUK++XE8OPq tg7bss9roKq/dHH+Ahek1lfo5Jm47BPbS9PlKFq8w/Oq2iu3GUeO5vqv6lYg/zck4+69 8RA5u1g7SOp+LJl0HIpEPj3CPB7nFUOS2sp0eh4NuGSNNUa6k9TQem/IoiBbsF/vP5h+ zCeXK1KzVaqasC+A9wNmOFRU/Ow3NOvztVKwujKh5xqqJPdZIivZ+uN6hg5Aj8RmZ+Vf yFxprVib6K266wpnKBKZY0AFmXpR6W6jxZRXgBdI36u3iuQwBj0mpc+PSdmdOpzdLil0 lZig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ng11-20020a17090b1a8b00b002792831692csi3732129pjb.58.2023.10.19.20.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 20:25:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3C60C832432A; Thu, 19 Oct 2023 20:25:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346850AbjJTDZH (ORCPT + 99 others); Thu, 19 Oct 2023 23:25:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233400AbjJTDZE (ORCPT ); Thu, 19 Oct 2023 23:25:04 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF5A2181; Thu, 19 Oct 2023 20:25:00 -0700 (PDT) Received: from canpemm100004.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SBVJ367hGzrTKr; Fri, 20 Oct 2023 11:22:11 +0800 (CST) Received: from [10.174.179.14] (10.174.179.14) by canpemm100004.china.huawei.com (7.192.105.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 20 Oct 2023 11:24:57 +0800 Subject: Re: [PATCH] scsi: libsas: fix set zero-address when device-type != NO_DEVICE To: Xingui Yang , , , CC: , , , , , References: <20231020024240.7708-1-yangxingui@huawei.com> From: Jason Yan Message-ID: <31524a87-9e02-5e43-5d71-5747c2e6e6b0@huawei.com> Date: Fri, 20 Oct 2023 11:24:56 +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: <20231020024240.7708-1-yangxingui@huawei.com> 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: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm100004.china.huawei.com (7.192.105.92) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 20:25:18 -0700 (PDT) On 2023/10/20 10:42, Xingui Yang wrote: > phy->attached_sas_addr will be set to a zero-address when > phy->linkrate < SAS_LINK_RATE_1_5_GBPS but device-type != NO_DEVICE, > and it may trigger BUG() as follows when do revalidate with zero-address: Hi Xingui, Why is this zero-addressed PHY added to another port? A zero-addressed PHY should not belong to any port. Thanks, Jason > > [562240.062536] sas: ex 500e004aaaaaaa1f phy0 new device attached > [562240.062616] sas: ex 500e004aaaaaaa1f phy00:U:5 attached: 0000000000000000 (stp) > [562240.062680] port-7:7:0: trying to add phy phy-7:7:19 fails: it's already part of another port > [562240.085064] ------------[ cut here ]------------ > [562240.096612] kernel BUG at drivers/scsi/scsi_transport_sas.c:1083! > [562240.109611] Internal error: Oops - BUG: 0 [#1] SMP > [562240.343518] Process kworker/u256:3 (pid: 435909, stack limit = 0x0000000003bcbebf) > [562240.421714] Workqueue: 0000:b4:02.0_disco_q sas_revalidate_domain [libsas] > [562240.437173] pstate: 40c00009 (nZcv daif +PAN +UAO) > [562240.450478] pc : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] > [562240.465283] lr : sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] > [562240.479751] sp : ffff0000300cfa70 > [562240.674822] Call trace: > [562240.682709] sas_port_add_phy+0x13c/0x168 [scsi_transport_sas] > [562240.694013] sas_ex_get_linkrate.isra.5+0xcc/0x128 [libsas] > [562240.704957] sas_ex_discover_end_dev+0xfc/0x538 [libsas] > [562240.715508] sas_ex_discover_dev+0x3cc/0x4b8 [libsas] > [562240.725634] sas_ex_discover_devices+0x9c/0x1a8 [libsas] > [562240.735855] sas_ex_revalidate_domain+0x2f0/0x450 [libsas] > [562240.746123] sas_revalidate_domain+0x158/0x160 [libsas] > [562240.756014] process_one_work+0x1b4/0x448 > [562240.764548] worker_thread+0x54/0x468 > [562240.772562] kthread+0x134/0x138 > [562240.779989] ret_from_fork+0x10/0x18 > > So set a zero-address for phy->attached_sas_addr only when > phy->attached_dev_type == NO_DEVICE. > > Fixes: 7d1d86518118 ("[SCSI] libsas: fix false positive 'device attached' conditions") > > Signed-off-by: Xingui Yang > --- > drivers/scsi/libsas/sas_expander.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c > index a2204674b680..5a81754d3768 100644 > --- a/drivers/scsi/libsas/sas_expander.c > +++ b/drivers/scsi/libsas/sas_expander.c > @@ -239,8 +239,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, > /* help some expanders that fail to zero sas_address in the 'no > * device' case > */ > - if (phy->attached_dev_type == SAS_PHY_UNUSED || > - phy->linkrate < SAS_LINK_RATE_1_5_GBPS) > + if (phy->attached_dev_type == SAS_PHY_UNUSED) > memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); > else > memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE); >