Add LCLK control into Aspeed LPC sub drivers
Subsystems (3)
v3 cover Add LCLK control into Aspeed LPC sub drivers
From: Jae Hyun Yoo <[email protected]>
Hello all,
This series is for appliying below fix to all Aspped LPC sub drivers.
https://lore.kernel.org/all/[email protected]/
An LPC sub driver can be enabled without using the lpc-ctrl driver or it can be registered ahead of lpc-ctrl depends on each system configuration and this difference introduces that LPC can be enabled without heart beating of LCLK so it causes improper handling on host interrupts when the host sends interrupts in that time frame. Then kernel eventually forcibly disables the interrupt with dumping stack and printing a 'nobody cared this irq' message out.
To prevent this issue, all LPC sub drivers should enable LCLK individually so this patch adds clock control logic into the remaining Aspeed LPC sub drivers.
Please review this series.
Thanks,
Jae
Changes sinve v2:
* Rebased it on the latest master.
* Made dts and bindigs changes' commit message more descriptive.
* Simplified the -EPROBE_DEFER handling using dev_err_probe().
Changes sinve v1:
* Added 'clocks' property into ibt and kcs-bmc bindings using 'aspeed,ast2400-ibt-bmc.txt' and 'aspeed,ast2400-kcs-bmc.yaml' respectively because these are not merged into 'aspeed-lpc.yaml' yet. The bindings merging could be done using a separate patch later.
Jae Hyun Yoo (6):
ARM: dts: aspeed: add LCLK setting into LPC IBT node
dt-bindings: ipmi: bt-bmc: add 'clocks' as a required property
ipmi: bt: add clock control logic
ARM: dts: aspeed: add LCLK setting into LPC KCS nodes
dt-bindings: ipmi: aspeed,kcs-bmc: add 'clocks' as a required property
ipmi: kcs_bmc_aspeed: add clock control logic
.../bindings/ipmi/aspeed,ast2400-ibt-bmc.txt | 2 ++ .../bindings/ipmi/aspeed,ast2400-kcs-bmc.yaml | 7 +++++ arch/arm/boot/dts/aspeed-g4.dtsi | 1 + arch/arm/boot/dts/aspeed-g5.dtsi | 5 ++++ arch/arm/boot/dts/aspeed-g6.dtsi | 5 ++++ drivers/char/ipmi/bt-bmc.c | 21 +++++++++++++- drivers/char/ipmi/kcs_bmc_aspeed.c | 28 ++++++++++++++++--- 7 files changed, 64 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/6 ARM: dts: aspeed: add LCLK setting into LPC IBT node
From: Jae Hyun Yoo <[email protected]>
If LPC BT driver is registered ahead of lpc-ctrl module, LPC BT hardware block will be enabled without heart beating of LCLK until lpc-ctrl enables the LCLK. This issue causes improper handling on host interrupts when the host sends interrupts in that time frame. Then kernel eventually forcibly disables the interrupt with dumping stack and printing a 'nobody cared this irq' message out.
To prevent this issue, all LPC sub drivers should enable LCLK individually so this patch adds 'clocks' property setting into LPC IBT node as one of required properties to enable the LCLK by the LPC IBT driver.
Note: dtbs should be re-compiled after applying this change since it's adding a new required property otherwise the driver will not be probed correctly.
---
v2 -> v3:
* Made commit message more descriptive.
v1 -> v2:
* No change.
arch/arm/boot/dts/aspeed-g4.dtsi | 1 + arch/arm/boot/dts/aspeed-g5.dtsi | 1 + arch/arm/boot/dts/aspeed-g6.dtsi | 1 + 3 files changed, 3 insertions(+)
arch/arm/boot/dts/aspeed-g4.dtsi +1 -0
@@ -381,6 +381,7 @@ ibt: ibt@140 { compatible = "aspeed,ast2400-ibt-bmc"; reg = <0x140 0x18>; interrupts = <8>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; };
arch/arm/boot/dts/aspeed-g5.dtsi +1 -0
@@ -507,6 +507,7 @@ ibt: ibt@140 { compatible = "aspeed,ast2500-ibt-bmc"; reg = <0x140 0x18>; interrupts = <8>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; }; };
arch/arm/boot/dts/aspeed-g6.dtsi +1 -0
@@ -581,6 +581,7 @@ ibt: ibt@140 { compatible = "aspeed,ast2600-ibt-bmc"; reg = <0x140 0x18>; interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; }; };
Signature · 1 line
2.25.1
PATCH v3 2/6 dt-bindings: ipmi: bt-bmc: add 'clocks' as a required property
In reply to [email protected]From: Jae Hyun Yoo <[email protected]>
If LPC BT driver is registered ahead of lpc-ctrl module, LPC BT hardware block will be enabled without heart beating of LCLK until lpc-ctrl enables the LCLK. This issue causes improper handling on host interrupts when the host sends interrupts in that time frame. Then kernel eventually forcibly disables the interrupt with dumping stack and printing a 'nobody cared this irq' message out.
To prevent this issue, all LPC sub drivers should enable LCLK individually so this patch adds 'clocks' property as one of required properties to enable the LCLK by the LPC IBT driver.
Note: dtsi change in this patch series should be applied along with, and dtbs should be re-compiled after applying this series since it's adding a new required property otherwise the driver will not be probed correctly.
---
v2 -> v3:
* Made commit message more descriptive.
v1 -> v2:
* Added 'clocks' property into ibt bindings using 'aspeed,ast2400-ibt-bmc.txt' because it's not merged into 'aspeed-lpc.yaml' yet. The bindings merging could be done using a separate patch later.
.../devicetree/bindings/ipmi/aspeed,ast2400-ibt-bmc.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ipmi/aspeed,ast2400-ibt-bmc.txt +2 -0
@@ -11,6 +11,7 @@ Required properties: "aspeed,ast2500-ibt-bmc" "aspeed,ast2600-ibt-bmc" - reg: physical address and size of the registers +- clocks: clock for the device Optional properties:
@@ -23,4 +24,5 @@ Example: compatible = "aspeed,ast2400-ibt-bmc"; reg = <0x1e789140 0x18>; interrupts = <8>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; };
Signature · 1 line
2.25.1
Re: [PATCH v3 2/6] dt-bindings: ipmi: bt-bmc: add 'clocks' as a required property
Quoted 23 lines · jae.hyun.yoo at intel.com
From: Jae Hyun Yoo <[email protected]>
If LPC BT driver is registered ahead of lpc-ctrl module, LPC BT hardware block will be enabled without heart beating of LCLK until lpc-ctrl enables the LCLK. This issue causes improper handling on host interrupts when the host sends interrupts in that time frame. Then kernel eventually forcibly disables the interrupt with dumping stack and printing a 'nobody cared this irq' message out.
To prevent this issue, all LPC sub drivers should enable LCLK individually so this patch adds 'clocks' property as one of required properties to enable the LCLK by the LPC IBT driver.
Note: dtsi change in this patch series should be applied along with, and dtbs should be re-compiled after applying this series since it's adding a new required property otherwise the driver will not be probed correctly.
Signed-off-by Jae Hyun Yoo <[email protected]>---
v2 -> v3:
* Made commit message more descriptive.
Quoted 9 lines
v1 -> v2:
* Added 'clocks' property into ibt bindings using 'aspeed,ast2400-ibt-bmc.txt' because it's not merged into 'aspeed-lpc.yaml' yet. The bindings merging could be done using a separate patch later..../devicetree/bindings/ipmi/aspeed,ast2400-ibt-bmc.txt | 2 ++ 1 file changed, 2 insertions(+)
PATCH v3 3/6 ipmi: bt: add clock control logic
In reply to [email protected]From: Jae Hyun Yoo <[email protected]>
If LPC BT driver is registered ahead of lpc-ctrl module, LPC BT hardware block will be enabled without heart beating of LCLK until lpc-ctrl enables the LCLK. This issue causes improper handling on host interrupts when the host sends interrupts in that time frame. Then kernel eventually forcibly disables the interrupt with dumping stack and printing a 'nobody cared this irq' message out.
To prevent this issue, all LPC sub drivers should enable LCLK individually so this patch adds clock control logic into the LPC BT driver.
Note: dtsi change in this patch series should be applied along with, and dtbs should be re-compiled after applying this series since it's adding a new required property otherwise this driver will not be probed correctly.
---
v2 -> v3:
* Simplified the -EPROBE_DEFER handling using dev_err_probe().
v1 -> v2:
* No change.
drivers/char/ipmi/bt-bmc.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/char/ipmi/bt-bmc.c +20 -1
@@ -5,6 +5,7 @@#include <linux/atomic.h> #include <linux/bt-bmc.h> +#include <linux/clk.h> #include <linux/errno.h> #include <linux/interrupt.h> #include <linux/io.h>
@@ -62,6 +63,7 @@ struct bt_bmc {wait_queue_head_t queue;struct timer_list poll_timer;struct mutex mutex; +struct clk *clk; };static atomic_t open_count =ATOMIC_INIT (0 );
@@ -423,6 +425,16 @@ static int bt_bmc_probe(struct platform_device *pdev)if (IS_ERR (bt_bmc->base))return PTR_ERR (bt_bmc->base); + bt_bmc->clk =devm_clk_get (dev,NULL ); +if (IS_ERR (bt_bmc->clk)) +return dev_err_probe (dev,PTR_ERR (bt_bmc->clk), +"Unable to get clock\n" ); + rc =clk_prepare_enable (bt_bmc->clk); +if (rc) { +dev_err (dev,"Unable to enable clock\n" ); +return rc; + } +mutex_init (&bt_bmc->mutex);init_waitqueue_head (&bt_bmc->queue);
@@ -433,7 +445,7 @@ static int bt_bmc_probe(struct platform_device *pdev) rc =misc_register (&bt_bmc->miscdev);if (rc) {dev_err (dev,"Unable to register misc device\n" ); -return rc; + goto err; }bt_bmc_config_irq (bt_bmc, pdev);
@@ -457,6 +469,11 @@ static int bt_bmc_probe(struct platform_device *pdev)clr_b_busy (bt_bmc);return 0 ; + +err: +clk_disable_unprepare (bt_bmc->clk); + +return rc; }static int bt_bmc_remove (struct platform_device *pdev)
@@ -466,6 +483,8 @@ static int bt_bmc_remove(struct platform_device *pdev)misc_deregister (&bt_bmc->miscdev);if (bt_bmc->irq <0 )del_timer_sync (&bt_bmc->poll_timer); +clk_disable_unprepare (bt_bmc->clk); +return 0 ; }
Signature · 1 line
2.25.1
PATCH v3 4/6 ARM: dts: aspeed: add LCLK setting into LPC KCS nodes
In reply to [email protected]From: Jae Hyun Yoo <[email protected]>
If LPC KCS driver is registered ahead of lpc-ctrl module, LPC KCS hardware block will be enabled without heart beating of LCLK until lpc-ctrl enables the LCLK. This issue causes improper handling on host interrupts when the host sends interrupts in that time frame. Then kernel eventually forcibly disables the interrupt with dumping stack and printing a 'nobody cared this irq' message out.
To prevent this issue, all LPC sub drivers should enable LCLK individually so this patch adds 'clocks' property setting into LPC KCS node as one of required properties to enable the LCLK by the LPC KCS driver.
Note: dtbs should be re-compiled after applying this change since it's adding a new required property otherwise the driver will not be probed correctly.
---
v2 -> v3:
* Made commit message more descriptive.
v1 -> v2:
* No change.
arch/arm/boot/dts/aspeed-g5.dtsi | 4 ++++ arch/arm/boot/dts/aspeed-g6.dtsi | 4 ++++ 2 files changed, 8 insertions(+)
arch/arm/boot/dts/aspeed-g5.dtsi +4 -0
@@ -446,6 +446,7 @@ kcs1: kcs@24 { compatible = "aspeed,ast2500-kcs-bmc-v2"; reg = <0x24 0x1>, <0x30 0x1>, <0x3c 0x1>; interrupts = <8>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; };
@@ -453,6 +454,7 @@ kcs2: kcs@28 { compatible = "aspeed,ast2500-kcs-bmc-v2"; reg = <0x28 0x1>, <0x34 0x1>, <0x40 0x1>; interrupts = <8>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; };
@@ -460,6 +462,7 @@ kcs3: kcs@2c { compatible = "aspeed,ast2500-kcs-bmc-v2"; reg = <0x2c 0x1>, <0x38 0x1>, <0x44 0x1>; interrupts = <8>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; };
@@ -467,6 +470,7 @@ kcs4: kcs@114 { compatible = "aspeed,ast2500-kcs-bmc-v2"; reg = <0x114 0x1>, <0x118 0x1>, <0x11c 0x1>; interrupts = <8>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; };
arch/arm/boot/dts/aspeed-g6.dtsi +4 -0
@@ -520,6 +520,7 @@ kcs1: kcs@24 { compatible = "aspeed,ast2500-kcs-bmc-v2"; reg = <0x24 0x1>, <0x30 0x1>, <0x3c 0x1>; interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; kcs_chan = <1>; status = "disabled"; };
@@ -528,6 +529,7 @@ kcs2: kcs@28 { compatible = "aspeed,ast2500-kcs-bmc-v2"; reg = <0x28 0x1>, <0x34 0x1>, <0x40 0x1>; interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; };
@@ -535,6 +537,7 @@ kcs3: kcs@2c { compatible = "aspeed,ast2500-kcs-bmc-v2"; reg = <0x2c 0x1>, <0x38 0x1>, <0x44 0x1>; interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; };
@@ -542,6 +545,7 @@ kcs4: kcs@114 { compatible = "aspeed,ast2500-kcs-bmc-v2"; reg = <0x114 0x1>, <0x118 0x1>, <0x11c 0x1>; interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; status = "disabled"; };
Signature · 1 line
2.25.1
PATCH v3 5/6 dt-bindings: ipmi: aspeed, kcs-bmc: add 'clocks' as a required property
In reply to [email protected]From: Jae Hyun Yoo <[email protected]>
If LPC KCS driver is registered ahead of lpc-ctrl module, LPC KCS hardware block will be enabled without heart beating of LCLK until lpc-ctrl enables the LCLK. This issue causes improper handling on host interrupts when the host sends interrupts in that time frame. Then kernel eventually forcibly disables the interrupt with dumping stack and printing a 'nobody cared this irq' message out.
To prevent this issue, all LPC sub drivers should enable LCLK individually so this patch adds 'clocks' property as one of required properties to enable the LCLK by the LPC KCS driver.
Note: dtsi change in this patch series should be applied along with, and dtbs should be re-compiled after applying this series since it's adding a new required property otherwise the driver will not be probed correctly.
---
v2 -> v3:
* Made commit message more descriptive.
v1 -> v2:
Changes sinve v1:
* Added 'clocks' property into kcs-bmc bindings using 'aspeed,ast2400-kcs-bmc.yaml' because it's not merged into 'aspeed-lpc.yaml' yet. The bindings merging could be done using a separate patch later.
.../devicetree/bindings/ipmi/aspeed,ast2400-kcs-bmc.yaml | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/ipmi/aspeed,ast2400-kcs-bmc.yaml +7 -0
@@ -71,9 +71,14 @@ properties: $ref: '/schemas/types.yaml#/definitions/uint32' description: The host CPU IO map address + clocks: + maxItems: 1 + description: Reference clock for the LPC controller + required: - compatible - interrupts + - clocks additionalProperties: false
@@ -96,6 +101,7 @@ allOf: examples: - | + #include <dt-bindings/clock/aspeed-clock.h> #include <dt-bindings/interrupt-controller/irq.h> kcs3: kcs@24 { compatible = "aspeed,ast2600-kcs-bmc";
@@ -103,4 +109,5 @@ examples: aspeed,lpc-io-reg = <0xca2>; aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; interrupts = <8>; + clocks = <&syscon ASPEED_CLK_GATE_LCLK>; };
Signature · 1 line
2.25.1
Re: [PATCH v3 5/6] dt-bindings: ipmi: aspeed,kcs-bmc: add 'clocks' as a required property
Quoted 30 lines · jae.hyun.yoo at intel.com
From: Jae Hyun Yoo <[email protected]>
If LPC KCS driver is registered ahead of lpc-ctrl module, LPC KCS hardware block will be enabled without heart beating of LCLK until lpc-ctrl enables the LCLK. This issue causes improper handling on host interrupts when the host sends interrupts in that time frame. Then kernel eventually forcibly disables the interrupt with dumping stack and printing a 'nobody cared this irq' message out.
To prevent this issue, all LPC sub drivers should enable LCLK individually so this patch adds 'clocks' property as one of required properties to enable the LCLK by the LPC KCS driver.
Note: dtsi change in this patch series should be applied along with, and dtbs should be re-compiled after applying this series since it's adding a new required property otherwise the driver will not be probed correctly.
Signed-off-by Jae Hyun Yoo <[email protected]>---
v2 -> v3:
* Made commit message more descriptive.v1 -> v2:
Changes sinve v1:
* Added 'clocks' property into kcs-bmc bindings using 'aspeed,ast2400-kcs-bmc.yaml' because it's not merged into 'aspeed-lpc.yaml' yet. The bindings merging could be done using a separate patch later.
Quoted 3 lines
.../devicetree/bindings/ipmi/aspeed,ast2400-kcs-bmc.yaml | 7 +++++++ 1 file changed, 7 insertions(+)
PATCH v3 6/6 ipmi: kcs_bmc_aspeed: add clock control logic
In reply to [email protected]From: Jae Hyun Yoo <[email protected]>
If LPC KCS driver is registered ahead of lpc-ctrl module, LPC KCS block will be enabled without heart beating of LCLK until lpc-ctrl enables the LCLK. This issue causes improper handling on host interrupts when the host sends interrupts in that time frame. Then kernel eventually forcibly disables the interrupt with dumping stack and printing a 'nobody cared this irq' message out.
To prevent this issue, all LPC sub drivers should enable LCLK individually so this patch adds clock control logic into the LPC KCS driver.
Note: dtsi change in this patch series should be applied along with, and dtbs should be re-compiled after applying this series since it's adding a new required property otherwise this driver will not be probed correctly.
---
v2 -> v3:
* Simplified the -EPROBE_DEFER handling using dev_err_probe().
v1 -> v2:
* No change.
drivers/char/ipmi/kcs_bmc_aspeed.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/char/ipmi/kcs_bmc_aspeed.c +24 -4
@@ -6,6 +6,7 @@#define pr_fmt (fmt) "aspeed-kcs-bmc: " fmt#include <linux/atomic.h> +#include <linux/clk.h> #include <linux/errno.h> #include <linux/interrupt.h> #include <linux/io.h>
@@ -126,6 +127,8 @@ struct aspeed_kcs_bmc {bool remove;struct timer_list timer; } obe; + +struct clk *clk; };struct aspeed_kcs_of_ops {
@@ -620,24 +623,34 @@ static int aspeed_kcs_probe(struct platform_device *pdev)return -ENODEV ; } + priv->clk =devm_clk_get (&pdev->dev,NULL ); +if (IS_ERR (priv->clk)) +return dev_err_probe (&pdev->dev,PTR_ERR (priv->clk), +"Couldn't get clock\n" ); + rc =clk_prepare_enable (priv->clk); +if (rc) { +dev_err (&pdev->dev,"Couldn't enable clock\n" ); +return rc; + } +spin_lock_init (&priv->obe.lock); priv->obe.remove = false;timer_setup (&priv->obe.timer, aspeed_kcs_check_obe,0 ); rc =aspeed_kcs_set_address (kcs_bmc, addrs, nr_addrs);if (rc) -return rc; + goto err;/* Host to BMC IRQ */ rc =aspeed_kcs_config_downstream_irq (kcs_bmc, pdev);if (rc) -return rc; + goto err;/* BMC to Host IRQ */ if (have_upstream_irq) { rc =aspeed_kcs_config_upstream_irq (priv, upstream_irq[0 ], upstream_irq[1 ]);if (rc <0 ) -return rc; + goto err; }else { priv->upstream_irq.mode = aspeed_kcs_irq_none; }
@@ -650,13 +663,19 @@ static int aspeed_kcs_probe(struct platform_device *pdev) rc =kcs_bmc_add_device (&priv->kcs_bmc);if (rc) {dev_warn (&pdev->dev,"Failed to register channel %d: %d\n" , kcs_bmc->channel, rc); -return rc; + goto err; }dev_info (&pdev->dev,"Initialised channel %d at 0x%x\n" , kcs_bmc->channel, addrs[0 ]);return 0 ; + +err: +aspeed_kcs_enable_channel (kcs_bmc, false); +clk_disable_unprepare (priv->clk); + +return rc; }static int aspeed_kcs_remove (struct platform_device *pdev)
@@ -664,6 +683,7 @@ static int aspeed_kcs_remove(struct platform_device *pdev)struct aspeed_kcs_bmc *priv =platform_get_drvdata (pdev);struct kcs_bmc_device *kcs_bmc = &priv->kcs_bmc; +clk_disable_unprepare (priv->clk);kcs_bmc_remove_device (kcs_bmc);aspeed_kcs_enable_channel (kcs_bmc, false);
Signature · 1 line
2.25.1