diff options
author | Krishna Gudipati <kgudipat@brocade.com> | 2011-06-24 23:24:29 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-06-29 18:11:09 -0400 |
commit | 4507025d01149aea8705e43508d0ef11e7010cfd (patch) | |
tree | 937fefad76c8534bd42e0d1e46659db61ea57288 /drivers/scsi/bfa/bfa_fcpim.c | |
parent | 3fd459804ff8e002db2671900debd0fc6dc6c443 (diff) |
[SCSI] bfa: DMA memory allocation enhancement.
- Modified the design such that each BFA sub-module will provide
the amount of DMA and KVA memory needed by it and queues the
same request to the global dma and kva info queues.
- During the memory allocation we iterate over this queue to allocate
the dma and kva memory requested by sub-modules.
- The change is needed to avoid requesting the aggregate amount of memory
needed by all the BFA sub-modules as one contiguous chunk.
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bfa/bfa_fcpim.c')
-rw-r--r-- | drivers/scsi/bfa/bfa_fcpim.c | 119 |
1 files changed, 75 insertions, 44 deletions
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c index eb14fd6193a0..27eab36f89a5 100644 --- a/drivers/scsi/bfa/bfa_fcpim.c +++ b/drivers/scsi/bfa/bfa_fcpim.c | |||
@@ -286,10 +286,9 @@ static void bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim, | |||
286 | * Compute and return memory needed by FCP(im) module. | 286 | * Compute and return memory needed by FCP(im) module. |
287 | */ | 287 | */ |
288 | static void | 288 | static void |
289 | bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 289 | bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len) |
290 | u32 *dm_len) | ||
291 | { | 290 | { |
292 | bfa_itnim_meminfo(cfg, km_len, dm_len); | 291 | bfa_itnim_meminfo(cfg, km_len); |
293 | 292 | ||
294 | /* | 293 | /* |
295 | * IO memory | 294 | * IO memory |
@@ -308,8 +307,7 @@ bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | |||
308 | 307 | ||
309 | static void | 308 | static void |
310 | bfa_fcpim_attach(struct bfa_fcp_mod_s *fcp, void *bfad, | 309 | bfa_fcpim_attach(struct bfa_fcp_mod_s *fcp, void *bfad, |
311 | struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo, | 310 | struct bfa_iocfc_cfg_s *cfg, struct bfa_pcidev_s *pcidev) |
312 | struct bfa_pcidev_s *pcidev) | ||
313 | { | 311 | { |
314 | struct bfa_fcpim_s *fcpim = &fcp->fcpim; | 312 | struct bfa_fcpim_s *fcpim = &fcp->fcpim; |
315 | struct bfa_s *bfa = fcp->bfa; | 313 | struct bfa_s *bfa = fcp->bfa; |
@@ -328,9 +326,9 @@ bfa_fcpim_attach(struct bfa_fcp_mod_s *fcp, void *bfad, | |||
328 | fcpim->profile_comp = NULL; | 326 | fcpim->profile_comp = NULL; |
329 | fcpim->profile_start = NULL; | 327 | fcpim->profile_start = NULL; |
330 | 328 | ||
331 | bfa_itnim_attach(fcpim, meminfo); | 329 | bfa_itnim_attach(fcpim); |
332 | bfa_tskim_attach(fcpim, meminfo); | 330 | bfa_tskim_attach(fcpim); |
333 | bfa_ioim_attach(fcpim, meminfo); | 331 | bfa_ioim_attach(fcpim); |
334 | } | 332 | } |
335 | 333 | ||
336 | static void | 334 | static void |
@@ -972,8 +970,7 @@ bfa_itnim_tskdone(struct bfa_itnim_s *itnim) | |||
972 | } | 970 | } |
973 | 971 | ||
974 | void | 972 | void |
975 | bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | 973 | bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len) |
976 | u32 *dm_len) | ||
977 | { | 974 | { |
978 | /* | 975 | /* |
979 | * ITN memory | 976 | * ITN memory |
@@ -982,15 +979,16 @@ bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, | |||
982 | } | 979 | } |
983 | 980 | ||
984 | void | 981 | void |
985 | bfa_itnim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | 982 | bfa_itnim_attach(struct bfa_fcpim_s *fcpim) |
986 | { | 983 | { |
987 | struct bfa_s *bfa = fcpim->bfa; | 984 | struct bfa_s *bfa = fcpim->bfa; |
985 | struct bfa_fcp_mod_s *fcp = fcpim->fcp; | ||
988 | struct bfa_itnim_s *itnim; | 986 | struct bfa_itnim_s *itnim; |
989 | int i, j; | 987 | int i, j; |
990 | 988 | ||
991 | INIT_LIST_HEAD(&fcpim->itnim_q); | 989 | INIT_LIST_HEAD(&fcpim->itnim_q); |
992 | 990 | ||
993 | itnim = (struct bfa_itnim_s *) bfa_meminfo_kva(minfo); | 991 | itnim = (struct bfa_itnim_s *) bfa_mem_kva_curp(fcp); |
994 | fcpim->itnim_arr = itnim; | 992 | fcpim->itnim_arr = itnim; |
995 | 993 | ||
996 | for (i = 0; i < fcpim->num_itnims; i++, itnim++) { | 994 | for (i = 0; i < fcpim->num_itnims; i++, itnim++) { |
@@ -1012,7 +1010,7 @@ bfa_itnim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | |||
1012 | bfa_sm_set_state(itnim, bfa_itnim_sm_uninit); | 1010 | bfa_sm_set_state(itnim, bfa_itnim_sm_uninit); |
1013 | } | 1011 | } |
1014 | 1012 | ||
1015 | bfa_meminfo_kva(minfo) = (u8 *) itnim; | 1013 | bfa_mem_kva_curp(fcp) = (u8 *) itnim; |
1016 | } | 1014 | } |
1017 | 1015 | ||
1018 | void | 1016 | void |
@@ -2345,22 +2343,23 @@ bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim, bfa_boolean_t iotov) | |||
2345 | * Memory allocation and initialization. | 2343 | * Memory allocation and initialization. |
2346 | */ | 2344 | */ |
2347 | void | 2345 | void |
2348 | bfa_ioim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | 2346 | bfa_ioim_attach(struct bfa_fcpim_s *fcpim) |
2349 | { | 2347 | { |
2350 | struct bfa_ioim_s *ioim; | 2348 | struct bfa_ioim_s *ioim; |
2349 | struct bfa_fcp_mod_s *fcp = fcpim->fcp; | ||
2351 | struct bfa_ioim_sp_s *iosp; | 2350 | struct bfa_ioim_sp_s *iosp; |
2352 | u16 i; | 2351 | u16 i; |
2353 | 2352 | ||
2354 | /* | 2353 | /* |
2355 | * claim memory first | 2354 | * claim memory first |
2356 | */ | 2355 | */ |
2357 | ioim = (struct bfa_ioim_s *) bfa_meminfo_kva(minfo); | 2356 | ioim = (struct bfa_ioim_s *) bfa_mem_kva_curp(fcp); |
2358 | fcpim->ioim_arr = ioim; | 2357 | fcpim->ioim_arr = ioim; |
2359 | bfa_meminfo_kva(minfo) = (u8 *) (ioim + fcpim->fcp->num_ioim_reqs); | 2358 | bfa_mem_kva_curp(fcp) = (u8 *) (ioim + fcpim->fcp->num_ioim_reqs); |
2360 | 2359 | ||
2361 | iosp = (struct bfa_ioim_sp_s *) bfa_meminfo_kva(minfo); | 2360 | iosp = (struct bfa_ioim_sp_s *) bfa_mem_kva_curp(fcp); |
2362 | fcpim->ioim_sp_arr = iosp; | 2361 | fcpim->ioim_sp_arr = iosp; |
2363 | bfa_meminfo_kva(minfo) = (u8 *) (iosp + fcpim->fcp->num_ioim_reqs); | 2362 | bfa_mem_kva_curp(fcp) = (u8 *) (iosp + fcpim->fcp->num_ioim_reqs); |
2364 | 2363 | ||
2365 | /* | 2364 | /* |
2366 | * Initialize ioim free queues | 2365 | * Initialize ioim free queues |
@@ -3109,15 +3108,16 @@ bfa_tskim_cleanup(struct bfa_tskim_s *tskim) | |||
3109 | * Memory allocation and initialization. | 3108 | * Memory allocation and initialization. |
3110 | */ | 3109 | */ |
3111 | void | 3110 | void |
3112 | bfa_tskim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | 3111 | bfa_tskim_attach(struct bfa_fcpim_s *fcpim) |
3113 | { | 3112 | { |
3114 | struct bfa_tskim_s *tskim; | 3113 | struct bfa_tskim_s *tskim; |
3114 | struct bfa_fcp_mod_s *fcp = fcpim->fcp; | ||
3115 | u16 i; | 3115 | u16 i; |
3116 | 3116 | ||
3117 | INIT_LIST_HEAD(&fcpim->tskim_free_q); | 3117 | INIT_LIST_HEAD(&fcpim->tskim_free_q); |
3118 | INIT_LIST_HEAD(&fcpim->tskim_unused_q); | 3118 | INIT_LIST_HEAD(&fcpim->tskim_unused_q); |
3119 | 3119 | ||
3120 | tskim = (struct bfa_tskim_s *) bfa_meminfo_kva(minfo); | 3120 | tskim = (struct bfa_tskim_s *) bfa_mem_kva_curp(fcp); |
3121 | fcpim->tskim_arr = tskim; | 3121 | fcpim->tskim_arr = tskim; |
3122 | 3122 | ||
3123 | for (i = 0; i < fcpim->num_tskim_reqs; i++, tskim++) { | 3123 | for (i = 0; i < fcpim->num_tskim_reqs; i++, tskim++) { |
@@ -3136,7 +3136,7 @@ bfa_tskim_attach(struct bfa_fcpim_s *fcpim, struct bfa_meminfo_s *minfo) | |||
3136 | list_add_tail(&tskim->qe, &fcpim->tskim_free_q); | 3136 | list_add_tail(&tskim->qe, &fcpim->tskim_free_q); |
3137 | } | 3137 | } |
3138 | 3138 | ||
3139 | bfa_meminfo_kva(minfo) = (u8 *) tskim; | 3139 | bfa_mem_kva_curp(fcp) = (u8 *) tskim; |
3140 | } | 3140 | } |
3141 | 3141 | ||
3142 | void | 3142 | void |
@@ -3233,9 +3233,14 @@ bfa_tskim_res_recfg(struct bfa_s *bfa, u16 num_tskim_fw) | |||
3233 | BFA_MODULE(fcp); | 3233 | BFA_MODULE(fcp); |
3234 | 3234 | ||
3235 | static void | 3235 | static void |
3236 | bfa_fcp_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, u32 *dm_len) | 3236 | bfa_fcp_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo, |
3237 | struct bfa_s *bfa) | ||
3237 | { | 3238 | { |
3238 | u16 num_io_req; | 3239 | struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa); |
3240 | struct bfa_mem_kva_s *fcp_kva = BFA_MEM_FCP_KVA(bfa); | ||
3241 | struct bfa_mem_dma_s *seg_ptr; | ||
3242 | u16 nsegs, idx, per_seg_ios, num_io_req; | ||
3243 | u32 km_len = 0; | ||
3239 | 3244 | ||
3240 | /* | 3245 | /* |
3241 | * ZERO for num_ioim_reqs and num_fwtio_reqs is allowed config value. | 3246 | * ZERO for num_ioim_reqs and num_fwtio_reqs is allowed config value. |
@@ -3261,43 +3266,69 @@ bfa_fcp_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, u32 *dm_len) | |||
3261 | cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX; | 3266 | cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX; |
3262 | } | 3267 | } |
3263 | 3268 | ||
3264 | bfa_fcpim_meminfo(cfg, km_len, dm_len); | 3269 | bfa_fcpim_meminfo(cfg, &km_len); |
3265 | 3270 | ||
3266 | num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs); | 3271 | num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs); |
3267 | *km_len += num_io_req * sizeof(struct bfa_iotag_s); | 3272 | km_len += num_io_req * sizeof(struct bfa_iotag_s); |
3268 | *km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_itn_s); | 3273 | km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_itn_s); |
3269 | *dm_len += num_io_req * BFI_IOIM_SNSLEN; | 3274 | |
3275 | /* dma memory */ | ||
3276 | nsegs = BFI_MEM_DMA_NSEGS(num_io_req, BFI_IOIM_SNSLEN); | ||
3277 | per_seg_ios = BFI_MEM_NREQS_SEG(BFI_IOIM_SNSLEN); | ||
3278 | |||
3279 | bfa_mem_dma_seg_iter(fcp, seg_ptr, nsegs, idx) { | ||
3280 | if (num_io_req >= per_seg_ios) { | ||
3281 | num_io_req -= per_seg_ios; | ||
3282 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
3283 | per_seg_ios * BFI_IOIM_SNSLEN); | ||
3284 | } else | ||
3285 | bfa_mem_dma_setup(minfo, seg_ptr, | ||
3286 | num_io_req * BFI_IOIM_SNSLEN); | ||
3287 | } | ||
3288 | |||
3289 | /* kva memory */ | ||
3290 | bfa_mem_kva_setup(minfo, fcp_kva, km_len); | ||
3270 | } | 3291 | } |
3271 | 3292 | ||
3272 | static void | 3293 | static void |
3273 | bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, | 3294 | bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
3274 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) | 3295 | struct bfa_pcidev_s *pcidev) |
3275 | { | 3296 | { |
3276 | struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa); | 3297 | struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa); |
3277 | u32 snsbufsz; | 3298 | struct bfa_mem_dma_s *seg_ptr; |
3299 | u16 idx, nsegs, num_io_req; | ||
3278 | 3300 | ||
3279 | fcp->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs; | 3301 | fcp->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs; |
3280 | fcp->num_fwtio_reqs = cfg->fwcfg.num_fwtio_reqs; | 3302 | fcp->num_fwtio_reqs = cfg->fwcfg.num_fwtio_reqs; |
3281 | fcp->num_itns = cfg->fwcfg.num_rports; | 3303 | fcp->num_itns = cfg->fwcfg.num_rports; |
3282 | fcp->bfa = bfa; | 3304 | fcp->bfa = bfa; |
3283 | 3305 | ||
3284 | snsbufsz = (fcp->num_ioim_reqs + fcp->num_fwtio_reqs) * BFI_IOIM_SNSLEN; | 3306 | /* |
3285 | fcp->snsbase.pa = bfa_meminfo_dma_phys(meminfo); | 3307 | * Setup the pool of snsbase addr's, that is passed to fw as |
3286 | bfa_meminfo_dma_phys(meminfo) += snsbufsz; | 3308 | * part of bfi_iocfc_cfg_s. |
3309 | */ | ||
3310 | num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs); | ||
3311 | nsegs = BFI_MEM_DMA_NSEGS(num_io_req, BFI_IOIM_SNSLEN); | ||
3312 | |||
3313 | bfa_mem_dma_seg_iter(fcp, seg_ptr, nsegs, idx) { | ||
3314 | |||
3315 | if (!bfa_mem_dma_virt(seg_ptr)) | ||
3316 | break; | ||
3317 | |||
3318 | fcp->snsbase[idx].pa = bfa_mem_dma_phys(seg_ptr); | ||
3319 | fcp->snsbase[idx].kva = bfa_mem_dma_virt(seg_ptr); | ||
3320 | bfa_iocfc_set_snsbase(bfa, idx, fcp->snsbase[idx].pa); | ||
3321 | } | ||
3287 | 3322 | ||
3288 | fcp->snsbase.kva = bfa_meminfo_dma_virt(meminfo); | 3323 | bfa_fcpim_attach(fcp, bfad, cfg, pcidev); |
3289 | bfa_meminfo_dma_virt(meminfo) += snsbufsz; | ||
3290 | bfa_iocfc_set_snsbase(bfa, fcp->snsbase.pa); | ||
3291 | 3324 | ||
3292 | bfa_fcpim_attach(fcp, bfad, cfg, meminfo, pcidev); | 3325 | bfa_iotag_attach(fcp); |
3293 | 3326 | ||
3294 | fcp->itn_arr = (struct bfa_itn_s *) bfa_meminfo_kva(meminfo); | 3327 | fcp->itn_arr = (struct bfa_itn_s *) bfa_mem_kva_curp(fcp); |
3295 | bfa_meminfo_kva(meminfo) = (u8 *)fcp->itn_arr + | 3328 | bfa_mem_kva_curp(fcp) = (u8 *)fcp->itn_arr + |
3296 | (fcp->num_itns * sizeof(struct bfa_itn_s)); | 3329 | (fcp->num_itns * sizeof(struct bfa_itn_s)); |
3297 | memset(fcp->itn_arr, 0, | 3330 | memset(fcp->itn_arr, 0, |
3298 | (fcp->num_itns * sizeof(struct bfa_itn_s))); | 3331 | (fcp->num_itns * sizeof(struct bfa_itn_s))); |
3299 | |||
3300 | bfa_iotag_attach(fcp, meminfo); | ||
3301 | } | 3332 | } |
3302 | 3333 | ||
3303 | static void | 3334 | static void |
@@ -3370,12 +3401,12 @@ bfa_itn_isr(struct bfa_s *bfa, struct bfi_msg_s *m) | |||
3370 | } | 3401 | } |
3371 | 3402 | ||
3372 | void | 3403 | void |
3373 | bfa_iotag_attach(struct bfa_fcp_mod_s *fcp, struct bfa_meminfo_s *minfo) | 3404 | bfa_iotag_attach(struct bfa_fcp_mod_s *fcp) |
3374 | { | 3405 | { |
3375 | struct bfa_iotag_s *iotag; | 3406 | struct bfa_iotag_s *iotag; |
3376 | u16 num_io_req, i; | 3407 | u16 num_io_req, i; |
3377 | 3408 | ||
3378 | iotag = (struct bfa_iotag_s *) bfa_meminfo_kva(minfo); | 3409 | iotag = (struct bfa_iotag_s *) bfa_mem_kva_curp(fcp); |
3379 | fcp->iotag_arr = iotag; | 3410 | fcp->iotag_arr = iotag; |
3380 | 3411 | ||
3381 | INIT_LIST_HEAD(&fcp->iotag_ioim_free_q); | 3412 | INIT_LIST_HEAD(&fcp->iotag_ioim_free_q); |
@@ -3392,5 +3423,5 @@ bfa_iotag_attach(struct bfa_fcp_mod_s *fcp, struct bfa_meminfo_s *minfo) | |||
3392 | list_add_tail(&iotag->qe, &fcp->iotag_tio_free_q); | 3423 | list_add_tail(&iotag->qe, &fcp->iotag_tio_free_q); |
3393 | } | 3424 | } |
3394 | 3425 | ||
3395 | bfa_meminfo_kva(minfo) = (u8 *) iotag; | 3426 | bfa_mem_kva_curp(fcp) = (u8 *) iotag; |
3396 | } | 3427 | } |