From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: David Miller <davem@davemloft.net>, mitsuhiro.kimura.kc@renesas.com
Cc: netdev@vger.kernel.org
Subject: Re: errors in alignment changes..
Date: Thu, 11 Dec 2014 01:08:07 +0300 [thread overview]
Message-ID: <5488C447.5080906@cogentembedded.com> (raw)
In-Reply-To: <20141210.155203.1136471667049608187.davem@davemloft.net>
On 12/10/2014 11:52 PM, David Miller wrote:
> I just re-reviewed this change:
> commit 4d6a949c62f123569fb355b6ec7f314b76f93735
> Author: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
> Date: Thu Nov 27 20:34:00 2014 +0900
> sh_eth: Fix skb alloc size and alignment adjust rule.
> and it has serious problems. Well, actually the code has
> always been broken in this area.
>
> + /* The size of the buffer is a multiple of 16 bytes. */
> + rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16);
> + dma_map_single(&ndev->dev, skb->data, rxdesc->buffer_length,
> + DMA_FROM_DEVICE);
> rxdesc->addr = virt_to_phys(PTR_ALIGN(skb->data, 4));
> rxdesc->status = cpu_to_edmac(mdp, RD_RACT | RD_RFP);
> It doesn't make any sense to call dma_map_single() if you aren't
> even going to use the return value. The DMA mapping created is
> the whole point of calling this function.
Note that this call is just moved from above, not added by this patch.
> And then later we pass:
> dma_sync_single_for_cpu(&ndev->dev, rxdesc->addr,
> - mdp->rx_buf_sz,
> + ALIGN(mdp->rx_buf_sz, 16),
> DMA_FROM_DEVICE);
> rxdesc->addr as the "DMA address", but that must be the return value
> from dma_map_single() not what you've actually stored there which is
> virt_to_phys() run on the skb->data.
> This code must be fixed to:
> 1) Put the return value from dma_map_single() into a local variable,
I have already requested such change in reply to the patch fixing several
DMA errors at once.
> and check for mapping errors.
This was done by that patch IIRC. It just needs to be properly split and
resubmitted.
> 2) On success put that return value into rxdesc->addr
I guess we can just do:
rxdesc->addr = dma_map_single(...);
WBR, Sergei
next prev parent reply other threads:[~2014-12-10 22:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 20:52 errors in alignment changes David Miller
2014-12-10 22:08 ` Sergei Shtylyov [this message]
2014-12-11 1:42 ` David Miller
2014-12-12 4:30 ` Simon Horman
2014-12-12 12:00 ` Sergei Shtylyov
2014-12-16 5:33 ` Simon Horman
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=5488C447.5080906@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=davem@davemloft.net \
--cc=mitsuhiro.kimura.kc@renesas.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.