From: Ben Hutchings <bhutchings@solarflare.com>
To: Fugang Duan <B38611@freescale.com>
Cc: <b20596@freescale.com>, <davem@davemloft.net>, <netdev@vger.kernel.org>
Subject: Re: [PATCH] net:fec: fix WARNING caused by lack of calls to dma_mapping_error()
Date: Wed, 13 Nov 2013 01:00:53 +0000 [thread overview]
Message-ID: <1384304453.3802.62.camel@bwh-desktop.uk.level5networks.com> (raw)
In-Reply-To: <1384224889-8316-1-git-send-email-B38611@freescale.com>
On Tue, 2013-11-12 at 10:54 +0800, Fugang Duan wrote:
> Enable CONFIG_HAVE_DMA_API_DEBUG, the kernel dump warning:
[...]
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index b2793b9..d93cb0c 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -386,7 +386,11 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> */
> bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr,
> FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
> -
> + if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr)) {
> + bdp->cbd_bufaddr = 0;
> + netdev_err(ndev, "Tx DMA memory map failed\n");
> + return NETDEV_TX_OK;
This error path must free the skb.
> + }
> /* Send it on its way. Tell FEC it's ready, interrupt when done,
> * it's the last BD of the frame, and to put the CRC on the end.
> */
> @@ -1001,6 +1005,9 @@ fec_enet_rx(struct net_device *ndev, int budget)
>
> bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, data,
> FEC_ENET_TX_FRSIZE, DMA_FROM_DEVICE);
> + /* here dma mapping shouldn't be error, just avoid kernel dump */
> + if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr))
> + netdev_err(ndev, "Rx DMA memory map failed\n");
This is not handling the error.
> rx_processing_done:
> /* Clear the status flags for this buffer */
> status &= ~BD_ENET_RX_STATS;
> @@ -1719,6 +1726,11 @@ static int fec_enet_alloc_buffers(struct net_device *ndev)
>
> bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, skb->data,
> FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE);
> + if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr)) {
> + fec_enet_free_buffers(ndev);
> + netdev_err(ndev, "Rx DMA memory map failed\n");
> + return -ENOMEM;
> + }
> bdp->cbd_sc = BD_ENET_RX_EMPTY;
>
> if (fep->bufdesc_ex) {
Error logging should be rate-limited.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2013-11-13 1:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-12 2:54 [PATCH] net:fec: fix WARNING caused by lack of calls to dma_mapping_error() Fugang Duan
2013-11-13 1:00 ` Ben Hutchings [this message]
2013-11-13 1:43 ` Ben Hutchings
2013-11-13 2:10 ` Fugang Duan
2013-11-13 3:02 ` Ben Hutchings
-- strict thread matches above, loose matches on Subject: below --
2013-11-14 1:30 Fugang Duan
2013-11-14 2:12 ` Ben Hutchings
2013-11-14 2:15 ` Fugang Duan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1384304453.3802.62.camel@bwh-desktop.uk.level5networks.com \
--to=bhutchings@solarflare.com \
--cc=B38611@freescale.com \
--cc=b20596@freescale.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox