aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bnx2fc/bnx2fc_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/bnx2fc/bnx2fc_io.c')
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_io.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 0679782d9d15..5b99844ef6bf 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1894,18 +1894,24 @@ int bnx2fc_queuecommand(struct Scsi_Host *host,
1894 goto exit_qcmd; 1894 goto exit_qcmd;
1895 } 1895 }
1896 } 1896 }
1897
1898 spin_lock_bh(&tgt->tgt_lock);
1899
1897 io_req = bnx2fc_cmd_alloc(tgt); 1900 io_req = bnx2fc_cmd_alloc(tgt);
1898 if (!io_req) { 1901 if (!io_req) {
1899 rc = SCSI_MLQUEUE_HOST_BUSY; 1902 rc = SCSI_MLQUEUE_HOST_BUSY;
1900 goto exit_qcmd; 1903 goto exit_qcmd_tgtlock;
1901 } 1904 }
1902 io_req->sc_cmd = sc_cmd; 1905 io_req->sc_cmd = sc_cmd;
1903 1906
1904 if (bnx2fc_post_io_req(tgt, io_req)) { 1907 if (bnx2fc_post_io_req(tgt, io_req)) {
1905 printk(KERN_ERR PFX "Unable to post io_req\n"); 1908 printk(KERN_ERR PFX "Unable to post io_req\n");
1906 rc = SCSI_MLQUEUE_HOST_BUSY; 1909 rc = SCSI_MLQUEUE_HOST_BUSY;
1907 goto exit_qcmd; 1910 goto exit_qcmd_tgtlock;
1908 } 1911 }
1912
1913exit_qcmd_tgtlock:
1914 spin_unlock_bh(&tgt->tgt_lock);
1909exit_qcmd: 1915exit_qcmd:
1910 return rc; 1916 return rc;
1911} 1917}
@@ -2020,6 +2026,8 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
2020 int task_idx, index; 2026 int task_idx, index;
2021 u16 xid; 2027 u16 xid;
2022 2028
2029 /* bnx2fc_post_io_req() is called with the tgt_lock held */
2030
2023 /* Initialize rest of io_req fields */ 2031 /* Initialize rest of io_req fields */
2024 io_req->cmd_type = BNX2FC_SCSI_CMD; 2032 io_req->cmd_type = BNX2FC_SCSI_CMD;
2025 io_req->port = port; 2033 io_req->port = port;
@@ -2047,9 +2055,7 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
2047 /* Build buffer descriptor list for firmware from sg list */ 2055 /* Build buffer descriptor list for firmware from sg list */
2048 if (bnx2fc_build_bd_list_from_sg(io_req)) { 2056 if (bnx2fc_build_bd_list_from_sg(io_req)) {
2049 printk(KERN_ERR PFX "BD list creation failed\n"); 2057 printk(KERN_ERR PFX "BD list creation failed\n");
2050 spin_lock_bh(&tgt->tgt_lock);
2051 kref_put(&io_req->refcount, bnx2fc_cmd_release); 2058 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2052 spin_unlock_bh(&tgt->tgt_lock);
2053 return -EAGAIN; 2059 return -EAGAIN;
2054 } 2060 }
2055 2061
@@ -2061,19 +2067,15 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
2061 task = &(task_page[index]); 2067 task = &(task_page[index]);
2062 bnx2fc_init_task(io_req, task); 2068 bnx2fc_init_task(io_req, task);
2063 2069
2064 spin_lock_bh(&tgt->tgt_lock);
2065
2066 if (tgt->flush_in_prog) { 2070 if (tgt->flush_in_prog) {
2067 printk(KERN_ERR PFX "Flush in progress..Host Busy\n"); 2071 printk(KERN_ERR PFX "Flush in progress..Host Busy\n");
2068 kref_put(&io_req->refcount, bnx2fc_cmd_release); 2072 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2069 spin_unlock_bh(&tgt->tgt_lock);
2070 return -EAGAIN; 2073 return -EAGAIN;
2071 } 2074 }
2072 2075
2073 if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) { 2076 if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) {
2074 printk(KERN_ERR PFX "Session not ready...post_io\n"); 2077 printk(KERN_ERR PFX "Session not ready...post_io\n");
2075 kref_put(&io_req->refcount, bnx2fc_cmd_release); 2078 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2076 spin_unlock_bh(&tgt->tgt_lock);
2077 return -EAGAIN; 2079 return -EAGAIN;
2078 } 2080 }
2079 2081
@@ -2091,6 +2093,5 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
2091 2093
2092 /* Ring doorbell */ 2094 /* Ring doorbell */
2093 bnx2fc_ring_doorbell(tgt); 2095 bnx2fc_ring_doorbell(tgt);
2094 spin_unlock_bh(&tgt->tgt_lock);
2095 return 0; 2096 return 0;
2096} 2097}