From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 A46A7361660 for ; Fri, 16 Jan 2026 10:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768560294; cv=none; b=fraNWSUxQjOLdDO/CP26ryKOoJ2NOJFjYF6EZmSuQJm7T2U6cNVH1gpGDosEO5Gpxs0EcvVKEOOd2xBvFZVOmhTQ/FbhUzbLdY6UMRSSYFjBHhTPUTYuktlhLrAI20LuOc/GP/JJ50+bbngMD6UlVllLhNfGlZkNef56N2FLCdw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768560294; c=relaxed/simple; bh=b7fb2kg9k9dh+/1ZB4RW0gIF9ob0dRm04urz98QiGjM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JxbdJpGBQ1/7yttihdzAdKsdqi7HVnBR+MCFuevv2ZSUN2ZbyoBllh2Poc18W4UXRhL6XrOtefXdmh4vmm/iZF2hcql5jTtKgGSBcQRSInmksKF4Vn5RmW5WNd9aTKVaZERAHfoYCl2olFkjESBKyFDt3DHUGFfnxtfqnlp3oGk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=npVRRZMb; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="npVRRZMb" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-47ee1fe7b24so13843375e9.1 for ; Fri, 16 Jan 2026 02:44:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768560290; x=1769165090; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lUX7IRgIyUPb4V4ApOigl/qbJl9m0SFY99Aj6A7demw=; b=npVRRZMb1dp8pb4o5o1xfiNBcJfCavVVdZmQBJ8rvljYhOMRDl/VI5txkcmO4pBZ3I /KVSF9or2D4DhzYq9sIEHwG0UyMy/8rEuTg6Cq1vWUOMeFNuWk4onwEJC6Cyg31siZmC lkEqijfwO2WYaiARXRyN4eYrKVfSo3KUX0T60gdnmkh7w38ByzeOzCnTFn27yhMOrsIg HzJaYT0fFq/r1XNy+1RSDgZFGrZWv9uevLPV31blKloPeWEsDbpc3XzRa7npuep1Cf9e BejEez2DCN4LWOmXxSg8oRJFJbVAruLQH0itn99PPdlKowcScGojok4LrH2dS+7PFaod gLmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768560290; x=1769165090; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lUX7IRgIyUPb4V4ApOigl/qbJl9m0SFY99Aj6A7demw=; b=Hl0Oph+MuMR+0cFH5CIQCzKs4vLMu/Y+BJ3lLwv33Q/P9jJUKLHaDKmqyuOhEahk1t +8vKK3z0/7yyiGC5UwBLeN/dMQbYQG/93u4Uh7Afy+/dng45JPqINg14QjHDQAWOGmKr RicFTSHaqQSHygpR9HB5fm6O4HrkVmZLYGVU1FlNBXOyUYNezVJNthUFZX3sOkzBJRM9 sJv46Mgiuiys+nPCGB2ZmShU+de2GxkjZHbF2tVtMoQcgMUfgnTQyalJlvTWd2NI5LxY OgLqrgkANraKD/Ib5y4nZsy4WJpB2+pf+Y0ex5AJITfpihDylxFFXwKgsmFF64qh+5pJ AvGA== X-Forwarded-Encrypted: i=1; AJvYcCUMrG+pR9UrIHvCwNoQPmdzBEUGIByUk9BiKlY0zOVkppslA/A9Ttbh5zAPw7WGbon0Fu5devGdlUYnDOA=@vger.kernel.org X-Gm-Message-State: AOJu0Yyn/Y/lf2UxZdIj4b14puvNldyPfXGPM+7Z5+UwG6tJ7S++p3Nd M3QhwvU3eQnBDzxpK4nP0IiZJr785yWJqxfm5e4916/EbDWYjIhr0fewOwLEoNKZDTHRuWUgIeg gWtltYXlKfAIzYFdgVg== X-Received: from wmaq10.prod.google.com ([2002:a05:600c:6c8a:b0:47e:d9ed:20f0]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c16a:b0:47e:e20e:bbbe with SMTP id 5b1f17b1804b1-4801e33c332mr30124455e9.25.1768560290048; Fri, 16 Jan 2026 02:44:50 -0800 (PST) Date: Fri, 16 Jan 2026 10:44:46 +0000 In-Reply-To: <20260115212657.399231-3-zhiw@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260115212657.399231-1-zhiw@nvidia.com> <20260115212657.399231-3-zhiw@nvidia.com> Message-ID: Subject: Re: [PATCH v9 2/5] rust: io: factor common I/O helpers into Io trait From: Alice Ryhl To: Zhi Wang Cc: rust-for-linux@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, dakr@kernel.org, bhelgaas@google.com, kwilczynski@kernel.org, ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu, markus.probst@posteo.de, helgaas@kernel.org, cjia@nvidia.com, smitra@nvidia.com, ankita@nvidia.com, aniketa@nvidia.com, kwankhede@nvidia.com, targupta@nvidia.com, acourbot@nvidia.com, joelagnelf@nvidia.com, jhubbard@nvidia.com, zhiwang@kernel.org, daniel.almeida@collabora.com Content-Type: text/plain; charset="utf-8" On Thu, Jan 15, 2026 at 11:26:46PM +0200, Zhi Wang wrote: > The previous Io type combined both the generic I/O access helpers > and MMIO implementation details in a single struct. > > To establish a cleaner layering between the I/O interface and its concrete > backends, paving the way for supporting additional I/O mechanisms in the > future, Io need to be factored. > > Factor the common helpers into new {Io, Io64} traits, and move the > MMIO-specific logic into a dedicated Mmio type implementing that > trait. Rename the IoRaw to MmioRaw and update the bus MMIO implementations > to use MmioRaw. > > No functional change intended. > > Cc: Alexandre Courbot > Cc: Alice Ryhl > Cc: Bjorn Helgaas > Cc: Danilo Krummrich > Cc: John Hubbard > Signed-off-by: Zhi Wang > +pub trait IoBase { > +pub trait IoKnownSize: IoBase { > +pub trait Io: IoBase { > +pub trait IoKnownSize64: IoKnownSize { > +pub trait Io64: Io { The following combinations are possible: 1. IoBase 2. IoBase + Io 3. IoBase + IoKnownSize 4. IoBase + Io + IoKnownSize 5. IoBase + Io + Io64 6. IoBase + Io + Io64 + IoKnownSize 7. IoBase + IoKnownSize + IoKnownSize64 8. IoBase + Io + IoKnownSize + IoKnownSize64 9. IoBase + Io + IoKnownSize + Io64 + IoKnownSize64 I'm not sure all of them make sense. I can't see a scenario where I would pick 1, 3, 6, 7, or 8. How about this trait hierachy? I believe I suggested something along these lines before. pub trait Io { pub trait Io64: Io { pub trait IoKnownSize: Io { With these traits, these scenarios are possible: 1. Io 2. Io + Io64 3. Io + IoKnownSize 4. Io + Io64 + IoKnownSize which seems to be the actual set of cases we care about. Note that IoKnownSize can have methods that only apply when Io64 is implemented: trait IoKnownSize: Io { /// Infallible 8-bit read with compile-time bounds check. fn read8(&self, offset: usize) -> u8; /// Infallible 64-bit read with compile-time bounds check. fn read64(&self, offset: usize) -> u64 where Self: Io64; } Alice