From: Jonathan Derrick <jonathan.derrick@linux.dev>
To: Vidya Sagar <vidyas@nvidia.com>
Cc: "Manivannan Sadhasivam" <mani@kernel.org>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Bjorn Helgaas" <helgaas@kernel.org>,
linux-pci@vger.kernel.org, "Lukas Wunner" <lukas@wunner.de>,
"Pali Rohár" <pali@kernel.org>,
"Jonathan Derrick" <jonathan.derrick@linux.dev>
Subject: [PATCH v2 2/7] PCI: Add pcie_port_slot_emulated stub
Date: Thu, 10 Nov 2022 12:50:10 -0700 [thread overview]
Message-ID: <20221110195015.207-3-jonathan.derrick@linux.dev> (raw)
In-Reply-To: <20221110195015.207-1-jonathan.derrick@linux.dev>
Add the checks to allow an emulated slot. An emulated slot will use
native Hotplug, AER, and PME services. It also needs to specify itself
as a hotplug bridge in order for bridge sizing to account for hotplug
reserved windows.
Signed-off-by: Jonathan Derrick <jonathan.derrick@linux.dev>
---
drivers/pci/pci-acpi.c | 3 +++
drivers/pci/pcie/portdrv_core.c | 9 ++++++---
drivers/pci/probe.c | 2 +-
include/linux/pci.h | 2 ++
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index a46fec776ad7..77a3c9e39966 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -798,6 +798,9 @@ bool pciehp_is_native(struct pci_dev *bridge)
if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
return false;
+ if (pcie_port_slot_emulated(bridge))
+ return true;
+
pcie_capability_read_dword(bridge, PCI_EXP_SLTCAP, &slot_cap);
if (!(slot_cap & PCI_EXP_SLTCAP_HPC))
return false;
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 1ac7fec47d6f..b3c1e7d4ff10 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -209,7 +209,8 @@ static int get_port_device_capability(struct pci_dev *dev)
int services = 0;
if (dev->is_hotplug_bridge &&
- (pcie_ports_native || host->native_pcie_hotplug)) {
+ (pcie_ports_native || pcie_port_slot_emulated(dev) ||
+ host->native_pcie_hotplug)) {
services |= PCIE_PORT_SERVICE_HP;
/*
@@ -222,14 +223,16 @@ static int get_port_device_capability(struct pci_dev *dev)
#ifdef CONFIG_PCIEAER
if (dev->aer_cap && pci_aer_available() &&
- (pcie_ports_native || host->native_aer))
+ (pcie_ports_native || pcie_port_slot_emulated(dev) ||
+ host->native_aer))
services |= PCIE_PORT_SERVICE_AER;
#endif
/* Root Ports and Root Complex Event Collectors may generate PMEs */
if ((pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC) &&
- (pcie_ports_native || host->native_pme)) {
+ (pcie_ports_native || pcie_port_slot_emulated(dev) ||
+ host->native_pme)) {
services |= PCIE_PORT_SERVICE_PME;
/*
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b66fa42c4b1f..86ac4d223eba 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1574,7 +1574,7 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev)
u32 reg32;
pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, ®32);
- if (reg32 & PCI_EXP_SLTCAP_HPC)
+ if (reg32 & PCI_EXP_SLTCAP_HPC || pcie_port_slot_emulated(pdev))
pdev->is_hotplug_bridge = 1;
}
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ff47ef83ab38..09f704337955 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1655,6 +1655,8 @@ extern bool pcie_ports_native;
#define pcie_ports_native false
#endif
+#define pcie_port_slot_emulated(dev) false
+
#define PCIE_LINK_STATE_L0S BIT(0)
#define PCIE_LINK_STATE_L1 BIT(1)
#define PCIE_LINK_STATE_CLKPM BIT(2)
--
2.30.2
next prev parent reply other threads:[~2022-11-10 19:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 19:50 [PATCH v2 0/7] PCIe Hotplug Slot Emulation driver Jonathan Derrick
2022-11-10 19:50 ` [PATCH v2 1/7] PCI: Allow for indirecting capability registers Jonathan Derrick
2022-11-10 21:10 ` Pali Rohár
2022-11-10 19:50 ` Jonathan Derrick [this message]
2022-11-10 19:50 ` [PATCH v2 3/7] PCI: pciehp: Expose the poll loop to other drivers Jonathan Derrick
2022-11-10 19:50 ` [PATCH v2 4/7] PCI: Move pci_dev_str_match to search.c Jonathan Derrick
2022-11-10 19:50 ` [PATCH v2 5/7] PCI: pci-bridge-emul: Provide a helper to set behavior Jonathan Derrick
2022-11-10 21:02 ` Pali Rohár
2022-11-10 19:50 ` [PATCH v2 6/7] PCI: pciehp: Add hotplug slot emulation driver Jonathan Derrick
2022-11-10 19:50 ` [PATCH v2 7/7] PCI: pciehp: Wire up pcie_port_emulate_slot and Jonathan Derrick
2022-11-10 21:17 ` [PATCH v2 0/7] PCIe Hotplug Slot Emulation driver Pali Rohár
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=20221110195015.207-3-jonathan.derrick@linux.dev \
--to=jonathan.derrick@linux.dev \
--cc=helgaas@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=lukas@wunner.de \
--cc=mani@kernel.org \
--cc=pali@kernel.org \
--cc=vidyas@nvidia.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;
as well as URLs for NNTP newsgroup(s).