public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Disaligned buffer in print_buffer
@ 2010-08-19 11:01 Stefano Babic
  2010-08-19 15:35 ` Mike Frysinger
  2010-08-27  9:41 ` Reinhard Meyer
  0 siblings, 2 replies; 10+ messages in thread
From: Stefano Babic @ 2010-08-19 11:01 UTC (permalink / raw)
  To: u-boot

As linebuf is accessed with 32-bit pointers, its address
must be 32 bit aligned to avoid misaligned access.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 lib/display_options.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/display_options.c b/lib/display_options.c
index 20319e6..30374f9 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -101,7 +101,7 @@ void print_size(unsigned long long size, const char *s)
 #define DEFAULT_LINE_LENGTH_BYTES (16)
 int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
 {
-	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
+	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1] __attribute__((__aligned__(4)));
 	uint32_t *uip = (void*)linebuf;
 	uint16_t *usp = (void*)linebuf;
 	uint8_t *ucp = (void*)linebuf;
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Disaligned buffer in print_buffer
  2010-08-19 11:01 [U-Boot] [PATCH] Disaligned buffer in print_buffer Stefano Babic
@ 2010-08-19 15:35 ` Mike Frysinger
  2010-08-19 16:33   ` Stefano Babic
  2010-08-27  9:41 ` Reinhard Meyer
  1 sibling, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2010-08-19 15:35 UTC (permalink / raw)
  To: u-boot

On Thursday, August 19, 2010 07:01:58 Stefano Babic wrote:
> -	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
> +	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1]
> __attribute__((__aligned__(4)));

i'd rather we go with Albert Aribaud's change (posted 14 Aug 2010)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100819/7b2489a6/attachment.pgp 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Disaligned buffer in print_buffer
  2010-08-19 15:35 ` Mike Frysinger
@ 2010-08-19 16:33   ` Stefano Babic
  2010-08-20  7:46     ` Albert ARIBAUD
  0 siblings, 1 reply; 10+ messages in thread
From: Stefano Babic @ 2010-08-19 16:33 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> On Thursday, August 19, 2010 07:01:58 Stefano Babic wrote:
>> -	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
>> +	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1]
>> __attribute__((__aligned__(4)));
> 
> i'd rather we go with Albert Aribaud's change (posted 14 Aug 2010)
> -mike

Ok, I have missed someone else went in the same trouble ! Wolfgang,
could you apply Albert's patch to the mainline ? As I see in the
discussion, the patch proposed is accepted because
_attribute__((__aligned__())) is everywhere used in u-boot.

Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Disaligned buffer in print_buffer
  2010-08-19 16:33   ` Stefano Babic
@ 2010-08-20  7:46     ` Albert ARIBAUD
  0 siblings, 0 replies; 10+ messages in thread
From: Albert ARIBAUD @ 2010-08-20  7:46 UTC (permalink / raw)
  To: u-boot

Le 19/08/2010 18:33, Stefano Babic a ?crit :
> As I see in the
> discussion, the patch proposed is accepted because
> _attribute__((__aligned__())) is everywhere used in u-boot.
>
> Stefano

'Acceptable' is my bet... Not yet 'accepted' though. :)

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Disaligned buffer in print_buffer
  2010-08-19 11:01 [U-Boot] [PATCH] Disaligned buffer in print_buffer Stefano Babic
  2010-08-19 15:35 ` Mike Frysinger
@ 2010-08-27  9:41 ` Reinhard Meyer
  2010-08-27 18:12   ` Mike Frysinger
  2010-08-27 18:24   ` Stefano Babic
  1 sibling, 2 replies; 10+ messages in thread
From: Reinhard Meyer @ 2010-08-27  9:41 UTC (permalink / raw)
  To: u-boot

Stefano Babic schrieb:
> As linebuf is accessed with 32-bit pointers, its address
> must be 32 bit aligned to avoid misaligned access.
> 
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> ---
>  lib/display_options.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/display_options.c b/lib/display_options.c
> index 20319e6..30374f9 100644
> --- a/lib/display_options.c
> +++ b/lib/display_options.c
> @@ -101,7 +101,7 @@ void print_size(unsigned long long size, const char *s)
>  #define DEFAULT_LINE_LENGTH_BYTES (16)
>  int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
>  {
> -	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
> +	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1] __attribute__((__aligned__(4)));
>  	uint32_t *uip = (void*)linebuf;
>  	uint16_t *usp = (void*)linebuf;
>  	uint8_t *ucp = (void*)linebuf;

Why not just declare it as
	uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];
?

Best Regards,
Reinhard

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Disaligned buffer in print_buffer
  2010-08-27  9:41 ` Reinhard Meyer
@ 2010-08-27 18:12   ` Mike Frysinger
  2010-08-27 18:24   ` Stefano Babic
  1 sibling, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2010-08-27 18:12 UTC (permalink / raw)
  To: u-boot

On Friday, August 27, 2010 05:41:08 Reinhard Meyer wrote:
> Stefano Babic schrieb:
> > --- a/lib/display_options.c
> > +++ b/lib/display_options.c
> > @@ -101,7 +101,7 @@ void print_size(unsigned long long size, const char
> > *s)
> > 
> >  #define DEFAULT_LINE_LENGTH_BYTES (16)
> >  int print_buffer (ulong addr, void* data, uint width, uint count, uint
> >  linelen) {
> > 
> > -	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
> > +	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1]
> > __attribute__((__aligned__(4)));
> > 
> >  	uint32_t *uip = (void*)linebuf;
> >  	uint16_t *usp = (void*)linebuf;
> >  	uint8_t *ucp = (void*)linebuf;
> 
> Why not just declare it as
> 	uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];
> ?

i guess that'd be another way of doing it
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100827/70be83e1/attachment.pgp 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Disaligned buffer in print_buffer
  2010-08-27  9:41 ` Reinhard Meyer
  2010-08-27 18:12   ` Mike Frysinger
@ 2010-08-27 18:24   ` Stefano Babic
  2010-08-27 19:06     ` Reinhard Meyer
  1 sibling, 1 reply; 10+ messages in thread
From: Stefano Babic @ 2010-08-27 18:24 UTC (permalink / raw)
  To: u-boot

Reinhard Meyer wrote:

Hi Reinhard,

> Why not just declare it as
> 	uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];
> ?

Yes, we do not need any special compiler attribute. I forward to Albert,
he sent previously an analog patch to solve this issue.

Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Disaligned buffer in print_buffer
  2010-08-27 18:24   ` Stefano Babic
@ 2010-08-27 19:06     ` Reinhard Meyer
  2010-08-28  6:56       ` Albert ARIBAUD
  0 siblings, 1 reply; 10+ messages in thread
From: Reinhard Meyer @ 2010-08-27 19:06 UTC (permalink / raw)
  To: u-boot

On 27.08.2010 20:24, Stefano Babic wrote:
> Reinhard Meyer wrote:
>
> Hi Reinhard,
>
>> Why not just declare it as
>> 	uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];
>> ?
>
> Yes, we do not need any special compiler attribute. I forward to Albert,
> he sent previously an analog patch to solve this issue.
>
> Stefano
>
If you need a patch for this, I have made the change here this morning.
I can format and email one instantly.

Reinhard

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Disaligned buffer in print_buffer
  2010-08-27 19:06     ` Reinhard Meyer
@ 2010-08-28  6:56       ` Albert ARIBAUD
  2010-08-28  7:17         ` Reinhard Meyer
  0 siblings, 1 reply; 10+ messages in thread
From: Albert ARIBAUD @ 2010-08-28  6:56 UTC (permalink / raw)
  To: u-boot

Le 27/08/2010 21:06, Reinhard Meyer a ?crit :
> On 27.08.2010 20:24, Stefano Babic wrote:
>> Reinhard Meyer wrote:
>>
>> Hi Reinhard,
>>
>>> Why not just declare it as
>>> uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];
>>> ?
>>
>> Yes, we do not need any special compiler attribute. I forward to Albert,
>> he sent previously an analog patch to solve this issue.
>>
>> Stefano
>>
> If you need a patch for this, I have made the change here this morning.
> I can format and email one instantly.
>
> Reinhard

I say go ahead!

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH] Disaligned buffer in print_buffer
  2010-08-28  6:56       ` Albert ARIBAUD
@ 2010-08-28  7:17         ` Reinhard Meyer
  0 siblings, 0 replies; 10+ messages in thread
From: Reinhard Meyer @ 2010-08-28  7:17 UTC (permalink / raw)
  To: u-boot

Dear Albert ARIBAUD,
>> If you need a patch for this, I have made the change here this morning.
>> I can format and email one instantly.
>>
>> Reinhard
>
> I say go ahead!
Its there, right after the message. It has a different title,
because I made it before I found the tread about the issue :)

Reinhard

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-08-28  7:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-19 11:01 [U-Boot] [PATCH] Disaligned buffer in print_buffer Stefano Babic
2010-08-19 15:35 ` Mike Frysinger
2010-08-19 16:33   ` Stefano Babic
2010-08-20  7:46     ` Albert ARIBAUD
2010-08-27  9:41 ` Reinhard Meyer
2010-08-27 18:12   ` Mike Frysinger
2010-08-27 18:24   ` Stefano Babic
2010-08-27 19:06     ` Reinhard Meyer
2010-08-28  6:56       ` Albert ARIBAUD
2010-08-28  7:17         ` Reinhard Meyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox