net: emaclite: Fixes, enable driver for other archs
Subsystems (2)
These patches solve a few issues with the driver observed on a RISC-V platform.
PATCH 1/3 net: emaclite: fix broken build
Function ioremap_nocache seems to be defined only for mips and microblaze architectures. Therefore, the function call in the emaclite driver causes this driver to be unusable with other architectures, for example riscv.
--- drivers/net/xilinx_emaclite.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/xilinx_emaclite.c +4 -0
@@ -615,8 +615,12 @@ static int emaclite_of_to_plat(struct udevice *dev)int offset =0 ; pdata->iobase =dev_read_addr (dev); +#if defined(CONFIG_MICROBLAZE ) || defined(CONFIG_MIPS ) emaclite->regs = (struct emaclite_regs *)ioremap_nocache (pdata->iobase,0x10000 ); +#else + emaclite->regs = (struct emaclite_regs *)pdata->iobase; +#endif emaclite->phyaddr =-1 ;
Signature · 1 line
2.31.1
Re: [PATCH 1/3] net: emaclite: fix broken build
Quoted 28 lines · Samuel Obuch
Function
ioremap_nocacheseems to be defined only for mips and microblaze architectures. Therefore, the function call in the emaclite driver causes this driver to be unusable with other architectures, for example riscv.Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/net/xilinx_emaclite.c +4
-1@@ -615,8 +615,12 @@ static int emaclite_of_to_plat(struct udevice *dev)int offset =0 ; pdata->iobase =dev_read_addr (dev); +#if defined(CONFIG_MICROBLAZE ) || defined(CONFIG_MIPS ) emaclite->regs = (struct emaclite_regs *)ioremap_nocache (pdata->iobase,0x10000 ); +#else + emaclite->regs = (struct emaclite_regs *)pdata->iobase; +#endif emaclite->phyaddr =-1 ; --
Quoted 2 lines
2.31.1
Hm...
Well, this isn't right,The right solution is to replace ioremap_nocache() with ioremap().
This way it will work both for MIPS and other architectures. I can do it myself, you can fix your patch. let me know. Thanks,
Ramon.
Michal Simek
maintainerRe: [PATCH 1/3] net: emaclite: fix broken build
Quoted 28 lines · Ramon Fried
Quoted 27 lines · Samuel Obuch
Function
ioremap_nocacheseems to be defined only for mips and microblaze architectures. Therefore, the function call in the emaclite driver causes this driver to be unusable with other architectures, for example riscv.Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/net/xilinx_emaclite.c +4
-0@@ -615,8 +615,12 @@ static int emaclite_of_to_plat(struct udevice *dev)int offset =0 ; pdata->iobase =dev_read_addr (dev); +#if defined(CONFIG_MICROBLAZE ) || defined(CONFIG_MIPS ) emaclite->regs = (struct emaclite_regs *)ioremap_nocache (pdata->iobase,0x10000 ); +#else + emaclite->regs = (struct emaclite_regs *)pdata->iobase; +#endif emaclite->phyaddr =-1 ;
Quoted 8 lines
Quoted 3 lines
--
2.31.1Hm...
Well, this isn't right,The right solution is to replaceioremap_nocache()withioremap().
This way it will work both for MIPS and other architectures. I can do it myself, you can fix your patch. let me know.
Microblaze doesn't define it now. But I agree that using ioremap which has implicit nocache is the right way to go. It means please create the first patch which creates ioremap for microblaze,
Then second to replace ioremap_nocache() in emaclite driver to ioremap. And third to remove ioremap_nocache from microblaze io.h.
Thanks,
Michal
Michal Simek
maintainerRe: [PATCH 1/3] net: emaclite: fix broken build
Hi,
Quoted 40 lines · Michal Simek
Quoted 28 lines · Ramon Fried
Quoted 27 lines · Samuel Obuch
Function
ioremap_nocacheseems to be defined only for mips and microblaze architectures. Therefore, the function call in the emaclite driver causes this driver to be unusable with other architectures, for example riscv.Signed-off-by Samuel Obuch <[email protected]>---
drivers/net/xilinx_emaclite.c| 4 ++++1 file changed, 4 insertions(+)drivers/net/xilinx_emaclite.c +4
-0@@ -615,8 +615,12 @@ static int emaclite_of_to_plat(struct udevice *dev) int offset = 0; pdata->iobase = dev_read_addr(dev); +#if defined(CONFIG_MICROBLAZE ) || defined(CONFIG_MIPS ) emaclite->regs = (struct emaclite_regs *)ioremap_nocache(pdata->iobase, 0x10000); +#else + emaclite->regs = (struct emaclite_regs *)pdata->iobase; +#endif emaclite->phyaddr = -1;Quoted 8 lines
Quoted 3 lines
Signature · 1 line
2.31.1Hm...
Well, this isn't right,The right solution is to replaceioremap_nocache()withioremap().
This way it will work both for MIPS and other architectures. I can do it myself, you can fix your patch. let me know.
Quoted 3 lines
Microblaze doesn't define it now. But I agree that using ioremap which has implicit nocache is the right way to go. It means please create the first patch which creates ioremap for microblaze,
Then second to replaceioremap_nocache()in emaclite driver to ioremap. And third to removeioremap_nocachefrom microblazeio.h.
I did closer look when I looked at other patches. You should switch to linux/io.h which automatically create ioremap if not defined by architecture.
And ioremap_nocache for microblaze can be removed later.
drivers/net/xilinx_emaclite.c +1 -1
@@ -21,7 +21,7 @@#include <linux/delay.h> #include <linux/errno.h> #include <linux/kernel.h> -#include <asm/io.h> +#include <linux/io.h>
M
Re: [PATCH 1/3] net: emaclite: fix broken build
Hi, using linux/io.h and ioremap works well for us, thanks. I will update the patch.
S
Quoted 78 lines · Michal Simek
Hi,
Quoted 4 lines · Michal Simek
Quoted 1 line · Ramon Fried
On Wed, Jul 13, 2022 at 5:02 PM Samuel Obuch <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Function
ioremap_nocacheseems to be defined only for mips andmicroblaze
Quoted 1 line
Quoted 1 line
Quoted 1 line
architectures. Therefore, the function call in the emaclite driver
causes
Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
this driver to be unusable with other architectures, for example riscv.
Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 4 ++++ 1 file changed, 4 insertions(+)(quoted diff) +0
-0
b/drivers/net/xilinx_emaclite.cQuoted 4 lines
Quoted 4 lines
drivers/net/xilinx_emaclite.c static int emaclite_of_to_plat(struct udevice
Quoted 4 lines
index
6c9f1f7c27..5cd88e04fe100644drivers/net/xilinx_emaclite.c +0
-0@@ -615,8 +615,12 @@ static int emaclite_of_to_plat(struct udevice*dev)
Quoted 5 lines
Quoted 5 lines
drivers/net/xilinx_emaclite.c static int emaclite_of_to_plat(struct udevice · line 619
Quoted 5 lines
drivers/net/xilinx_emaclite.c +1
-0int offset =0 ; pdata->iobase =dev_read_addr (dev); +#if defined(CONFIG_MICROBLAZE ) || defined(CONFIG_MIPS ) emaclite->regs = (struct emaclite_regs*)ioremap_nocache(pdata->iobase,
Quoted 1 line
Quoted 1 line
Quoted 1 line
0x10000);Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/xilinx_emaclite.c +3
-0+#else + emaclite->regs = (struct emaclite_regs *)pdata->iobase; +#endif emaclite->phyaddr =-1 ;Quoted 8 lines
Quoted 3 lines
--
2.31.1Hm...
Well, this isn't right,The right solution is to replaceioremap_nocache()withioremap().
This way it will work both for MIPS and other architectures. I can do it myself, you can fix your patch. let me know.Quoted 1 line
Microblaze doesn't define it now. But I agree that using ioremap which
has
Quoted 2 lines
implicit nocache is the right way to go.
It means please create the first patch which creates ioremap formicroblaze,
Quoted 1 line
Then second to replace
ioremap_nocache()in emaclite driver to ioremap.And
Quoted 1 line
third to remove
ioremap_nocachefrom microblazeio.h.I did closer look when I looked at other patches. You should switch to
linux/io.hwhich automatically create ioremap if not defined by architecture.And
ioremap_nocachefor microblaze can be removed later.drivers/net/xilinx_emaclite.c +1
-1@@ -21,7 +21,7 @@#include <linux/delay.h> #include <linux/errno.h> #include <linux/kernel.h> -#include <asm/io.h> +#include <linux/io.h> M
PATCH 2/3 net: emaclite: fix xemaclite_alignedread/write functions
In reply to Samuel ObuchUse __raw_read* and __raw_write* functions to ensure read/write is passed to the memory-mapped regions, as non-volatile accesses may get optimised out.
--- drivers/net/xilinx_emaclite.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/xilinx_emaclite.c +4 -5
@@ -113,12 +113,12 @@ static void xemaclite_alignedread(u32 *srcptr, void *destptr, u32 bytecount)/* Word aligned buffer, no correction needed. */ to32ptr = (u32 *) destptr;while (bytecount >3 ) { - *to32ptr++ = *from32ptr++; + *to32ptr++ =__raw_readl (from32ptr++); bytecount -=4 ; } to8ptr = (u8 *) to32ptr; - alignbuffer = *from32ptr++; + alignbuffer =__raw_readl (from32ptr++); from8ptr = (u8 *) &alignbuffer;for (i =0 ; i < bytecount; i++)
@@ -136,8 +136,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount) from32ptr = (u32 *) srcptr;while (bytecount >3 ) { - - *to32ptr++ = *from32ptr++; +__raw_writel (*from32ptr++, to32ptr++); bytecount -=4 ; }
@@ -148,7 +147,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount)for (i =0 ; i < bytecount; i++) *to8ptr++ = *from8ptr++; - *to32ptr++ = alignbuffer; +__raw_writel (alignbuffer, to32ptr++); } static int wait_for_bit(const char *func, u32 *reg, const u32 mask,
Signature · 1 line
2.31.1
Re: [PATCH 2/3] net: emaclite: fix xemaclite_alignedread/write functions
Quoted 49 lines · Samuel Obuch
Use __raw_read* and __raw_write* functions to ensure read/write is passed to the memory-mapped regions, as non-volatile accesses may get optimised out.
Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/net/xilinx_emaclite.c +4
-6@@ -113,12 +113,12 @@ static void xemaclite_alignedread(u32 *srcptr, void *destptr, u32 bytecount)/* Word aligned buffer, no correction needed. */ to32ptr = (u32 *) destptr;while (bytecount >3 ) { - *to32ptr++ = *from32ptr++; + *to32ptr++ =__raw_readl (from32ptr++); bytecount -=4 ; } to8ptr = (u8 *) to32ptr; - alignbuffer = *from32ptr++; + alignbuffer =__raw_readl (from32ptr++); from8ptr = (u8 *) &alignbuffer;for (i =0 ; i < bytecount; i++)@@ -136,8 +136,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount) from32ptr = (u32 *) srcptr;while (bytecount >3 ) { - - *to32ptr++ = *from32ptr++; +__raw_writel (*from32ptr++, to32ptr++); bytecount -=4 ; }@@ -148,7 +147,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount)for (i =0 ; i < bytecount; i++) *to8ptr++ = *from8ptr++; - *to32ptr++ = alignbuffer; +__raw_writel (alignbuffer, to32ptr++); } static int wait_for_bit(const char *func, u32 *reg, const u32 mask, --
Quoted 2 lines
2.31.1
I think that using readl/writel is fine, no need for raw_...
Michal Simek
maintainerRe: [PATCH 2/3] net: emaclite: fix xemaclite_alignedread/write functions
Quoted 48 lines · Ramon Fried
Quoted 47 lines · Samuel Obuch
Use __raw_read* and __raw_write* functions to ensure read/write is passed to the memory-mapped regions, as non-volatile accesses may get optimised out.
Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/net/xilinx_emaclite.c +4
-5@@ -113,12 +113,12 @@ static void xemaclite_alignedread(u32 *srcptr, void *destptr, u32 bytecount)/* Word aligned buffer, no correction needed. */ to32ptr = (u32 *) destptr;while (bytecount >3 ) { - *to32ptr++ = *from32ptr++; + *to32ptr++ =__raw_readl (from32ptr++); bytecount -=4 ; } to8ptr = (u8 *) to32ptr; - alignbuffer = *from32ptr++; + alignbuffer =__raw_readl (from32ptr++); from8ptr = (u8 *) &alignbuffer;for (i =0 ; i < bytecount; i++)@@ -136,8 +136,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount) from32ptr = (u32 *) srcptr;while (bytecount >3 ) { - - *to32ptr++ = *from32ptr++; +__raw_writel (*from32ptr++, to32ptr++); bytecount -=4 ; }@@ -148,7 +147,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount)for (i =0 ; i < bytecount; i++) *to8ptr++ = *from8ptr++; - *to32ptr++ = alignbuffer; +__raw_writel (alignbuffer, to32ptr++); }
Quoted 5 lines
Quoted 4 lines
drivers/net/xilinx_emaclite.c +0
-1static int wait_for_bit(const char *func, u32 *reg, const u32 mask, --2.31.1
I think that using readl/writel is fine, no need for
raw_...
For microblaze that should be fine but let me ask my team to rest it on ARM.
I think that __raw version are safer because this IP can also run on big endian systems and I think that was the reason why readl/writel wasn't used in past.
Thanks,
Michal
Re: [PATCH 2/3] net: emaclite: fix xemaclite_alignedread/write functions
Quoted 58 lines · Michal Simek
Quoted 48 lines · Ramon Fried
Quoted 47 lines · Samuel Obuch
Use __raw_read* and __raw_write* functions to ensure read/write is passed to the memory-mapped regions, as non-volatile accesses may get optimised out.
Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/net/xilinx_emaclite.c +4
-5@@ -113,12 +113,12 @@ static void xemaclite_alignedread(u32 *srcptr, void *destptr, u32 bytecount)/* Word aligned buffer, no correction needed. */ to32ptr = (u32 *) destptr;while (bytecount >3 ) { - *to32ptr++ = *from32ptr++; + *to32ptr++ =__raw_readl (from32ptr++); bytecount -=4 ; } to8ptr = (u8 *) to32ptr; - alignbuffer = *from32ptr++; + alignbuffer =__raw_readl (from32ptr++); from8ptr = (u8 *) &alignbuffer;for (i =0 ; i < bytecount; i++)@@ -136,8 +136,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount) from32ptr = (u32 *) srcptr;while (bytecount >3 ) { - - *to32ptr++ = *from32ptr++; +__raw_writel (*from32ptr++, to32ptr++); bytecount -=4 ; }@@ -148,7 +147,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount)for (i =0 ; i < bytecount; i++) *to8ptr++ = *from8ptr++; - *to32ptr++ = alignbuffer; +__raw_writel (alignbuffer, to32ptr++); }Quoted 5 lines
Quoted 4 lines
drivers/net/xilinx_emaclite.c +0
-1static int wait_for_bit(const char *func, u32 *reg, const u32 mask, --2.31.1
I think that using readl/writel is fine, no need for
raw_...
Quoted 6 lines
For microblaze that should be fine but let me ask my team to rest it on ARM. I think that
__rawversion are safer because this IP can also run on big endian systems and I think that was the reason why readl/writel wasn't used in past.Thanks,
Michal
Hi Michal,
Do you have any new information on this? For the v2, it would be good to have this resolved.
Thanks,
Jan
Michal Simek
maintainerRe: [PATCH 2/3] net: emaclite: fix xemaclite_alignedread/write functions
Quoted 63 lines · Jan Remes
Quoted 62 lines · Michal Simek
Quoted 48 lines · Ramon Fried
Quoted 47 lines · Samuel Obuch
Use __raw_read* and __raw_write* functions to ensure read/write is passed to the memory-mapped regions, as non-volatile accesses may get optimised out.
Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/net/xilinx_emaclite.c +4
-5@@ -113,12 +113,12 @@ static void xemaclite_alignedread(u32 *srcptr, void *destptr, u32 bytecount)/* Word aligned buffer, no correction needed. */ to32ptr = (u32 *) destptr;while (bytecount >3 ) { - *to32ptr++ = *from32ptr++; + *to32ptr++ =__raw_readl (from32ptr++); bytecount -=4 ; } to8ptr = (u8 *) to32ptr; - alignbuffer = *from32ptr++; + alignbuffer =__raw_readl (from32ptr++); from8ptr = (u8 *) &alignbuffer;for (i =0 ; i < bytecount; i++)@@ -136,8 +136,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount) from32ptr = (u32 *) srcptr;while (bytecount >3 ) { - - *to32ptr++ = *from32ptr++; +__raw_writel (*from32ptr++, to32ptr++); bytecount -=4 ; }@@ -148,7 +147,7 @@ static void xemaclite_alignedwrite(void *srcptr, u32 *destptr, u32 bytecount)for (i =0 ; i < bytecount; i++) *to8ptr++ = *from8ptr++; - *to32ptr++ = alignbuffer; +__raw_writel (alignbuffer, to32ptr++); }Quoted 5 lines
Quoted 4 lines
drivers/net/xilinx_emaclite.c +0
-1static int wait_for_bit(const char *func, u32 *reg, const u32 mask, --2.31.1
I think that using readl/writel is fine, no need for
raw_...For microblaze that should be fine but let me ask my team to rest it on ARM. I think that
__rawversion are safer because this IP can also run on big endian systems and I think that was the reason why readl/writel wasn't used in past.
Quoted 7 lines
Quoted 2 lines
Thanks,
MichalHi Michal,
Do you have any new information on this? For the v2, it would be good to have this resolved.
we are not testing emaclite on any ARM design. But in Linux you can find in this driver.
#ifdef __BIG_ENDIAN
#define xemaclite_readl ioread32be
#define xemaclite_writel iowrite32be
#else
#define xemaclite_readl ioread32
#define xemaclite_writel iowrite32
#endif
If you keep __raw variants it will ensure that native endian access is doing to be used.
On ARM IIRC readl/writel also have barriers. Origin patch is also using raw variant that's why I expect it is working on your system.
Thanks,
Michal
Re: [PATCH 2/3] net: emaclite: fix xemaclite_alignedread/write functions
Hi, I tested both versions to be sure, but the results are as can be expected:
1. both __raw_readl/__raw_writel and readl/writel functions work ok on riscv - only the original nonvolatile accesses were problematic
2. the additional barrier in readl/writel functions can introduce noticeable slowdown - e.g. with our setup, download speed over tftp for the same image decreased from 460 KiB/s to 118 KiB/s
Can we conclude to keep the raw versions in the patch?
Thanks,
Samuel
Quoted 107 lines · Michal Simek
Quoted 1 line · Jan Remes
On Mon, Aug 8, 2022 at 10:05 AM Michal Simek <[email protected]>
Quoted 5 lines · wrote:
Quoted 5 lines · Ramon Fried
Quoted 1 line
On Wed, Jul 13, 2022 at 5:02 PM Samuel Obuch <[email protected]>
Quoted 11 lines · wrote:
Quoted 11 lines
Quoted 11 lines
Review
Quoted 11 lines
Use __raw_read* and __raw_write* functions to ensure read/write is passed to the memory-mapped regions, as non-volatile accesses may get optimised out.
Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/drivers/net/xilinx_emaclite.cQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/xilinx_emaclite.c static void xemaclite_alignedread(u32 *srcptr,
Quoted 4 lines
index
5cd88e04fe..de7a2dee0b100644drivers/net/xilinx_emaclite.c +0
-0@@ -113,12 +113,12 @@ static void xemaclite_alignedread(u32 *srcptr,void *destptr, u32 bytecount)
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/net/xilinx_emaclite.c +1
-1/* Word aligned buffer, no correction needed. */ to32ptr = (u32 *) destptr;while (bytecount >3 ) { - *to32ptr++ = *from32ptr++; + *to32ptr++ =__raw_readl (from32ptr++); bytecount -=4 ; } to8ptr = (u8 *) to32ptr;Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/xilinx_emaclite.c static void xemaclite_alignedwrite(void *srcptr,
Quoted 6 lines
drivers/net/xilinx_emaclite.c +1
-1- alignbuffer = *from32ptr++; + alignbuffer =__raw_readl (from32ptr++); from8ptr = (u8 *) &alignbuffer;for (i =0 ; i < bytecount; i++)@@ -136,8 +136,7 @@ static void xemaclite_alignedwrite(void *srcptr,u32 *destptr, u32 bytecount)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/net/xilinx_emaclite.c static void xemaclite_alignedwrite(void *srcptr,
Quoted 10 lines
drivers/net/xilinx_emaclite.c +1
-2from32ptr = (u32 *) srcptr;while (bytecount >3 ) { - - *to32ptr++ = *from32ptr++; +__raw_writel (*from32ptr++, to32ptr++); bytecount -=4 ; }@@ -148,7 +147,7 @@ static void xemaclite_alignedwrite(void *srcptr,u32 *destptr, u32 bytecount)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/xilinx_emaclite.c +1
-1for (i =0 ; i < bytecount; i++) *to8ptr++ = *from8ptr++; - *to32ptr++ = alignbuffer; +__raw_writel (alignbuffer, to32ptr++); }Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
drivers/net/xilinx_emaclite.c +0
-1static int wait_for_bit(const char *func, u32 *reg, const u32 mask, --2.31.1
I think that using readl/writel is fine, no need for
raw_...For microblaze that should be fine but let me ask my team to rest it on
ARM.
Quoted 1 line
Quoted 1 line
I think that
__rawversion are safer because this IP can also run onbig endian
Quoted 1 line
Quoted 1 line
systems and I think that was the reason why readl/writel wasn't used in
past.
Quoted 8 lines
Quoted 3 lines
Thanks,
MichalHi Michal,
Do you have any new information on this? For the v2, it would be good to have this resolved.
we are not testing emaclite on any ARM design. But in Linux you can find in this
driver.#ifdef
__BIG_ENDIAN
#definexemaclite_readlioread32be
#definexemaclite_writeliowrite32be
#else
#definexemaclite_readlioread32
#definexemaclite_writeliowrite32
#endifIf you keep
__rawvariants it will ensure that native endian access is doing to
be used.
On ARM IIRC readl/writel also have barriers. Origin patch is also using raw
variant that's why I expect it is working on your system.Thanks,
Michal
Michal Simek
maintainerRe: [PATCH 2/3] net: emaclite: fix xemaclite_alignedread/write functions
Hi,
Quoted 6 lines · Samuel Obuch
Hi, I tested both versions to be sure, but the results are as can be expected:
1. both __raw_readl/__raw_writel and readl/writel functions work ok on riscv - only the original nonvolatile accesses were problematic
2. the additional barrier in readl/writel functions can introduce noticeable slowdown - e.g. with our setup, download speed over tftp for the same image decreased from 460 KiB/s to 118 KiB/sCan we conclude to keep the raw versions in the patch?
I prefer raw versions too.
M
Re: [PATCH 2/3] net: emaclite: fix xemaclite_alignedread/write functions
Quoted 12 lines · Michal Simek
Hi,
Quoted 8 lines · Samuel Obuch
Hi, I tested both versions to be sure, but the results are as can be expected:
1. both __raw_readl/__raw_writel and readl/writel functions work ok on riscv - only the original nonvolatile accesses were problematic
2. the additional barrier in readl/writel functions can introduce noticeable slowdown - e.g. with our setup, download speed over tftp for the same image decreased from 460 KiB/s to 118 KiB/s
Quoted 5 lines
Quoted 1 line
Can we conclude to keep the raw versions in the patch?
I prefer raw versions too.
Let's keep it raw.
PATCH 3/3 net: emaclite: fix handling for IP packets with specific lengths
In reply to Samuel ObuchThe maximum length is capped similarly to the emaclite_send function. Avoid integer underflow for values of ip->ip_len < 30, the minimum length of an IP packet is 21 bytes.
--- drivers/net/xilinx_emaclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/xilinx_emaclite.c +3 -1
@@ -518,6 +518,8 @@ try_again: length =ntohs (ip->ip_len); length +=ETHER_HDR_SIZE +ETH_FCS_LEN ;debug ("IP Packet %x\n" , length); +if (length >PKTSIZE ) + length =PKTSIZE ;break ;default :debug ("Other Packet\n" );
@@ -526,7 +528,7 @@ try_again: }/* Read the rest of the packet which is longer then first read */ -if (length != first_read) +if (length > first_read)xemaclite_alignedread (addr + first_read, etherrxbuff + first_read, length - first_read);
Signature · 1 line
2.31.1
Re: [PATCH 3/3] net: emaclite: fix handling for IP packets with specific lengths
Quoted 33 lines · Samuel Obuch
The maximum length is capped similarly to the
emaclite_sendfunction. Avoid integer underflow for values ofip->ip_len< 30, the minimum length of an IP packet is 21 bytes.Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/xilinx_emaclite.c +3
-2@@ -518,6 +518,8 @@ try_again: length =ntohs (ip->ip_len); length +=ETHER_HDR_SIZE +ETH_FCS_LEN ;debug ("IP Packet %x\n" , length); +if (length >PKTSIZE ) + length =PKTSIZE ;break ;default :debug ("Other Packet\n" );@@ -526,7 +528,7 @@ try_again: }/* Read the rest of the packet which is longer then first read */ -if (length != first_read) +if (length > first_read)xemaclite_alignedread (addr + first_read, etherrxbuff + first_read, length - first_read); --
Quoted 2 lines
2.31.1
+ Michal
Re: [PATCH 3/3] net: emaclite: fix handling for IP packets with specific lengths
Quoted 27 lines · Ramon Fried
Quoted 26 lines · Samuel Obuch
The maximum length is capped similarly to the
emaclite_sendfunction. Avoid integer underflow for values ofip->ip_len< 30, the minimum length of an IP packet is 21 bytes.Signed-off-by Samuel Obuch <[email protected]>--- drivers/net/xilinx_emaclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/xilinx_emaclite.c +2
-0@@ -518,6 +518,8 @@ try_again: length =ntohs (ip->ip_len); length +=ETHER_HDR_SIZE +ETH_FCS_LEN ;debug ("IP Packet %x\n" , length); +if (length >PKTSIZE ) + length =PKTSIZE ;break ;default :debug ("Other Packet\n" );@@ -526,7 +528,7 @@ try_again: }
Quoted 10 lines
Quoted 9 lines
drivers/net/xilinx_emaclite.c +1
-2/* Read the rest of the packet which is longer then first read */ -if (length != first_read) +if (length > first_read)xemaclite_alignedread (addr + first_read, etherrxbuff + first_read, length - first_read); --2.31.1
+ Michal
This looks good.
Thanks,
Michal
Michal Simek
maintainerHi,
Quoted 1 line · Samuel Obuch
These patches solve a few issues with the driver observed on a RISC-V platform.
How does that system look like that you are using standard Xilinx IPs? Do you use any other standard Xilinx IP like console?
Is it available somewhere that I can run it too?
Thanks,
Michal
Hi,
its a soft-core in an FPGA. Other than the ethernet, I think we only use Xilinx bridges.
Unfortunately theres no publicly available version.
S.
Quoted 14 lines · Michal Simek
Hi,
Quoted 1 line · Samuel Obuch
These patches solve a few issues with the driver observed on a RISC-V
platform.
How does that system look like that you are using standard Xilinx IPs? Do you use any other standard Xilinx IP like console?
Is it available somewhere that I can run it too?
Thanks,
Michal
Hi Samuel,
po 8. 8. 2022 v 10:34 odesílatel Samuel Obuch <[email protected]> napsal:
Quoted 22 lines
Hi,
its a soft-core in an FPGA. Other than the ethernet, I think we only use Xilinx bridges.
Unfortunately theres no publicly available version.
S.
Quoted 10 lines · Michal Simek
Hi,
Quoted 1 line · Samuel Obuch
These patches solve a few issues with the driver observed on a RISC-V
platform.
How does that system look like that you are using standard Xilinx IPs? Do you use any other standard Xilinx IP like console?
Is it available somewhere that I can run it too?
Are you going to send a new version of this patchset?
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs