Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp149896lqs; Mon, 4 Mar 2024 19:19:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXyfzyDRZxJxP38TcVJ5r30EPy2uxY7t5PIRy4sN1BZrewtODmszlkthu9IP3GBXWcw6j5kO77Mm87os+1ckTOqfQPPLX2DKWolRElNnQ== X-Google-Smtp-Source: AGHT+IFm1Ly7CKNpQoAS/9XAkLjinpB9ixExHfV6xgjrlgltPqLK8Vfg7AXHutt8LrrIWI3Y7NBr X-Received: by 2002:a19:6919:0:b0:513:1cc8:6d0d with SMTP id e25-20020a196919000000b005131cc86d0dmr329171lfc.12.1709608778812; Mon, 04 Mar 2024 19:19:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709608778; cv=pass; d=google.com; s=arc-20160816; b=wUpa1p08YoD32bifsRn2lejsuaend1oYhbAsaF4y970boLBjocVsi1pmwrF1vpRhK/ uFbb2cGw0W+A9Cy4O5r2UirzJCitxzhYoEcWsUOhxAWxLVvDWgE2rPhzdEqj+sr9644J kcxsOasyvPVPW/OPyX4kzZgL0SLMO7PDdDrR9hNgZp8A4fJ4M3+0pnJY0ScFRnxQCrbR Z/ESaZTxs1q31seZk4anHHHYRRfdauznvdsUJgZCupbEG8a9Z5MEVKHRg86kyS1bf1PO 4m+eHgSDT/BCwAdcJSgVf8NPAMoNH4EF3joaurRr/SrPClvJgrYx1QVmBs2y6PCia0+p essA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=IlB47yH33/gEzjvAoCnmXMNnnKsum0uDNiM/+MnpQDg=; fh=//PK83JiSuf09VrLTJ/1a5pLyBuwV5iPDuHG3nxjI+Y=; b=wxooc7TN9qSdn9gg1+UAPcw8nqWTd6qbgYHOJyS0raMrAtCPCR9jmnKJKmXoY0NQTO ZE7UF+aVed3JYuxkQKZmLVs/x8iwuAhPVYVaZLwc4UORFzRC7bYGSTJefCwSkG2q5uHW YHxNaW6Aj4T2g6Y1cVs1ztagG1h+dzHrHqZKb5YMZgdIud4RqHXe6dAx/2j4xFjXsJ8u aCOiAgtEOsZSwHPOMqvUifY9fqgMAQPquPARViouWW8RxNDuu9tVdgbX88VkHyZoj2oI ZUURW3ppnQfPUHsXhihzRBrxxUtJLrLcyMIctHFtBhbFXkX6+g+ZQAzN0tAel8lVbHhA R8XA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-91605-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i25-20020a17090671d900b00a44e1f65c37si2735586ejk.230.2024.03.04.19.19.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 19:19:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91605-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-91605-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 862921F2317D for ; Tue, 5 Mar 2024 03:19:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FBE8376E6; Tue, 5 Mar 2024 03:19:28 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id DD9772942C for ; Tue, 5 Mar 2024 03:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.131.102.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709608767; cv=none; b=Bji8KT/nDXTTMCmZfI/VsXjVm5qfiuCYPCO8ms3WobCRVfBVAmHz6SGX17EGoIo3ZmD1mjX8xINgHBGQMRH2r9JSMlaA2i02w+SsM+b4ycri3JE3uA/r6EExt/UEzdbi/8TptRZFZU3J12UmhN3nFrpl4gWA1Ogxdf7kI5HvS9c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709608767; c=relaxed/simple; bh=Ck4ZctKVOXdlbvUJ8DoMXK80YN5zrcPcWCl0t3M5bwM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qZTsvF+M+AtVQDCF8OToNV1/tVhsFMtDb0Dm03559sNQUUPvYE/3ocNV0da0yJMbNW+F+nusJ7nQHNG3PXE+6xuw4X2vTrsMxvyOoklLUQSBmIkcIrHKnSkKUKpy9CqjZDtqQHrA886jiWGi4hZlLp2N19xX6WDZdf3KzzlBL+c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu; spf=pass smtp.mailfrom=netrider.rowland.org; arc=none smtp.client-ip=192.131.102.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netrider.rowland.org Received: (qmail 143883 invoked by uid 1000); 4 Mar 2024 22:19:24 -0500 Date: Mon, 4 Mar 2024 22:19:24 -0500 From: Alan Stern To: Marek =?iso-8859-1?Q?Marczykowski-G=F3recki?= Cc: Greg KH , Demi Marie Obenour , linux-usb@vger.kernel.org, Linux Kernel Mailing List Subject: Re: usbip doesn't work with userspace code that accesses USB devices Message-ID: References: <2024030406-kilogram-raving-33c5@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Mar 05, 2024 at 12:52:22AM +0100, Marek Marczykowski-G?recki wrote: > On Mon, Mar 04, 2024 at 11:46:04PM +0100, Marek Marczykowski-G?recki wrote: > > Terminology: > > 1. sys-usb - a VM where USB controller (a PCI device) lives; here > > usbip-host is attached to the device > > 2. testvm - target VM where usbip is connected; here vhci-hcd is used > > 3. qvm-usb - tool that connects the above two (equivalent of > > userspace part of standard usbip) > > > > Specific steps: > > 1. Connect android phone - at this point it's only in sys-usb > > 2. Switch its mode to file transfer - observe reconnect in sys-usb > > 3. Use qvm-usb to attach it to the testvm > > 4. Call jmtpfs -d /mnt in testvm > > Or maybe reset or something is involved here too? > > After using qvm-usb to attach _and detach_ the device, it stays bound to > usbip-host driver (that's intentional). But then, even after re-binding > back to the "usb" driver, jmtpfs called in sys-usb directly fails the > same way, including failure to reset. > > In fact, even without usbip involved at all, jmtpfs directly in sys-usb > works only once. The second attempt (without either physically reconnecting > the phone, or changing its more to "no data transfer" and back to "file > transfer") fails the same way. After terminating the first instance, I > see just this logged: > > [921332.525210] usb 2-1: reset high-speed USB device number 22 using xhci_hcd If something doesn't work when usbip isn't involved, you definitely shouldn't expect it to work when usbip _is_ involved. It sounds like you're facing more than one type of problem. The best approach is to attack them separately. I'd start with problems that exist only on sys-usb first -- keeping usbip out of the picture will make everything much simpler. You can try capturing a usbmon trace, starting from before the phone is attached, and continuing on through the mode changes and failures. In fact, break it up into several traces, each starting just before one of the major events (initial plug-in, mode change, whatever). Once that's under control, I suggest using usbmon on both sides (sys-usb and testvm) of the usbip connection. But start without usbip. Alan Stern