mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC support
Subsystems (4)
v2 cover mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC support
Hello,
I've added a couple of patches since v1 of this series. The horizon has broadened slightly with a fix for SPARC builds as well in patch 1/4. Ulf suggested a minor cleanup on v1 with respect to handling of the current clock value, so that's now patch 2/4. Patches 3/4 and 4/4 are as they were in v1.
The v1 series can be found here:
https://patchwork.ozlabs.org/cover/1155757/
Please review!
Andrew
Andrew Jeffery (4):
mmc: sdhci-of-aspeed: Fix link failure for SPARC
mmc: sdhci-of-aspeed: Drop redundant assignment to host->clock
mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock()
mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK
drivers/mmc/host/sdhci-of-aspeed.c | 62 ++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 20 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/4 mmc: sdhci-of-aspeed: Fix link failure for SPARC
Resolves the following build error reported by the 0-day bot:
ERROR: "of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!
SPARC does not set CONFIG_OF_ADDRESS so the symbol is missing. Guard the callsite to maintain build coverage for the rest of the driver.
--- drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-)
drivers/mmc/host/sdhci-of-aspeed.c +25 -13
@@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = { .remove = aspeed_sdhci_remove, }; -static int aspeed_sdc_probe (struct platform_device *pdev) - +static int aspeed_sdc_create_sdhcis (struct platform_device *pdev) { +#if defined(CONFIG_OF_ADDRESS )struct device_node *parent, *child; + + parent = pdev->dev.of_node; + +for_each_available_child_of_node (parent, child) { +struct platform_device *cpdev; + + cpdev =of_platform_device_create (child,NULL , &pdev->dev); +if (!cpdev) { +of_node_put (child); +return -ENODEV ; + } + } +#endif + +return 0 ; +} + +static int aspeed_sdc_probe (struct platform_device *pdev) + +{struct aspeed_sdc *sdc;int ret;
@@ -256,17 +276,9 @@ static int aspeed_sdc_probe(struct platform_device *pdev)dev_set_drvdata (&pdev->dev, sdc); - parent = pdev->dev.of_node; -for_each_available_child_of_node (parent, child) { -struct platform_device *cpdev; - - cpdev =of_platform_device_create (child,NULL , &pdev->dev); -if (!cpdev) { -of_node_put (child); - ret = -ENODEV ; - goto err_clk; - } - } + ret =aspeed_sdc_create_sdhcis (pdev); +if (ret) + goto err_clk;return 0 ;
Signature · 1 line
2.20.1
Joel Stanley
maintainerRe: [PATCH v2 1/4] mmc: sdhci-of-aspeed: Fix link failure for SPARC
Quoted 19 lines · Andrew Jeffery
Resolves the following build error reported by the 0-day bot:
ERROR: "
of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!SPARC does not set
CONFIG_OF_ADDRESSso the symbol is missing. Guard the callsite to maintain build coverage for the rest of the driver.Reported-by kbuild test robot <[email protected]>Signed-off-by Andrew Jeffery <[email protected]>--- drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-)drivers/mmc/host/sdhci-of-aspeed.c +0
-0
drivers/mmc/host/sdhci-of-aspeed.c static struct platform_driver aspeed_sdhci_driver = { · line 229
Quoted 8 lines
drivers/mmc/host/sdhci-of-aspeed.c +2
-2@@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = { .remove = aspeed_sdhci_remove, }; -static int aspeed_sdc_probe (struct platform_device *pdev) - +static int aspeed_sdc_create_sdhcis (struct platform_device *pdev) { +#if defined(CONFIG_OF_ADDRESS )
This is going to be untested code forever, as no one will be running on a chip with this hardware present but OF_ADDRESS disabled.
How about we make the driver depend on OF_ADDRESS instead?
Cheers,
Joel
Quoted 48 lines
drivers/mmc/host/sdhci-of-aspeed.c +23
-12struct device_node *parent, *child; + + parent = pdev->dev.of_node; + +for_each_available_child_of_node (parent, child) { +struct platform_device *cpdev; + + cpdev =of_platform_device_create (child,NULL , &pdev->dev); +if (!cpdev) { +of_node_put (child); +return -ENODEV ; + } + } +#endif + +return 0 ; +} + +static int aspeed_sdc_probe (struct platform_device *pdev) + +{struct aspeed_sdc *sdc;int ret;@@ -256,17 +276,9 @@ static int aspeed_sdc_probe(struct platform_device *pdev)dev_set_drvdata (&pdev->dev, sdc); - parent = pdev->dev.of_node; -for_each_available_child_of_node (parent, child) { -struct platform_device *cpdev; - - cpdev =of_platform_device_create (child,NULL , &pdev->dev); -if (!cpdev) { -of_node_put (child); - ret = -ENODEV ; - goto err_clk; - } - } + ret =aspeed_sdc_create_sdhcis (pdev); +if (ret) + goto err_clk;return 0 ; --2.20.1
Re: [PATCH v2 1/4] mmc: sdhci-of-aspeed: Fix link failure for SPARC
Quoted 32 lines · Joel Stanley
Quoted 19 lines · Andrew Jeffery
Resolves the following build error reported by the 0-day bot:
ERROR: "
of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!SPARC does not set
CONFIG_OF_ADDRESSso the symbol is missing. Guard the callsite to maintain build coverage for the rest of the driver.Reported-by kbuild test robot <[email protected]>Signed-off-by Andrew Jeffery <[email protected]>--- drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-)drivers/mmc/host/sdhci-of-aspeed.c +0
-0drivers/mmc/host/sdhci-of-aspeed.c static struct platform_driver aspeed_sdhci_driver = { · line 229
Quoted 8 lines
drivers/mmc/host/sdhci-of-aspeed.c +2
-2@@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = { .remove = aspeed_sdhci_remove, }; -static int aspeed_sdc_probe (struct platform_device *pdev) - +static int aspeed_sdc_create_sdhcis (struct platform_device *pdev) { +#if defined(CONFIG_OF_ADDRESS )This is going to be untested code forever, as no one will be running on a chip with this hardware present but
OF_ADDRESSdisabled.
Quoted 1 line
How about we make the driver depend on
OF_ADDRESSinstead?
Testing is split into two pieces here: compile-time and run-time. Clearly the run-time behaviour is going to be broken on configurations without CONFIG_OF_ADDRESS (SPARC as mentioned), but I don't think that means we shouldn't allow it to be compiled in that case (e.g. CONFIG_COMPILE_TEST performs a similar role).
With respect to compile-time it's possible to compile either path as demonstrated by the build failure report.
Having said that there's no reason we couldn't do what you suggest, just it wasn't the existing solution pattern for the problem (there are several other drivers that suffered the same bug that were fixed in the style of this patch). Either way works, it's all somewhat academic. Your suggestion is more obvious in terms of correctness, but this patch is basically just code motion (the only addition is the #if/ #endif lines over what was already there if we disregard the function declaration/invocation). I'll change it if there are further complaints and a reason to do a v3.
Andrew
Re: [PATCH v2 1/4] mmc: sdhci-of-aspeed: Fix link failure for SPARC
Quoted 47 lines · Andrew Jeffery
Quoted 32 lines · Joel Stanley
Quoted 19 lines · Andrew Jeffery
Resolves the following build error reported by the 0-day bot:
ERROR: "
of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!SPARC does not set
CONFIG_OF_ADDRESSso the symbol is missing. Guard the callsite to maintain build coverage for the rest of the driver.Reported-by kbuild test robot <[email protected]>Signed-off-by Andrew Jeffery <[email protected]>--- drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-)drivers/mmc/host/sdhci-of-aspeed.c +0
-0drivers/mmc/host/sdhci-of-aspeed.c static struct platform_driver aspeed_sdhci_driver = { · line 229
Quoted 8 lines
drivers/mmc/host/sdhci-of-aspeed.c +2
-2@@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = { .remove = aspeed_sdhci_remove, }; -static int aspeed_sdc_probe (struct platform_device *pdev) - +static int aspeed_sdc_create_sdhcis (struct platform_device *pdev) { +#if defined(CONFIG_OF_ADDRESS )This is going to be untested code forever, as no one will be running on a chip with this hardware present but
OF_ADDRESSdisabled.Quoted 1 line
How about we make the driver depend on
OF_ADDRESSinstead?Testing is split into two pieces here: compile-time and run-time. Clearly the run-time behaviour is going to be broken on configurations without
CONFIG_OF_ADDRESS(SPARC as mentioned), but I don't think that means we shouldn't allow it to be compiled in that case (e.g.CONFIG_COMPILE_TESTperforms a similar role).With respect to compile-time it's possible to compile either path as demonstrated by the build failure report.
Quoted 9 lines
Having said that there's no reason we couldn't do what you suggest, just it wasn't the existing solution pattern for the problem (there are several other drivers that suffered the same bug that were fixed in the style of this patch). Either way works, it's all somewhat academic. Your suggestion is more obvious in terms of correctness, but this patch is basically just code motion (the only addition is the
#if/#endiflines over what was already there if we disregard the function declaration/invocation). I'll change it if there are further complaints and a reason to do a v3.
I am in favor of Joel's suggestion as I don't really like having ifdefs bloating around in the driver (unless very good reasons). Please re-spin a v3.
Another option is to implement stub function and to deal with error codes, but that sounds more like a long term thingy, if even applicable here.
Kind regards
Uffe
Re: [PATCH v2 1/4] mmc: sdhci-of-aspeed: Fix link failure for SPARC
Quoted 58 lines · Ulf Hansson
Quoted 47 lines · Andrew Jeffery
Quoted 32 lines · Joel Stanley
Quoted 19 lines · Andrew Jeffery
Resolves the following build error reported by the 0-day bot:
ERROR: "
of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!SPARC does not set
CONFIG_OF_ADDRESSso the symbol is missing. Guard the callsite to maintain build coverage for the rest of the driver.Reported-by kbuild test robot <[email protected]>Signed-off-by Andrew Jeffery <[email protected]>--- drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-)drivers/mmc/host/sdhci-of-aspeed.c +0
-0drivers/mmc/host/sdhci-of-aspeed.c static struct platform_driver aspeed_sdhci_driver = { · line 229
Quoted 8 lines
drivers/mmc/host/sdhci-of-aspeed.c +2
-2@@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = { .remove = aspeed_sdhci_remove, }; -static int aspeed_sdc_probe (struct platform_device *pdev) - +static int aspeed_sdc_create_sdhcis (struct platform_device *pdev) { +#if defined(CONFIG_OF_ADDRESS )This is going to be untested code forever, as no one will be running on a chip with this hardware present but
OF_ADDRESSdisabled.Quoted 1 line
How about we make the driver depend on
OF_ADDRESSinstead?Testing is split into two pieces here: compile-time and run-time. Clearly the run-time behaviour is going to be broken on configurations without
CONFIG_OF_ADDRESS(SPARC as mentioned), but I don't think that means we shouldn't allow it to be compiled in that case (e.g.CONFIG_COMPILE_TESTperforms a similar role).With respect to compile-time it's possible to compile either path as demonstrated by the build failure report.
Quoted 9 lines
Having said that there's no reason we couldn't do what you suggest, just it wasn't the existing solution pattern for the problem (there are several other drivers that suffered the same bug that were fixed in the style of this patch). Either way works, it's all somewhat academic. Your suggestion is more obvious in terms of correctness, but this patch is basically just code motion (the only addition is the
#if/#endiflines over what was already there if we disregard the function declaration/invocation). I'll change it if there are further complaints and a reason to do a v3.
Quoted 7 lines
I am in favor of Joel's suggestion as I don't really like having ifdefs bloating around in the driver (unless very good reasons). Please re-spin a v3.
Another option is to implement stub function and to deal with error codes, but that sounds more like a long term thingy, if even applicable here.
No worries then, will post a respin shortly.
Andrew
PATCH v2 2/4 mmc: sdhci-of-aspeed: Drop redundant assignment to host->clock
In reply to Andrew Jefferyhost->clock is already managed by sdhci_set_ios().
--- drivers/mmc/host/sdhci-of-aspeed.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/mmc/host/sdhci-of-aspeed.c +1 -4
@@ -61,7 +61,7 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)sdhci_writew (host,0 ,SDHCI_CLOCK_CONTROL );if (clock ==0 ) - goto out; +return ;for (div =1 ; div <256 ; div *=2 ) {if ((host->max_clk / div) <= clock)
@@ -72,9 +72,6 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) clk = div <<SDHCI_DIVIDER_SHIFT ;sdhci_enable_clk (host, clk); - -out: - host->clock = clock; }static void aspeed_sdhci_set_bus_width (struct sdhci_host *host,int width)
Signature · 1 line
2.20.1
PATCH v2 3/4 mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock()
In reply to Andrew JefferyThe early-exit didn't seem to matter on the AST2500, but on the AST2600 the SD clock genuinely may not be running on entry to aspeed_sdhci_set_clock(). Remove the early exit to ensure we always run sdhci_enable_clk().
--- drivers/mmc/host/sdhci-of-aspeed.c | 3 --- 1 file changed, 3 deletions(-)
drivers/mmc/host/sdhci-of-aspeed.c +0 -3
@@ -55,9 +55,6 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)int div;u16 clk; -if (clock == host->clock) -return ; -sdhci_writew (host,0 ,SDHCI_CLOCK_CONTROL );if (clock ==0 )
Signature · 1 line
2.20.1
PATCH v2 4/4 mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK
In reply to Andrew JefferyAdd a get_max_clock() handler to sdhci-of-aspeed to report f_max as the maximum clock rate if it is set. This enables artificial limitation of the bus speed via max-frequency in the devicetree for e.g. the AST2600 evaluation board where I was seeing errors at 200MHz.
--- drivers/mmc/host/sdhci-of-aspeed.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-aspeed.c +18 -2
@@ -52,16 +52,24 @@ static void aspeed_sdc_configure_8bit_mode(struct aspeed_sdc *sdc,static void aspeed_sdhci_set_clock (struct sdhci_host *host,unsigned int clock) { +struct sdhci_pltfm_host *pltfm_host; +unsigned long parent;int div;u16 clk; + pltfm_host =sdhci_priv (host); + parent =clk_get_rate (pltfm_host->clk); +sdhci_writew (host,0 ,SDHCI_CLOCK_CONTROL );if (clock ==0 )return ; +if (WARN_ON (clock > host->max_clk)) + clock = host->max_clk; +for (div =1 ; div <256 ; div *=2 ) { -if ((host->max_clk / div) <= clock) +if ((parent / div) <= clock)break ; } div >>=1 ;
@@ -71,6 +79,14 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)sdhci_enable_clk (host, clk); } +static unsigned int aspeed_sdhci_get_max_clock (struct sdhci_host *host) +{ +if (host->mmc->f_max) +return host->mmc->f_max; + +return sdhci_pltfm_clk_get_max_clock (host); +} +static void aspeed_sdhci_set_bus_width (struct sdhci_host *host,int width) {struct sdhci_pltfm_host *pltfm_priv;
@@ -97,7 +113,7 @@ static void aspeed_sdhci_set_bus_width(struct sdhci_host *host, int width)static const struct sdhci_ops aspeed_sdhci_ops = { .set_clock = aspeed_sdhci_set_clock, - .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .get_max_clock = aspeed_sdhci_get_max_clock, .set_bus_width = aspeed_sdhci_set_bus_width, .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, .reset = sdhci_reset,
Signature · 1 line
2.20.1
Ulf Hansson
AppliedQuoted 7 lines · Andrew Jeffery
Hello,
I've added a couple of patches since v1 of this series. The horizon has broadened slightly with a fix for SPARC builds as well in patch 1/4. Ulf suggested a minor cleanup on v1 with respect to handling of the current clock value, so that's now patch 2/4. Patches 3/4 and 4/4 are as they were in v1.
Applied patch 2->4 for next, thanks!
Kind regards
Uffe
Quoted 21 lines
The v1 series can be found here:
https://patchwork.ozlabs.org/cover/1155757/
Please review!
Andrew
Andrew Jeffery (4):
mmc: sdhci-of-aspeed: Fix link failure for SPARC
mmc: sdhci-of-aspeed: Drop redundant assignment tohost->clock
mmc: sdhci-of-aspeed: Uphold clocks-on post-condition ofset_clock()
mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLKdrivers/mmc/host/sdhci-of-aspeed.c | 62 ++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 20 deletions(-)--
2.20.1