linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Don Brace <don.brace@pmcs.com>
To: scott.teel@pmcs.com, Kevin.Barnett@pmcs.com,
	james.bottomley@parallels.com, hch@infradead.org,
	Justin.Lindley@pmcs.com, brace@pmcs.com
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH v2 48/48] hpsa: Use local workqueues instead of system workqueues
Date: Fri, 23 Jan 2015 16:45:17 -0600	[thread overview]
Message-ID: <20150123224517.14919.28023.stgit@brunhilda> (raw)
In-Reply-To: <20150123224020.14919.29458.stgit@brunhilda>

Suggested-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Webb Scales <webbnh@hp.com>
Reviewed-by: Kevin Barnett <Kevin.Barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   68 +++++++++++++++++++++++++++++++++++++++++----------
 drivers/scsi/hpsa.h |    2 ++
 2 files changed, 56 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 15ef65c..95d581c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -6787,14 +6787,14 @@ static int hpsa_offline_devices_ready(struct ctlr_info *h)
 	return 0;
 }
 
-
-static void hpsa_monitor_ctlr_worker(struct work_struct *work)
+static void hpsa_rescan_ctlr_worker(struct work_struct *work)
 {
 	unsigned long flags;
 	struct ctlr_info *h = container_of(to_delayed_work(work),
-					struct ctlr_info, monitor_ctlr_work);
-	detect_controller_lockup(h);
-	if (lockup_detected(h))
+					struct ctlr_info, rescan_ctlr_work);
+
+
+	if (h->remove_in_progress)
 		return;
 
 	if (hpsa_ctlr_needs_rescan(h) || hpsa_offline_devices_ready(h)) {
@@ -6803,17 +6803,44 @@ static void hpsa_monitor_ctlr_worker(struct work_struct *work)
 		hpsa_scan_start(h->scsi_host);
 		scsi_host_put(h->scsi_host);
 	}
-
 	spin_lock_irqsave(&h->lock, flags);
-	if (h->remove_in_progress) {
-		spin_unlock_irqrestore(&h->lock, flags);
+	if (!h->remove_in_progress)
+		queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work,
+				h->heartbeat_sample_interval);
+	spin_unlock_irqrestore(&h->lock, flags);
+}
+
+static void hpsa_monitor_ctlr_worker(struct work_struct *work)
+{
+	unsigned long flags;
+	struct ctlr_info *h = container_of(to_delayed_work(work),
+					struct ctlr_info, monitor_ctlr_work);
+
+	detect_controller_lockup(h);
+	if (lockup_detected(h))
 		return;
-	}
-	schedule_delayed_work(&h->monitor_ctlr_work,
+
+	spin_lock_irqsave(&h->lock, flags);
+	if (!h->remove_in_progress)
+		schedule_delayed_work(&h->monitor_ctlr_work,
 				h->heartbeat_sample_interval);
 	spin_unlock_irqrestore(&h->lock, flags);
 }
 
+static struct workqueue_struct *hpsa_create_controller_wq(struct ctlr_info *h,
+						char *name)
+{
+	struct workqueue_struct *wq = NULL;
+	char wq_name[20];
+
+	snprintf(wq_name, sizeof(wq_name), "%s_%d_hpsa", name, h->ctlr);
+	wq = alloc_ordered_workqueue(wq_name, 0);
+	if (!wq)
+		dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name);
+
+	return wq;
+}
+
 static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	int dac, rc;
@@ -6856,12 +6883,18 @@ reinit_after_soft_reset:
 	spin_lock_init(&h->scan_lock);
 	atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS);
 
-	h->resubmit_wq = alloc_workqueue("hpsa", WQ_MEM_RECLAIM, 0);
+	h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan");
+	if (!h->rescan_ctlr_wq) {
+		rc = -ENOMEM;
+		goto clean1;
+	}
+
+	h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit");
 	if (!h->resubmit_wq) {
-		dev_err(&h->pdev->dev, "Failed to allocate work queue\n");
 		rc = -ENOMEM;
 		goto clean1;
 	}
+
 	/* Allocate and clear per-cpu variable lockup_detected */
 	h->lockup_detected = alloc_percpu(u32);
 	if (!h->lockup_detected) {
@@ -6985,6 +7018,9 @@ reinit_after_soft_reset:
 	INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker);
 	schedule_delayed_work(&h->monitor_ctlr_work,
 				h->heartbeat_sample_interval);
+	INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker);
+	queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work,
+				h->heartbeat_sample_interval);
 	return 0;
 
 clean4:
@@ -6996,6 +7032,8 @@ clean2:
 clean1:
 	if (h->resubmit_wq)
 		destroy_workqueue(h->resubmit_wq);
+	if (h->rescan_ctlr_wq)
+		destroy_workqueue(h->rescan_ctlr_wq);
 	if (h->lockup_detected)
 		free_percpu(h->lockup_detected);
 	kfree(h);
@@ -7069,11 +7107,13 @@ static void hpsa_remove_one(struct pci_dev *pdev)
 	/* Get rid of any controller monitoring work items */
 	spin_lock_irqsave(&h->lock, flags);
 	h->remove_in_progress = 1;
-	cancel_delayed_work(&h->monitor_ctlr_work);
 	spin_unlock_irqrestore(&h->lock, flags);
+	cancel_delayed_work_sync(&h->monitor_ctlr_work);
+	cancel_delayed_work_sync(&h->rescan_ctlr_work);
+	destroy_workqueue(h->rescan_ctlr_wq);
+	destroy_workqueue(h->resubmit_wq);
 	hpsa_unregister_scsi(h);	/* unhook from SCSI subsystem */
 	hpsa_shutdown(pdev);
-	destroy_workqueue(h->resubmit_wq);
 	iounmap(h->vaddr);
 	iounmap(h->transtable);
 	iounmap(h->cfgtable);
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 62c50c3..6577130 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -207,6 +207,7 @@ struct ctlr_info {
 	atomic_t firmware_flash_in_progress;
 	u32 __percpu *lockup_detected;
 	struct delayed_work monitor_ctlr_work;
+	struct delayed_work rescan_ctlr_work;
 	int remove_in_progress;
 	/* Address of h->q[x] is passed to intr handler to know which queue */
 	u8 q[MAX_REPLY_QUEUES];
@@ -251,6 +252,7 @@ struct ctlr_info {
 	int	acciopath_status;
 	int	raid_offload_debug;
 	struct workqueue_struct *resubmit_wq;
+	struct workqueue_struct *rescan_ctlr_wq;
 };
 
 struct offline_device_entry {


  parent reply	other threads:[~2015-01-23 22:46 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 22:41 [PATCH v2 00/48] hpsa driver updates Don Brace
2015-01-23 22:41 ` [PATCH v2 01/48] hpsa: correct endian sparse warnings Don Brace
2015-01-23 22:41 ` [PATCH v2 02/48] hpsa: fix memory leak in kdump hard reset Don Brace
2015-01-23 22:41 ` [PATCH v2 03/48] hpsa: turn off interrupts when kdump starts Don Brace
2015-01-23 22:41 ` [PATCH v2 04/48] hpsa: change how SA controllers are reset Don Brace
2015-01-23 22:41 ` [PATCH v2 05/48] hpsa: correct change_queue_depth Don Brace
2015-01-23 22:41 ` [PATCH v2 06/48] hpsa: adjust RAID-1, RAID-1ADM, and RAID-6 names Don Brace
2015-01-23 22:41 ` [PATCH v2 07/48] hpsa: rename free_irqs to hpsa_free_irqs Don Brace
2015-01-23 22:41 ` [PATCH v2 08/48] hpsa: Fix -Wunused-but-set-variable warning Don Brace
2015-01-23 22:41 ` [PATCH v2 09/48] hpsa: notice all request_irq errors Don Brace
2015-01-23 22:41 ` [PATCH v2 10/48] hpsa: remove 0x from queue depth print which is in decimal Don Brace
2015-01-23 22:42 ` [PATCH v2 11/48] hpsa: propagate hard_reset failures in reset_devices mode Don Brace
2015-01-23 22:42 ` [PATCH v2 12/48] hpsa: propagate return value from board ID lookup Don Brace
2015-01-23 22:42 ` [PATCH v2 13/48] hpsa: downgrade the Waiting for no-op print to dev_info Don Brace
2015-01-23 22:42 ` [PATCH v2 14/48] hpsa: refactor hpsa_find_board_params() to encapsulate legacy test Don Brace
2015-01-23 22:42 ` [PATCH v2 15/48] hpsa: trivial message and comment clean ups Don Brace
2015-01-23 22:42 ` [PATCH v2 16/48] hpsa: report failure to ioremap config table Don Brace
2015-01-23 22:42 ` [PATCH v2 17/48] hpsa: rename hpsa_request_irq to hpsa_request_irqs Don Brace
2015-01-23 22:42 ` [PATCH v2 18/48] hpsa: pass error from pci_set_consistent_dma_mask from hpsa_message Don Brace
2015-01-23 22:42 ` [PATCH v2 19/48] hpsa: report allocation failures while allocating SG chain blocks Don Brace
2015-01-23 22:42 ` [PATCH v2 20/48] hpsa: fix memory leak in hpsa_alloc_cmd_pool Don Brace
2015-01-23 22:42 ` [PATCH v2 21/48] hpsa: avoid unneccesary calls to resource freeing functions Don Brace
2015-01-23 22:42 ` [PATCH v2 22/48] hpsa: reserve some commands for use by driver Don Brace
2015-01-23 22:43 ` [PATCH v2 23/48] hpsa: get rid of cmd_special_alloc and cmd_special_free Don Brace
2015-01-23 22:43 ` [PATCH v2 24/48] hpsa: do not queue commands internally in driver Don Brace
2015-01-23 22:43 ` [PATCH v2 25/48] hpsa: do not request device rescan on every ioaccel path error Don Brace
2015-01-23 22:43 ` [PATCH v2 26/48] hpsa: factor out hpsa_ciss_submit function Don Brace
2015-01-23 22:43 ` [PATCH v2 27/48] hpsa: use workqueue to resubmit failed ioaccel commands Don Brace
2015-01-23 22:43 ` [PATCH v2 28/48] hpsa: honor queue depth of physical devices Don Brace
2015-01-23 22:43 ` [PATCH v2 29/48] hpsa: fix race between abort handler and main i/o path Don Brace
2015-01-23 22:43 ` [PATCH v2 30/48] hpsa: optimize cmd_alloc function by remembering last allocation Don Brace
2015-01-23 22:43 ` [PATCH v2 31/48] hpsa: count passthru cmds with atomics, not a spin locked int Don Brace
2015-01-23 22:43 ` [PATCH v2 32/48] hpsa: slightly optimize SA5_performant_completed Don Brace
2015-01-23 22:43 ` [PATCH v2 33/48] hpsa: do not check for msi(x) in interrupt_pending Don Brace
2015-01-23 22:44 ` [PATCH v2 34/48] hpsa: remove incorrect BUG_ONs checking for raid offload enable Don Brace
2015-01-23 22:44 ` [PATCH v2 35/48] hpsa: do not ack controller events on controllers that do not support it Don Brace
2015-01-23 22:44 ` [PATCH v2 36/48] hpsa: guard against overflowing raid map array Don Brace
2015-01-23 22:44 ` [PATCH v2 37/48] hpsa: check for ctlr lockup after command allocation in main io path Don Brace
2015-01-23 22:44 ` [PATCH v2 38/48] hpsa: return failed from device reset/abort handlers Don Brace
2015-01-23 22:44 ` [PATCH v2 39/48] hpsa: do not use a void pointer for scsi_cmd field of struct CommandList Don Brace
2015-01-23 22:44 ` [PATCH v2 40/48] hpsa: print CDBs instead of kernel virtual addresses for uncommon errors Don Brace
2015-01-23 22:44 ` [PATCH v2 41/48] hpsa: do not use function pointers in fast path command submission Don Brace
2015-01-23 22:44 ` [PATCH v2 42/48] hpsa: move SG descriptor set-up out of hpsa_scatter_gather() Don Brace
2015-01-23 22:44 ` [PATCH v2 43/48] hpsa: refactor duplicated scan completion code into a new routine Don Brace
2015-01-23 22:44 ` [PATCH v2 44/48] hpsa: shorten the wait for the CISS doorbell mode change ack Don Brace
2015-01-23 22:45 ` [PATCH v2 45/48] hpsa: detect and report failures changing controller transport modes Don Brace
2015-01-23 22:45 ` [PATCH v2 46/48] hpsa: add in gen9 controller model names Don Brace
2015-01-23 22:45 ` [PATCH v2 47/48] hpsa: add in P840ar controller model name Don Brace
2015-01-23 22:45 ` Don Brace [this message]
2015-01-27 16:55   ` [PATCH v2 48/48] hpsa: Use local workqueues instead of system workqueues Tomas Henzl
2015-01-27 17:13     ` Tomas Henzl

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=20150123224517.14919.28023.stgit@brunhilda \
    --to=don.brace@pmcs.com \
    --cc=Justin.Lindley@pmcs.com \
    --cc=Kevin.Barnett@pmcs.com \
    --cc=brace@pmcs.com \
    --cc=hch@infradead.org \
    --cc=james.bottomley@parallels.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=scott.teel@pmcs.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;
as well as URLs for NNTP newsgroup(s).