Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: Lukas Wunner <lukas@wunner.de>,
	Laurent Bigonville <bigon@bigon.be>,
	Mario Limonciello <mario.limonciello@amd.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Mika Westerberg <westeri@kernel.org>,
	Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>,
	Gil Fine <gil.fine@linux.intel.com>,
	Rene Sapiens <rene.sapiens@intel.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 5/5] PCI: Set native_pcie_hotplug up front based on pcie_ports_native
Date: Tue, 22 Jul 2025 17:33:48 -0500	[thread overview]
Message-ID: <20250722223348.GA2856499@bhelgaas> (raw)
In-Reply-To: <db299ce6-314c-41d2-85a4-118f0ac420e1@linux.intel.com>

On Mon, Jul 14, 2025 at 04:50:45PM -0700, Sathyanarayanan Kuppuswamy wrote:
> 
> On 7/14/25 4:00 PM, Sathyanarayanan Kuppuswamy wrote:
> > 
> > On 7/13/25 7:31 AM, Lukas Wunner wrote:
> > > Bjorn suggests to "set host->native_pcie_hotplug up front based on
> > > CONFIG_HOTPLUG_PCI_PCIE and pcie_ports_native, and pciehp_is_native()
> > > would collapse to just an accessor for host->native_pcie_hotplug".
> > > 
> > > Unfortunately only half of this is possible:
> > > 
> > > The check for pcie_ports_native can indeed be moved out of
> > > pciehp_is_native() and into acpi_pci_root_create().
> > > 
> > > The check for CONFIG_HOTPLUG_PCI_PCIE however cannot be eliminated:
> > > 
> > > get_port_device_capability() needs to know whether platform firmware has
> > > granted PCIe Native Hot-Plug control to the operating system. If it has
> > > and CONFIG_HOTPLUG_PCI_PCIE is disabled, the function disables hotplug
> > > interrupts in case BIOS left them enabled.
> > > 
> > > If host->native_pcie_hotplug would be set up front based on
> > > CONFIG_HOTPLUG_PCI_PCIE, it would later on be impossible for
> > > get_port_device_capability() to tell whether it can safely disable hotplug
> > > interrupts:  It wouldn't know whether Native Hot-Plug control was granted.
> > 
> > Since pcie_ports_native is a PCI driver specific override option, I am not
> > sure it is worth referring to this option in ACPI driver, just to reduce the
> > number of pcie_ports_native checks from 2 to 1.
> 
> Never mind. It looks like the goal is to simplify the
> pciehp_is_native() call.

I would actually like to see more uses of pcie_ports_native removed.
It's basically an override of the OS/platform negotiation for control
of features, so I think it would make sense to test it somewhere in
the negotiate_os_control() rats nest or in acpi_pci_root_create().

> > > Link: https://lore.kernel.org/r/20250627025607.GA1650254@bhelgaas/
> > > Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> > > Signed-off-by: Lukas Wunner <lukas@wunner.de>
> > > ---
> > >   drivers/acpi/pci_root.c    | 3 ++-
> > >   drivers/pci/pci-acpi.c     | 3 ---
> > >   drivers/pci/pcie/portdrv.c | 2 +-
> > >   3 files changed, 3 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> > > index 74ade4160314..f3de0dc9c533 100644
> > > --- a/drivers/acpi/pci_root.c
> > > +++ b/drivers/acpi/pci_root.c
> > > @@ -1028,7 +1028,8 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
> > >           goto out_release_info;
> > >         host_bridge = to_pci_host_bridge(bus->bridge);
> > > -    if (!(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
> > > +    if (!pcie_ports_native &&
> > > +        !(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
> > >           host_bridge->native_pcie_hotplug = 0;
> > >       if (!(root->osc_control_set & OSC_PCI_SHPC_NATIVE_HP_CONTROL))
> > >           host_bridge->native_shpc_hotplug = 0;
> > > diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> > > index ed7ed66a595b..b513826ea293 100644
> > > --- a/drivers/pci/pci-acpi.c
> > > +++ b/drivers/pci/pci-acpi.c
> > > @@ -820,9 +820,6 @@ bool pciehp_is_native(struct pci_dev *bridge)
> > >       if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
> > >           return false;
> > >   -    if (pcie_ports_native)
> > > -        return true;
> > > -
> > >       host = pci_find_host_bridge(bridge->bus);
> > >       return host->native_pcie_hotplug;
> > >   }
> > > diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
> > > index d1b68c18444f..fa83ebdcfecb 100644
> > > --- a/drivers/pci/pcie/portdrv.c
> > > +++ b/drivers/pci/pcie/portdrv.c
> > > @@ -223,7 +223,7 @@ static int get_port_device_capability(struct pci_dev *dev)
> > >       if (dev->is_pciehp &&
> > >           (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
> > >            pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) &&
> > > -        (pcie_ports_native || host->native_pcie_hotplug)) {
> > > +        host->native_pcie_hotplug) {
> > >           services |= PCIE_PORT_SERVICE_HP;
> > >             /*
> > 
> -- 
> Sathyanarayanan Kuppuswamy
> Linux Kernel Developer
> 

  reply	other threads:[~2025-07-22 22:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-13 14:31 [PATCH v2 0/5] PCI: Clean up and fix is_hotplug_bridge usage Lukas Wunner
2025-07-13 14:31 ` [PATCH v2 1/5] PCI/ACPI: Fix runtime PM ref imbalance on Hot-Plug Capable ports Lukas Wunner
2025-07-26 20:50   ` Rafael J. Wysocki
2025-07-13 14:31 ` [PATCH v2 2/5] PCI/portdrv: Use is_pciehp instead of is_hotplug_bridge Lukas Wunner
2025-07-13 14:31 ` [PATCH v2 3/5] PCI: pciehp: " Lukas Wunner
2025-07-13 14:31 ` [PATCH v2 4/5] PCI: Move is_pciehp check out of pciehp_is_native() Lukas Wunner
2025-07-13 14:31 ` [PATCH v2 5/5] PCI: Set native_pcie_hotplug up front based on pcie_ports_native Lukas Wunner
2025-07-14 23:00   ` Sathyanarayanan Kuppuswamy
2025-07-14 23:50     ` Sathyanarayanan Kuppuswamy
2025-07-22 22:33       ` Bjorn Helgaas [this message]
2025-07-22 22:35 ` [PATCH v2 0/5] PCI: Clean up and fix is_hotplug_bridge usage Bjorn Helgaas
2025-07-25  8:19   ` Lukas Wunner
2025-07-25 19:33     ` Bjorn Helgaas
2025-07-26 20:52       ` Rafael J. Wysocki

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=20250722223348.GA2856499@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=alan.borzeszkowski@linux.intel.com \
    --cc=bigon@bigon.be \
    --cc=gil.fine@linux.intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mario.limonciello@amd.com \
    --cc=rafael@kernel.org \
    --cc=rene.sapiens@intel.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=westeri@kernel.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