diff options
author | Christoph Hellwig <hch@infradead.org> | 2011-04-02 08:15:04 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 04:00:37 -0700 |
commit | bc5c96748a5f2067193faa8131b2aa5f9775d309 (patch) | |
tree | 509dc1a4e1cd2859f9c521af6c41b0a955226bc2 /drivers/scsi/isci/host.c | |
parent | 524b5f723be8a1d966c1285d69810bc461f181c2 (diff) | |
download | kernel_samsung_crespo-bc5c96748a5f2067193faa8131b2aa5f9775d309.zip kernel_samsung_crespo-bc5c96748a5f2067193faa8131b2aa5f9775d309.tar.gz kernel_samsung_crespo-bc5c96748a5f2067193faa8131b2aa5f9775d309.tar.bz2 |
isci: simplify dma coherent allocation
Remove the insane infrastructure for preallocating coheren DMA regions,
and just allocate the memory where needed. This also gets rid of the
aligment adjustments given that Documentation/DMA-API-HOWTO.txt sais:
"The cpu return address and the DMA bus master address are both
guaranteed to be aligned to the smallest PAGE_SIZE order which
is greater than or equal to the requested size. This invariant
exists (for example) to guarantee that if you allocate a chunk
which is smaller than or equal to 64 kilobytes, the extent of the
buffer you receive will not cross a 64K boundary."
Signed-off-by: Christoph Hellwig <hch@lst.de>
[djbw: moved allocation from start to init, re-add memset]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/host.c')
-rw-r--r-- | drivers/scsi/isci/host.c | 95 |
1 files changed, 1 insertions, 94 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index adfc245..927f088 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c @@ -170,96 +170,6 @@ void isci_host_stop_complete(struct isci_host *ihost, enum sci_status completion wake_up(&ihost->eventq); } -static struct coherent_memory_info *isci_host_alloc_mdl_struct( - struct isci_host *isci_host, - u32 size) -{ - struct coherent_memory_info *mdl_struct; - void *uncached_address = NULL; - - - mdl_struct = devm_kzalloc(&isci_host->pdev->dev, - sizeof(*mdl_struct), - GFP_KERNEL); - if (!mdl_struct) - return NULL; - - INIT_LIST_HEAD(&mdl_struct->node); - - uncached_address = dmam_alloc_coherent(&isci_host->pdev->dev, - size, - &mdl_struct->dma_handle, - GFP_KERNEL); - if (!uncached_address) - return NULL; - - /* memset the whole memory area. */ - memset((char *)uncached_address, 0, size); - mdl_struct->vaddr = uncached_address; - mdl_struct->size = (size_t)size; - - return mdl_struct; -} - -static void isci_host_build_mde( - struct sci_physical_memory_descriptor *mde_struct, - struct coherent_memory_info *mdl_struct) -{ - unsigned long address = 0; - dma_addr_t dma_addr = 0; - - address = (unsigned long)mdl_struct->vaddr; - dma_addr = mdl_struct->dma_handle; - - /* to satisfy the alignment. */ - if ((address % mde_struct->constant_memory_alignment) != 0) { - int align_offset - = (mde_struct->constant_memory_alignment - - (address % mde_struct->constant_memory_alignment)); - address += align_offset; - dma_addr += align_offset; - } - - mde_struct->virtual_address = (void *)address; - mde_struct->physical_address = dma_addr; - mdl_struct->mde = mde_struct; -} - -static int isci_host_mdl_allocate_coherent( - struct isci_host *isci_host) -{ - struct sci_physical_memory_descriptor *current_mde; - struct coherent_memory_info *mdl_struct; - u32 size = 0; - - struct sci_base_memory_descriptor_list *mdl_handle = - &isci_host->core_controller->mdl; - - sci_mdl_first_entry(mdl_handle); - - current_mde = sci_mdl_get_current_entry(mdl_handle); - - while (current_mde != NULL) { - - size = (current_mde->constant_memory_size - + current_mde->constant_memory_alignment); - - mdl_struct = isci_host_alloc_mdl_struct(isci_host, size); - if (!mdl_struct) - return -ENOMEM; - - list_add_tail(&mdl_struct->node, &isci_host->mdl_struct_list); - - isci_host_build_mde(current_mde, mdl_struct); - - sci_mdl_next_entry(mdl_handle); - current_mde = sci_mdl_get_current_entry(mdl_handle); - } - - return 0; -} - - /** * isci_host_completion_routine() - This function is the delayed service * routine that calls the sci core library's completion handler. It's @@ -523,8 +433,6 @@ int isci_host_init(struct isci_host *isci_host) tasklet_init(&isci_host->completion_tasklet, isci_host_completion_routine, (unsigned long)isci_host); - INIT_LIST_HEAD(&(isci_host->mdl_struct_list)); - INIT_LIST_HEAD(&isci_host->requests_to_complete); INIT_LIST_HEAD(&isci_host->requests_to_errorback); @@ -539,8 +447,7 @@ int isci_host_init(struct isci_host *isci_host) return -ENODEV; } - /* populate mdl with dma memory. scu_mdl_allocate_coherent() */ - err = isci_host_mdl_allocate_coherent(isci_host); + err = scic_controller_mem_init(isci_host->core_controller); if (err) return err; |