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 07/19] scsi: hisi_sas: add an mechanism to do reset work synchronously
Date: Sat, 9 Dec 2017 01:16:38 +0800	[thread overview]
Message-ID: <1512753410-50924-8-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>

Sometimes it is required to know when the controller reset
has completed and also if it has completed successfully.
For such places, we call hisi_sas_controller_reset() directly
before. That may lead to multiple calls to this function.

This patch create a per-reset structure which contains
a completion structure and status flag to know when the reset
completes and also the status. It is also in hisi_hba.wq to
do reset work.

As all host reset works are done in hisi_hba.wq, we don't worry
multiple calls to hisi_sas_controller_reset().

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas.h      | 26 ++++++++++++++++++++++++++
 drivers/scsi/hisi_sas/hisi_sas_main.c | 19 ++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index b2534ca..71bc8ea 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -99,6 +99,31 @@ struct hisi_sas_hw_error {
 	const struct hisi_sas_hw_error *sub;
 };
 
+struct hisi_sas_rst {
+	struct hisi_hba *hisi_hba;
+	struct completion *completion;
+	struct work_struct work;
+	bool done;
+};
+
+#define HISI_SAS_RST_WORK_INIT(r, c) \
+	{	.hisi_hba = hisi_hba, \
+		.completion = &c, \
+		.work = __WORK_INITIALIZER(r.work, \
+				hisi_sas_sync_rst_work_handler), \
+		.done = false, \
+		}
+
+#define HISI_SAS_DECLARE_RST_WORK_ON_STACK(r) \
+	DECLARE_COMPLETION_ONSTACK(c); \
+	DECLARE_WORK(w, hisi_sas_sync_rst_work_handler); \
+	struct hisi_sas_rst r = HISI_SAS_RST_WORK_INIT(r, c)
+
+enum hisi_sas_bit_err_type {
+	HISI_SAS_ERR_SINGLE_BIT_ECC = 0x0,
+	HISI_SAS_ERR_MULTI_BIT_ECC = 0x1,
+};
+
 struct hisi_sas_phy {
 	struct hisi_hba	*hisi_hba;
 	struct hisi_sas_port	*port;
@@ -426,5 +451,6 @@ extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,
 				    struct hisi_sas_slot *slot);
 extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba);
 extern void hisi_sas_rst_work_handler(struct work_struct *work);
+extern void hisi_sas_sync_rst_work_handler(struct work_struct *work);
 extern void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba);
 #endif
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index e4b3092..fb162c0 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1299,8 +1299,14 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun)
 static int hisi_sas_clear_nexus_ha(struct sas_ha_struct *sas_ha)
 {
 	struct hisi_hba *hisi_hba = sas_ha->lldd_ha;
+	HISI_SAS_DECLARE_RST_WORK_ON_STACK(r);
 
-	return hisi_sas_controller_reset(hisi_hba);
+	queue_work(hisi_hba->wq, &r.work);
+	wait_for_completion(r.completion);
+	if (r.done)
+		return TMF_RESP_FUNC_COMPLETE;
+
+	return TMF_RESP_FUNC_FAILED;
 }
 
 static int hisi_sas_query_task(struct sas_task *task)
@@ -1820,6 +1826,17 @@ void hisi_sas_rst_work_handler(struct work_struct *work)
 }
 EXPORT_SYMBOL_GPL(hisi_sas_rst_work_handler);
 
+void hisi_sas_sync_rst_work_handler(struct work_struct *work)
+{
+	struct hisi_sas_rst *rst =
+		container_of(work, struct hisi_sas_rst, work);
+
+	if (!hisi_sas_controller_reset(rst->hisi_hba))
+		rst->done = true;
+	complete(rst->completion);
+}
+EXPORT_SYMBOL_GPL(hisi_sas_sync_rst_work_handler);
+
 int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba)
 {
 	struct device *dev = hisi_hba->dev;
-- 
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 ` [PATCH 04/19] scsi: hisi_sas: optimise port id refresh function John Garry
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 ` John Garry [this message]
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-8-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®