mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: <jejb@linux.vnet.ibm.com>, <martin.petersen@oracle.com>
Cc: <linuxarm@huawei.com>, <linux-scsi@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Xiaofei Tan <tanxiaofei@huawei.com>,
	"John Garry" <john.garry@huawei.com>
Subject: [PATCH 04/19] scsi: hisi_sas: optimise port id refresh function
Date: Sat, 9 Dec 2017 01:16:35 +0800	[thread overview]
Message-ID: <1512753410-50924-5-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1512753410-50924-1-git-send-email-john.garry@huawei.com>

From: Xiaofei Tan <tanxiaofei@huawei.com>

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 <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 48 ++++++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 18 deletions(-)

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);
 
-- 
1.9.1

  parent reply	other threads:[~2017-12-08 16:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-08 17:16 [PATCH 00/19] hisi_sas: PM, RAS, and other misc changes John Garry
2017-12-08 17:16 ` [PATCH 01/19] scsi: hisi_sas: initialize dq spinlock before use John Garry
2017-12-08 17:16 ` [PATCH 02/19] scsi: hisi_sas: fix dma_unmap_sg() parameter John Garry
2017-12-08 17:16 ` [PATCH 03/19] scsi: hisi_sas: relocate clearing ITCT and freeing device John Garry
2017-12-08 17:16 ` John Garry [this message]
2017-12-08 17:16 ` [PATCH 05/19] scsi: hisi_sas: some optimizations of host controller reset John Garry
2017-12-08 17:16 ` [PATCH 06/19] scsi: hisi_sas: modify hisi_sas_dev_gone() for reset John Garry
2017-12-08 17:16 ` [PATCH 07/19] scsi: hisi_sas: add an mechanism to do reset work synchronously John Garry
2017-12-08 17:16 ` [PATCH 08/19] scsi: hisi_sas: change ncq process for v3 hw John Garry
2017-12-08 17:16 ` [PATCH 09/19] scsi: hisi_sas: add RAS feature " John Garry
2017-12-08 17:16 ` [PATCH 10/19] scsi: hisi_sas: add some print to enhance debugging John Garry
2017-12-08 17:16 ` [PATCH 11/19] scsi: hisi_sas: improve int_chnl_int_v2_hw() consistency with v3 hw John Garry
2017-12-08 17:16 ` [PATCH 12/19] scsi: hisi_sas: add v2 hw port AXI error handling support John Garry
2017-12-08 17:16 ` [PATCH 13/19] scsi: hisi_sas: use an general way to delay PHY work John Garry
2017-12-08 17:16 ` [PATCH 14/19] scsi: hisi_sas: do link reset for some CHL_INT2 ints John Garry
2017-12-08 17:16 ` [PATCH 15/19] scsi: hisi_sas: judge result of internal abort John Garry
2017-12-08 17:16 ` [PATCH 16/19] scsi: hisi_sas: add internal abort dev in some places John Garry
2017-12-08 17:16 ` [PATCH 17/19] scsi: hisi_sas: fix SAS_QUEUE_FULL problem while running IO John Garry
2017-12-08 17:16 ` [PATCH 18/19] scsi: hisi_sas: re-add the lldd_port_deformed() John Garry
2017-12-08 17:16 ` [PATCH 19/19] scsi: hisi_sas: add v3 hw suspend and resume John Garry
2017-12-15  2:34 ` [PATCH 00/19] hisi_sas: PM, RAS, and other misc changes Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1512753410-50924-5-git-send-email-john.garry@huawei.com \
    --to=john.garry@huawei.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=martin.petersen@oracle.com \
    --cc=tanxiaofei@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®