From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: phasta@kernel.org
Cc: Bjorn Helgaas <helgaas@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>, Yao Zi <ziyao@disroot.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Frank <Frank.Sae@motor-comm.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Choong Yong Liang <yong.liang.choong@linux.intel.com>,
Chen-Yu Tsai <wens@csie.org>, Jisheng Zhang <jszhang@kernel.org>,
Furong Xu <0x1207@gmail.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
Mingcong Bai <jeffbai@aosc.io>,
Kexy Biscuit <kexybiscuit@aosc.io>, Runhua He <hua@aosc.io>,
Xi Ruoyao <xry111@xry111.site>
Subject: Re: [PATCH net-next v3 2/3] net: stmmac: Add glue driver for Motorcomm YT6801 ethernet controller
Date: Mon, 8 Dec 2025 10:53:41 +0000 [thread overview]
Message-ID: <aTauNWvRKhn-muir@shell.armlinux.org.uk> (raw)
In-Reply-To: <7e024db2557a4d5822a0dd409ae678d10d815d9c.camel@mailbox.org>
On Mon, Dec 08, 2025 at 11:47:23AM +0100, Philipp Stanner wrote:
> On Mon, 2025-12-08 at 10:15 +0000, Russell King (Oracle) wrote:
> > On Mon, Dec 08, 2025 at 10:54:36AM +0100, Philipp Stanner wrote:
> > > The bad news is that it's not super trivial to remove. I looked into it
> > > about two times and decided I can't invest that time currently. You
> > > need to go over all drivers again to see who uses pcim_enable_device(),
> > > then add free_irq_vecs() for them all and so on…
> >
> > So that I can confirm, you're saying that all drivers that call
> > pci_alloc_irq_vectors() should call pci_free_irq_vectors() in their
> > ->remove() method and not rely on the devres behaviour that
> > pcim_enable_device() will permit.
>
> "permit" is kind of a generous word. This behavior is dangerous and
> there were bugs because of that in the past, because it confused
> programmers. See:
>
> f00059b4c1b0 drm/vboxvideo: fix mapping leaks
>
>
> pcim_enable_device() used to switch all sorts of functions into managed
> mode. As far as I could figure out through git, back in 2009 it was
> intended that ALL pci functions are switched into managed mode that
> way. That's also how it was documented.
>
> The ecosystem then fractured, however. Some functions were always
> managed (pcim_), some never, and some sometimes.
>
> I removed all "sometimes managed" functions since 2024. The last
> remainder is MSI.
>
> If we want to remove that, we need to:
> 1. Find all drivers that rely on pci_free_irq_vectors() being run
> automatically. IOW those that use pcim_enable_device() + wrappers
> around pci_setup_msi_context().
> 2. Port those drivers to do the free_irq_vecs manually, if it's not
> a problem if it's called twice. If that were a problem, those
> drivers would also need to replace pcim_enable_device() with
> pci_enable_device().
> 3. Once all drivers are ported, remove the devres code from msi.c
> 4. Do associated cleanup work in PCI.
>
> >
> > In terms of whether it's safe to call this twice, pci_free_irq_vectors()
> > calls pci_disable_msix() and pci_disable_msi().
> >
> > pci_disable_msix() checks:
> >
> > if (!pci_msi_enabled() || !dev || !dev->msix_enabled)
> > return;
> >
> > which will set dev->msix_enabled to 0 via pci_msix_shutdown().
> >
> > pci_disable_msi() does a similar check:
> >
> > if (!pci_msi_enabled() || !dev || !dev->msi_enabled)
> > return;
> >
> > and similarly pci_msi_shutdown() sets dev->msi_enabled to 0.
> >
> > So my conclusion is it's safe to call pci_free_irq_vectors() twice for
> > the same device.
> >
>
> Hm. Looks good.
So, what do you want to see for new drivers such as the one at the top
of this thread? Should they explicitly call pci_free_irq_vectors() even
though they call pcim_enable_device() ?
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2025-12-08 10:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 16:32 [PATCH net-next v3 0/3] Add DWMAC glue driver for Motorcomm YT6801 Yao Zi
2025-11-24 16:32 ` [PATCH net-next v3 1/3] net: phy: motorcomm: Support YT8531S PHY in YT6801 Ethernet controller Yao Zi
2025-11-24 16:32 ` [PATCH net-next v3 2/3] net: stmmac: Add glue driver for Motorcomm YT6801 ethernet controller Yao Zi
2025-11-24 19:06 ` Russell King (Oracle)
2025-12-05 5:31 ` Yao Zi
2025-12-05 9:34 ` Russell King (Oracle)
2025-12-05 22:16 ` Bjorn Helgaas
2025-12-08 9:54 ` Philipp Stanner
2025-12-08 10:15 ` Russell King (Oracle)
2025-12-08 10:47 ` Philipp Stanner
2025-12-08 10:53 ` Russell King (Oracle) [this message]
2025-12-08 10:55 ` Philipp Stanner
2025-12-11 14:23 ` Yao Zi
2025-12-11 14:44 ` Philipp Stanner
2025-12-08 11:11 ` Russell King (Oracle)
2025-11-24 16:32 ` [PATCH net-next v3 3/3] MAINTAINERS: Assign myself as maintainer of Motorcomm DWMAC glue driver Yao Zi
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=aTauNWvRKhn-muir@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=0x1207@gmail.com \
--cc=Frank.Sae@motor-comm.com \
--cc=andrew+netdev@lunn.ch \
--cc=bhelgaas@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=helgaas@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=hua@aosc.io \
--cc=jeffbai@aosc.io \
--cc=jszhang@kernel.org \
--cc=kexybiscuit@aosc.io \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phasta@kernel.org \
--cc=tglx@linutronix.de \
--cc=vladimir.oltean@nxp.com \
--cc=wens@csie.org \
--cc=xry111@xry111.site \
--cc=yong.liang.choong@linux.intel.com \
--cc=ziyao@disroot.org \
/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;
as well as URLs for NNTP newsgroup(s).