aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/be2iscsi
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2012-04-18 04:06:00 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-04-25 04:01:40 -0400
commit1282ab76d983b2753b5cd4c9ae6b8019b0557b30 (patch)
tree79898110d3fb31019cc0103e98ec698490a642cf /drivers/scsi/be2iscsi
parent3ec7827134a976a3ffffd9e438b8d8dfd6eca9b7 (diff)
[SCSI] be2iscsi: Freeing of WRB and SGL Handle in cleanup task
The WRB and SGL Handle allocated for Login task were not freed back to the pool after the login process was done. This code releases the WRB and SGL Handle after the login process. v2: - Fix up locking so bh calls are not done when not needed. - Make beiscsi_cleanup_task static. Signed-off-by: Jayamohan Kallickal <jayamohan.kallickal@emulex.com> [various fixes] Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/be2iscsi')
-rw-r--r--drivers/scsi/be2iscsi/be_main.c107
1 files changed, 62 insertions, 45 deletions
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 23344c8c5b79..185cf394b9f0 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1252,9 +1252,9 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn,
1252 task = pwrb_handle->pio_handle; 1252 task = pwrb_handle->pio_handle;
1253 1253
1254 io_task = task->dd_data; 1254 io_task = task->dd_data;
1255 spin_lock(&phba->mgmt_sgl_lock); 1255 spin_lock_bh(&phba->mgmt_sgl_lock);
1256 free_mgmt_sgl_handle(phba, io_task->psgl_handle); 1256 free_mgmt_sgl_handle(phba, io_task->psgl_handle);
1257 spin_unlock(&phba->mgmt_sgl_lock); 1257 spin_unlock_bh(&phba->mgmt_sgl_lock);
1258 spin_lock_bh(&session->lock); 1258 spin_lock_bh(&session->lock);
1259 free_wrb_handle(phba, pwrb_context, pwrb_handle); 1259 free_wrb_handle(phba, pwrb_context, pwrb_handle);
1260 spin_unlock_bh(&session->lock); 1260 spin_unlock_bh(&session->lock);
@@ -3693,6 +3693,57 @@ static void beiscsi_clean_port(struct beiscsi_hba *phba)
3693 kfree(phba->ep_array); 3693 kfree(phba->ep_array);
3694} 3694}
3695 3695
3696static void beiscsi_cleanup_task(struct iscsi_task *task)
3697{
3698 struct beiscsi_io_task *io_task = task->dd_data;
3699 struct iscsi_conn *conn = task->conn;
3700 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
3701 struct beiscsi_hba *phba = beiscsi_conn->phba;
3702 struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess;
3703 struct hwi_wrb_context *pwrb_context;
3704 struct hwi_controller *phwi_ctrlr;
3705
3706 phwi_ctrlr = phba->phwi_ctrlr;
3707 pwrb_context = &phwi_ctrlr->wrb_context[beiscsi_conn->beiscsi_conn_cid
3708 - phba->fw_config.iscsi_cid_start];
3709
3710 if (io_task->cmd_bhs) {
3711 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
3712 io_task->bhs_pa.u.a64.address);
3713 io_task->cmd_bhs = NULL;
3714 }
3715
3716 if (task->sc) {
3717 if (io_task->pwrb_handle) {
3718 free_wrb_handle(phba, pwrb_context,
3719 io_task->pwrb_handle);
3720 io_task->pwrb_handle = NULL;
3721 }
3722
3723 if (io_task->psgl_handle) {
3724 spin_lock(&phba->io_sgl_lock);
3725 free_io_sgl_handle(phba, io_task->psgl_handle);
3726 spin_unlock(&phba->io_sgl_lock);
3727 io_task->psgl_handle = NULL;
3728 }
3729 } else {
3730 if (!beiscsi_conn->login_in_progress) {
3731 if (io_task->pwrb_handle) {
3732 free_wrb_handle(phba, pwrb_context,
3733 io_task->pwrb_handle);
3734 io_task->pwrb_handle = NULL;
3735 }
3736 if (io_task->psgl_handle) {
3737 spin_lock(&phba->mgmt_sgl_lock);
3738 free_mgmt_sgl_handle(phba,
3739 io_task->psgl_handle);
3740 spin_unlock(&phba->mgmt_sgl_lock);
3741 io_task->psgl_handle = NULL;
3742 }
3743 }
3744 }
3745}
3746
3696void 3747void
3697beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, 3748beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn,
3698 struct beiscsi_offload_params *params) 3749 struct beiscsi_offload_params *params)
@@ -3701,12 +3752,19 @@ beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn,
3701 struct iscsi_target_context_update_wrb *pwrb = NULL; 3752 struct iscsi_target_context_update_wrb *pwrb = NULL;
3702 struct be_mem_descriptor *mem_descr; 3753 struct be_mem_descriptor *mem_descr;
3703 struct beiscsi_hba *phba = beiscsi_conn->phba; 3754 struct beiscsi_hba *phba = beiscsi_conn->phba;
3755 struct iscsi_task *task = beiscsi_conn->task;
3756 struct iscsi_session *session = task->conn->session;
3704 u32 doorbell = 0; 3757 u32 doorbell = 0;
3705 3758
3706 /* 3759 /*
3707 * We can always use 0 here because it is reserved by libiscsi for 3760 * We can always use 0 here because it is reserved by libiscsi for
3708 * login/startup related tasks. 3761 * login/startup related tasks.
3709 */ 3762 */
3763 beiscsi_conn->login_in_progress = 0;
3764 spin_lock_bh(&session->lock);
3765 beiscsi_cleanup_task(task);
3766 spin_unlock_bh(&session->lock);
3767
3710 pwrb_handle = alloc_wrb_handle(phba, (beiscsi_conn->beiscsi_conn_cid - 3768 pwrb_handle = alloc_wrb_handle(phba, (beiscsi_conn->beiscsi_conn_cid -
3711 phba->fw_config.iscsi_cid_start)); 3769 phba->fw_config.iscsi_cid_start));
3712 pwrb = (struct iscsi_target_context_update_wrb *)pwrb_handle->pwrb; 3770 pwrb = (struct iscsi_target_context_update_wrb *)pwrb_handle->pwrb;
@@ -3862,6 +3920,7 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)
3862 io_task->pwrb_handle = 3920 io_task->pwrb_handle =
3863 beiscsi_conn->plogin_wrb_handle; 3921 beiscsi_conn->plogin_wrb_handle;
3864 } 3922 }
3923 beiscsi_conn->task = task;
3865 } else { 3924 } else {
3866 spin_lock(&phba->mgmt_sgl_lock); 3925 spin_lock(&phba->mgmt_sgl_lock);
3867 io_task->psgl_handle = alloc_mgmt_sgl_handle(phba); 3926 io_task->psgl_handle = alloc_mgmt_sgl_handle(phba);
@@ -3904,53 +3963,11 @@ free_hndls:
3904 io_task->pwrb_handle = NULL; 3963 io_task->pwrb_handle = NULL;
3905 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, 3964 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
3906 io_task->bhs_pa.u.a64.address); 3965 io_task->bhs_pa.u.a64.address);
3966 io_task->cmd_bhs = NULL;
3907 SE_DEBUG(DBG_LVL_1, "Alloc of SGL_ICD Failed\n"); 3967 SE_DEBUG(DBG_LVL_1, "Alloc of SGL_ICD Failed\n");
3908 return -ENOMEM; 3968 return -ENOMEM;
3909} 3969}
3910 3970
3911static void beiscsi_cleanup_task(struct iscsi_task *task)
3912{
3913 struct beiscsi_io_task *io_task = task->dd_data;
3914 struct iscsi_conn *conn = task->conn;
3915 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
3916 struct beiscsi_hba *phba = beiscsi_conn->phba;
3917 struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess;
3918 struct hwi_wrb_context *pwrb_context;
3919 struct hwi_controller *phwi_ctrlr;
3920
3921 phwi_ctrlr = phba->phwi_ctrlr;
3922 pwrb_context = &phwi_ctrlr->wrb_context[beiscsi_conn->beiscsi_conn_cid
3923 - phba->fw_config.iscsi_cid_start];
3924 if (io_task->pwrb_handle) {
3925 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle);
3926 io_task->pwrb_handle = NULL;
3927 }
3928
3929 if (io_task->cmd_bhs) {
3930 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
3931 io_task->bhs_pa.u.a64.address);
3932 }
3933
3934 if (task->sc) {
3935 if (io_task->psgl_handle) {
3936 spin_lock(&phba->io_sgl_lock);
3937 free_io_sgl_handle(phba, io_task->psgl_handle);
3938 spin_unlock(&phba->io_sgl_lock);
3939 io_task->psgl_handle = NULL;
3940 }
3941 } else {
3942 if (task->hdr &&
3943 ((task->hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN))
3944 return;
3945 if (io_task->psgl_handle) {
3946 spin_lock(&phba->mgmt_sgl_lock);
3947 free_mgmt_sgl_handle(phba, io_task->psgl_handle);
3948 spin_unlock(&phba->mgmt_sgl_lock);
3949 io_task->psgl_handle = NULL;
3950 }
3951 }
3952}
3953
3954static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, 3971static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg,
3955 unsigned int num_sg, unsigned int xferlen, 3972 unsigned int num_sg, unsigned int xferlen,
3956 unsigned int writedir) 3973 unsigned int writedir)