From: Yijing Wang <wangyijing@huawei.com>
To: <jejb@linux.vnet.ibm.com>, <martin.petersen@oracle.com>
Cc: <chenqilin2@huawei.com>, <hare@suse.com>,
<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<chenxiang66@hisilicon.com>, <huangdaode@hisilicon.com>,
<wangkefeng.wang@huawei.com>, <zhaohongjiang@huawei.com>,
<dingtianhong@huawei.com>, <guohanjun@huawei.com>,
<yanaijie@huawei.com>, <hch@lst.de>, <dan.j.williams@intel.com>,
<emilne@redhat.com>, <thenzl@redhat.com>, <wefu@redhat.com>,
<charles.chenxin@huawei.com>, <chenweilong@huawei.com>,
<john.garry@huawei.com>, Yijing Wang <wangyijing@huawei.com>,
"Johannes Thumshirn" <jthumshirn@suse.de>
Subject: [PATCH v3 6/7] libsas: add wait-complete support to sync discovery event
Date: Mon, 10 Jul 2017 15:06:08 +0800 [thread overview]
Message-ID: <1499670369-44143-7-git-send-email-wangyijing@huawei.com> (raw)
In-Reply-To: <1499670369-44143-1-git-send-email-wangyijing@huawei.com>
Introduce a sync flag to tag discovery event whether need to
sync execute, per-event wait-complete ensure sync.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: John Garry <john.garry@huawei.com>
CC: Johannes Thumshirn <jthumshirn@suse.de>
CC: Ewan Milne <emilne@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Tomas Henzl <thenzl@redhat.com>
CC: Dan Williams <dan.j.williams@intel.com>
---
drivers/scsi/libsas/sas_discover.c | 8 ++++++--
drivers/scsi/libsas/sas_expander.c | 12 +++++++++++-
drivers/scsi/libsas/sas_internal.h | 27 +++++++++++++++++++++++++++
include/scsi/libsas.h | 2 ++
4 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index a25d648..d68f8dd 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -378,6 +378,7 @@ void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *dev)
list_del_init(&dev->disco_list_node);
sas_rphy_free(dev->rphy);
sas_unregister_common_dev(port, dev);
+ sas_disc_cancel_sync(&port->disc.disc_work[DISCE_DESTRUCT]);
return;
}
@@ -541,6 +542,7 @@ static void sas_discover_common_fn(struct work_struct *work)
struct asd_sas_port *port = ev->port;
sas_event_fns[ev->type](work);
+ sas_disc_wakeup(ev);
sas_port_put(port);
}
@@ -571,8 +573,10 @@ static void sas_chain_work(struct sas_ha_struct *ha, struct sas_work *sw)
else
ret = scsi_queue_work(ha->core.shost, &sw->work);
- if (ret != 1)
+ if (ret != 1) {
sas_port_put(port);
+ sas_disc_cancel_sync(ev);
+ }
}
static void sas_chain_event(int event, unsigned long *pending,
@@ -592,9 +596,9 @@ int sas_discover_event(struct asd_sas_port *port, enum discover_event ev)
{
struct sas_discovery *disc;
+ disc = &port->disc;
if (!port)
return 0;
- disc = &port->disc;
BUG_ON(ev >= DISC_NUM_EVENTS);
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 570b2cb..9d26c28 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -822,14 +822,18 @@ static struct domain_device *sas_ex_discover_end_dev(
list_add_tail(&child->disco_list_node, &parent->port->disco_list);
+ sas_disc_wait_init(child->port, DISCE_PROBE);
res = sas_discover_sata(child);
if (res) {
+ sas_disc_cancel_sync(&child->port->disc.disc_work[DISCE_PROBE]);
SAS_DPRINTK("sas_discover_sata() for device %16llx at "
"%016llx:0x%x returned 0x%x\n",
SAS_ADDR(child->sas_addr),
SAS_ADDR(parent->sas_addr), phy_id, res);
goto out_list_del;
}
+ sas_disc_wait_completion(child->port, DISCE_PROBE);
+
} else
#endif
if (phy->attached_tproto & SAS_PROTOCOL_SSP) {
@@ -847,14 +851,17 @@ static struct domain_device *sas_ex_discover_end_dev(
list_add_tail(&child->disco_list_node, &parent->port->disco_list);
+ sas_disc_wait_init(child->port, DISCE_PROBE);
res = sas_discover_end_dev(child);
if (res) {
+ sas_disc_cancel_sync(&child->port->disc.disc_work[DISCE_PROBE]);
SAS_DPRINTK("sas_discover_end_dev() for device %16llx "
"at %016llx:0x%x returned 0x%x\n",
SAS_ADDR(child->sas_addr),
SAS_ADDR(parent->sas_addr), phy_id, res);
goto out_list_del;
}
+ sas_disc_wait_completion(child->port, DISCE_PROBE);
} else {
SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n",
phy->attached_tproto, SAS_ADDR(parent->sas_addr),
@@ -1890,8 +1897,11 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent,
if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
child->dev_type == SAS_FANOUT_EXPANDER_DEVICE)
sas_unregister_ex_tree(parent->port, child);
- else
+ else {
+ sas_disc_wait_init(parent->port, DISCE_DESTRUCT);
sas_unregister_dev(parent->port, child);
+ sas_disc_wait_completion(parent->port, DISCE_DESTRUCT);
+ }
found = child;
break;
}
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index 890b5d26..09a9b10 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -134,6 +134,33 @@ static inline void sas_port_get(struct asd_sas_port *port)
kref_get(&port->ref);
}
+static inline void sas_disc_cancel_sync(struct sas_discovery_event *event)
+{
+ event->is_sync = false;
+}
+
+static inline void sas_disc_wakeup(struct sas_discovery_event *event)
+{
+ if (event->is_sync)
+ complete(&event->completion);
+}
+
+static inline void sas_disc_wait_init(struct asd_sas_port *port,
+ enum discover_event event)
+{
+ port->disc.disc_work[event].is_sync = true;
+ init_completion(&port->disc.disc_work[event].completion);
+}
+
+static inline void sas_disc_wait_completion(struct asd_sas_port *port,
+ enum discover_event event)
+{
+ if (port->disc.disc_work[event].is_sync) {
+ wait_for_completion(&port->disc.disc_work[event].completion);
+ port->disc.disc_work[event].is_sync = false;
+ }
+}
+
#ifdef CONFIG_SCSI_SAS_HOST_SMP
extern int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
struct request *rsp);
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 4bcb9fe..21e9fb140 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -243,6 +243,8 @@ struct sas_discovery_event {
struct sas_work work;
struct asd_sas_port *port;
enum discover_event type;
+ bool is_sync;
+ struct completion completion;
};
static inline struct sas_discovery_event *to_sas_discovery_event(struct work_struct *work)
--
2.5.0
next prev parent reply other threads:[~2017-07-10 7:02 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-10 7:06 [PATCH v3 0/7] Enhance libsas hotplug feature Yijing Wang
2017-07-10 7:06 ` [PATCH v3 1/7] libsas: Use static sas event pool to appease sas event lost Yijing Wang
2017-07-11 15:37 ` John Garry
2017-07-12 2:06 ` wangyijing
2017-07-12 8:17 ` John Garry
2017-07-12 8:47 ` wangyijing
2017-07-12 10:13 ` John Garry
2017-07-13 2:13 ` wangyijing
2017-07-14 6:40 ` Hannes Reinecke
2017-07-10 7:06 ` [PATCH v3 2/7] libsas: remove unused port_gone_completion Yijing Wang
2017-07-11 15:54 ` John Garry
2017-07-12 2:18 ` wangyijing
2017-07-14 6:40 ` Hannes Reinecke
2017-07-10 7:06 ` [PATCH v3 3/7] libsas: Use new workqueue to run sas event Yijing Wang
2017-07-14 6:42 ` Hannes Reinecke
2017-07-10 7:06 ` [PATCH v3 4/7] libsas: add sas event wait-complete support Yijing Wang
2017-07-14 6:51 ` Hannes Reinecke
2017-07-14 7:46 ` wangyijing
2017-07-14 8:42 ` John Garry
2017-07-10 7:06 ` [PATCH v3 5/7] libsas: add a new workqueue to run probe/destruct discovery event Yijing Wang
2017-07-12 16:50 ` John Garry
2017-07-13 2:36 ` wangyijing
2017-07-14 6:52 ` Hannes Reinecke
2017-07-10 7:06 ` Yijing Wang [this message]
2017-07-12 13:51 ` [PATCH v3 6/7] libsas: add wait-complete support to sync " John Garry
2017-07-13 2:19 ` wangyijing
2017-07-14 6:53 ` Hannes Reinecke
2017-07-10 7:06 ` [PATCH v3 7/7] libsas: release disco mutex during waiting in sas_ex_discover_end_dev Yijing Wang
2017-07-13 16:10 ` John Garry
2017-07-14 1:44 ` wangyijing
2017-07-14 8:26 ` John Garry
2017-07-14 6:55 ` Hannes Reinecke
2017-07-12 9:59 ` [PATCH v3 0/7] Enhance libsas hotplug feature John Garry
2017-07-12 11:56 ` Johannes Thumshirn
2017-07-13 1:27 ` wangyijing
2017-07-13 1:37 ` wangyijing
2017-07-13 8:08 ` John Garry
2017-07-13 8:38 ` wangyijing
2017-07-14 8:19 ` wangyijing
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=1499670369-44143-7-git-send-email-wangyijing@huawei.com \
--to=wangyijing@huawei.com \
--cc=charles.chenxin@huawei.com \
--cc=chenqilin2@huawei.com \
--cc=chenweilong@huawei.com \
--cc=chenxiang66@hisilicon.com \
--cc=dan.j.williams@intel.com \
--cc=dingtianhong@huawei.com \
--cc=emilne@redhat.com \
--cc=guohanjun@huawei.com \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=huangdaode@hisilicon.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=john.garry@huawei.com \
--cc=jthumshirn@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=thenzl@redhat.com \
--cc=wangkefeng.wang@huawei.com \
--cc=wefu@redhat.com \
--cc=yanaijie@huawei.com \
--cc=zhaohongjiang@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®