From patchwork Fri Dec 8 17:16:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 121211 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp867840qgn; Fri, 8 Dec 2017 08:35:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMYyxFwpIZ9F49U4R657akEt5+YLmS81YAOsEPEoSOYUyKyW0jSt1HgDtQe5yeDHfIFqc0QJ X-Received: by 10.84.128.197 with SMTP id a63mr19929275pla.340.1512750922670; Fri, 08 Dec 2017 08:35:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512750922; cv=none; d=google.com; s=arc-20160816; b=XCfIaSztCxLpu7Pm5VzX+aJQlWrWwjOmdMd1Nvy0HXPWgopMhk+jtuMWEt2i83MpL1 bo7/0od7yxel06KE3OicDNFXhvuaKGh5wvcBaTDoswq0fjyeK3I2Z1sIzA4XfJL1x7QR +/YBikr7Di7ydkZlqt0JAB/XLJInwUWWtLRKZUpl0R+DvKL7OmklGCv/LqLpqf/i3KSb xfbUV+hkNbrGXvWKMxRnbqcsg/uN90Kl88Y5uFWypEayR9EC0bcY9bQv5iBPeWgwGY6K 7bvPcZ1CycD+1JgJdNYPwYjibB2p2T3LiI7N5RTOTN2U4f0jfhODAyKChQMWGIe5zeFJ jpMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=8Pyvc7wEBKXkMCxg8bpsz/vmF93ah+sOiI/L82229lI=; b=TqIC/kFg7F3DXZbjG3q1WVUCWTmpUWuPEBGEOiuVGpFvyQ502NPyw8I8ZA/3hwyMIH lALiqmqXZ4uPcodr/z1gfNdtLDwubixShRZvOHoyGlMxEotCP5P/aRspA3SDf/zdsxdL eDyk0iWyQaQCPtX66vdazvjV57zxSeLzOj7KXeNQHCt2mvKKXhC46cHc0RAFze6V6Jbv GqglI04+CRg4dCPIGHCaHsbO7OVH5HVrJm0QGD9Pv89IRxD/jJQY+BQUqzU6kBUfoHVg Ww2S0LAWDHcAQfGHDpLUY9gcNj73Y3TdbQZkAx+uqo+rLKN9nkqJHItTr7mbM3MM6Eqd rXOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i191si5704252pge.391.2017.12.08.08.35.22; Fri, 08 Dec 2017 08:35:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754655AbdLHQfV (ORCPT + 18 others); Fri, 8 Dec 2017 11:35:21 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2229 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753157AbdLHQbC (ORCPT ); Fri, 8 Dec 2017 11:31:02 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id CED4B65A8F982; Sat, 9 Dec 2017 00:30:44 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.361.1; Sat, 9 Dec 2017 00:30:36 +0800 From: John Garry To: , CC: , , , Xiaofei Tan , "John Garry" Subject: [PATCH 04/19] scsi: hisi_sas: optimise port id refresh function Date: Sat, 9 Dec 2017 01:16:35 +0800 Message-ID: <1512753410-50924-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512753410-50924-1-git-send-email-john.garry@huawei.com> References: <1512753410-50924-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaofei Tan Currently refreshing the PHY port id after reset is done in the rescan topology function, which is quite late in the reset process. It could be moved earlier in the process, as the port id can be refreshed once the PHYs become ready. In addition to this, we should set the hisi_sas_dev port id to 0xff (invalid port id) if all PHYs of this port remain down for the same device. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 48 ++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 18 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 6446ce2..326ecb2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -990,27 +990,42 @@ static int hisi_sas_debug_issue_ssp_tmf(struct domain_device *device, sizeof(ssp_task), tmf); } -static void hisi_sas_refresh_port_id(struct hisi_hba *hisi_hba, - struct asd_sas_port *sas_port, enum sas_linkrate linkrate) +static void hisi_sas_refresh_port_id(struct hisi_hba *hisi_hba) { - struct hisi_sas_device *sas_dev; - struct domain_device *device; + u32 state = hisi_hba->hw->get_phys_state(hisi_hba); int i; for (i = 0; i < HISI_SAS_MAX_DEVICES; i++) { - sas_dev = &hisi_hba->devices[i]; - device = sas_dev->sas_device; + struct hisi_sas_device *sas_dev = &hisi_hba->devices[i]; + struct domain_device *device = sas_dev->sas_device; + struct asd_sas_port *sas_port; + struct hisi_sas_port *port; + struct hisi_sas_phy *phy = NULL; + struct asd_sas_phy *sas_phy; + if ((sas_dev->dev_type == SAS_PHY_UNUSED) - || !device || (device->port != sas_port)) + || !device || !device->port) continue; - hisi_hba->hw->clear_itct(hisi_hba, sas_dev); + sas_port = device->port; + port = to_hisi_sas_port(sas_port); + + list_for_each_entry(sas_phy, &sas_port->phy_list, port_phy_el) + if (state & BIT(sas_phy->id)) { + phy = sas_phy->lldd_phy; + break; + } + + if (phy) { + port->id = phy->port_id; - /* Update linkrate of directly attached device. */ - if (!device->parent) - device->linkrate = linkrate; + /* Update linkrate of directly attached device. */ + if (!device->parent) + device->linkrate = phy->sas_phy.linkrate; - hisi_hba->hw->setup_itct(hisi_hba, sas_dev); + hisi_hba->hw->setup_itct(hisi_hba, sas_dev); + } else + port->id = 0xff; } } @@ -1025,21 +1040,17 @@ static void hisi_sas_rescan_topology(struct hisi_hba *hisi_hba, u32 old_state, struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; struct asd_sas_phy *sas_phy = &phy->sas_phy; struct asd_sas_port *sas_port = sas_phy->port; - struct hisi_sas_port *port = to_hisi_sas_port(sas_port); bool do_port_check = !!(_sas_port != sas_port); if (!sas_phy->phy->enabled) continue; /* Report PHY state change to libsas */ - if (state & (1 << phy_no)) { - if (do_port_check && sas_port) { + if (state & BIT(phy_no)) { + if (do_port_check && sas_port && sas_port->port_dev) { struct domain_device *dev = sas_port->port_dev; _sas_port = sas_port; - port->id = phy->port_id; - hisi_sas_refresh_port_id(hisi_hba, - sas_port, sas_phy->linkrate); if (DEV_IS_EXPANDER(dev->dev_type)) sas_ha->notify_port_event(sas_phy, @@ -1088,6 +1099,7 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba) /* Init and wait for PHYs to come up and all libsas event finished. */ hisi_hba->hw->phys_init(hisi_hba); msleep(1000); + hisi_sas_refresh_port_id(hisi_hba); drain_workqueue(hisi_hba->wq); drain_workqueue(shost->work_q);