[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1401818123.18833.17.camel@joe-AO725>
Date: Tue, 03 Jun 2014 10:55:23 -0700
From: Joe Perches <joe@...ches.com>
To: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
Cc: Shradha Shah <sshah@...arflare.com>,
David Miller <davem@...emloft.net>, netdev@...r.kernel.org,
linux-net-drivers@...arflare.com
Subject: Re: [PATCH net v4 1/2] sfc: use 64-bit writes for PIO.
On Tue, 2014-06-03 at 20:45 +0400, Sergei Shtylyov wrote:
> Hello.
>
> On 06/03/2014 02:04 PM, Shradha Shah wrote:
>
> > From: Jon Cooper <jcooper@...arflare.com>
>
> > Patch to open-code the memory copy routines.
> > 32bit writes over the PCI bus causes data corruption.
>
> > Fixes:ee45fd92c739
> > ("sfc: Use TX PIO for sufficiently small packets")
>
> > Signed-off-by: Shradha Shah <sshah@...arflare.com>
> > ---
> > drivers/net/ethernet/sfc/tx.c | 24 +++++++++++++++++++-----
> > 1 file changed, 19 insertions(+), 5 deletions(-)
>
> > diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c
> > index fa94753..d2c9ca0 100644
> > --- a/drivers/net/ethernet/sfc/tx.c
> > +++ b/drivers/net/ethernet/sfc/tx.c
> > @@ -189,6 +189,20 @@ struct efx_short_copy_buffer {
> > u8 buf[L1_CACHE_BYTES];
> > };
> >
> > +/* Copy in explicit 64-bit writes. */
> > +static void efx_memcpy_64(void __iomem *dest, void *src, size_t len)
> > +{
> > + u64 *src64 = src, __iomem *dest64 = dest;
> > + size_t i, l64 = len / 8;
> > +
> > + WARN_ON_ONCE(len % 8 != 0);
> > + WARN_ON_ONCE(((u8 __iomem *)dest - (u8 __iomem *)0) % 8 != 0);
> > + BUILD_BUG_ON(sizeof(uint64_t) != 8);
> > +
> > + for (i = 0; i < l64; ++i)
> > + writeq(src64[i], dest64+i);
>
> Could you please surround + by spaces for consistency?
>
> > +}
> > +
The BUILD_BUG_ON seems unnecessary.
The separate WARN_ON_ONCEs could be combined.
The subtraction of 0 just seems odd.
Would this be clearer as:
static void efx_memcpy_64(void __iomem *dest, void *src, size_t len)
{
u64 *src64 = src,
u64 __iomem *dest64 = dest;
size_t l64 = len / 8;
size_t i;
WARN_ON_ONCE(len % 8 || dest64 % 8);
for (i = 0; i < l64; i++)
writeq(src64[i], &dest64[i]);
}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists