From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx2-f0.google.com (mail-yx2-f0.google.com [74.125.224.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFE0F23394A for ; Mon, 13 Jul 2026 20:03:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.128 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783973024; cv=none; b=iF3On15kaYXJDSx9rK5QuKgZX+aZlB3ASeFoSHK0fnAQKYoBAKzaG5VgN6wRjsSsmJX1BGwrGH6MtiRD8R20KYVznT8NpqiHfuas3HiTUhTetDmiUtEBY6IqMkfVeQW80UwSZgX3KdkJDYp7IFj8ErdspxmL3PwWztutAW0lKtw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783973024; c=relaxed/simple; bh=lNq9HbHx84bO0jNzQuDP2EuhbElpWCYOSVhU+wGOVjw=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Syd++Llj718kgpDPBbbDatLUsHIuZVQHJZjNUQGBvgbMQh6tJxIsAoA1BD9fLdnHe1t9doV110SJ6+VXl+1Wx35VXR7HTxXO303uKUSh5NgL8cNlyplQaCU7DyUcNwJkF9i//16lWfOUtcPTFesNTx4KXgu7QOcUwdxZvIX7Z2E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OGi5Mj2V; arc=none smtp.client-ip=74.125.224.128 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OGi5Mj2V" Received: by mail-yx2-f0.google.com with SMTP id 00721157ae682-81e7a64294cso707867b3.1 for ; Mon, 13 Jul 2026 13:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783973021; x=1784577821; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=TQ/EY59cpu1jkc21PGftgoguMZtfT9udSMBKlCW2BmU=; b=OGi5Mj2VyA8svzmhqWbXBJC9SfhEe6eSbp2k7zPV/jOQ3ucKH82EezhbS+nB994lMz KzU2sg4RfYxe6qVnXzEjgIHsvQhzrBXw5RhM2lczZGJB52LujnV8xubGt5Z+nf86bZRC 4WVjkEoCFMCPU07rl+V0nPYj37b8Xo0tvZefvgpFOw6Gf7lH4amwKKQ6L/X+Y4UdFOD4 hVdURCVxqrM33AxmM1erYI96Dnh29vD/bkKLsVuZlzntHg115f7VOysI+p4RC/dL4LEd UTxrQko/b5eZ36UH+G20xQ/ny+GkCYvdn9E+s94fucSK9ksh/KUVXlp5iRoiW3deIzsq nFGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783973021; x=1784577821; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=TQ/EY59cpu1jkc21PGftgoguMZtfT9udSMBKlCW2BmU=; b=aQ5L9yiH3gIYAUmc0RHOw9GQhrkzrI55V2NMnc/oTaRsO3DmrSECZEOeJOWIH55vP9 BptZZnsYeu2PgJmwC+SKtFNQqZBWteRUCqIvEG+qf/Mna7tFePxJeBiF9y7NMgkA+bEr IsuoRW7jav3T+VXpfrBdfA+HMziqwgVDJ7EEHZ6N4DCSI24p2W8QmYYdctdOU6b5Ti1g ftPyrt8+NE6F+NnRr/ov3MFrN9qwaR6ElF1c/OolNhWVkmalJzUz5+2/1RVwAxt3+L9p 9bRw37IJAioSdjh3gv1zSK0hfAHDIi7ISPgIEjw++hK/66xZmq/cYXWd53dDHtwCICGn mQTw== X-Forwarded-Encrypted: i=1; AHgh+Ro0KBym0XSLI4rZ319Qo1e9qawX5nLpBdwMI3zORwtxgkoTrLSQsEBVAYkhDXnMGjCVUQK/EA7CRyRq/6c=@vger.kernel.org X-Gm-Message-State: AOJu0Yzb2QSoROrkeyHIjdF4xHSO7CWemfVfJ3fq1q3X8xLZl9GW5srg WfLsXJBgSxy46NSEHq+Uo3J4oORmyZbjHkCtdz4MtfhbFV/BGANqgOlM X-Gm-Gg: AfdE7ckXoDuEAoibb7x3IPIzXLuY7XE+ChT3UgdbDIYjbf7NwbuNZbhTmpQH9VT90if D8KwCxFbc06exUqHOc0LGLNQSyMiF8pRR3aE/alpuK/s7fyC47n7cQo7wwXegb5pxoSgxjWD70z wQfnexBCsqH5d8HuEkkJTbLziNvh906bTuG493gNxHhdVAVUiA8gsEY0X17fMVV2hBemsEOcU8e zo6dS4WB+WDo4qVQWustlQ5cWhdEhvGjTq8MJvxu7HZz0osp8h+HhFtHaMSgUj8FvmjMhpzS4qW 0sINj8T0XjSOKdvH0W2PEA0Og0lYxf83LlS7vZ0plIuUMjKpkf56U2POsLuF4dsvcyLKgstSVfm bfN7s83lOSuhliOQNqcgb5Prho93PivNQZZ7+LQ4jEaDj0xk+0xwro/ZVlYnMqwc1ETDhfrrCNW fbslsFzukW+tHmRR3YpPxFEhcL+P6xyG34KJUTR3syjT3dQkwnrOpA5TLNvyJCPtdXJkGVyJGk0 iuDNA== X-Received: by 2002:a05:690c:3344:b0:814:5840:2f92 with SMTP id 00721157ae682-81e9014da15mr83359257b3.48.1783973020642; Mon, 13 Jul 2026 13:03:40 -0700 (PDT) Received: from pendragon (76-234-45-214.lightspeed.cicril.sbcglobal.net. [76.234.45.214]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81e6c23939fsm123926137b3.46.2026.07.13.13.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 13:03:40 -0700 (PDT) From: Colin Braun X-Google-Original-From: Colin Braun Date: Mon, 13 Jul 2026 15:03:38 -0500 To: Danilo Krummrich Cc: Colin Braun , Miguel Ojeda , Greg Kroah-Hartman , Boqun Feng , Gary Guo , =?utf-8?B?QmrDtnJu?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , Onur =?utf-8?B?w5Z6a2Fu?= , Mauro Carvalho Chehab , Alan Stern , Mathias Nyman , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-usb@vger.kernel.org, linux-media@vger.kernel.org, Colin Braun , oneukum@suse.com Subject: Re: [RFC PATCH 2/4] rust: usb: add usb host interface and endpoint abstractions Message-ID: References: <20260712-urb-abstraction-v1-v1-0-9fa011634ead@gmail.com> <20260712-urb-abstraction-v1-v1-2-9fa011634ead@gmail.com> 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=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Jul 13, 2026 at 03:22:33PM +0200, Danilo Krummrich wrote: > (Cc: Oliver) > > On Sun Jul 12, 2026 at 11:07 PM CEST, Colin Braun wrote: > > @@ -382,8 +556,8 @@ fn as_ref(&self) -> &device::Device { > > } > > } > > > > -impl AsRef for Interface { > > - fn as_ref(&self) -> &Device { > > +impl AsRef> for Interface { > > + fn as_ref(&self) -> &Device { > > // SAFETY: `self.as_raw()` is valid by the type invariants. > > let usb_dev = unsafe { bindings::interface_to_usbdev(self.as_raw()) }; > > Please see commit f12140f21acb ("rust: usb: don't retain device context for the > interface parent"). > > We can't derive the device context of a USB device from a USB interface. Please > also see the device context documentation in [1]. > > USB device drivers are separate from USB interface drivers, we can't assume that > a USB device is bound to a USB device driver just because a USB interface (of > that same device) is bound to an USB interface driver. > > The same is true from the Core context, which means the device is in a bus > device callback, where the device lock is held. > > This is also the reason why I keep proposing to only expose simple forwarding > helpers on usb::Interface to implement URBs (see also [2] and [3]). > > An URB requires either usb::Interface or, for a USB device driver, > usb::Device. But since we can't derive usb::Device from > usb::Interface a simple forwarding helper does the trick. That makes sense, thank you for pointing this out. I should have taken a look at the git log for that line to try to understand its background. I'll remove the usb::Device::set_interface() and usb::Device::control_msg() implementations in my next revision (since they will no longer be used) and just implement them on usb::Interface.