From: Russell King - ARM Linux <linux@armlinux.org.uk>
To: YueHaibing <yuehaibing@huawei.com>
Cc: davem@davemloft.net, nbd@openwrt.org, john@phrozen.org,
sean.wang@mediatek.com, nelson.chang@mediatek.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] net: mediatek: use dma_zalloc_coherent instead of allocator/memset
Date: Thu, 19 Jul 2018 15:17:23 +0100 [thread overview]
Message-ID: <20180719141723.GM17271@n2100.armlinux.org.uk> (raw)
In-Reply-To: <20180719140955.19444-1-yuehaibing@huawei.com>
On Thu, Jul 19, 2018 at 10:09:55PM +0800, YueHaibing wrote:
> Use dma_zalloc_coherent instead of dma_alloc_coherent
> followed by memset 0.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index d8ebf0a..fbdb3e3 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -1221,14 +1221,11 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
> if (!ring->buf)
> goto no_tx_mem;
>
> - ring->dma = dma_alloc_coherent(eth->dev,
> - MTK_DMA_SIZE * sz,
> - &ring->phys,
> - GFP_ATOMIC | __GFP_ZERO);
> + ring->dma = dma_zalloc_coherent(eth->dev, MTK_DMA_SIZE * sz,
> + &ring->phys, GFP_ATOMIC | __GFP_ZERO);
> if (!ring->dma)
> goto no_tx_mem;
>
> - memset(ring->dma, 0, MTK_DMA_SIZE * sz);
I have to wonder whether this code needs two forms of zeroing... in
the original code, __GFP_ZERO _and_ a call to memset() just in case
__GFP_ZERO failed to do its job, and in the replacement code, just
in case dma_zalloc_coherent() hasn't got the idea...
I think you can drop the __GFP_ZERO. ;)
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 13.8Mbps down 630kbps up
According to speedtest.net: 13Mbps down 490kbps up
prev parent reply other threads:[~2018-07-19 14:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-19 14:09 YueHaibing
2018-07-19 14:17 ` Russell King - ARM Linux [this message]
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=20180719141723.GM17271@n2100.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=davem@davemloft.net \
--cc=john@phrozen.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=nbd@openwrt.org \
--cc=nelson.chang@mediatek.com \
--cc=netdev@vger.kernel.org \
--cc=sean.wang@mediatek.com \
--cc=yuehaibing@huawei.com \
/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
all inboxes | Powered by JetHome®