mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Stanner <phasta@mailbox.org>
To: Yao Zi <me@ziyao.cc>,
	phasta@kernel.org, Bjorn Helgaas <helgaas@kernel.org>,
	 "Russell King (Oracle)" <linux@armlinux.org.uk>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: 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: Thu, 11 Dec 2025 15:44:57 +0100	[thread overview]
Message-ID: <130064e95124f32a40618620450016bec0a96ffd.camel@mailbox.org> (raw)
In-Reply-To: <aTrT3rHhtXkSyPOO@pie>

On Thu, 2025-12-11 at 14:23 +0000, Yao Zi wrote:
> On Mon, Dec 08, 2025 at 10:54:36AM +0100, Philipp Stanner wrote:
> > On Fri, 2025-12-05 at 16:16 -0600, Bjorn Helgaas wrote:
> > > [+to Philipp, Thomas for MSI devres question]
> > > 
> > > On Fri, Dec 05, 2025 at 09:34:54AM +0000, Russell King (Oracle) wrote:
> > > > On Fri, Dec 05, 2025 at 05:31:34AM +0000, Yao Zi wrote:
> > > > > On Mon, Nov 24, 2025 at 07:06:12PM +0000, Russell King (Oracle) wrote:
> > > > > > On Mon, Nov 24, 2025 at 04:32:10PM +0000, Yao Zi wrote:
> 
> ...
> 
> > > > This looks very non-intuitive, and the documentation for
> > > > pci_alloc_irq_vectors() doesn't help:
> > > > 
> > > >  * Upon a successful allocation, the caller should use pci_irq_vector()
> > > >  * to get the Linux IRQ number to be passed to request_threaded_irq().
> > > >  * The driver must call pci_free_irq_vectors() on cleanup.
> > > >    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > > 
> > > > because if what you say is correct (and it looks like it is) then this
> > > > line is blatently incorrect.
> > 
> > True, this line is false. It should probably state "If you didn't
> > enable your PCI device with pcim_enable_device(), you must call
> > pci_free_irq_vectors() on cleanup."
> > 
> > If it's not a bug, one could keep the docu that way or at least phrase
> > it in a way so that no additional users start relying on that hybrid
> > mechanism.
> 
> Thanks for the clarification, would you mind me sending a patch to fix
> the description, and also mention the automatic clean-up behavior
> shouldn't be relied anymore in new code?

If I would mind if *you* send such a patch? I for sure wouldn't mind,
that's the entire idea of open source development ^^

I can of course review it if you +Cc me.

> 
> ...
> 
> > The good news is that it's the last remainder of PCI hybrid devres and
> > getting rid of it would allow for removal of some additional code, too
> > (e.g., is_enabled bit and pcim_pin_device()).
> > 
> > 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…
> 
> Do you think adding an implementation of pcim_alloc_irq_vectors(), that
> always call pci_free_irq_vectors() regardless whether the PCI device is
> managed, will help the conversion?
> 
> This will make it more trival to rewrite drivers depending on the
> automatic clean-up behavior: since calling pci_free_irq_vectors()
> several times is okay, we could simply change pci_alloc_irq_vectors() to
> pcim_alloc_irq_vectors(), without considering where to call
> pci_free_irq_vectors().
> 
> Introducing pcim_alloc_irq_vectors() will also help newly-introduced
> drivers to reduce duplicated code to handle resource clean-up.

That's in fact how I have cleaned up the hybrid nature that was present
until this year in pci_request_region() et al.:

https://lore.kernel.org/linux-pci/20250519112959.25487-2-phasta@kernel.org/

It's one way to do it. First port everyone who relies on managed
behavior to a pcim_ function, and once they're all ported, remove the
hybrid nature from the pci_ function.

So that works, yes. The real question is just whether one wants a pcim_
function for the irq vectors. My personal impression is that this looks
like a useful feature; but my expertise with MSI is a bit limited.
There's also this strange kernel-wide msi_enabled global bool.. 

I guess the best way to find out is to try implementing it.

In case of doubt, the boring unmanaged pci_ version is the safe choice.
One contributor around here has once called the managed versions "the
crazy devres voodoo" :p

(BTW, just to be sure, pcim_ functions must not be interconnected with
pcim_enable() in the future anymore, nor shall they use global state.
All PCI devres functionality should purely work on the device file
through pure devres. The pcim_enable() interconnection cam only from
the hybrid feature.)


P.

> 
> > If you give me a pointer I can provide a TODO entry. In any case, feel
> > free to set me as a reviewer!
> 
> > Regards
> > Philipp
> 
> Regards,
> Yao Zi


  reply	other threads:[~2025-12-11 14:45 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)
2025-12-08 10:55                   ` Philipp Stanner
2025-12-11 14:23             ` Yao Zi
2025-12-11 14:44               ` Philipp Stanner [this message]
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=130064e95124f32a40618620450016bec0a96ffd.camel@mailbox.org \
    --to=phasta@mailbox.org \
    --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=linux@armlinux.org.uk \
    --cc=me@ziyao.cc \
    --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 \
    /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

all inboxes | Powered by JetHome®