All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rockchip_rk3288_efuse_read: Fix segfault in rockchip_rk3288_efuse_read by using readl instead of readb when reading REG_EFUSE_DOUT.
@ 2019-10-05  7:50 ` Amr Bekhit
  0 siblings, 0 replies; 2+ messages in thread
From: Amr Bekhit @ 2019-10-05  7:50 UTC (permalink / raw)
  To: heiko-4mtYJXux2i+zQB+pC5nmwQ, wxt-TNX95d0MmH7DzftRWevZcw
  Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

When trying to read the efuse of the RK3188 a segfault is raised when
the following line is called in rockchip_rk3288_efuse_read:

*buf++ = readb(efuse->base + REG_EFUSE_DOUT);

It appears that the problem here might be the use of readb, which I
suspect is triggering an unaligned access. Changing this to readl
resolves the issue (as is done in rockchip_rk3399_efuse_read).

From 9923a6889aa325faf842a6757c9f9bd0f0195acb Mon Sep 17 00:00:00 2001
From: Amr Bekhit <amr-X1kpDkasp4NBDgjK7y7TUQ@public.gmane.org>
Date: Sat, 5 Oct 2019 10:45:17 +0300
Subject: [PATCH] Fix segfault in rockchip_rk3288_efuse_read by using readl
 instead of readb when reading REG_EFUSE_DOUT.

Signed-off-by: Amr Bekhit <amr-X1kpDkasp4NBDgjK7y7TUQ@public.gmane.org>
---
 drivers/nvmem/rockchip-efuse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/rockchip-efuse.c b/drivers/nvmem/rockchip-efuse.c
index e4579de5d014..f680a80d81cf 100644
--- a/drivers/nvmem/rockchip-efuse.c
+++ b/drivers/nvmem/rockchip-efuse.c
@@ -78,7 +78,7 @@ static int rockchip_rk3288_efuse_read(void *context,
unsigned int offset,
  writel(readl(efuse->base + REG_EFUSE_CTRL) |
       RK3288_STROBE, efuse->base + REG_EFUSE_CTRL);
  udelay(1);
- *buf++ = readb(efuse->base + REG_EFUSE_DOUT);
+ *buf++ = readl(efuse->base + REG_EFUSE_DOUT);
  writel(readl(efuse->base + REG_EFUSE_CTRL) &
         (~RK3288_STROBE), efuse->base + REG_EFUSE_CTRL);
  udelay(1);
-- 
2.20.1

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

* [PATCH] rockchip_rk3288_efuse_read: Fix segfault in rockchip_rk3288_efuse_read by using readl instead of readb when reading REG_EFUSE_DOUT.
@ 2019-10-05  7:50 ` Amr Bekhit
  0 siblings, 0 replies; 2+ messages in thread
From: Amr Bekhit @ 2019-10-05  7:50 UTC (permalink / raw)
  To: heiko, wxt; +Cc: linux-rockchip, linux-arm-kernel

When trying to read the efuse of the RK3188 a segfault is raised when
the following line is called in rockchip_rk3288_efuse_read:

*buf++ = readb(efuse->base + REG_EFUSE_DOUT);

It appears that the problem here might be the use of readb, which I
suspect is triggering an unaligned access. Changing this to readl
resolves the issue (as is done in rockchip_rk3399_efuse_read).

From 9923a6889aa325faf842a6757c9f9bd0f0195acb Mon Sep 17 00:00:00 2001
From: Amr Bekhit <amr@helmpcb.com>
Date: Sat, 5 Oct 2019 10:45:17 +0300
Subject: [PATCH] Fix segfault in rockchip_rk3288_efuse_read by using readl
 instead of readb when reading REG_EFUSE_DOUT.

Signed-off-by: Amr Bekhit <amr@helmpcb.com>
---
 drivers/nvmem/rockchip-efuse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/rockchip-efuse.c b/drivers/nvmem/rockchip-efuse.c
index e4579de5d014..f680a80d81cf 100644
--- a/drivers/nvmem/rockchip-efuse.c
+++ b/drivers/nvmem/rockchip-efuse.c
@@ -78,7 +78,7 @@ static int rockchip_rk3288_efuse_read(void *context,
unsigned int offset,
  writel(readl(efuse->base + REG_EFUSE_CTRL) |
       RK3288_STROBE, efuse->base + REG_EFUSE_CTRL);
  udelay(1);
- *buf++ = readb(efuse->base + REG_EFUSE_DOUT);
+ *buf++ = readl(efuse->base + REG_EFUSE_DOUT);
  writel(readl(efuse->base + REG_EFUSE_CTRL) &
         (~RK3288_STROBE), efuse->base + REG_EFUSE_CTRL);
  udelay(1);
-- 
2.20.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-10-05  7:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-05  7:50 [PATCH] rockchip_rk3288_efuse_read: Fix segfault in rockchip_rk3288_efuse_read by using readl instead of readb when reading REG_EFUSE_DOUT Amr Bekhit
2019-10-05  7:50 ` Amr Bekhit

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.