Re: Mixer regression with usb soundcard

2017-12-18 Thread Takashi Iwai
On Tue, 19 Dec 2017 02:04:51 +0100,
Mauro Santos wrote:
> 
> On 18-12-2017 22:48, Takashi Iwai wrote:
> > On Mon, 18 Dec 2017 22:56:07 +0100,
> > Mauro Santos wrote:
> >>
> >> On 18-12-2017 19:30, Takashi Iwai wrote:
> >>> On Mon, 18 Dec 2017 20:10:44 +0100,
> >>> Mauro Santos wrote:
> 
>  On 18-12-2017 17:50, Jaejoong Kim wrote:
> > Mauro,
> >
> > Could you please try debug patch(I also attach the patch file)?
> 
>  With the attached patch I get the following when plugging in the usb dac
>  directly to a usb3 port:
>  [   54.391539] usb 1-2: new full-speed USB device number 7 using xhci_hcd
>  [   54.514996] usb 1-2: device descriptor read/64, error -71
>  [   54.849808] input: HiFimeDIY Audio HiFimeDIY DAC as
>  /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
>  [   54.850168] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID
>  v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
>  [   54.950421] usb 1-2: [DEBUG] nameid:0, len:0
>  [   54.950426] usb 1-2: [DEBUG] len:3, get_term_name:PCM
>  [   54.950429] usb 1-2: [11] SU [PCM] items = 2
>  [   54.950985] usbcore: registered new interface driver snd-usb-audio
> >>>
> >>> Hmm, the driver get the supposedly correct name string here, so I see
> >>> no flaw, so far.
> >>>
> >>> Could you put the similar debug prints after reverting the commit and
> >>> compare?  Or, at minimum, you can enable simply the kernel debug
> >>> prints like below:
> >>>
> >>>   % echo "file sound/usb/mixer.c +p" > 
> >>> /sys/kernel/debug/dynamic_debug_control
> >>>
> >>> and re-plug the device.
> >>>
> >>> Also, could you attach the output of "amixer contents" on both working
> >>> and non-working kernels?
> >>>
> >>
> >> I have compiled a new kernel where I have reverted the commit and I've
> >> added the debug output based on your last debug patch. I attach the
> >> patch that reverts the changes and adds the debug output just in case
> >> anyone wants to do a sanity check on it (don't mind the indentation I
> >> think I botched that).
> >>
> >> With the debug patches I get no extra output when echoing to the
> >> dynamic_debug/control file, I guess that's expected.
> >>
> >> I attach the dmesg and amixer outputs for the case without revert plus
> >> debug (bad) and revert plus debug (good).
> >>
> >> One change does jump out:
> >>
> >> bad:  usb 1-2: [11] SU [PCM] items = 2
> >> good: usb 1-2: [11] SU [PCM Capture Source] items = 2
> > 
> > Thanks, that explains what went wrong.  The commit dropped the brace
> > at the if-line, and it ended up with the lack of suffix unless
> > get_term_name() fails.
> > 
> > The fix patch is below.  Could you check whether it cures the issue?
> 
> This patch does seem to work fine for me, I can see all the mixer
> controls for the usb soundcard/dac.
> 
> For good measure I have also tested with a couple of usb headsets and I
> didn't see anything amiss (they don't have any "Capture Source" controls
> though).
> 
> Thank you for looking into this and fixing it.

Good to hear, I queued the fix to for-linus branch.
I'm going to send a pull request for rc5.


thanks,

Takashi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mixer regression with usb soundcard

2017-12-18 Thread Jaejoong Kim
2017-12-19 7:48 GMT+09:00 Takashi Iwai :
> On Mon, 18 Dec 2017 22:56:07 +0100,
> Mauro Santos wrote:
>>
>> On 18-12-2017 19:30, Takashi Iwai wrote:
>> > On Mon, 18 Dec 2017 20:10:44 +0100,
>> > Mauro Santos wrote:
>> >>
>> >> On 18-12-2017 17:50, Jaejoong Kim wrote:
>> >>> Mauro,
>> >>>
>> >>> Could you please try debug patch(I also attach the patch file)?
>> >>
>> >> With the attached patch I get the following when plugging in the usb dac
>> >> directly to a usb3 port:
>> >> [   54.391539] usb 1-2: new full-speed USB device number 7 using xhci_hcd
>> >> [   54.514996] usb 1-2: device descriptor read/64, error -71
>> >> [   54.849808] input: HiFimeDIY Audio HiFimeDIY DAC as
>> >> /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
>> >> [   54.850168] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID
>> >> v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
>> >> [   54.950421] usb 1-2: [DEBUG] nameid:0, len:0
>> >> [   54.950426] usb 1-2: [DEBUG] len:3, get_term_name:PCM
>> >> [   54.950429] usb 1-2: [11] SU [PCM] items = 2
>> >> [   54.950985] usbcore: registered new interface driver snd-usb-audio
>> >
>> > Hmm, the driver get the supposedly correct name string here, so I see
>> > no flaw, so far.
>> >
>> > Could you put the similar debug prints after reverting the commit and
>> > compare?  Or, at minimum, you can enable simply the kernel debug
>> > prints like below:
>> >
>> >   % echo "file sound/usb/mixer.c +p" > 
>> > /sys/kernel/debug/dynamic_debug_control
>> >
>> > and re-plug the device.
>> >
>> > Also, could you attach the output of "amixer contents" on both working
>> > and non-working kernels?
>> >
>>
>> I have compiled a new kernel where I have reverted the commit and I've
>> added the debug output based on your last debug patch. I attach the
>> patch that reverts the changes and adds the debug output just in case
>> anyone wants to do a sanity check on it (don't mind the indentation I
>> think I botched that).
>>
>> With the debug patches I get no extra output when echoing to the
>> dynamic_debug/control file, I guess that's expected.
>>
>> I attach the dmesg and amixer outputs for the case without revert plus
>> debug (bad) and revert plus debug (good).
>>
>> One change does jump out:
>>
>> bad:  usb 1-2: [11] SU [PCM] items = 2
>> good: usb 1-2: [11] SU [PCM Capture Source] items = 2
>
> Thanks, that explains what went wrong.  The commit dropped the brace
> at the if-line, and it ended up with the lack of suffix unless
> get_term_name() fails.
>
> The fix patch is below.  Could you check whether it cures the issue?
>
> Also, Jaejoong, could you check whether it doesn't your device,
> either?  I believe it should keep working, but just to be sure.

I don't have an USB audio DAC with selector unit descriptor.
But your patch file looks good to me. Thanks for fix the regression.

>
>
> Takashi
>
> -- 8< --
> From: Takashi Iwai 
> Subject: [PATCH] ALSA: usb-audio: Fix the missing ctl name suffix at parsing
>  SU
>
> The commit 89b89d121ffc ("ALSA: usb-audio: Add check return value for
> usb_string()") added the check of the return value from
> snd_usb_copy_string_desc(), which is correct per se, but it introduced
> a regression.  In the original code, either the "Clock Source",
> "Playback Source" or "Capture Source" suffix is added after the
> terminal string, while the commit changed it to add the suffix only
> when get_term_name() is failing.  It ended up with an incorrect ctl
> name like "PCM" instead of "PCM Capture Source".
>
> Also, even the original code has a similar bug: when the ctl name is
> generated from snd_usb_copy_string_desc() for the given iSelector, it
> also doesn't put the suffix.
>
> This patch addresses these issues: the suffix is added always when no
> static mapping is found.  Also the patch tries to put more comments
> and cleans up the if/else block for better readability in order to
> avoid the same pitfall again.
>
> Fixes: 89b89d121ffc ("ALSA: usb-audio: Add check return value for 
> usb_string()")
> Reported-by: Mauro Santos 
> Cc: 
> Signed-off-by: Takashi Iwai 
> ---
>  sound/usb/mixer.c | 27 ---
>  1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> index afc208e1c756..60ebc99ae323 100644
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -2173,20 +2173,25 @@ static int parse_audio_selector_unit(struct 
> mixer_build *state, int unitid,
> kctl->private_value = (unsigned long)namelist;
> kctl->private_free = usb_mixer_selector_elem_free;
>
> -   nameid = uac_selector_unit_iSelector(desc);
> +   /* check the static mapping table at first */
> len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
> -   if (len)
> -   ;
> -   else if (nameid)
> -   

Re: Mixer regression with usb soundcard

2017-12-18 Thread Mauro Santos
On 18-12-2017 22:48, Takashi Iwai wrote:
> On Mon, 18 Dec 2017 22:56:07 +0100,
> Mauro Santos wrote:
>>
>> On 18-12-2017 19:30, Takashi Iwai wrote:
>>> On Mon, 18 Dec 2017 20:10:44 +0100,
>>> Mauro Santos wrote:

 On 18-12-2017 17:50, Jaejoong Kim wrote:
> Mauro,
>
> Could you please try debug patch(I also attach the patch file)?

 With the attached patch I get the following when plugging in the usb dac
 directly to a usb3 port:
 [   54.391539] usb 1-2: new full-speed USB device number 7 using xhci_hcd
 [   54.514996] usb 1-2: device descriptor read/64, error -71
 [   54.849808] input: HiFimeDIY Audio HiFimeDIY DAC as
 /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
 [   54.850168] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID
 v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
 [   54.950421] usb 1-2: [DEBUG] nameid:0, len:0
 [   54.950426] usb 1-2: [DEBUG] len:3, get_term_name:PCM
 [   54.950429] usb 1-2: [11] SU [PCM] items = 2
 [   54.950985] usbcore: registered new interface driver snd-usb-audio
>>>
>>> Hmm, the driver get the supposedly correct name string here, so I see
>>> no flaw, so far.
>>>
>>> Could you put the similar debug prints after reverting the commit and
>>> compare?  Or, at minimum, you can enable simply the kernel debug
>>> prints like below:
>>>
>>>   % echo "file sound/usb/mixer.c +p" > 
>>> /sys/kernel/debug/dynamic_debug_control
>>>
>>> and re-plug the device.
>>>
>>> Also, could you attach the output of "amixer contents" on both working
>>> and non-working kernels?
>>>
>>
>> I have compiled a new kernel where I have reverted the commit and I've
>> added the debug output based on your last debug patch. I attach the
>> patch that reverts the changes and adds the debug output just in case
>> anyone wants to do a sanity check on it (don't mind the indentation I
>> think I botched that).
>>
>> With the debug patches I get no extra output when echoing to the
>> dynamic_debug/control file, I guess that's expected.
>>
>> I attach the dmesg and amixer outputs for the case without revert plus
>> debug (bad) and revert plus debug (good).
>>
>> One change does jump out:
>>
>> bad:  usb 1-2: [11] SU [PCM] items = 2
>> good: usb 1-2: [11] SU [PCM Capture Source] items = 2
> 
> Thanks, that explains what went wrong.  The commit dropped the brace
> at the if-line, and it ended up with the lack of suffix unless
> get_term_name() fails.
> 
> The fix patch is below.  Could you check whether it cures the issue?

This patch does seem to work fine for me, I can see all the mixer
controls for the usb soundcard/dac.

For good measure I have also tested with a couple of usb headsets and I
didn't see anything amiss (they don't have any "Capture Source" controls
though).

Thank you for looking into this and fixing it.

> Also, Jaejoong, could you check whether it doesn't your device,
> either?  I believe it should keep working, but just to be sure.
> 
> 
> Takashi
> 
> -- 8< --
> From: Takashi Iwai 
> Subject: [PATCH] ALSA: usb-audio: Fix the missing ctl name suffix at parsing
>  SU
> 
> The commit 89b89d121ffc ("ALSA: usb-audio: Add check return value for
> usb_string()") added the check of the return value from
> snd_usb_copy_string_desc(), which is correct per se, but it introduced
> a regression.  In the original code, either the "Clock Source",
> "Playback Source" or "Capture Source" suffix is added after the
> terminal string, while the commit changed it to add the suffix only
> when get_term_name() is failing.  It ended up with an incorrect ctl
> name like "PCM" instead of "PCM Capture Source".
> 
> Also, even the original code has a similar bug: when the ctl name is
> generated from snd_usb_copy_string_desc() for the given iSelector, it
> also doesn't put the suffix.
> 
> This patch addresses these issues: the suffix is added always when no
> static mapping is found.  Also the patch tries to put more comments
> and cleans up the if/else block for better readability in order to
> avoid the same pitfall again.
> 
> Fixes: 89b89d121ffc ("ALSA: usb-audio: Add check return value for 
> usb_string()")
> Reported-by: Mauro Santos 
> Cc: 
> Signed-off-by: Takashi Iwai 
> ---
>  sound/usb/mixer.c | 27 ---
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> index afc208e1c756..60ebc99ae323 100644
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -2173,20 +2173,25 @@ static int parse_audio_selector_unit(struct 
> mixer_build *state, int unitid,
>   kctl->private_value = (unsigned long)namelist;
>   kctl->private_free = usb_mixer_selector_elem_free;
>  
> - nameid = uac_selector_unit_iSelector(desc);
> + /* check the static mapping table at first */
>   len = check_mapped_name(map, 

Re: Mixer regression with usb soundcard

2017-12-18 Thread Takashi Iwai
On Mon, 18 Dec 2017 22:56:07 +0100,
Mauro Santos wrote:
> 
> On 18-12-2017 19:30, Takashi Iwai wrote:
> > On Mon, 18 Dec 2017 20:10:44 +0100,
> > Mauro Santos wrote:
> >>
> >> On 18-12-2017 17:50, Jaejoong Kim wrote:
> >>> Mauro,
> >>>
> >>> Could you please try debug patch(I also attach the patch file)?
> >>
> >> With the attached patch I get the following when plugging in the usb dac
> >> directly to a usb3 port:
> >> [   54.391539] usb 1-2: new full-speed USB device number 7 using xhci_hcd
> >> [   54.514996] usb 1-2: device descriptor read/64, error -71
> >> [   54.849808] input: HiFimeDIY Audio HiFimeDIY DAC as
> >> /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
> >> [   54.850168] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID
> >> v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
> >> [   54.950421] usb 1-2: [DEBUG] nameid:0, len:0
> >> [   54.950426] usb 1-2: [DEBUG] len:3, get_term_name:PCM
> >> [   54.950429] usb 1-2: [11] SU [PCM] items = 2
> >> [   54.950985] usbcore: registered new interface driver snd-usb-audio
> > 
> > Hmm, the driver get the supposedly correct name string here, so I see
> > no flaw, so far.
> > 
> > Could you put the similar debug prints after reverting the commit and
> > compare?  Or, at minimum, you can enable simply the kernel debug
> > prints like below:
> > 
> >   % echo "file sound/usb/mixer.c +p" > 
> > /sys/kernel/debug/dynamic_debug_control
> > 
> > and re-plug the device.
> > 
> > Also, could you attach the output of "amixer contents" on both working
> > and non-working kernels?
> > 
> 
> I have compiled a new kernel where I have reverted the commit and I've
> added the debug output based on your last debug patch. I attach the
> patch that reverts the changes and adds the debug output just in case
> anyone wants to do a sanity check on it (don't mind the indentation I
> think I botched that).
> 
> With the debug patches I get no extra output when echoing to the
> dynamic_debug/control file, I guess that's expected.
> 
> I attach the dmesg and amixer outputs for the case without revert plus
> debug (bad) and revert plus debug (good).
> 
> One change does jump out:
> 
> bad:  usb 1-2: [11] SU [PCM] items = 2
> good: usb 1-2: [11] SU [PCM Capture Source] items = 2

Thanks, that explains what went wrong.  The commit dropped the brace
at the if-line, and it ended up with the lack of suffix unless
get_term_name() fails.

The fix patch is below.  Could you check whether it cures the issue?

Also, Jaejoong, could you check whether it doesn't your device,
either?  I believe it should keep working, but just to be sure.


Takashi

-- 8< --
From: Takashi Iwai 
Subject: [PATCH] ALSA: usb-audio: Fix the missing ctl name suffix at parsing
 SU

The commit 89b89d121ffc ("ALSA: usb-audio: Add check return value for
usb_string()") added the check of the return value from
snd_usb_copy_string_desc(), which is correct per se, but it introduced
a regression.  In the original code, either the "Clock Source",
"Playback Source" or "Capture Source" suffix is added after the
terminal string, while the commit changed it to add the suffix only
when get_term_name() is failing.  It ended up with an incorrect ctl
name like "PCM" instead of "PCM Capture Source".

Also, even the original code has a similar bug: when the ctl name is
generated from snd_usb_copy_string_desc() for the given iSelector, it
also doesn't put the suffix.

This patch addresses these issues: the suffix is added always when no
static mapping is found.  Also the patch tries to put more comments
and cleans up the if/else block for better readability in order to
avoid the same pitfall again.

Fixes: 89b89d121ffc ("ALSA: usb-audio: Add check return value for usb_string()")
Reported-by: Mauro Santos 
Cc: 
Signed-off-by: Takashi Iwai 
---
 sound/usb/mixer.c | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index afc208e1c756..60ebc99ae323 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2173,20 +2173,25 @@ static int parse_audio_selector_unit(struct mixer_build 
*state, int unitid,
kctl->private_value = (unsigned long)namelist;
kctl->private_free = usb_mixer_selector_elem_free;
 
-   nameid = uac_selector_unit_iSelector(desc);
+   /* check the static mapping table at first */
len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
-   if (len)
-   ;
-   else if (nameid)
-   len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
-sizeof(kctl->id.name));
-   else
-   len = get_term_name(state, >oterm,
-   kctl->id.name, sizeof(kctl->id.name), 0);
-
if (!len) {
-   strlcpy(kctl->id.name, "USB", 

Re: Mixer regression with usb soundcard

2017-12-18 Thread Mauro Santos
On 18-12-2017 21:56, Mauro Santos wrote:
> On 18-12-2017 19:30, Takashi Iwai wrote:
>> On Mon, 18 Dec 2017 20:10:44 +0100,
>> Mauro Santos wrote:
>>>
>>> On 18-12-2017 17:50, Jaejoong Kim wrote:
 Mauro,

 Could you please try debug patch(I also attach the patch file)?
>>>
>>> With the attached patch I get the following when plugging in the usb dac
>>> directly to a usb3 port:
>>> [   54.391539] usb 1-2: new full-speed USB device number 7 using xhci_hcd
>>> [   54.514996] usb 1-2: device descriptor read/64, error -71
>>> [   54.849808] input: HiFimeDIY Audio HiFimeDIY DAC as
>>> /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
>>> [   54.850168] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID
>>> v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
>>> [   54.950421] usb 1-2: [DEBUG] nameid:0, len:0
>>> [   54.950426] usb 1-2: [DEBUG] len:3, get_term_name:PCM
>>> [   54.950429] usb 1-2: [11] SU [PCM] items = 2
>>> [   54.950985] usbcore: registered new interface driver snd-usb-audio
>>
>> Hmm, the driver get the supposedly correct name string here, so I see
>> no flaw, so far.
>>
>> Could you put the similar debug prints after reverting the commit and
>> compare?  Or, at minimum, you can enable simply the kernel debug
>> prints like below:
>>
>>   % echo "file sound/usb/mixer.c +p" > 
>> /sys/kernel/debug/dynamic_debug_control
>>
>> and re-plug the device.
>>
>> Also, could you attach the output of "amixer contents" on both working
>> and non-working kernels?
>>
> 
> I have compiled a new kernel where I have reverted the commit and I've
> added the debug output based on your last debug patch. I attach the
> patch that reverts the changes and adds the debug output just in case
> anyone wants to do a sanity check on it (don't mind the indentation I
> think I botched that).
> 
> With the debug patches I get no extra output when echoing to the
> dynamic_debug/control file, I guess that's expected.
> 
Turns out there is some output, I can't echo and plug, I need to plug,
echo, replug. Dmesg outputs are attached.

> I attach the dmesg and amixer outputs for the case without revert plus
> debug (bad) and revert plus debug (good).
> 
> One change does jump out:
> 
> bad:  usb 1-2: [11] SU [PCM] items = 2
> good: usb 1-2: [11] SU [PCM Capture Source] items = 2
> 


-- 
Mauro Santos
[   81.753703] usb 1-2: new full-speed USB device number 9 using xhci_hcd
[   81.877148] usb 1-2: device descriptor read/64, error -71
[   82.210907] input: HiFimeDIY Audio HiFimeDIY DAC as 
/devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0005/input/input22
[   82.211121] hid-generic 0003:1852:7022.0005: input,hidraw2: USB HID v1.00 
Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
[   82.231042] usb 1-2: [16] FU [PCM Playback Switch] ch = 1, val = 0/1/1
[   82.232211] usb 1-2: cannot set ctl value: req = 0x4, wValue = 0x201, wIndex 
= 0x1001, type = 4, data = 0x40/0x0
[   82.232616] usb 1-2: [16] FU [PCM Playback Volume] ch = 2, val = -14080/0/128
[   82.232626] usb 1-2: [14] FU [Line Capture Switch] ch = 1, val = 0/1/1
[   82.233919] usb 1-2: cannot set ctl value: req = 0x4, wValue = 0x201, wIndex 
= 0xe01, type = 4, data = 0x40/0x0
[   82.234301] usb 1-2: [14] FU [Line Capture Volume] ch = 2, val = 
-10240/3072/128
[   82.234310] usb 1-2: [DEBUG] nameid:0, len:0
[   82.234313] usb 1-2: [DEBUG] len:3, get_term_name:PCM
[   82.234315] usb 1-2: [11] SU [PCM] items = 2
[   59.283418] usb 1-2: new full-speed USB device number 8 using xhci_hcd
[   59.407116] usb 1-2: device descriptor read/64, error -71
[   59.740686] input: HiFimeDIY Audio HiFimeDIY DAC as 
/devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0004/input/input21
[   59.740893] hid-generic 0003:1852:7022.0004: input,hidraw2: USB HID v1.00 
Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
[   59.760971] usb 1-2: [16] FU [PCM Playback Switch] ch = 1, val = 0/1/1
[   59.762056] usb 1-2: cannot set ctl value: req = 0x4, wValue = 0x201, wIndex 
= 0x1001, type = 4, data = 0x40/0x0
[   59.762418] usb 1-2: [16] FU [PCM Playback Volume] ch = 2, val = -14080/0/128
[   59.762423] usb 1-2: [14] FU [Line Capture Switch] ch = 1, val = 0/1/1
[   59.763510] usb 1-2: cannot set ctl value: req = 0x4, wValue = 0x201, wIndex 
= 0xe01, type = 4, data = 0x40/0x0
[   59.763845] usb 1-2: [14] FU [Line Capture Volume] ch = 2, val = 
-10240/3072/128
[   59.763848] usb 1-2: [DEBUG] nameid:0, len:0
[   59.763849] usb 1-2: [DEBUG] len:3, get_term_name:PCM
[   59.763850] usb 1-2: [11] SU [PCM Capture Source] items = 2


Re: Mixer regression with usb soundcard

2017-12-18 Thread Mauro Santos
On 18-12-2017 19:30, Takashi Iwai wrote:
> On Mon, 18 Dec 2017 20:10:44 +0100,
> Mauro Santos wrote:
>>
>> On 18-12-2017 17:50, Jaejoong Kim wrote:
>>> Mauro,
>>>
>>> Could you please try debug patch(I also attach the patch file)?
>>
>> With the attached patch I get the following when plugging in the usb dac
>> directly to a usb3 port:
>> [   54.391539] usb 1-2: new full-speed USB device number 7 using xhci_hcd
>> [   54.514996] usb 1-2: device descriptor read/64, error -71
>> [   54.849808] input: HiFimeDIY Audio HiFimeDIY DAC as
>> /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
>> [   54.850168] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID
>> v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
>> [   54.950421] usb 1-2: [DEBUG] nameid:0, len:0
>> [   54.950426] usb 1-2: [DEBUG] len:3, get_term_name:PCM
>> [   54.950429] usb 1-2: [11] SU [PCM] items = 2
>> [   54.950985] usbcore: registered new interface driver snd-usb-audio
> 
> Hmm, the driver get the supposedly correct name string here, so I see
> no flaw, so far.
> 
> Could you put the similar debug prints after reverting the commit and
> compare?  Or, at minimum, you can enable simply the kernel debug
> prints like below:
> 
>   % echo "file sound/usb/mixer.c +p" > /sys/kernel/debug/dynamic_debug_control
> 
> and re-plug the device.
> 
> Also, could you attach the output of "amixer contents" on both working
> and non-working kernels?
> 

I have compiled a new kernel where I have reverted the commit and I've
added the debug output based on your last debug patch. I attach the
patch that reverts the changes and adds the debug output just in case
anyone wants to do a sanity check on it (don't mind the indentation I
think I botched that).

With the debug patches I get no extra output when echoing to the
dynamic_debug/control file, I guess that's expected.

I attach the dmesg and amixer outputs for the case without revert plus
debug (bad) and revert plus debug (good).

One change does jump out:

bad:  usb 1-2: [11] SU [PCM] items = 2
good: usb 1-2: [11] SU [PCM Capture Source] items = 2

-- 
Mauro Santos
Simple mixer control 'PCM',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 110
  Mono:
  Front Left: Playback 0 [0%] [-55.00dB] [on]
  Front Right: Playback 0 [0%] [-55.00dB] [on]
Simple mixer control 'PCM Capture Source',0
  Capabilities: enum
  Items: 'Line' 'IEC958 In'
  Item0: 'Line'
Simple mixer control 'Line',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 104
  Front Left: Capture 0 [0%] [-40.00dB] [off]
  Front Right: Capture 0 [0%] [-40.00dB] [off]
[   63.600402] usb 1-2: new full-speed USB device number 7 using xhci_hcd
[   63.723739] usb 1-2: device descriptor read/64, error -71
[   64.057506] input: HiFimeDIY Audio HiFimeDIY DAC as 
/devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
[   64.057780] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID v1.00 
Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
[   64.154091] usb 1-2: [DEBUG] nameid:0, len:0
[   64.154095] usb 1-2: [DEBUG] len:3, get_term_name:PCM
[   64.154097] usb 1-2: [11] SU [PCM Capture Source] items = 2
[   64.154495] usbcore: registered new interface driver snd-usb-audio
diff -ur a/sound/usb/mixer.c b/sound/usb/mixer.c
--- a/sound/usb/mixer.c	2017-12-18 19:47:02.748776502 +
+++ b/sound/usb/mixer.c	2017-12-18 20:18:30.023770892 +
@@ -595,7 +595,7 @@
 	while (snd_ctl_find_id(mixer->chip->card, >id))
 		kctl->id.index++;
 	if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) {
-		usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
+		usb_audio_err(mixer->chip, "cannot add control (err = %d)\n",
 			  err);
 		return err;
 	}
@@ -656,10 +656,14 @@
 			 unsigned char *name, int maxlen, int term_only)
 {
 	struct iterm_name_combo *names;
+int len;
 
-	if (iterm->name)
-		return snd_usb_copy_string_desc(state, iterm->name,
+	if (iterm->name) {
+		len = snd_usb_copy_string_desc(state, iterm->name,
 		name, maxlen);
+usb_audio_err(state->chip, "[DEBUG] len:%d, iterm->name:%d\n", len, iterm->name);
+return len;
+}
 
 	/* virtual type - not a real terminal */
 	if (iterm->type >> 16) {
@@ -2175,17 +2179,24 @@
 
 	nameid = uac_selector_unit_iSelector(desc);
 	len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
+
+usb_audio_err(state->chip, "[DEBUG] nameid:%d, len:%d\n", nameid, len);
+
 	if (len)
 		;
-	else if (nameid)
+	else if (nameid) {
 		len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
 	 sizeof(kctl->id.name));
-	else
+usb_audio_err(state->chip, "[DEBUG] len:%d, copy_string id.name:%s\n",
+len, (len > 0) ? kctl->id.name : " ");
+}
+	else {
 		len = get_term_name(state, >oterm,
 kctl->id.name, 

Re: Mixer regression with usb soundcard

2017-12-18 Thread Takashi Iwai
On Mon, 18 Dec 2017 20:10:44 +0100,
Mauro Santos wrote:
> 
> On 18-12-2017 17:50, Jaejoong Kim wrote:
> > Mauro,
> > 
> > Could you please try debug patch(I also attach the patch file)?
> 
> With the attached patch I get the following when plugging in the usb dac
> directly to a usb3 port:
> [   54.391539] usb 1-2: new full-speed USB device number 7 using xhci_hcd
> [   54.514996] usb 1-2: device descriptor read/64, error -71
> [   54.849808] input: HiFimeDIY Audio HiFimeDIY DAC as
> /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
> [   54.850168] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID
> v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
> [   54.950421] usb 1-2: [DEBUG] nameid:0, len:0
> [   54.950426] usb 1-2: [DEBUG] len:3, get_term_name:PCM
> [   54.950429] usb 1-2: [11] SU [PCM] items = 2
> [   54.950985] usbcore: registered new interface driver snd-usb-audio

Hmm, the driver get the supposedly correct name string here, so I see
no flaw, so far.

Could you put the similar debug prints after reverting the commit and
compare?  Or, at minimum, you can enable simply the kernel debug
prints like below:

  % echo "file sound/usb/mixer.c +p" > /sys/kernel/debug/dynamic_debug_control

and re-plug the device.

Also, could you attach the output of "amixer contents" on both working
and non-working kernels?


thanks,

Takashi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mixer regression with usb soundcard

2017-12-18 Thread Mauro Santos
On 18-12-2017 17:50, Jaejoong Kim wrote:
> Mauro,
> 
> Could you please try debug patch(I also attach the patch file)?

With the attached patch I get the following when plugging in the usb dac
directly to a usb3 port:
[   54.391539] usb 1-2: new full-speed USB device number 7 using xhci_hcd
[   54.514996] usb 1-2: device descriptor read/64, error -71
[   54.849808] input: HiFimeDIY Audio HiFimeDIY DAC as
/devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
[   54.850168] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID
v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
[   54.950421] usb 1-2: [DEBUG] nameid:0, len:0
[   54.950426] usb 1-2: [DEBUG] len:3, get_term_name:PCM
[   54.950429] usb 1-2: [11] SU [PCM] items = 2
[   54.950985] usbcore: registered new interface driver snd-usb-audio

> 
> And can you share your usb audio dac? Is this same device with yours?
> https://hifimediy.com/index.php?route=product/product_id=83
> 

It is similar to that but I bought mine in August of 2013.

The description of my device when I bought it was:
HifiMeDiy Sabre USB DAC. Digital to Audio Converter 96khz/24bit (incl
USB to optical converter feature).

I have opened the box and on the PCB mine says UAE23 v1.3A.
It uses a tenor te7022l usb receiver plus a sabre es9032p dac if it matters.

> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> index 84b9f9c..6200aa2 100644
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -595,7 +595,7 @@ int snd_usb_mixer_add_control(struct
> usb_mixer_elem_list *list,
>   while (snd_ctl_find_id(mixer->chip->card, >id))
>   kctl->id.index++;
>   if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) {
> - usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
> + usb_audio_err(mixer->chip, "[DEBUG] cannot add control (err = %d)\n",
> err);
>   return err;
>   }
> @@ -656,10 +656,14 @@ static int get_term_name(struct mixer_build
> *state, struct usb_audio_term *iterm
>   unsigned char *name, int maxlen, int term_only)
>  {
>   struct iterm_name_combo *names;
> + int len;
> 
> - if (iterm->name)
> - return snd_usb_copy_string_desc(state, iterm->name,
> + if (iterm->name) {
> + len = snd_usb_copy_string_desc(state, iterm->name,
>   name, maxlen);
> + usb_audio_err(state->chip, "[DEBUG] len:%d, iterm->name:%d\n", len,
> iterm->name);
> + return len;
> + }
> 
>   /* virtual type - not a real terminal */
>   if (iterm->type >> 16) {
> @@ -2162,14 +2166,23 @@ static int parse_audio_selector_unit(struct
> mixer_build *state, int unitid,
> 
>   nameid = uac_selector_unit_iSelector(desc);
>   len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
> +
> + usb_audio_err(state->chip, "[DEBUG] nameid:%d, len:%d\n", nameid, len);
> +
>   if (len)
>   ;
> - else if (nameid)
> + else if (nameid) {
>   len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
>   sizeof(kctl->id.name));
> - else
> + usb_audio_err(state->chip, "[DEBUG] len:%d, copy_string id.name:%s\n",
> + len, (len > 0) ? kctl->id.name : " ");
> + }
> + else {
>   len = get_term_name(state, >oterm,
>   kctl->id.name, sizeof(kctl->id.name), 0);
> + usb_audio_err(state->chip, "[DEBUG] len:%d, get_term_name:%s\n",
> + len, (len > 0) ? kctl->id.name : " ");
> + }
> 
>   if (!len) {
>   strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
> @@ -2182,7 +2195,7 @@ static int parse_audio_selector_unit(struct
> mixer_build *state, int unitid,
>   append_ctl_name(kctl, " Playback Source");
>   }
> 
> - usb_audio_dbg(state->chip, "[%d] SU [%s] items = %d\n",
> + usb_audio_err(state->chip, "[%d] SU [%s] items = %d\n",
>   cval->head.id, kctl->id.name, desc->bNrInPins);
>   return snd_usb_mixer_add_control(>head, kctl);
>  }
> 
> 
> 2017-12-19 2:19 GMT+09:00 Jaejoong Kim :
>> 2017-12-19 2:13 GMT+09:00 Takashi Iwai :
>>> On Mon, 18 Dec 2017 18:05:18 +0100,
>>> Mauro Santos wrote:

 On 18-12-2017 15:45, Takashi Iwai wrote:
> On Mon, 18 Dec 2017 16:30:13 +0100,
> Mauro Santos wrote:
>>
>> On 18-12-2017 13:53, Takashi Iwai wrote:
>>> On Mon, 18 Dec 2017 14:44:44 +0100,
>>> Greg KH wrote:

 On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
> I believe this is the right place to report this problem, but if it
> isn't please point me in the right direction.

 Adding the developer of that patch, and the sound maintainer and
 developers to the thread.

> I have noticed that after the update from kernel 4.14.5 to 4.14.6
> alsamixer does not show the usual volume controls for my usb 
> soundcard.
>
> Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: 
> Add
> check return value for usb_string() (from linux-stable) makes the
> controls come back again with kernel 4.14.6.
>>> (snip)

 This is odd, Takashi, I 

Re: Mixer regression with usb soundcard

2017-12-18 Thread Mauro Santos
On 18-12-2017 16:59, Jaejoong Kim wrote:
> Mauro,
> thanks for the report and sorry for the make problem.
> 
> Could you try below debug patch? I add more debug code with Takashi's 
> guideline.
> 

I get this when I plug the device directly to a usb3 port:
[   63.643706] usb 1-2: new full-speed USB device number 7 using xhci_hcd
[   63.767089] usb 1-2: device descriptor read/64, error -71
[   64.100906] input: HiFimeDIY Audio HiFimeDIY DAC as
/devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/0003:1852:7022.0003/input/input20
[   64.101208] hid-generic 0003:1852:7022.0003: input,hidraw2: USB HID
v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-2/input0
[   64.208385] usb 1-2: [DEBUG] nameid:0, len:0
[   64.208390] usb 1-2: [DEBUG] len:3, get_term_name:PCM
[   64.208393] usb 1-2: [11] SU [PCM] items = 2
[   64.208881] usbcore: registered new interface driver snd-usb-audio

If I plug it to a usb2 hub where I usually have it connected the output
is almost the same:
[  129.159898] usb 1-3.3: new full-speed USB device number 8 using xhci_hcd
[  129.246587] usb 1-3.3: device descriptor read/64, error -32
[  129.532552] input: HiFimeDIY Audio HiFimeDIY DAC as
/devices/pci:00/:00:14.0/usb1/1-3/1-3.3/1-3.3:1.0/0003:1852:7022.0004/input/input21
[  129.532790] hid-generic 0003:1852:7022.0004: input,hidraw2: USB HID
v1.00 Device [HiFimeDIY Audio HiFimeDIY DAC] on usb-:00:14.0-3.3/input0
[  129.560090] usb 1-3.3: [DEBUG] nameid:0, len:0
[  129.560096] usb 1-3.3: [DEBUG] len:3, get_term_name:PCM
[  129.560100] usb 1-3.3: [11] SU [PCM] items = 2

I'm compiling now a kernel with your other patch, I'll get back to you
with all the information I can gather on the device once I test with the
other patch.

> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> index 84b9f9c..0233425 100644
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -595,7 +595,7 @@ int snd_usb_mixer_add_control(struct
> usb_mixer_elem_list *list,
> while (snd_ctl_find_id(mixer->chip->card, >id))
> kctl->id.index++;
> if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) {
> -   usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
> +   usb_audio_err(mixer->chip, "[DEBUG] cannot add control
> (err = %d)\n",
>   err);
> return err;
> }
> @@ -2162,14 +2162,23 @@ static int parse_audio_selector_unit(struct
> mixer_build *state, int unitid,
> 
> nameid = uac_selector_unit_iSelector(desc);
> len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
> +
> +   usb_audio_err(state->chip, "[DEBUG] nameid:%d, len:%d\n", nameid, 
> len);
> +
> if (len)
> ;
> -   else if (nameid)
> +   else if (nameid) {
> len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
>  sizeof(kctl->id.name));
> -   else
> +   usb_audio_err(state->chip, "[DEBUG] len:%d,
> copy_string id.name:%s\n",
> +   len, (len > 0) ? kctl->id.name : " ");
> +   }
> +   else {
> len = get_term_name(state, >oterm,
> kctl->id.name, sizeof(kctl->id.name), 0);
> +   usb_audio_err(state->chip, "[DEBUG] len:%d, 
> get_term_name:%s\n",
> +   len, (len > 0) ? kctl->id.name : " ");
> +   }
> 
> if (!len) {
> strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
> @@ -2182,7 +2191,7 @@ static int parse_audio_selector_unit(struct
> mixer_build *state, int unitid,
> append_ctl_name(kctl, " Playback Source");
> }
> 
> -   usb_audio_dbg(state->chip, "[%d] SU [%s] items = %d\n",
> +   usb_audio_err(state->chip, "[%d] SU [%s] items = %d\n",
> cval->head.id, kctl->id.name, desc->bNrInPins);
> return snd_usb_mixer_add_control(>head, kctl);
>  }
> 
> 
> 2017-12-19 0:45 GMT+09:00 Takashi Iwai :
>> On Mon, 18 Dec 2017 16:30:13 +0100,
>> Mauro Santos wrote:
>>>
>>> On 18-12-2017 13:53, Takashi Iwai wrote:
 On Mon, 18 Dec 2017 14:44:44 +0100,
 Greg KH wrote:
>
> On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
>> I believe this is the right place to report this problem, but if it
>> isn't please point me in the right direction.
>
> Adding the developer of that patch, and the sound maintainer and
> developers to the thread.
>
>> I have noticed that after the update from kernel 4.14.5 to 4.14.6
>> alsamixer does not show the usual volume controls for my usb soundcard.
>>
>> Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: Add
>> check return value for usb_string() (from linux-stable) makes the
>> controls come back again with kernel 4.14.6.
 (snip)
>
> This is odd, Takashi, I thought 

Re: Mixer regression with usb soundcard

2017-12-18 Thread Jaejoong Kim
Mauro,

Could you please try debug patch(I also attach the patch file)?

And can you share your usb audio dac? Is this same device with yours?
https://hifimediy.com/index.php?route=product/product_id=83

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 84b9f9c..6200aa2 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -595,7 +595,7 @@ int snd_usb_mixer_add_control(struct
usb_mixer_elem_list *list,
  while (snd_ctl_find_id(mixer->chip->card, >id))
  kctl->id.index++;
  if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) {
- usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
+ usb_audio_err(mixer->chip, "[DEBUG] cannot add control (err = %d)\n",
err);
  return err;
  }
@@ -656,10 +656,14 @@ static int get_term_name(struct mixer_build
*state, struct usb_audio_term *iterm
  unsigned char *name, int maxlen, int term_only)
 {
  struct iterm_name_combo *names;
+ int len;

- if (iterm->name)
- return snd_usb_copy_string_desc(state, iterm->name,
+ if (iterm->name) {
+ len = snd_usb_copy_string_desc(state, iterm->name,
  name, maxlen);
+ usb_audio_err(state->chip, "[DEBUG] len:%d, iterm->name:%d\n", len,
iterm->name);
+ return len;
+ }

  /* virtual type - not a real terminal */
  if (iterm->type >> 16) {
@@ -2162,14 +2166,23 @@ static int parse_audio_selector_unit(struct
mixer_build *state, int unitid,

  nameid = uac_selector_unit_iSelector(desc);
  len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
+
+ usb_audio_err(state->chip, "[DEBUG] nameid:%d, len:%d\n", nameid, len);
+
  if (len)
  ;
- else if (nameid)
+ else if (nameid) {
  len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
  sizeof(kctl->id.name));
- else
+ usb_audio_err(state->chip, "[DEBUG] len:%d, copy_string id.name:%s\n",
+ len, (len > 0) ? kctl->id.name : " ");
+ }
+ else {
  len = get_term_name(state, >oterm,
  kctl->id.name, sizeof(kctl->id.name), 0);
+ usb_audio_err(state->chip, "[DEBUG] len:%d, get_term_name:%s\n",
+ len, (len > 0) ? kctl->id.name : " ");
+ }

  if (!len) {
  strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
@@ -2182,7 +2195,7 @@ static int parse_audio_selector_unit(struct
mixer_build *state, int unitid,
  append_ctl_name(kctl, " Playback Source");
  }

- usb_audio_dbg(state->chip, "[%d] SU [%s] items = %d\n",
+ usb_audio_err(state->chip, "[%d] SU [%s] items = %d\n",
  cval->head.id, kctl->id.name, desc->bNrInPins);
  return snd_usb_mixer_add_control(>head, kctl);
 }


2017-12-19 2:19 GMT+09:00 Jaejoong Kim :
> 2017-12-19 2:13 GMT+09:00 Takashi Iwai :
>> On Mon, 18 Dec 2017 18:05:18 +0100,
>> Mauro Santos wrote:
>>>
>>> On 18-12-2017 15:45, Takashi Iwai wrote:
>>> > On Mon, 18 Dec 2017 16:30:13 +0100,
>>> > Mauro Santos wrote:
>>> >>
>>> >> On 18-12-2017 13:53, Takashi Iwai wrote:
>>> >>> On Mon, 18 Dec 2017 14:44:44 +0100,
>>> >>> Greg KH wrote:
>>> 
>>>  On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
>>> > I believe this is the right place to report this problem, but if it
>>> > isn't please point me in the right direction.
>>> 
>>>  Adding the developer of that patch, and the sound maintainer and
>>>  developers to the thread.
>>> 
>>> > I have noticed that after the update from kernel 4.14.5 to 4.14.6
>>> > alsamixer does not show the usual volume controls for my usb 
>>> > soundcard.
>>> >
>>> > Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: 
>>> > Add
>>> > check return value for usb_string() (from linux-stable) makes the
>>> > controls come back again with kernel 4.14.6.
>>> >>> (snip)
>>> 
>>>  This is odd, Takashi, I thought we fixed up the problem that if the
>>>  string was invalid, the code would continue to go on, it's not a "real"
>>>  error.  Did that not get marked for the stable trees?
>>> >>>
>>> >>> Yes, it was marked as stable, and it's odd that the revert of the
>>> >>> given commit changes the behavior in that way.
>>> >>>
>>> >>> Mauro, could you double-check whether reverting the commit really does
>>> >>> fix it as expected?  If yes, could you put some debug print at the
>>> >>> part the patch touches, and check which unit id gives len=0 from
>>> >>> snd_usb_copy_string_desc()?
>>> >>
>>> >> I'm sure reverting that patch makes things work as expected. I noticed
>>> >> the problem after an update and that is the only thing I revert on top
>>> >> of the kernel provided by the distro (Arch Linux).
>>> >
>>> > Did you revert only one patch, not both patches?
>>> > Just to be sure.
>>>
>>> I have reverted only one patch.
>>>
>>> >> Alsamixer works fine for the built in soundcard in my laptop, but the
>>> >> mixer for the usb soundcard was not working so it's specific to usb and
>>> >> only 2 patches touch the mixer.c file between 4.14.5 and 4.14.6. I've
>>> >> tried reversing both, one at a time, and only reverting this one
>>> >> restored the expected behavior.
>>> >>
>>> >> 

Re: Mixer regression with usb soundcard

2017-12-18 Thread Jaejoong Kim
2017-12-19 2:13 GMT+09:00 Takashi Iwai :
> On Mon, 18 Dec 2017 18:05:18 +0100,
> Mauro Santos wrote:
>>
>> On 18-12-2017 15:45, Takashi Iwai wrote:
>> > On Mon, 18 Dec 2017 16:30:13 +0100,
>> > Mauro Santos wrote:
>> >>
>> >> On 18-12-2017 13:53, Takashi Iwai wrote:
>> >>> On Mon, 18 Dec 2017 14:44:44 +0100,
>> >>> Greg KH wrote:
>> 
>>  On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
>> > I believe this is the right place to report this problem, but if it
>> > isn't please point me in the right direction.
>> 
>>  Adding the developer of that patch, and the sound maintainer and
>>  developers to the thread.
>> 
>> > I have noticed that after the update from kernel 4.14.5 to 4.14.6
>> > alsamixer does not show the usual volume controls for my usb soundcard.
>> >
>> > Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: Add
>> > check return value for usb_string() (from linux-stable) makes the
>> > controls come back again with kernel 4.14.6.
>> >>> (snip)
>> 
>>  This is odd, Takashi, I thought we fixed up the problem that if the
>>  string was invalid, the code would continue to go on, it's not a "real"
>>  error.  Did that not get marked for the stable trees?
>> >>>
>> >>> Yes, it was marked as stable, and it's odd that the revert of the
>> >>> given commit changes the behavior in that way.
>> >>>
>> >>> Mauro, could you double-check whether reverting the commit really does
>> >>> fix it as expected?  If yes, could you put some debug print at the
>> >>> part the patch touches, and check which unit id gives len=0 from
>> >>> snd_usb_copy_string_desc()?
>> >>
>> >> I'm sure reverting that patch makes things work as expected. I noticed
>> >> the problem after an update and that is the only thing I revert on top
>> >> of the kernel provided by the distro (Arch Linux).
>> >
>> > Did you revert only one patch, not both patches?
>> > Just to be sure.
>>
>> I have reverted only one patch.
>>
>> >> Alsamixer works fine for the built in soundcard in my laptop, but the
>> >> mixer for the usb soundcard was not working so it's specific to usb and
>> >> only 2 patches touch the mixer.c file between 4.14.5 and 4.14.6. I've
>> >> tried reversing both, one at a time, and only reverting this one
>> >> restored the expected behavior.
>> >>
>> >> Regarding adding the debug print I'm going to need guidance. Without
>> >> reverting anything, would adding at line 2178 of sound/usb/mixer.c the
>> >> following be enough?
>> >>
>> >> printk("usbmixdbg: nameid=%d len=%d 
>> >> id.name=%s\n",nameid,len,kctl->id.name);
>> >>
>> >> It would then look like this (minus the line wrapping):
>> >> len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
>> >> printk("usbmixdbg: nameid=%d len=%d 
>> >> id.name=%s\n",nameid,len,kctl->id.name);
>> >> if (len)
>> >
>> > Well, at that point, there should be no difference.
>> > The difference is after that, so what I'd like to see is something
>> > like:
>> >
>> > --- a/sound/usb/mixer.c
>> > +++ b/sound/usb/mixer.c
>> > @@ -2175,14 +2175,18 @@ static int parse_audio_selector_unit(struct 
>> > mixer_build *state, int unitid,
>> >
>> > nameid = uac_selector_unit_iSelector(desc);
>> > len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
>> > +   pr_info("XXX id=%d, check_mapped_name=%d\n", id, len);
>> > if (len)
>> > ;
>> > -   else if (nameid)
>> > +   else if (nameid) {
>> > len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
>> >  sizeof(kctl->id.name));
>> > -   else
>> > +   pr_info("XXX id=%d, copy_string=%d\n", len);
>> > +   } else {
>> > len = get_term_name(state, >oterm,
>> > kctl->id.name, sizeof(kctl->id.name), 0);
>> > +   pr_info("XXX id=%d, get_term_name=%d\n", len);
>> > +   }
>> >
>> > if (!len) {
>> > strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
>> >
>> >
>> > If you see copy_string=0, it means that your hardware reports a bogus
>> > entry, and the driver does it correctly.  If ignoring that error
>> > really restores the old behavior back, it essentially means that it
>> > worked casually in the past...
>>
>> I have applied your patch on top of 4.14.7 without reverting anything
>> and I was planning to reply only after I had some result but building
>> failed (without any errors strangely).
>>
>> I took a second look at your patch and I have a (maybe silly/naive)
>> question, don't the second and third pr_info calls need an extra
>> argument? There are two %d in the string but only one variable (len).
>
> Yeah, sure, of course you need them :)
> I haven't tested the patch, but just to give you an idea.
> Sorry if you wasted your time due to that.

OK. I will make a debug patch with you last debug code.

--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -656,10 +656,14 @@ 

Re: Mixer regression with usb soundcard

2017-12-18 Thread Takashi Iwai
On Mon, 18 Dec 2017 18:05:18 +0100,
Mauro Santos wrote:
> 
> On 18-12-2017 15:45, Takashi Iwai wrote:
> > On Mon, 18 Dec 2017 16:30:13 +0100,
> > Mauro Santos wrote:
> >>
> >> On 18-12-2017 13:53, Takashi Iwai wrote:
> >>> On Mon, 18 Dec 2017 14:44:44 +0100,
> >>> Greg KH wrote:
> 
>  On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
> > I believe this is the right place to report this problem, but if it
> > isn't please point me in the right direction.
> 
>  Adding the developer of that patch, and the sound maintainer and
>  developers to the thread.
> 
> > I have noticed that after the update from kernel 4.14.5 to 4.14.6
> > alsamixer does not show the usual volume controls for my usb soundcard.
> >
> > Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: Add
> > check return value for usb_string() (from linux-stable) makes the
> > controls come back again with kernel 4.14.6.
> >>> (snip)
> 
>  This is odd, Takashi, I thought we fixed up the problem that if the
>  string was invalid, the code would continue to go on, it's not a "real"
>  error.  Did that not get marked for the stable trees?
> >>>
> >>> Yes, it was marked as stable, and it's odd that the revert of the
> >>> given commit changes the behavior in that way.
> >>>
> >>> Mauro, could you double-check whether reverting the commit really does
> >>> fix it as expected?  If yes, could you put some debug print at the
> >>> part the patch touches, and check which unit id gives len=0 from
> >>> snd_usb_copy_string_desc()?
> >>
> >> I'm sure reverting that patch makes things work as expected. I noticed
> >> the problem after an update and that is the only thing I revert on top
> >> of the kernel provided by the distro (Arch Linux).
> > 
> > Did you revert only one patch, not both patches?
> > Just to be sure.
> 
> I have reverted only one patch.
> 
> >> Alsamixer works fine for the built in soundcard in my laptop, but the
> >> mixer for the usb soundcard was not working so it's specific to usb and
> >> only 2 patches touch the mixer.c file between 4.14.5 and 4.14.6. I've
> >> tried reversing both, one at a time, and only reverting this one
> >> restored the expected behavior.
> >>
> >> Regarding adding the debug print I'm going to need guidance. Without
> >> reverting anything, would adding at line 2178 of sound/usb/mixer.c the
> >> following be enough?
> >>
> >> printk("usbmixdbg: nameid=%d len=%d 
> >> id.name=%s\n",nameid,len,kctl->id.name);
> >>
> >> It would then look like this (minus the line wrapping):
> >> len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
> >> printk("usbmixdbg: nameid=%d len=%d 
> >> id.name=%s\n",nameid,len,kctl->id.name);
> >> if (len)
> > 
> > Well, at that point, there should be no difference.
> > The difference is after that, so what I'd like to see is something
> > like:
> > 
> > --- a/sound/usb/mixer.c
> > +++ b/sound/usb/mixer.c
> > @@ -2175,14 +2175,18 @@ static int parse_audio_selector_unit(struct 
> > mixer_build *state, int unitid,
> >  
> > nameid = uac_selector_unit_iSelector(desc);
> > len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
> > +   pr_info("XXX id=%d, check_mapped_name=%d\n", id, len);
> > if (len)
> > ;
> > -   else if (nameid)
> > +   else if (nameid) {
> > len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
> >  sizeof(kctl->id.name));
> > -   else
> > +   pr_info("XXX id=%d, copy_string=%d\n", len);
> > +   } else {
> > len = get_term_name(state, >oterm,
> > kctl->id.name, sizeof(kctl->id.name), 0);
> > +   pr_info("XXX id=%d, get_term_name=%d\n", len);
> > +   }
> >  
> > if (!len) {
> > strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
> > 
> > 
> > If you see copy_string=0, it means that your hardware reports a bogus
> > entry, and the driver does it correctly.  If ignoring that error
> > really restores the old behavior back, it essentially means that it
> > worked casually in the past...
> 
> I have applied your patch on top of 4.14.7 without reverting anything
> and I was planning to reply only after I had some result but building
> failed (without any errors strangely).
> 
> I took a second look at your patch and I have a (maybe silly/naive)
> question, don't the second and third pr_info calls need an extra
> argument? There are two %d in the string but only one variable (len).

Yeah, sure, of course you need them :)
I haven't tested the patch, but just to give you an idea.
Sorry if you wasted your time due to that.


Takashi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mixer regression with usb soundcard

2017-12-18 Thread Takashi Iwai
On Mon, 18 Dec 2017 17:59:38 +0100,
Jaejoong Kim wrote:
> 
> AudioControl Interface Descriptor:
> bLength 8
> bDescriptorType36
> bDescriptorSubtype  5 (SELECTOR_UNIT)
> bUnitID11
> bNrInPins   2
> baSource( 0)   14
> baSource( 1)5
> iSelector   0
> ^
> 
> >From the lsusb.txt, iSelector is '0' which means
> uac_selector_unit_iSelector() return zero I think.

Yes, and in that case, nameid=0, thus it should go to
get_term_name(), and there must be no difference.
If any difference came from the given commit, it must be nameid!=0,
and yet snd_usb_copy_string_desc(namei) returns an error.

In anyway, another potential fix would be the patch like below.
It covers the case where an error is returned from
snb_usb_copy_string_desc() and doesn't fall back to the default name
resolution.


thanks,

Takashi

--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -656,10 +656,14 @@ static int get_term_name(struct mixer_build *state, 
struct usb_audio_term *iterm
 unsigned char *name, int maxlen, int term_only)
 {
struct iterm_name_combo *names;
+   int len;
 
-   if (iterm->name)
-   return snd_usb_copy_string_desc(state, iterm->name,
+   if (iterm->name) {
+   len = snd_usb_copy_string_desc(state, iterm->name,
name, maxlen);
+   if (len)
+   return len;
+   }
 
/* virtual type - not a real terminal */
if (iterm->type >> 16) {
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mixer regression with usb soundcard

2017-12-18 Thread Mauro Santos
On 18-12-2017 15:45, Takashi Iwai wrote:
> On Mon, 18 Dec 2017 16:30:13 +0100,
> Mauro Santos wrote:
>>
>> On 18-12-2017 13:53, Takashi Iwai wrote:
>>> On Mon, 18 Dec 2017 14:44:44 +0100,
>>> Greg KH wrote:

 On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
> I believe this is the right place to report this problem, but if it
> isn't please point me in the right direction.

 Adding the developer of that patch, and the sound maintainer and
 developers to the thread.

> I have noticed that after the update from kernel 4.14.5 to 4.14.6
> alsamixer does not show the usual volume controls for my usb soundcard.
>
> Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: Add
> check return value for usb_string() (from linux-stable) makes the
> controls come back again with kernel 4.14.6.
>>> (snip)

 This is odd, Takashi, I thought we fixed up the problem that if the
 string was invalid, the code would continue to go on, it's not a "real"
 error.  Did that not get marked for the stable trees?
>>>
>>> Yes, it was marked as stable, and it's odd that the revert of the
>>> given commit changes the behavior in that way.
>>>
>>> Mauro, could you double-check whether reverting the commit really does
>>> fix it as expected?  If yes, could you put some debug print at the
>>> part the patch touches, and check which unit id gives len=0 from
>>> snd_usb_copy_string_desc()?
>>
>> I'm sure reverting that patch makes things work as expected. I noticed
>> the problem after an update and that is the only thing I revert on top
>> of the kernel provided by the distro (Arch Linux).
> 
> Did you revert only one patch, not both patches?
> Just to be sure.

I have reverted only one patch.

>> Alsamixer works fine for the built in soundcard in my laptop, but the
>> mixer for the usb soundcard was not working so it's specific to usb and
>> only 2 patches touch the mixer.c file between 4.14.5 and 4.14.6. I've
>> tried reversing both, one at a time, and only reverting this one
>> restored the expected behavior.
>>
>> Regarding adding the debug print I'm going to need guidance. Without
>> reverting anything, would adding at line 2178 of sound/usb/mixer.c the
>> following be enough?
>>
>> printk("usbmixdbg: nameid=%d len=%d id.name=%s\n",nameid,len,kctl->id.name);
>>
>> It would then look like this (minus the line wrapping):
>> len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
>> printk("usbmixdbg: nameid=%d len=%d id.name=%s\n",nameid,len,kctl->id.name);
>> if (len)
> 
> Well, at that point, there should be no difference.
> The difference is after that, so what I'd like to see is something
> like:
> 
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -2175,14 +2175,18 @@ static int parse_audio_selector_unit(struct 
> mixer_build *state, int unitid,
>  
>   nameid = uac_selector_unit_iSelector(desc);
>   len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
> + pr_info("XXX id=%d, check_mapped_name=%d\n", id, len);
>   if (len)
>   ;
> - else if (nameid)
> + else if (nameid) {
>   len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
>sizeof(kctl->id.name));
> - else
> + pr_info("XXX id=%d, copy_string=%d\n", len);
> + } else {
>   len = get_term_name(state, >oterm,
>   kctl->id.name, sizeof(kctl->id.name), 0);
> + pr_info("XXX id=%d, get_term_name=%d\n", len);
> + }
>  
>   if (!len) {
>   strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
> 
> 
> If you see copy_string=0, it means that your hardware reports a bogus
> entry, and the driver does it correctly.  If ignoring that error
> really restores the old behavior back, it essentially means that it
> worked casually in the past...

I have applied your patch on top of 4.14.7 without reverting anything
and I was planning to reply only after I had some result but building
failed (without any errors strangely).

I took a second look at your patch and I have a (maybe silly/naive)
question, don't the second and third pr_info calls need an extra
argument? There are two %d in the string but only one variable (len).

-- 
Mauro Santos
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mixer regression with usb soundcard

2017-12-18 Thread Jaejoong Kim
Mauro,
thanks for the report and sorry for the make problem.

Could you try below debug patch? I add more debug code with Takashi's guideline.

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 84b9f9c..0233425 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -595,7 +595,7 @@ int snd_usb_mixer_add_control(struct
usb_mixer_elem_list *list,
while (snd_ctl_find_id(mixer->chip->card, >id))
kctl->id.index++;
if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) {
-   usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
+   usb_audio_err(mixer->chip, "[DEBUG] cannot add control
(err = %d)\n",
  err);
return err;
}
@@ -2162,14 +2162,23 @@ static int parse_audio_selector_unit(struct
mixer_build *state, int unitid,

nameid = uac_selector_unit_iSelector(desc);
len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
+
+   usb_audio_err(state->chip, "[DEBUG] nameid:%d, len:%d\n", nameid, len);
+
if (len)
;
-   else if (nameid)
+   else if (nameid) {
len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
 sizeof(kctl->id.name));
-   else
+   usb_audio_err(state->chip, "[DEBUG] len:%d,
copy_string id.name:%s\n",
+   len, (len > 0) ? kctl->id.name : " ");
+   }
+   else {
len = get_term_name(state, >oterm,
kctl->id.name, sizeof(kctl->id.name), 0);
+   usb_audio_err(state->chip, "[DEBUG] len:%d, get_term_name:%s\n",
+   len, (len > 0) ? kctl->id.name : " ");
+   }

if (!len) {
strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
@@ -2182,7 +2191,7 @@ static int parse_audio_selector_unit(struct
mixer_build *state, int unitid,
append_ctl_name(kctl, " Playback Source");
}

-   usb_audio_dbg(state->chip, "[%d] SU [%s] items = %d\n",
+   usb_audio_err(state->chip, "[%d] SU [%s] items = %d\n",
cval->head.id, kctl->id.name, desc->bNrInPins);
return snd_usb_mixer_add_control(>head, kctl);
 }


2017-12-19 0:45 GMT+09:00 Takashi Iwai :
> On Mon, 18 Dec 2017 16:30:13 +0100,
> Mauro Santos wrote:
>>
>> On 18-12-2017 13:53, Takashi Iwai wrote:
>> > On Mon, 18 Dec 2017 14:44:44 +0100,
>> > Greg KH wrote:
>> >>
>> >> On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
>> >>> I believe this is the right place to report this problem, but if it
>> >>> isn't please point me in the right direction.
>> >>
>> >> Adding the developer of that patch, and the sound maintainer and
>> >> developers to the thread.
>> >>
>> >>> I have noticed that after the update from kernel 4.14.5 to 4.14.6
>> >>> alsamixer does not show the usual volume controls for my usb soundcard.
>> >>>
>> >>> Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: Add
>> >>> check return value for usb_string() (from linux-stable) makes the
>> >>> controls come back again with kernel 4.14.6.
>> > (snip)
>> >>
>> >> This is odd, Takashi, I thought we fixed up the problem that if the
>> >> string was invalid, the code would continue to go on, it's not a "real"
>> >> error.  Did that not get marked for the stable trees?
>> >
>> > Yes, it was marked as stable, and it's odd that the revert of the
>> > given commit changes the behavior in that way.
>> >
>> > Mauro, could you double-check whether reverting the commit really does
>> > fix it as expected?  If yes, could you put some debug print at the
>> > part the patch touches, and check which unit id gives len=0 from
>> > snd_usb_copy_string_desc()?
>>
>> I'm sure reverting that patch makes things work as expected. I noticed
>> the problem after an update and that is the only thing I revert on top
>> of the kernel provided by the distro (Arch Linux).
>
> Did you revert only one patch, not both patches?
> Just to be sure.
>
>> Alsamixer works fine for the built in soundcard in my laptop, but the
>> mixer for the usb soundcard was not working so it's specific to usb and
>> only 2 patches touch the mixer.c file between 4.14.5 and 4.14.6. I've
>> tried reversing both, one at a time, and only reverting this one
>> restored the expected behavior.
>>
>> Regarding adding the debug print I'm going to need guidance. Without
>> reverting anything, would adding at line 2178 of sound/usb/mixer.c the
>> following be enough?
>>
>> printk("usbmixdbg: nameid=%d len=%d id.name=%s\n",nameid,len,kctl->id.name);
>>
>> It would then look like this (minus the line wrapping):
>> len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
>> printk("usbmixdbg: nameid=%d len=%d id.name=%s\n",nameid,len,kctl->id.name);
>> if (len)
>
> Well, at that point, there should be no difference.
> The difference is 

Re: Mixer regression with usb soundcard

2017-12-18 Thread Takashi Iwai
On Mon, 18 Dec 2017 16:30:13 +0100,
Mauro Santos wrote:
> 
> On 18-12-2017 13:53, Takashi Iwai wrote:
> > On Mon, 18 Dec 2017 14:44:44 +0100,
> > Greg KH wrote:
> >>
> >> On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
> >>> I believe this is the right place to report this problem, but if it
> >>> isn't please point me in the right direction.
> >>
> >> Adding the developer of that patch, and the sound maintainer and
> >> developers to the thread.
> >>
> >>> I have noticed that after the update from kernel 4.14.5 to 4.14.6
> >>> alsamixer does not show the usual volume controls for my usb soundcard.
> >>>
> >>> Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: Add
> >>> check return value for usb_string() (from linux-stable) makes the
> >>> controls come back again with kernel 4.14.6.
> > (snip)
> >>
> >> This is odd, Takashi, I thought we fixed up the problem that if the
> >> string was invalid, the code would continue to go on, it's not a "real"
> >> error.  Did that not get marked for the stable trees?
> > 
> > Yes, it was marked as stable, and it's odd that the revert of the
> > given commit changes the behavior in that way.
> > 
> > Mauro, could you double-check whether reverting the commit really does
> > fix it as expected?  If yes, could you put some debug print at the
> > part the patch touches, and check which unit id gives len=0 from
> > snd_usb_copy_string_desc()?
> 
> I'm sure reverting that patch makes things work as expected. I noticed
> the problem after an update and that is the only thing I revert on top
> of the kernel provided by the distro (Arch Linux).

Did you revert only one patch, not both patches?
Just to be sure.

> Alsamixer works fine for the built in soundcard in my laptop, but the
> mixer for the usb soundcard was not working so it's specific to usb and
> only 2 patches touch the mixer.c file between 4.14.5 and 4.14.6. I've
> tried reversing both, one at a time, and only reverting this one
> restored the expected behavior.
> 
> Regarding adding the debug print I'm going to need guidance. Without
> reverting anything, would adding at line 2178 of sound/usb/mixer.c the
> following be enough?
> 
> printk("usbmixdbg: nameid=%d len=%d id.name=%s\n",nameid,len,kctl->id.name);
> 
> It would then look like this (minus the line wrapping):
> len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
> printk("usbmixdbg: nameid=%d len=%d id.name=%s\n",nameid,len,kctl->id.name);
> if (len)

Well, at that point, there should be no difference.
The difference is after that, so what I'd like to see is something
like:

--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2175,14 +2175,18 @@ static int parse_audio_selector_unit(struct mixer_build 
*state, int unitid,
 
nameid = uac_selector_unit_iSelector(desc);
len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
+   pr_info("XXX id=%d, check_mapped_name=%d\n", id, len);
if (len)
;
-   else if (nameid)
+   else if (nameid) {
len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
 sizeof(kctl->id.name));
-   else
+   pr_info("XXX id=%d, copy_string=%d\n", len);
+   } else {
len = get_term_name(state, >oterm,
kctl->id.name, sizeof(kctl->id.name), 0);
+   pr_info("XXX id=%d, get_term_name=%d\n", len);
+   }
 
if (!len) {
strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));


If you see copy_string=0, it means that your hardware reports a bogus
entry, and the driver does it correctly.  If ignoring that error
really restores the old behavior back, it essentially means that it
worked casually in the past...


thanks,

Takashi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mixer regression with usb soundcard

2017-12-18 Thread Mauro Santos
On 18-12-2017 13:53, Takashi Iwai wrote:
> On Mon, 18 Dec 2017 14:44:44 +0100,
> Greg KH wrote:
>>
>> On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
>>> I believe this is the right place to report this problem, but if it
>>> isn't please point me in the right direction.
>>
>> Adding the developer of that patch, and the sound maintainer and
>> developers to the thread.
>>
>>> I have noticed that after the update from kernel 4.14.5 to 4.14.6
>>> alsamixer does not show the usual volume controls for my usb soundcard.
>>>
>>> Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: Add
>>> check return value for usb_string() (from linux-stable) makes the
>>> controls come back again with kernel 4.14.6.
> (snip)
>>
>> This is odd, Takashi, I thought we fixed up the problem that if the
>> string was invalid, the code would continue to go on, it's not a "real"
>> error.  Did that not get marked for the stable trees?
> 
> Yes, it was marked as stable, and it's odd that the revert of the
> given commit changes the behavior in that way.
> 
> Mauro, could you double-check whether reverting the commit really does
> fix it as expected?  If yes, could you put some debug print at the
> part the patch touches, and check which unit id gives len=0 from
> snd_usb_copy_string_desc()?

I'm sure reverting that patch makes things work as expected. I noticed
the problem after an update and that is the only thing I revert on top
of the kernel provided by the distro (Arch Linux).

Alsamixer works fine for the built in soundcard in my laptop, but the
mixer for the usb soundcard was not working so it's specific to usb and
only 2 patches touch the mixer.c file between 4.14.5 and 4.14.6. I've
tried reversing both, one at a time, and only reverting this one
restored the expected behavior.

Regarding adding the debug print I'm going to need guidance. Without
reverting anything, would adding at line 2178 of sound/usb/mixer.c the
following be enough?

printk("usbmixdbg: nameid=%d len=%d id.name=%s\n",nameid,len,kctl->id.name);

It would then look like this (minus the line wrapping):
len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
printk("usbmixdbg: nameid=%d len=%d id.name=%s\n",nameid,len,kctl->id.name);
if (len)

-- 
Mauro Santos
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mixer regression with usb soundcard

2017-12-18 Thread Takashi Iwai
On Mon, 18 Dec 2017 14:44:44 +0100,
Greg KH wrote:
> 
> On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
> > I believe this is the right place to report this problem, but if it
> > isn't please point me in the right direction.
> 
> Adding the developer of that patch, and the sound maintainer and
> developers to the thread.
> 
> > I have noticed that after the update from kernel 4.14.5 to 4.14.6
> > alsamixer does not show the usual volume controls for my usb soundcard.
> > 
> > Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: Add
> > check return value for usb_string() (from linux-stable) makes the
> > controls come back again with kernel 4.14.6.
(snip)
> 
> This is odd, Takashi, I thought we fixed up the problem that if the
> string was invalid, the code would continue to go on, it's not a "real"
> error.  Did that not get marked for the stable trees?

Yes, it was marked as stable, and it's odd that the revert of the
given commit changes the behavior in that way.

Mauro, could you double-check whether reverting the commit really does
fix it as expected?  If yes, could you put some debug print at the
part the patch touches, and check which unit id gives len=0 from
snd_usb_copy_string_desc()?


thanks,

Takashi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mixer regression with usb soundcard

2017-12-18 Thread Greg KH
On Sun, Dec 17, 2017 at 06:56:05PM +, Mauro Santos wrote:
> I believe this is the right place to report this problem, but if it
> isn't please point me in the right direction.

Adding the developer of that patch, and the sound maintainer and
developers to the thread.

> I have noticed that after the update from kernel 4.14.5 to 4.14.6
> alsamixer does not show the usual volume controls for my usb soundcard.
> 
> Reverting 3884d12e17ab770aa0f5d4bc65bfbfd006f417fa ALSA: usb-audio: Add
> check return value for usb_string() (from linux-stable) makes the
> controls come back again with kernel 4.14.6.
> 
> Amixer shows a difference between the good and bad case.
> 
> Good amixer output (4.14.5):
> Simple mixer control 'PCM',0
>   Capabilities: pvolume pswitch pswitch-joined
>   Playback channels: Front Left - Front Right
>   Limits: Playback 0 - 110
>   Mono:
>   Front Left: Playback 0 [0%] [-55.00dB] [on]
>   Front Right: Playback 0 [0%] [-55.00dB] [on]
> Simple mixer control 'PCM Capture Source',0
>   Capabilities: enum
>   Items: 'Line' 'IEC958 In'
>   Item0: 'Line'
> Simple mixer control 'Line',0
>   Capabilities: cvolume cswitch cswitch-joined
>   Capture channels: Front Left - Front Right
>   Limits: Capture 0 - 104
>   Front Left: Capture 20 [19%] [-30.00dB] [off]
>   Front Right: Capture 20 [19%] [-30.00dB] [off]
> 
> Bad amixer output (4.14.6):
> Simple mixer control 'PCM',0
>   Capabilities: pvolume pswitch pswitch-joined enum
>   Items: 'Line' 'IEC958 In'
>   Item0: 'Line'
>   Item1: 'Line'
> Simple mixer control 'Line',0
>   Capabilities: cvolume cswitch cswitch-joined
>   Capture channels: Front Left - Front Right
>   Limits: Capture 0 - 104
>   Front Left: Capture 20 [19%] [-30.00dB] [off]
>   Front Right: Capture 20 [19%] [-30.00dB] [off]
> 
> The output of lsusb -v for the affected sound card is attached.
> 
> -- 
> Mauro Santos

> Bus 001 Device 006: ID 1852:7022 GYROCOM C Co., LTD 
> Device Descriptor:
>   bLength18
>   bDescriptorType 1
>   bcdUSB   1.10
>   bDeviceClass0 
>   bDeviceSubClass 0 
>   bDeviceProtocol 0 
>   bMaxPacketSize0 8
>   idVendor   0x1852 GYROCOM C Co., LTD
>   idProduct  0x7022 
>   bcdDevice0.01
>   iManufacturer   1 HiFimeDIY Audio
>   iProduct2 HiFimeDIY DAC
>   iSerial 0 
>   bNumConfigurations  1
>   Configuration Descriptor:
> bLength 9
> bDescriptorType 2
> wTotalLength  428
> bNumInterfaces  4
> bConfigurationValue 1
> iConfiguration  0 
> bmAttributes 0x80
>   (Bus Powered)
> MaxPower  500mA
> Interface Descriptor:
>   bLength 9
>   bDescriptorType 4
>   bInterfaceNumber0
>   bAlternateSetting   0
>   bNumEndpoints   1
>   bInterfaceClass 3 Human Interface Device
>   bInterfaceSubClass  0 
>   bInterfaceProtocol  0 
>   iInterface  0 
> HID Device Descriptor:
>   bLength 9
>   bDescriptorType33
>   bcdHID   1.00
>   bCountryCode0 Not supported
>   bNumDescriptors 1
>   bDescriptorType34 Report
>   wDescriptorLength  58
>  Report Descriptors: 
>** UNAVAILABLE **
>   Endpoint Descriptor:
> bLength 7
> bDescriptorType 5
> bEndpointAddress 0x81  EP 1 IN
> bmAttributes3
>   Transfer TypeInterrupt
>   Synch Type   None
>   Usage Type   Data
> wMaxPacketSize 0x0012  1x 18 bytes
> bInterval  32
> Interface Descriptor:
>   bLength 9
>   bDescriptorType 4
>   bInterfaceNumber1
>   bAlternateSetting   0
>   bNumEndpoints   0
>   bInterfaceClass 1 Audio
>   bInterfaceSubClass  1 Control Device
>   bInterfaceProtocol  0 
>   iInterface  3 SABRE 24/96 DAC_DigiT
>   AudioControl Interface Descriptor:
> bLength10
> bDescriptorType36
> bDescriptorSubtype  1 (HEADER)
> bcdADC   1.00
> wTotalLength   92
> bInCollection   2
> baInterfaceNr( 0)   2
> baInterfaceNr( 1)   3
>   AudioControl Interface Descriptor:
> bLength12
> bDescriptorType36
> bDescriptorSubtype  2 (INPUT_TERMINAL)
> bTerminalID 1
> wTerminalType  0x0603 Line Connector
> bAssocTerminal  0
> bNrChannels 2
> wChannelConfig 0x0003
>   Left Front (L)
>