From: tip-bot for Jan Kiszka <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, andy.shevchenko@gmail.com,
tglx@linutronix.de, hpa@zytor.com, b.spranger@linutronix.de,
jan.kiszka@siemens.com, bhelgaas@google.com, mingo@kernel.org
Subject: [tip:x86/platform] PCI: Scan all functions when running over Jailhouse
Date: Thu, 8 Mar 2018 03:34:26 -0800 [thread overview]
Message-ID: <tip-690f4304104f37e473bd5e43fc5247f5cd35b225@git.kernel.org> (raw)
In-Reply-To: <06e279b2a3e06cf6689ab3975f8ab592bba02362.1520408357.git.jan.kiszka@siemens.com>
Commit-ID: 690f4304104f37e473bd5e43fc5247f5cd35b225
Gitweb: https://git.kernel.org/tip/690f4304104f37e473bd5e43fc5247f5cd35b225
Author: Jan Kiszka <jan.kiszka@siemens.com>
AuthorDate: Wed, 7 Mar 2018 08:39:13 +0100
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 8 Mar 2018 12:30:37 +0100
PCI: Scan all functions when running over Jailhouse
Per PCIe r4.0, sec 7.5.1.1.9, multi-function devices are required to have a
function 0. Therefore, Linux scans for devices at function 0 (devfn
0/8/16/...) and only scans for other functions if function 0 has its
Multi-Function Device bit set or ARI or SR-IOV indicate there are more
functions.
The Jailhouse hypervisor may pass individual functions of a multi-function
device to a guest without passing function 0, which means a Linux guest
won't find them.
Change Linux PCI probing so it scans all function numbers when running as a
guest over Jailhouse.
This is technically prohibited by the spec, so it is possible that PCI
devices without the Multi-Function Device bit set may have unexpected
behavior in response to this probe.
Originally-by: Benedikt Spranger <b.spranger@linutronix.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: jailhouse-dev@googlegroups.com
Cc: Benedikt Spranger <b.spranger@linutronix.de>
Cc: linux-pci@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Link: https://lkml.kernel.org/r/06e279b2a3e06cf6689ab3975f8ab592bba02362.1520408357.git.jan.kiszka@siemens.com
---
arch/x86/pci/legacy.c | 4 +++-
drivers/pci/probe.c | 22 +++++++++++++++++++---
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/arch/x86/pci/legacy.c b/arch/x86/pci/legacy.c
index 1cb01abcb1be..dfbe6ac38830 100644
--- a/arch/x86/pci/legacy.c
+++ b/arch/x86/pci/legacy.c
@@ -4,6 +4,7 @@
#include <linux/init.h>
#include <linux/export.h>
#include <linux/pci.h>
+#include <asm/jailhouse_para.h>
#include <asm/pci_x86.h>
/*
@@ -34,13 +35,14 @@ int __init pci_legacy_init(void)
void pcibios_scan_specific_bus(int busn)
{
+ int stride = jailhouse_paravirt() ? 1 : 8;
int devfn;
u32 l;
if (pci_find_bus(0, busn))
return;
- for (devfn = 0; devfn < 256; devfn += 8) {
+ for (devfn = 0; devfn < 256; devfn += stride) {
if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) &&
l != 0x0000 && l != 0xffff) {
DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ef5377438a1e..3c365dc996e7 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -16,6 +16,7 @@
#include <linux/pci-aspm.h>
#include <linux/aer.h>
#include <linux/acpi.h>
+#include <linux/hypervisor.h>
#include <linux/irqdomain.h>
#include <linux/pm_runtime.h>
#include "pci.h"
@@ -2518,14 +2519,29 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
{
unsigned int used_buses, normal_bridges = 0, hotplug_bridges = 0;
unsigned int start = bus->busn_res.start;
- unsigned int devfn, cmax, max = start;
+ unsigned int devfn, fn, cmax, max = start;
struct pci_dev *dev;
+ int nr_devs;
dev_dbg(&bus->dev, "scanning bus\n");
/* Go find them, Rover! */
- for (devfn = 0; devfn < 0x100; devfn += 8)
- pci_scan_slot(bus, devfn);
+ for (devfn = 0; devfn < 256; devfn += 8) {
+ nr_devs = pci_scan_slot(bus, devfn);
+
+ /*
+ * The Jailhouse hypervisor may pass individual functions of a
+ * multi-function device to a guest without passing function 0.
+ * Look for them as well.
+ */
+ if (jailhouse_paravirt() && nr_devs == 0) {
+ for (fn = 1; fn < 8; fn++) {
+ dev = pci_scan_single_device(bus, devfn + fn);
+ if (dev)
+ dev->multifunction = 1;
+ }
+ }
+ }
/* Reserve buses for SR-IOV capability */
used_buses = pci_iov_bus_range(bus);
next prev parent reply other threads:[~2018-03-08 11:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-07 7:39 [PATCH v5 0/7] jailhouse: Enhance secondary Jailhouse guest support /wrt PCI Jan Kiszka
2018-03-07 7:39 ` [PATCH v5 1/7] jailhouse: Provide detection for non-x86 systems Jan Kiszka
2018-03-08 11:33 ` [tip:x86/platform] " tip-bot for Jan Kiszka
2018-03-07 7:39 ` [PATCH v5 2/7] PCI: Scan all functions when running over Jailhouse Jan Kiszka
2018-03-08 11:34 ` tip-bot for Jan Kiszka [this message]
2018-03-07 7:39 ` [PATCH v5 3/7] x86/jailhouse: Enable PCI mmconfig access in inmates Jan Kiszka
2018-03-08 11:35 ` [tip:x86/platform] " tip-bot for Otavio Pontes
2018-03-07 7:39 ` [PATCH v5 4/7] x86: Align x86_64 PCI_MMCONFIG with 32-bit variant Jan Kiszka
2018-03-08 11:35 ` [tip:x86/platform] " tip-bot for Jan Kiszka
2018-03-07 7:39 ` [PATCH v5 5/7] x86: Consolidate PCI_MMCONFIG configs Jan Kiszka
2018-03-08 11:36 ` [tip:x86/platform] " tip-bot for Jan Kiszka
2018-03-07 7:39 ` [PATCH v5 6/7] x86/jailhouse: Allow to use PCI_MMCONFIG without ACPI Jan Kiszka
2018-03-08 11:36 ` [tip:x86/platform] " tip-bot for Jan Kiszka
2018-03-07 7:39 ` [PATCH v5 7/7] MAINTAINERS: Add entry for Jailhouse Jan Kiszka
2018-03-08 11:36 ` [tip:x86/platform] " tip-bot for Jan Kiszka
2018-03-19 19:48 ` [PATCH v5 0/7] jailhouse: Enhance secondary Jailhouse guest support /wrt PCI Bjorn Helgaas
2018-03-19 19:50 ` Thomas Gleixner
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=tip-690f4304104f37e473bd5e43fc5247f5cd35b225@git.kernel.org \
--to=tipbot@zytor.com \
--cc=andy.shevchenko@gmail.com \
--cc=b.spranger@linutronix.de \
--cc=bhelgaas@google.com \
--cc=hpa@zytor.com \
--cc=jan.kiszka@siemens.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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