Commit bebe933d authored by Geoff Levand's avatar Geoff Levand Committed by David S. Miller

net/ps3_gelic_net: Use dma_mapping_error

The current Gelic Etherenet driver was checking the return value of its
dma_map_single call, and not using the dma_mapping_error() routine.

Fixes runtime problems like these:

  DMA-API: ps3_gelic_driver sb_05: device driver failed to check map error
  WARNING: CPU: 0 PID: 0 at kernel/dma/debug.c:1027 .check_unmap+0x888/0x8dc

Fixes: 02c18891 ("ps3: gigabit ethernet driver for PS3, take3")
Reviewed-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
Signed-off-by: default avatarGeoff Levand <geoff@infradead.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 19b3bb51
...@@ -317,15 +317,17 @@ static int gelic_card_init_chain(struct gelic_card *card, ...@@ -317,15 +317,17 @@ static int gelic_card_init_chain(struct gelic_card *card,
/* set up the hardware pointers in each descriptor */ /* set up the hardware pointers in each descriptor */
for (i = 0; i < no; i++, descr++) { for (i = 0; i < no; i++, descr++) {
dma_addr_t cpu_addr;
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE); gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
descr->bus_addr =
dma_map_single(ctodev(card), descr,
GELIC_DESCR_SIZE,
DMA_BIDIRECTIONAL);
if (!descr->bus_addr) cpu_addr = dma_map_single(ctodev(card), descr,
GELIC_DESCR_SIZE, DMA_BIDIRECTIONAL);
if (dma_mapping_error(ctodev(card), cpu_addr))
goto iommu_error; goto iommu_error;
descr->bus_addr = cpu_to_be32(cpu_addr);
descr->next = descr + 1; descr->next = descr + 1;
descr->prev = descr - 1; descr->prev = descr - 1;
} }
...@@ -375,6 +377,7 @@ static int gelic_descr_prepare_rx(struct gelic_card *card, ...@@ -375,6 +377,7 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
static const unsigned int rx_skb_size = static const unsigned int rx_skb_size =
ALIGN(GELIC_NET_MAX_FRAME, GELIC_NET_RXBUF_ALIGN) + ALIGN(GELIC_NET_MAX_FRAME, GELIC_NET_RXBUF_ALIGN) +
GELIC_NET_RXBUF_ALIGN - 1; GELIC_NET_RXBUF_ALIGN - 1;
dma_addr_t cpu_addr;
int offset; int offset;
if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE) if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE)
...@@ -396,11 +399,10 @@ static int gelic_descr_prepare_rx(struct gelic_card *card, ...@@ -396,11 +399,10 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
if (offset) if (offset)
skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset); skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset);
/* io-mmu-map the skb */ /* io-mmu-map the skb */
descr->buf_addr = cpu_to_be32(dma_map_single(ctodev(card), cpu_addr = dma_map_single(ctodev(card), descr->skb->data,
descr->skb->data, GELIC_NET_MAX_FRAME, DMA_FROM_DEVICE);
GELIC_NET_MAX_FRAME, descr->buf_addr = cpu_to_be32(cpu_addr);
DMA_FROM_DEVICE)); if (dma_mapping_error(ctodev(card), cpu_addr)) {
if (!descr->buf_addr) {
dev_kfree_skb_any(descr->skb); dev_kfree_skb_any(descr->skb);
descr->skb = NULL; descr->skb = NULL;
dev_info(ctodev(card), dev_info(ctodev(card),
...@@ -780,7 +782,7 @@ static int gelic_descr_prepare_tx(struct gelic_card *card, ...@@ -780,7 +782,7 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
buf = dma_map_single(ctodev(card), skb->data, skb->len, DMA_TO_DEVICE); buf = dma_map_single(ctodev(card), skb->data, skb->len, DMA_TO_DEVICE);
if (!buf) { if (dma_mapping_error(ctodev(card), buf)) {
dev_err(ctodev(card), dev_err(ctodev(card),
"dma map 2 failed (%p, %i). Dropping packet\n", "dma map 2 failed (%p, %i). Dropping packet\n",
skb->data, skb->len); skb->data, skb->len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment