From: Lino Sanfilippo <LinoSanfilippo@gmx.de>
To: Pavel Belous <Pavel.Belous@aquantia.com>,
"David S . Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org,
Simon Edelhaus <Simon.Edelhaus@aquantia.com>,
Alexey Andriyanov <Alexey.Andriyanov@aquantia.com>
Subject: Re: [PATCH net-next 10/13] net: ethernet: aquantia: Checking for success dma_map_single.
Date: Wed, 15 Feb 2017 22:23:24 +0100 [thread overview]
Message-ID: <60f99adb-f29f-1527-0a0a-406c39c99d0f@gmx.de> (raw)
In-Reply-To: <6ad9fef330a2c9b59139621efbb7c77e746d9f25.1487187192.git.pavel.belous@aquantia.com>
On 15.02.2017 21:01, Pavel Belous wrote:
> From: Pavel Belous <pavel.belous@aquantia.com>
>
> Dma mapping can fail. We should check the result.
>
> Signed-off-by: Pavel Belous <pavel.belous@aquantia.com>
> ---
> drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
> index daed4c1..7000b9f 100644
> --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
> +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
> @@ -476,11 +476,15 @@ static unsigned int aq_nic_map_skb_frag(struct aq_nic_s *self,
> unsigned int ret = 0U;
> unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
> unsigned int frag_count = 0U;
> + struct device *dev = aq_nic_get_dev(self);
>
> dx->flags = 0U;
> dx->len = skb_headlen(skb);
> - dx->pa = dma_map_single(aq_nic_get_dev(self), skb->data, dx->len,
> - DMA_TO_DEVICE);
> + dx->pa = dma_map_single(dev, skb->data, dx->len, DMA_TO_DEVICE);
> +
> + if (unlikely(dma_mapping_error(dev, dx->pa)))
> + goto err_exit;
> +
> dx->len_pkt = skb->len;
> dx->is_sop = 1U;
> dx->is_mapped = 1U;
> @@ -502,8 +506,10 @@ static unsigned int aq_nic_map_skb_frag(struct aq_nic_s *self,
>
> frag_len = skb_frag_size(frag);
>
> - frag_pa = skb_frag_dma_map(aq_nic_get_dev(self), frag, 0,
> + frag_pa = skb_frag_dma_map(dev, frag, 0,
> frag_len, DMA_TO_DEVICE);
> + if (unlikely(dma_mapping_error(dev, frag_pa)))
> + goto err_exit;
In case of this error you have to undo all mappings that you have
done so far (i.e the complete frag list and the head buffer).
> while (frag_len > AQ_CFG_TX_FRAME_MAX) {
> ++dx;
> @@ -529,6 +535,7 @@ static unsigned int aq_nic_map_skb_frag(struct aq_nic_s *self,
> dx->is_eop = 1U;
> dx->skb = skb;
>
> +err_exit:
> return ret;
> }
>
>
Regards,
Lino
next prev parent reply other threads:[~2017-02-15 21:23 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-15 20:01 [PATCH net-next 00/13] net: ethernet: aquantia: improvements and fixes Pavel Belous
2017-02-15 20:01 ` [PATCH net-next 01/13] net: ethernet: aquantia: Removed extra assignment for skb->dev Pavel Belous
2017-02-15 20:53 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 02/13] net: ethernet: aquantia: Removed busy_count field Pavel Belous
2017-02-15 20:56 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 03/13] net: ethernet: aquantia: Removed unnecessary comparsion "old_mtu == new_mtu" Pavel Belous
2017-02-15 20:56 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 04/13] net: ethernet: aquantia: Using module_pci_driver Pavel Belous
2017-02-15 20:57 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 05/13] net: ethernet: aquantia: Superfluous initialization of "err" Pavel Belous
2017-02-15 21:01 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 06/13] net: ethernet: aquantia: Fixed missing rtnl_unlock Pavel Belous
2017-02-15 21:02 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 07/13] net: ethernet: aquantia: Using NETDEV_TX_OK instead 0 Pavel Belous
2017-02-15 21:02 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 08/13] net: ethernet: aquantia: Null pointer check for aq_nic_ndev_alloc Pavel Belous
2017-02-15 21:04 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 09/13] net: ethernet: aquantia: Call netdev_register after all initialized Pavel Belous
2017-02-15 21:18 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 10/13] net: ethernet: aquantia: Checking for success dma_map_single Pavel Belous
2017-02-15 21:23 ` Lino Sanfilippo [this message]
2017-02-15 21:40 ` Lino Sanfilippo
2017-02-15 21:47 ` Pavel Belous
2017-02-15 20:01 ` [PATCH net-next 11/13] net: ethernet: aquantia: Refactoring buffers copying Pavel Belous
2017-02-15 21:31 ` Lino Sanfilippo
2017-02-15 21:50 ` Pavel Belous
2017-02-16 13:10 ` David Laight
2017-02-16 16:02 ` Lino Sanfilippo
2017-02-16 16:37 ` David Laight
2017-02-19 10:36 ` Lino Sanfilippo
2017-02-15 20:01 ` [PATCH net-next 12/13] net: ethernet: aquantia: Fixed incorrect buff->len calculation Pavel Belous
2017-02-15 20:01 ` [PATCH net-next 13/13] net: ethernet: aquantia: Fixed memory allocation if AQ_CFG_RX_FRAME_MAX > 1 page Pavel Belous
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=60f99adb-f29f-1527-0a0a-406c39c99d0f@gmx.de \
--to=linosanfilippo@gmx.de \
--cc=Alexey.Andriyanov@aquantia.com \
--cc=Pavel.Belous@aquantia.com \
--cc=Simon.Edelhaus@aquantia.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;
as well as URLs for NNTP newsgroup(s).