aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlegacy/4965-mac.c
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2013-01-30 11:08:03 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-02-01 14:27:22 -0500
commit96ebbe8d019ab50b34fc3499398ab98de8c2d01b (patch)
treed8f3e0c8d555183a85b7560bdfec1d659722f842 /drivers/net/wireless/iwlegacy/4965-mac.c
parent58b27101e16f2a24e901dd9e67c2ab6e5707d6a3 (diff)
iwlegacy: check for dma mapping errors
Handle pci_map_page() errors. This fixes "DMA-API: device driver failed to check map error" warning. Reported-by: Zdenek Kabelac <zkabelac@redhat.com> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy/4965-mac.c')
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index d2d5aae21d38..9741ac10a334 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -319,6 +319,7 @@ il4965_rx_allocate(struct il_priv *il, gfp_t priority)
319 struct list_head *element; 319 struct list_head *element;
320 struct il_rx_buf *rxb; 320 struct il_rx_buf *rxb;
321 struct page *page; 321 struct page *page;
322 dma_addr_t page_dma;
322 unsigned long flags; 323 unsigned long flags;
323 gfp_t gfp_mask = priority; 324 gfp_t gfp_mask = priority;
324 325
@@ -356,33 +357,35 @@ il4965_rx_allocate(struct il_priv *il, gfp_t priority)
356 return; 357 return;
357 } 358 }
358 359
360 /* Get physical address of the RB */
361 page_dma =
362 pci_map_page(il->pci_dev, page, 0,
363 PAGE_SIZE << il->hw_params.rx_page_order,
364 PCI_DMA_FROMDEVICE);
365 if (unlikely(pci_dma_mapping_error(il->pci_dev, page_dma))) {
366 __free_pages(page, il->hw_params.rx_page_order);
367 break;
368 }
369
359 spin_lock_irqsave(&rxq->lock, flags); 370 spin_lock_irqsave(&rxq->lock, flags);
360 371
361 if (list_empty(&rxq->rx_used)) { 372 if (list_empty(&rxq->rx_used)) {
362 spin_unlock_irqrestore(&rxq->lock, flags); 373 spin_unlock_irqrestore(&rxq->lock, flags);
374 pci_unmap_page(il->pci_dev, page_dma,
375 PAGE_SIZE << il->hw_params.rx_page_order,
376 PCI_DMA_FROMDEVICE);
363 __free_pages(page, il->hw_params.rx_page_order); 377 __free_pages(page, il->hw_params.rx_page_order);
364 return; 378 return;
365 } 379 }
380
366 element = rxq->rx_used.next; 381 element = rxq->rx_used.next;
367 rxb = list_entry(element, struct il_rx_buf, list); 382 rxb = list_entry(element, struct il_rx_buf, list);
368 list_del(element); 383 list_del(element);
369 384
370 spin_unlock_irqrestore(&rxq->lock, flags);
371
372 BUG_ON(rxb->page); 385 BUG_ON(rxb->page);
373 rxb->page = page;
374 /* Get physical address of the RB */
375 rxb->page_dma =
376 pci_map_page(il->pci_dev, page, 0,
377 PAGE_SIZE << il->hw_params.rx_page_order,
378 PCI_DMA_FROMDEVICE);
379 /* dma address must be no more than 36 bits */
380 BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36));
381 /* and also 256 byte aligned! */
382 BUG_ON(rxb->page_dma & DMA_BIT_MASK(8));
383
384 spin_lock_irqsave(&rxq->lock, flags);
385 386
387 rxb->page = page;
388 rxb->page_dma = page_dma;
386 list_add_tail(&rxb->list, &rxq->rx_free); 389 list_add_tail(&rxb->list, &rxq->rx_free);
387 rxq->free_count++; 390 rxq->free_count++;
388 il->alloc_rxb_page++; 391 il->alloc_rxb_page++;
@@ -4292,8 +4295,16 @@ il4965_rx_handle(struct il_priv *il)
4292 pci_map_page(il->pci_dev, rxb->page, 0, 4295 pci_map_page(il->pci_dev, rxb->page, 0,
4293 PAGE_SIZE << il->hw_params. 4296 PAGE_SIZE << il->hw_params.
4294 rx_page_order, PCI_DMA_FROMDEVICE); 4297 rx_page_order, PCI_DMA_FROMDEVICE);
4295 list_add_tail(&rxb->list, &rxq->rx_free); 4298
4296 rxq->free_count++; 4299 if (unlikely(pci_dma_mapping_error(il->pci_dev,
4300 rxb->page_dma))) {
4301 __il_free_pages(il, rxb->page);
4302 rxb->page = NULL;
4303 list_add_tail(&rxb->list, &rxq->rx_used);
4304 } else {
4305 list_add_tail(&rxb->list, &rxq->rx_free);
4306 rxq->free_count++;
4307 }
4297 } else 4308 } else
4298 list_add_tail(&rxb->list, &rxq->rx_used); 4309 list_add_tail(&rxb->list, &rxq->rx_used);
4299 4310