2019-12-09 21:32:14

by Nicholas Johnson

[permalink] [raw]
Subject: [[RFC PATCH v1] 1/1] PCI: Add pci=nobbn to ignore ACPI _BBN method to override host bridge bus window

Add pci=nobbn kernel parameter.

Override the host bridge bus resource to [bus 00-ff] when specified.

Update documentation to reflect the above.

Signed-off-by: Nicholas Johnson <[email protected]>
---
Documentation/admin-guide/kernel-parameters.txt | 2 ++
arch/x86/include/asm/pci_x86.h | 1 +
arch/x86/pci/acpi.c | 11 +++++++++++
arch/x86/pci/common.c | 3 +++
4 files changed, 17 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index cfe8c2b67..0333d9d63 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3432,6 +3432,8 @@
please report a bug.
nocrs [X86] Ignore PCI host bridge windows from ACPI.
If you need to use this, please report a bug.
+ nobbn [X86] Ignore PCI BIOS Bus Number from ACPI.
+ If you need to use this, please report a bug.
routeirq Do IRQ routing for all PCI devices.
This is normally done in pci_enable_device(),
so this option is a temporary workaround
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
index 73bb404f4..179cdd5d1 100644
--- a/arch/x86/include/asm/pci_x86.h
+++ b/arch/x86/include/asm/pci_x86.h
@@ -39,6 +39,7 @@ do { \
#define PCI_ROOT_NO_CRS 0x100000
#define PCI_NOASSIGN_BARS 0x200000
#define PCI_BIG_ROOT_WINDOW 0x400000
+#define PCI_ROOT_NO_BBN 0x800000

extern unsigned int pci_probe;
extern unsigned long pirq_table_addr;
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 948656069..fc54a1f3c 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -20,6 +20,7 @@ struct pci_root_info {
};

static bool pci_use_crs = true;
+static bool pci_use_bbn = true;
static bool pci_ignore_seg = false;

static int __init set_use_crs(const struct dmi_system_id *id)
@@ -156,6 +157,8 @@ void __init pci_acpi_crs_quirks(void)
else if (pci_probe & PCI_USE__CRS)
pci_use_crs = true;

+ pci_use_bbn = !(pci_probe & PCI_ROOT_NO_BBN);
+
printk(KERN_INFO "PCI: %s host bridge windows from ACPI; "
"if necessary, use \"pci=%s\" and report a bug\n",
pci_use_crs ? "Using" : "Ignoring",
@@ -298,6 +301,14 @@ static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci)
struct resource_entry *entry, *tmp;
int status;

+ if (!pci_use_bbn){
+ dev_printk(KERN_DEBUG, &device->dev,
+ "host bridge window %pR (ignored)\n",
+ &ci->root->secondary);
+ ci->root->secondary.start = 0x00;
+ ci->root->secondary.end = 0xff;
+ }
+
status = acpi_pci_probe_root_resources(ci);
if (pci_use_crs) {
resource_list_for_each_entry_safe(entry, tmp, &ci->resources)
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 9acab6ac2..9183a999f 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -594,6 +594,9 @@ char *__init pcibios_setup(char *str)
} else if (!strcmp(str, "nocrs")) {
pci_probe |= PCI_ROOT_NO_CRS;
return NULL;
+ } else if (!strcmp(str, "nobbn")) {
+ pci_probe |= PCI_ROOT_NO_BBN;
+ return NULL;
#ifdef CONFIG_PHYS_ADDR_T_64BIT
} else if (!strcmp(str, "big_root_window")) {
pci_probe |= PCI_BIG_ROOT_WINDOW;
--
2.24.0


2020-01-17 01:06:31

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [[RFC PATCH v1] 1/1] PCI: Add pci=nobbn to ignore ACPI _BBN method to override host bridge bus window

Nicholas,

Nicholas Johnson <[email protected]> writes:

> Add pci=nobbn kernel parameter.
>
> Override the host bridge bus resource to [bus 00-ff] when specified.

Fine, but you completely fail to explain why this is useful and why
someone would utilize this command line parameter.

Thanks,

tglx

2020-01-17 15:03:00

by Nicholas Johnson

[permalink] [raw]
Subject: Re: [[RFC PATCH v1] 1/1] PCI: Add pci=nobbn to ignore ACPI _BBN method to override host bridge bus window

On Thu, Jan 16, 2020 at 11:13:13PM +0100, Thomas Gleixner wrote:
> Nicholas,
>
> Nicholas Johnson <[email protected]> writes:
>
> > Add pci=nobbn kernel parameter.
> >
> > Override the host bridge bus resource to [bus 00-ff] when specified.
>
> Fine, but you completely fail to explain why this is useful and why
> someone would utilize this command line parameter.
There are motherboards with single PCIe root complex which give
significantly less than [bus 00-ff] via CRS. I own one with [bus 00-7f]
and have seen some with significantly less.

A user who wants to use more busses than the motherboard advertises will
want to use this kernel parameter, for instance if they have a lot of
PCIe switches or Thunderbolt 3 devices.

This is similar to how we have pci=nocrs to override motherboards with
issues. The bus resource is not overridden by pci=nocrs, even though it
will usually come from the same method. However, I believe it would be
unwise to change pci=nocrs to include bus resource, as detailed in my
original RFC.

>
> Thanks,
>
> tglx

Thanks,
Nicholas

2020-01-17 16:06:33

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [[RFC PATCH v1] 1/1] PCI: Add pci=nobbn to ignore ACPI _BBN method to override host bridge bus window

[+cc Rafael, linux-acpi, start of thread at
https://lore.kernel.org/lkml/PSXP216MB0438F3D8C09957C6A45BC43D80580@PSXP216MB0438.KORP216.PROD.OUTLOOK.COM/T/#u]

On Fri, Jan 17, 2020 at 03:00:11PM +0000, Nicholas Johnson wrote:
> On Thu, Jan 16, 2020 at 11:13:13PM +0100, Thomas Gleixner wrote:
> > Nicholas Johnson <[email protected]> writes:
> >
> > > Add pci=nobbn kernel parameter.
> > >
> > > Override the host bridge bus resource to [bus 00-ff] when specified.
> >
> > Fine, but you completely fail to explain why this is useful and why
> > someone would utilize this command line parameter.
>
> There are motherboards with single PCIe root complex which give
> significantly less than [bus 00-ff] via CRS. I own one with [bus 00-7f]
> and have seen some with significantly less.
>
> A user who wants to use more busses than the motherboard advertises will
> want to use this kernel parameter, for instance if they have a lot of
> PCIe switches or Thunderbolt 3 devices.

I don't think this is a good idea. "pci=nocrs" was mainly useful to
work around Linux defects in handling _CRS methods. I don't think we
have comparable defects in our handling of _BBN.

In your example, the BIOS is telling us the bridge leads to [bus
00-7f]. We don't know what is at [bus 80-ff]. Maybe that range is
valid and usable, and maybe it's not. It could be routed to a
different host bridge, it could contain devices the BIOS uses for its
own purposes, it could be completely invalid.

If we *did* decide this is a good idea, "nobbn" is a misleading name.
_BBN evaluates to a single bus number, not a range. In your example,
BIOS is supplying _BBN=0 and _CRS that contains [bus 00-7f]. "nobbn"
suggests that'd we'd ignore _BBN. But this patch actually ignores the
bus number range from _CRS, so it has nothing to do with _BBN.

> This is similar to how we have pci=nocrs to override motherboards with
> issues. The bus resource is not overridden by pci=nocrs, even though it
> will usually come from the same method. However, I believe it would be
> unwise to change pci=nocrs to include bus resource, as detailed in my
> original RFC.

For reference, I think this original RFC was
https://lore.kernel.org/r/PSXP216MB04385B2C1BB518E5219C30CE80580@PSXP216MB0438.KORP216.PROD.OUTLOOK.COM

Bjorn

2020-01-18 13:40:48

by Nicholas Johnson

[permalink] [raw]
Subject: Re: [[RFC PATCH v1] 1/1] PCI: Add pci=nobbn to ignore ACPI _BBN method to override host bridge bus window

On Fri, Jan 17, 2020 at 10:05:02AM -0600, Bjorn Helgaas wrote:
> [+cc Rafael, linux-acpi, start of thread at
> https://lore.kernel.org/lkml/PSXP216MB0438F3D8C09957C6A45BC43D80580@PSXP216MB0438.KORP216.PROD.OUTLOOK.COM/T/#u]
>
> On Fri, Jan 17, 2020 at 03:00:11PM +0000, Nicholas Johnson wrote:
> > On Thu, Jan 16, 2020 at 11:13:13PM +0100, Thomas Gleixner wrote:
> > > Nicholas Johnson <[email protected]> writes:
> > >
> > > > Add pci=nobbn kernel parameter.
> > > >
> > > > Override the host bridge bus resource to [bus 00-ff] when specified.
> > >
> > > Fine, but you completely fail to explain why this is useful and why
> > > someone would utilize this command line parameter.
> >
> > There are motherboards with single PCIe root complex which give
> > significantly less than [bus 00-ff] via CRS. I own one with [bus 00-7f]
> > and have seen some with significantly less.
> >
> > A user who wants to use more busses than the motherboard advertises will
> > want to use this kernel parameter, for instance if they have a lot of
> > PCIe switches or Thunderbolt 3 devices.
>
> I don't think this is a good idea. "pci=nocrs" was mainly useful to
> work around Linux defects in handling _CRS methods. I don't think we
> have comparable defects in our handling of _BBN.
What about motherboards with poor implementations, where they have
possibly not given us all the busses solely becuase they thought nobody
would need them all? Ideally, Linux would not have to deal with broken
hardware - but yet, the world is full of poor implementations, hence the
need for quirks.

>
> In your example, the BIOS is telling us the bridge leads to [bus
> 00-7f]. We don't know what is at [bus 80-ff]. Maybe that range is
> valid and usable, and maybe it's not. It could be routed to a
> different host bridge, it could contain devices the BIOS uses for its
> own purposes, it could be completely invalid.
If it is unusable, the system crashes and the user ceases to use the
option. The option works wonders for me - no issues. This is the same as
nocrs, which can lead to us using "unusable" memory from hidden devices.
It is a risk, but there are people happy to live life on the edge, and
giving them that option can enable those people to do what they want.
Those who value stability will not use such options.

>
> If we *did* decide this is a good idea, "nobbn" is a misleading name.
> _BBN evaluates to a single bus number, not a range. In your example,
> BIOS is supplying _BBN=0 and _CRS that contains [bus 00-7f]. "nobbn"
> suggests that'd we'd ignore _BBN. But this patch actually ignores the
> bus number range from _CRS, so it has nothing to do with _BBN.
Perhaps pci=nocrsbus - this is up for discussion. I am aware that it
normally comes from crs but could not come up with a good parameter
name.

>
> > This is similar to how we have pci=nocrs to override motherboards with
> > issues. The bus resource is not overridden by pci=nocrs, even though it
> > will usually come from the same method. However, I believe it would be
> > unwise to change pci=nocrs to include bus resource, as detailed in my
> > original RFC.
>
> For reference, I think this original RFC was
> https://lore.kernel.org/r/PSXP216MB04385B2C1BB518E5219C30CE80580@PSXP216MB0438.KORP216.PROD.OUTLOOK.COM
>
> Bjorn

Regards,
Nicholas