MMC:dw_mmc:when enable biu_clk should check whether this clk is normal
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): CGME20260104023451epcas5p391708610b5ce46d0e2a5f4bfbad01c71@epcas5p3.samsung.com
PATCH 1/1 MMC:dw_mmc:when enable biu_clk should check whether this clk is normal
some vendor doesn't use biu_clk , enable it will panic log is below:
[ 438.400868] [7: binder:436_2: 4998] Unable to handle kernel paging request at virtual address fffffffffffffffe [ 438.400877] [7: binder:436_2: 4998] Mem abort info: [ 438.400881] [7: binder:436_2: 4998] ESR = 0x0000000096000005 [ 438.400887] [7: binder:436_2: 4998] EC = 0x25: DABT (current EL), IL = 32 bits [ 438.400894] [7: binder:436_2: 4998] SET = 0, FnV = 0 [ 438.400899] [7: binder:436_2: 4998] EA = 0, S1PTW = 0 [ 438.400904] [7: binder:436_2: 4998] FSC = 0x05: level 1 translation fault ... [ 438.409424] [7: binder:436_2: 4998] Call trace: [ 438.409429] [7: binder:436_2: 4998] clk_prepare+0x10/0x24 [ 438.409439] [7: binder:436_2: 4998] dw_mci_runtime_resume+0x50/0x2d8 [dw_mmc_samsung cd210e210975263404c28fc89778f369f8398f0c] [ 438.409471] [7: binder:436_2: 4998] dw_mci_exynos_runtime_resume+0x18/0x58 [dw_mmc_exynos_samsung 2735a594c7c9c9e8c65b0b87523fbf70dcaabfff] [ 438.409496] [7: binder:436_2: 4998] pm_generic_runtime_resume+0x40/0x58 [ 438.409506] [7: binder:436_2: 4998] pm_runtime_force_resume+0x9c/0x134 [ 438.409517] [7: binder:436_2: 4998] platform_pm_resume+0x40/0x8c [ 438.409529] [7: binder:436_2: 4998] dpm_run_callback+0x64/0x230 [ 438.409540] [7: binder:436_2: 4998] __device_resume+0x1d8/0x394 [ 438.409551] [7: binder:436_2: 4998] dpm_resume+0x110/0x2b8 [ 438.409561] [7: binder:436_2: 4998] dpm_resume_end+0x1c/0x38 [ 438.409570] [7: binder:436_2: 4998] suspend_devices_and_enter+0x828/0xab0 [ 438.409582] [7: binder:436_2: 4998] pm_suspend+0x334/0x618 [ 438.409592] [7: binder:436_2: 4998] state_store+0x104/0x144 [ 438.409601] [7: binder:436_2: 4998] kobj_attr_store+0x30/0x48 [ 438.409610] [7: binder:436_2: 4998] sysfs_kf_write+0x54/0x6c [ 438.409619] [7: binder:436_2: 4998] kernfs_fop_write_iter+0x104/0x1a8 [ 438.409628] [7: binder:436_2: 4998] vfs_write+0x24c/0x2f4 [ 438.409640] [7: binder:436_2: 4998] ksys_write+0x78/0xe8 [ 438.409652] [7: binder:436_2: 4998] __arm64_sys_write+0x1c/0x2c [ 438.409664] [7: binder:436_2: 4998] invoke_syscall+0x58/0x114 [ 438.409676] [7: binder:436_2: 4998] el0_svc_common+0xac/0xe0 [ 438.409687] [7: binder:436_2: 4998] do_el0_svc+0x1c/0x28 [ 438.409698] [7: binder:436_2: 4998] el0_svc+0x38/0x68 [ 438.409705] [7: binder:436_2: 4998] el0t_64_sync_handler+0x68/0xbc [ 438.409712] [7: binder:436_2: 4998] el0t_64_sync+0x1a8/0x1ac
--- drivers/mmc/host/dw_mmc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/host/dw_mmc.c +9 -3
@@ -3633,9 +3633,15 @@ int dw_mci_runtime_resume(struct device *dev)if (host->slot && (mmc_host_can_gpio_cd (host->slot->mmc) || !mmc_card_is_removable (host->slot->mmc))) { - ret =clk_prepare_enable (host->biu_clk); -if (ret) -return ret; +if (IS_ERR (host->biu_clk)) { +dev_dbg (host->dev,"biu clock not available\n" ); + }else { + ret =clk_prepare_enable (host->biu_clk); +if (ret) { +dev_err (host->dev,"failed to enable biu clock\n" ); + goto err; + } + } } ret =clk_prepare_enable (host->ciu_clk);
Signature · 1 line
2.50.1
Shawn Lin
maintainerQuoted 2 lines · ping.gao
some vendor doesn't use
biu_clk, enable it will panic log is below:
I still don't understand the real issue you tried to solve.
host->biu_clk is got via devm_clk_get() in dw_mci_probe(). If succeed, immediately it's enabled a few lines below. Otherwise, dw_mci_probe() returns with failure. Seems you are not enabling it in runtime callbacks, but why clk_prepare_enable(host->biu_clk) is able to work when driver probed?
Quoted 62 lines
[ 438.400868] [7: binder:436_2: 4998] Unable to handle kernel paging request at virtual address fffffffffffffffe [ 438.400877] [7: binder:436_2: 4998] Mem abort info: [ 438.400881] [7: binder:436_2: 4998] ESR = 0x0000000096000005 [ 438.400887] [7: binder:436_2: 4998] EC = 0x25: DABT (current EL), IL = 32 bits [ 438.400894] [7: binder:436_2: 4998] SET = 0, FnV = 0 [ 438.400899] [7: binder:436_2: 4998] EA = 0, S1PTW = 0 [ 438.400904] [7: binder:436_2: 4998] FSC = 0x05: level 1 translation fault ... [ 438.409424] [7: binder:436_2: 4998] Call trace: [ 438.409429] [7: binder:436_2: 4998] clk_prepare+0x10/0x24 [ 438.409439] [7: binder:436_2: 4998] dw_mci_runtime_resume+0x50/0x2d8 [dw_mmc_samsung cd210e210975263404c28fc89778f369f8398f0c] [ 438.409471] [7: binder:436_2: 4998] dw_mci_exynos_runtime_resume+0x18/0x58 [dw_mmc_exynos_samsung 2735a594c7c9c9e8c65b0b87523fbf70dcaabfff] [ 438.409496] [7: binder:436_2: 4998] pm_generic_runtime_resume+0x40/0x58 [ 438.409506] [7: binder:436_2: 4998] pm_runtime_force_resume+0x9c/0x134 [ 438.409517] [7: binder:436_2: 4998] platform_pm_resume+0x40/0x8c [ 438.409529] [7: binder:436_2: 4998] dpm_run_callback+0x64/0x230 [ 438.409540] [7: binder:436_2: 4998] __device_resume+0x1d8/0x394 [ 438.409551] [7: binder:436_2: 4998] dpm_resume+0x110/0x2b8 [ 438.409561] [7: binder:436_2: 4998] dpm_resume_end+0x1c/0x38 [ 438.409570] [7: binder:436_2: 4998] suspend_devices_and_enter+0x828/0xab0 [ 438.409582] [7: binder:436_2: 4998] pm_suspend+0x334/0x618 [ 438.409592] [7: binder:436_2: 4998] state_store+0x104/0x144 [ 438.409601] [7: binder:436_2: 4998] kobj_attr_store+0x30/0x48 [ 438.409610] [7: binder:436_2: 4998] sysfs_kf_write+0x54/0x6c [ 438.409619] [7: binder:436_2: 4998] kernfs_fop_write_iter+0x104/0x1a8 [ 438.409628] [7: binder:436_2: 4998] vfs_write+0x24c/0x2f4 [ 438.409640] [7: binder:436_2: 4998] ksys_write+0x78/0xe8 [ 438.409652] [7: binder:436_2: 4998] __arm64_sys_write+0x1c/0x2c [ 438.409664] [7: binder:436_2: 4998] invoke_syscall+0x58/0x114 [ 438.409676] [7: binder:436_2: 4998] el0_svc_common+0xac/0xe0 [ 438.409687] [7: binder:436_2: 4998] do_el0_svc+0x1c/0x28 [ 438.409698] [7: binder:436_2: 4998] el0_svc+0x38/0x68 [ 438.409705] [7: binder:436_2: 4998] el0t_64_sync_handler+0x68/0xbc [ 438.409712] [7: binder:436_2: 4998] el0t_64_sync+0x1a8/0x1acSigned-off-by ping.gao <[email protected]>--- drivers/mmc/host/dw_mmc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/mmc/host/dw_mmc.c +9
-3@@ -3633,9 +3633,15 @@ int dw_mci_runtime_resume(struct device *dev)if (host->slot && (mmc_host_can_gpio_cd (host->slot->mmc) || !mmc_card_is_removable (host->slot->mmc))) { - ret =clk_prepare_enable (host->biu_clk); -if (ret) -return ret; +if (IS_ERR (host->biu_clk)) { +dev_dbg (host->dev,"biu clock not available\n" ); + }else { + ret =clk_prepare_enable (host->biu_clk); +if (ret) { +dev_err (host->dev,"failed to enable biu clock\n" ); + goto err; + } + } } ret =clk_prepare_enable (host->ciu_clk);
Hi,
Quoted 11 lines · Shawn Lin
Quoted 2 lines · ping.gao
some vendor doesn't use
biu_clk, enable it will panic log is below:I still don't understand the real issue you tried to solve.
host->biu_clkis got viadevm_clk_get()indw_mci_probe(). If succeed, immediately it's enabled a few lines below. Otherwise,dw_mci_probe()returns with failure. Seems you are not enabling it in runtime callbacks, but whyclk_prepare_enable(host->biu_clk)is able to work when driver probed?
Based on the error and this patch, I believe what happens is:
1. dw_mci_probe() calls devm_clk_get(host->dev, "biu")
2. The clock does not exist on the platform from Ping Gao, so host->biu_clk gets an error pointer assigned
3. "biu clock not available" gets printed at debug level
4. the error is ignored, but the error pointer is still assigned to host->biu_clk
5. in the runtime PM handler clk_prepare_enable is called for host->biu_clk and thus for an error pointer
Instead of hacking this up even further (as this patch does), the proper fix is to cleanup the probe function. I believe the complete biu clock handling in it could be reduced to this:
host->biu_clk = devm_clk_get_optional_enabled(host->dev, "biu");
ret = PTR_ERR_OR_ZERO(host->biu_clk);
if (ret)
return dev_err_probe(host->dev, ret, "failed to get biu clock\n");That will assign NULL to host->biu_clk when there is no clock defined and it is fine to run clk_prepare_enable() with NULL as clock pointer. Note, that this will handle the clock enabling as part of devm, so you will also have to drop the clk_disable_unprepare() calls from the err_clk_biu goto label and the extra call from dw_mci_remove().
Something similar should probably be done for host->ciu_clk, which seems to have the same incorrect logic.
Greetings,
-- Sebastian
Quoted 63 lines
Quoted 61 lines
[ 438.400868] [7: binder:436_2: 4998] Unable to handle kernel paging request at virtual address fffffffffffffffe [ 438.400877] [7: binder:436_2: 4998] Mem abort info: [ 438.400881] [7: binder:436_2: 4998] ESR = 0x0000000096000005 [ 438.400887] [7: binder:436_2: 4998] EC = 0x25: DABT (current EL), IL = 32 bits [ 438.400894] [7: binder:436_2: 4998] SET = 0, FnV = 0 [ 438.400899] [7: binder:436_2: 4998] EA = 0, S1PTW = 0 [ 438.400904] [7: binder:436_2: 4998] FSC = 0x05: level 1 translation fault ... [ 438.409424] [7: binder:436_2: 4998] Call trace: [ 438.409429] [7: binder:436_2: 4998] clk_prepare+0x10/0x24 [ 438.409439] [7: binder:436_2: 4998] dw_mci_runtime_resume+0x50/0x2d8 [dw_mmc_samsung cd210e210975263404c28fc89778f369f8398f0c] [ 438.409471] [7: binder:436_2: 4998] dw_mci_exynos_runtime_resume+0x18/0x58 [dw_mmc_exynos_samsung 2735a594c7c9c9e8c65b0b87523fbf70dcaabfff] [ 438.409496] [7: binder:436_2: 4998] pm_generic_runtime_resume+0x40/0x58 [ 438.409506] [7: binder:436_2: 4998] pm_runtime_force_resume+0x9c/0x134 [ 438.409517] [7: binder:436_2: 4998] platform_pm_resume+0x40/0x8c [ 438.409529] [7: binder:436_2: 4998] dpm_run_callback+0x64/0x230 [ 438.409540] [7: binder:436_2: 4998] __device_resume+0x1d8/0x394 [ 438.409551] [7: binder:436_2: 4998] dpm_resume+0x110/0x2b8 [ 438.409561] [7: binder:436_2: 4998] dpm_resume_end+0x1c/0x38 [ 438.409570] [7: binder:436_2: 4998] suspend_devices_and_enter+0x828/0xab0 [ 438.409582] [7: binder:436_2: 4998] pm_suspend+0x334/0x618 [ 438.409592] [7: binder:436_2: 4998] state_store+0x104/0x144 [ 438.409601] [7: binder:436_2: 4998] kobj_attr_store+0x30/0x48 [ 438.409610] [7: binder:436_2: 4998] sysfs_kf_write+0x54/0x6c [ 438.409619] [7: binder:436_2: 4998] kernfs_fop_write_iter+0x104/0x1a8 [ 438.409628] [7: binder:436_2: 4998] vfs_write+0x24c/0x2f4 [ 438.409640] [7: binder:436_2: 4998] ksys_write+0x78/0xe8 [ 438.409652] [7: binder:436_2: 4998] __arm64_sys_write+0x1c/0x2c [ 438.409664] [7: binder:436_2: 4998] invoke_syscall+0x58/0x114 [ 438.409676] [7: binder:436_2: 4998] el0_svc_common+0xac/0xe0 [ 438.409687] [7: binder:436_2: 4998] do_el0_svc+0x1c/0x28 [ 438.409698] [7: binder:436_2: 4998] el0_svc+0x38/0x68 [ 438.409705] [7: binder:436_2: 4998] el0t_64_sync_handler+0x68/0xbc [ 438.409712] [7: binder:436_2: 4998] el0t_64_sync+0x1a8/0x1acSigned-off-by ping.gao <[email protected]>--- drivers/mmc/host/dw_mmc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/mmc/host/dw_mmc.c +9
-3@@ -3633,9 +3633,15 @@ int dw_mci_runtime_resume(struct device *dev)if (host->slot && (mmc_host_can_gpio_cd (host->slot->mmc) || !mmc_card_is_removable (host->slot->mmc))) { - ret =clk_prepare_enable (host->biu_clk); -if (ret) -return ret; +if (IS_ERR (host->biu_clk)) { +dev_dbg (host->dev,"biu clock not available\n" ); + }else { + ret =clk_prepare_enable (host->biu_clk); +if (ret) { +dev_err (host->dev,"failed to enable biu clock\n" ); + goto err; + } + } } ret =clk_prepare_enable (host->ciu_clk);
Shawn Lin
maintainerHi Sevastian,
Quoted 17 lines · Sebastian Reichel
Hi,
Quoted 11 lines · Shawn Lin
Quoted 2 lines · ping.gao
some vendor doesn't use
biu_clk, enable it will panic log is below:I still don't understand the real issue you tried to solve.
host->biu_clkis got viadevm_clk_get()indw_mci_probe(). If succeed, immediately it's enabled a few lines below. Otherwise,dw_mci_probe()returns with failure. Seems you are not enabling it in runtime callbacks, but whyclk_prepare_enable(host->biu_clk)is able to work when driver probed?Based on the error and this patch, I believe what happens is:
Quoted 9 lines
1.
dw_mci_probe()callsdevm_clk_get(host->dev, "biu")
2. The clock does not exist on the platform from Ping Gao, sohost->biu_clk gets an error pointer assigned 3. "biu clock not available" gets printed at debug level 4. the error is ignored, but the error pointer is still assigned to host->biu_clk 5. in the runtime PM handler clk_prepare_enable is called for host->biu_clk and thus for an error pointer
Thanks for the details. For example,
1. dw_mci_exynos_probe() enables runtime PM before calling dw_mci_pltfm_register()->dw_mci_probe().
2. biu_clk gets an error and propagate it to dw_mci_pltfm_register(),
3. runtime PM is disabled in dw_mci_exynos_probe() later if seeing error.
Does that mean runtime PM handler is called between step 2 and step 3? If that is the case, how could we allow this happen because the the controller's configuaration isn't been finished yet. Or maybe I misunderstand your point?
Quoted 86 lines
Instead of hacking this up even further (as this patch does), the proper fix is to cleanup the probe function. I believe the complete biu clock handling in it could be reduced to this:
host->biu_clk = devm_clk_get_optional_enabled(host->dev, "biu"); ret = PTR_ERR_OR_ZERO(host->biu_clk); if (ret) return dev_err_probe(host->dev, ret, "failed to get biu clock\n");That will assign NULL to
host->biu_clkwhen there is no clock defined and it is fine to runclk_prepare_enable()with NULL as clock pointer. Note, that this will handle the clock enabling as part of devm, so you will also have to drop theclk_disable_unprepare()calls from theerr_clk_biugoto label and the extra call fromdw_mci_remove().Something similar should probably be done for
host->ciu_clk, which seems to have the same incorrect logic.Greetings,
-- Sebastian
Quoted 63 lines
Quoted 61 lines
[ 438.400868] [7: binder:436_2: 4998] Unable to handle kernel paging request at virtual address fffffffffffffffe [ 438.400877] [7: binder:436_2: 4998] Mem abort info: [ 438.400881] [7: binder:436_2: 4998] ESR = 0x0000000096000005 [ 438.400887] [7: binder:436_2: 4998] EC = 0x25: DABT (current EL), IL = 32 bits [ 438.400894] [7: binder:436_2: 4998] SET = 0, FnV = 0 [ 438.400899] [7: binder:436_2: 4998] EA = 0, S1PTW = 0 [ 438.400904] [7: binder:436_2: 4998] FSC = 0x05: level 1 translation fault ... [ 438.409424] [7: binder:436_2: 4998] Call trace: [ 438.409429] [7: binder:436_2: 4998] clk_prepare+0x10/0x24 [ 438.409439] [7: binder:436_2: 4998] dw_mci_runtime_resume+0x50/0x2d8 [dw_mmc_samsung cd210e210975263404c28fc89778f369f8398f0c] [ 438.409471] [7: binder:436_2: 4998] dw_mci_exynos_runtime_resume+0x18/0x58 [dw_mmc_exynos_samsung 2735a594c7c9c9e8c65b0b87523fbf70dcaabfff] [ 438.409496] [7: binder:436_2: 4998] pm_generic_runtime_resume+0x40/0x58 [ 438.409506] [7: binder:436_2: 4998] pm_runtime_force_resume+0x9c/0x134 [ 438.409517] [7: binder:436_2: 4998] platform_pm_resume+0x40/0x8c [ 438.409529] [7: binder:436_2: 4998] dpm_run_callback+0x64/0x230 [ 438.409540] [7: binder:436_2: 4998] __device_resume+0x1d8/0x394 [ 438.409551] [7: binder:436_2: 4998] dpm_resume+0x110/0x2b8 [ 438.409561] [7: binder:436_2: 4998] dpm_resume_end+0x1c/0x38 [ 438.409570] [7: binder:436_2: 4998] suspend_devices_and_enter+0x828/0xab0 [ 438.409582] [7: binder:436_2: 4998] pm_suspend+0x334/0x618 [ 438.409592] [7: binder:436_2: 4998] state_store+0x104/0x144 [ 438.409601] [7: binder:436_2: 4998] kobj_attr_store+0x30/0x48 [ 438.409610] [7: binder:436_2: 4998] sysfs_kf_write+0x54/0x6c [ 438.409619] [7: binder:436_2: 4998] kernfs_fop_write_iter+0x104/0x1a8 [ 438.409628] [7: binder:436_2: 4998] vfs_write+0x24c/0x2f4 [ 438.409640] [7: binder:436_2: 4998] ksys_write+0x78/0xe8 [ 438.409652] [7: binder:436_2: 4998] __arm64_sys_write+0x1c/0x2c [ 438.409664] [7: binder:436_2: 4998] invoke_syscall+0x58/0x114 [ 438.409676] [7: binder:436_2: 4998] el0_svc_common+0xac/0xe0 [ 438.409687] [7: binder:436_2: 4998] do_el0_svc+0x1c/0x28 [ 438.409698] [7: binder:436_2: 4998] el0_svc+0x38/0x68 [ 438.409705] [7: binder:436_2: 4998] el0t_64_sync_handler+0x68/0xbc [ 438.409712] [7: binder:436_2: 4998] el0t_64_sync+0x1a8/0x1acSigned-off-by ping.gao <[email protected]>--- drivers/mmc/host/dw_mmc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/mmc/host/dw_mmc.c +9
-3@@ -3633,9 +3633,15 @@ int dw_mci_runtime_resume(struct device *dev)if (host->slot && (mmc_host_can_gpio_cd (host->slot->mmc) || !mmc_card_is_removable (host->slot->mmc))) { - ret =clk_prepare_enable (host->biu_clk); -if (ret) -return ret; +if (IS_ERR (host->biu_clk)) { +dev_dbg (host->dev,"biu clock not available\n" ); + }else { + ret =clk_prepare_enable (host->biu_clk); +if (ret) { +dev_err (host->dev,"failed to enable biu clock\n" ); + goto err; + } + } } ret =clk_prepare_enable (host->ciu_clk);
Hi,
Quoted 30 lines · Shawn Lin
Hi Sevastian,
Quoted 17 lines · Sebastian Reichel
Hi,
Quoted 11 lines · Shawn Lin
Quoted 2 lines · ping.gao
some vendor doesn't use
biu_clk, enable it will panic log is below:I still don't understand the real issue you tried to solve.
host->biu_clkis got viadevm_clk_get()indw_mci_probe(). If succeed, immediately it's enabled a few lines below. Otherwise,dw_mci_probe()returns with failure. Seems you are not enabling it in runtime callbacks, but whyclk_prepare_enable(host->biu_clk)is able to work when driver probed?Based on the error and this patch, I believe what happens is:
Quoted 9 lines
1.
dw_mci_probe()callsdevm_clk_get(host->dev, "biu")
2. The clock does not exist on the platform from Ping Gao, sohost->biu_clk gets an error pointer assigned 3. "biu clock not available" gets printed at debug level 4. the error is ignored, but the error pointer is still assigned to host->biu_clk 5. in the runtime PM handler clk_prepare_enable is called for host->biu_clk and thus for an error pointer
Quoted 4 lines
Thanks for the details. For example,
1.dw_mci_exynos_probe()enables runtime PM before calling dw_mci_pltfm_register()->dw_mci_probe().
2.biu_clkgets an error and propagate it todw_mci_pltfm_register(),
The error propagation does not happen. This is the current code in dw_mci_probe():
host->biu_clk = devm_clk_get(host->dev, "biu");
if (IS_ERR(host->biu_clk)) {
dev_dbg(host->dev, "biu clock not available\n");
ret = PTR_ERR(host->biu_clk);
if (ret == -EPROBE_DEFER)
return ret;
/* --- no return here --- */
} else {
ret = clk_prepare_enable(host->biu_clk);
if (ret) {
dev_err(host->dev, "failed to enable biu clock\n");
return ret;
}
}This code continues probing for any error code that is not -EPROBE_DEFER. My understanding is, that this has been done intensionally, since the clock does not exist on some platforms.
Effectively this is an open coded devm_clk_get_optional with the difference that you may not use any clk_* operations on the error code. A minimal fix would be to assign "host->biu_clk = NULL;" at the end of the error handling code, which would open code more of the devm_clk_get_optional() behaviour.
Obviously there is no point in having this open coded and the helper existed since ages, so I strongly suggest to just use that. Either devm_clk_get_optional() or even better devm_clk_get_optional_enabled(). This results in:
- less code, which is easier to understand
- fixing the bug at hand
- proper error handling for errors that are neither -EPROBE_DEFER nor -ENOENT.
- better error/debug messaging behaviour for -EPROBE_DEFER when using dev_err_probe() instead of the dev_dbg print.
Greetings,
-- Sebastian
Quoted 95 lines
3. runtime PM is disabled in
dw_mci_exynos_probe()later if seeing error.Does that mean runtime PM handler is called between step 2 and step 3? If that is the case, how could we allow this happen because the the controller's configuaration isn't been finished yet. Or maybe I misunderstand your point?
Quoted 86 lines
Instead of hacking this up even further (as this patch does), the proper fix is to cleanup the probe function. I believe the complete biu clock handling in it could be reduced to this:
host->biu_clk = devm_clk_get_optional_enabled(host->dev, "biu"); ret = PTR_ERR_OR_ZERO(host->biu_clk); if (ret) return dev_err_probe(host->dev, ret, "failed to get biu clock\n");That will assign NULL to
host->biu_clkwhen there is no clock defined and it is fine to runclk_prepare_enable()with NULL as clock pointer. Note, that this will handle the clock enabling as part of devm, so you will also have to drop theclk_disable_unprepare()calls from theerr_clk_biugoto label and the extra call fromdw_mci_remove().Something similar should probably be done for
host->ciu_clk, which seems to have the same incorrect logic.Greetings,
-- Sebastian
Quoted 63 lines
Quoted 61 lines
[ 438.400868] [7: binder:436_2: 4998] Unable to handle kernel paging request at virtual address fffffffffffffffe [ 438.400877] [7: binder:436_2: 4998] Mem abort info: [ 438.400881] [7: binder:436_2: 4998] ESR = 0x0000000096000005 [ 438.400887] [7: binder:436_2: 4998] EC = 0x25: DABT (current EL), IL = 32 bits [ 438.400894] [7: binder:436_2: 4998] SET = 0, FnV = 0 [ 438.400899] [7: binder:436_2: 4998] EA = 0, S1PTW = 0 [ 438.400904] [7: binder:436_2: 4998] FSC = 0x05: level 1 translation fault ... [ 438.409424] [7: binder:436_2: 4998] Call trace: [ 438.409429] [7: binder:436_2: 4998] clk_prepare+0x10/0x24 [ 438.409439] [7: binder:436_2: 4998] dw_mci_runtime_resume+0x50/0x2d8 [dw_mmc_samsung cd210e210975263404c28fc89778f369f8398f0c] [ 438.409471] [7: binder:436_2: 4998] dw_mci_exynos_runtime_resume+0x18/0x58 [dw_mmc_exynos_samsung 2735a594c7c9c9e8c65b0b87523fbf70dcaabfff] [ 438.409496] [7: binder:436_2: 4998] pm_generic_runtime_resume+0x40/0x58 [ 438.409506] [7: binder:436_2: 4998] pm_runtime_force_resume+0x9c/0x134 [ 438.409517] [7: binder:436_2: 4998] platform_pm_resume+0x40/0x8c [ 438.409529] [7: binder:436_2: 4998] dpm_run_callback+0x64/0x230 [ 438.409540] [7: binder:436_2: 4998] __device_resume+0x1d8/0x394 [ 438.409551] [7: binder:436_2: 4998] dpm_resume+0x110/0x2b8 [ 438.409561] [7: binder:436_2: 4998] dpm_resume_end+0x1c/0x38 [ 438.409570] [7: binder:436_2: 4998] suspend_devices_and_enter+0x828/0xab0 [ 438.409582] [7: binder:436_2: 4998] pm_suspend+0x334/0x618 [ 438.409592] [7: binder:436_2: 4998] state_store+0x104/0x144 [ 438.409601] [7: binder:436_2: 4998] kobj_attr_store+0x30/0x48 [ 438.409610] [7: binder:436_2: 4998] sysfs_kf_write+0x54/0x6c [ 438.409619] [7: binder:436_2: 4998] kernfs_fop_write_iter+0x104/0x1a8 [ 438.409628] [7: binder:436_2: 4998] vfs_write+0x24c/0x2f4 [ 438.409640] [7: binder:436_2: 4998] ksys_write+0x78/0xe8 [ 438.409652] [7: binder:436_2: 4998] __arm64_sys_write+0x1c/0x2c [ 438.409664] [7: binder:436_2: 4998] invoke_syscall+0x58/0x114 [ 438.409676] [7: binder:436_2: 4998] el0_svc_common+0xac/0xe0 [ 438.409687] [7: binder:436_2: 4998] do_el0_svc+0x1c/0x28 [ 438.409698] [7: binder:436_2: 4998] el0_svc+0x38/0x68 [ 438.409705] [7: binder:436_2: 4998] el0t_64_sync_handler+0x68/0xbc [ 438.409712] [7: binder:436_2: 4998] el0t_64_sync+0x1a8/0x1acSigned-off-by ping.gao <[email protected]>--- drivers/mmc/host/dw_mmc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/mmc/host/dw_mmc.c +9
-3@@ -3633,9 +3633,15 @@ int dw_mci_runtime_resume(struct device *dev)if (host->slot && (mmc_host_can_gpio_cd (host->slot->mmc) || !mmc_card_is_removable (host->slot->mmc))) { - ret =clk_prepare_enable (host->biu_clk); -if (ret) -return ret; +if (IS_ERR (host->biu_clk)) { +dev_dbg (host->dev,"biu clock not available\n" ); + }else { + ret =clk_prepare_enable (host->biu_clk); +if (ret) { +dev_err (host->dev,"failed to enable biu clock\n" ); + goto err; + } + } } ret =clk_prepare_enable (host->ciu_clk);
Shawn Lin
maintainerQuoted 56 lines · Sebastian Reichel
Hi,
Quoted 30 lines · Shawn Lin
Hi Sevastian,
Quoted 17 lines · Sebastian Reichel
Hi,
Quoted 11 lines · Shawn Lin
Quoted 2 lines · ping.gao
some vendor doesn't use
biu_clk, enable it will panic log is below:I still don't understand the real issue you tried to solve.
host->biu_clkis got viadevm_clk_get()indw_mci_probe(). If succeed, immediately it's enabled a few lines below. Otherwise,dw_mci_probe()returns with failure. Seems you are not enabling it in runtime callbacks, but whyclk_prepare_enable(host->biu_clk)is able to work when driver probed?Based on the error and this patch, I believe what happens is:
Quoted 9 lines
1.
dw_mci_probe()callsdevm_clk_get(host->dev, "biu")
2. The clock does not exist on the platform from Ping Gao, sohost->biu_clk gets an error pointer assigned 3. "biu clock not available" gets printed at debug level 4. the error is ignored, but the error pointer is still assigned to host->biu_clk 5. in the runtime PM handler clk_prepare_enable is called for host->biu_clk and thus for an error pointerQuoted 4 lines
Thanks for the details. For example,
1.dw_mci_exynos_probe()enables runtime PM before calling dw_mci_pltfm_register()->dw_mci_probe().
2.biu_clkgets an error and propagate it todw_mci_pltfm_register(),The error propagation does not happen. This is the current code in
dw_mci_probe():host->biu_clk = devm_clk_get(host->dev, "biu"); if (IS_ERR(host->biu_clk)) { dev_dbg(host->dev, "biu clock not available\n"); ret = PTR_ERR(host->biu_clk); if (ret == -EPROBE_DEFER) return ret; /* --- no return here --- */ } else { ret = clk_prepare_enable(host->biu_clk); if (ret) { dev_err(host->dev, "failed to enable biu clock\n"); return ret; } }
Quoted 4 lines
This code continues probing for any error code that is not -EPROBE_DEFER. My understanding is, that this has been done intensionally, since the clock does not exist on some platforms.
I never thought of biu_clk isn't been provided as it's for accessing register/fifo/interrupt/DMA requested by dwc databook. I was suprised it's the optional case for some platforms. What I was thinking is all based on that defer case.
Quoted 5 lines
Effectively this is an open coded
devm_clk_get_optionalwith the difference that you may not use any clk_* operations on the error code. A minimal fix would be to assign "host->biu_clk= NULL;" at the end of the error handling code, which would open code more of thedevm_clk_get_optional()behaviour.
Yes, if it's optional case for some platforms, we should use devm_clk_get_optional() instead, both for biu_clk and ciu_clk. Although I will also be surprised to see ciu_clk is also optional, the code should be consistent.
Quoted 112 lines
Obviously there is no point in having this open coded and the helper existed since ages, so I strongly suggest to just use that. Either
devm_clk_get_optional()or even betterdevm_clk_get_optional_enabled(). This results in:- less code, which is easier to understand
- fixing the bug at hand
- proper error handling for errors that are neither -EPROBE_DEFER nor-ENOENT.
- better error/debug messaging behaviour for -EPROBE_DEFER when usingdev_err_probe()instead of thedev_dbgprint.Greetings,
-- Sebastian
Quoted 95 lines
3. runtime PM is disabled in
dw_mci_exynos_probe()later if seeing error.Does that mean runtime PM handler is called between step 2 and step 3? If that is the case, how could we allow this happen because the the controller's configuaration isn't been finished yet. Or maybe I misunderstand your point?
Quoted 86 lines
Instead of hacking this up even further (as this patch does), the proper fix is to cleanup the probe function. I believe the complete biu clock handling in it could be reduced to this:
host->biu_clk = devm_clk_get_optional_enabled(host->dev, "biu"); ret = PTR_ERR_OR_ZERO(host->biu_clk); if (ret) return dev_err_probe(host->dev, ret, "failed to get biu clock\n");That will assign NULL to
host->biu_clkwhen there is no clock defined and it is fine to runclk_prepare_enable()with NULL as clock pointer. Note, that this will handle the clock enabling as part of devm, so you will also have to drop theclk_disable_unprepare()calls from theerr_clk_biugoto label and the extra call fromdw_mci_remove().Something similar should probably be done for
host->ciu_clk, which seems to have the same incorrect logic.Greetings,
-- Sebastian
Quoted 63 lines
Quoted 61 lines
[ 438.400868] [7: binder:436_2: 4998] Unable to handle kernel paging request at virtual address fffffffffffffffe [ 438.400877] [7: binder:436_2: 4998] Mem abort info: [ 438.400881] [7: binder:436_2: 4998] ESR = 0x0000000096000005 [ 438.400887] [7: binder:436_2: 4998] EC = 0x25: DABT (current EL), IL = 32 bits [ 438.400894] [7: binder:436_2: 4998] SET = 0, FnV = 0 [ 438.400899] [7: binder:436_2: 4998] EA = 0, S1PTW = 0 [ 438.400904] [7: binder:436_2: 4998] FSC = 0x05: level 1 translation fault ... [ 438.409424] [7: binder:436_2: 4998] Call trace: [ 438.409429] [7: binder:436_2: 4998] clk_prepare+0x10/0x24 [ 438.409439] [7: binder:436_2: 4998] dw_mci_runtime_resume+0x50/0x2d8 [dw_mmc_samsung cd210e210975263404c28fc89778f369f8398f0c] [ 438.409471] [7: binder:436_2: 4998] dw_mci_exynos_runtime_resume+0x18/0x58 [dw_mmc_exynos_samsung 2735a594c7c9c9e8c65b0b87523fbf70dcaabfff] [ 438.409496] [7: binder:436_2: 4998] pm_generic_runtime_resume+0x40/0x58 [ 438.409506] [7: binder:436_2: 4998] pm_runtime_force_resume+0x9c/0x134 [ 438.409517] [7: binder:436_2: 4998] platform_pm_resume+0x40/0x8c [ 438.409529] [7: binder:436_2: 4998] dpm_run_callback+0x64/0x230 [ 438.409540] [7: binder:436_2: 4998] __device_resume+0x1d8/0x394 [ 438.409551] [7: binder:436_2: 4998] dpm_resume+0x110/0x2b8 [ 438.409561] [7: binder:436_2: 4998] dpm_resume_end+0x1c/0x38 [ 438.409570] [7: binder:436_2: 4998] suspend_devices_and_enter+0x828/0xab0 [ 438.409582] [7: binder:436_2: 4998] pm_suspend+0x334/0x618 [ 438.409592] [7: binder:436_2: 4998] state_store+0x104/0x144 [ 438.409601] [7: binder:436_2: 4998] kobj_attr_store+0x30/0x48 [ 438.409610] [7: binder:436_2: 4998] sysfs_kf_write+0x54/0x6c [ 438.409619] [7: binder:436_2: 4998] kernfs_fop_write_iter+0x104/0x1a8 [ 438.409628] [7: binder:436_2: 4998] vfs_write+0x24c/0x2f4 [ 438.409640] [7: binder:436_2: 4998] ksys_write+0x78/0xe8 [ 438.409652] [7: binder:436_2: 4998] __arm64_sys_write+0x1c/0x2c [ 438.409664] [7: binder:436_2: 4998] invoke_syscall+0x58/0x114 [ 438.409676] [7: binder:436_2: 4998] el0_svc_common+0xac/0xe0 [ 438.409687] [7: binder:436_2: 4998] do_el0_svc+0x1c/0x28 [ 438.409698] [7: binder:436_2: 4998] el0_svc+0x38/0x68 [ 438.409705] [7: binder:436_2: 4998] el0t_64_sync_handler+0x68/0xbc [ 438.409712] [7: binder:436_2: 4998] el0t_64_sync+0x1a8/0x1acSigned-off-by ping.gao <[email protected]>--- drivers/mmc/host/dw_mmc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/mmc/host/dw_mmc.c +9
-3@@ -3633,9 +3633,15 @@ int dw_mci_runtime_resume(struct device *dev)if (host->slot && (mmc_host_can_gpio_cd (host->slot->mmc) || !mmc_card_is_removable (host->slot->mmc))) { - ret =clk_prepare_enable (host->biu_clk); -if (ret) -return ret; +if (IS_ERR (host->biu_clk)) { +dev_dbg (host->dev,"biu clock not available\n" ); + }else { + ret =clk_prepare_enable (host->biu_clk); +if (ret) { +dev_err (host->dev,"failed to enable biu clock\n" ); + goto err; + } + } } ret =clk_prepare_enable (host->ciu_clk);