Skip to content

Commit c51a986

Browse files
author
Christoph Hellwig
committed
firewire-ohci: use dma_alloc_pages
Use dma_alloc_pages to allocate DMAable pages instead of hoping that the architecture either has GFP_DMA32 or not more than 4G of memory. Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent e8d39a9 commit c51a986

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

drivers/firewire/ohci.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -674,17 +674,16 @@ static void ar_context_link_page(struct ar_context *ctx, unsigned int index)
674674

675675
static void ar_context_release(struct ar_context *ctx)
676676
{
677+
struct device *dev = ctx->ohci->card.device;
677678
unsigned int i;
678679

679680
vunmap(ctx->buffer);
680681

681-
for (i = 0; i < AR_BUFFERS; i++)
682-
if (ctx->pages[i]) {
683-
dma_unmap_page(ctx->ohci->card.device,
684-
ar_buffer_bus(ctx, i),
685-
PAGE_SIZE, DMA_FROM_DEVICE);
686-
__free_page(ctx->pages[i]);
687-
}
682+
for (i = 0; i < AR_BUFFERS; i++) {
683+
if (ctx->pages[i])
684+
dma_free_pages(dev, PAGE_SIZE, ctx->pages[i],
685+
ar_buffer_bus(ctx, i), DMA_FROM_DEVICE);
686+
}
688687
}
689688

690689
static void ar_context_abort(struct ar_context *ctx, const char *error_msg)
@@ -970,6 +969,7 @@ static void ar_context_tasklet(unsigned long data)
970969
static int ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci,
971970
unsigned int descriptors_offset, u32 regs)
972971
{
972+
struct device *dev = ohci->card.device;
973973
unsigned int i;
974974
dma_addr_t dma_addr;
975975
struct page *pages[AR_BUFFERS + AR_WRAPAROUND_PAGES];
@@ -980,17 +980,13 @@ static int ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci,
980980
tasklet_init(&ctx->tasklet, ar_context_tasklet, (unsigned long)ctx);
981981

982982
for (i = 0; i < AR_BUFFERS; i++) {
983-
ctx->pages[i] = alloc_page(GFP_KERNEL | GFP_DMA32);
983+
ctx->pages[i] = dma_alloc_pages(dev, PAGE_SIZE, &dma_addr,
984+
DMA_FROM_DEVICE, GFP_KERNEL);
984985
if (!ctx->pages[i])
985986
goto out_of_memory;
986-
dma_addr = dma_map_page(ohci->card.device, ctx->pages[i],
987-
0, PAGE_SIZE, DMA_FROM_DEVICE);
988-
if (dma_mapping_error(ohci->card.device, dma_addr)) {
989-
__free_page(ctx->pages[i]);
990-
ctx->pages[i] = NULL;
991-
goto out_of_memory;
992-
}
993987
set_page_private(ctx->pages[i], dma_addr);
988+
dma_sync_single_for_device(dev, dma_addr, PAGE_SIZE,
989+
DMA_FROM_DEVICE);
994990
}
995991

996992
for (i = 0; i < AR_BUFFERS; i++)

0 commit comments

Comments
 (0)