soc: imx8m: Increase the clock enable before reading the register
PATCH 1/1 soc: imx8m: Increase the clock enable before reading the register
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.
--- drivers/soc/imx/soc-imx8m.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/soc/imx/soc-imx8m.c +11 -0
@@ -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);
Signature · 1 line
2.25.1
Quoted 5 lines · Xiaolei Wang
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
Quoted 51 lines
Signed-off-by Xiaolei Wang <[email protected]>--- drivers/soc/imx/soc-imx8m.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/soc/imx/soc-imx8m.c +11
-0@@ -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);Signature · 1 line
2.25.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 10 lines · Shawn Guo
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.Quoted 5 lines · Xiaolei Wang
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
Quoted 54 lines
Shawn
Quoted 51 lines
Signed-off-by Xiaolei Wang <[email protected]>--- drivers/soc/imx/soc-imx8m.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/soc/imx/soc-imx8m.c +11
-1@@ -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
Quoted 14 lines · Xiaolei
Quoted 10 lines · Shawn Guo
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.Quoted 5 lines · Xiaolei Wang
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?
Quoted 6 lines
Yes,
Although there is a problem with commit
7d981405d0fd, it also solves the kexec kernel hang, commit7d981405d0fdis 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
Lucas Stach
Reviewed-byAm Freitag, dem 11.11.2022 um 11:53 +0800 schrieb Shawn Guo:
Quoted 22 lines · Xiaolei
Quoted 14 lines · Shawn Guo
Quoted 10 lines
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.Quoted 5 lines · Xiaolei Wang
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?Quoted 6 lines
Yes,
Although there is a problem with commit
7d981405d0fd, it also solves the kexec kernel hang, commit7d981405d0fdis reverted, and the kexec kernel hang will also be introduced, so the clock needs to be enabled when the kexec kernel starts.
Quoted 5 lines
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:
Regards,
Lucas
Shawn Guo
Reviewed-by Lucas StachQuoted 29 lines · Lucas Stach
Am Freitag, dem 11.11.2022 um 11:53 +0800 schrieb Shawn Guo:
Quoted 22 lines · Xiaolei
Quoted 14 lines · Shawn Guo
Quoted 10 lines
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.Quoted 5 lines · Xiaolei Wang
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?Quoted 6 lines
Yes,
Although there is a problem with commit
7d981405d0fd, it also solves the kexec kernel hang, commit7d981405d0fdis reverted, and the kexec kernel hang will also be introduced, so the clock needs to be enabled when the kexec kernel starts.Quoted 5 lines
Ok.
Lucas,
Any comments here?
Quoted 8 lines
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 <[email protected]>
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.