From: Bjorn Helgaas <bhelgaas@google.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Tony Luck <tony.luck@intel.com>, "H. Peter Anvin" <hpa@zytor.com>,
Yinghai Lu <yinghai@kernel.org>, Jiang Liu <liuj97@gmail.com>,
Myron Stowe <myron.stowe@redhat.com>
Subject: Re: [Alternative 2][PATCH] ACPI / PCI: Set root bridge ACPI handle in advance
Date: Wed, 2 Jan 2013 16:07:32 -0700 [thread overview]
Message-ID: <20130102230732.GB31813@google.com> (raw)
In-Reply-To: <2816571.07LqOj3EJg@vostro.rjw.lan>
On Thu, Dec 27, 2012 at 10:32:13PM +0100, Rafael J. Wysocki wrote:
> To that end, split pci_create_root_bus() into two functions,
> pci_alloc_root() and pci_add_root(), that will allocate memory for
> the new PCI bus and bridge representations and register them with
> the driver core, respectively, and that may be called directly by
> the architectures that need to set the root bridge's ACPI handle
> before registering it.
I'm trying to *reduce* the interfaces for creating and scanning PCI
host bridges, and this is a step in the opposite direction.
> Next, Make both x86 and ia64 (the only architectures using ACPI at
> the moment) call pci_alloc_root(), set the root bridge's ACPI handle
> and then call pci_add_root() in their pci_acpi_scan_root() routines
> instead of calling pci_create_root_bus(). For the other code paths
> adding PCI root bridges define a new pci_create_root_bus() as a
> simple combination of pci_alloc_root() and pci_add_root().
pci_create_root_bus() takes a "struct device *parent" argument. That
seems like a logical place to tell the PCI core about the host bridge
device, but x86 and ia64 currently pass NULL there.
The patch below shows what I'm thinking. It does have the side-effect
of changing the sysfs topology from this:
/sys/devices/pci0000:00
/sys/devices/pci0000:00/0000:00:00.0
to this:
/sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/pci0000:00
/sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/pci0000:00/0000:00:00.0
because it puts the PCI root bus (pci0000:00) under the PNP0A08 device
rather than at the top level. That seems like an improvement to me,
but it *is* different.
Bjorn
commit 5dee5f2f4fefbe4888939871c2252299067123bf
Author: Bjorn Helgaas <bhelgaas@google.com>
Date: Wed Jan 2 13:47:02 2013 -0700
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 0c01261..1cfde12 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -552,8 +552,9 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
(u8)root->secondary.end, root->mcfg_addr))
- bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
- sd, &resources);
+ bus = pci_create_root_bus(&device->dev, busnum,
+ &pci_root_ops, sd,
+ &resources);
if (bus) {
pci_scan_child_bus(bus);
@@ -593,6 +594,15 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
return bus;
}
+int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+{
+ struct device *parent = bridge->dev.parent;
+
+ if (parent)
+ ACPI_HANDLE_SET(&bridge->dev, to_acpi_device(parent)->handle);
+ return 0;
+}
+
int __init pci_acpi_init(void)
{
struct pci_dev *dev = NULL;
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 1af4008..d4516c4 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -303,28 +303,9 @@ static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
return 0;
}
-static int acpi_pci_find_root_bridge(struct device *dev, acpi_handle *handle)
-{
- int num;
- unsigned int seg, bus;
-
- /*
- * The string should be the same as root bridge's name
- * Please look at 'pci_scan_bus_parented'
- */
- num = sscanf(dev_name(dev), "pci%04x:%02x", &seg, &bus);
- if (num != 2)
- return -ENODEV;
- *handle = acpi_get_pci_rootbridge_handle(seg, bus);
- if (!*handle)
- return -ENODEV;
- return 0;
-}
-
static struct acpi_bus_type acpi_pci_bus = {
.bus = &pci_bus_type,
.find_device = acpi_pci_find_device,
- .find_bridge = acpi_pci_find_root_bridge,
};
static int __init acpi_pci_init(void)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6186f03..3575b2b 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1633,6 +1633,11 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
return max;
}
+int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+{
+ return 0;
+}
+
struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
struct pci_ops *ops, void *sysdata, struct list_head *resources)
{
@@ -1645,7 +1650,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
char bus_addr[64];
char *fmt;
-
b = pci_alloc_bus();
if (!b)
return NULL;
@@ -1666,6 +1670,9 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
bridge->dev.parent = parent;
bridge->dev.release = pci_release_bus_bridge_dev;
dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
+ error = pcibios_root_bridge_prepare(bridge);
+ if (error)
+ goto bridge_dev_reg_err;
error = device_register(&bridge->dev);
if (error)
goto bridge_dev_reg_err;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 15472d6..238438c 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -674,6 +674,7 @@ extern struct list_head pci_root_buses; /* list of all known PCI buses */
/* Some device drivers need know if pci is initiated */
extern int no_pci_devices(void);
+int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
void pcibios_fixup_bus(struct pci_bus *);
int __must_check pcibios_enable_device(struct pci_dev *, int mask);
/* Architecture specific versions may override this (weak) */
next prev parent reply other threads:[~2013-01-02 23:07 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1558789.gX8cmBgyDV@vostro.rjw.lan>
[not found] ` <4085861.TBmZVTPOvU@vostro.rjw.lan>
[not found] ` <3596215.suSiEFiGH8@vostro.rjw.lan>
2012-12-20 21:13 ` [Update 2][PATCH] ACPI / PCI: Set root bridge ACPI handle in advance Bjorn Helgaas
2012-12-20 21:19 ` H. Peter Anvin
2012-12-20 22:56 ` Rafael J. Wysocki
2012-12-21 0:25 ` Bjorn Helgaas
2012-12-25 22:42 ` [Alternative][PATCH] " Rafael J. Wysocki
2012-12-26 18:14 ` Bjorn Helgaas
2012-12-26 22:35 ` Rafael J. Wysocki
2012-12-26 20:04 ` Yinghai Lu
2012-12-26 20:10 ` Bjorn Helgaas
2012-12-26 20:16 ` Yinghai Lu
2012-12-26 20:41 ` Yinghai Lu
2012-12-26 22:36 ` Rafael J. Wysocki
2012-12-27 0:10 ` Yinghai Lu
2012-12-27 12:47 ` Rafael J. Wysocki
2012-12-27 13:31 ` Rafael J. Wysocki
2012-12-27 21:25 ` Rafael J. Wysocki
2012-12-27 21:32 ` [Alternative 2][PATCH] " Rafael J. Wysocki
2013-01-02 23:07 ` Bjorn Helgaas [this message]
2013-01-03 0:40 ` Rafael J. Wysocki
2013-01-03 12:11 ` Rafael J. Wysocki
2013-01-03 21:23 ` Rafael J. Wysocki
2013-01-03 22:13 ` Bjorn Helgaas
2013-01-03 22:56 ` Rafael J. Wysocki
2013-01-04 1:00 ` Bjorn Helgaas
2013-01-04 11:38 ` Rafael J. Wysocki
2013-01-05 0:03 ` Yinghai Lu
2013-01-05 0:14 ` Rafael J. Wysocki
2013-01-05 0:19 ` Yinghai Lu
2013-01-05 0:36 ` Bjorn Helgaas
2013-01-05 0:54 ` Rafael J. Wysocki
2013-01-03 20:44 ` Rafael J. Wysocki
2013-01-09 21:33 ` [Alternative][PATCH] ACPI / PCI: Set root bridge ACPI handle in advance, v2 Rafael J. Wysocki
2013-01-09 22:16 ` Bjorn Helgaas
2013-01-09 23:06 ` Rafael J. Wysocki
2013-01-09 23:27 ` Yinghai Lu
2013-01-10 0:05 ` Rafael J. Wysocki
2013-01-11 21:53 ` Rafael J. Wysocki
2013-01-11 23:01 ` Yinghai Lu
2013-01-10 22:54 ` Yinghai Lu
2013-01-10 23:40 ` Rafael J. Wysocki
2013-01-11 12:27 ` 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=20130102230732.GB31813@google.com \
--to=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=liuj97@gmail.com \
--cc=myron.stowe@redhat.com \
--cc=rjw@sisk.pl \
--cc=tony.luck@intel.com \
--cc=yinghai@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;
as well as URLs for NNTP newsgroup(s).