linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.8 07/20] RISC-V: Take text_mutex in ftrace_init_nop()
       [not found] <20200921144027.2135390-1-sashal@kernel.org>
@ 2020-09-21 14:40 ` Sasha Levin
  2020-09-21 14:40 ` [PATCH AUTOSEL 5.8 20/20] riscv: Fix Kendryte K210 device tree Sasha Levin
  1 sibling, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2020-09-21 14:40 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Sasha Levin, linux-riscv, Palmer Dabbelt, Guo Ren

From: Palmer Dabbelt <palmerdabbelt@google.com>

[ Upstream commit 66d18dbda8469a944dfec6c49d26d5946efba218 ]

Without this we get lockdep failures.  They're spurious failures as SMP isn't
up when ftrace_init_nop() is called.  As far as I can tell the easiest fix is
to just take the lock, which also seems like the safest fix.

Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Acked-by: Guo Ren <guoren@kernel.org>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/riscv/include/asm/ftrace.h |  7 +++++++
 arch/riscv/kernel/ftrace.c      | 19 +++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h
index ace8a6e2d11d3..845002cc2e571 100644
--- a/arch/riscv/include/asm/ftrace.h
+++ b/arch/riscv/include/asm/ftrace.h
@@ -66,6 +66,13 @@ do {									\
  * Let auipc+jalr be the basic *mcount unit*, so we make it 8 bytes here.
  */
 #define MCOUNT_INSN_SIZE 8
+
+#ifndef __ASSEMBLY__
+struct dyn_ftrace;
+int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
+#define ftrace_init_nop ftrace_init_nop
+#endif
+
 #endif
 
 #endif /* _ASM_RISCV_FTRACE_H */
diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
index 2ff63d0cbb500..99e12faa54986 100644
--- a/arch/riscv/kernel/ftrace.c
+++ b/arch/riscv/kernel/ftrace.c
@@ -97,6 +97,25 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
 	return __ftrace_modify_call(rec->ip, addr, false);
 }
 
+
+/*
+ * This is called early on, and isn't wrapped by
+ * ftrace_arch_code_modify_{prepare,post_process}() and therefor doesn't hold
+ * text_mutex, which triggers a lockdep failure.  SMP isn't running so we could
+ * just directly poke the text, but it's simpler to just take the lock
+ * ourselves.
+ */
+int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
+{
+	int out;
+
+	ftrace_arch_code_modify_prepare();
+	out = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
+	ftrace_arch_code_modify_post_process();
+
+	return out;
+}
+
 int ftrace_update_ftrace_func(ftrace_func_t func)
 {
 	int ret = __ftrace_modify_call((unsigned long)&ftrace_call,
-- 
2.25.1


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

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

* [PATCH AUTOSEL 5.8 20/20] riscv: Fix Kendryte K210 device tree
       [not found] <20200921144027.2135390-1-sashal@kernel.org>
  2020-09-21 14:40 ` [PATCH AUTOSEL 5.8 07/20] RISC-V: Take text_mutex in ftrace_init_nop() Sasha Levin
@ 2020-09-21 14:40 ` Sasha Levin
  2020-09-23  0:27   ` Damien Le Moal
  1 sibling, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2020-09-21 14:40 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Sasha Levin, devicetree, Damien Le Moal, Palmer Dabbelt,
	linux-riscv

From: Damien Le Moal <damien.lemoal@wdc.com>

[ Upstream commit f025d9d9934b84cd03b7796072d10686029c408e ]

The Kendryte K210 SoC CLINT is compatible with Sifive clint v0
(sifive,clint0). Fix the Kendryte K210 device tree clint entry to be
inline with the sifive timer definition documented in
Documentation/devicetree/bindings/timer/sifive,clint.yaml.
The device tree clint entry is renamed similarly to u-boot device tree
definition to improve compatibility with u-boot defined device tree.
To ensure correct initialization, the interrup-cells attribute is added
and the interrupt-extended attribute definition fixed.

This fixes boot failures with Kendryte K210 SoC boards.

Note that the clock referenced is kept as K210_CLK_ACLK, which does not
necessarilly match the clint MTIME increment rate. This however does not
seem to cause any problem for now.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/riscv/boot/dts/kendryte/k210.dtsi | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/boot/dts/kendryte/k210.dtsi b/arch/riscv/boot/dts/kendryte/k210.dtsi
index c1df56ccb8d55..d2d0ff6456325 100644
--- a/arch/riscv/boot/dts/kendryte/k210.dtsi
+++ b/arch/riscv/boot/dts/kendryte/k210.dtsi
@@ -95,10 +95,12 @@ sysctl: sysctl@50440000 {
 			#clock-cells = <1>;
 		};
 
-		clint0: interrupt-controller@2000000 {
+		clint0: clint@2000000 {
+			#interrupt-cells = <1>;
 			compatible = "riscv,clint0";
 			reg = <0x2000000 0xC000>;
-			interrupts-extended = <&cpu0_intc 3>,  <&cpu1_intc 3>;
+			interrupts-extended =  <&cpu0_intc 3 &cpu0_intc 7
+						&cpu1_intc 3 &cpu1_intc 7>;
 			clocks = <&sysctl K210_CLK_ACLK>;
 		};
 
-- 
2.25.1


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

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

* Re: [PATCH AUTOSEL 5.8 20/20] riscv: Fix Kendryte K210 device tree
  2020-09-21 14:40 ` [PATCH AUTOSEL 5.8 20/20] riscv: Fix Kendryte K210 device tree Sasha Levin
@ 2020-09-23  0:27   ` Damien Le Moal
  2020-09-26 19:42     ` Palmer Dabbelt
  0 siblings, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2020-09-23  0:27 UTC (permalink / raw)
  To: Sasha Levin, linux-kernel@vger.kernel.org, stable@vger.kernel.org
  Cc: devicetree@vger.kernel.org, linux-riscv@lists.infradead.org,
	Palmer Dabbelt

On 2020/09/21 23:41, Sasha Levin wrote:
> From: Damien Le Moal <damien.lemoal@wdc.com>
> 
> [ Upstream commit f025d9d9934b84cd03b7796072d10686029c408e ]
> 
> The Kendryte K210 SoC CLINT is compatible with Sifive clint v0
> (sifive,clint0). Fix the Kendryte K210 device tree clint entry to be
> inline with the sifive timer definition documented in
> Documentation/devicetree/bindings/timer/sifive,clint.yaml.
> The device tree clint entry is renamed similarly to u-boot device tree
> definition to improve compatibility with u-boot defined device tree.
> To ensure correct initialization, the interrup-cells attribute is added
> and the interrupt-extended attribute definition fixed.
> 
> This fixes boot failures with Kendryte K210 SoC boards.
> 
> Note that the clock referenced is kept as K210_CLK_ACLK, which does not
> necessarilly match the clint MTIME increment rate. This however does not
> seem to cause any problem for now.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  arch/riscv/boot/dts/kendryte/k210.dtsi | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/boot/dts/kendryte/k210.dtsi b/arch/riscv/boot/dts/kendryte/k210.dtsi
> index c1df56ccb8d55..d2d0ff6456325 100644
> --- a/arch/riscv/boot/dts/kendryte/k210.dtsi
> +++ b/arch/riscv/boot/dts/kendryte/k210.dtsi
> @@ -95,10 +95,12 @@ sysctl: sysctl@50440000 {
>  			#clock-cells = <1>;
>  		};
>  
> -		clint0: interrupt-controller@2000000 {
> +		clint0: clint@2000000 {
> +			#interrupt-cells = <1>;
>  			compatible = "riscv,clint0";
>  			reg = <0x2000000 0xC000>;
> -			interrupts-extended = <&cpu0_intc 3>,  <&cpu1_intc 3>;
> +			interrupts-extended =  <&cpu0_intc 3 &cpu0_intc 7
> +						&cpu1_intc 3 &cpu1_intc 7>;
>  			clocks = <&sysctl K210_CLK_ACLK>;
>  		};
>  
> 

Sasha,

This is a fix for a problem in 5.9 tree. 5.8 kernel is fine without this patch.
And I think applying it to 5.8 might actually break things since the proper
clint driver was added to kernel 5.9 and does not exist in 5.8.

Best regards.

-- 
Damien Le Moal
Western Digital Research

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

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

* Re: [PATCH AUTOSEL 5.8 20/20] riscv: Fix Kendryte K210 device tree
  2020-09-23  0:27   ` Damien Le Moal
@ 2020-09-26 19:42     ` Palmer Dabbelt
  2020-09-26 20:51       ` Sasha Levin
  0 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2020-09-26 19:42 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: sashal, devicetree, linux-riscv, linux-kernel, stable

>On Tue, 22 Sep 2020 17:27:42 PDT (-0700), Damien Le Moal wrote:
>> On 2020/09/21 23:41, Sasha Levin wrote:
>> From: Damien Le Moal <damien.lemoal@wdc.com>
>> 
>> [ Upstream commit f025d9d9934b84cd03b7796072d10686029c408e ]
>> 
>> The Kendryte K210 SoC CLINT is compatible with Sifive clint v0
>> (sifive,clint0). Fix the Kendryte K210 device tree clint entry to be
>> inline with the sifive timer definition documented in
>> Documentation/devicetree/bindings/timer/sifive,clint.yaml.
>> The device tree clint entry is renamed similarly to u-boot device tree
>> definition to improve compatibility with u-boot defined device tree.
>> To ensure correct initialization, the interrup-cells attribute is added
>> and the interrupt-extended attribute definition fixed.
>> 
>> This fixes boot failures with Kendryte K210 SoC boards.
>> 
>> Note that the clock referenced is kept as K210_CLK_ACLK, which does not
>> necessarilly match the clint MTIME increment rate. This however does not
>> seem to cause any problem for now.
>> 
>> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
>> Signed-off-by: Sasha Levin <sashal@kernel.org>
>> ---
>>  arch/riscv/boot/dts/kendryte/k210.dtsi | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/riscv/boot/dts/kendryte/k210.dtsi b/arch/riscv/boot/dts/kendryte/k210.dtsi
>> index c1df56ccb8d55..d2d0ff6456325 100644
>> --- a/arch/riscv/boot/dts/kendryte/k210.dtsi
>> +++ b/arch/riscv/boot/dts/kendryte/k210.dtsi
>> @@ -95,10 +95,12 @@ sysctl: sysctl@50440000 {
>>  			#clock-cells = <1>;
>>  		};
>>  
>> -		clint0: interrupt-controller@2000000 {
>> +		clint0: clint@2000000 {
>> +			#interrupt-cells = <1>;
>>  			compatible = "riscv,clint0";
>>  			reg = <0x2000000 0xC000>;
>> -			interrupts-extended = <&cpu0_intc 3>,  <&cpu1_intc 3>;
>> +			interrupts-extended =  <&cpu0_intc 3 &cpu0_intc 7
>> +						&cpu1_intc 3 &cpu1_intc 7>;
>>  			clocks = <&sysctl K210_CLK_ACLK>;
>>  		};
>>  
>> 
>
>Sasha,
>
>This is a fix for a problem in 5.9 tree. 5.8 kernel is fine without this patch.
>And I think applying it to 5.8 might actually break things since the proper
>clint driver was added to kernel 5.9 and does not exist in 5.8.

IIUC this won't actually break anything on 5.8, as the reason nobody noticed
that the old one was broken is because the old CLINT driver just didn't care
about what's in the device tree.  These interrupt numbers are defined by the
ISA manual so we jut had them encoded into the arch/riscv first-level interrupt
controller driver.

That said, it definately doesn't fix anything so it seems safer to just not
backport it.

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

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

* Re: [PATCH AUTOSEL 5.8 20/20] riscv: Fix Kendryte K210 device tree
  2020-09-26 19:42     ` Palmer Dabbelt
@ 2020-09-26 20:51       ` Sasha Levin
  0 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2020-09-26 20:51 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: devicetree, Damien Le Moal, linux-riscv, linux-kernel, stable

On Sat, Sep 26, 2020 at 12:42:42PM -0700, Palmer Dabbelt wrote:
>>On Tue, 22 Sep 2020 17:27:42 PDT (-0700), Damien Le Moal wrote:
>>>On 2020/09/21 23:41, Sasha Levin wrote:
>>>From: Damien Le Moal <damien.lemoal@wdc.com>
>>>
>>>[ Upstream commit f025d9d9934b84cd03b7796072d10686029c408e ]
>>>
>>>The Kendryte K210 SoC CLINT is compatible with Sifive clint v0
>>>(sifive,clint0). Fix the Kendryte K210 device tree clint entry to be
>>>inline with the sifive timer definition documented in
>>>Documentation/devicetree/bindings/timer/sifive,clint.yaml.
>>>The device tree clint entry is renamed similarly to u-boot device tree
>>>definition to improve compatibility with u-boot defined device tree.
>>>To ensure correct initialization, the interrup-cells attribute is added
>>>and the interrupt-extended attribute definition fixed.
>>>
>>>This fixes boot failures with Kendryte K210 SoC boards.
>>>
>>>Note that the clock referenced is kept as K210_CLK_ACLK, which does not
>>>necessarilly match the clint MTIME increment rate. This however does not
>>>seem to cause any problem for now.
>>>
>>>Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>>>Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
>>>Signed-off-by: Sasha Levin <sashal@kernel.org>
>>>---
>>> arch/riscv/boot/dts/kendryte/k210.dtsi | 6 ++++--
>>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>>diff --git a/arch/riscv/boot/dts/kendryte/k210.dtsi b/arch/riscv/boot/dts/kendryte/k210.dtsi
>>>index c1df56ccb8d55..d2d0ff6456325 100644
>>>--- a/arch/riscv/boot/dts/kendryte/k210.dtsi
>>>+++ b/arch/riscv/boot/dts/kendryte/k210.dtsi
>>>@@ -95,10 +95,12 @@ sysctl: sysctl@50440000 {
>>> 			#clock-cells = <1>;
>>> 		};
>>>-		clint0: interrupt-controller@2000000 {
>>>+		clint0: clint@2000000 {
>>>+			#interrupt-cells = <1>;
>>> 			compatible = "riscv,clint0";
>>> 			reg = <0x2000000 0xC000>;
>>>-			interrupts-extended = <&cpu0_intc 3>,  <&cpu1_intc 3>;
>>>+			interrupts-extended =  <&cpu0_intc 3 &cpu0_intc 7
>>>+						&cpu1_intc 3 &cpu1_intc 7>;
>>> 			clocks = <&sysctl K210_CLK_ACLK>;
>>> 		};
>>>
>>
>>Sasha,
>>
>>This is a fix for a problem in 5.9 tree. 5.8 kernel is fine without this patch.
>>And I think applying it to 5.8 might actually break things since the proper
>>clint driver was added to kernel 5.9 and does not exist in 5.8.
>
>IIUC this won't actually break anything on 5.8, as the reason nobody noticed
>that the old one was broken is because the old CLINT driver just didn't care
>about what's in the device tree.  These interrupt numbers are defined by the
>ISA manual so we jut had them encoded into the arch/riscv first-level interrupt
>controller driver.
>
>That said, it definately doesn't fix anything so it seems safer to just not
>backport it.

Sure, I'll drop it. Thanks!

-- 
Thanks,
Sasha

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

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

end of thread, other threads:[~2020-09-26 20:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20200921144027.2135390-1-sashal@kernel.org>
2020-09-21 14:40 ` [PATCH AUTOSEL 5.8 07/20] RISC-V: Take text_mutex in ftrace_init_nop() Sasha Levin
2020-09-21 14:40 ` [PATCH AUTOSEL 5.8 20/20] riscv: Fix Kendryte K210 device tree Sasha Levin
2020-09-23  0:27   ` Damien Le Moal
2020-09-26 19:42     ` Palmer Dabbelt
2020-09-26 20:51       ` Sasha Levin

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).