net: stmmac: explicitly deassert GMAC_AHB_RESET
Subsystems (6)
PATCH 1/3 net: stmmac: explicitly deassert GMAC_AHB_RESET
We are currently assuming that GMAC_AHB_RESET will already be deasserted by the bootloader. However if this has not been done, probing of the GMAC will fail. To remedy this we must ensure GMAC_AHB_RESET has been deasserted prior to probing.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++++++ include/linux/stmmac.h | 1 + 3 files changed, 15 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7 -0
@@ -6840,6 +6840,13 @@ int stmmac_dvr_probe(struct device *device,reset_control_reset (priv->plat->stmmac_rst); } +if (priv->plat->stmmac_ahb_rst) { + ret =reset_control_deassert (priv->plat->stmmac_ahb_rst); +if (ret == -ENOTSUPP ) +dev_err (priv->device, +"unable to bring out of ahb reset\n" ); + } +/* Init MAC and get the capabilities */ ret =stmmac_hw_init (priv);if (ret)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +7 -0
@@ -600,6 +600,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) goto error_hw_init; } + plat->stmmac_ahb_rst =devm_reset_control_get_optional_shared ( + &pdev->dev,"ahb" ); +if (IS_ERR (plat->stmmac_ahb_rst)) { + ret = plat->stmmac_ahb_rst; + goto error_hw_init; + } +return plat; error_hw_init:
include/linux/stmmac.h +1 -0
@@ -239,6 +239,7 @@ struct plat_stmmacenet_data {unsigned int mult_fact_100ns;s32 ptp_max_adj;struct reset_control *stmmac_rst; +struct reset_control *stmmac_ahb_rst;struct stmmac_axi *axi;int has_gmac4;bool has_sun8i;
Signature · 1 line
2.26.3
PATCH 2/3 ARM: dts: qcom: add ahb reset to ipq806x-gmac
Add GMAC_AHB_RESET to the resets property of each gmac node.
--- arch/arm/boot/dts/qcom-ipq8064.dtsi | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
arch/arm/boot/dts/qcom-ipq8064.dtsi +12 -8
@@ -643,8 +643,9 @@ gmac0: ethernet@37000000 { clocks = <&gcc GMAC_CORE1_CLK>; clock-names = "stmmaceth"; - resets = <&gcc GMAC_CORE1_RESET>; - reset-names = "stmmaceth"; + resets = <&gcc GMAC_CORE1_RESET>, + <&gcc GMAC_AHB_RESET>; + reset-names = "stmmaceth", "ahb"; status = "disabled"; };
@@ -666,8 +667,9 @@ gmac1: ethernet@37200000 { clocks = <&gcc GMAC_CORE2_CLK>; clock-names = "stmmaceth"; - resets = <&gcc GMAC_CORE2_RESET>; - reset-names = "stmmaceth"; + resets = <&gcc GMAC_CORE2_RESET>, + <&gcc GMAC_AHB_RESET>; + reset-names = "stmmaceth", "ahb"; status = "disabled"; };
@@ -689,8 +691,9 @@ gmac2: ethernet@37400000 { clocks = <&gcc GMAC_CORE3_CLK>; clock-names = "stmmaceth"; - resets = <&gcc GMAC_CORE3_RESET>; - reset-names = "stmmaceth"; + resets = <&gcc GMAC_CORE3_RESET>, + <&gcc GMAC_AHB_RESET>; + reset-names = "stmmaceth", "ahb"; status = "disabled"; };
@@ -712,8 +715,9 @@ gmac3: ethernet@37600000 { clocks = <&gcc GMAC_CORE4_CLK>; clock-names = "stmmaceth"; - resets = <&gcc GMAC_CORE4_RESET>; - reset-names = "stmmaceth"; + resets = <&gcc GMAC_CORE4_RESET>, + <&gcc GMAC_AHB_RESET>; + reset-names = "stmmaceth", "ahb"; status = "disabled"; };
Signature · 1 line
2.26.3
PATCH 3/3 dt-bindings: net: stmmac: add ahb reset to example
In reply to Matthew HaganAdd ahb reset to the reset properties within the example gmac node.
--- Documentation/devicetree/bindings/net/ipq806x-dwmac.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/ipq806x-dwmac.txt +3 -2
@@ -30,6 +30,7 @@ Example: clocks = <&gcc GMAC_CORE1_CLK>; clock-names = "stmmaceth"; - resets = <&gcc GMAC_CORE1_RESET>; - reset-names = "stmmaceth"; + resets = <&gcc GMAC_CORE1_RESET>, + <&gcc GMAC_AHB_RESET>; + reset-names = "stmmaceth", "ahb"; };
Signature · 1 line
2.26.3
Quoted 5 lines · Matthew Hagan
We are currently assuming that
GMAC_AHB_RESETwill already be deasserted by the bootloader. However if this has not been done, probing of the GMAC will fail. To remedy this we must ensureGMAC_AHB_RESEThas been deasserted prior to probing.
Sounds good, just some small style comments below.
Quoted 12 lines
Signed-off-by Matthew Hagan <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++++++ include/linux/stmmac.h | 1 + 3 files changed, 15 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_dvr_probe(struct device *device, · line 6843
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-0@@ -6840,6 +6840,13 @@ int stmmac_dvr_probe(struct device *device,reset_control_reset (priv->plat->stmmac_rst); } +if (priv->plat->stmmac_ahb_rst) {
You don't need this conditional, stmmac_ahb_rst will be NULL if not specified and you can reset_control_deassert(NULL) without any problems.
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_dvr_probe(struct device *device, · line 6847
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4
-0+ ret =reset_control_deassert (priv->plat->stmmac_ahb_rst); +if (ret == -ENOTSUPP ) +dev_err (priv->device, +"unable to bring out of ahb reset\n" );
No need to wrap this line.
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-0+ } +/* Init MAC and get the capabilities */ ret =stmmac_hw_init (priv);if (ret)drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0
-0
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) · line 606
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +4
-0@@ -600,6 +600,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) goto error_hw_init; } + plat->stmmac_ahb_rst =devm_reset_control_get_optional_shared ( + &pdev->dev,"ahb" ); +if (IS_ERR (plat->stmmac_ahb_rst)) { + ret = plat->stmmac_ahb_rst;
You need a PTR_ERR() around the plat->stmmac_ahb_rst.
Regards,
Bjorn
Quoted 21 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +3
-0+ goto error_hw_init; + } +return plat; error_hw_init:include/linux/stmmac.h +1
-0@@ -239,6 +239,7 @@ struct plat_stmmacenet_data {unsigned int mult_fact_100ns;s32 ptp_max_adj;struct reset_control *stmmac_rst; +struct reset_control *stmmac_ahb_rst;struct stmmac_axi *axi;int has_gmac4;bool has_sun8i;Signature · 1 line
2.26.3
Quoted 70 lines · Bjorn Andersson
Quoted 5 lines · Matthew Hagan
We are currently assuming that
GMAC_AHB_RESETwill already be deasserted by the bootloader. However if this has not been done, probing of the GMAC will fail. To remedy this we must ensureGMAC_AHB_RESEThas been deasserted prior to probing.Sounds good, just some small style comments below.
Quoted 12 lines
Signed-off-by Matthew Hagan <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++++++ include/linux/stmmac.h | 1 + 3 files changed, 15 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_dvr_probe(struct device *device, · line 6843
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-0@@ -6840,6 +6840,13 @@ int stmmac_dvr_probe(struct device *device,reset_control_reset (priv->plat->stmmac_rst); } +if (priv->plat->stmmac_ahb_rst) {You don't need this conditional,
stmmac_ahb_rstwill be NULL if not specified and you canreset_control_deassert(NULL)without any problems.drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_dvr_probe(struct device *device, · line 6847
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4
-0+ ret =reset_control_deassert (priv->plat->stmmac_ahb_rst); +if (ret == -ENOTSUPP ) +dev_err (priv->device, +"unable to bring out of ahb reset\n" );No need to wrap this line.
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-0+ } +/* Init MAC and get the capabilities */ ret =stmmac_hw_init (priv);if (ret)drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0
-0drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) · line 606
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +4
-0@@ -600,6 +600,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) goto error_hw_init; } + plat->stmmac_ahb_rst =devm_reset_control_get_optional_shared ( + &pdev->dev,"ahb" ); +if (IS_ERR (plat->stmmac_ahb_rst)) { + ret = plat->stmmac_ahb_rst;You need a
PTR_ERR()around theplat->stmmac_ahb_rst.Regards,
BjornQuoted 14 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +3
-0+ goto error_hw_init; + } +return plat; error_hw_init:include/linux/stmmac.h +0
-0@@ -239,6 +239,7 @@ struct plat_stmmacenet_data {unsigned int mult_fact_100ns;s32 ptp_max_adj;struct reset_control *stmmac_rst;
Quoted 8 lines
Quoted 8 lines
include/linux/stmmac.h +1
-0+struct reset_control *stmmac_ahb_rst;struct stmmac_axi *axi;int has_gmac4;bool has_sun8i;Signature · 1 line
2.26.3
Thanks for the review. Will submit a v2 shortly.
Matthew
PATCH v2 1/1 net: stmmac: explicitly deassert GMAC_AHB_RESET
We are currently assuming that GMAC_AHB_RESET will already be deasserted by the bootloader. However if this has not been done, probing of the GMAC will fail. To remedy this we must ensure GMAC_AHB_RESET has been deasserted prior to probing.
v2 changes:
- remove NULL condition check for stmmac_ahb_rst in stmmac_main.c
- unwrap dev_err() message in stmmac_main.c
- add PTR_ERR() around plat->stmmac_ahb_rst in stmmac_platform.c
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++++++ include/linux/stmmac.h | 1 + 3 files changed, 12 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
@@ -6840,6 +6840,10 @@ int stmmac_dvr_probe(struct device *device,reset_control_reset (priv->plat->stmmac_rst); } + ret =reset_control_deassert (priv->plat->stmmac_ahb_rst); +if (ret == -ENOTSUPP ) +dev_err (priv->device,"unable to bring out of ahb reset\n" ); +/* Init MAC and get the capabilities */ ret =stmmac_hw_init (priv);if (ret)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +7 -0
@@ -600,6 +600,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) goto error_hw_init; } + plat->stmmac_ahb_rst =devm_reset_control_get_optional_shared ( + &pdev->dev,"ahb" ); +if (IS_ERR (plat->stmmac_ahb_rst)) { + ret =PTR_ERR (plat->stmmac_ahb_rst); + goto error_hw_init; + } +return plat; error_hw_init:
include/linux/stmmac.h +1 -0
@@ -239,6 +239,7 @@ struct plat_stmmacenet_data {unsigned int mult_fact_100ns;s32 ptp_max_adj;struct reset_control *stmmac_rst; +struct reset_control *stmmac_ahb_rst;struct stmmac_axi *axi;int has_gmac4;bool has_sun8i;
Signature · 7 lines
2.26.3 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 22 lines · Matthew Hagan
We are currently assuming that
GMAC_AHB_RESETwill already be deasserted by the bootloader. However if this has not been done, probing of the GMAC will fail. To remedy this we must ensureGMAC_AHB_RESEThas been deasserted prior to probing.v2 changes:
- remove NULL condition check forstmmac_ahb_rstinstmmac_main.c
- unwrapdev_err()message instmmac_main.c
- addPTR_ERR()aroundplat->stmmac_ahb_rstinstmmac_platform.cSigned-off-by Matthew Hagan <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++++++ include/linux/stmmac.h | 1 + 3 files changed, 12 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_dvr_probe(struct device *device, · line 6846
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4
-0@@ -6840,6 +6840,10 @@ int stmmac_dvr_probe(struct device *device,reset_control_reset (priv->plat->stmmac_rst); } + ret =reset_control_deassert (priv->plat->stmmac_ahb_rst); +if (ret == -ENOTSUPP ) +dev_err (priv->device,"unable to bring out of ahb reset\n" ); +
I would make this
if (ret) dev_err(priv->device, "unable to bring out of ahb reset: %pe\n", ERR_PTR(ret));
Also consider asserting the reset again in the remove path. Or is there a reason not to?
With that addressed,
regards
Philipp
Quoted 26 lines · Philipp Zabel
Quoted 25 lines · Matthew Hagan
We are currently assuming that
GMAC_AHB_RESETwill already be deasserted by the bootloader. However if this has not been done, probing of the GMAC will fail. To remedy this we must ensureGMAC_AHB_RESEThas been deasserted prior to probing.v2 changes:
- remove NULL condition check forstmmac_ahb_rstinstmmac_main.c
- unwrapdev_err()message instmmac_main.c
- addPTR_ERR()aroundplat->stmmac_ahb_rstinstmmac_platform.cSigned-off-by Matthew Hagan <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++++++ include/linux/stmmac.h | 1 + 3 files changed, 12 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0@@ -6840,6 +6840,10 @@ int stmmac_dvr_probe(struct device *device,reset_control_reset (priv->plat->stmmac_rst); }
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_dvr_probe(struct device *device, · line 6846
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4
-0+ ret =reset_control_deassert (priv->plat->stmmac_ahb_rst); +if (ret == -ENOTSUPP ) +dev_err (priv->device,"unable to bring out of ahb reset\n" ); +I would make this
if (ret) dev_err(priv->device, "unable to bring out of ahb reset: %pe\n", ERR_PTR(ret));
Done.
Quoted 3 lines
Also consider asserting the reset again in the remove path. Or is there a reason not to?
Don't see any issue doing this. As this is a shared reset, the assert will only occur when the final GMAC is removed, due to the tracking of deassert_count.
Quoted 6 lines
With that addressed,
Reviewed-by Philipp Zabel <[email protected]>regards
Philipp
Thanks,
Matthew
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 1/1 net: stmmac: explicitly deassert GMAC_AHB_RESET
In reply to Matthew HaganWe are currently assuming that GMAC_AHB_RESET will already be deasserted by the bootloader. However if this has not been done, probing of the GMAC will fail. To remedy this we must ensure GMAC_AHB_RESET has been deasserted prior to probing.
v2 changes:
- remove NULL condition check for stmmac_ahb_rst in stmmac_main.c
- unwrap dev_err() message in stmmac_main.c
- add PTR_ERR() around plat->stmmac_ahb_rst in stmmac_platform.c
v3 changes:
- add error pointer to dev_err() output
- add reset_control_assert(stmmac_ahb_rst) in stmmac_dvr_remove
- revert PTR_ERR() around plat->stmmac_ahb_rst since this is performed on the returned value of ret by the calling function
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++++++ include/linux/stmmac.h | 1 + 3 files changed, 14 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 -0
@@ -6840,6 +6840,11 @@ int stmmac_dvr_probe(struct device *device,reset_control_reset (priv->plat->stmmac_rst); } + ret =reset_control_deassert (priv->plat->stmmac_ahb_rst); +if (ret == -ENOTSUPP ) +dev_err (priv->device,"unable to bring out of ahb reset: %pe\n" , +ERR_PTR (ret)); +/* Init MAC and get the capabilities */ ret =stmmac_hw_init (priv);if (ret)
@@ -7072,6 +7077,7 @@ int stmmac_dvr_remove(struct device *dev)phylink_destroy (priv->phylink);if (priv->plat->stmmac_rst)reset_control_assert (priv->plat->stmmac_rst); +reset_control_assert (priv->plat->stmmac_ahb_rst);pm_runtime_put (dev);pm_runtime_disable (dev); if (priv->hw->pcs != STMMAC_PCS_TBI &&
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +7 -0
@@ -600,6 +600,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) goto error_hw_init; } + plat->stmmac_ahb_rst =devm_reset_control_get_optional_shared ( + &pdev->dev,"ahb" ); +if (IS_ERR (plat->stmmac_ahb_rst)) { + ret = plat->stmmac_ahb_rst; + goto error_hw_init; + } +return plat; error_hw_init:
include/linux/stmmac.h +1 -0
@@ -239,6 +239,7 @@ struct plat_stmmacenet_data {unsigned int mult_fact_100ns;s32 ptp_max_adj;struct reset_control *stmmac_rst; +struct reset_control *stmmac_ahb_rst;struct stmmac_axi *axi;int has_gmac4;bool has_sun8i;
Signature · 7 lines
2.26.3 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 11 lines · On Tue, 8 Jun 2021 19:59:06 +0100 you wrote:
We are currently assuming that
GMAC_AHB_RESETwill already be deasserted by the bootloader. However if this has not been done, probing of the GMAC will fail. To remedy this we must ensureGMAC_AHB_RESEThas been deasserted prior to probing.v2 changes:
- remove NULL condition check forstmmac_ahb_rstinstmmac_main.c
- unwrapdev_err()message instmmac_main.c
- addPTR_ERR()aroundplat->stmmac_ahb_rstinstmmac_platform.c[...]
Here is the summary with links:
- [v3] net: stmmac: explicitly deassert GMAC_AHB_RESET
https://git.kernel.org/netdev/net-next/c/e67f325e9cd6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 8 lines · Bjorn Andersson
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0
-0@@ -600,6 +600,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) goto error_hw_init; }
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) · line 606
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +4
-0+ plat->stmmac_ahb_rst =devm_reset_control_get_optional_shared ( + &pdev->dev,"ahb" ); +if (IS_ERR (plat->stmmac_ahb_rst)) { + ret = plat->stmmac_ahb_rst;You need a
PTR_ERR()around theplat->stmmac_ahb_rst.
This is giving a warning. Shouldn't v1 be kept as it is here? Please refer to "net: stmmac: platform: use optional clk/reset get APIs" [1] which modified error handling for plat->stmmac_rst. PTR_ERR() would then be called by the parent function on the returned value of ret.
[1]: https://lore.kernel.org/netdev/[email protected]/
Thanks,
Matthew