diff mbox series

[2/2] ALSA: usb-audio: Generic application of implicit fb to Roland/BOSS devices

Message ID 20210422120413.457-2-tiwai@suse.de (mailing list archive)
State Accepted
Commit 316791b556f7c4aeb7a7fea8f400f4434e71d1bf
Headers show
Series [1/2] Revert "ALSA: usb-audio: Add support for many Roland devices..." | expand

Commit Message

Takashi Iwai April 22, 2021, 12:04 p.m. UTC
Through the examinations and experiments with lots of Roland and BOSS
USB-audio devices, we found out that the recently introduced
full-duplex operations with the implicit feedback mode work fine for
quite a few devices, while the others need only the capture-side quirk
to enforce the full-duplex mode.  The recent commit d86f43b17ed4
("ALSA: usb-audio: Add support for many Roland devices' implicit
feedback quirks") tried to add such quirk entries manually in the
lists, but this turned out to be too many and error-prone, hence it
was reverted again.

This patch is another attempt to cover those missing Roland/BOSS
devices but in a more generic way.  It matches the devices with the
vendor ID 0x0582, and checks whether they are with both ASYNC sync
types or ASYNC is only for capture device.  In the former case, it's
the device with the implicit feedback mode, and applies accordingly.
In both cases, the capture stream requires always the full-duplex
mode, and we apply the known capture quirk for that, too.

Basically the already existing BOSS device quirk entries become
redundant after this generic matching, so those are removed.  Although
the capture_implicit_fb_quirks[] table became empty and superfluous, I
keep it for now, so that people can put a special device easily at any
time later again.

Link: https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
Tested-by: Lucas Endres <jaffa225man@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/implicit.c | 92 +++++++++++++++++++++++++++++---------------
 1 file changed, 62 insertions(+), 30 deletions(-)

Comments

Mike Oliphant April 22, 2021, 7:20 p.m. UTC | #1
I had wondered whether the hardcoded endpoints were necessary (or always
accurate).

This method seems much cleaner, and I can report that it is working as
expected (playback-only, record-only, and full duplex) on the BOSS GT-1.

Mike

On Thu, Apr 22, 2021 at 5:04 AM Takashi Iwai <tiwai@suse.de> wrote:

> Through the examinations and experiments with lots of Roland and BOSS
> USB-audio devices, we found out that the recently introduced
> full-duplex operations with the implicit feedback mode work fine for
> quite a few devices, while the others need only the capture-side quirk
> to enforce the full-duplex mode.  The recent commit d86f43b17ed4
> ("ALSA: usb-audio: Add support for many Roland devices' implicit
> feedback quirks") tried to add such quirk entries manually in the
> lists, but this turned out to be too many and error-prone, hence it
> was reverted again.
>
> This patch is another attempt to cover those missing Roland/BOSS
> devices but in a more generic way.  It matches the devices with the
> vendor ID 0x0582, and checks whether they are with both ASYNC sync
> types or ASYNC is only for capture device.  In the former case, it's
> the device with the implicit feedback mode, and applies accordingly.
> In both cases, the capture stream requires always the full-duplex
> mode, and we apply the known capture quirk for that, too.
>
> Basically the already existing BOSS device quirk entries become
> redundant after this generic matching, so those are removed.  Although
> the capture_implicit_fb_quirks[] table became empty and superfluous, I
> keep it for now, so that people can put a special device easily at any
> time later again.
>
> Link:
> https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
> Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
> Tested-by: Lucas Endres <jaffa225man@gmail.com>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>  sound/usb/implicit.c | 92 +++++++++++++++++++++++++++++---------------
>  1 file changed, 62 insertions(+), 30 deletions(-)
>
> diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c
> index 94acfaa7f2ef..590a0dbba7a2 100644
> --- a/sound/usb/implicit.c
> +++ b/sound/usb/implicit.c
> @@ -79,15 +79,6 @@ static const struct snd_usb_implicit_fb_match
> playback_implicit_fb_quirks[] = {
>
>  /* Implicit feedback quirk table for capture: only FIXED type */
>  static const struct snd_usb_implicit_fb_match
> capture_implicit_fb_quirks[] = {
> -       IMPLICIT_FB_BOTH_DEV(0x0582, 0x0130, 0x0d, 0x01), /* BOSS BR-80 */
> -       IMPLICIT_FB_BOTH_DEV(0x0582, 0x0171, 0x0d, 0x01), /* BOSS RC-505 */
> -       IMPLICIT_FB_BOTH_DEV(0x0582, 0x0185, 0x0d, 0x01), /* BOSS GP-10 */
> -       IMPLICIT_FB_BOTH_DEV(0x0582, 0x0189, 0x0d, 0x01), /* BOSS GT-100v2
> */
> -       IMPLICIT_FB_BOTH_DEV(0x0582, 0x01d6, 0x0d, 0x01), /* BOSS GT-1 */
> -       IMPLICIT_FB_BOTH_DEV(0x0582, 0x01d8, 0x0d, 0x01), /* BOSS Katana */
> -       IMPLICIT_FB_BOTH_DEV(0x0582, 0x01e5, 0x0d, 0x01), /* BOSS GT-001 */
> -       IMPLICIT_FB_BOTH_DEV(0x0582, 0x0203, 0x0d, 0x01), /* BOSS AD-10 */
> -
>         {} /* terminator */
>  };
>
> @@ -145,30 +136,70 @@ static int add_generic_uac2_implicit_fb(struct
> snd_usb_audio *chip,
>                                        ifnum, alts);
>  }
>
> -/* Like the function above, but specific to Roland with vendor class and
> hack */
> +static bool roland_sanity_check_iface(struct usb_host_interface *alts)
> +{
> +       if (alts->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC ||
> +           (alts->desc.bInterfaceSubClass != 2 &&
> +            alts->desc.bInterfaceProtocol != 2) ||
> +           alts->desc.bNumEndpoints < 1)
> +               return false;
> +       return true;
> +}
> +
> +/* Like the UAC2 case above, but specific to Roland with vendor class and
> hack */
>  static int add_roland_implicit_fb(struct snd_usb_audio *chip,
>                                   struct audioformat *fmt,
> -                                 unsigned int ifnum,
> -                                 unsigned int altsetting)
> +                                 struct usb_host_interface *alts)
>  {
> -       struct usb_host_interface *alts;
>         struct usb_endpoint_descriptor *epd;
>
> -       alts = snd_usb_get_host_interface(chip, ifnum, altsetting);
> -       if (!alts)
> +       if (!roland_sanity_check_iface(alts))
>                 return 0;
> -       if (alts->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC ||
> -           (alts->desc.bInterfaceSubClass != 2 &&
> -            alts->desc.bInterfaceProtocol != 2) ||
> -           alts->desc.bNumEndpoints < 1)
> +       /* only when both streams are with ASYNC type */
> +       epd = get_endpoint(alts, 0);
> +       if (!usb_endpoint_is_isoc_out(epd) ||
> +           (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) !=
> USB_ENDPOINT_SYNC_ASYNC)
> +               return 0;
> +
> +       /* check capture EP */
> +       alts = snd_usb_get_host_interface(chip,
> +                                         alts->desc.bInterfaceNumber + 1,
> +                                         alts->desc.bAlternateSetting);
> +       if (!alts || !roland_sanity_check_iface(alts))
>                 return 0;
>         epd = get_endpoint(alts, 0);
>         if (!usb_endpoint_is_isoc_in(epd) ||
> -           (epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
> -                                       USB_ENDPOINT_USAGE_IMPLICIT_FB)
> +           (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) !=
> USB_ENDPOINT_SYNC_ASYNC)
>                 return 0;
> +       chip->playback_first = 1;
>         return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
> -                                      ifnum, alts);
> +                                      alts->desc.bInterfaceNumber, alts);
> +}
> +
> +/* capture quirk for Roland device; always full-duplex */
> +static int add_roland_capture_quirk(struct snd_usb_audio *chip,
> +                                   struct audioformat *fmt,
> +                                   struct usb_host_interface *alts)
> +{
> +       struct usb_endpoint_descriptor *epd;
> +
> +       if (!roland_sanity_check_iface(alts))
> +               return 0;
> +       epd = get_endpoint(alts, 0);
> +       if (!usb_endpoint_is_isoc_in(epd) ||
> +           (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) !=
> USB_ENDPOINT_SYNC_ASYNC)
> +               return 0;
> +
> +       alts = snd_usb_get_host_interface(chip,
> +                                         alts->desc.bInterfaceNumber - 1,
> +                                         alts->desc.bAlternateSetting);
> +       if (!alts || !roland_sanity_check_iface(alts))
> +               return 0;
> +       epd = get_endpoint(alts, 0);
> +       if (!usb_endpoint_is_isoc_out(epd))
> +               return 0;
> +       return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
> +                                      alts->desc.bInterfaceNumber, alts);
>  }
>
>  /* Playback and capture EPs on Pioneer devices share the same iface/altset
> @@ -306,14 +337,8 @@ static int audioformat_implicit_fb_quirk(struct
> snd_usb_audio *chip,
>         }
>
>         /* Roland/BOSS implicit feedback with vendor spec class */
> -       if (attr == USB_ENDPOINT_SYNC_ASYNC &&
> -           alts->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
> -           alts->desc.bInterfaceProtocol == 2 &&
> -           alts->desc.bNumEndpoints == 1 &&
> -           USB_ID_VENDOR(chip->usb_id) == 0x0582 /* Roland */) {
> -               if (add_roland_implicit_fb(chip, fmt,
> -                                          alts->desc.bInterfaceNumber + 1,
> -                                          alts->desc.bAlternateSetting))
> +       if (USB_ID_VENDOR(chip->usb_id) == 0x0582) {
> +               if (add_roland_implicit_fb(chip, fmt, alts) > 0)
>                         return 1;
>         }
>
> @@ -345,6 +370,13 @@ static int audioformat_capture_quirk(struct
> snd_usb_audio *chip,
>         if (p && (p->type == IMPLICIT_FB_FIXED || p->type ==
> IMPLICIT_FB_BOTH))
>                 return add_implicit_fb_sync_ep(chip, fmt, p->ep_num, 0,
>                                                p->iface, NULL);
> +
> +       /* Roland/BOSS need full-duplex streams */
> +       if (USB_ID_VENDOR(chip->usb_id) == 0x0582) {
> +               if (add_roland_capture_quirk(chip, fmt, alts) > 0)
> +                       return 1;
> +       }
> +
>         if (is_pioneer_implicit_fb(chip, alts))
>                 return 1; /* skip the quirk, also don't handle generic
> sync EP */
>         return 0;
> --
> 2.26.2
>
>
Lucas April 23, 2021, 6:49 a.m. UTC | #2
Most everything seems to be working, but I ran into a couple of, hopefully,
simple issues:

1. The UA-101 in its full speed (USB 1.1) mode times out for both capture
and playback, though its high speed (USB 2) mode is perfect.
(I'm using plughw to work with 2 channels here):
arecord -D plughw:UA101 -f S32_LE -r 48000 -c 2 ./file.wav
arecord: main:830: audio open error: Connection timed out

aplay -D plughw:UA101 -f S32_LE -r 48000 -c 2 ./other-file.wav
aplay: main:830: audio open error: Connection timed out

2.  I noticed with the INTEGRA-7 and the R-26, so far (with "pasuspender --
cat" running simultaneously):
When I first begin playback with aplay like,
"aplay -D hw:INTEGRA7 -f S32_LE -r 96000 -c 2 ./file.wav"
to play a long recording, and then start capturing for a while, while
that's still playing with something like,
"arecord -D hw:INTEGRA7 -f S32_LE -r 96000 -c 2 ./duplex-file.wav".
If I then end the arecord with ctrl-c before the aplay has finished, aplay
may end in the near future without finishing the entire playback, with this:
aplay: pcm_write:2061: write error: Input/output error

I may try beginning the capture first, and then starting aplay, but I've
run out of time for tonight.

If problem two can't be fixed, this functionality is certainly better than
before when it wasn't working at all.  I think JACK would keep the capture
and playback endpoints open, until itself closes, so it's probably a rare
person like me that would even notice it.

Thanks again!,

  Lucas
Takashi Iwai April 23, 2021, 7:47 a.m. UTC | #3
On Fri, 23 Apr 2021 08:49:22 +0200,
Lucas wrote:
> 
> Most everything seems to be working, but I ran into a couple of, hopefully,
> simple issues:
> 
> 1. The UA-101 in its full speed (USB 1.1) mode times out for both capture and
> playback, though its high speed (USB 2) mode is perfect.
> (I'm using plughw to work with 2 channels here):
> arecord -D plughw:UA101 -f S32_LE -r 48000 -c 2 ./file.wav
> arecord: main:830: audio open error: Connection timed out
> 
> aplay -D plughw:UA101 -f S32_LE -r 48000 -c 2 ./other-file.wav
> aplay: main:830: audio open error: Connection timed out

Is this really with snd-usb-audio driver?  Please check the entry in
/proc/asound/modules (or traverse via sysfs).

> 2.  I noticed with the INTEGRA-7 and the R-26, so far (with "pasuspender --
> cat" running simultaneously):
> When I first begin playback with aplay like,
> "aplay -D hw:INTEGRA7 -f S32_LE -r 96000 -c 2 ./file.wav"
> to play a long recording, and then start capturing for a while, while that's
> still playing with something like,
> "arecord -D hw:INTEGRA7 -f S32_LE -r 96000 -c 2 ./duplex-file.wav".
> If I then end the arecord with ctrl-c before the aplay has finished, aplay may
> end in the near future without finishing the entire playback, with this:
> aplay: pcm_write:2061: write error: Input/output error
> 
> I may try beginning the capture first, and then starting aplay, but I've run
> out of time for tonight.
> 
> If problem two can't be fixed, this functionality is certainly better than
> before when it wasn't working at all.  I think JACK would keep the capture and
> playback endpoints open, until itself closes, so it's probably a rare person
> like me that would even notice it.

This rather sounds like a generic problem of the implicit feedback.
Please give the kernel log with snd_usb_audio.dyndbg=+p boot option
with some notion which timestamp corresponding to which action
(e.g. starting playback, stopping recording, etc).


thanks,

Takashi
Takashi Iwai April 23, 2021, 9:29 a.m. UTC | #4
On Thu, 22 Apr 2021 21:20:19 +0200,
Mike Oliphant wrote:
> 
> I had wondered whether the hardcoded endpoints were necessary (or always
> accurate).
> 
> This method seems much cleaner, and I can report that it is working as
> expected (playback-only, record-only, and full duplex) on the BOSS GT-1.

Thanks for confirmation.

FWIW, the patches are on my for-next branch, destined for 5.13
kernel.


Takashi
Lucas April 23, 2021, 6:04 p.m. UTC | #5
On Fri, Apr 23, 2021 at 2:47 AM Takashi Iwai <tiwai@suse.de> wrote:

> Is this really with snd-usb-audio driver?  Please check the entry in
> /proc/asound/modules (or traverse via sysfs).
>

No, I see it's not.  It's using the correct snd_ua101 module

This rather sounds like a generic problem of the implicit feedback.
> Please give the kernel log with snd_usb_audio.dyndbg=+p boot option
> with some notion which timestamp corresponding to which action
> (e.g. starting playback, stopping recording, etc).
>

Okay, that's good news!  Thanks, and here's that:

I turned the INTEGRA-7 on at 11:59:00
It started fully at 11:59:27, which is probably when the kernel could see
it:

[ 1632.073938] usb 1-1.6: new high-speed USB device number 5 using ehci-pci
[ 1634.034266] usb 1-1.6: New USB device found, idVendor=0582,
idProduct=015b, bcdDevice= 1.00
[ 1634.034274] usb 1-1.6: New USB device strings: Mfr=1, Product=2,
SerialNumber=0
[ 1634.034277] usb 1-1.6: Product: INTEGRA-7
[ 1634.034279] usb 1-1.6: Manufacturer: Roland
[ 1634.036522] usb 1-1.6: 1:1: added playback implicit_fb sync_ep 8e, iface
2:1
[ 1634.036527] usb 1-1.6: 1:1: add audio endpoint 0xd
[ 1634.036539] usb 1-1.6: Creating new data endpoint #d
[ 1634.036541] usb 1-1.6: Creating new data endpoint #8e
[ 1634.036638] usb 1-1.6: 1:1 Set sample rate 96000, clock 0
[ 1634.036891] usb 1-1.6: 2:1: added capture implicit_fb sync_ep d, iface
1:1
[ 1634.036894] usb 1-1.6: 2:1: add audio endpoint 0x8e
[ 1634.036997] usb 1-1.6: 2:1 Set sample rate 96000, clock 0
[ 1634.082834] usb 1-1.6: Open EP 0x8e, iface=2:1, idx=0
[ 1634.082840] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=19184, periods=4, implicit_fb=1
[ 1634.082843] usb 1-1.6: Open EP 0xd, iface=1:1, idx=0
[ 1634.082844] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=19184, periods=4, implicit_fb=1
[ 1634.082847] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1634.083011] usb 1-1.6: Setting usb interface 2:1 for EP 0x8e
[ 1634.083143] usb 1-1.6: 2:1 Set sample rate 96000, clock 0
[ 1634.083146] usb 1-1.6: Setting params for data EP 0x8e, pipe 0x70580
[ 1634.083160] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.083162] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1634.083246] usb 1-1.6: Setting usb interface 1:1 for EP 0xd
[ 1634.083416] usb 1-1.6: 1:1 Set sample rate 96000, clock 0
[ 1634.083421] usb 1-1.6: Setting params for data EP 0xd, pipe 0x68500
[ 1634.083444] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.085019] usb 1-1.6: Closing EP 0x8e (count 1)
[ 1634.085022] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1634.085144] usb 1-1.6: EP 0x8e closed
[ 1634.085146] usb 1-1.6: Closing EP 0xd (count 1)
[ 1634.085148] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1634.085273] usb 1-1.6: EP 0xd closed
[ 1634.085652] usb 1-1.6: Open EP 0x8e, iface=2:1, idx=0
[ 1634.085655] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=19184, periods=4, implicit_fb=1
[ 1634.085658] usb 1-1.6: Open EP 0xd, iface=1:1, idx=0
[ 1634.085659] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=19184, periods=4, implicit_fb=1
[ 1634.085661] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1634.085826] usb 1-1.6: Setting usb interface 2:1 for EP 0x8e
[ 1634.085873] usb 1-1.6: 2:1 Set sample rate 96000, clock 0
[ 1634.085879] usb 1-1.6: Setting params for data EP 0x8e, pipe 0x70580
[ 1634.085884] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.085886] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1634.086018] usb 1-1.6: Setting usb interface 1:1 for EP 0xd
[ 1634.086139] usb 1-1.6: 1:1 Set sample rate 96000, clock 0
[ 1634.086153] usb 1-1.6: Setting params for data EP 0xd, pipe 0x68500
[ 1634.086158] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.086292] usb 1-1.6: Closing EP 0x8e (count 1)
[ 1634.086294] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1634.086400] usb 1-1.6: EP 0x8e closed
[ 1634.086403] usb 1-1.6: Closing EP 0xd (count 1)
[ 1634.086404] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1634.086524] usb 1-1.6: EP 0xd closed
[ 1634.086817] usb 1-1.6: Open EP 0xd, iface=1:1, idx=0
[ 1634.086820] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=19184, periods=4, implicit_fb=1
[ 1634.086822] usb 1-1.6: Open EP 0x8e, iface=2:1, idx=0
[ 1634.086824] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=19184, periods=4, implicit_fb=1
[ 1634.086826] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1634.086858] usb 1-1.6: Setting usb interface 1:1 for EP 0xd
[ 1634.086993] usb 1-1.6: 1:1 Set sample rate 96000, clock 0
[ 1634.086996] usb 1-1.6: Setting params for data EP 0xd, pipe 0x68500
[ 1634.087000] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.087001] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1634.087106] usb 1-1.6: Setting usb interface 2:1 for EP 0x8e
[ 1634.087272] usb 1-1.6: 2:1 Set sample rate 96000, clock 0
[ 1634.087279] usb 1-1.6: Setting params for data EP 0x8e, pipe 0x70580
[ 1634.087284] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.087295] usb 1-1.6: Starting data EP 0xd (running 0)
[ 1634.087320] usb 1-1.6: 12 URBs submitted for EP 0xd
[ 1634.087322] usb 1-1.6: Starting data EP 0x8e (running 0)
[ 1634.087338] usb 1-1.6: 12 URBs submitted for EP 0x8e
[ 1634.088270] usb 1-1.6: Reopened EP 0x8e (count 1)
[ 1634.088273] usb 1-1.6: Reopened EP 0xd (count 1)
[ 1634.088286] usb 1-1.6: Closing EP 0x8e (count 2)
[ 1634.088288] usb 1-1.6: Closing EP 0xd (count 2)
[ 1634.088599] usb 1-1.6: Reopened EP 0x8e (count 1)
[ 1634.088601] usb 1-1.6: Reopened EP 0xd (count 1)
[ 1634.088612] usb 1-1.6: Stopping data EP 0x8e (running 1)
[ 1634.088616] usb 1-1.6: Stopping data EP 0xd (running 1)
[ 1634.101964] usb 1-1.6: Closing EP 0xd (count 2)
[ 1634.101972] usb 1-1.6: Closing EP 0x8e (count 2)
[ 1634.102043] usb 1-1.6: Closing EP 0x8e (count 1)
[ 1634.102045] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1634.102129] usb 1-1.6: EP 0x8e closed
[ 1634.102132] usb 1-1.6: Closing EP 0xd (count 1)
[ 1634.102134] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1634.102255] usb 1-1.6: EP 0xd closed
[ 1634.107863] usb 1-1.6: Open EP 0xd, iface=1:1, idx=0
[ 1634.107867] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=19184, periods=4, implicit_fb=1
[ 1634.107869] usb 1-1.6: Open EP 0x8e, iface=2:1, idx=0
[ 1634.107871] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=19184, periods=4, implicit_fb=1
[ 1634.107873] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1634.107992] usb 1-1.6: Setting usb interface 1:1 for EP 0xd
[ 1634.108137] usb 1-1.6: 1:1 Set sample rate 96000, clock 0
[ 1634.108147] usb 1-1.6: Setting params for data EP 0xd, pipe 0x68500
[ 1634.108161] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.108164] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1634.108236] usb 1-1.6: Setting usb interface 2:1 for EP 0x8e
[ 1634.108376] usb 1-1.6: 2:1 Set sample rate 96000, clock 0
[ 1634.108384] usb 1-1.6: Setting params for data EP 0x8e, pipe 0x70580
[ 1634.108393] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.108413] usb 1-1.6: Starting data EP 0xd (running 0)
[ 1634.108452] usb 1-1.6: 12 URBs submitted for EP 0xd
[ 1634.108454] usb 1-1.6: Starting data EP 0x8e (running 0)
[ 1634.108470] usb 1-1.6: 12 URBs submitted for EP 0x8e
[ 1634.108782] usb 1-1.6: Reopened EP 0x8e (count 1)
[ 1634.108785] usb 1-1.6: Reopened EP 0xd (count 1)
[ 1634.108796] usb 1-1.6: Closing EP 0x8e (count 2)
[ 1634.108797] usb 1-1.6: Closing EP 0xd (count 2)
[ 1634.109076] usb 1-1.6: Reopened EP 0x8e (count 1)
[ 1634.109078] usb 1-1.6: Reopened EP 0xd (count 1)
[ 1634.109089] usb 1-1.6: Stopping data EP 0x8e (running 1)
[ 1634.109093] usb 1-1.6: Stopping data EP 0xd (running 1)
[ 1634.121982] usb 1-1.6: Closing EP 0xd (count 2)
[ 1634.121987] usb 1-1.6: Closing EP 0x8e (count 2)
[ 1634.122023] usb 1-1.6: Closing EP 0x8e (count 1)
[ 1634.122024] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1634.122136] usb 1-1.6: EP 0x8e closed
[ 1634.122139] usb 1-1.6: Closing EP 0xd (count 1)
[ 1634.122141] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1634.122250] usb 1-1.6: EP 0xd closed
[ 1634.136890] usb 1-1.6: Open EP 0xd, iface=1:1, idx=0
[ 1634.136895] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=524288, periods=2, implicit_fb=1
[ 1634.136898] usb 1-1.6: Open EP 0x8e, iface=2:1, idx=0
[ 1634.136899] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=524288, periods=2, implicit_fb=1
[ 1634.136901] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1634.137059] usb 1-1.6: Setting usb interface 1:1 for EP 0xd
[ 1634.137214] usb 1-1.6: 1:1 Set sample rate 96000, clock 0
[ 1634.137225] usb 1-1.6: Setting params for data EP 0xd, pipe 0x68500
[ 1634.137235] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.137238] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1634.137362] usb 1-1.6: Setting usb interface 2:1 for EP 0x8e
[ 1634.137500] usb 1-1.6: 2:1 Set sample rate 96000, clock 0
[ 1634.137508] usb 1-1.6: Setting params for data EP 0x8e, pipe 0x70580
[ 1634.137517] usb 1-1.6: Set up 12 URBS, ret=0
[ 1634.137608] usb 1-1.6: Starting data EP 0xd (running 0)
[ 1634.137630] usb 1-1.6: 12 URBs submitted for EP 0xd
[ 1634.137632] usb 1-1.6: Starting data EP 0x8e (running 0)
[ 1634.137648] usb 1-1.6: 12 URBs submitted for EP 0x8e
[ 1634.138532] usb 1-1.6: 1:1 Start Playback PCM
[ 1634.139021] usb 1-1.6: Reopened EP 0x8e (count 1)
[ 1634.139024] usb 1-1.6: Reopened EP 0xd (count 1)
[ 1634.139549] usb 1-1.6: Starting data EP 0x8e (running 1)
[ 1634.139553] usb 1-1.6: Starting data EP 0xd (running 1)
[ 1634.139554] usb 1-1.6: 2:1 Start Capture PCM
[ 1639.143013] usb 1-1.6: Stopping data EP 0xd (running 2)
[ 1639.143022] usb 1-1.6: Stopping data EP 0x8e (running 2)
[ 1639.143026] usb 1-1.6: 2:1 Stop Capture PCM
[ 1639.143083] usb 1-1.6: Closing EP 0x8e (count 2)
[ 1639.143086] usb 1-1.6: Closing EP 0xd (count 2)
[ 1639.144139] usb 1-1.6: Stopping data EP 0x8e (running 1)
[ 1639.144147] usb 1-1.6: Stopping data EP 0xd (running 1)
[ 1639.144150] usb 1-1.6: 1:1 Stop Playback PCM
[ 1639.157925] usb 1-1.6: Closing EP 0xd (count 1)
[ 1639.157933] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1639.158186] usb 1-1.6: EP 0xd closed
[ 1639.158190] usb 1-1.6: Closing EP 0x8e (count 1)
[ 1639.158192] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1639.158431] usb 1-1.6: EP 0x8e closed

I began playing the long file.wav at 12:00:00
aplay -D hw:INTEGRA7 -f S32_LE -r 96000 -c 2 ./file.wav
Playing WAVE './file.wav' : Signed 32 bit Little Endian, Rate 96000 Hz,
Stereo

[ 1682.241471] usb 1-1.6: Open EP 0xd, iface=1:1, idx=0
[ 1682.241478] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=96000, periods=4, implicit_fb=1
[ 1682.241482] usb 1-1.6: Open EP 0x8e, iface=2:1, idx=0
[ 1682.241484] usb 1-1.6:   channels=2, rate=96000, format=S32_LE,
period_bytes=96000, periods=4, implicit_fb=1
[ 1682.241487] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1682.241608] usb 1-1.6: Setting usb interface 1:1 for EP 0xd
[ 1682.241746] usb 1-1.6: 1:1 Set sample rate 96000, clock 0
[ 1682.241754] usb 1-1.6: Setting params for data EP 0xd, pipe 0x68500
[ 1682.241761] usb 1-1.6: Set up 12 URBS, ret=0
[ 1682.241764] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1682.241988] usb 1-1.6: Setting usb interface 2:1 for EP 0x8e
[ 1682.242126] usb 1-1.6: 2:1 Set sample rate 96000, clock 0
[ 1682.242136] usb 1-1.6: Setting params for data EP 0x8e, pipe 0x70580
[ 1682.242144] usb 1-1.6: Set up 12 URBS, ret=0
[ 1682.242176] usb 1-1.6: Starting data EP 0xd (running 0)
[ 1682.242202] usb 1-1.6: 12 URBs submitted for EP 0xd
[ 1682.242204] usb 1-1.6: Starting data EP 0x8e (running 0)
[ 1682.242223] usb 1-1.6: 12 URBs submitted for EP 0x8e
[ 1682.242373] usb 1-1.6: 1:1 Start Playback PCM

I began recording soon after:
arecord -D hw:INTEGRA7 -f S32_LE -r 96000 -c 2 ./duplex.wav
Recording WAVE './duplex.wav' : Signed 32 bit Little Endian, Rate 96000 Hz,
Stereo

[ 1742.225424] usb 1-1.6: Reopened EP 0x8e (count 1)
[ 1742.225431] usb 1-1.6: Reopened EP 0xd (count 1)
[ 1742.225555] usb 1-1.6: Starting data EP 0x8e (running 1)
[ 1742.225559] usb 1-1.6: Starting data EP 0xd (running 1)
[ 1742.225561] usb 1-1.6: 2:1 Start Capture PCM

I ended arecord at 12:02:00 with ctrl-c:
^CAborted by signal Interrupt...
And playback became abruptly inaudible at 12:02:00 too.

[ 1798.440257] usb 1-1.6: Stopping data EP 0xd (running 2)
[ 1798.440266] usb 1-1.6: Stopping data EP 0x8e (running 2)
[ 1798.440270] usb 1-1.6: 2:1 Stop Capture PCM
[ 1798.440277] usb 1-1.6: Closing EP 0x8e (count 2)
[ 1798.440280] usb 1-1.6: Closing EP 0xd (count 2)

By 12:03:00 (appears to be 12:02:30), aplay had timed out with:
aplay: pcm_write:2061: write error: Input/output error

[ 1828.881035] usb 1-1.6: Stopping data EP 0x8e (running 1)
[ 1828.881049] usb 1-1.6: Stopping data EP 0xd (running 1)
[ 1828.881053] usb 1-1.6: 1:1 Stop Playback PCM
[ 1828.896990] usb 1-1.6: Closing EP 0xd (count 1)
[ 1828.896998] usb 1-1.6: Setting usb interface 1:0 for EP 0xd
[ 1828.897139] usb 1-1.6: EP 0xd closed
[ 1828.897146] usb 1-1.6: Closing EP 0x8e (count 1)
[ 1828.897149] usb 1-1.6: Setting usb interface 2:0 for EP 0x8e
[ 1828.897406] usb 1-1.6: EP 0x8e closed

I can confirm everything else is perfect, as my previous test of this patch
already proved.

Thanks for putting up with my pedantic musings,

  Lucas
Keith Milner April 24, 2021, 11:09 a.m. UTC | #6
Hi,
I updated to the latest "for-next" branch and did some testing, including
digging out some old Roland/Boss stuff from my cupboard, and the following
all work for both capture and playback:

Boss Katana (specifically Katana 100W mk1)
Boss GT-1
Boss GT-001
Boss BR-80
Roland V-Studio 20

The only failure was a Roland SD-50 unit which worked on capture, but did
not play back unless capture was running at the same time. I think I
previously tested this with Takashi-san, and it didn't work then, but we
didn't follow up on it as we were focusing on other devices.

I may try to dig into this some more, but the lsusb follows if anyone wants
to make any suggestions. I'm actually not, personally, that worried about
this particular device being fully working as it works for me in Ardour
(which opens both capture and playback at the same time), but I thought I
would throw it in in case there was an obvious case which might apply to
other Roland/Boss devices.

Bus 001 Device 015: ID 0582:0114 Roland Corp. SD-50
Device Descriptor:
 bLength                18
 bDescriptorType         1
 bcdUSB               1.10
 bDeviceClass          255 Vendor Specific Class
 bDeviceSubClass         0
 bDeviceProtocol       255
 bMaxPacketSize0        64
 idVendor           0x0582 Roland Corp.
 idProduct          0x0114 SD-50
 bcdDevice            1.00
 iManufacturer           1 Roland
 iProduct                2 SD-50
 iSerial                 0
 bNumConfigurations      1
 Configuration Descriptor:
   bLength                 9
   bDescriptorType         2
   wTotalLength       0x00a7
   bNumInterfaces          3
   bConfigurationValue     1
   iConfiguration          0
   bmAttributes         0x80
     (Bus Powered)
   MaxPower              480mA
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        0
     bAlternateSetting       0
     bNumEndpoints           0
     bInterfaceClass       255 Vendor Specific Class
     bInterfaceSubClass      2
     bInterfaceProtocol      2
     iInterface              0
     ** UNRECOGNIZED:  06 24 f1 01 00 00
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        0
     bAlternateSetting       1
     bNumEndpoints           1
     bInterfaceClass       255 Vendor Specific Class
     bInterfaceSubClass      2
     bInterfaceProtocol      2
     iInterface              0
     ** UNRECOGNIZED:  07 24 01 01 00 01 00
     ** UNRECOGNIZED:  0b 24 02 01 02 03 18 01 44 ac 00
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x01  EP 1 OUT
       bmAttributes            9
         Transfer Type            Isochronous
         Synch Type               Adaptive
         Usage Type               Data
       wMaxPacketSize     0x0140  1x 320 bytes
       bInterval               1
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        1
     bAlternateSetting       0
     bNumEndpoints           0
     bInterfaceClass       255 Vendor Specific Class
     bInterfaceSubClass      2
     bInterfaceProtocol      1
     iInterface              0
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        1
     bAlternateSetting       1
     bNumEndpoints           1
     bInterfaceClass       255 Vendor Specific Class
     bInterfaceSubClass      2
     bInterfaceProtocol      1
     iInterface              0
     ** UNRECOGNIZED:  07 24 01 07 00 01 00
     ** UNRECOGNIZED:  0b 24 02 01 02 03 18 01 44 ac 00
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x82  EP 2 IN
       bmAttributes            5
         Transfer Type            Isochronous
         Synch Type               Asynchronous
         Usage Type               Data
       wMaxPacketSize     0x0140  1x 320 bytes
       bInterval               1
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        2
     bAlternateSetting       0
     bNumEndpoints           2
     bInterfaceClass       255 Vendor Specific Class
     bInterfaceSubClass      3
     bInterfaceProtocol      0
     iInterface              0
     ** UNRECOGNIZED:  06 24 f1 02 03 03
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x03  EP 3 OUT
       bmAttributes            2
         Transfer Type            Bulk
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0040  1x 64 bytes
       bInterval               0
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x84  EP 4 IN
       bmAttributes            2
         Transfer Type            Bulk
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0040  1x 64 bytes
       bInterval               0
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        2
     bAlternateSetting       1
     bNumEndpoints           2
     bInterfaceClass       255 Vendor Specific Class
     bInterfaceSubClass      3
     bInterfaceProtocol      0
     iInterface              0
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x03  EP 3 OUT
       bmAttributes            2
         Transfer Type            Bulk
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0040  1x 64 bytes
       bInterval               0
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x84  EP 4 IN
       bmAttributes            3
         Transfer Type            Interrupt
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0040  1x 64 bytes
       bInterval               1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
 (Bus Powered)


Regards,

Keith







On Fri, 23 Apr 2021 at 10:29, Takashi Iwai <tiwai@suse.de> wrote:

> On Thu, 22 Apr 2021 21:20:19 +0200,
> Mike Oliphant wrote:
> >
> > I had wondered whether the hardcoded endpoints were necessary (or always
> > accurate).
> >
> > This method seems much cleaner, and I can report that it is working as
> > expected (playback-only, record-only, and full duplex) on the BOSS GT-1.
>
> Thanks for confirmation.
>
> FWIW, the patches are on my for-next branch, destined for 5.13
> kernel.
>
>
> Takashi
>
Lucas April 24, 2021, 9:43 p.m. UTC | #7
The Roland SD-50 appears to have very similar endpoint properties to my
EDIROL UA-4FX and UA-25EX.  This makes me think you could try adding this
to the capture quirks table, although I'm not sure if it would override the
new automatic configuration method, Takashi left the table there for fringe
tests so it should:

        IMPLICIT_FB_FIXED_DEV(0x0582, 0x0114, 0x01, 0x01), /* Roland SD-50
*/

My guess endpoint address of 0x01 (just after the 0x0114) could be wrong,
but since the R-26, INTEGRA-7, etc. OUT endpoint address is used, that's
the one I chose for yours.  Truthfully, I had both the EDIROL UA-4FX and
UA-25EX running with the plain wrong address of 0x0d (which was meant for
other devices) and they were working perfectly.

I hope that helps,

  Lucas
Takashi Iwai April 25, 2021, 9:16 a.m. UTC | #8
On Fri, 23 Apr 2021 20:04:38 +0200,
Lucas wrote:
> 
> On Fri, Apr 23, 2021 at 2:47 AM Takashi Iwai <tiwai@suse.de> wrote:
> 
>     Is this really with snd-usb-audio driver?  Please check the entry in
>     /proc/asound/modules (or traverse via sysfs).
> 
> No, I see it's not.  It's using the correct snd_ua101 module

Then it's expected, and it's been so.  I haven't touched snd-ua101
driver code until now.

>     This rather sounds like a generic problem of the implicit feedback.
>     Please give the kernel log with snd_usb_audio.dyndbg=+p boot option
>     with some notion which timestamp corresponding to which action
>     (e.g. starting playback, stopping recording, etc).
> 
> Okay, that's good news!  Thanks, and here's that:

Thanks.

Could you try the patch below?


Takashi


--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -1443,11 +1443,11 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep)
 	if (snd_BUG_ON(!atomic_read(&ep->running)))
 		return;
 
-	if (ep->sync_source)
-		WRITE_ONCE(ep->sync_source->sync_sink, NULL);
-
-	if (!atomic_dec_return(&ep->running))
+	if (!atomic_dec_return(&ep->running)) {
+		if (ep->sync_source)
+			WRITE_ONCE(ep->sync_source->sync_sink, NULL);
 		stop_urbs(ep, false);
+	}
 }
 
 /**
Lucas April 25, 2021, 7:23 p.m. UTC | #9
That patch worked perfectly for both devices I noticed the issue on (the
Roland INTEGRA-7 and R-26).

Although unrelated, I think the other issue with the EIDROL UA-101 in full
speed mode (USB 1.1) is new since trying the 5.12.0-rc8-next-20210422
kernel branch.  Prior to that, I'd been continually patching updates to the
mainline 5.11.9 source.

Thanks again, Takashi!,

  Lucas
Takashi Iwai April 26, 2021, 6:34 a.m. UTC | #10
On Sun, 25 Apr 2021 21:23:31 +0200,
Lucas wrote:
> 
> That patch worked perfectly for both devices I noticed the issue on (the
> Roland INTEGRA-7 and R-26).

Great, I submitted the proper patch now.

> Although unrelated, I think the other issue with the EIDROL UA-101 in full
> speed mode (USB 1.1) is new since trying the 5.12.0-rc8-next-20210422 kernel
> branch.  Prior to that, I'd been continually patching updates to the mainline
> 5.11.9 source.

Hm, let me know if you find more details.


thanks,

Takashi
Lucas April 28, 2021, 9:43 p.m. UTC | #11
On Mon, Apr 26, 2021 at 1:34 AM Takashi Iwai <tiwai@suse.de> wrote:

> On Sun, 25 Apr 2021 21:23:31 +0200,
> Lucas wrote:
> >
> > That patch worked perfectly for both devices I noticed the issue on (the
> > Roland INTEGRA-7 and R-26).
>
> Great, I submitted the proper patch now.
>

Thanks for everything!  This is highly appreciated by me, and probably will
be by many others and those who won't even realize they hadn't been
supported until now.  Although it's been fun feeling useful, It'll be quite
nice to go back to a packaged kernel and save some storage space too.


> > Although unrelated, I think the other issue with the EIDROL UA-101 in
> full
> > speed mode (USB 1.1) is new since trying the 5.12.0-rc8-next-20210422
> kernel
> > branch.  Prior to that, I'd been continually patching updates to the
> mainline
> > 5.11.9 source.
>
> Hm, let me know if you find more details.
>

The kernel option "snd_ua101.dyndbg=+p" debugging details seem lacking
here, so this is the little I was able to gather:

The Edirol UA-101's full speed (USB 1.1) mode is affected, but not its high
speed (USB 2) mode, which works under these same conditions.

It only misbehaves on my USB2 ports, not my other availability of USB3.
On a working older kernel 5.9.0-1-rt-amd64 with the dyndbg above enabled, I
got a very sparse debugging log:
3:43:00 turned it on (already switched to full speed mode-USB 1.1, &
already connected to a USB2 port)

[  185.018174] usb 3-1.5: new full-speed USB device number 3 using ehci-pci
[  185.129040] usb 3-1.5: New USB device found, idVendor=0582,
idProduct=008d, bcdDevice= 1.03
[  185.129046] usb 3-1.5: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[  185.129048] usb 3-1.5: Product: UA-101 USB1
[  185.129050] usb 3-1.5: Manufacturer: EDIROL
[  185.129052] usb 3-1.5: SerialNumber: AX85615

3:45:00 arecord -D plughw:USB1 -f S24_3LE -r 48000 -c 2 ./file.wav
Recording WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate
48000 Hz, Stereo

3:47:20 ended with ctrl-c
^CAborted by signal Interrupt...

3:50:00 aplay -D plughw:USB1 -f S24_3LE -r 48000 -c 2 ./file.wav
Playing WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate
48000 Hz, Stereo

3:52:03 playback ended normally

3:54:30 disconnected the USB cable

[  872.498057] usb 3-1.5: USB disconnect, device number 3



Now here's the same tests with kernel 5.12.0-rc8-next-20210422, still with
boot option "snd_ua101.dyndbg=+p".  Note the alsa device name changed from
"USB1" on the old kernel to UA101" here, but I doubt that makes the
difference:

2:12:30 turned it on (already connected to a USB2 port, probably the same
port, though its designation changed)

[  163.133264] usb 4-1.5: new full-speed USB device number 3 using ehci-pci
[  163.244115] usb 4-1.5: New USB device found, idVendor=0582,
idProduct=008d, bcdDevice= 1.03
[  163.244126] usb 4-1.5: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[  163.244130] usb 4-1.5: Product: UA-101 USB1
[  163.244133] usb 4-1.5: Manufacturer: EDIROL
[  163.244135] usb 4-1.5: SerialNumber: AX85615
[  163.263127] usbcore: registered new interface driver snd-ua101
[  168.476496] usb 4-1.5: cannot initialize interface; error -110: unknown
error
[  173.596462] usb 4-1.5: cannot initialize interface; error -110: unknown
error
[  178.716557] usb 4-1.5: cannot initialize interface; error -110: unknown
error
[  183.836518] usb 4-1.5: cannot initialize interface; error -110: unknown
error

2:13:00 arecord -D plughw:UA101 -f S24_3LE -r 48000 -c 2 ./file.wav
arecord: main:830: audio open error: Connection timed out

[  188.956481] usb 4-1.5: cannot initialize interface; error -110: unknown
error
[  194.076450] usb 4-1.5: cannot initialize interface; error -110: unknown
error
[  199.196407] usb 4-1.5: cannot initialize interface; error -110: unknown
error

2:14:30 aplay -D plughw:UA101 -f S24_3LE -r 48000 -c 2
./Music/test-kernel-5.11.9-patched-integra-7-usb-digital-audio-all-6-demos.wav


[  285.979938] usb 4-1.5: cannot initialize interface; error -110: unknown
error

after a few seconds:
aplay: main:830: audio open error: Connection timed out

2:17:19 turned it off

[  447.489736] usb 4-1.5: USB disconnect, device number 3



Then, here, I connected it to a USB3 port (which works):

2:21:00 turned it on

[  671.310730] usb 1-1.2: new full-speed USB device number 5 using xhci_hcd
[  671.413736] usb 1-1.2: New USB device found, idVendor=0582,
idProduct=008d, bcdDevice= 1.03
[  671.413747] usb 1-1.2: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[  671.413751] usb 1-1.2: Product: UA-101 USB1
[  671.413754] usb 1-1.2: Manufacturer: EDIROL
[  671.413757] usb 1-1.2: SerialNumber: AX85615

2:22:00 arecord -D plughw:UA101 -f S24_3LE -r 48000 -c 2 ./file.wav
Recording WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate
48000 Hz, Stereo

2:26:09 ended it with ctrl-c
^CAborted by signal Interrupt...

2:27:30 aplay -D plughw:UA101 -f S24_3LE -r 48000 -c 2 ./file.wav
Playing WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate
48000 Hz, Stereo

2:31:40 playback ended normally

2:33:00 disconnected it

[ 1390.570021] usb 1-1.2: USB disconnect, device number 5



Later, I turned it off, changed switch to high speed (USB 2) mode (which
works), and plugged it back in to that same USB2 port with the trouble
earlier:

2:47:00 turned it on

[ 2231.706964] usb 4-1.5: new high-speed USB device number 8 using ehci-pci
[ 2231.817266] usb 4-1.5: New USB device found, idVendor=0582,
idProduct=007d, bcdDevice= 1.03
[ 2231.817277] usb 4-1.5: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[ 2231.817281] usb 4-1.5: Product: UA-101
[ 2231.817284] usb 4-1.5: Manufacturer: EDIROL
[ 2231.817287] usb 4-1.5: SerialNumber: AX85615

2:47:30 arecord -D plughw:UA101 -f S24_3LE -r 48000 -c 2 ./file.wav
Recording WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate
48000 Hz, Stereo

2:48:30 ended recording with ctl-c
^CAborted by signal Interrupt...

2:50:00 turned it off

[ 2412.517175] usb 4-1.5: USB disconnect, device number 8


Sorry if that's not enough information; it certainly seems bare to me.  I'd
be happy if you have other suggestions that could lead to better diagnosis,
though.

Thanks,

  Lucas
Takashi Iwai April 29, 2021, 9:15 a.m. UTC | #12
On Wed, 28 Apr 2021 23:43:30 +0200,
Lucas wrote:
> On Mon, Apr 26, 2021 at 1:34 AM Takashi Iwai <tiwai@suse.de> wrote:
>     On Sun, 25 Apr 2021 21:23:31 +0200,
>     Lucas wrote:
>     > Although unrelated, I think the other issue with the EIDROL UA-101 in
>     full
>     > speed mode (USB 1.1) is new since trying the 5.12.0-rc8-next-20210422
>     kernel
>     > branch.  Prior to that, I'd been continually patching updates to the
>     mainline
>     > 5.11.9 source.
>    
>     Hm, let me know if you find more details.
> 
> The kernel option "snd_ua101.dyndbg=+p" debugging details seem lacking here,
> so this is the little I was able to gather:
> 
> The Edirol UA-101's full speed (USB 1.1) mode is affected, but not its high
> speed (USB 2) mode, which works under these same conditions.
> 
> It only misbehaves on my USB2 ports, not my other availability of USB3.
> On a working older kernel 5.9.0-1-rt-amd64 with the dyndbg above enabled, I
> got a very sparse debugging log:
> 3:43:00 turned it on (already switched to full speed mode-USB 1.1, & already
> connected to a USB2 port)
> 
> [  185.018174] usb 3-1.5: new full-speed USB device number 3 using ehci-pci
> [  185.129040] usb 3-1.5: New USB device found, idVendor=0582, idProduct=008d,
> bcdDevice= 1.03
> [  185.129046] usb 3-1.5: New USB device strings: Mfr=1, Product=2,
> SerialNumber=3
> [  185.129048] usb 3-1.5: Product: UA-101 USB1
> [  185.129050] usb 3-1.5: Manufacturer: EDIROL
> [  185.129052] usb 3-1.5: SerialNumber: AX85615
> 
> 3:45:00 arecord -D plughw:USB1 -f S24_3LE -r 48000 -c 2 ./file.wav
> Recording WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate
> 48000 Hz, Stereo
> 
> 3:47:20 ended with ctrl-c
> ^CAborted by signal Interrupt...
> 
> 3:50:00 aplay -D plughw:USB1 -f S24_3LE -r 48000 -c 2 ./file.wav
> Playing WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate 48000
> Hz, Stereo
> 
> 3:52:03 playback ended normally
> 
> 3:54:30 disconnected the USB cable
> 
> [  872.498057] usb 3-1.5: USB disconnect, device number 3
> 
> Now here's the same tests with kernel 5.12.0-rc8-next-20210422, still with
> boot option "snd_ua101.dyndbg=+p".  Note the alsa device name changed from
> "USB1" on the old kernel to UA101" here, but I doubt that makes the
> difference:
> 
> 2:12:30 turned it on (already connected to a USB2 port, probably the same
> port, though its designation changed)
> 
> [  163.133264] usb 4-1.5: new full-speed USB device number 3 using ehci-pci
> [  163.244115] usb 4-1.5: New USB device found, idVendor=0582, idProduct=008d,
> bcdDevice= 1.03
> [  163.244126] usb 4-1.5: New USB device strings: Mfr=1, Product=2,
> SerialNumber=3
> [  163.244130] usb 4-1.5: Product: UA-101 USB1
> [  163.244133] usb 4-1.5: Manufacturer: EDIROL
> [  163.244135] usb 4-1.5: SerialNumber: AX85615
> [  163.263127] usbcore: registered new interface driver snd-ua101
> [  168.476496] usb 4-1.5: cannot initialize interface; error -110: unknown
> error
> [  173.596462] usb 4-1.5: cannot initialize interface; error -110: unknown
> error
> [  178.716557] usb 4-1.5: cannot initialize interface; error -110: unknown
> error
> [  183.836518] usb 4-1.5: cannot initialize interface; error -110: unknown
> error
> 
> 2:13:00 arecord -D plughw:UA101 -f S24_3LE -r 48000 -c 2 ./file.wav
> arecord: main:830: audio open error: Connection timed out
> 
> [  188.956481] usb 4-1.5: cannot initialize interface; error -110: unknown
> error
> [  194.076450] usb 4-1.5: cannot initialize interface; error -110: unknown
> error
> [  199.196407] usb 4-1.5: cannot initialize interface; error -110: unknown
> error
> 
> 2:14:30 aplay -D plughw:UA101 -f S24_3LE -r 48000 -c 2 ./Music/
> test-kernel-5.11.9-patched-integra-7-usb-digital-audio-all-6-demos.wav
> 
> [  285.979938] usb 4-1.5: cannot initialize interface; error -110: unknown
> error
> 
> after a few seconds:
> aplay: main:830: audio open error: Connection timed out
> 
> 2:17:19 turned it off
> 
> [  447.489736] usb 4-1.5: USB disconnect, device number 3
> 
> Then, here, I connected it to a USB3 port (which works):
> 
> 2:21:00 turned it on
> 
> [  671.310730] usb 1-1.2: new full-speed USB device number 5 using xhci_hcd
> [  671.413736] usb 1-1.2: New USB device found, idVendor=0582, idProduct=008d,
> bcdDevice= 1.03
> [  671.413747] usb 1-1.2: New USB device strings: Mfr=1, Product=2,
> SerialNumber=3
> [  671.413751] usb 1-1.2: Product: UA-101 USB1
> [  671.413754] usb 1-1.2: Manufacturer: EDIROL
> [  671.413757] usb 1-1.2: SerialNumber: AX85615
> 
> 2:22:00 arecord -D plughw:UA101 -f S24_3LE -r 48000 -c 2 ./file.wav
> Recording WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate
> 48000 Hz, Stereo
> 
> 2:26:09 ended it with ctrl-c
> ^CAborted by signal Interrupt...
> 
> 2:27:30 aplay -D plughw:UA101 -f S24_3LE -r 48000 -c 2 ./file.wav
> Playing WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate 48000
> Hz, Stereo
> 
> 2:31:40 playback ended normally
> 
> 2:33:00 disconnected it
> 
> [ 1390.570021] usb 1-1.2: USB disconnect, device number 5
> 
> Later, I turned it off, changed switch to high speed (USB 2) mode (which
> works), and plugged it back in to that same USB2 port with the trouble
> earlier:
> 
> 2:47:00 turned it on
> 
> [ 2231.706964] usb 4-1.5: new high-speed USB device number 8 using ehci-pci
> [ 2231.817266] usb 4-1.5: New USB device found, idVendor=0582, idProduct=007d,
> bcdDevice= 1.03
> [ 2231.817277] usb 4-1.5: New USB device strings: Mfr=1, Product=2,
> SerialNumber=3
> [ 2231.817281] usb 4-1.5: Product: UA-101
> [ 2231.817284] usb 4-1.5: Manufacturer: EDIROL
> [ 2231.817287] usb 4-1.5: SerialNumber: AX85615
> 
> 2:47:30 arecord -D plughw:UA101 -f S24_3LE -r 48000 -c 2 ./file.wav
> Recording WAVE './file.wav' : Signed 24 bit Little Endian in 3bytes, Rate
> 48000 Hz, Stereo
> 
> 2:48:30 ended recording with ctl-c
> ^CAborted by signal Interrupt...
> 
> 2:50:00 turned it off
> 
> [ 2412.517175] usb 4-1.5: USB disconnect, device number 8
> 
> Sorry if that's not enough information; it certainly seems bare to me.  I'd be
> happy if you have other suggestions that could lead to better diagnosis,
> though.

The error -110 is ETIMEDOUT, and the symptom implies that the problem
is rather in USB core side.  You'd better ask USB devs.  It might be
worth to run git bisect if it's a kernel regression and reliably
reproducible.


thanks,

Takashi
Lucas April 29, 2021, 5:29 p.m. UTC | #13
Alright, thanks!  I really appreciate your suggestions and will try what I
can.  First, I will have to see if I can track down the code change that
broke it.

On Thu, Apr 29, 2021 at 4:15 AM Takashi Iwai <tiwai@suse.de> wrote:

> The error -110 is ETIMEDOUT, and the symptom implies that the problem
> is rather in USB core side.  You'd better ask USB devs.  It might be
> worth to run git bisect if it's a kernel regression and reliably
> reproducible.
>

It must be reliably reproducible (with my hardware at least), as luckily,
it never varied in my tests.

Thanks,

  Lucas
diff mbox series

Patch

diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c
index 94acfaa7f2ef..590a0dbba7a2 100644
--- a/sound/usb/implicit.c
+++ b/sound/usb/implicit.c
@@ -79,15 +79,6 @@  static const struct snd_usb_implicit_fb_match playback_implicit_fb_quirks[] = {
 
 /* Implicit feedback quirk table for capture: only FIXED type */
 static const struct snd_usb_implicit_fb_match capture_implicit_fb_quirks[] = {
-	IMPLICIT_FB_BOTH_DEV(0x0582, 0x0130, 0x0d, 0x01), /* BOSS BR-80 */
-	IMPLICIT_FB_BOTH_DEV(0x0582, 0x0171, 0x0d, 0x01), /* BOSS RC-505 */
-	IMPLICIT_FB_BOTH_DEV(0x0582, 0x0185, 0x0d, 0x01), /* BOSS GP-10 */
-	IMPLICIT_FB_BOTH_DEV(0x0582, 0x0189, 0x0d, 0x01), /* BOSS GT-100v2 */
-	IMPLICIT_FB_BOTH_DEV(0x0582, 0x01d6, 0x0d, 0x01), /* BOSS GT-1 */
-	IMPLICIT_FB_BOTH_DEV(0x0582, 0x01d8, 0x0d, 0x01), /* BOSS Katana */
-	IMPLICIT_FB_BOTH_DEV(0x0582, 0x01e5, 0x0d, 0x01), /* BOSS GT-001 */
-	IMPLICIT_FB_BOTH_DEV(0x0582, 0x0203, 0x0d, 0x01), /* BOSS AD-10 */
-
 	{} /* terminator */
 };
 
@@ -145,30 +136,70 @@  static int add_generic_uac2_implicit_fb(struct snd_usb_audio *chip,
 				       ifnum, alts);
 }
 
-/* Like the function above, but specific to Roland with vendor class and hack */
+static bool roland_sanity_check_iface(struct usb_host_interface *alts)
+{
+	if (alts->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC ||
+	    (alts->desc.bInterfaceSubClass != 2 &&
+	     alts->desc.bInterfaceProtocol != 2) ||
+	    alts->desc.bNumEndpoints < 1)
+		return false;
+	return true;
+}
+
+/* Like the UAC2 case above, but specific to Roland with vendor class and hack */
 static int add_roland_implicit_fb(struct snd_usb_audio *chip,
 				  struct audioformat *fmt,
-				  unsigned int ifnum,
-				  unsigned int altsetting)
+				  struct usb_host_interface *alts)
 {
-	struct usb_host_interface *alts;
 	struct usb_endpoint_descriptor *epd;
 
-	alts = snd_usb_get_host_interface(chip, ifnum, altsetting);
-	if (!alts)
+	if (!roland_sanity_check_iface(alts))
 		return 0;
-	if (alts->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC ||
-	    (alts->desc.bInterfaceSubClass != 2 &&
-	     alts->desc.bInterfaceProtocol != 2) ||
-	    alts->desc.bNumEndpoints < 1)
+	/* only when both streams are with ASYNC type */
+	epd = get_endpoint(alts, 0);
+	if (!usb_endpoint_is_isoc_out(epd) ||
+	    (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
+		return 0;
+
+	/* check capture EP */
+	alts = snd_usb_get_host_interface(chip,
+					  alts->desc.bInterfaceNumber + 1,
+					  alts->desc.bAlternateSetting);
+	if (!alts || !roland_sanity_check_iface(alts))
 		return 0;
 	epd = get_endpoint(alts, 0);
 	if (!usb_endpoint_is_isoc_in(epd) ||
-	    (epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
-					USB_ENDPOINT_USAGE_IMPLICIT_FB)
+	    (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
 		return 0;
+	chip->playback_first = 1;
 	return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
-				       ifnum, alts);
+				       alts->desc.bInterfaceNumber, alts);
+}
+
+/* capture quirk for Roland device; always full-duplex */
+static int add_roland_capture_quirk(struct snd_usb_audio *chip,
+				    struct audioformat *fmt,
+				    struct usb_host_interface *alts)
+{
+	struct usb_endpoint_descriptor *epd;
+
+	if (!roland_sanity_check_iface(alts))
+		return 0;
+	epd = get_endpoint(alts, 0);
+	if (!usb_endpoint_is_isoc_in(epd) ||
+	    (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
+		return 0;
+
+	alts = snd_usb_get_host_interface(chip,
+					  alts->desc.bInterfaceNumber - 1,
+					  alts->desc.bAlternateSetting);
+	if (!alts || !roland_sanity_check_iface(alts))
+		return 0;
+	epd = get_endpoint(alts, 0);
+	if (!usb_endpoint_is_isoc_out(epd))
+		return 0;
+	return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
+				       alts->desc.bInterfaceNumber, alts);
 }
 
 /* Playback and capture EPs on Pioneer devices share the same iface/altset
@@ -306,14 +337,8 @@  static int audioformat_implicit_fb_quirk(struct snd_usb_audio *chip,
 	}
 
 	/* Roland/BOSS implicit feedback with vendor spec class */
-	if (attr == USB_ENDPOINT_SYNC_ASYNC &&
-	    alts->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
-	    alts->desc.bInterfaceProtocol == 2 &&
-	    alts->desc.bNumEndpoints == 1 &&
-	    USB_ID_VENDOR(chip->usb_id) == 0x0582 /* Roland */) {
-		if (add_roland_implicit_fb(chip, fmt,
-					   alts->desc.bInterfaceNumber + 1,
-					   alts->desc.bAlternateSetting))
+	if (USB_ID_VENDOR(chip->usb_id) == 0x0582) {
+		if (add_roland_implicit_fb(chip, fmt, alts) > 0)
 			return 1;
 	}
 
@@ -345,6 +370,13 @@  static int audioformat_capture_quirk(struct snd_usb_audio *chip,
 	if (p && (p->type == IMPLICIT_FB_FIXED || p->type == IMPLICIT_FB_BOTH))
 		return add_implicit_fb_sync_ep(chip, fmt, p->ep_num, 0,
 					       p->iface, NULL);
+
+	/* Roland/BOSS need full-duplex streams */
+	if (USB_ID_VENDOR(chip->usb_id) == 0x0582) {
+		if (add_roland_capture_quirk(chip, fmt, alts) > 0)
+			return 1;
+	}
+
 	if (is_pioneer_implicit_fb(chip, alts))
 		return 1; /* skip the quirk, also don't handle generic sync EP */
 	return 0;