firewire: fw-ohci: use dma_alloc_coherent for ar_buffer

Currently, we do nothing to guarantee we have a consistent DMA buffer for
asynchronous receive packets. Rather than doing several sync's following a
dma_map_single() to get consistent buffers, just switch to using
dma_alloc_coherent().

Resolves constant buffer failures on my own x86_64 laptop w/4GB of RAM and
likely to fix a number of other failures witnessed on x86_64 systems with
4GB of RAM or more.

Signed-off-by: Jarod Wilson <jwilson@redhat.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

authored by Jarod Wilson and committed by Stefan Richter bde1709a 6e45ef4c

+5 -13
+5 -13
drivers/firewire/fw-ohci.c
··· 284 284 dma_addr_t ab_bus; 285 285 size_t offset; 286 286 287 - ab = (struct ar_buffer *) __get_free_page(GFP_ATOMIC); 287 + ab = dma_alloc_coherent(dev, PAGE_SIZE, &ab_bus, GFP_ATOMIC); 288 288 if (ab == NULL) 289 289 return -ENOMEM; 290 - 291 - ab_bus = dma_map_single(dev, ab, PAGE_SIZE, DMA_BIDIRECTIONAL); 292 - if (dma_mapping_error(ab_bus)) { 293 - free_page((unsigned long) ab); 294 - return -ENOMEM; 295 - } 296 290 297 291 memset(&ab->descriptor, 0, sizeof(ab->descriptor)); 298 292 ab->descriptor.control = cpu_to_le16(DESCRIPTOR_INPUT_MORE | ··· 297 303 ab->descriptor.data_address = cpu_to_le32(ab_bus + offset); 298 304 ab->descriptor.res_count = cpu_to_le16(PAGE_SIZE - offset); 299 305 ab->descriptor.branch_address = 0; 300 - 301 - dma_sync_single_for_device(dev, ab_bus, PAGE_SIZE, DMA_BIDIRECTIONAL); 302 306 303 307 ctx->last_buffer->descriptor.branch_address = cpu_to_le32(ab_bus | 1); 304 308 ctx->last_buffer->next = ab; ··· 401 409 402 410 if (d->res_count == 0) { 403 411 size_t size, rest, offset; 412 + dma_addr_t buffer_bus; 404 413 405 414 /* 406 415 * This descriptor is finished and we may have a ··· 410 417 */ 411 418 412 419 offset = offsetof(struct ar_buffer, data); 413 - dma_unmap_single(ohci->card.device, 414 - le32_to_cpu(ab->descriptor.data_address) - offset, 415 - PAGE_SIZE, DMA_BIDIRECTIONAL); 420 + buffer_bus = le32_to_cpu(ab->descriptor.data_address) - offset; 416 421 417 422 buffer = ab; 418 423 ab = ab->next; ··· 426 435 while (buffer < end) 427 436 buffer = handle_ar_packet(ctx, buffer); 428 437 429 - free_page((unsigned long)buffer); 438 + dma_free_coherent(ohci->card.device, PAGE_SIZE, 439 + buffer, buffer_bus); 430 440 ar_context_add_page(ctx); 431 441 } else { 432 442 buffer = ctx->pointer;