All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sunil Kovvuri <sunil.kovvuri@gmail.com>
To: Kevin Hao <haokexin@gmail.com>
Cc: David Laight <David.Laight@aculab.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Subbaraya Sundeep <sbhatta@marvell.com>,
	Sunil Goutham <sgoutham@marvell.com>,
	Geetha sowjanya <gakula@marvell.com>,
	hariprasad <hkelam@marvell.com>
Subject: Re: [PATCH] net: octeontx2: Make sure the buffer is 128 byte aligned
Date: Thu, 21 Jan 2021 18:12:39 +0530	[thread overview]
Message-ID: <CA+sq2CeOUWvmrQ36JkO9VHvkWOf=ONYzitXRp+ZHE+U1JbU4Lg@mail.gmail.com> (raw)
In-Reply-To: <20210121115141.GA472545@pek-khao-d2.corp.ad.wrs.com>

On Thu, Jan 21, 2021 at 5:26 PM Kevin Hao <haokexin@gmail.com> wrote:
>
> On Thu, Jan 21, 2021 at 09:53:08AM +0000, David Laight wrote:
> > From: Kevin Hao
> > > Sent: 21 January 2021 07:09
> > >
> > > The octeontx2 hardware needs the buffer to be 128 byte aligned.
> > > But in the current implementation of napi_alloc_frag(), it can't
> > > guarantee the return address is 128 byte aligned even the request size
> > > is a multiple of 128 bytes, so we have to request an extra 128 bytes and
> > > use the PTR_ALIGN() to make sure that the buffer is aligned correctly.
> > >
> > > Fixes: 7a36e4918e30 ("octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers")
> > > Reported-by: Subbaraya Sundeep <sbhatta@marvell.com>
> > > Signed-off-by: Kevin Hao <haokexin@gmail.com>
> > > ---
> > >  drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > > b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > > index bdfa2e293531..5ddedc3b754d 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > > @@ -488,10 +488,11 @@ dma_addr_t __otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool)
> > >     dma_addr_t iova;
> > >     u8 *buf;
> > >
> > > -   buf = napi_alloc_frag(pool->rbsize);
> > > +   buf = napi_alloc_frag(pool->rbsize + OTX2_ALIGN);
> > >     if (unlikely(!buf))
> > >             return -ENOMEM;
> > >
> > > +   buf = PTR_ALIGN(buf, OTX2_ALIGN);
> > >     iova = dma_map_single_attrs(pfvf->dev, buf, pool->rbsize,
> > >                                 DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);
> > >     if (unlikely(dma_mapping_error(pfvf->dev, iova))) {
> > > --
> > > 2.29.2
> >
> > Doesn't that break the 'free' code ?
> > Surely it needs the original pointer.
>
> Why do we care about the original pointer? The free code should work with
> the mangling poiner. Did I miss something?
>
> >

I too agree, put_page(buf) or put_page(buf + OTX2_ALIGN) is same.

  reply	other threads:[~2021-01-21 12:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21  7:09 [PATCH] net: octeontx2: Make sure the buffer is 128 byte aligned Kevin Hao
2021-01-21  9:01 ` sundeep subbaraya
2021-01-21  9:53 ` David Laight
2021-01-21 11:51   ` Kevin Hao
2021-01-21 12:42     ` Sunil Kovvuri [this message]
2021-01-23  2:10 ` patchwork-bot+netdevbpf

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='CA+sq2CeOUWvmrQ36JkO9VHvkWOf=ONYzitXRp+ZHE+U1JbU4Lg@mail.gmail.com' \
    --to=sunil.kovvuri@gmail.com \
    --cc=David.Laight@aculab.com \
    --cc=davem@davemloft.net \
    --cc=gakula@marvell.com \
    --cc=haokexin@gmail.com \
    --cc=hkelam@marvell.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.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 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.