aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2014-05-07 07:15:46 -0400
committerIngo Molnar <mingo@kernel.org>2014-05-07 07:15:46 -0400
commit2fe5de9ce7d57498abc14b375cad2fcf8c3ee6cc (patch)
tree9478e8cf470c1d5bdb2d89b57a7e35919ab95e72 /drivers/scsi
parent08f8aeb55d7727d644dbbbbfb798fe937d47751d (diff)
parent2b4cfe64dee0d84506b951d81bf55d9891744d25 (diff)
Merge branch 'sched/urgent' into sched/core, to avoid conflicts
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/Kconfig3
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_fcoe.c12
-rw-r--r--drivers/scsi/bnx2i/bnx2i_init.c12
-rw-r--r--drivers/scsi/fcoe/fcoe.c15
-rw-r--r--drivers/scsi/iscsi_tcp.c2
-rw-r--r--drivers/scsi/iscsi_tcp.h2
-rw-r--r--drivers/scsi/libiscsi.c32
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c18
-rw-r--r--drivers/scsi/scsi.c9
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/scsi/scsi_pm.c128
-rw-r--r--drivers/scsi/scsi_priv.h2
-rw-r--r--drivers/scsi/scsi_scan.c2
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c6
-rw-r--r--drivers/scsi/scsi_transport_srp.c1
-rw-r--r--drivers/scsi/sd.c1
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c4
17 files changed, 209 insertions, 44 deletions
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index c8bd092fc945..02832d64d918 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -263,6 +263,9 @@ config SCSI_SCAN_ASYNC
263 You can override this choice by specifying "scsi_mod.scan=sync" 263 You can override this choice by specifying "scsi_mod.scan=sync"
264 or async on the kernel's command line. 264 or async on the kernel's command line.
265 265
266 Note that this setting also affects whether resuming from
267 system suspend will be performed asynchronously.
268
266menu "SCSI Transports" 269menu "SCSI Transports"
267 depends on SCSI 270 depends on SCSI
268 271
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 3455cc5e4bfd..f54843023466 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2592,12 +2592,16 @@ static int __init bnx2fc_mod_init(void)
2592 spin_lock_init(&p->fp_work_lock); 2592 spin_lock_init(&p->fp_work_lock);
2593 } 2593 }
2594 2594
2595 cpu_notifier_register_begin();
2596
2595 for_each_online_cpu(cpu) { 2597 for_each_online_cpu(cpu) {
2596 bnx2fc_percpu_thread_create(cpu); 2598 bnx2fc_percpu_thread_create(cpu);
2597 } 2599 }
2598 2600
2599 /* Initialize per CPU interrupt thread */ 2601 /* Initialize per CPU interrupt thread */
2600 register_hotcpu_notifier(&bnx2fc_cpu_notifier); 2602 __register_hotcpu_notifier(&bnx2fc_cpu_notifier);
2603
2604 cpu_notifier_register_done();
2601 2605
2602 cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); 2606 cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb);
2603 2607
@@ -2662,13 +2666,17 @@ static void __exit bnx2fc_mod_exit(void)
2662 if (l2_thread) 2666 if (l2_thread)
2663 kthread_stop(l2_thread); 2667 kthread_stop(l2_thread);
2664 2668
2665 unregister_hotcpu_notifier(&bnx2fc_cpu_notifier); 2669 cpu_notifier_register_begin();
2666 2670
2667 /* Destroy per cpu threads */ 2671 /* Destroy per cpu threads */
2668 for_each_online_cpu(cpu) { 2672 for_each_online_cpu(cpu) {
2669 bnx2fc_percpu_thread_destroy(cpu); 2673 bnx2fc_percpu_thread_destroy(cpu);
2670 } 2674 }
2671 2675
2676 __unregister_hotcpu_notifier(&bnx2fc_cpu_notifier);
2677
2678 cpu_notifier_register_done();
2679
2672 destroy_workqueue(bnx2fc_wq); 2680 destroy_workqueue(bnx2fc_wq);
2673 /* 2681 /*
2674 * detach from scsi transport 2682 * detach from scsi transport
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 34c294b42c84..80c03b452d61 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -537,11 +537,15 @@ static int __init bnx2i_mod_init(void)
537 p->iothread = NULL; 537 p->iothread = NULL;
538 } 538 }
539 539
540 cpu_notifier_register_begin();
541
540 for_each_online_cpu(cpu) 542 for_each_online_cpu(cpu)
541 bnx2i_percpu_thread_create(cpu); 543 bnx2i_percpu_thread_create(cpu);
542 544
543 /* Initialize per CPU interrupt thread */ 545 /* Initialize per CPU interrupt thread */
544 register_hotcpu_notifier(&bnx2i_cpu_notifier); 546 __register_hotcpu_notifier(&bnx2i_cpu_notifier);
547
548 cpu_notifier_register_done();
545 549
546 return 0; 550 return 0;
547 551
@@ -581,11 +585,15 @@ static void __exit bnx2i_mod_exit(void)
581 } 585 }
582 mutex_unlock(&bnx2i_dev_lock); 586 mutex_unlock(&bnx2i_dev_lock);
583 587
584 unregister_hotcpu_notifier(&bnx2i_cpu_notifier); 588 cpu_notifier_register_begin();
585 589
586 for_each_online_cpu(cpu) 590 for_each_online_cpu(cpu)
587 bnx2i_percpu_thread_destroy(cpu); 591 bnx2i_percpu_thread_destroy(cpu);
588 592
593 __unregister_hotcpu_notifier(&bnx2i_cpu_notifier);
594
595 cpu_notifier_register_done();
596
589 iscsi_unregister_transport(&bnx2i_iscsi_transport); 597 iscsi_unregister_transport(&bnx2i_iscsi_transport);
590 cnic_unregister_driver(CNIC_ULP_ISCSI); 598 cnic_unregister_driver(CNIC_ULP_ISCSI);
591} 599}
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 843a679d2a5e..00ee0ed642aa 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -2633,14 +2633,18 @@ static int __init fcoe_init(void)
2633 skb_queue_head_init(&p->fcoe_rx_list); 2633 skb_queue_head_init(&p->fcoe_rx_list);
2634 } 2634 }
2635 2635
2636 cpu_notifier_register_begin();
2637
2636 for_each_online_cpu(cpu) 2638 for_each_online_cpu(cpu)
2637 fcoe_percpu_thread_create(cpu); 2639 fcoe_percpu_thread_create(cpu);
2638 2640
2639 /* Initialize per CPU interrupt thread */ 2641 /* Initialize per CPU interrupt thread */
2640 rc = register_hotcpu_notifier(&fcoe_cpu_notifier); 2642 rc = __register_hotcpu_notifier(&fcoe_cpu_notifier);
2641 if (rc) 2643 if (rc)
2642 goto out_free; 2644 goto out_free;
2643 2645
2646 cpu_notifier_register_done();
2647
2644 /* Setup link change notification */ 2648 /* Setup link change notification */
2645 fcoe_dev_setup(); 2649 fcoe_dev_setup();
2646 2650
@@ -2655,6 +2659,9 @@ out_free:
2655 for_each_online_cpu(cpu) { 2659 for_each_online_cpu(cpu) {
2656 fcoe_percpu_thread_destroy(cpu); 2660 fcoe_percpu_thread_destroy(cpu);
2657 } 2661 }
2662
2663 cpu_notifier_register_done();
2664
2658 mutex_unlock(&fcoe_config_mutex); 2665 mutex_unlock(&fcoe_config_mutex);
2659 destroy_workqueue(fcoe_wq); 2666 destroy_workqueue(fcoe_wq);
2660 return rc; 2667 return rc;
@@ -2687,11 +2694,15 @@ static void __exit fcoe_exit(void)
2687 } 2694 }
2688 rtnl_unlock(); 2695 rtnl_unlock();
2689 2696
2690 unregister_hotcpu_notifier(&fcoe_cpu_notifier); 2697 cpu_notifier_register_begin();
2691 2698
2692 for_each_online_cpu(cpu) 2699 for_each_online_cpu(cpu)
2693 fcoe_percpu_thread_destroy(cpu); 2700 fcoe_percpu_thread_destroy(cpu);
2694 2701
2702 __unregister_hotcpu_notifier(&fcoe_cpu_notifier);
2703
2704 cpu_notifier_register_done();
2705
2695 mutex_unlock(&fcoe_config_mutex); 2706 mutex_unlock(&fcoe_config_mutex);
2696 2707
2697 /* 2708 /*
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index bfb6d07d87f0..11854845393b 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -125,7 +125,7 @@ static inline int iscsi_sw_sk_state_check(struct sock *sk)
125 return 0; 125 return 0;
126} 126}
127 127
128static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag) 128static void iscsi_sw_tcp_data_ready(struct sock *sk)
129{ 129{
130 struct iscsi_conn *conn; 130 struct iscsi_conn *conn;
131 struct iscsi_tcp_conn *tcp_conn; 131 struct iscsi_tcp_conn *tcp_conn;
diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h
index 666fe09378fa..f42ecb238af5 100644
--- a/drivers/scsi/iscsi_tcp.h
+++ b/drivers/scsi/iscsi_tcp.h
@@ -40,7 +40,7 @@ struct iscsi_sw_tcp_conn {
40 40
41 struct iscsi_sw_tcp_send out; 41 struct iscsi_sw_tcp_send out;
42 /* old values for socket callbacks */ 42 /* old values for socket callbacks */
43 void (*old_data_ready)(struct sock *, int); 43 void (*old_data_ready)(struct sock *);
44 void (*old_state_change)(struct sock *); 44 void (*old_state_change)(struct sock *);
45 void (*old_write_space)(struct sock *); 45 void (*old_write_space)(struct sock *);
46 46
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 5b8605ca42fa..26dc005bb0f0 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -387,6 +387,10 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
387 if (rc) 387 if (rc)
388 return rc; 388 return rc;
389 } 389 }
390
391 if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
392 task->protected = true;
393
390 if (sc->sc_data_direction == DMA_TO_DEVICE) { 394 if (sc->sc_data_direction == DMA_TO_DEVICE) {
391 unsigned out_len = scsi_out(sc)->length; 395 unsigned out_len = scsi_out(sc)->length;
392 struct iscsi_r2t_info *r2t = &task->unsol_r2t; 396 struct iscsi_r2t_info *r2t = &task->unsol_r2t;
@@ -822,6 +826,33 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
822 826
823 sc->result = (DID_OK << 16) | rhdr->cmd_status; 827 sc->result = (DID_OK << 16) | rhdr->cmd_status;
824 828
829 if (task->protected) {
830 sector_t sector;
831 u8 ascq;
832
833 /**
834 * Transports that didn't implement check_protection
835 * callback but still published T10-PI support to scsi-mid
836 * deserve this BUG_ON.
837 **/
838 BUG_ON(!session->tt->check_protection);
839
840 ascq = session->tt->check_protection(task, &sector);
841 if (ascq) {
842 sc->result = DRIVER_SENSE << 24 |
843 SAM_STAT_CHECK_CONDITION;
844 scsi_build_sense_buffer(1, sc->sense_buffer,
845 ILLEGAL_REQUEST, 0x10, ascq);
846 sc->sense_buffer[7] = 0xc; /* Additional sense length */
847 sc->sense_buffer[8] = 0; /* Information desc type */
848 sc->sense_buffer[9] = 0xa; /* Additional desc length */
849 sc->sense_buffer[10] = 0x80; /* Validity bit */
850
851 put_unaligned_be64(sector, &sc->sense_buffer[12]);
852 goto out;
853 }
854 }
855
825 if (rhdr->response != ISCSI_STATUS_CMD_COMPLETED) { 856 if (rhdr->response != ISCSI_STATUS_CMD_COMPLETED) {
826 sc->result = DID_ERROR << 16; 857 sc->result = DID_ERROR << 16;
827 goto out; 858 goto out;
@@ -1582,6 +1613,7 @@ static inline struct iscsi_task *iscsi_alloc_task(struct iscsi_conn *conn,
1582 task->have_checked_conn = false; 1613 task->have_checked_conn = false;
1583 task->last_timeout = jiffies; 1614 task->last_timeout = jiffies;
1584 task->last_xfer = jiffies; 1615 task->last_xfer = jiffies;
1616 task->protected = false;
1585 INIT_LIST_HEAD(&task->running); 1617 INIT_LIST_HEAD(&task->running);
1586 return task; 1618 return task;
1587} 1619}
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 788c4fe2b0c9..68fb66fdb757 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -684,6 +684,20 @@ static void tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
684 qlt_xmit_tm_rsp(mcmd); 684 qlt_xmit_tm_rsp(mcmd);
685} 685}
686 686
687static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd)
688{
689 struct qla_tgt_cmd *cmd = container_of(se_cmd,
690 struct qla_tgt_cmd, se_cmd);
691 struct scsi_qla_host *vha = cmd->vha;
692 struct qla_hw_data *ha = vha->hw;
693
694 if (!cmd->sg_mapped)
695 return;
696
697 pci_unmap_sg(ha->pdev, cmd->sg, cmd->sg_cnt, cmd->dma_data_direction);
698 cmd->sg_mapped = 0;
699}
700
687/* Local pointer to allocated TCM configfs fabric module */ 701/* Local pointer to allocated TCM configfs fabric module */
688struct target_fabric_configfs *tcm_qla2xxx_fabric_configfs; 702struct target_fabric_configfs *tcm_qla2xxx_fabric_configfs;
689struct target_fabric_configfs *tcm_qla2xxx_npiv_fabric_configfs; 703struct target_fabric_configfs *tcm_qla2xxx_npiv_fabric_configfs;
@@ -1468,7 +1482,7 @@ static int tcm_qla2xxx_check_initiator_node_acl(
1468 } 1482 }
1469 se_tpg = &tpg->se_tpg; 1483 se_tpg = &tpg->se_tpg;
1470 1484
1471 se_sess = transport_init_session(); 1485 se_sess = transport_init_session(TARGET_PROT_NORMAL);
1472 if (IS_ERR(se_sess)) { 1486 if (IS_ERR(se_sess)) {
1473 pr_err("Unable to initialize struct se_session\n"); 1487 pr_err("Unable to initialize struct se_session\n");
1474 return PTR_ERR(se_sess); 1488 return PTR_ERR(se_sess);
@@ -1877,6 +1891,7 @@ static struct target_core_fabric_ops tcm_qla2xxx_ops = {
1877 .queue_data_in = tcm_qla2xxx_queue_data_in, 1891 .queue_data_in = tcm_qla2xxx_queue_data_in,
1878 .queue_status = tcm_qla2xxx_queue_status, 1892 .queue_status = tcm_qla2xxx_queue_status,
1879 .queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp, 1893 .queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp,
1894 .aborted_task = tcm_qla2xxx_aborted_task,
1880 /* 1895 /*
1881 * Setup function pointers for generic logic in 1896 * Setup function pointers for generic logic in
1882 * target_core_fabric_configfs.c 1897 * target_core_fabric_configfs.c
@@ -1926,6 +1941,7 @@ static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
1926 .queue_data_in = tcm_qla2xxx_queue_data_in, 1941 .queue_data_in = tcm_qla2xxx_queue_data_in,
1927 .queue_status = tcm_qla2xxx_queue_status, 1942 .queue_status = tcm_qla2xxx_queue_status,
1928 .queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp, 1943 .queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp,
1944 .aborted_task = tcm_qla2xxx_aborted_task,
1929 /* 1945 /*
1930 * Setup function pointers for generic logic in 1946 * Setup function pointers for generic logic in
1931 * target_core_fabric_configfs.c 1947 * target_core_fabric_configfs.c
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index c4d632c27a3e..88d46fe6bf98 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -91,6 +91,15 @@ EXPORT_SYMBOL(scsi_logging_level);
91ASYNC_DOMAIN(scsi_sd_probe_domain); 91ASYNC_DOMAIN(scsi_sd_probe_domain);
92EXPORT_SYMBOL(scsi_sd_probe_domain); 92EXPORT_SYMBOL(scsi_sd_probe_domain);
93 93
94/*
95 * Separate domain (from scsi_sd_probe_domain) to maximize the benefit of
96 * asynchronous system resume operations. It is marked 'exclusive' to avoid
97 * being included in the async_synchronize_full() that is invoked by
98 * dpm_resume()
99 */
100ASYNC_DOMAIN_EXCLUSIVE(scsi_sd_pm_domain);
101EXPORT_SYMBOL(scsi_sd_pm_domain);
102
94/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI. 103/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI.
95 * You may not alter any existing entry (although adding new ones is 104 * You may not alter any existing entry (although adding new ones is
96 * encouraged once assigned by ANSI/INCITS T10 105 * encouraged once assigned by ANSI/INCITS T10
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 5681c05ac506..65a123d9c676 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -184,7 +184,7 @@ void scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
184 */ 184 */
185int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, 185int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
186 int data_direction, void *buffer, unsigned bufflen, 186 int data_direction, void *buffer, unsigned bufflen,
187 unsigned char *sense, int timeout, int retries, int flags, 187 unsigned char *sense, int timeout, int retries, u64 flags,
188 int *resid) 188 int *resid)
189{ 189{
190 struct request *req; 190 struct request *req;
@@ -235,7 +235,7 @@ EXPORT_SYMBOL(scsi_execute);
235int scsi_execute_req_flags(struct scsi_device *sdev, const unsigned char *cmd, 235int scsi_execute_req_flags(struct scsi_device *sdev, const unsigned char *cmd,
236 int data_direction, void *buffer, unsigned bufflen, 236 int data_direction, void *buffer, unsigned bufflen,
237 struct scsi_sense_hdr *sshdr, int timeout, int retries, 237 struct scsi_sense_hdr *sshdr, int timeout, int retries,
238 int *resid, int flags) 238 int *resid, u64 flags)
239{ 239{
240 char *sense = NULL; 240 char *sense = NULL;
241 int result; 241 int result;
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index 001e9ceda4c3..7454498c4091 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -18,35 +18,77 @@
18 18
19#ifdef CONFIG_PM_SLEEP 19#ifdef CONFIG_PM_SLEEP
20 20
21static int scsi_dev_type_suspend(struct device *dev, int (*cb)(struct device *)) 21static int do_scsi_suspend(struct device *dev, const struct dev_pm_ops *pm)
22{ 22{
23 return pm && pm->suspend ? pm->suspend(dev) : 0;
24}
25
26static int do_scsi_freeze(struct device *dev, const struct dev_pm_ops *pm)
27{
28 return pm && pm->freeze ? pm->freeze(dev) : 0;
29}
30
31static int do_scsi_poweroff(struct device *dev, const struct dev_pm_ops *pm)
32{
33 return pm && pm->poweroff ? pm->poweroff(dev) : 0;
34}
35
36static int do_scsi_resume(struct device *dev, const struct dev_pm_ops *pm)
37{
38 return pm && pm->resume ? pm->resume(dev) : 0;
39}
40
41static int do_scsi_thaw(struct device *dev, const struct dev_pm_ops *pm)
42{
43 return pm && pm->thaw ? pm->thaw(dev) : 0;
44}
45
46static int do_scsi_restore(struct device *dev, const struct dev_pm_ops *pm)
47{
48 return pm && pm->restore ? pm->restore(dev) : 0;
49}
50
51static int scsi_dev_type_suspend(struct device *dev,
52 int (*cb)(struct device *, const struct dev_pm_ops *))
53{
54 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
23 int err; 55 int err;
24 56
57 /* flush pending in-flight resume operations, suspend is synchronous */
58 async_synchronize_full_domain(&scsi_sd_pm_domain);
59
25 err = scsi_device_quiesce(to_scsi_device(dev)); 60 err = scsi_device_quiesce(to_scsi_device(dev));
26 if (err == 0) { 61 if (err == 0) {
27 if (cb) { 62 err = cb(dev, pm);
28 err = cb(dev); 63 if (err)
29 if (err) 64 scsi_device_resume(to_scsi_device(dev));
30 scsi_device_resume(to_scsi_device(dev));
31 }
32 } 65 }
33 dev_dbg(dev, "scsi suspend: %d\n", err); 66 dev_dbg(dev, "scsi suspend: %d\n", err);
34 return err; 67 return err;
35} 68}
36 69
37static int scsi_dev_type_resume(struct device *dev, int (*cb)(struct device *)) 70static int scsi_dev_type_resume(struct device *dev,
71 int (*cb)(struct device *, const struct dev_pm_ops *))
38{ 72{
73 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
39 int err = 0; 74 int err = 0;
40 75
41 if (cb) 76 err = cb(dev, pm);
42 err = cb(dev);
43 scsi_device_resume(to_scsi_device(dev)); 77 scsi_device_resume(to_scsi_device(dev));
44 dev_dbg(dev, "scsi resume: %d\n", err); 78 dev_dbg(dev, "scsi resume: %d\n", err);
79
80 if (err == 0) {
81 pm_runtime_disable(dev);
82 pm_runtime_set_active(dev);
83 pm_runtime_enable(dev);
84 }
85
45 return err; 86 return err;
46} 87}
47 88
48static int 89static int
49scsi_bus_suspend_common(struct device *dev, int (*cb)(struct device *)) 90scsi_bus_suspend_common(struct device *dev,
91 int (*cb)(struct device *, const struct dev_pm_ops *))
50{ 92{
51 int err = 0; 93 int err = 0;
52 94
@@ -66,20 +108,54 @@ scsi_bus_suspend_common(struct device *dev, int (*cb)(struct device *))
66 return err; 108 return err;
67} 109}
68 110
69static int 111static void async_sdev_resume(void *dev, async_cookie_t cookie)
70scsi_bus_resume_common(struct device *dev, int (*cb)(struct device *))
71{ 112{
72 int err = 0; 113 scsi_dev_type_resume(dev, do_scsi_resume);
114}
73 115
74 if (scsi_is_sdev_device(dev)) 116static void async_sdev_thaw(void *dev, async_cookie_t cookie)
75 err = scsi_dev_type_resume(dev, cb); 117{
118 scsi_dev_type_resume(dev, do_scsi_thaw);
119}
76 120
77 if (err == 0) { 121static void async_sdev_restore(void *dev, async_cookie_t cookie)
122{
123 scsi_dev_type_resume(dev, do_scsi_restore);
124}
125
126static int scsi_bus_resume_common(struct device *dev,
127 int (*cb)(struct device *, const struct dev_pm_ops *))
128{
129 async_func_t fn;
130
131 if (!scsi_is_sdev_device(dev))
132 fn = NULL;
133 else if (cb == do_scsi_resume)
134 fn = async_sdev_resume;
135 else if (cb == do_scsi_thaw)
136 fn = async_sdev_thaw;
137 else if (cb == do_scsi_restore)
138 fn = async_sdev_restore;
139 else
140 fn = NULL;
141
142 if (fn) {
143 async_schedule_domain(fn, dev, &scsi_sd_pm_domain);
144
145 /*
146 * If a user has disabled async probing a likely reason
147 * is due to a storage enclosure that does not inject
148 * staggered spin-ups. For safety, make resume
149 * synchronous as well in that case.
150 */
151 if (strncmp(scsi_scan_type, "async", 5) != 0)
152 async_synchronize_full_domain(&scsi_sd_pm_domain);
153 } else {
78 pm_runtime_disable(dev); 154 pm_runtime_disable(dev);
79 pm_runtime_set_active(dev); 155 pm_runtime_set_active(dev);
80 pm_runtime_enable(dev); 156 pm_runtime_enable(dev);
81 } 157 }
82 return err; 158 return 0;
83} 159}
84 160
85static int scsi_bus_prepare(struct device *dev) 161static int scsi_bus_prepare(struct device *dev)
@@ -97,38 +173,32 @@ static int scsi_bus_prepare(struct device *dev)
97 173
98static int scsi_bus_suspend(struct device *dev) 174static int scsi_bus_suspend(struct device *dev)
99{ 175{
100 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 176 return scsi_bus_suspend_common(dev, do_scsi_suspend);
101 return scsi_bus_suspend_common(dev, pm ? pm->suspend : NULL);
102} 177}
103 178
104static int scsi_bus_resume(struct device *dev) 179static int scsi_bus_resume(struct device *dev)
105{ 180{
106 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 181 return scsi_bus_resume_common(dev, do_scsi_resume);
107 return scsi_bus_resume_common(dev, pm ? pm->resume : NULL);
108} 182}
109 183
110static int scsi_bus_freeze(struct device *dev) 184static int scsi_bus_freeze(struct device *dev)
111{ 185{
112 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 186 return scsi_bus_suspend_common(dev, do_scsi_freeze);
113 return scsi_bus_suspend_common(dev, pm ? pm->freeze : NULL);
114} 187}
115 188
116static int scsi_bus_thaw(struct device *dev) 189static int scsi_bus_thaw(struct device *dev)
117{ 190{
118 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 191 return scsi_bus_resume_common(dev, do_scsi_thaw);
119 return scsi_bus_resume_common(dev, pm ? pm->thaw : NULL);
120} 192}
121 193
122static int scsi_bus_poweroff(struct device *dev) 194static int scsi_bus_poweroff(struct device *dev)
123{ 195{
124 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 196 return scsi_bus_suspend_common(dev, do_scsi_poweroff);
125 return scsi_bus_suspend_common(dev, pm ? pm->poweroff : NULL);
126} 197}
127 198
128static int scsi_bus_restore(struct device *dev) 199static int scsi_bus_restore(struct device *dev)
129{ 200{
130 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 201 return scsi_bus_resume_common(dev, do_scsi_restore);
131 return scsi_bus_resume_common(dev, pm ? pm->restore : NULL);
132} 202}
133 203
134#else /* CONFIG_PM_SLEEP */ 204#else /* CONFIG_PM_SLEEP */
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index f079a598bed4..48e5b657e79f 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -112,6 +112,7 @@ extern void scsi_exit_procfs(void);
112#endif /* CONFIG_PROC_FS */ 112#endif /* CONFIG_PROC_FS */
113 113
114/* scsi_scan.c */ 114/* scsi_scan.c */
115extern char scsi_scan_type[];
115extern int scsi_complete_async_scans(void); 116extern int scsi_complete_async_scans(void);
116extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int, 117extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
117 unsigned int, unsigned int, int); 118 unsigned int, unsigned int, int);
@@ -166,6 +167,7 @@ static inline int scsi_autopm_get_host(struct Scsi_Host *h) { return 0; }
166static inline void scsi_autopm_put_host(struct Scsi_Host *h) {} 167static inline void scsi_autopm_put_host(struct Scsi_Host *h) {}
167#endif /* CONFIG_PM_RUNTIME */ 168#endif /* CONFIG_PM_RUNTIME */
168 169
170extern struct async_domain scsi_sd_pm_domain;
169extern struct async_domain scsi_sd_probe_domain; 171extern struct async_domain scsi_sd_probe_domain;
170 172
171/* 173/*
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 27f96d5b7680..e02b3aab56ce 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -97,7 +97,7 @@ MODULE_PARM_DESC(max_luns,
97#define SCSI_SCAN_TYPE_DEFAULT "sync" 97#define SCSI_SCAN_TYPE_DEFAULT "sync"
98#endif 98#endif
99 99
100static char scsi_scan_type[6] = SCSI_SCAN_TYPE_DEFAULT; 100char scsi_scan_type[6] = SCSI_SCAN_TYPE_DEFAULT;
101 101
102module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO); 102module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO);
103MODULE_PARM_DESC(scan, "sync, async or none"); 103MODULE_PARM_DESC(scan, "sync, async or none");
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index fd8ffe6bcfdd..0102a2d70dd8 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1225,7 +1225,7 @@ struct bus_type iscsi_flashnode_bus = {
1225 * Adds a sysfs entry for the flashnode session attributes 1225 * Adds a sysfs entry for the flashnode session attributes
1226 * 1226 *
1227 * Returns: 1227 * Returns:
1228 * pointer to allocated flashnode sess on sucess 1228 * pointer to allocated flashnode sess on success
1229 * %NULL on failure 1229 * %NULL on failure
1230 */ 1230 */
1231struct iscsi_bus_flash_session * 1231struct iscsi_bus_flash_session *
@@ -1423,7 +1423,7 @@ static int iscsi_iter_destroy_flashnode_conn_fn(struct device *dev, void *data)
1423} 1423}
1424 1424
1425/** 1425/**
1426 * iscsi_destroy_flashnode_sess - destory flashnode session entry 1426 * iscsi_destroy_flashnode_sess - destroy flashnode session entry
1427 * @fnode_sess: pointer to flashnode session entry to be destroyed 1427 * @fnode_sess: pointer to flashnode session entry to be destroyed
1428 * 1428 *
1429 * Deletes the flashnode session entry and all children flashnode connection 1429 * Deletes the flashnode session entry and all children flashnode connection
@@ -1453,7 +1453,7 @@ static int iscsi_iter_destroy_flashnode_fn(struct device *dev, void *data)
1453} 1453}
1454 1454
1455/** 1455/**
1456 * iscsi_destroy_all_flashnode - destory all flashnode session entries 1456 * iscsi_destroy_all_flashnode - destroy all flashnode session entries
1457 * @shost: pointer to host data 1457 * @shost: pointer to host data
1458 * 1458 *
1459 * Destroys all the flashnode session entries and all corresponding children 1459 * Destroys all the flashnode session entries and all corresponding children
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index d47ffc8d3e43..13e898332e45 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -810,6 +810,7 @@ EXPORT_SYMBOL_GPL(srp_remove_host);
810 810
811/** 811/**
812 * srp_stop_rport_timers - stop the transport layer recovery timers 812 * srp_stop_rport_timers - stop the transport layer recovery timers
813 * @rport: SRP remote port for which to stop the timers.
813 * 814 *
814 * Must be called after srp_remove_host() and scsi_remove_host(). The caller 815 * Must be called after srp_remove_host() and scsi_remove_host(). The caller
815 * must hold a reference on the rport (rport->dev) and on the SCSI host 816 * must hold a reference on the rport (rport->dev) and on the SCSI host
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 89e6c04ac595..efcbcd182863 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3026,6 +3026,7 @@ static int sd_remove(struct device *dev)
3026 devt = disk_devt(sdkp->disk); 3026 devt = disk_devt(sdkp->disk);
3027 scsi_autopm_get_device(sdkp->device); 3027 scsi_autopm_get_device(sdkp->device);
3028 3028
3029 async_synchronize_full_domain(&scsi_sd_pm_domain);
3029 async_synchronize_full_domain(&scsi_sd_probe_domain); 3030 async_synchronize_full_domain(&scsi_sd_probe_domain);
3030 blk_queue_prep_rq(sdkp->device->request_queue, scsi_prep_fn); 3031 blk_queue_prep_rq(sdkp->device->request_queue, scsi_prep_fn);
3031 blk_queue_unprep_rq(sdkp->device->request_queue, NULL); 3032 blk_queue_unprep_rq(sdkp->device->request_queue, NULL);
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index d92fe4037e94..6b349e301869 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -3000,7 +3000,11 @@ sym_dequeue_from_squeue(struct sym_hcb *np, int i, int target, int lun, int task
3000 if ((target == -1 || cp->target == target) && 3000 if ((target == -1 || cp->target == target) &&
3001 (lun == -1 || cp->lun == lun) && 3001 (lun == -1 || cp->lun == lun) &&
3002 (task == -1 || cp->tag == task)) { 3002 (task == -1 || cp->tag == task)) {
3003#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
3003 sym_set_cam_status(cp->cmd, DID_SOFT_ERROR); 3004 sym_set_cam_status(cp->cmd, DID_SOFT_ERROR);
3005#else
3006 sym_set_cam_status(cp->cmd, DID_REQUEUE);
3007#endif
3004 sym_remque(&cp->link_ccbq); 3008 sym_remque(&cp->link_ccbq);
3005 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq); 3009 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq);
3006 } 3010 }