From patchwork Tue Jun 18 17:33:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 252397 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E81A22C0089 for ; Wed, 19 Jun 2013 04:02:02 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933234Ab3FRSB7 (ORCPT ); Tue, 18 Jun 2013 14:01:59 -0400 Received: from shell.v3.sk ([195.168.3.45]:47699 "EHLO norkia.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933157Ab3FRSB5 (ORCPT ); Tue, 18 Jun 2013 14:01:57 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by norkia.v3.sk (Postfix) with ESMTP id 822AE12A0E9; Tue, 18 Jun 2013 19:33:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at v3.sk Received: from norkia.v3.sk ([127.0.0.1]) by localhost (norkia.v3.sk [127.0.0.1]) (amavisd-new, port 10024) with SMTP id z2eIHN-vKbCe; Tue, 18 Jun 2013 19:33:34 +0200 (CEST) Received: from localhost.localdomain (gw-brno.gooddata.com [194.213.40.134]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: lkundrak@v3.sk) by norkia.v3.sk (Postfix) with ESMTP id 6844B12A0E5; Tue, 18 Jun 2013 19:33:34 +0200 (CEST) From: Lubomir Rintel To: Lennert Buytenhek Cc: Lubomir Rintel , Lennert Buytenhek , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mv643xx_eth: Fix a DMA-API error handling warning Date: Tue, 18 Jun 2013 19:33:28 +0200 Message-Id: <1371576808-21907-1-git-send-email-lkundrak@v3.sk> X-Mailer: git-send-email 1.7.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We check the failure status just prior to unmap, since it would be too much of a hassle to roll back commands we already started to enqueue if we handled it just after the map. This way we at least avoid a lockup on reclaim, the card presumably didn't succeed DMA-ing to a bogus address anyway. ------------[ cut here ]------------ WARNING: at lib/dma-debug.c:933 check_unmap+0x75c/0x840() mv643xx_eth_port mv643xx_eth_port.0: DMA-API: device driver failed to check map error[device address=0x000000001cc3f1c2] [size=90 bytes] [mapped as single] Modules linked in: bnep bluetooth rfkill marvell mv643xx_eth mv_cesa leds_gpio uinput mmc_block sata_mv mvsdio mmc_core usb_storage [] (unwind_backtrace+0x0/0x124) from [] (warn_slowpath_common+0x54/0x6c) [] (warn_slowpath_common+0x54/0x6c) from [] (warn_slowpath_fmt+0x34/0x44) [] (warn_slowpath_fmt+0x34/0x44) from [] (check_unmap+0x75c/0x840) [] (check_unmap+0x75c/0x840) from [] (debug_dma_unmap_page+0x64/0x70) [] (debug_dma_unmap_page+0x64/0x70) from [] (txq_reclaim+0x218/0x264 [mv643xx_eth]) [] (txq_reclaim+0x218/0x264 [mv643xx_eth]) from [] (mv643xx_eth_poll+0x2a8/0x6b8 [mv643xx_eth]) [] (mv643xx_eth_poll+0x2a8/0x6b8 [mv643xx_eth]) from [] (net_rx_action+0x9c/0x338) [] (net_rx_action+0x9c/0x338) from [] (__do_softirq+0x16c/0x398) [] (__do_softirq+0x16c/0x398) from [] (irq_exit+0x5c/0xc0) [] (irq_exit+0x5c/0xc0) from [] (handle_IRQ+0x6c/0x8c) [] (handle_IRQ+0x6c/0x8c) from [] (__irq_svc+0x38/0x80) [] (__irq_svc+0x38/0x80) from [] (memcpy+0x24/0x3a4) ---[ end trace 0c94555a37c67b61 ]--- Mapped at: [] debug_dma_map_page+0x48/0x11c [] mv643xx_eth_xmit+0x41c/0x5a8 [mv643xx_eth] [] dev_hard_start_xmit+0x308/0x6cc [] sch_direct_xmit+0x74/0x2d4 [] dev_queue_xmit+0x4b8/0x8dc Signed-off-by: Lubomir Rintel Cc: Lennert Buytenhek Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/net/ethernet/marvell/mv643xx_eth.c | 26 +++++++++++++++++++------- 1 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index d1cbfb1..7e14c83 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -519,8 +519,13 @@ static int rxq_process(struct rx_queue *rxq, int budget) if (rxq->rx_curr_desc == rxq->rx_ring_size) rxq->rx_curr_desc = 0; - dma_unmap_single(mp->dev->dev.parent, rx_desc->buf_ptr, - rx_desc->buf_size, DMA_FROM_DEVICE); + if (dma_mapping_error(mp->dev->dev.parent, rx_desc->buf_ptr)) { + dev_err(mp->dev->dev.parent, + "Receive buffer could not be mapped, skipping unmap.\n"); + } else { + dma_unmap_single(mp->dev->dev.parent, rx_desc->buf_ptr, + rx_desc->buf_size, DMA_FROM_DEVICE); + } rxq->rx_desc_count--; rx++; @@ -902,12 +907,19 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force) mp->dev->stats.tx_errors++; } - if (cmd_sts & TX_FIRST_DESC) { - dma_unmap_single(mp->dev->dev.parent, desc->buf_ptr, - desc->byte_cnt, DMA_TO_DEVICE); + if (dma_mapping_error(mp->dev->dev.parent, desc->buf_ptr)) { + dev_err(mp->dev->dev.parent, + "Transmit buffer could not be mapped, skipping unmap.\n"); } else { - dma_unmap_page(mp->dev->dev.parent, desc->buf_ptr, - desc->byte_cnt, DMA_TO_DEVICE); + if (cmd_sts & TX_FIRST_DESC) { + dma_unmap_single(mp->dev->dev.parent, + desc->buf_ptr, desc->byte_cnt, + DMA_TO_DEVICE); + } else { + dma_unmap_page(mp->dev->dev.parent, + desc->buf_ptr, desc->byte_cnt, + DMA_TO_DEVICE); + } } dev_kfree_skb(skb);