* [PATCH] soc: imx8m: Increase the clock enable before reading the register
@ 2022-10-28 4:14 Xiaolei Wang
2022-11-11 2:46 ` Shawn Guo
0 siblings, 1 reply; 6+ messages in thread
From: Xiaolei Wang @ 2022-10-28 4:14 UTC (permalink / raw)
To: shawnguo, s.hauer, kernel, festevam
Cc: l.stach, linux-imx, linux-arm-kernel, linux-kernel
When executing kdump to start the second kernel,
since IMX-OCOTP has turned off the clock, the clock
needs to be re-enabled, otherwise the system will hang.
Fixes: ac34de14ac30 ("Revert "soc: imx8m: change to use platform driver"")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
---
drivers/soc/imx/soc-imx8m.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
index cc57a384d74d..28144c699b0c 100644
--- a/drivers/soc/imx/soc-imx8m.c
+++ b/drivers/soc/imx/soc-imx8m.c
@@ -11,6 +11,7 @@
#include <linux/platform_device.h>
#include <linux/arm-smccc.h>
#include <linux/of.h>
+#include <linux/clk.h>
#define REV_B1 0x21
@@ -56,6 +57,7 @@ static u32 __init imx8mq_soc_revision(void)
void __iomem *ocotp_base;
u32 magic;
u32 rev;
+ struct clk *clk;
np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp");
if (!np)
@@ -63,6 +65,13 @@ static u32 __init imx8mq_soc_revision(void)
ocotp_base = of_iomap(np, 0);
WARN_ON(!ocotp_base);
+ clk = of_clk_get_by_name(np, NULL);
+ if (!clk) {
+ WARN_ON(!clk);
+ return 0;
+ }
+
+ clk_prepare_enable(clk);
/*
* SOC revision on older imx8mq is not available in fuses so query
@@ -79,6 +88,8 @@ static u32 __init imx8mq_soc_revision(void)
soc_uid <<= 32;
soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
+ clk_disable_unprepare(clk);
+ clk_put(clk);
iounmap(ocotp_base);
of_node_put(np);
--
2.25.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] 6+ messages in thread* Re: [PATCH] soc: imx8m: Increase the clock enable before reading the register
2022-10-28 4:14 [PATCH] soc: imx8m: Increase the clock enable before reading the register Xiaolei Wang
@ 2022-11-11 2:46 ` Shawn Guo
2022-11-11 3:01 ` Wang, Xiaolei
0 siblings, 1 reply; 6+ messages in thread
From: Shawn Guo @ 2022-11-11 2:46 UTC (permalink / raw)
To: Xiaolei Wang
Cc: s.hauer, kernel, festevam, l.stach, linux-imx, linux-arm-kernel,
linux-kernel
On Fri, Oct 28, 2022 at 12:14:18PM +0800, Xiaolei Wang wrote:
> When executing kdump to start the second kernel,
> since IMX-OCOTP has turned off the clock, the clock
> needs to be re-enabled, otherwise the system will hang.
>
> Fixes: ac34de14ac30 ("Revert "soc: imx8m: change to use platform driver"")
Are you saying this fixes a regression caused by ac34de14ac30?
Shawn
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> ---
> drivers/soc/imx/soc-imx8m.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
> index cc57a384d74d..28144c699b0c 100644
> --- a/drivers/soc/imx/soc-imx8m.c
> +++ b/drivers/soc/imx/soc-imx8m.c
> @@ -11,6 +11,7 @@
> #include <linux/platform_device.h>
> #include <linux/arm-smccc.h>
> #include <linux/of.h>
> +#include <linux/clk.h>
>
> #define REV_B1 0x21
>
> @@ -56,6 +57,7 @@ static u32 __init imx8mq_soc_revision(void)
> void __iomem *ocotp_base;
> u32 magic;
> u32 rev;
> + struct clk *clk;
>
> np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp");
> if (!np)
> @@ -63,6 +65,13 @@ static u32 __init imx8mq_soc_revision(void)
>
> ocotp_base = of_iomap(np, 0);
> WARN_ON(!ocotp_base);
> + clk = of_clk_get_by_name(np, NULL);
> + if (!clk) {
> + WARN_ON(!clk);
> + return 0;
> + }
> +
> + clk_prepare_enable(clk);
>
> /*
> * SOC revision on older imx8mq is not available in fuses so query
> @@ -79,6 +88,8 @@ static u32 __init imx8mq_soc_revision(void)
> soc_uid <<= 32;
> soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
>
> + clk_disable_unprepare(clk);
> + clk_put(clk);
> iounmap(ocotp_base);
> of_node_put(np);
>
> --
> 2.25.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] soc: imx8m: Increase the clock enable before reading the register
2022-11-11 2:46 ` Shawn Guo
@ 2022-11-11 3:01 ` Wang, Xiaolei
2022-11-11 3:53 ` Shawn Guo
0 siblings, 1 reply; 6+ messages in thread
From: Wang, Xiaolei @ 2022-11-11 3:01 UTC (permalink / raw)
To: Shawn Guo
Cc: s.hauer, kernel, festevam, l.stach, linux-imx, linux-arm-kernel,
linux-kernel
On 11/11/2022 10:46 AM, Shawn Guo wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> On Fri, Oct 28, 2022 at 12:14:18PM +0800, Xiaolei Wang wrote:
>> When executing kdump to start the second kernel,
>> since IMX-OCOTP has turned off the clock, the clock
>> needs to be re-enabled, otherwise the system will hang.
>>
>> Fixes: ac34de14ac30 ("Revert "soc: imx8m: change to use platform driver"")
> Are you saying this fixes a regression caused by ac34de14ac30?
Yes,
Although there is a problem with commit 7d981405d0fd, it also solves the
kexec kernel hang, commit 7d981405d0fd is reverted, and the kexec kernel
hang will also be introduced, so the clock needs to be enabled when the
kexec kernel starts.
thanks
xiaolei
>
> Shawn
>
>> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
>> ---
>> drivers/soc/imx/soc-imx8m.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
>> index cc57a384d74d..28144c699b0c 100644
>> --- a/drivers/soc/imx/soc-imx8m.c
>> +++ b/drivers/soc/imx/soc-imx8m.c
>> @@ -11,6 +11,7 @@
>> #include <linux/platform_device.h>
>> #include <linux/arm-smccc.h>
>> #include <linux/of.h>
>> +#include <linux/clk.h>
>>
>> #define REV_B1 0x21
>>
>> @@ -56,6 +57,7 @@ static u32 __init imx8mq_soc_revision(void)
>> void __iomem *ocotp_base;
>> u32 magic;
>> u32 rev;
>> + struct clk *clk;
>>
>> np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp");
>> if (!np)
>> @@ -63,6 +65,13 @@ static u32 __init imx8mq_soc_revision(void)
>>
>> ocotp_base = of_iomap(np, 0);
>> WARN_ON(!ocotp_base);
>> + clk = of_clk_get_by_name(np, NULL);
>> + if (!clk) {
>> + WARN_ON(!clk);
>> + return 0;
>> + }
>> +
>> + clk_prepare_enable(clk);
>>
>> /*
>> * SOC revision on older imx8mq is not available in fuses so query
>> @@ -79,6 +88,8 @@ static u32 __init imx8mq_soc_revision(void)
>> soc_uid <<= 32;
>> soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
>>
>> + clk_disable_unprepare(clk);
>> + clk_put(clk);
>> iounmap(ocotp_base);
>> of_node_put(np);
>>
>> --
>> 2.25.1
>>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] soc: imx8m: Increase the clock enable before reading the register
2022-11-11 3:01 ` Wang, Xiaolei
@ 2022-11-11 3:53 ` Shawn Guo
2022-11-11 9:05 ` Lucas Stach
0 siblings, 1 reply; 6+ messages in thread
From: Shawn Guo @ 2022-11-11 3:53 UTC (permalink / raw)
To: Wang, Xiaolei, l.stach
Cc: s.hauer, kernel, festevam, linux-imx, linux-arm-kernel,
linux-kernel
On Fri, Nov 11, 2022 at 11:01:15AM +0800, Wang, Xiaolei wrote:
>
> On 11/11/2022 10:46 AM, Shawn Guo wrote:
> > CAUTION: This email comes from a non Wind River email account!
> > Do not click links or open attachments unless you recognize the sender and know the content is safe.
> >
> > On Fri, Oct 28, 2022 at 12:14:18PM +0800, Xiaolei Wang wrote:
> > > When executing kdump to start the second kernel,
> > > since IMX-OCOTP has turned off the clock, the clock
> > > needs to be re-enabled, otherwise the system will hang.
> > >
> > > Fixes: ac34de14ac30 ("Revert "soc: imx8m: change to use platform driver"")
> > Are you saying this fixes a regression caused by ac34de14ac30?
>
>
> Yes,
>
> Although there is a problem with commit 7d981405d0fd, it also solves the
> kexec kernel hang, commit 7d981405d0fd is reverted, and the kexec kernel
> hang will also be introduced, so the clock needs to be enabled when the
> kexec kernel starts.
Ok.
Lucas,
Any comments here?
Shawn
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] soc: imx8m: Increase the clock enable before reading the register
2022-11-11 3:53 ` Shawn Guo
@ 2022-11-11 9:05 ` Lucas Stach
2022-11-14 8:20 ` Shawn Guo
0 siblings, 1 reply; 6+ messages in thread
From: Lucas Stach @ 2022-11-11 9:05 UTC (permalink / raw)
To: Shawn Guo, Wang, Xiaolei
Cc: s.hauer, kernel, festevam, linux-imx, linux-arm-kernel,
linux-kernel
Am Freitag, dem 11.11.2022 um 11:53 +0800 schrieb Shawn Guo:
> On Fri, Nov 11, 2022 at 11:01:15AM +0800, Wang, Xiaolei wrote:
> >
> > On 11/11/2022 10:46 AM, Shawn Guo wrote:
> > > CAUTION: This email comes from a non Wind River email account!
> > > Do not click links or open attachments unless you recognize the sender and know the content is safe.
> > >
> > > On Fri, Oct 28, 2022 at 12:14:18PM +0800, Xiaolei Wang wrote:
> > > > When executing kdump to start the second kernel,
> > > > since IMX-OCOTP has turned off the clock, the clock
> > > > needs to be re-enabled, otherwise the system will hang.
> > > >
> > > > Fixes: ac34de14ac30 ("Revert "soc: imx8m: change to use platform driver"")
> > > Are you saying this fixes a regression caused by ac34de14ac30?
> >
> >
> > Yes,
> >
> > Although there is a problem with commit 7d981405d0fd, it also solves the
> > kexec kernel hang, commit 7d981405d0fd is reverted, and the kexec kernel
> > hang will also be introduced, so the clock needs to be enabled when the
> > kexec kernel starts.
>
> Ok.
>
> Lucas,
>
> Any comments here?
Yea, the explanation with kdump in the commit message is a tad too
specific I think. The simple fact is: OCOTP register access needs the
OCOTP clock to be running and this code peeks into this register
region, so it needs to ensure the clock is active.
Other than this minor issue with the commit message, the change itself
looks fine:
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Regards,
Lucas
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] soc: imx8m: Increase the clock enable before reading the register
2022-11-11 9:05 ` Lucas Stach
@ 2022-11-14 8:20 ` Shawn Guo
0 siblings, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2022-11-14 8:20 UTC (permalink / raw)
To: Lucas Stach
Cc: Wang, Xiaolei, s.hauer, kernel, festevam, linux-imx,
linux-arm-kernel, linux-kernel
On Fri, Nov 11, 2022 at 10:05:21AM +0100, Lucas Stach wrote:
> Am Freitag, dem 11.11.2022 um 11:53 +0800 schrieb Shawn Guo:
> > On Fri, Nov 11, 2022 at 11:01:15AM +0800, Wang, Xiaolei wrote:
> > >
> > > On 11/11/2022 10:46 AM, Shawn Guo wrote:
> > > > CAUTION: This email comes from a non Wind River email account!
> > > > Do not click links or open attachments unless you recognize the sender and know the content is safe.
> > > >
> > > > On Fri, Oct 28, 2022 at 12:14:18PM +0800, Xiaolei Wang wrote:
> > > > > When executing kdump to start the second kernel,
> > > > > since IMX-OCOTP has turned off the clock, the clock
> > > > > needs to be re-enabled, otherwise the system will hang.
> > > > >
> > > > > Fixes: ac34de14ac30 ("Revert "soc: imx8m: change to use platform driver"")
> > > > Are you saying this fixes a regression caused by ac34de14ac30?
> > >
> > >
> > > Yes,
> > >
> > > Although there is a problem with commit 7d981405d0fd, it also solves the
> > > kexec kernel hang, commit 7d981405d0fd is reverted, and the kexec kernel
> > > hang will also be introduced, so the clock needs to be enabled when the
> > > kexec kernel starts.
> >
> > Ok.
> >
> > Lucas,
> >
> > Any comments here?
>
> Yea, the explanation with kdump in the commit message is a tad too
> specific I think. The simple fact is: OCOTP register access needs the
> OCOTP clock to be running and this code peeks into this register
> region, so it needs to ensure the clock is active.
>
> Other than this minor issue with the commit message, the change itself
> looks fine:
> Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Thanks for the review and comment, Lucas! I reworded the subject and
commit log a bit like below, and applied the patch, thanks!
---8<------
soc: imx8m: Enable OCOTP clock before reading the register
Commit 7d981405d0fd ("soc: imx8m: change to use platform driver") ever
removed the dependency on bootloader for enabling OCOTP clock. It
helped to fix a kexec kernel hang issue. But unfortunately it caused
a regression on CAAM driver and got reverted.
This is the second try to enable the OCOTP clock by directly calling
clock API instead of indirectly enabling the clock via nvmem API.
Fixes: ac34de14ac30 ("Revert "soc: imx8m: change to use platform driver"")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-14 8:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-28 4:14 [PATCH] soc: imx8m: Increase the clock enable before reading the register Xiaolei Wang
2022-11-11 2:46 ` Shawn Guo
2022-11-11 3:01 ` Wang, Xiaolei
2022-11-11 3:53 ` Shawn Guo
2022-11-11 9:05 ` Lucas Stach
2022-11-14 8:20 ` Shawn Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).