Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-02-12 22:18:26 +0100
committerJiri Slaby <jslaby@suse.cz>2019-02-12 22:21:26 +0100
commit2adc837b835eb1202a67729e9ff717d3e687ae9a (patch)
treeddfe21b8edcd280f6475a63d4a5e88ddd0e6706b
parent54df0c1849715e0889f143de7440c56150374742 (diff)
scsi: cxlflash: Prevent deadlock when adapter probe fails
-rw-r--r--patches.kernel.org/4.20.8-328-scsi-cxlflash-Prevent-deadlock-when-adapter-pr.patch79
-rw-r--r--series.conf1
2 files changed, 80 insertions, 0 deletions
diff --git a/patches.kernel.org/4.20.8-328-scsi-cxlflash-Prevent-deadlock-when-adapter-pr.patch b/patches.kernel.org/4.20.8-328-scsi-cxlflash-Prevent-deadlock-when-adapter-pr.patch
new file mode 100644
index 0000000000..ff5ad25412
--- /dev/null
+++ b/patches.kernel.org/4.20.8-328-scsi-cxlflash-Prevent-deadlock-when-adapter-pr.patch
@@ -0,0 +1,79 @@
+From: Vaibhav Jain <vaibhav@linux.ibm.com>
+Date: Wed, 30 Jan 2019 17:56:51 +0530
+Subject: [PATCH] scsi: cxlflash: Prevent deadlock when adapter probe fails
+References: bnc#1012628
+Patch-mainline: 4.20.8
+Git-commit: bb61b843ffd46978d7ca5095453e572714934eeb
+
+commit bb61b843ffd46978d7ca5095453e572714934eeb upstream.
+
+Presently when an error is encountered during probe of the cxlflash
+adapter, a deadlock is seen with cpu thread stuck inside
+cxlflash_remove(). Below is the trace of the deadlock as logged by
+khungtaskd:
+
+cxlflash 0006:00:00.0: cxlflash_probe: init_afu failed rc=-16
+INFO: task kworker/80:1:890 blocked for more than 120 seconds.
+ Not tainted 5.0.0-rc4-capi2-kexec+ #2
+"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
+kworker/80:1 D 0 890 2 0x00000808
+Workqueue: events work_for_cpu_fn
+
+Call Trace:
+ 0x4d72136320 (unreliable)
+ __switch_to+0x2cc/0x460
+ __schedule+0x2bc/0xac0
+ schedule+0x40/0xb0
+ cxlflash_remove+0xec/0x640 [cxlflash]
+ cxlflash_probe+0x370/0x8f0 [cxlflash]
+ local_pci_probe+0x6c/0x140
+ work_for_cpu_fn+0x38/0x60
+ process_one_work+0x260/0x530
+ worker_thread+0x280/0x5d0
+ kthread+0x1a8/0x1b0
+ ret_from_kernel_thread+0x5c/0x80
+INFO: task systemd-udevd:5160 blocked for more than 120 seconds.
+
+The deadlock occurs as cxlflash_remove() is called from cxlflash_probe()
+without setting 'cxlflash_cfg->state' to STATE_PROBED and the probe thread
+starts to wait on 'cxlflash_cfg->reset_waitq'. Since the device was never
+successfully probed the 'cxlflash_cfg->state' never changes from
+STATE_PROBING hence the deadlock occurs.
+
+We fix this deadlock by setting the variable 'cxlflash_cfg->state' to
+STATE_PROBED in case an error occurs during cxlflash_probe() and just
+before calling cxlflash_remove().
+
+Cc: stable@vger.kernel.org
+Fixes: c21e0bbfc485("cxlflash: Base support for IBM CXL Flash Adapter")
+Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ drivers/scsi/cxlflash/main.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
+index 6637116529aa..f987c40c47a1 100644
+--- a/drivers/scsi/cxlflash/main.c
++++ b/drivers/scsi/cxlflash/main.c
+@@ -3694,6 +3694,7 @@ static int cxlflash_probe(struct pci_dev *pdev,
+ host->max_cmd_len = CXLFLASH_MAX_CDB_LEN;
+
+ cfg = shost_priv(host);
++ cfg->state = STATE_PROBING;
+ cfg->host = host;
+ rc = alloc_mem(cfg);
+ if (rc) {
+@@ -3782,6 +3783,7 @@ static int cxlflash_probe(struct pci_dev *pdev,
+ return rc;
+
+ out_remove:
++ cfg->state = STATE_PROBED;
+ cxlflash_remove(pdev);
+ goto out;
+ }
+--
+2.20.1
+
diff --git a/series.conf b/series.conf
index 7167b1a71a..544a03e5ba 100644
--- a/series.conf
+++ b/series.conf
@@ -1064,6 +1064,7 @@
patches.kernel.org/4.20.8-325-usb-gadget-musb-fix-short-isoc-packets-with-in.patch
patches.kernel.org/4.20.8-326-staging-speakup-fix-tty-operation-NULL-derefs.patch
patches.kernel.org/4.20.8-327-scsi-sd_zbc-Fix-zone-information-messages.patch
+ patches.kernel.org/4.20.8-328-scsi-cxlflash-Prevent-deadlock-when-adapter-pr.patch
########################################################
# Build fixes that apply to the vanilla kernel too.