Rust for Linux List
 help / color / mirror / Atom feed
From: Maurice Hieronymus <mhi@mailbox.org>
To: Danilo Krummrich <dakr@kernel.org>, Bjorn Helgaas <bhelgaas@google.com>
Cc: "Maurice Hieronymus" <mhi@mailbox.org>,
	"Lukas Wunner" <lukas@wunner.de>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Onur Özkan" <work@onurozkan.dev>,
	"Beata Michalska" <beata.michalska@arm.com>,
	nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] rust: pci: rework device enabling API
Date: Thu, 30 Jul 2026 15:25:58 +0200	[thread overview]
Message-ID: <20260730132559.65566-1-mhi@mailbox.org> (raw)
In-Reply-To: <DJVUHS5VHP4Z.G2FV1QJQ8ZYH@mailbox.org>

On Sat Jul 11, 2026 at 5:25 PM CEST, Maurice Hieronymus wrote:
> I went ahead and sent a series implementing the second option, a
> public flags bitmap with generated accessors following the driver
> core precedent, converting is_busmaster and broken_parity_status:
>
> https://lore.kernel.org/r/20260711-pci-dev-flags-v1-0-2fcf2811138c@mailbox.org

A status update on that, and two questions.

v2 [1] moved the bit into `priv_flags` instead, as Lukas preferred. He
then asked me to convert xen-pciback's two direct `dev->is_busmaster = 0`
assignments to `pci_clear_master()`, so that nothing outside drivers/pci
writes the flag [2].

That conversion is not behavior-preserving: the assignments clear the
software flag only, while `pci_clear_master()` also clears
PCI_COMMAND_MASTER in config space. Commit 7681f31ec9cd ("xen/pciback:
Don't disable PCI_COMMAND on PCI device reset.") deliberately removed a
PCI_COMMAND write from directly above the first assignment, so putting
one back at that spot looked wrong to me.

I said so in that thread on Jul 18 [3], and asked the xen maintainers
directly in a separate mail on Jul 23 [4]. Neither has had a reply, so
the C-side prerequisite has not moved since.

On proceeding on the Rust side in the meantime:

I would like to keep the enable/disable rework in the EDU series rather
than drop it. `enable_device_mem()` has no disable counterpart, so the
enable count is never dropped on unbind, and the sample does not come
back up after rmmod + modprobe.

The races the guard would expose are not introduced by this series.
`is_busmaster` shares one bitfield word in `struct pci_dev` with a
number of other flags, and those are written from unrelated contexts, so
several of them can be updated concurrently with it.
`broken_parity_status` is only the clearest example:
`broken_parity_status_store()` (drivers/pci/pci-sysfs.c) writes it from
sysfs without taking any lock at all, so userspace can already race an
`is_busmaster` update today.

So my first question: would you take the `DeviceEnableGuard` design
while that word is still a C bitfield, given that it can already be
raced from userspace today, and let the EDU sample land on top of it,
replacing `rust_driver_pci` as you asked? Or do you want the bitops
conversion merged first, in which case the series stays blocked on
linux-pci.

My second question is a behavioural one, since I do not have much
experience here: what is the accepted way forward when a list does not
respond? I do not want to resend the same question every week and turn
into noise, but I also do not want to guess at xen-pciback semantics and
break someone's setup.

[1] https://lore.kernel.org/linux-pci/20260714-pci-dev-flags-v2-1-a1d7dc441cf3@mailbox.org/
[2] https://lore.kernel.org/linux-pci/alcSjoypegNolW48@wunner.de/
[3] https://lore.kernel.org/linux-pci/DK1UXXRGW737.2IVTYCHPRM9ET@mailbox.org/
[4] https://lore.kernel.org/linux-pci/20260723161638.9838-1-mhi@mailbox.org/

Best,

Maurice

      reply	other threads:[~2026-07-30 13:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  9:32 [PATCH] rust: pci: rework device enabling API Maurice Hieronymus
2026-07-02 21:47 ` Danilo Krummrich
2026-07-05 21:04   ` Maurice Hieronymus
2026-07-11 15:25     ` Maurice Hieronymus
2026-07-30 13:25       ` Maurice Hieronymus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260730132559.65566-1-mhi@mailbox.org \
    --to=mhi@mailbox.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=beata.michalska@arm.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=lukas@wunner.de \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox