* [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is NULL @ 2015-12-18 9:38 Gong Qianyu 2015-12-18 10:24 ` Heiko Schocher 2016-01-03 15:02 ` Stefano Babic 0 siblings, 2 replies; 5+ messages in thread From: Gong Qianyu @ 2015-12-18 9:38 UTC (permalink / raw) To: u-boot This could avoid executing the code that only applies to i.MX platforms. The bus_i2c_init() is called before relocation and will assgin value to a static variable. If U-Boot is then still running in a flash device, it's theoretically not allowed to write data to flash without an erasing operation. For i.MX platforms, the U-Boot is always running in DDR. Actually it causes asynchronous error when the ARM64 system error report is enabled and the flash write protect is set. Signed-off-by: Gong Qianyu <Qianyu.Gong@freescale.com> --- V3: - Sorry..Remove an unrelated line in other file. drivers/i2c/mxc_i2c.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index fa4c82f..b2d15c9 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -581,8 +581,16 @@ void bus_i2c_init(int index, int speed, int unused, return; } - mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; - mxc_i2c_buses[index].idle_bus_data = idle_bus_data; + /* + * Warning: Be careful to allow the assignment to a static + * variable here. This function could be called while U-Boot is + * still running in flash memory. So such assignment is equal + * to write data to flash without erasing. + */ + if (idle_bus_fn) + mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; + if (idle_bus_data) + mxc_i2c_buses[index].idle_bus_data = idle_bus_data; ret = enable_i2c_clk(1, index); if (ret < 0) { -- 2.1.0.27.g96db324 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is NULL 2015-12-18 9:38 [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is NULL Gong Qianyu @ 2015-12-18 10:24 ` Heiko Schocher 2015-12-21 5:41 ` Qianyu Gong 2016-01-03 15:02 ` Stefano Babic 1 sibling, 1 reply; 5+ messages in thread From: Heiko Schocher @ 2015-12-18 10:24 UTC (permalink / raw) To: u-boot Hello Gong Qianyu, added Stefano Babic to cc as he is the imx maintainer. Am 18.12.2015 um 10:38 schrieb Gong Qianyu: > This could avoid executing the code that only applies to i.MX platforms. > > The bus_i2c_init() is called before relocation and will assgin value > to a static variable. If U-Boot is then still running in a flash > device, it's theoretically not allowed to write data to flash without > an erasing operation. For i.MX platforms, the U-Boot is always running > in DDR. > > Actually it causes asynchronous error when the ARM64 system error > report is enabled and the flash write protect is set. > > Signed-off-by: Gong Qianyu <Qianyu.Gong@freescale.com> > --- > V3: > - Sorry..Remove an unrelated line in other file. > > drivers/i2c/mxc_i2c.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) Ok, from my side, but it would be better to switch your board(s) to support DM and get rid of this old stuff from this driver. Reviewed-by: Heiko Schocher <hs@denx.de> bye, Heiko > > diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c > index fa4c82f..b2d15c9 100644 > --- a/drivers/i2c/mxc_i2c.c > +++ b/drivers/i2c/mxc_i2c.c > @@ -581,8 +581,16 @@ void bus_i2c_init(int index, int speed, int unused, > return; > } > > - mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; > - mxc_i2c_buses[index].idle_bus_data = idle_bus_data; > + /* > + * Warning: Be careful to allow the assignment to a static > + * variable here. This function could be called while U-Boot is > + * still running in flash memory. So such assignment is equal > + * to write data to flash without erasing. > + */ > + if (idle_bus_fn) > + mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; > + if (idle_bus_data) > + mxc_i2c_buses[index].idle_bus_data = idle_bus_data; > > ret = enable_i2c_clk(1, index); > if (ret < 0) { > -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is NULL 2015-12-18 10:24 ` Heiko Schocher @ 2015-12-21 5:41 ` Qianyu Gong 2015-12-30 9:27 ` Qianyu Gong 0 siblings, 1 reply; 5+ messages in thread From: Qianyu Gong @ 2015-12-21 5:41 UTC (permalink / raw) To: u-boot > -----Original Message----- > From: Heiko Schocher [mailto:hs at denx.de] > Sent: Friday, December 18, 2015 6:24 PM > To: Gong Qianyu-B52263 > Cc: u-boot at lists.denx.de; Stefano Babic > Subject: Re: [U-Boot] [Patch V3] i2c: mxc: add a condition in case the > parameter is NULL > > Hello Gong Qianyu, > > added Stefano Babic to cc as he is the imx maintainer. > > Am 18.12.2015 um 10:38 schrieb Gong Qianyu: > > This could avoid executing the code that only applies to i.MX platforms. > > > > The bus_i2c_init() is called before relocation and will assgin value > > to a static variable. If U-Boot is then still running in a flash > > device, it's theoretically not allowed to write data to flash without > > an erasing operation. For i.MX platforms, the U-Boot is always running > > in DDR. > > > > Actually it causes asynchronous error when the ARM64 system error > > report is enabled and the flash write protect is set. > > > > Signed-off-by: Gong Qianyu <Qianyu.Gong@freescale.com> > > --- > > V3: > > - Sorry..Remove an unrelated line in other file. > > > > drivers/i2c/mxc_i2c.c | 12 ++++++++++-- > > 1 file changed, 10 insertions(+), 2 deletions(-) > > Ok, from my side, but it would be better to switch your board(s) to > support DM and get rid of this old stuff from this driver. > > Reviewed-by: Heiko Schocher <hs@denx.de> > > bye, > Heiko Thanks. But I have no control over this driver. Maybe they are considering to convert it later. Regards, Qianyu > > > > diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index > > fa4c82f..b2d15c9 100644 > > --- a/drivers/i2c/mxc_i2c.c > > +++ b/drivers/i2c/mxc_i2c.c > > @@ -581,8 +581,16 @@ void bus_i2c_init(int index, int speed, int unused, > > return; > > } > > > > - mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; > > - mxc_i2c_buses[index].idle_bus_data = idle_bus_data; > > + /* > > + * Warning: Be careful to allow the assignment to a static > > + * variable here. This function could be called while U-Boot is > > + * still running in flash memory. So such assignment is equal > > + * to write data to flash without erasing. > > + */ > > + if (idle_bus_fn) > > + mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; > > + if (idle_bus_data) > > + mxc_i2c_buses[index].idle_bus_data = idle_bus_data; > > > > ret = enable_i2c_clk(1, index); > > if (ret < 0) { > > > > -- > DENX Software Engineering GmbH, Managing Director: Wolfgang Denk > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is NULL 2015-12-21 5:41 ` Qianyu Gong @ 2015-12-30 9:27 ` Qianyu Gong 0 siblings, 0 replies; 5+ messages in thread From: Qianyu Gong @ 2015-12-30 9:27 UTC (permalink / raw) To: u-boot Hi Stefano, Could you please help to merge this patch? Thanks very much. Regards, Qianyu > -----Original Message----- > From: Qianyu Gong > Sent: Monday, December 21, 2015 1:42 PM > To: hs at denx.de; Gong Qianyu-B52263 <Qianyu.Gong@freescale.com> > Cc: u-boot at lists.denx.de; Stefano Babic <sbabic@denx.de> > Subject: RE: [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is > NULL > > > > > -----Original Message----- > > From: Heiko Schocher [mailto:hs at denx.de] > > Sent: Friday, December 18, 2015 6:24 PM > > To: Gong Qianyu-B52263 > > Cc: u-boot at lists.denx.de; Stefano Babic > > Subject: Re: [U-Boot] [Patch V3] i2c: mxc: add a condition in case the > > parameter is NULL > > > > Hello Gong Qianyu, > > > > added Stefano Babic to cc as he is the imx maintainer. > > > > Am 18.12.2015 um 10:38 schrieb Gong Qianyu: > > > This could avoid executing the code that only applies to i.MX platforms. > > > > > > The bus_i2c_init() is called before relocation and will assgin value > > > to a static variable. If U-Boot is then still running in a flash > > > device, it's theoretically not allowed to write data to flash > > > without an erasing operation. For i.MX platforms, the U-Boot is > > > always running in DDR. > > > > > > Actually it causes asynchronous error when the ARM64 system error > > > report is enabled and the flash write protect is set. > > > > > > Signed-off-by: Gong Qianyu <Qianyu.Gong@freescale.com> > > > --- > > > V3: > > > - Sorry..Remove an unrelated line in other file. > > > > > > drivers/i2c/mxc_i2c.c | 12 ++++++++++-- > > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > Ok, from my side, but it would be better to switch your board(s) to > > support DM and get rid of this old stuff from this driver. > > > > Reviewed-by: Heiko Schocher <hs@denx.de> > > > > bye, > > Heiko > > Thanks. But I have no control over this driver. Maybe they are considering to > convert it later. > > Regards, > Qianyu > > > > > > > diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index > > > fa4c82f..b2d15c9 100644 > > > --- a/drivers/i2c/mxc_i2c.c > > > +++ b/drivers/i2c/mxc_i2c.c > > > @@ -581,8 +581,16 @@ void bus_i2c_init(int index, int speed, int unused, > > > return; > > > } > > > > > > - mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; > > > - mxc_i2c_buses[index].idle_bus_data = idle_bus_data; > > > + /* > > > + * Warning: Be careful to allow the assignment to a static > > > + * variable here. This function could be called while U-Boot is > > > + * still running in flash memory. So such assignment is equal > > > + * to write data to flash without erasing. > > > + */ > > > + if (idle_bus_fn) > > > + mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; > > > + if (idle_bus_data) > > > + mxc_i2c_buses[index].idle_bus_data = idle_bus_data; > > > > > > ret = enable_i2c_clk(1, index); > > > if (ret < 0) { > > > > > > > -- > > DENX Software Engineering GmbH, Managing Director: Wolfgang Denk > > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is NULL 2015-12-18 9:38 [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is NULL Gong Qianyu 2015-12-18 10:24 ` Heiko Schocher @ 2016-01-03 15:02 ` Stefano Babic 1 sibling, 0 replies; 5+ messages in thread From: Stefano Babic @ 2016-01-03 15:02 UTC (permalink / raw) To: u-boot On 18/12/2015 10:38, Gong Qianyu wrote: > This could avoid executing the code that only applies to i.MX platforms. > > The bus_i2c_init() is called before relocation and will assgin value > to a static variable. If U-Boot is then still running in a flash > device, it's theoretically not allowed to write data to flash without > an erasing operation. For i.MX platforms, the U-Boot is always running > in DDR. > > Actually it causes asynchronous error when the ARM64 system error > report is enabled and the flash write protect is set. > > Signed-off-by: Gong Qianyu <Qianyu.Gong@freescale.com> > --- Applied to u-boot-imx, thanks! Best regards, Stefano Babic -- ===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de ===================================================================== ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-01-03 15:02 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-12-18 9:38 [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is NULL Gong Qianyu 2015-12-18 10:24 ` Heiko Schocher 2015-12-21 5:41 ` Qianyu Gong 2015-12-30 9:27 ` Qianyu Gong 2016-01-03 15:02 ` Stefano Babic
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.