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 | |
| 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>
| -rw-r--r-- | drivers/scsi/be2iscsi/be_iscsi.c | 46 | ||||
| -rw-r--r-- | drivers/scsi/be2iscsi/be_main.c | 69 | ||||
| -rw-r--r-- | drivers/scsi/be2iscsi/be_main.h | 1 |
3 files changed, 51 insertions, 65 deletions
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index f18e643f3589..2fd25442cfaf 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c | |||
| @@ -45,14 +45,9 @@ struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, | |||
| 45 | struct beiscsi_endpoint *beiscsi_ep; | 45 | struct beiscsi_endpoint *beiscsi_ep; |
| 46 | struct iscsi_cls_session *cls_session; | 46 | struct iscsi_cls_session *cls_session; |
| 47 | struct beiscsi_hba *phba; | 47 | struct beiscsi_hba *phba; |
| 48 | struct iscsi_task *task; | ||
| 49 | struct iscsi_session *sess; | 48 | struct iscsi_session *sess; |
| 50 | struct beiscsi_session *beiscsi_sess; | 49 | struct beiscsi_session *beiscsi_sess; |
| 51 | struct beiscsi_io_task *io_task; | 50 | struct beiscsi_io_task *io_task; |
| 52 | unsigned int max_size, num_cmd; | ||
| 53 | dma_addr_t bus_add; | ||
| 54 | u64 pa_addr; | ||
| 55 | void *vaddr; | ||
| 56 | 51 | ||
| 57 | SE_DEBUG(DBG_LVL_8, "In beiscsi_session_create\n"); | 52 | SE_DEBUG(DBG_LVL_8, "In beiscsi_session_create\n"); |
| 58 | 53 | ||
| @@ -80,20 +75,18 @@ struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, | |||
| 80 | if (!cls_session) | 75 | if (!cls_session) |
| 81 | return NULL; | 76 | return NULL; |
| 82 | sess = cls_session->dd_data; | 77 | sess = cls_session->dd_data; |
| 83 | max_size = ALIGN(sizeof(struct be_cmd_bhs), 64) * sess->cmds_max; | 78 | beiscsi_sess = sess->dd_data; |
| 84 | vaddr = pci_alloc_consistent(phba->pcidev, max_size, &bus_add); | 79 | beiscsi_sess->bhs_pool = pci_pool_create("beiscsi_bhs_pool", |
| 85 | pa_addr = (__u64) bus_add; | 80 | phba->pcidev, |
| 86 | 81 | sizeof(struct be_cmd_bhs), | |
| 87 | for (num_cmd = 0; num_cmd < sess->cmds_max; num_cmd++) { | 82 | 64, 0); |
| 88 | task = sess->cmds[num_cmd]; | 83 | if (!beiscsi_sess->bhs_pool) |
| 89 | io_task = task->dd_data; | 84 | goto destroy_sess; |
| 90 | io_task->cmd_bhs = vaddr; | 85 | |
| 91 | io_task->bhs_pa.u.a64.address = pa_addr; | ||
| 92 | io_task->alloc_size = max_size; | ||
| 93 | vaddr += ALIGN(sizeof(struct be_cmd_bhs), 64); | ||
| 94 | pa_addr += ALIGN(sizeof(struct be_cmd_bhs), 64); | ||
| 95 | } | ||
| 96 | return cls_session; | 86 | return cls_session; |
| 87 | destroy_sess: | ||
| 88 | iscsi_session_teardown(cls_session); | ||
| 89 | return NULL; | ||
| 97 | } | 90 | } |
| 98 | 91 | ||
| 99 | /** | 92 | /** |
| @@ -105,18 +98,10 @@ struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, | |||
| 105 | */ | 98 | */ |
| 106 | void beiscsi_session_destroy(struct iscsi_cls_session *cls_session) | 99 | void beiscsi_session_destroy(struct iscsi_cls_session *cls_session) |
| 107 | { | 100 | { |
| 108 | struct iscsi_task *task; | ||
| 109 | struct beiscsi_io_task *io_task; | ||
| 110 | struct iscsi_session *sess = cls_session->dd_data; | 101 | struct iscsi_session *sess = cls_session->dd_data; |
| 111 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); | 102 | struct beiscsi_session *beiscsi_sess = sess->dd_data; |
| 112 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
| 113 | 103 | ||
| 114 | task = sess->cmds[0]; | 104 | pci_pool_destroy(beiscsi_sess->bhs_pool); |
| 115 | io_task = task->dd_data; | ||
| 116 | pci_free_consistent(phba->pcidev, | ||
| 117 | io_task->alloc_size, | ||
| 118 | io_task->cmd_bhs, | ||
| 119 | io_task->bhs_pa.u.a64.address); | ||
| 120 | iscsi_session_teardown(cls_session); | 105 | iscsi_session_teardown(cls_session); |
| 121 | } | 106 | } |
| 122 | 107 | ||
| @@ -133,6 +118,8 @@ beiscsi_conn_create(struct iscsi_cls_session *cls_session, u32 cid) | |||
| 133 | struct iscsi_cls_conn *cls_conn; | 118 | struct iscsi_cls_conn *cls_conn; |
| 134 | struct beiscsi_conn *beiscsi_conn; | 119 | struct beiscsi_conn *beiscsi_conn; |
| 135 | struct iscsi_conn *conn; | 120 | struct iscsi_conn *conn; |
| 121 | struct iscsi_session *sess; | ||
| 122 | struct beiscsi_session *beiscsi_sess; | ||
| 136 | 123 | ||
| 137 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_create ,cid" | 124 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_create ,cid" |
| 138 | "from iscsi layer=%d\n", cid); | 125 | "from iscsi layer=%d\n", cid); |
| @@ -148,6 +135,9 @@ beiscsi_conn_create(struct iscsi_cls_session *cls_session, u32 cid) | |||
| 148 | beiscsi_conn->ep = NULL; | 135 | beiscsi_conn->ep = NULL; |
| 149 | beiscsi_conn->phba = phba; | 136 | beiscsi_conn->phba = phba; |
| 150 | beiscsi_conn->conn = conn; | 137 | beiscsi_conn->conn = conn; |
| 138 | sess = cls_session->dd_data; | ||
| 139 | beiscsi_sess = sess->dd_data; | ||
| 140 | beiscsi_conn->beiscsi_sess = beiscsi_sess; | ||
| 151 | return cls_conn; | 141 | return cls_conn; |
| 152 | } | 142 | } |
| 153 | 143 | ||
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); |
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h index 387e363b0ec7..53c9b70ac7ac 100644 --- a/drivers/scsi/be2iscsi/be_main.h +++ b/drivers/scsi/be2iscsi/be_main.h | |||
| @@ -391,7 +391,6 @@ struct beiscsi_io_task { | |||
| 391 | unsigned short cid; | 391 | unsigned short cid; |
| 392 | unsigned short header_len; | 392 | unsigned short header_len; |
| 393 | 393 | ||
| 394 | unsigned int alloc_size; | ||
| 395 | struct be_cmd_bhs *cmd_bhs; | 394 | struct be_cmd_bhs *cmd_bhs; |
| 396 | struct be_bus_address bhs_pa; | 395 | struct be_bus_address bhs_pa; |
| 397 | unsigned short bhs_len; | 396 | unsigned short bhs_len; |
