All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0
@ 2017-11-12 18:34 ` Martin Blumenstingl
  0 siblings, 0 replies; 9+ messages in thread
From: Martin Blumenstingl @ 2017-11-12 18:34 UTC (permalink / raw)
  To: linux-arm-kernel

meson_mx_efuse_read calculates the address internal to the eFuse based
on the offset and the word size. This works fine with any given offset.
However, the offset is also included when writing to the output buffer.
This means that reading 4 bytes at offset 500 tries to write beyond the
array allocated by the nvmem core as it wants to write the 4 bytes to
"buffer address + offset (500)".
This issue did not show up in the previous tests since no driver uses
any value from the eFuse yet and reading the eFuse via sysfs simply
reads the whole eFuse, starting at offset 0.

Fix this by only including the offset in the internal address
calculation.

Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/nvmem/meson-mx-efuse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/meson-mx-efuse.c b/drivers/nvmem/meson-mx-efuse.c
index a346b4923550..41d3a3c1104e 100644
--- a/drivers/nvmem/meson-mx-efuse.c
+++ b/drivers/nvmem/meson-mx-efuse.c
@@ -156,8 +156,8 @@ static int meson_mx_efuse_read(void *context, unsigned int offset,
 				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE,
 				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE);
 
-	for (i = offset; i < offset + bytes; i += efuse->config.word_size) {
-		addr = i / efuse->config.word_size;
+	for (i = 0; i < bytes; i += efuse->config.word_size) {
+		addr = (offset + i) / efuse->config.word_size;
 
 		err = meson_mx_efuse_read_addr(efuse, addr, &tmp);
 		if (err)
-- 
2.15.0

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

* [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0
@ 2017-11-12 18:34 ` Martin Blumenstingl
  0 siblings, 0 replies; 9+ messages in thread
From: Martin Blumenstingl @ 2017-11-12 18:34 UTC (permalink / raw)
  To: linus-amlogic

meson_mx_efuse_read calculates the address internal to the eFuse based
on the offset and the word size. This works fine with any given offset.
However, the offset is also included when writing to the output buffer.
This means that reading 4 bytes at offset 500 tries to write beyond the
array allocated by the nvmem core as it wants to write the 4 bytes to
"buffer address + offset (500)".
This issue did not show up in the previous tests since no driver uses
any value from the eFuse yet and reading the eFuse via sysfs simply
reads the whole eFuse, starting at offset 0.

Fix this by only including the offset in the internal address
calculation.

Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/nvmem/meson-mx-efuse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/meson-mx-efuse.c b/drivers/nvmem/meson-mx-efuse.c
index a346b4923550..41d3a3c1104e 100644
--- a/drivers/nvmem/meson-mx-efuse.c
+++ b/drivers/nvmem/meson-mx-efuse.c
@@ -156,8 +156,8 @@ static int meson_mx_efuse_read(void *context, unsigned int offset,
 				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE,
 				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE);
 
-	for (i = offset; i < offset + bytes; i += efuse->config.word_size) {
-		addr = i / efuse->config.word_size;
+	for (i = 0; i < bytes; i += efuse->config.word_size) {
+		addr = (offset + i) / efuse->config.word_size;
 
 		err = meson_mx_efuse_read_addr(efuse, addr, &tmp);
 		if (err)
-- 
2.15.0

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

* [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0
  2017-11-12 18:34 ` Martin Blumenstingl
@ 2017-12-01 21:24   ` Martin Blumenstingl
  -1 siblings, 0 replies; 9+ messages in thread
From: Martin Blumenstingl @ 2017-12-01 21:24 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Srinivas, Hi Greg,

On Sun, Nov 12, 2017 at 7:34 PM, Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
> meson_mx_efuse_read calculates the address internal to the eFuse based
> on the offset and the word size. This works fine with any given offset.
> However, the offset is also included when writing to the output buffer.
> This means that reading 4 bytes at offset 500 tries to write beyond the
> array allocated by the nvmem core as it wants to write the 4 bytes to
> "buffer address + offset (500)".
> This issue did not show up in the previous tests since no driver uses
> any value from the eFuse yet and reading the eFuse via sysfs simply
> reads the whole eFuse, starting at offset 0.
>
> Fix this by only including the offset in the internal address
> calculation.
>
> Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs")
if you don't have any comments on this patch: could you please queue
it as a fix for 4.15 (which is where above commit landed)?


thank you!
Regards
Martin

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

* [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0
@ 2017-12-01 21:24   ` Martin Blumenstingl
  0 siblings, 0 replies; 9+ messages in thread
From: Martin Blumenstingl @ 2017-12-01 21:24 UTC (permalink / raw)
  To: linus-amlogic

Hi Srinivas, Hi Greg,

On Sun, Nov 12, 2017 at 7:34 PM, Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
> meson_mx_efuse_read calculates the address internal to the eFuse based
> on the offset and the word size. This works fine with any given offset.
> However, the offset is also included when writing to the output buffer.
> This means that reading 4 bytes at offset 500 tries to write beyond the
> array allocated by the nvmem core as it wants to write the 4 bytes to
> "buffer address + offset (500)".
> This issue did not show up in the previous tests since no driver uses
> any value from the eFuse yet and reading the eFuse via sysfs simply
> reads the whole eFuse, starting at offset 0.
>
> Fix this by only including the offset in the internal address
> calculation.
>
> Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs")
if you don't have any comments on this patch: could you please queue
it as a fix for 4.15 (which is where above commit landed)?


thank you!
Regards
Martin

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

* [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0
  2017-12-01 21:24   ` Martin Blumenstingl
@ 2017-12-10 18:03     ` Martin Blumenstingl
  -1 siblings, 0 replies; 9+ messages in thread
From: Martin Blumenstingl @ 2017-12-10 18:03 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Srinivas, Hi Greg,

On Fri, Dec 1, 2017 at 10:24 PM, Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
> Hi Srinivas, Hi Greg,
>
> On Sun, Nov 12, 2017 at 7:34 PM, Martin Blumenstingl
> <martin.blumenstingl@googlemail.com> wrote:
>> meson_mx_efuse_read calculates the address internal to the eFuse based
>> on the offset and the word size. This works fine with any given offset.
>> However, the offset is also included when writing to the output buffer.
>> This means that reading 4 bytes at offset 500 tries to write beyond the
>> array allocated by the nvmem core as it wants to write the 4 bytes to
>> "buffer address + offset (500)".
>> This issue did not show up in the previous tests since no driver uses
>> any value from the eFuse yet and reading the eFuse via sysfs simply
>> reads the whole eFuse, starting at offset 0.
>>
>> Fix this by only including the offset in the internal address
>> calculation.
>>
>> Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs")
> if you don't have any comments on this patch: could you please queue
> it as a fix for 4.15 (which is where above commit landed)?
(gentle ping) do you have any comments for this patch?


Regards
Martin

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

* [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0
@ 2017-12-10 18:03     ` Martin Blumenstingl
  0 siblings, 0 replies; 9+ messages in thread
From: Martin Blumenstingl @ 2017-12-10 18:03 UTC (permalink / raw)
  To: linus-amlogic

Hi Srinivas, Hi Greg,

On Fri, Dec 1, 2017 at 10:24 PM, Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
> Hi Srinivas, Hi Greg,
>
> On Sun, Nov 12, 2017 at 7:34 PM, Martin Blumenstingl
> <martin.blumenstingl@googlemail.com> wrote:
>> meson_mx_efuse_read calculates the address internal to the eFuse based
>> on the offset and the word size. This works fine with any given offset.
>> However, the offset is also included when writing to the output buffer.
>> This means that reading 4 bytes at offset 500 tries to write beyond the
>> array allocated by the nvmem core as it wants to write the 4 bytes to
>> "buffer address + offset (500)".
>> This issue did not show up in the previous tests since no driver uses
>> any value from the eFuse yet and reading the eFuse via sysfs simply
>> reads the whole eFuse, starting at offset 0.
>>
>> Fix this by only including the offset in the internal address
>> calculation.
>>
>> Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs")
> if you don't have any comments on this patch: could you please queue
> it as a fix for 4.15 (which is where above commit landed)?
(gentle ping) do you have any comments for this patch?


Regards
Martin

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

* [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0
  2017-11-12 18:34 ` Martin Blumenstingl
@ 2017-12-11 11:48   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 9+ messages in thread
From: Srinivas Kandagatla @ 2017-12-11 11:48 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Martin,
On 12/11/17 18:34, Martin Blumenstingl wrote:
> meson_mx_efuse_read calculates the address internal to the eFuse based
> on the offset and the word size. This works fine with any given offset.
> However, the offset is also included when writing to the output buffer.
> This means that reading 4 bytes at offset 500 tries to write beyond the
> array allocated by the nvmem core as it wants to write the 4 bytes to
> "buffer address + offset (500)".
> This issue did not show up in the previous tests since no driver uses
> any value from the eFuse yet and reading the eFuse via sysfs simply
> reads the whole eFuse, starting at offset 0.
> 
> Fix this by only including the offset in the internal address
> calculation.
> 
> Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
Thanks for your patience,

I will send this to Greg along with other fixes some time this week!

thanks,
srini



>   drivers/nvmem/meson-mx-efuse.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvmem/meson-mx-efuse.c b/drivers/nvmem/meson-mx-efuse.c
> index a346b4923550..41d3a3c1104e 100644
> --- a/drivers/nvmem/meson-mx-efuse.c
> +++ b/drivers/nvmem/meson-mx-efuse.c
> @@ -156,8 +156,8 @@ static int meson_mx_efuse_read(void *context, unsigned int offset,
>   				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE,
>   				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE);
>   
> -	for (i = offset; i < offset + bytes; i += efuse->config.word_size) {
> -		addr = i / efuse->config.word_size;
> +	for (i = 0; i < bytes; i += efuse->config.word_size) {
> +		addr = (offset + i) / efuse->config.word_size;
>   
>   		err = meson_mx_efuse_read_addr(efuse, addr, &tmp);
>   		if (err)
> 

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

* [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0
@ 2017-12-11 11:48   ` Srinivas Kandagatla
  0 siblings, 0 replies; 9+ messages in thread
From: Srinivas Kandagatla @ 2017-12-11 11:48 UTC (permalink / raw)
  To: linus-amlogic

Hi Martin,
On 12/11/17 18:34, Martin Blumenstingl wrote:
> meson_mx_efuse_read calculates the address internal to the eFuse based
> on the offset and the word size. This works fine with any given offset.
> However, the offset is also included when writing to the output buffer.
> This means that reading 4 bytes at offset 500 tries to write beyond the
> array allocated by the nvmem core as it wants to write the 4 bytes to
> "buffer address + offset (500)".
> This issue did not show up in the previous tests since no driver uses
> any value from the eFuse yet and reading the eFuse via sysfs simply
> reads the whole eFuse, starting at offset 0.
> 
> Fix this by only including the offset in the internal address
> calculation.
> 
> Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
Thanks for your patience,

I will send this to Greg along with other fixes some time this week!

thanks,
srini



>   drivers/nvmem/meson-mx-efuse.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvmem/meson-mx-efuse.c b/drivers/nvmem/meson-mx-efuse.c
> index a346b4923550..41d3a3c1104e 100644
> --- a/drivers/nvmem/meson-mx-efuse.c
> +++ b/drivers/nvmem/meson-mx-efuse.c
> @@ -156,8 +156,8 @@ static int meson_mx_efuse_read(void *context, unsigned int offset,
>   				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE,
>   				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE);
>   
> -	for (i = offset; i < offset + bytes; i += efuse->config.word_size) {
> -		addr = i / efuse->config.word_size;
> +	for (i = 0; i < bytes; i += efuse->config.word_size) {
> +		addr = (offset + i) / efuse->config.word_size;
>   
>   		err = meson_mx_efuse_read_addr(efuse, addr, &tmp);
>   		if (err)
> 

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

* [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0
@ 2017-12-15 13:42 srinivas.kandagatla
  0 siblings, 0 replies; 9+ messages in thread
From: srinivas.kandagatla @ 2017-12-15 13:42 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, srinivas.kandagatla, Martin Blumenstingl

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

meson_mx_efuse_read calculates the address internal to the eFuse based
on the offset and the word size. This works fine with any given offset.
However, the offset is also included when writing to the output buffer.
This means that reading 4 bytes at offset 500 tries to write beyond the
array allocated by the nvmem core as it wants to write the 4 bytes to
"buffer address + offset (500)".
This issue did not show up in the previous tests since no driver uses
any value from the eFuse yet and reading the eFuse via sysfs simply
reads the whole eFuse, starting at offset 0.

Fix this by only including the offset in the internal address
calculation.

Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
Hi Greg, 

Can you pick this patch up for next possible RC cycle.

Thanks,
Srini

 drivers/nvmem/meson-mx-efuse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/meson-mx-efuse.c b/drivers/nvmem/meson-mx-efuse.c
index a346b4923550..41d3a3c1104e 100644
--- a/drivers/nvmem/meson-mx-efuse.c
+++ b/drivers/nvmem/meson-mx-efuse.c
@@ -156,8 +156,8 @@ static int meson_mx_efuse_read(void *context, unsigned int offset,
 				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE,
 				 MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE);
 
-	for (i = offset; i < offset + bytes; i += efuse->config.word_size) {
-		addr = i / efuse->config.word_size;
+	for (i = 0; i < bytes; i += efuse->config.word_size) {
+		addr = (offset + i) / efuse->config.word_size;
 
 		err = meson_mx_efuse_read_addr(efuse, addr, &tmp);
 		if (err)
-- 
2.15.0

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

end of thread, other threads:[~2017-12-15 13:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-12 18:34 [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0 Martin Blumenstingl
2017-11-12 18:34 ` Martin Blumenstingl
2017-12-01 21:24 ` Martin Blumenstingl
2017-12-01 21:24   ` Martin Blumenstingl
2017-12-10 18:03   ` Martin Blumenstingl
2017-12-10 18:03     ` Martin Blumenstingl
2017-12-11 11:48 ` Srinivas Kandagatla
2017-12-11 11:48   ` Srinivas Kandagatla
2017-12-15 13:42 srinivas.kandagatla

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.