* [U-Boot] [PATCH] usb: gadget: Fix data aborts during USB ethernet boot @ 2013-08-20 23:32 Joel Fernandes 2013-08-27 13:52 ` Marek Vasut 0 siblings, 1 reply; 6+ messages in thread From: Joel Fernandes @ 2013-08-20 23:32 UTC (permalink / raw) To: u-boot As seen on GCC 4.6 Linaro compiler, control_req buffer is not aligned on 4 byte boundaray causing data aborts in eth_setup -> conf_buf during dhcp boot over usb_ether. Fix the issue my aligning control_req buffer to 4-byte boundary. Tested on am335x_evm platform (beaglebone). Applies on 2013.10-rc1 branch. Cc: Tom Rini <trini@ti.com> Signed-off-by: Joel Fernandes <joelf@ti.com> --- drivers/usb/gadget/ether.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 579893c..251d7b2 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -849,7 +849,7 @@ static struct usb_gadget_strings stringtab = { }; /*============================================================================*/ -static u8 control_req[USB_BUFSIZ]; +static u8 control_req[USB_BUFSIZ] __attribute__ ((aligned(4))); #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS) static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4))); #endif -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: gadget: Fix data aborts during USB ethernet boot 2013-08-20 23:32 [U-Boot] [PATCH] usb: gadget: Fix data aborts during USB ethernet boot Joel Fernandes @ 2013-08-27 13:52 ` Marek Vasut 2013-09-04 21:30 ` Joel Fernandes 0 siblings, 1 reply; 6+ messages in thread From: Marek Vasut @ 2013-08-27 13:52 UTC (permalink / raw) To: u-boot Dear Joel Fernandes, > As seen on GCC 4.6 Linaro compiler, control_req buffer is not aligned > on 4 byte boundaray causing data aborts in eth_setup -> conf_buf > during dhcp boot over usb_ether. Fix the issue my aligning control_req > buffer to 4-byte boundary. > > Tested on am335x_evm platform (beaglebone). > Applies on 2013.10-rc1 branch. > > Cc: Tom Rini <trini@ti.com> > Signed-off-by: Joel Fernandes <joelf@ti.com> Please keep me in the CC next time. > --- > drivers/usb/gadget/ether.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c > index 579893c..251d7b2 100644 > --- a/drivers/usb/gadget/ether.c > +++ b/drivers/usb/gadget/ether.c > @@ -849,7 +849,7 @@ static struct usb_gadget_strings stringtab = { > }; > > /*======================================================================== > ====*/ -static u8 control_req[USB_BUFSIZ]; > +static u8 control_req[USB_BUFSIZ] __attribute__ ((aligned(4))); Please make this cacheline aligned, so we get rid of bounce buffering of the requests on stupid hardware. > #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS) > static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4))); This could also use fixing, but the STATUS_BYTECOUNT would need to be up-aligned as well then. Some DEFINE_CACHE_ALIGN_BUFFER might help in both cases here. > #endif Best regards, Marek Vasut ^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: gadget: Fix data aborts during USB ethernet boot 2013-08-27 13:52 ` Marek Vasut @ 2013-09-04 21:30 ` Joel Fernandes 2013-09-04 21:38 ` Marek Vasut 0 siblings, 1 reply; 6+ messages in thread From: Joel Fernandes @ 2013-09-04 21:30 UTC (permalink / raw) To: u-boot On 08/27/2013 08:52 AM, Marek Vasut wrote: > Dear Joel Fernandes, > >> As seen on GCC 4.6 Linaro compiler, control_req buffer is not aligned >> on 4 byte boundaray causing data aborts in eth_setup -> conf_buf >> during dhcp boot over usb_ether. Fix the issue my aligning control_req >> buffer to 4-byte boundary. >> >> Tested on am335x_evm platform (beaglebone). >> Applies on 2013.10-rc1 branch. >> >> Cc: Tom Rini <trini@ti.com> >> Signed-off-by: Joel Fernandes <joelf@ti.com> > > Please keep me in the CC next time. Ok. >> --- >> drivers/usb/gadget/ether.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c >> index 579893c..251d7b2 100644 >> --- a/drivers/usb/gadget/ether.c >> +++ b/drivers/usb/gadget/ether.c >> @@ -849,7 +849,7 @@ static struct usb_gadget_strings stringtab = { >> }; >> >> /*======================================================================== >> ====*/ -static u8 control_req[USB_BUFSIZ]; >> +static u8 control_req[USB_BUFSIZ] __attribute__ ((aligned(4))); > > Please make this cacheline aligned, so we get rid of bounce buffering of the > requests on stupid hardware. >> #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS) >> static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4))); > > This could also use fixing, but the STATUS_BYTECOUNT would need to be up-aligned > as well then. Some DEFINE_CACHE_ALIGN_BUFFER might help in both cases here. Ok, how about __aligned(CONFIG_SYS_CACHELINE_SIZE) instead of defining a new DEFINE_CACHE_ALIGN_BUFFER macro? Can you explain what you meant by STATUS_BYTECOUNT up-aligned and why its needed to be up-aligned? Regards, -Joel > >> #endif > > Best regards, > Marek Vasut > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: gadget: Fix data aborts during USB ethernet boot 2013-09-04 21:30 ` Joel Fernandes @ 2013-09-04 21:38 ` Marek Vasut 2013-09-04 21:54 ` Joel Fernandes 0 siblings, 1 reply; 6+ messages in thread From: Marek Vasut @ 2013-09-04 21:38 UTC (permalink / raw) To: u-boot Dear Joel Fernandes, > On 08/27/2013 08:52 AM, Marek Vasut wrote: > > Dear Joel Fernandes, > > > >> As seen on GCC 4.6 Linaro compiler, control_req buffer is not aligned > >> on 4 byte boundaray causing data aborts in eth_setup -> conf_buf > >> during dhcp boot over usb_ether. Fix the issue my aligning control_req > >> buffer to 4-byte boundary. > >> > >> Tested on am335x_evm platform (beaglebone). > >> Applies on 2013.10-rc1 branch. > >> > >> Cc: Tom Rini <trini@ti.com> > >> Signed-off-by: Joel Fernandes <joelf@ti.com> > > > > Please keep me in the CC next time. > > Ok. > > >> --- > >> > >> drivers/usb/gadget/ether.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c > >> index 579893c..251d7b2 100644 > >> --- a/drivers/usb/gadget/ether.c > >> +++ b/drivers/usb/gadget/ether.c > >> @@ -849,7 +849,7 @@ static struct usb_gadget_strings stringtab = { > >> > >> }; > >> > >> /*===================================================================== > >> === > >> > >> ====*/ -static u8 control_req[USB_BUFSIZ]; > >> +static u8 control_req[USB_BUFSIZ] __attribute__ ((aligned(4))); > > > > Please make this cacheline aligned, so we get rid of bounce buffering of > > the requests on stupid hardware. > > > >> #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS) > >> static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4))); > > > > This could also use fixing, but the STATUS_BYTECOUNT would need to be > > up-aligned as well then. Some DEFINE_CACHE_ALIGN_BUFFER might help in > > both cases here. > > Ok, how about __aligned(CONFIG_SYS_CACHELINE_SIZE) instead of defining > a new DEFINE_CACHE_ALIGN_BUFFER macro? THis is already defined and used throughout the USB code, check include/common.h IIRC. > Can you explain what you meant by STATUS_BYTECOUNT up-aligned and why its > needed to be up-aligned? it's 16 bytes now, no? Up-align it to cacheline size. Best regards, Marek Vasut ^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: gadget: Fix data aborts during USB ethernet boot 2013-09-04 21:38 ` Marek Vasut @ 2013-09-04 21:54 ` Joel Fernandes 2013-09-04 22:02 ` Marek Vasut 0 siblings, 1 reply; 6+ messages in thread From: Joel Fernandes @ 2013-09-04 21:54 UTC (permalink / raw) To: u-boot On 09/04/2013 04:38 PM, Marek Vasut wrote: > Dear Joel Fernandes, > >> On 08/27/2013 08:52 AM, Marek Vasut wrote: >>> Dear Joel Fernandes, >>> >>>> As seen on GCC 4.6 Linaro compiler, control_req buffer is not aligned >>>> on 4 byte boundaray causing data aborts in eth_setup -> conf_buf >>>> during dhcp boot over usb_ether. Fix the issue my aligning control_req >>>> buffer to 4-byte boundary. >>>> >>>> Tested on am335x_evm platform (beaglebone). >>>> Applies on 2013.10-rc1 branch. >>>> >>>> Cc: Tom Rini <trini@ti.com> >>>> Signed-off-by: Joel Fernandes <joelf@ti.com> >>> >>> Please keep me in the CC next time. >> >> Ok. >> >>>> --- >>>> >>>> drivers/usb/gadget/ether.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c >>>> index 579893c..251d7b2 100644 >>>> --- a/drivers/usb/gadget/ether.c >>>> +++ b/drivers/usb/gadget/ether.c >>>> @@ -849,7 +849,7 @@ static struct usb_gadget_strings stringtab = { >>>> >>>> }; >>>> >>>> /*===================================================================== >>>> === >>>> >>>> ====*/ -static u8 control_req[USB_BUFSIZ]; >>>> +static u8 control_req[USB_BUFSIZ] __attribute__ ((aligned(4))); >>> >>> Please make this cacheline aligned, so we get rid of bounce buffering of >>> the requests on stupid hardware. >>> >>>> #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS) >>>> static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4))); >>> >>> This could also use fixing, but the STATUS_BYTECOUNT would need to be >>> up-aligned as well then. Some DEFINE_CACHE_ALIGN_BUFFER might help in >>> both cases here. >> >> Ok, how about __aligned(CONFIG_SYS_CACHELINE_SIZE) instead of defining >> a new DEFINE_CACHE_ALIGN_BUFFER macro? > > THis is already defined and used throughout the USB code, check include/common.h > IIRC. > >> Can you explain what you meant by STATUS_BYTECOUNT up-aligned and why its >> needed to be up-aligned? > > it's 16 bytes now, no? Up-align it to cacheline size. Ok, that makes sense. Thanks. Hope below patch is OK, but I have to test it more once I am near a setup and can send out a proper patch later today. If its ok can you explain technical reason for need to up-align array size to cacheline size, and why aligning only buffer location is not enough? Also I saw the following comment before the macro definition: * Usage of this macro shall be avoided or used with extreme care! Regards, -Joel diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 579893c..700d5fb 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -849,9 +849,10 @@ static struct usb_gadget_strings stringtab = { }; /*============================================================================*/ -static u8 control_req[USB_BUFSIZ]; +DEFINE_CACHE_ALIGN_BUFFER(u8, control_req, USB_BUFSIZ); + #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS) -static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4))); +DEFINE_CACHE_ALIGN_BUFFER(u8, status_req, STATUS_BYTECOUNT); #endif ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: gadget: Fix data aborts during USB ethernet boot 2013-09-04 21:54 ` Joel Fernandes @ 2013-09-04 22:02 ` Marek Vasut 0 siblings, 0 replies; 6+ messages in thread From: Marek Vasut @ 2013-09-04 22:02 UTC (permalink / raw) To: u-boot Dear Joel Fernandes, > On 09/04/2013 04:38 PM, Marek Vasut wrote: > > Dear Joel Fernandes, > > > >> On 08/27/2013 08:52 AM, Marek Vasut wrote: > >>> Dear Joel Fernandes, > >>> > >>>> As seen on GCC 4.6 Linaro compiler, control_req buffer is not aligned > >>>> on 4 byte boundaray causing data aborts in eth_setup -> conf_buf > >>>> during dhcp boot over usb_ether. Fix the issue my aligning control_req > >>>> buffer to 4-byte boundary. > >>>> > >>>> Tested on am335x_evm platform (beaglebone). > >>>> Applies on 2013.10-rc1 branch. > >>>> > >>>> Cc: Tom Rini <trini@ti.com> > >>>> Signed-off-by: Joel Fernandes <joelf@ti.com> > >>> > >>> Please keep me in the CC next time. > >> > >> Ok. > >> > >>>> --- > >>>> > >>>> drivers/usb/gadget/ether.c | 2 +- > >>>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>>> > >>>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c > >>>> index 579893c..251d7b2 100644 > >>>> --- a/drivers/usb/gadget/ether.c > >>>> +++ b/drivers/usb/gadget/ether.c > >>>> @@ -849,7 +849,7 @@ static struct usb_gadget_strings stringtab = { > >>>> > >>>> }; > >>>> > >>>> /*=================================================================== > >>>> == === > >>>> > >>>> ====*/ -static u8 control_req[USB_BUFSIZ]; > >>>> +static u8 control_req[USB_BUFSIZ] __attribute__ ((aligned(4))); > >>> > >>> Please make this cacheline aligned, so we get rid of bounce buffering > >>> of the requests on stupid hardware. > >>> > >>>> #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS) > >>>> static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4))); > >>> > >>> This could also use fixing, but the STATUS_BYTECOUNT would need to be > >>> up-aligned as well then. Some DEFINE_CACHE_ALIGN_BUFFER might help in > >>> both cases here. > >> > >> Ok, how about __aligned(CONFIG_SYS_CACHELINE_SIZE) instead of defining > >> a new DEFINE_CACHE_ALIGN_BUFFER macro? > > > > THis is already defined and used throughout the USB code, check > > include/common.h IIRC. > > > >> Can you explain what you meant by STATUS_BYTECOUNT up-aligned and why > >> its needed to be up-aligned? > > > > it's 16 bytes now, no? Up-align it to cacheline size. > > Ok, that makes sense. Thanks. Hope below patch is OK, but I have to test it > more once I am near a setup and can send out a proper patch later today. > > If its ok can you explain technical reason for need to up-align array size > to cacheline size, and why aligning only buffer location is not enough? > > Also I saw the following comment before the macro definition: > * Usage of this macro shall be avoided or used with extreme care! > > Regards, > > -Joel > > diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c > index 579893c..700d5fb 100644 > --- a/drivers/usb/gadget/ether.c > +++ b/drivers/usb/gadget/ether.c > @@ -849,9 +849,10 @@ static struct usb_gadget_strings stringtab = { > }; > > /*======================================================================== > ====*/ -static u8 control_req[USB_BUFSIZ]; > +DEFINE_CACHE_ALIGN_BUFFER(u8, control_req, USB_BUFSIZ); > + > #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS) > -static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4))); > +DEFINE_CACHE_ALIGN_BUFFER(u8, status_req, STATUS_BYTECOUNT); > #endif Yeah, I think so. Repost V2 and we should be cool here. Best regards, Marek Vasut ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-09-04 22:02 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-08-20 23:32 [U-Boot] [PATCH] usb: gadget: Fix data aborts during USB ethernet boot Joel Fernandes 2013-08-27 13:52 ` Marek Vasut 2013-09-04 21:30 ` Joel Fernandes 2013-09-04 21:38 ` Marek Vasut 2013-09-04 21:54 ` Joel Fernandes 2013-09-04 22:02 ` Marek Vasut
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox