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>, <john.garry2@mail.dcu.ie>,
	<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<zhangfei.gao@linaro.org>, Xiaofei Tan <tanxiaofei@huawei.com>,
	John Garry <john.garry@huawei.com>
Subject: [PATCH 17/23] scsi: hisi_sas: handle PHY UP+DOWN simultaneous irq
Date: Thu, 23 Mar 2017 01:25:33 +0800	[thread overview]
Message-ID: <1490203539-228029-18-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1490203539-228029-1-git-send-email-john.garry@huawei.com>

From: Xiaofei Tan <tanxiaofei@huawei.com>

Handle the situation that PHY UP and DOWN irq happen simultaneously.
There is no mechanism of SoC HW to ensure this situation will never
happen. So, we add this handle just in case.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 56 +++++++++++++++++++++++-----------
 1 file changed, 39 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 8e869d9..45bd69d 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -2285,7 +2285,7 @@ static int prep_abort_v2_hw(struct hisi_hba *hisi_hba,
 
 static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
 {
-	int i, res = 0;
+	int i, res = IRQ_HANDLED;
 	u32 context, port_id, link_rate, hard_phy_linkrate;
 	struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
 	struct asd_sas_phy *sas_phy = &phy->sas_phy;
@@ -2373,7 +2373,6 @@ static bool check_any_wideports_v2_hw(struct hisi_hba *hisi_hba)
 
 static int phy_down_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
 {
-	int res = 0;
 	u32 phy_state, sl_ctrl, txid_auto;
 	struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
 	struct hisi_sas_port *port = phy->port;
@@ -2398,7 +2397,7 @@ static int phy_down_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
 	hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, CHL_INT0_NOT_RDY_MSK);
 	hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 0);
 
-	return res;
+	return IRQ_HANDLED;
 }
 
 static irqreturn_t int_phy_updown_v2_hw(int irq_no, void *p)
@@ -2406,35 +2405,58 @@ static irqreturn_t int_phy_updown_v2_hw(int irq_no, void *p)
 	struct hisi_hba *hisi_hba = p;
 	u32 irq_msk;
 	int phy_no = 0;
-	irqreturn_t res = IRQ_HANDLED;
 
 	irq_msk = (hisi_sas_read32(hisi_hba, HGC_INVLD_DQE_INFO)
 		   >> HGC_INVLD_DQE_INFO_FB_CH0_OFF) & 0x1ff;
 	while (irq_msk) {
 		if (irq_msk  & 1) {
-			u32 irq_value = hisi_sas_phy_read32(hisi_hba, phy_no,
-							    CHL_INT0);
+			u32 reg_value = hisi_sas_phy_read32(hisi_hba, phy_no,
+					    CHL_INT0);
+
+			switch (reg_value & (CHL_INT0_NOT_RDY_MSK |
+					CHL_INT0_SL_PHY_ENABLE_MSK)) {
 
-			if (irq_value & CHL_INT0_SL_PHY_ENABLE_MSK)
+			case CHL_INT0_SL_PHY_ENABLE_MSK:
 				/* phy up */
-				if (phy_up_v2_hw(phy_no, hisi_hba)) {
-					res = IRQ_NONE;
-					goto end;
-				}
+				if (phy_up_v2_hw(phy_no, hisi_hba) ==
+				    IRQ_NONE)
+					return IRQ_NONE;
+				break;
 
-			if (irq_value & CHL_INT0_NOT_RDY_MSK)
+			case CHL_INT0_NOT_RDY_MSK:
 				/* phy down */
-				if (phy_down_v2_hw(phy_no, hisi_hba)) {
-					res = IRQ_NONE;
-					goto end;
+				if (phy_down_v2_hw(phy_no, hisi_hba) ==
+				    IRQ_NONE)
+					return IRQ_NONE;
+				break;
+
+			case (CHL_INT0_NOT_RDY_MSK |
+					CHL_INT0_SL_PHY_ENABLE_MSK):
+				reg_value = hisi_sas_read32(hisi_hba,
+						PHY_STATE);
+				if (reg_value & BIT(phy_no)) {
+					/* phy up */
+					if (phy_up_v2_hw(phy_no, hisi_hba) ==
+					    IRQ_NONE)
+						return IRQ_NONE;
+				} else {
+					/* phy down */
+					if (phy_down_v2_hw(phy_no, hisi_hba) ==
+					    IRQ_NONE)
+						return IRQ_NONE;
 				}
+				break;
+
+			default:
+				break;
+			}
+
 		}
 		irq_msk >>= 1;
 		phy_no++;
 	}
 
-end:
-	return res;
+	return IRQ_HANDLED;
 }
 
 static void phy_bcast_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
-- 
1.9.1

  parent reply	other threads:[~2017-03-22 17:03 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 17:25 [PATCH 00/23] hisi_sas: error handling and other misc fixes and improvements John Garry
2017-03-22 17:25 ` [PATCH 01/23] scsi: hisi_sas: add to_hisi_sas_port() John Garry
2017-03-22 17:25 ` [PATCH 02/23] scsi: hisi_sas: add controller reset John Garry
2017-03-22 17:25 ` [PATCH 03/23] scsi: hisi_sas: move PHY init to hisi_sas_scan_start() John Garry
2017-03-22 17:25 ` [PATCH 04/23] scsi: hisi_sas: add softreset function for SATA disk John Garry
2017-03-22 17:25 ` [PATCH 05/23] scsi: hisi_sas: remove hisi_sas_port_deformed() John Garry
2017-03-22 17:25 ` [PATCH 06/23] scsi: hisi_sas: error hisi_sas_task_prep() when port down John Garry
2017-03-22 17:25 ` [PATCH 07/23] scsi: hisi_sas: only reset link for PHY_FUNC_LINK_RESET John Garry
2017-03-22 17:25 ` [PATCH 08/23] scsi: hisi_sas: modify error handling for v2 hw John Garry
2017-03-22 17:25 ` [PATCH 09/23] scsi: hisi_sas: modify hisi_sas_abort_task() for SSP John Garry
2017-03-22 17:25 ` [PATCH 10/23] scsi: hisi_sas: hardreset for SATA disk in LU reset John Garry
2017-03-22 17:25 ` [PATCH 11/23] scsi: hisi_sas: check for SAS_TASK_STATE_ABORTED in slot complete John Garry
2017-03-22 17:25 ` [PATCH 12/23] scsi: hisi_sas: free slots after hardreset John Garry
2017-03-22 17:25 ` [PATCH 13/23] scsi: hisi_sas: fix some sas_task.task_state_lock locking John Garry
2017-03-22 17:25 ` [PATCH 14/23] scsi: hisi_sas: remove task free'ing for timeouts John Garry
2017-03-22 17:25 ` [PATCH 15/23] scsi: hisi_sas: process error codes according to their priority John Garry
2017-03-22 17:25 ` [PATCH 16/23] scsi: hisi_sas: some modifications to v2 hw reg init values John Garry
2017-03-22 17:25 ` John Garry [this message]
2017-03-22 17:25 ` [PATCH 18/23] scsi: hisi_sas: rename hisi_sas_link_timeout_{enable, disable}_link John Garry
2017-03-22 17:25 ` [PATCH 19/23] scsi: hisi_sas: add hisi_sas_clear_nexus_ha() John Garry
2017-03-22 17:25 ` [PATCH 20/23] scsi: hisi_sas: release SMP slot in lldd_abort_task John Garry
2017-03-22 17:25 ` [PATCH 21/23] scsi: hisi_sas: check hisi_sas_lu_reset() error message John Garry
2017-03-22 17:25 ` [PATCH 22/23] scsi: hisi_sas: use dev_is_sata to identify SATA or SAS disk John Garry
2017-03-22 17:25 ` [PATCH 23/23] scsi: hisi_sas: add is_sata_phy_v2_hw() John Garry
2017-03-23 15:12 ` [PATCH 00/23] hisi_sas: error handling and other misc fixes and improvements 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=1490203539-228029-18-git-send-email-john.garry@huawei.com \
    --to=john.garry@huawei.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=john.garry2@mail.dcu.ie \
    --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 \
    --cc=zhangfei.gao@linaro.org \
    /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®