* [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned accesses @ 2013-04-28 10:39 Andrew Gabbasov 2013-04-28 18:58 ` Marek Vasut 0 siblings, 1 reply; 4+ messages in thread From: Andrew Gabbasov @ 2013-04-28 10:39 UTC (permalink / raw) To: u-boot Packed structure cfi_qry contains unaligned 16- and 32-bits members, accessing which causes problems when cfi_flash driver is compiled with -munaligned-access option: flash initialization hangs, probably due to data error. Since fixing the code to use some other way of accessing those fields seems quite expensive, just force the compiler to use -mno-unaligned-access. Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com> --- drivers/mtd/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile index 543c845..a120f0b 100644 --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile @@ -46,6 +46,9 @@ all: $(LIB) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)cfi_flash.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned accesses 2013-04-28 10:39 [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned accesses Andrew Gabbasov @ 2013-04-28 18:58 ` Marek Vasut 2013-04-29 9:40 ` Gabbasov, Andrew 0 siblings, 1 reply; 4+ messages in thread From: Marek Vasut @ 2013-04-28 18:58 UTC (permalink / raw) To: u-boot Dear Andrew Gabbasov, > Packed structure cfi_qry contains unaligned 16- and 32-bits members, > accessing which causes problems when cfi_flash driver is compiled with > -munaligned-access option: flash initialization hangs, probably > due to data error. > > Since fixing the code to use some other way of accessing those fields > seems quite expensive, just force the compiler to use > -mno-unaligned-access. > > Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com> > --- > drivers/mtd/Makefile | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile > index 543c845..a120f0b 100644 > --- a/drivers/mtd/Makefile > +++ b/drivers/mtd/Makefile > @@ -46,6 +46,9 @@ all: $(LIB) > $(LIB): $(obj).depend $(OBJS) > $(call cmd_link_o_target, $(OBJS)) > > +# SEE README.arm-unaligned-accesses > +$(obj)cfi_flash.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) > + > ######################################################################### > > # defines $(obj).depend target I'd say rather fix the structure than use this workaround. See, using u8[3] u16 will make unaligned access. The fix would be to split that u16 into two u8 and add a proper accessor. It'll be much larger effort, but it'd also be more correct. Best regards, Marek Vasut ^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned accesses 2013-04-28 18:58 ` Marek Vasut @ 2013-04-29 9:40 ` Gabbasov, Andrew 2013-05-08 14:56 ` Gabbasov, Andrew 0 siblings, 1 reply; 4+ messages in thread From: Gabbasov, Andrew @ 2013-04-29 9:40 UTC (permalink / raw) To: u-boot > From: Marek Vasut [marek.vasut at gmail.com] > Sent: Sunday, April 28, 2013 22:58 > To: u-boot at lists.denx.de > Cc: Gabbasov, Andrew; Albert ARIBAUD; Tom Rini > Subject: Re: [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned accesses > > Dear Andrew Gabbasov, > > > Packed structure cfi_qry contains unaligned 16- and 32-bits members, > > accessing which causes problems when cfi_flash driver is compiled with > > -munaligned-access option: flash initialization hangs, probably > > due to data error. > > > > Since fixing the code to use some other way of accessing those fields > > seems quite expensive, just force the compiler to use > > -mno-unaligned-access. > > > > Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com> > > --- > > drivers/mtd/Makefile | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile > > index 543c845..a120f0b 100644 > > --- a/drivers/mtd/Makefile > > +++ b/drivers/mtd/Makefile > > @@ -46,6 +46,9 @@ all: $(LIB) > > $(LIB): $(obj).depend $(OBJS) > > $(call cmd_link_o_target, $(OBJS)) > > > > +# SEE README.arm-unaligned-accesses > > +$(obj)cfi_flash.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) > > + > > ######################################################################### > > > > # defines $(obj).depend target > > I'd say rather fix the structure than use this workaround. See, using > > u8[3] > u16 > > will make unaligned access. The fix would be to split that u16 into two u8 and > add a proper accessor. It'll be much larger effort, but it'd also be more > correct. > > Best regards, > Marek Vasut Hi Marek, Thank you for your response. I was thinking about this way of fixing, but it seemed too require too much effort. However, after some closer look it turned out to be not quite difficult, since there are quite a few accesses to such unaligned fields. So, I made another fix and sent to separately to the list with Subject: "[U-Boot][PATCH] ARM: cfi_flash: Fix unaligned accesses to cfi_qry structure". Please, look at it, if it is OK from your point of view. Thanks. Best regards, Andrew ^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned accesses 2013-04-29 9:40 ` Gabbasov, Andrew @ 2013-05-08 14:56 ` Gabbasov, Andrew 0 siblings, 0 replies; 4+ messages in thread From: Gabbasov, Andrew @ 2013-05-08 14:56 UTC (permalink / raw) To: u-boot > From: Gabbasov, Andrew > Sent: Monday, April 29, 2013 13:40 > To: Marek Vasut; u-boot at lists.denx.de > Cc: Albert ARIBAUD; Tom Rini > Subject: RE: [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned accesses [ skipped ] > Hi Marek, > > Thank you for your response. > > I was thinking about this way of fixing, but it seemed too require too much effort. > However, after some closer look it turned out to be not quite difficult, since > there are quite a few accesses to such unaligned fields. So, I made another fix and > sent to separately to the list with Subject: "[U-Boot][PATCH] ARM: cfi_flash: Fix unaligned > accesses to cfi_qry structure". Please, look at it, if it is OK from your point of view. > > Thanks. > > Best regards, > Andrew Any comments on that new fix? Thanks. Best regards, Andrew ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-05-08 14:56 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-04-28 10:39 [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned accesses Andrew Gabbasov 2013-04-28 18:58 ` Marek Vasut 2013-04-29 9:40 ` Gabbasov, Andrew 2013-05-08 14:56 ` Gabbasov, Andrew
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox