diff options
author | Jayamohan Kallickal <jayamohank@serverengines.com> | 2009-09-21 22:52:26 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-10-02 15:01:55 -0400 |
commit | 2afc95bf546a961d2936d886c3802e159f1bae6b (patch) | |
tree | b898db3b79c260dac3f050955fc512c118f97efe /drivers/scsi/be2iscsi/be_main.c | |
parent | b8b9e1b8128d8854cf55740f9ceba3010143520d (diff) |
[SCSI] be2iscsi: Moving to pci_pools v3
This patch contains changes to use pci_pools for iscsi hdr
instead of pci_alloc_consistent. Here we alloc and free to pool
for every IO
v3:
- Remove cleanup loop in beiscsi_session_destroy
- Fixup for allocation failure handling in beiscsi_alloc_pdu
- Removed unused variable in beiscsi_session_destroy.
[jejb: fix up pci_pool_alloc address sizing problem]
Signed-off-by: Jayamohan Kallickal <jayamohank@serverengines.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/be2iscsi/be_main.c')
-rw-r--r-- | drivers/scsi/be2iscsi/be_main.c | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index d520fe875859..4f1aca346e38 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c | |||
@@ -2880,7 +2880,16 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) | |||
2880 | struct hwi_wrb_context *pwrb_context; | 2880 | struct hwi_wrb_context *pwrb_context; |
2881 | struct hwi_controller *phwi_ctrlr; | 2881 | struct hwi_controller *phwi_ctrlr; |
2882 | itt_t itt; | 2882 | itt_t itt; |
2883 | struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess; | ||
2884 | dma_addr_t paddr; | ||
2883 | 2885 | ||
2886 | io_task->cmd_bhs = pci_pool_alloc(beiscsi_sess->bhs_pool, | ||
2887 | GFP_KERNEL, &paddr); | ||
2888 | |||
2889 | if (!io_task->cmd_bhs) | ||
2890 | return -ENOMEM; | ||
2891 | |||
2892 | io_task->bhs_pa.u.a64.address = paddr; | ||
2884 | io_task->pwrb_handle = alloc_wrb_handle(phba, | 2893 | io_task->pwrb_handle = alloc_wrb_handle(phba, |
2885 | beiscsi_conn->beiscsi_conn_cid, | 2894 | beiscsi_conn->beiscsi_conn_cid, |
2886 | task->itt); | 2895 | task->itt); |
@@ -2894,17 +2903,9 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) | |||
2894 | spin_lock(&phba->io_sgl_lock); | 2903 | spin_lock(&phba->io_sgl_lock); |
2895 | io_task->psgl_handle = alloc_io_sgl_handle(phba); | 2904 | io_task->psgl_handle = alloc_io_sgl_handle(phba); |
2896 | spin_unlock(&phba->io_sgl_lock); | 2905 | spin_unlock(&phba->io_sgl_lock); |
2897 | if (!io_task->psgl_handle) { | 2906 | if (!io_task->psgl_handle) |
2898 | phwi_ctrlr = phba->phwi_ctrlr; | 2907 | goto free_hndls; |
2899 | pwrb_context = &phwi_ctrlr->wrb_context | 2908 | |
2900 | [beiscsi_conn->beiscsi_conn_cid]; | ||
2901 | free_wrb_handle(phba, pwrb_context, | ||
2902 | io_task->pwrb_handle); | ||
2903 | io_task->pwrb_handle = NULL; | ||
2904 | SE_DEBUG(DBG_LVL_1, | ||
2905 | "Alloc of SGL_ICD Failed \n"); | ||
2906 | return -ENOMEM; | ||
2907 | } | ||
2908 | } else { | 2909 | } else { |
2909 | io_task->scsi_cmnd = NULL; | 2910 | io_task->scsi_cmnd = NULL; |
2910 | if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN) { | 2911 | if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN) { |
@@ -2913,18 +2914,9 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) | |||
2913 | io_task->psgl_handle = (struct sgl_handle *) | 2914 | io_task->psgl_handle = (struct sgl_handle *) |
2914 | alloc_mgmt_sgl_handle(phba); | 2915 | alloc_mgmt_sgl_handle(phba); |
2915 | spin_unlock(&phba->mgmt_sgl_lock); | 2916 | spin_unlock(&phba->mgmt_sgl_lock); |
2916 | if (!io_task->psgl_handle) { | 2917 | if (!io_task->psgl_handle) |
2917 | phwi_ctrlr = phba->phwi_ctrlr; | 2918 | goto free_hndls; |
2918 | pwrb_context = | 2919 | |
2919 | &phwi_ctrlr->wrb_context | ||
2920 | [beiscsi_conn->beiscsi_conn_cid]; | ||
2921 | free_wrb_handle(phba, pwrb_context, | ||
2922 | io_task->pwrb_handle); | ||
2923 | io_task->pwrb_handle = NULL; | ||
2924 | SE_DEBUG(DBG_LVL_1, "Alloc of " | ||
2925 | "MGMT_SGL_ICD Failed \n"); | ||
2926 | return -ENOMEM; | ||
2927 | } | ||
2928 | beiscsi_conn->login_in_progress = 1; | 2920 | beiscsi_conn->login_in_progress = 1; |
2929 | beiscsi_conn->plogin_sgl_handle = | 2921 | beiscsi_conn->plogin_sgl_handle = |
2930 | io_task->psgl_handle; | 2922 | io_task->psgl_handle; |
@@ -2936,23 +2928,24 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) | |||
2936 | spin_lock(&phba->mgmt_sgl_lock); | 2928 | spin_lock(&phba->mgmt_sgl_lock); |
2937 | io_task->psgl_handle = alloc_mgmt_sgl_handle(phba); | 2929 | io_task->psgl_handle = alloc_mgmt_sgl_handle(phba); |
2938 | spin_unlock(&phba->mgmt_sgl_lock); | 2930 | spin_unlock(&phba->mgmt_sgl_lock); |
2939 | if (!io_task->psgl_handle) { | 2931 | if (!io_task->psgl_handle) |
2940 | phwi_ctrlr = phba->phwi_ctrlr; | 2932 | goto free_hndls; |
2941 | pwrb_context = &phwi_ctrlr->wrb_context | ||
2942 | [beiscsi_conn->beiscsi_conn_cid]; | ||
2943 | free_wrb_handle(phba, pwrb_context, | ||
2944 | io_task->pwrb_handle); | ||
2945 | io_task->pwrb_handle = NULL; | ||
2946 | SE_DEBUG(DBG_LVL_1, "Alloc of " | ||
2947 | "MGMT_SGL_ICD Failed \n"); | ||
2948 | return -ENOMEM; | ||
2949 | } | ||
2950 | } | 2933 | } |
2951 | } | 2934 | } |
2952 | itt = (itt_t) cpu_to_be32(((unsigned int)task->itt << 16) | | 2935 | itt = (itt_t) cpu_to_be32(((unsigned int)task->itt << 16) | |
2953 | (unsigned int)(io_task->psgl_handle->sgl_index)); | 2936 | (unsigned int)(io_task->psgl_handle->sgl_index)); |
2954 | io_task->cmd_bhs->iscsi_hdr.itt = itt; | 2937 | io_task->cmd_bhs->iscsi_hdr.itt = itt; |
2955 | return 0; | 2938 | return 0; |
2939 | |||
2940 | free_hndls: | ||
2941 | phwi_ctrlr = phba->phwi_ctrlr; | ||
2942 | pwrb_context = &phwi_ctrlr->wrb_context[beiscsi_conn->beiscsi_conn_cid]; | ||
2943 | free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); | ||
2944 | io_task->pwrb_handle = NULL; | ||
2945 | pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, | ||
2946 | io_task->bhs_pa.u.a64.address); | ||
2947 | SE_DEBUG(DBG_LVL_1, "Alloc of SGL_ICD Failed \n"); | ||
2948 | return -ENOMEM; | ||
2956 | } | 2949 | } |
2957 | 2950 | ||
2958 | static void beiscsi_cleanup_task(struct iscsi_task *task) | 2951 | static void beiscsi_cleanup_task(struct iscsi_task *task) |
@@ -2961,6 +2954,7 @@ static void beiscsi_cleanup_task(struct iscsi_task *task) | |||
2961 | struct iscsi_conn *conn = task->conn; | 2954 | struct iscsi_conn *conn = task->conn; |
2962 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; | 2955 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; |
2963 | struct beiscsi_hba *phba = beiscsi_conn->phba; | 2956 | struct beiscsi_hba *phba = beiscsi_conn->phba; |
2957 | struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess; | ||
2964 | struct hwi_wrb_context *pwrb_context; | 2958 | struct hwi_wrb_context *pwrb_context; |
2965 | struct hwi_controller *phwi_ctrlr; | 2959 | struct hwi_controller *phwi_ctrlr; |
2966 | 2960 | ||
@@ -2971,6 +2965,11 @@ static void beiscsi_cleanup_task(struct iscsi_task *task) | |||
2971 | io_task->pwrb_handle = NULL; | 2965 | io_task->pwrb_handle = NULL; |
2972 | } | 2966 | } |
2973 | 2967 | ||
2968 | if (io_task->cmd_bhs) { | ||
2969 | pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, | ||
2970 | io_task->bhs_pa.u.a64.address); | ||
2971 | } | ||
2972 | |||
2974 | if (task->sc) { | 2973 | if (task->sc) { |
2975 | if (io_task->psgl_handle) { | 2974 | if (io_task->psgl_handle) { |
2976 | spin_lock(&phba->io_sgl_lock); | 2975 | spin_lock(&phba->io_sgl_lock); |
@@ -3003,7 +3002,6 @@ static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, | |||
3003 | unsigned int doorbell = 0; | 3002 | unsigned int doorbell = 0; |
3004 | 3003 | ||
3005 | pwrb = io_task->pwrb_handle->pwrb; | 3004 | pwrb = io_task->pwrb_handle->pwrb; |
3006 | |||
3007 | io_task->cmd_bhs->iscsi_hdr.exp_statsn = 0; | 3005 | io_task->cmd_bhs->iscsi_hdr.exp_statsn = 0; |
3008 | io_task->bhs_len = sizeof(struct be_cmd_bhs); | 3006 | io_task->bhs_len = sizeof(struct be_cmd_bhs); |
3009 | 3007 | ||
@@ -3020,7 +3018,6 @@ static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, | |||
3020 | &io_task->cmd_bhs->iscsi_data_pdu, 1); | 3018 | &io_task->cmd_bhs->iscsi_data_pdu, 1); |
3021 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, INI_WR_CMD); | 3019 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, INI_WR_CMD); |
3022 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 1); | 3020 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 1); |
3023 | |||
3024 | } else { | 3021 | } else { |
3025 | SE_DEBUG(DBG_LVL_4, "READ Command \t"); | 3022 | SE_DEBUG(DBG_LVL_4, "READ Command \t"); |
3026 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, INI_RD_CMD); | 3023 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, INI_RD_CMD); |