diff mbox series

ASoC: ti: omap-mcbsp: duplicate sysfs failure after PROBE_DEFER

Message ID 20220614155931.2706437-1-dowens@precisionplanting.com (mailing list archive)
State New, archived
Headers show
Series ASoC: ti: omap-mcbsp: duplicate sysfs failure after PROBE_DEFER | expand

Commit Message

David Owens June 14, 2022, 3:59 p.m. UTC
The call to sdma_pcm_platform_register() can return PROBE_DEFER, leading
to omap_mcbsp_init() being called multiple times.  sysfs node creation
fails in subsequent calls to omap_mcbsp_init(), which prevents
the driver from ever successfully probing.  The resulting errors can be
seen during boot:

[    1.749328] sysfs: cannot create duplicate filename '/devices/platform/68000000.ocp/49022000.mcbsp/max_tx_thres'
[    1.759643] CPU: 0 PID: 6 Comm: kworker/u2:0 Not tainted 5.18.0-yocto-standard #1
[    1.767181] Hardware name: Generic OMAP36xx (Flattened Device Tree)
[    1.773498] Workqueue: events_unbound deferred_probe_work_func
[    1.779449]  unwind_backtrace from show_stack+0x10/0x14
[    1.784729]  show_stack from sysfs_warn_dup+0x4c/0x60
[    1.789825]  sysfs_warn_dup from sysfs_add_file_mode_ns+0x104/0x150
[    1.796142]  sysfs_add_file_mode_ns from internal_create_group+0x10c/0x3ac
[    1.803100]  internal_create_group from asoc_mcbsp_probe+0x270/0x454
[    1.809539]  asoc_mcbsp_probe from platform_probe+0x58/0xb8
[    1.815155]  platform_probe from really_probe+0x14c/0x34c
[    1.820617]  really_probe from __driver_probe_device+0xcc/0x1c0
[    1.826599]  __driver_probe_device from driver_probe_device+0x30/0xd4
[    1.833129]  driver_probe_device from __device_attach_driver+0x8c/0xf0
[    1.839721]  __device_attach_driver from bus_for_each_drv+0x80/0xcc
[    1.846038]  bus_for_each_drv from __device_attach+0xe4/0x170
[    1.851837]  __device_attach from bus_probe_device+0x84/0x8c
[    1.857543]  bus_probe_device from deferred_probe_work_func+0x9c/0xc8
[    1.864044]  deferred_probe_work_func from process_one_work+0x194/0x3b8
[    1.870727]  process_one_work from worker_thread+0x200/0x4cc
[    1.876434]  worker_thread from kthread+0xb8/0xdc
[    1.881195]  kthread from ret_from_fork+0x14/0x2c
[    1.885955] Exception stack(0xc1069fb0 to 0xc1069ff8)
[    1.891052] 9fa0:                                     00000000 00000000 00000000 00000000
[    1.899291] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.907501] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    1.914215] omap-mcbsp 49022000.mcbsp: Unable to create additional controls
[    1.921264] omap-mcbsp: probe of 49022000.mcbsp failed with error -17
[    1.928405] omap-twl4030 sound: devm_snd_soc_register_card() failed: -517

Signed-off-by: David Owens <dowens@precisionplanting.com>
---
 sound/soc/ti/omap-mcbsp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--
2.34.1

This email is intended solely for the use of the individual to whom it is addressed and may contain confidential and/or privileged material. Any views or opinions presented are solely those of the author and do not necessarily represent those of Precision Planting. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. Neither AGCO nor the sender accepts any responsibility for viruses, and it is your responsibility to scan, and virus check the e-mail and its attachment(s) (if any).

Comments

Mark Brown June 14, 2022, 4:08 p.m. UTC | #1
On Tue, Jun 14, 2022 at 10:59:31AM -0500, David Owens wrote:

> The call to sdma_pcm_platform_register() can return PROBE_DEFER, leading
> to omap_mcbsp_init() being called multiple times.  sysfs node creation
> fails in subsequent calls to omap_mcbsp_init(), which prevents
> the driver from ever successfully probing.  The resulting errors can be
> seen during boot:
> 
> [    1.749328] sysfs: cannot create duplicate filename '/devices/platform/68000000.ocp/49022000.mcbsp/max_tx_thres'
> [    1.759643] CPU: 0 PID: 6 Comm: kworker/u2:0 Not tainted 5.18.0-yocto-standard #1
> [    1.767181] Hardware name: Generic OMAP36xx (Flattened Device Tree)
> [    1.773498] Workqueue: events_unbound deferred_probe_work_func
> [    1.779449]  unwind_backtrace from show_stack+0x10/0x14
> [    1.784729]  show_stack from sysfs_warn_dup+0x4c/0x60

Please think hard before including complete backtraces in upstream
reports, they are very large and contain almost no useful information
relative to their size so often obscure the relevant content in your
message. If part of the backtrace is usefully illustrative (it often is
for search engines if nothing else) then it's usually better to pull out
the relevant sections.

> +++ b/sound/soc/ti/omap-mcbsp.c
> @@ -1403,6 +1403,10 @@ static int asoc_mcbsp_probe(struct platform_device *pdev)
>         mcbsp->dev = &pdev->dev;
>         platform_set_drvdata(pdev, mcbsp);
> 
> +       ret = sdma_pcm_platform_register(&pdev->dev, "tx", "rx");
> +       if (ret)
> +               return ret;
> +
>         ret = omap_mcbsp_init(pdev);
>         if (ret)
>                 return ret;
> @@ -1412,13 +1416,9 @@ static int asoc_mcbsp_probe(struct platform_device *pdev)
>                 omap_mcbsp_dai.capture.formats = SNDRV_PCM_FMTBIT_S16_LE;
>         }
> 
> -       ret = devm_snd_soc_register_component(&pdev->dev,
> +       return devm_snd_soc_register_component(&pdev->dev,
>                                               &omap_mcbsp_component,
>                                               &omap_mcbsp_dai, 1);
> -       if (ret)
> -               return ret;
> -
> -       return sdma_pcm_platform_register(&pdev->dev, "tx", "rx");
>  }

It's not clear to me how this fixes the problem, your commit message
doesn't mention how?  I was expecting to see more error handling paths
being added to unwind the sysfs allocation, or a conversion to devm.  As
things stand it's not clear to me that the error won't persist in the
case where we defer registering the component.
David Owens June 14, 2022, 6:38 p.m. UTC | #2
On 6/14/22 11:08, Mark Brown wrote:
> On Tue, Jun 14, 2022 at 10:59:31AM -0500, David Owens wrote:
>
>> The call to sdma_pcm_platform_register() can return PROBE_DEFER, leading
>> to omap_mcbsp_init() being called multiple times.  sysfs node creation
>> fails in subsequent calls to omap_mcbsp_init(), which prevents
>> the driver from ever successfully probing.  The resulting errors can be
>> seen during boot:
>>
>> [    1.749328] sysfs: cannot create duplicate filename '/devices/platform/68000000.ocp/49022000.mcbsp/max_tx_thres'
>> [    1.759643] CPU: 0 PID: 6 Comm: kworker/u2:0 Not tainted 5.18.0-yocto-standard #1
>> [    1.767181] Hardware name: Generic OMAP36xx (Flattened Device Tree)
>> [    1.773498] Workqueue: events_unbound deferred_probe_work_func
>> [    1.779449]  unwind_backtrace from show_stack+0x10/0x14
>> [    1.784729]  show_stack from sysfs_warn_dup+0x4c/0x60
> Please think hard before including complete backtraces in upstream
> reports, they are very large and contain almost no useful information
> relative to their size so often obscure the relevant content in your
> message. If part of the backtrace is usefully illustrative (it often is
> for search engines if nothing else) then it's usually better to pull out
> the relevant sections.
Probably just the "sysfs:" line would suffice.  I'll be sure to limit
traces in the future, thanks for the tip.
>> +++ b/sound/soc/ti/omap-mcbsp.c
>> @@ -1403,6 +1403,10 @@ static int asoc_mcbsp_probe(struct platform_device *pdev)
>>          mcbsp->dev = &pdev->dev;
>>          platform_set_drvdata(pdev, mcbsp);
>>
>> +       ret = sdma_pcm_platform_register(&pdev->dev, "tx", "rx");
>> +       if (ret)
>> +               return ret;
>> +
>>          ret = omap_mcbsp_init(pdev);
>>          if (ret)
>>                  return ret;
>> @@ -1412,13 +1416,9 @@ static int asoc_mcbsp_probe(struct platform_device *pdev)
>>                  omap_mcbsp_dai.capture.formats = SNDRV_PCM_FMTBIT_S16_LE;
>>          }
>>
>> -       ret = devm_snd_soc_register_component(&pdev->dev,
>> +       return devm_snd_soc_register_component(&pdev->dev,
>>                                                &omap_mcbsp_component,
>>                                                &omap_mcbsp_dai, 1);
>> -       if (ret)
>> -               return ret;
>> -
>> -       return sdma_pcm_platform_register(&pdev->dev, "tx", "rx");
>>   }
> It's not clear to me how this fixes the problem, your commit message
> doesn't mention how?  I was expecting to see more error handling paths
> being added to unwind the sysfs allocation, or a conversion to devm.  As
> things stand it's not clear to me that the error won't persist in the
> case where we defer registering the component.

Moving sdma_pcm_platform_register() before sysfs node creation allowed
probe to exit with EPROBE_DEFER without needing to unwind sysfs nodes.
While this worked in my particular case, as you point out it might not
address all probe deferrals.  I can look for a more robust solution and
submit as a v2 patch.

-Dave

This email is intended solely for the use of the individual to whom it is addressed and may contain confidential and/or privileged material. Any views or opinions presented are solely those of the author and do not necessarily represent those of Precision Planting. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. Neither AGCO nor the sender accepts any responsibility for viruses, and it is your responsibility to scan, and virus check the e-mail and its attachment(s) (if any).
diff mbox series

Patch

diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
index 4479d74f0a45..b7c1fb70cb25 100644
--- a/sound/soc/ti/omap-mcbsp.c
+++ b/sound/soc/ti/omap-mcbsp.c
@@ -1403,6 +1403,10 @@  static int asoc_mcbsp_probe(struct platform_device *pdev)
        mcbsp->dev = &pdev->dev;
        platform_set_drvdata(pdev, mcbsp);

+       ret = sdma_pcm_platform_register(&pdev->dev, "tx", "rx");
+       if (ret)
+               return ret;
+
        ret = omap_mcbsp_init(pdev);
        if (ret)
                return ret;
@@ -1412,13 +1416,9 @@  static int asoc_mcbsp_probe(struct platform_device *pdev)
                omap_mcbsp_dai.capture.formats = SNDRV_PCM_FMTBIT_S16_LE;
        }

-       ret = devm_snd_soc_register_component(&pdev->dev,
+       return devm_snd_soc_register_component(&pdev->dev,
                                              &omap_mcbsp_component,
                                              &omap_mcbsp_dai, 1);
-       if (ret)
-               return ret;
-
-       return sdma_pcm_platform_register(&pdev->dev, "tx", "rx");
 }

 static int asoc_mcbsp_remove(struct platform_device *pdev)