linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] export acpi_pci_root to find pci_bus correctly
@ 2009-07-23 23:02 Alex Chiang
  2009-07-23 23:03 ` [PATCH v3 1/2] ACPI: export acpi_pci_root and friends Alex Chiang
  2009-07-23 23:03 ` [PATCH v3 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly Alex Chiang
  0 siblings, 2 replies; 7+ messages in thread
From: Alex Chiang @ 2009-07-23 23:02 UTC (permalink / raw)
  To: jbarnes, lenb; +Cc: linux-pci, linux-kernel, linux-acpi

This is v3 of a patch series that:

	a) exports struct acpi_pci_root
	b) fixes an assumption in acpiphp about finding struct pci_bus

It's a minimal fix that's aimed at -rc5, as (b) fixes an assumption
introduced in -rc1.

I'll send the rest of the cleanups for linux-next later, after doing
some more testing.

Original thread here:
	http://thread.gmane.org/gmane.linux.kernel.pci/5080

v2 -> v3:
	- don't depend on acpi_is_root_bridge (Bjorn Helgaas)

v1 -> v2:
	- fixed build error in acpi_pci_root
	- reduced patch series in scope to be much smaller


---

Alex Chiang (2):
      ACPI: export acpi_pci_root and friends
      PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly


 drivers/acpi/pci_root.c            |   17 ++---------------
 drivers/pci/hotplug/acpiphp_glue.c |   28 +++++++++++++++++-----------
 include/acpi/acpi_bus.h            |   16 ++++++++++++++++
 3 files changed, 35 insertions(+), 26 deletions(-)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/2] ACPI: export acpi_pci_root and friends
  2009-07-23 23:02 [PATCH v3 0/2] export acpi_pci_root to find pci_bus correctly Alex Chiang
@ 2009-07-23 23:03 ` Alex Chiang
  2009-07-24 16:35   ` Bjorn Helgaas
  2009-07-23 23:03 ` [PATCH v3 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly Alex Chiang
  1 sibling, 1 reply; 7+ messages in thread
From: Alex Chiang @ 2009-07-23 23:03 UTC (permalink / raw)
  To: jbarnes, lenb; +Cc: linux-pci, Bjorn Helgaas, linux-kernel, linux-acpi

We can simplify ACPI drivers if we can tell whether a handle is an
ACPI PCI root or not.

Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/acpi/pci_root.c |   17 ++---------------
 include/acpi/acpi_bus.h |   16 ++++++++++++++++
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 55b5b90..31b961c 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -61,20 +61,6 @@ static struct acpi_driver acpi_pci_root_driver = {
 		},
 };
 
-struct acpi_pci_root {
-	struct list_head node;
-	struct acpi_device *device;
-	struct pci_bus *bus;
-	u16 segment;
-	u8 bus_nr;
-
-	u32 osc_support_set;	/* _OSC state of support bits */
-	u32 osc_control_set;	/* _OSC state of control bits */
-	u32 osc_control_qry;	/* the latest _OSC query result */
-
-	u32 osc_queried:1;	/* has _OSC control been queried? */
-};
-
 static LIST_HEAD(acpi_pci_roots);
 
 static struct acpi_pci_driver *sub_driver;
@@ -317,7 +303,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags)
 	return status;
 }
 
-static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
+struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
 {
 	struct acpi_pci_root *root;
 
@@ -327,6 +313,7 @@ static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
 	}
 	return NULL;
 }
+EXPORT_SYMBOL_GPL(acpi_pci_find_root);
 
 struct acpi_handle_node {
 	struct list_head node;
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index c65e4ce..c3ace75 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -369,10 +369,26 @@ int register_acpi_bus_type(struct acpi_bus_type *);
 int unregister_acpi_bus_type(struct acpi_bus_type *);
 struct device *acpi_get_physical_device(acpi_handle);
 
+struct acpi_pci_root {
+	struct list_head node;
+	struct acpi_device * device;
+	struct acpi_pci_id id;
+	struct pci_bus *bus;
+	u16 segment;
+	u8 bus_nr;
+
+	u32 osc_support_set;	/* _OSC state of support bits */
+	u32 osc_control_set;	/* _OSC state of control bits */
+	u32 osc_control_qry;	/* the latest _OSC query result */
+
+	u32 osc_queried:1;	/* has _OSC control been queried? */
+};
+
 /* helper */
 acpi_handle acpi_get_child(acpi_handle, acpi_integer);
 int acpi_is_root_bridge(acpi_handle);
 acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
+struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
 #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
 
 #ifdef CONFIG_PM_SLEEP

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly
  2009-07-23 23:02 [PATCH v3 0/2] export acpi_pci_root to find pci_bus correctly Alex Chiang
  2009-07-23 23:03 ` [PATCH v3 1/2] ACPI: export acpi_pci_root and friends Alex Chiang
@ 2009-07-23 23:03 ` Alex Chiang
  2009-07-24 16:35   ` Bjorn Helgaas
  2009-07-24 21:38   ` Jesse Barnes
  1 sibling, 2 replies; 7+ messages in thread
From: Alex Chiang @ 2009-07-23 23:03 UTC (permalink / raw)
  To: jbarnes, lenb; +Cc: linux-pci, linux-kernel, linux-acpi

We cannot simply call acpi_get_pci_dev() on any random ACPI handle
and hope that it works, because a PCI root bridge may not have
an associated struct pci_dev.

This is allowed per the PCI specification, and is referred to as a
non-materialized bridge.

So, depending on the type of PCI bridge that the handle points to,
use the appropriate interface to return the struct pci_bus correctly.

Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/acpiphp_glue.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 0cb0f83..2e5f259 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -62,6 +62,22 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus);
 static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus);
 static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context);
 
+static struct pci_bus *pci_bus_from_handle(acpi_handle handle)
+{
+	struct pci_bus *pbus;
+	struct acpi_pci_root *root;
+
+	root = acpi_pci_find_root(handle);
+	if (root)
+		pbus = root->bus;
+	else {
+		struct pci_dev *pdev = acpi_get_pci_dev(handle);
+		pbus = pdev->subordinate;
+		pci_dev_put(pdev);
+	}
+	return pbus;
+}
+
 /* callback routine to check for the existence of a pci dock device */
 static acpi_status
 is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv)
@@ -1387,16 +1403,7 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
 /* Program resources in newly inserted bridge */
 static int acpiphp_configure_bridge (acpi_handle handle)
 {
-	struct pci_dev *dev;
-	struct pci_bus *bus;
-
-	dev = acpi_get_pci_dev(handle);
-	if (!dev) {
-		err("cannot get PCI domain and bus number for bridge\n");
-		return -EINVAL;
-	}
-
-	bus = dev->bus;
+	struct pci_bus *bus = pci_bus_from_handle(handle);
 
 	pci_bus_size_bridges(bus);
 	pci_bus_assign_resources(bus);
@@ -1404,7 +1411,6 @@ static int acpiphp_configure_bridge (acpi_handle handle)
 	acpiphp_set_hpp_values(handle, bus);
 	pci_enable_bridges(bus);
 	acpiphp_configure_ioapics(handle);
-	pci_dev_put(dev);
 	return 0;
 }
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/2] ACPI: export acpi_pci_root and friends
  2009-07-23 23:03 ` [PATCH v3 1/2] ACPI: export acpi_pci_root and friends Alex Chiang
@ 2009-07-24 16:35   ` Bjorn Helgaas
  0 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2009-07-24 16:35 UTC (permalink / raw)
  To: Alex Chiang; +Cc: jbarnes, lenb, linux-pci, linux-kernel, linux-acpi

On Thursday 23 July 2009 05:03:00 pm Alex Chiang wrote:
> We can simplify ACPI drivers if we can tell whether a handle is an
> ACPI PCI root or not.
> 
> Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
> Signed-off-by: Alex Chiang <achiang@hp.com>

Reviewed-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

> ---
> 
>  drivers/acpi/pci_root.c |   17 ++---------------
>  include/acpi/acpi_bus.h |   16 ++++++++++++++++
>  2 files changed, 18 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 55b5b90..31b961c 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -61,20 +61,6 @@ static struct acpi_driver acpi_pci_root_driver = {
>  		},
>  };
>  
> -struct acpi_pci_root {
> -	struct list_head node;
> -	struct acpi_device *device;
> -	struct pci_bus *bus;
> -	u16 segment;
> -	u8 bus_nr;
> -
> -	u32 osc_support_set;	/* _OSC state of support bits */
> -	u32 osc_control_set;	/* _OSC state of control bits */
> -	u32 osc_control_qry;	/* the latest _OSC query result */
> -
> -	u32 osc_queried:1;	/* has _OSC control been queried? */
> -};
> -
>  static LIST_HEAD(acpi_pci_roots);
>  
>  static struct acpi_pci_driver *sub_driver;
> @@ -317,7 +303,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags)
>  	return status;
>  }
>  
> -static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
> +struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
>  {
>  	struct acpi_pci_root *root;
>  
> @@ -327,6 +313,7 @@ static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
>  	}
>  	return NULL;
>  }
> +EXPORT_SYMBOL_GPL(acpi_pci_find_root);
>  
>  struct acpi_handle_node {
>  	struct list_head node;
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index c65e4ce..c3ace75 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -369,10 +369,26 @@ int register_acpi_bus_type(struct acpi_bus_type *);
>  int unregister_acpi_bus_type(struct acpi_bus_type *);
>  struct device *acpi_get_physical_device(acpi_handle);
>  
> +struct acpi_pci_root {
> +	struct list_head node;
> +	struct acpi_device * device;
> +	struct acpi_pci_id id;
> +	struct pci_bus *bus;
> +	u16 segment;
> +	u8 bus_nr;
> +
> +	u32 osc_support_set;	/* _OSC state of support bits */
> +	u32 osc_control_set;	/* _OSC state of control bits */
> +	u32 osc_control_qry;	/* the latest _OSC query result */
> +
> +	u32 osc_queried:1;	/* has _OSC control been queried? */
> +};
> +
>  /* helper */
>  acpi_handle acpi_get_child(acpi_handle, acpi_integer);
>  int acpi_is_root_bridge(acpi_handle);
>  acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
> +struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
>  #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
>  
>  #ifdef CONFIG_PM_SLEEP
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly
  2009-07-23 23:03 ` [PATCH v3 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly Alex Chiang
@ 2009-07-24 16:35   ` Bjorn Helgaas
  2009-07-24 21:38   ` Jesse Barnes
  1 sibling, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2009-07-24 16:35 UTC (permalink / raw)
  To: Alex Chiang; +Cc: jbarnes, lenb, linux-pci, linux-kernel, linux-acpi

On Thursday 23 July 2009 05:03:05 pm Alex Chiang wrote:
> We cannot simply call acpi_get_pci_dev() on any random ACPI handle
> and hope that it works, because a PCI root bridge may not have
> an associated struct pci_dev.
> 
> This is allowed per the PCI specification, and is referred to as a
> non-materialized bridge.
> 
> So, depending on the type of PCI bridge that the handle points to,
> use the appropriate interface to return the struct pci_bus correctly.
> 
> Signed-off-by: Alex Chiang <achiang@hp.com>

Reviewed-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

> ---
> 
>  drivers/pci/hotplug/acpiphp_glue.c |   28 +++++++++++++++++-----------
>  1 files changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
> index 0cb0f83..2e5f259 100644
> --- a/drivers/pci/hotplug/acpiphp_glue.c
> +++ b/drivers/pci/hotplug/acpiphp_glue.c
> @@ -62,6 +62,22 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus);
>  static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus);
>  static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context);
>  
> +static struct pci_bus *pci_bus_from_handle(acpi_handle handle)
> +{
> +	struct pci_bus *pbus;
> +	struct acpi_pci_root *root;
> +
> +	root = acpi_pci_find_root(handle);
> +	if (root)
> +		pbus = root->bus;
> +	else {
> +		struct pci_dev *pdev = acpi_get_pci_dev(handle);
> +		pbus = pdev->subordinate;
> +		pci_dev_put(pdev);
> +	}
> +	return pbus;
> +}
> +
>  /* callback routine to check for the existence of a pci dock device */
>  static acpi_status
>  is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv)
> @@ -1387,16 +1403,7 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
>  /* Program resources in newly inserted bridge */
>  static int acpiphp_configure_bridge (acpi_handle handle)
>  {
> -	struct pci_dev *dev;
> -	struct pci_bus *bus;
> -
> -	dev = acpi_get_pci_dev(handle);
> -	if (!dev) {
> -		err("cannot get PCI domain and bus number for bridge\n");
> -		return -EINVAL;
> -	}
> -
> -	bus = dev->bus;
> +	struct pci_bus *bus = pci_bus_from_handle(handle);
>  
>  	pci_bus_size_bridges(bus);
>  	pci_bus_assign_resources(bus);
> @@ -1404,7 +1411,6 @@ static int acpiphp_configure_bridge (acpi_handle handle)
>  	acpiphp_set_hpp_values(handle, bus);
>  	pci_enable_bridges(bus);
>  	acpiphp_configure_ioapics(handle);
> -	pci_dev_put(dev);
>  	return 0;
>  }
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly
  2009-07-23 23:03 ` [PATCH v3 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly Alex Chiang
  2009-07-24 16:35   ` Bjorn Helgaas
@ 2009-07-24 21:38   ` Jesse Barnes
  2009-07-24 23:58     ` Alex Chiang
  1 sibling, 1 reply; 7+ messages in thread
From: Jesse Barnes @ 2009-07-24 21:38 UTC (permalink / raw)
  To: Alex Chiang; +Cc: lenb, linux-pci, linux-kernel, linux-acpi

On Thu, 23 Jul 2009 17:03:05 -0600
Alex Chiang <achiang@hp.com> wrote:

> We cannot simply call acpi_get_pci_dev() on any random ACPI handle
> and hope that it works, because a PCI root bridge may not have
> an associated struct pci_dev.
> 
> This is allowed per the PCI specification, and is referred to as a
> non-materialized bridge.
> 
> So, depending on the type of PCI bridge that the handle points to,
> use the appropriate interface to return the struct pci_bus correctly.
> 
> Signed-off-by: Alex Chiang <achiang@hp.com>
> ---

I put these in my linux-next branch, just because I'm really
conservative about the current release.

If we hear of boxes in the wild getting bitten by the non-materialized
bit, we can push this set back to stable.

-- 
Jesse Barnes, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly
  2009-07-24 21:38   ` Jesse Barnes
@ 2009-07-24 23:58     ` Alex Chiang
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Chiang @ 2009-07-24 23:58 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: lenb, linux-pci, linux-kernel, linux-acpi

* Jesse Barnes <jesse.barnes@intel.com>:
> On Thu, 23 Jul 2009 17:03:05 -0600
> Alex Chiang <achiang@hp.com> wrote:
> 
> > We cannot simply call acpi_get_pci_dev() on any random ACPI handle
> > and hope that it works, because a PCI root bridge may not have
> > an associated struct pci_dev.
> > 
> > This is allowed per the PCI specification, and is referred to as a
> > non-materialized bridge.
> > 
> > So, depending on the type of PCI bridge that the handle points to,
> > use the appropriate interface to return the struct pci_bus correctly.
> > 
> > Signed-off-by: Alex Chiang <achiang@hp.com>
> > ---
> 
> I put these in my linux-next branch, just because I'm really
> conservative about the current release.
> 
> If we hear of boxes in the wild getting bitten by the non-materialized
> bit, we can push this set back to stable.

Sounds good, thanks Jesse.

/ac


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-07-24 23:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-23 23:02 [PATCH v3 0/2] export acpi_pci_root to find pci_bus correctly Alex Chiang
2009-07-23 23:03 ` [PATCH v3 1/2] ACPI: export acpi_pci_root and friends Alex Chiang
2009-07-24 16:35   ` Bjorn Helgaas
2009-07-23 23:03 ` [PATCH v3 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly Alex Chiang
2009-07-24 16:35   ` Bjorn Helgaas
2009-07-24 21:38   ` Jesse Barnes
2009-07-24 23:58     ` Alex Chiang

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).