Received: by 2002:a17:90a:bc8d:0:0:0:0 with SMTP id x13csp747436pjr; Wed, 20 May 2020 12:25:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk4bZF0bf6fB3sKdYN51GKyUMB9QzAyO9Gqdwmh7hMkF/IU9nzzmi1ywdpEEYIqMR4Mt6N X-Received: by 2002:a17:906:6055:: with SMTP id p21mr566100ejj.316.1590002748112; Wed, 20 May 2020 12:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590002748; cv=none; d=google.com; s=arc-20160816; b=Tx8/iMaFiOrrlXO8dwHCijpJkl4VYRTH+AHmap0g70lDjJaoROhssL5JF0xqBGf2N+ B8G0CMaGc0VvifNMnNI7W8rprHikRPStqYWzPG9nw/cBq0MK0LvwuMSS9Wg4KfhN66Og agblRNueGRe2dZs8sOxjWqZ/ibHT9rg4OGTEZCuzBNNtGHsxhV0EvTth6vrrOx00tHJV PYu9q31jAoiR1vnVKq/0NlU4brVd08uYp9f8VLoMrVhQP2Fe44tKnpf6PktdrxaBw7fN HTgU4rp9UU4qV4eOhDvb0xgQUJP7Kd38HO5d8fLZO6UUwG/2uZDj+KSKdX2dMODayqqp Fq6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=ISUNx/HLMMSE8Tvl/e62o1EtgA7fevrvudGLHO1IQH8=; b=zM5lVb/kylPh8zYCdLpTL7aEfNzJ8laMHdw/7b9RekcBkVaI864vrF3AWkkYk3bL8A Jnm1VJIKwuHyQHmGR8RtX3AxDtzlGDkAemn6H0H5/6EcnhNsOzezePlZ+t/Eg4caRV8H IlV1irloAO2EuBus1y4/FCi8Qum9/asGeH4x78o7jvbgboeqGVqfBuAK9fmZgAYWsG3x nl7X3nWtaqXmG3QOVlM7S23fAJw3OwZ4tqK1RPHzoprmCICGyDwK4vfonHNq6X+GtMH6 qw+07B8KkOZNe3DWrtgB5Ah/5sF70FvUrn6SsdCCp3L9MlD3990/IQXdC90Te0ltLWGE gERA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si2148790edl.266.2020.05.20.12.25.23; Wed, 20 May 2020 12:25:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726970AbgETTV5 (ORCPT + 99 others); Wed, 20 May 2020 15:21:57 -0400 Received: from shelob.surriel.com ([96.67.55.147]:56038 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgETTV4 (ORCPT ); Wed, 20 May 2020 15:21:56 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1jbUHh-0005vw-19; Wed, 20 May 2020 15:21:45 -0400 Message-ID: <667d8d156fa5d8420ef1c3b1d08b94a10d2398cc.camel@surriel.com> Subject: Re: XHCI vs PCM2903B/PCM2904 part 2 From: Rik van Riel To: Alan Stern Cc: linux-usb , alsa-devel@alsa-project.org, "linux-kernel@vger.kernel.org" , Mathias Nyman , Greg Kroah-Hartman , Jaroslav Kysela , Takashi Iwai Date: Wed, 20 May 2020 15:21:44 -0400 In-Reply-To: <20200520163840.GA11084@rowland.harvard.edu> References: <273cc1c074cc4a4058f31afe487fb233f5cf0351.camel@surriel.com> <20200520163840.GA11084@rowland.harvard.edu> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-kor7JAH8v80RgB55+Ksv" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-kor7JAH8v80RgB55+Ksv Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2020-05-20 at 12:38 -0400, Alan Stern wrote: > On Wed, May 20, 2020 at 07:26:57AM -0400, Rik van Riel wrote: > > After a few more weeks of digging, I have come to the tentative > > conclusion that either the XHCI driver, or the USB sound driver, > > or both, fail to handle USB errors correctly. > >=20 > > I have some questions at the bottom, after a (brief-ish) > > explanation > > of exactly what seems to go wrong. > >=20 > > TL;DR: arecord from a misbehaving device can hang forever > > after a USB error, due to poll on /dev/snd/timer never returning. > >=20 > > The details: under some mysterious circumstances, the PCM290x > > family sound chips can send more data than expected during an > > isochronous transfer, leading to a babble error. Those >=20 > Do these chips connect as USB-3 devices or as USB-2? (I wouldn't > expect=20 > an audio device to use USB-3; it shouldn't need the higher > bandwidth.) USB-2 > In general, errors such as babble are not supposed to stop > isochronous=20 > endpoints. However, it seems that they do. The urb never gets an answer after snd_complete_urb refiles it with usb_submit_urb. > > However, the USB sound driver seems to have no idea that this > > error happened. The function retire_capture_urb looks at the > > status of each isochronous frame, but seems to be under the > > assumption that the sound device just keeps on running. >=20 > This is appropriate, for the reason mentioned above. Having arecord get stuck forever does not seem like the right behavior, though :) > > This leads me to a few questions: > > - should retire_capture_urb call snd_pcm_stop_xrun, > > or another function like it, if it sees certain > > errors in the iso frame in the URB? >=20 > No. Isochronous endpoints are expected to encounter errors from time > to=20 > time; that is the nature of isochronous communications. You're > supposed=20 > to ignore the errors (skip over any bad data) and keep going. ... > The notion of "stopped state" is not part of USB-2. As a result, it=20 > should be handled entirely within the xhci-hcd driver. Interesting. That makes me really curious why things are getting stuck, now... > > - how should the USB sound driver recover from these > > occasional and/or one-off errors? stop the sound > > stream, or try to reinitialize the device and start > > recording again? >=20 > As far as I know, it should do its best to continue (perhaps fill in=20 > missing data with zeros). That was my first intuition as well, given the documented behavior of isochronous frames. However, given that the device appears to stop sending frames after that error, at least usbmon is not seeing any, I am not sure what needs to happen in order to get that behavior. --=20 All Rights Reversed. --=-kor7JAH8v80RgB55+Ksv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAl7Fg0gACgkQznnekoTE 3oP6nAf/ela41PoyQHGOBVNUyLcwbl0jNWe/6JBUdk+jwh0wI/tP+dy5CLR6IOzG Fu1aDqLgUXF/gGLcFvNUl9LBz5kf9UDRrCflmFEAEgeViLuO1eIV+DOoaoogdclh X8L/tL4rv3fpK7lIRdx14Knwtpy2wTkmvFGyiTBQAtKs1FG00t+jRuYjYNKs6KNA o8MyPBYtp4QE0XMua9pEBvVRm+fjh8bJCXcFYYJw88e4o+MhBkfnZWA6Xrnl5YGw jwyfCSGWvNWCi8zKuJfkSWhsSOJk5a+TCGhIY7yhHNT3tUacLORRNEJ+8cbucpQ9 mdwQnjU9EBX+UB+99OwQCSlzTECYAQ== =4YvF -----END PGP SIGNATURE----- --=-kor7JAH8v80RgB55+Ksv--