diff mbox series

ASoC: dapm: Revert "use component prefix when checking widget names"

Message ID 20210703125034.24655-1-rf@opensource.cirrus.com
State New
Headers show
Series ASoC: dapm: Revert "use component prefix when checking widget names" | expand

Commit Message

Richard Fitzgerald July 3, 2021, 12:50 p.m. UTC
This reverts
commit ae4fc532244b ("ASoC: dapm: use component prefix when checking widget names")

That commit breaks all users of the snd_soc_component_*_pin() functions
because it results in the prefix being added twice. It also breaks code
that correctly uses the snd_soc_dapm_*_pin() functions.

Use the snd_soc_component_*_pin() functions if you want the component
prefix to be prepended automatically.

Use the raw snd_soc_dapm_*_pin() functions if the caller has the full
name that should be matched exactly.

Fixes: commit ae4fc532244b ("ASoC: dapm: use component prefix when checking widget names")
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/soc-dapm.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Comments

Mark Brown July 5, 2021, 4:50 p.m. UTC | #1
On Sat, Jul 03, 2021 at 01:50:34PM +0100, Richard Fitzgerald wrote:

> That commit breaks all users of the snd_soc_component_*_pin() functions
> because it results in the prefix being added twice. It also breaks code
> that correctly uses the snd_soc_dapm_*_pin() functions.

> Use the snd_soc_component_*_pin() functions if you want the component
> prefix to be prepended automatically.

> Use the raw snd_soc_dapm_*_pin() functions if the caller has the full
> name that should be matched exactly.

I'm not sure the analysis of which function to use when is correct or
what we want here (though it will work ATM), though looking again more
closely at the patch it doesn't look entirely right either.  The way
this used to be done, and the way that older code will most likely
assume things work, was that the DAPM functions would first try to match
on the local DAPM context before falling back to doing a global match.
This is what the fallback loop is intended to do, and the dapm functions
are passing the "search other contexts" flag into dapm_find_widget().

I'd not expect the distinction you seem to expect between component and
DAPM and we probably have a bunch of older drivers that aren't working
correctly like the Realtek driver mentioned in the original fix.  I
think what needs to happen is that dapm_find_widget() needs to be
checking both the prefixed and non-prefixed names, and that the
component stuff shouldn't need to bother and just be a convenience
wrapper for users that happene to have a component to hand.
Alternatively we need to do an audit of all the non-machine drivers to
switch them to use the component functions exclusively (and possibly
some of the machine drivers as well), most of the CODEC users look to be
a small number of Wolfson/Cirrus ones.
Richard Fitzgerald July 22, 2021, 9:55 a.m. UTC | #2
On 05/07/2021 17:50, Mark Brown wrote:
> On Sat, Jul 03, 2021 at 01:50:34PM +0100, Richard Fitzgerald wrote:
> 
>> That commit breaks all users of the snd_soc_component_*_pin() functions
>> because it results in the prefix being added twice. It also breaks code
>> that correctly uses the snd_soc_dapm_*_pin() functions.
> 
>> Use the snd_soc_component_*_pin() functions if you want the component
>> prefix to be prepended automatically.
> 
>> Use the raw snd_soc_dapm_*_pin() functions if the caller has the full
>> name that should be matched exactly.
> 
> I'm not sure the analysis of which function to use when is correct or
> what we want here (though it will work ATM), though looking again more
> closely at the patch it doesn't look entirely right either.  The way
> this used to be done, and the way that older code will most likely
> assume things work, was that the DAPM functions would first try to match
> on the local DAPM context before falling back to doing a global match.
> This is what the fallback loop is intended to do, and the dapm functions
> are passing the "search other contexts" flag into dapm_find_widget().
> 
> I'd not expect the distinction you seem to expect between component and
> DAPM and we probably have a bunch of older drivers that aren't working
> correctly like the Realtek driver mentioned in the original fix.  I
> think what needs to happen is that dapm_find_widget() needs to be
> checking both the prefixed and non-prefixed names, and that the
> component stuff shouldn't need to bother and just be a convenience
> wrapper for users that happene to have a component to hand.
> Alternatively we need to do an audit of all the non-machine drivers to
> switch them to use the component functions exclusively (and possibly
> some of the machine drivers as well), most of the CODEC users look to be
> a small number of Wolfson/Cirrus ones.
> 

I don't mind if someone wants to change the core dapm functions if that
is generally useful, providing that it also updates all callers of those
functions to still work.

Changing the behaviour of core code to fix the Realtek driver without
updating other callers of those functions is a problem.
Richard Fitzgerald July 23, 2021, 3:17 p.m. UTC | #3
On 22/07/2021 10:55, Richard Fitzgerald wrote:
> On 05/07/2021 17:50, Mark Brown wrote:
>> On Sat, Jul 03, 2021 at 01:50:34PM +0100, Richard Fitzgerald wrote:
>>
>>> That commit breaks all users of the snd_soc_component_*_pin() functions
>>> because it results in the prefix being added twice. It also breaks code
>>> that correctly uses the snd_soc_dapm_*_pin() functions.
>>
>>> Use the snd_soc_component_*_pin() functions if you want the component
>>> prefix to be prepended automatically.
>>
>>> Use the raw snd_soc_dapm_*_pin() functions if the caller has the full
>>> name that should be matched exactly.
>>
>> I'm not sure the analysis of which function to use when is correct or
>> what we want here (though it will work ATM), though looking again more
>> closely at the patch it doesn't look entirely right either.  The way
>> this used to be done, and the way that older code will most likely
>> assume things work, was that the DAPM functions would first try to match
>> on the local DAPM context before falling back to doing a global match.
>> This is what the fallback loop is intended to do, and the dapm functions
>> are passing the "search other contexts" flag into dapm_find_widget().
>>
>> I'd not expect the distinction you seem to expect between component and
>> DAPM and we probably have a bunch of older drivers that aren't working
>> correctly like the Realtek driver mentioned in the original fix.  I
>> think what needs to happen is that dapm_find_widget() needs to be
>> checking both the prefixed and non-prefixed names, and that the
>> component stuff shouldn't need to bother and just be a convenience
>> wrapper for users that happene to have a component to hand.
>> Alternatively we need to do an audit of all the non-machine drivers to
>> switch them to use the component functions exclusively (and possibly
>> some of the machine drivers as well), most of the CODEC users look to be
>> a small number of Wolfson/Cirrus ones.
>>
> 
> I don't mind if someone wants to change the core dapm functions if that
> is generally useful, providing that it also updates all callers of those
> functions to still work.
> 
> Changing the behaviour of core code to fix the Realtek driver without
> updating other callers of those functions is a problem.

Just to point out this is breaking stuff right now. It's not just
theoretical.
Mark Brown July 23, 2021, 3:24 p.m. UTC | #4
On Fri, Jul 23, 2021 at 04:17:26PM +0100, Richard Fitzgerald wrote:
> On 22/07/2021 10:55, Richard Fitzgerald wrote:
> > On 05/07/2021 17:50, Mark Brown wrote:

> > I don't mind if someone wants to change the core dapm functions if that
> > is generally useful, providing that it also updates all callers of those
> > functions to still work.

> > Changing the behaviour of core code to fix the Realtek driver without
> > updating other callers of those functions is a problem.

> Just to point out this is breaking stuff right now. It's not just
> theoretical.

You took several weeks to respond to my review comment, I'm sure you can
cope with waiting a day or two for a response to your followup (which
I'm having trouble understanding TBH).  It would probably help if you
could specifically identify the problem you are seeing and where you're
seeing it - as I said in my review comment there appears to be a
misconception about how the APIs are expected to work.
Mark Brown July 28, 2021, 4:09 p.m. UTC | #5
On Thu, Jul 22, 2021 at 10:55:23AM +0100, Richard Fitzgerald wrote:

> I don't mind if someone wants to change the core dapm functions if that
> is generally useful, providing that it also updates all callers of those
> functions to still work.

> Changing the behaviour of core code to fix the Realtek driver without
> updating other callers of those functions is a problem.

The thing here is that nobody would have thought that that any caller
would have been open coding this stuff like the component things were,
it's simply the wrong abstraction level to be implementing something
like this so people wouldn't think of auditing the callers to find uses
which might notice that prefixing suddenly worked.
Richard Fitzgerald July 28, 2021, 6:29 p.m. UTC | #6
On 28/07/2021 17:09, Mark Brown wrote:
> On Thu, Jul 22, 2021 at 10:55:23AM +0100, Richard Fitzgerald wrote:
> 
>> I don't mind if someone wants to change the core dapm functions if that
>> is generally useful, providing that it also updates all callers of those
>> functions to still work.
> 
>> Changing the behaviour of core code to fix the Realtek driver without
>> updating other callers of those functions is a problem.
> 
> The thing here is that nobody would have thought that that any caller
> would have been open coding this stuff like the component things were,

On the contrary, since that was the only way to use these functions with
a prefixed component it's entirely possible that there is code already
adding the prefix. Why would you expect nobody has ever written code
that works?

> it's simply the wrong abstraction level to be implementing something

Ok, but that doesn't mean that it could never have happened.

> like this so people wouldn't think of auditing the callers to find uses

I don't think that it's either safe or desirable to skip checking how
callers use functionality that you want to change. My understanding of
Linux development protocol was that if you make a change that affects
other code, you are responsible for updating that other code to match.
Regardless of whether you agree with how that other code was
implemented. It creates a lot of overhead for everyone if it's ok to
make changes without trying to fix up other code that is affected by
that change.
diff mbox series

Patch

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 91bf939d5233..1369a3fea911 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2528,20 +2528,9 @@  static struct snd_soc_dapm_widget *dapm_find_widget(
 {
 	struct snd_soc_dapm_widget *w;
 	struct snd_soc_dapm_widget *fallback = NULL;
-	char prefixed_pin[80];
-	const char *pin_name;
-	const char *prefix = soc_dapm_prefix(dapm);
-
-	if (prefix) {
-		snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
-			 prefix, pin);
-		pin_name = prefixed_pin;
-	} else {
-		pin_name = pin;
-	}
 
 	for_each_card_widgets(dapm->card, w) {
-		if (!strcmp(w->name, pin_name)) {
+		if (!strcmp(w->name, pin)) {
 			if (w->dapm == dapm)
 				return w;
 			else