diff mbox series

[7/8] ASoC: topology: suppress probe deferral errors

Message ID 20230705123018.30903-8-johan+linaro@kernel.org (mailing list archive)
State Accepted
Commit b6c3bdda3a7e43acfcec711ce20e7cfe44744740
Headers show
Series ASoC/soundwire/qdsp6/wcd: fix leaks and probe deferral | expand

Commit Message

Johan Hovold July 5, 2023, 12:30 p.m. UTC
Suppress probe deferral error messages when loading topologies and
creating frontend links to avoid spamming the logs when a component has
not yet been registered:

    snd-sc8280xp sound: ASoC: adding FE link failed
    snd-sc8280xp sound: ASoC: topology: could not load header: -517

Note that dev_err_probe() is not used as the topology component can be
probed and removed while the underlying platform device remains bound to
its driver.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 sound/soc/soc-topology.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Amadeusz Sławiński July 5, 2023, 3:07 p.m. UTC | #1
On 7/5/2023 2:30 PM, Johan Hovold wrote:
> Suppress probe deferral error messages when loading topologies and
> creating frontend links to avoid spamming the logs when a component has
> not yet been registered:
> 
>      snd-sc8280xp sound: ASoC: adding FE link failed
>      snd-sc8280xp sound: ASoC: topology: could not load header: -517
> 
> Note that dev_err_probe() is not used as the topology component can be
> probed and removed while the underlying platform device remains bound to
> its driver.

I'm not sure that I understand that argument... what's wrong with
dev_err_probe(tplg->dev, err, "ASoC: adding FE link failed\n");
instead of
dev_err(tplg->dev, "ASoC: adding FE link failed\n");
?
Personally I would prefer dev_err_probe() to be used as it also provides 
debug message.

> 
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
>   sound/soc/soc-topology.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
> index d0aca6b9058b..696c9647debe 100644
> --- a/sound/soc/soc-topology.c
> +++ b/sound/soc/soc-topology.c
> @@ -1751,7 +1751,8 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
>   
>   	ret = snd_soc_add_pcm_runtimes(tplg->comp->card, link, 1);
>   	if (ret < 0) {
> -		dev_err(tplg->dev, "ASoC: adding FE link failed\n");
> +		if (ret != -EPROBE_DEFER)
> +			dev_err(tplg->dev, "ASoC: adding FE link failed\n");
>   		goto err;
>   	}
>   
> @@ -2514,8 +2515,11 @@ static int soc_tplg_process_headers(struct soc_tplg *tplg)
>   			/* load the header object */
>   			ret = soc_tplg_load_header(tplg, hdr);
>   			if (ret < 0) {
> -				dev_err(tplg->dev,
> -					"ASoC: topology: could not load header: %d\n", ret);
> +				if (ret != -EPROBE_DEFER) {
> +					dev_err(tplg->dev,
> +						"ASoC: topology: could not load header: %d\n",
> +						ret);
> +				}
>   				return ret;
>   			}
>
Johan Hovold July 6, 2023, 6:14 a.m. UTC | #2
On Wed, Jul 05, 2023 at 05:07:22PM +0200, Amadeusz Sławiński wrote:
> On 7/5/2023 2:30 PM, Johan Hovold wrote:
> > Suppress probe deferral error messages when loading topologies and
> > creating frontend links to avoid spamming the logs when a component has
> > not yet been registered:
> > 
> >      snd-sc8280xp sound: ASoC: adding FE link failed
> >      snd-sc8280xp sound: ASoC: topology: could not load header: -517
> > 
> > Note that dev_err_probe() is not used as the topology component can be
> > probed and removed while the underlying platform device remains bound to
> > its driver.
> 
> I'm not sure that I understand that argument... what's wrong with
> dev_err_probe(tplg->dev, err, "ASoC: adding FE link failed\n");
> instead of
> dev_err(tplg->dev, "ASoC: adding FE link failed\n");
> ?

In short, it is not correct to use dev_err_probe() here as this is not a
probe function.

dev_err_probe() is tied to driver core and will specifically allocate
and associate an error message with the struct device on probe
deferrals, which is later freed when the struct device is bound to a
driver (or released).

For ASoC drivers, the struct device is typically bound to a driver long
before the components they register are "probed". I use quotation marks
as this is not probing in the driver model sense of the word and the
underlying struct device is already bound to a driver when the component
is "probed".

> Personally I would prefer dev_err_probe() to be used as it also provides 
> debug message.

Yeah, but it would be conceptually wrong to do so (besides the fact that
it would waste some memory).

Johan
Amadeusz Sławiński July 6, 2023, 7:25 a.m. UTC | #3
On 7/6/2023 8:14 AM, Johan Hovold wrote:
> On Wed, Jul 05, 2023 at 05:07:22PM +0200, Amadeusz Sławiński wrote:
>> On 7/5/2023 2:30 PM, Johan Hovold wrote:
>>> Suppress probe deferral error messages when loading topologies and
>>> creating frontend links to avoid spamming the logs when a component has
>>> not yet been registered:
>>>
>>>       snd-sc8280xp sound: ASoC: adding FE link failed
>>>       snd-sc8280xp sound: ASoC: topology: could not load header: -517
>>>
>>> Note that dev_err_probe() is not used as the topology component can be
>>> probed and removed while the underlying platform device remains bound to
>>> its driver.
>>
>> I'm not sure that I understand that argument... what's wrong with
>> dev_err_probe(tplg->dev, err, "ASoC: adding FE link failed\n");
>> instead of
>> dev_err(tplg->dev, "ASoC: adding FE link failed\n");
>> ?
> 
> In short, it is not correct to use dev_err_probe() here as this is not a
> probe function.
> 
> dev_err_probe() is tied to driver core and will specifically allocate
> and associate an error message with the struct device on probe
> deferrals, which is later freed when the struct device is bound to a
> driver (or released).
> 

I guess you mean call to: device_set_deferred_probe_reason(dev, &vaf);
perhaps functionality could be extended to allow to skip this call and 
just do prints? Or just add separate dev_err_defer function without this 
step, although it would be best if they could share parts of code.
Johan Hovold July 10, 2023, 12:01 p.m. UTC | #4
On Thu, Jul 06, 2023 at 09:25:26AM +0200, Amadeusz Sławiński wrote:
> On 7/6/2023 8:14 AM, Johan Hovold wrote:

> > In short, it is not correct to use dev_err_probe() here as this is not a
> > probe function.
> > 
> > dev_err_probe() is tied to driver core and will specifically allocate
> > and associate an error message with the struct device on probe
> > deferrals, which is later freed when the struct device is bound to a
> > driver (or released).

> I guess you mean call to: device_set_deferred_probe_reason(dev, &vaf);
> perhaps functionality could be extended to allow to skip this call and 
> just do prints? Or just add separate dev_err_defer function without this 
> step, although it would be best if they could share parts of code.

Feel free to suggest adding such a function if you think it's
worthwhile. It doesn't exist today it should not be a prerequisite for
suppressing these error messages.

Johan
diff mbox series

Patch

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index d0aca6b9058b..696c9647debe 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1751,7 +1751,8 @@  static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
 
 	ret = snd_soc_add_pcm_runtimes(tplg->comp->card, link, 1);
 	if (ret < 0) {
-		dev_err(tplg->dev, "ASoC: adding FE link failed\n");
+		if (ret != -EPROBE_DEFER)
+			dev_err(tplg->dev, "ASoC: adding FE link failed\n");
 		goto err;
 	}
 
@@ -2514,8 +2515,11 @@  static int soc_tplg_process_headers(struct soc_tplg *tplg)
 			/* load the header object */
 			ret = soc_tplg_load_header(tplg, hdr);
 			if (ret < 0) {
-				dev_err(tplg->dev,
-					"ASoC: topology: could not load header: %d\n", ret);
+				if (ret != -EPROBE_DEFER) {
+					dev_err(tplg->dev,
+						"ASoC: topology: could not load header: %d\n",
+						ret);
+				}
 				return ret;
 			}