Skip to content

Commit b5cf6b6

Browse files
ew929595James Bottomley
authored andcommitted
[SCSI] bnx2i: Added the use of kthreads to handle SCSI cmd completion
This patch breaks the SCSI cmd completion into two parts: 1. The bh will allocate and queued work to the cmd specific CPU IO completion kthread. The CPU for the cmd is from the sc->request->cpu. 2. The CPU specific IO completion kthread will call the scsi_cmd_resp routine to do the actual cmd completion. In the normal case, these IO completion kthreads should complete before the blk IO times out at 60s. However, in the case when these kthreads are blocked for whatever reason and exceeded the timeout, the call to conn_destroy will have to iterate and exhaust all related work in the percpu work list for all online CPUs. This will guarantee the protection of the work->session and conn pointers before they get freed. Also modified the event coalescing formula to have at least the event_coal_min outstanding cmds in the pipeline so the SCSI producer would not get underrun. Also changed the following SCSI parameters: - can_queue from 1024 to 2048 - cmds_per_lun from 24 to 128 Signed-off-by: Eddie Wai <eddie.wai@broadcom.com> Acked-by: Benjamin Li <benli@broadcom.com> Acked-by: Michael Chan <mchan@broadcom.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 74dcd0e commit b5cf6b6

4 files changed

Lines changed: 333 additions & 35 deletions

File tree

‎drivers/scsi/bnx2i/bnx2i.h‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
#include <linux/pci.h>
2323
#include <linux/spinlock.h>
2424
#include <linux/interrupt.h>
25+
#include <linux/delay.h>
2526
#include <linux/sched.h>
2627
#include <linux/in.h>
2728
#include <linux/kfifo.h>
2829
#include <linux/netdevice.h>
2930
#include <linux/completion.h>
31+
#include <linux/kthread.h>
32+
#include <linux/cpu.h>
3033

3134
#include <scsi/scsi_cmnd.h>
3235
#include <scsi/scsi_device.h>
@@ -202,10 +205,13 @@ struct io_bdt {
202205
/**
203206
* bnx2i_cmd - iscsi command structure
204207
*
208+
* @hdr: iSCSI header
209+
* @conn: iscsi_conn pointer
205210
* @scsi_cmd: SCSI-ML task pointer corresponding to this iscsi cmd
206211
* @sg: SG list
207212
* @io_tbl: buffer descriptor (BD) table
208213
* @bd_tbl_dma: buffer descriptor (BD) table's dma address
214+
* @req: bnx2i specific command request struct
209215
*/
210216
struct bnx2i_cmd {
211217
struct iscsi_hdr hdr;
@@ -229,6 +235,7 @@ struct bnx2i_cmd {
229235
* @gen_pdu: login/nopout/logout pdu resources
230236
* @violation_notified: bit mask used to track iscsi error/warning messages
231237
* already printed out
238+
* @work_cnt: keeps track of the number of outstanding work
232239
*
233240
* iSCSI connection structure
234241
*/
@@ -252,6 +259,8 @@ struct bnx2i_conn {
252259
*/
253260
struct generic_pdu_resc gen_pdu;
254261
u64 violation_notified;
262+
263+
atomic_t work_cnt;
255264
};
256265

257266

@@ -661,7 +670,6 @@ enum {
661670
* @hba: adapter to which this connection belongs
662671
* @conn: iscsi connection this EP is linked to
663672
* @cls_ep: associated iSCSI endpoint pointer
664-
* @sess: iscsi session this EP is linked to
665673
* @cm_sk: cnic sock struct
666674
* @hba_age: age to detect if 'iscsid' issues ep_disconnect()
667675
* after HBA reset is completed by bnx2i/cnic/bnx2
@@ -687,7 +695,7 @@ struct bnx2i_endpoint {
687695
u32 hba_age;
688696
u32 state;
689697
unsigned long timestamp;
690-
int num_active_cmds;
698+
atomic_t num_active_cmds;
691699
u32 ec_shift;
692700

693701
struct qp_info qp;
@@ -700,6 +708,19 @@ struct bnx2i_endpoint {
700708
};
701709

702710

711+
struct bnx2i_work {
712+
struct list_head list;
713+
struct iscsi_session *session;
714+
struct bnx2i_conn *bnx2i_conn;
715+
struct cqe cqe;
716+
};
717+
718+
struct bnx2i_percpu_s {
719+
struct task_struct *iothread;
720+
struct list_head work_list;
721+
spinlock_t p_work_lock;
722+
};
723+
703724

704725
/* Global variables */
705726
extern unsigned int error_mask1, error_mask2;
@@ -783,7 +804,7 @@ extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list(
783804
struct bnx2i_hba *hba, u32 iscsi_cid);
784805

785806
extern int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep);
786-
extern void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
807+
extern int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
787808

788809
extern int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep);
789810

@@ -793,4 +814,8 @@ extern void bnx2i_print_active_cmd_queue(struct bnx2i_conn *conn);
793814
extern void bnx2i_print_xmit_pdu_queue(struct bnx2i_conn *conn);
794815
extern void bnx2i_print_recv_state(struct bnx2i_conn *conn);
795816

817+
extern int bnx2i_percpu_io_thread(void *arg);
818+
extern int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
819+
struct bnx2i_conn *bnx2i_conn,
820+
struct cqe *cqe);
796821
#endif

0 commit comments

Comments
 (0)