All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
@ 2014-08-21  4:04 Rafael J. Wysocki
  2014-08-21 12:08 ` Zhang Rui
  2014-08-24  7:06 ` Zhang Rui
  0 siblings, 2 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2014-08-21  4:04 UTC (permalink / raw)
  To: ACPI Devel Maling List
  Cc: Linux Kernel Mailing List, Zhang Rui, Gabriele Mazzotta,
	Dirk Griesbach, Matthew Garrett

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

We generally don't allow ACPI drivers to bind to ACPI device objects
that companion "physical" device objects are created for to avoid
situations in which two different drivers may attempt to handle one
device at the same time.  Recent ACPI device enumeration rework
extended that approach to ACPI PNP devices by starting to use a scan
handler for enumerating them.  However, we previously allowed ACPI
drivers to bind to ACPI device objects with existing PNP device
companions and changing that led to functional regressions on some
systems.

For this reason, add a special check for PNP devices in
acpi_device_probe() so that ACPI drivers can bind to ACPI device
objects having existing PNP device companions as before.

Fixes: eec15edbb0e1 (ACPI / PNP: use device ID list for PNPACPI device enumeration)
Link: https://bugzilla.kernel.org/show_bug.cgi?id=81511
Link: https://bugzilla.kernel.org/show_bug.cgi?id=81971
Reported-and-tested-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
Reported-and-tested-by: Dirk Griesbach <spamthis@freenet.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_pnp.c |    5 +++++
 drivers/acpi/internal.h |    1 +
 drivers/acpi/scan.c     |    2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/acpi/acpi_pnp.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_pnp.c
+++ linux-pm/drivers/acpi/acpi_pnp.c
@@ -396,3 +396,8 @@ void __init acpi_pnp_init(void)
 {
 	acpi_scan_add_handler(&acpi_pnp_handler);
 }
+
+bool is_acpi_pnp_device(struct acpi_device *adev)
+{
+	return adev->handler == &acpi_pnp_handler;
+}
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -86,6 +86,7 @@ void acpi_device_add_finalize(struct acp
 void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
 bool acpi_device_is_present(struct acpi_device *adev);
 bool acpi_device_is_battery(struct acpi_device *adev);
+bool is_acpi_pnp_device(struct acpi_device *adev);
 
 /* --------------------------------------------------------------------------
                                   Power Resource
Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -975,7 +975,7 @@ static int acpi_device_probe(struct devi
 	struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
 	int ret;
 
-	if (acpi_dev->handler)
+	if (acpi_dev->handler && !is_acpi_pnp_device(acpi_dev))
 		return -EINVAL;
 
 	if (!acpi_drv->ops.add)

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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-08-21  4:04 [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects Rafael J. Wysocki
@ 2014-08-21 12:08 ` Zhang Rui
  2014-08-21 16:36   ` Rafael J. Wysocki
  2014-08-21 17:10   ` Rafael J. Wysocki
  2014-08-24  7:06 ` Zhang Rui
  1 sibling, 2 replies; 11+ messages in thread
From: Zhang Rui @ 2014-08-21 12:08 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Gabriele Mazzotta, Dirk Griesbach, Matthew Garrett

Hi, Rafael,

On Thu, 2014-08-21 at 06:04 +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> We generally don't allow ACPI drivers to bind to ACPI device objects
> that companion "physical" device objects are created for to avoid
> situations in which two different drivers may attempt to handle one
> device at the same time.

Yes, and I think we should not break this rule.

>   Recent ACPI device enumeration rework
> extended that approach to ACPI PNP devices by starting to use a scan
> handler for enumerating them.  However, we previously allowed ACPI
> drivers to bind to ACPI device objects with existing PNP device
> companions and changing that led to functional regressions on some
> systems.
> 
Question: except the PNP0C01/PNP0C02 case, if we have an device have two
ids that matches two different drivers, should we allow both drivers
probe successfully?
I think the answer is no.
In the PNP0C01/PNP0C02 case, I think we can fix the issue by the
following patch instead.

Note that I've just tested on my machine and it works well.
I still need the bug reporter to check if the patch fixes bug 81511 or not.

>From c6c388728d08a6368f21dab61d6f0a940e0ea13a Mon Sep 17 00:00:00 2001
From: Zhang Rui <rui.zhang@intel.com>
Date: Thu, 21 Aug 2014 13:39:47 +0800
Subject: [RFC PATCH] ACPI: introduce motherboard resource management

ACPI Devices with _HID/_CID PNP0C01/PNP0C02 represents that
they have some motherboard resources that needs to be reserved.

We used to enumerated those devices to PNP bus and rely on
PNP system driver to do resource reservation.
But this mechanism does not work well nowadays as many devices
not only represent motherboard resources, but also represent
physical devices that need native drivers other than PNP system
driver for the device to work. For example,
1) https://bugzilla.kernel.org/show_bug.cgi?id=46741,
    Device (NIPM)
    {
        Name (_HID, EisaId ("IPI0001"))  // _HID: Hardware ID
        Name (_CID, EisaId ("PNP0C01"))  // _CID: Compatible ID
   the NIPM device has _CID PNP0C01 but it is an IPMI device.
   PNP system driver blocks the PNP IPMI driver to probe.
2) https://bugzilla.kernel.org/show_bug.cgi?id=81511
        Device (IFFS)
        {
            Name (_HID, EisaId ("INT3392"))  // _HID: Hardware ID
            Name (_CID, EisaId ("PNP0C02"))  // _CID: Compatible ID
   the IFFS device has _CID PNP0C02, but it is an intel rapid start
   device, which already has an ACPI driver at
   drivers/platform/x86/intel-rst.c
3) a couple of machines, including the on in
   https://bugzilla.kernel.org/show_bug.cgi?id=81511, has the AML code
   like following
        Device (PTID)
        {
            Name (_HID, EisaId ("INT340E"))  // _HID: Hardware ID
            Name (_CID, EisaId ("PNP0C02"))  // _CID: Compatible ID
   the PTID device has _CID PNP0C02, but it is also represents an
   INT340E device, there is a platform bus driver for this device
   which will be introduced by myself soon.

In any of the above cases, the current code for managing PNP0C01/PNP0C02
resources in Linux kernel is broken, because it either blocks the physical
device driver on the same bus, or results in multiple drivers loaded for
the same ACPI device node, which may also has some potential risks.

Thus, IMO, we need a clean way to handle those motherboard resources.
Given that PNP0C01/PNP0C02 is more like an indicator for reserving the
resources, this patch
1. does the resource reservation in ACPI code directly, with the same logic
   and time point in drivers/pnp/quirks.c and drivers/pnp/system.c.
2. makes PNP0C01/PNP0C02 PNP id transparent to Linux devices and drivers,
   thus PNP system driver becomes a no-op for ACPI enumerated devices.

This is just a draft patch, and I'd like to see if this is
the right direction to go. Any comments are welcome.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/acpi_pnp.c |   3 -
 drivers/acpi/scan.c     | 208 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 204 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
index 1f8b204..a7deae5 100644
--- a/drivers/acpi/acpi_pnp.c
+++ b/drivers/acpi/acpi_pnp.c
@@ -134,9 +134,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
 	{"FUJ02bf"},
 	{"FUJ02B1"},
 	{"FUJ02E3"},
-	/* system */
-	{"PNP0c02"},		/* General ID for reserving resources */
-	{"PNP0c01"},		/* memory controller */
 	/* rtc_cmos */
 	{"PNP0b00"},
 	{"PNP0b01"},
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 0a817ad..674518b 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -11,6 +11,7 @@
 #include <linux/kthread.h>
 #include <linux/dmi.h>
 #include <linux/nls.h>
+#include <linux/pci.h>
 
 #include <asm/pgtable.h>
 
@@ -1781,12 +1782,201 @@ static bool acpi_object_is_system_bus(acpi_handle handle)
 	return false;
 }
 
+static bool acpi_is_motherboard_resource(char *id)
+{
+	return !(strncmp(id, "PNP0C01", sizeof("PNP0C01")) &&
+		 strncmp(id, "PNP0C02", sizeof("PNP0C02")));
+}
+
+static LIST_HEAD(acpi_motherboard_resource_list);
+
+struct acpi_motherboard_resource {
+	acpi_handle handle;
+	struct list_head node;
+};
+
+static void acpi_record_motherboard_resource(acpi_handle handle)
+{
+	struct acpi_motherboard_resource *res;
+
+	res = kzalloc(sizeof(struct acpi_motherboard_resource), GFP_KERNEL);
+	if (!res)
+		return;
+	res->handle = handle;
+	list_add(&res->node, &acpi_motherboard_resource_list);
+}
+
+static void reserve_range(struct acpi_device *device, struct resource *r, int port)
+{
+	char *regionid;
+	resource_size_t start = r->start, end = r->end;
+	struct resource *res;
+	int result;
+
+	regionid = kmalloc(20, GFP_KERNEL);
+	if (!regionid)
+		return;
+
+	snprintf(regionid, 20, "ACPI %s", dev_name(&device->dev));
+		
+	if (port)
+		res = request_region(start, end - start + 1, regionid);
+	else
+		res = request_mem_region(start, end - start + 1, regionid);
+	if (res)
+		res->flags &= ~IORESOURCE_BUSY;
+	else
+		kfree(regionid);
+
+	dev_info(&device->dev, "%pR %s reserved\n", r,
+			res ? "has been" : "could not be");
+}
+
+static int is_pci_reserved(struct resource *res)
+{
+	struct pci_dev *pdev = NULL;
+	resource_size_t acpi_start, acpi_end, pci_start, pci_end;
+	int i;
+
+	/*
+	 * Some BIOSes have motherboard devices with resources that
+	 * partially overlap PCI BARs.
+	 * Those resources should not be reserved, or else, it will
+	 * prevent the normal PCI driver from requesting them later.
+	 */
+	for_each_pci_dev(pdev) {
+		for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+			unsigned long type;
+
+			type = pci_resource_flags(pdev, i) & res->flags
+			       & (IORESOURCE_IO | IORESOURCE_MEM);
+			if (!type || pci_resource_len(pdev, i) == 0)
+				continue;
+
+			pci_start = pci_resource_start(pdev, i);
+			pci_end = pci_resource_end(pdev, i);
+
+			if (res->start == 0 && res->end == 0)
+				continue;
+
+			acpi_start = res->start;
+			acpi_end = res->end;
+
+			/*
+			 * If the ACPI region doesn't overlap the PCI
+			 * region at all, there's no problem.
+			 */
+			if (acpi_end < pci_start || acpi_start > pci_end)
+				continue;
+
+			/*
+			 * If the PNP region completely encloses (or is
+			 * at least as large as) the PCI region, that's
+			 * also OK.  For example, this happens when the
+			 * PNP device describes a bridge with PCI
+			 * behind it.
+			 */
+			if (acpi_start <= pci_start && acpi_end >= pci_end)
+				continue;
+
+			/*
+			 * Otherwise, the ACPI region overlaps *part* of
+			 * the PCI region, and that might prevent a PCI
+			 * driver from requesting its resources.
+			 */
+			return true;
+		}
+	}
+	return false;
+}
+
+static acpi_status __init __acpi_reserve_motherboard_resource(struct acpi_resource *res,
+							void *data)
+{
+	struct resource r = {0};
+	acpi_handle handle = data;
+	struct acpi_device *device;
+	int result;
+
+	result = acpi_bus_get_device(handle, &device);
+	if (result)
+		return AE_OK;
+
+	if (!device->status.present)
+		return AE_OK;
+
+	switch (res->type) {
+	case ACPI_RESOURCE_TYPE_MEMORY24:
+	case ACPI_RESOURCE_TYPE_MEMORY32:
+	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
+		if (!acpi_dev_resource_memory(res, &r))
+			return AE_OK;
+		break;
+	case ACPI_RESOURCE_TYPE_IO:
+	case ACPI_RESOURCE_TYPE_FIXED_IO:
+		if (!acpi_dev_resource_io(res, &r))
+			return AE_OK;
+		break;
+	case ACPI_RESOURCE_TYPE_ADDRESS16:
+	case ACPI_RESOURCE_TYPE_ADDRESS32:
+	case ACPI_RESOURCE_TYPE_ADDRESS64:
+		if (!acpi_dev_resource_address_space(res, &r))
+			return AE_OK;
+		break;
+	case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
+		if (!acpi_dev_resource_ext_address_space(res, &r))
+			return AE_OK;
+		break;
+	default:
+		return AE_OK;
+	}
+
+	if (r.flags & IORESOURCE_DISABLED)
+		return AE_OK;
+
+	if (is_pci_reserved(&r))
+		return AE_OK;
+
+	if (r.flags & IORESOURCE_IO) {
+		if (r.start < 0x100)
+		/*
+		 * Below 0x100 is only standard PC hardware
+		 * (pics, kbd, timer, dma, ...)
+		 * We should not get resource conflicts there,
+		 * and the kernel reserves these anyway
+		 * (see arch/i386/kernel/setup.c).
+		 * So, do nothing
+		 */
+			return AE_OK;
+		if (r.end < r.start)
+			return AE_OK;       /* invalid */
+                reserve_range(device, &r, 1);
+        } else if (r.flags & IORESOURCE_MEM) {
+                reserve_range(device, &r, 0);
+        }
+
+	return AE_OK;
+}
+
+static int __init acpi_reserve_motherboard_resource(void)
+{
+	struct acpi_motherboard_resource *res;
+
+	list_for_each_entry(res, &acpi_motherboard_resource_list, node)
+		acpi_walk_resources(res->handle, METHOD_NAME__CRS,
+			__acpi_reserve_motherboard_resource, res->handle);
+
+	return 0;
+}
+fs_initcall(acpi_reserve_motherboard_resource);
+
 static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
 				int device_type)
 {
 	acpi_status status;
 	struct acpi_device_info *info;
 	struct acpi_pnp_device_id_list *cid_list;
+	int is_mb_resource = 0;
 	int i;
 
 	switch (device_type) {
@@ -1804,13 +1994,20 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
 		}
 
 		if (info->valid & ACPI_VALID_HID) {
-			acpi_add_id(pnp, info->hardware_id.string);
-			pnp->type.platform_id = 1;
+			if (!acpi_is_motherboard_resource(info->hardware_id.string)) {
+				acpi_add_id(pnp, info->hardware_id.string);
+				pnp->type.platform_id = 1;
+			} else
+				is_mb_resource = 1;
 		}
 		if (info->valid & ACPI_VALID_CID) {
 			cid_list = &info->compatible_id_list;
-			for (i = 0; i < cid_list->count; i++)
-				acpi_add_id(pnp, cid_list->ids[i].string);
+			for (i = 0; i < cid_list->count; i++) {
+				if (!acpi_is_motherboard_resource(cid_list->ids[i].string))
+					acpi_add_id(pnp, cid_list->ids[i].string);
+				else
+					is_mb_resource = 1;
+			}
 		}
 		if (info->valid & ACPI_VALID_ADR) {
 			pnp->bus_address = info->address;
@@ -1822,6 +2019,9 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
 
 		kfree(info);
 
+		if (is_mb_resource)
+			acpi_record_motherboard_resource(handle);
+
 		/*
 		 * Some devices don't reliably have _HIDs & _CIDs, so add
 		 * synthetic HIDs to make sure drivers can find them.
-- 
1.8.3.2




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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-08-21 12:08 ` Zhang Rui
@ 2014-08-21 16:36   ` Rafael J. Wysocki
  2014-08-21 17:10   ` Rafael J. Wysocki
  1 sibling, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2014-08-21 16:36 UTC (permalink / raw)
  To: Zhang Rui
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Gabriele Mazzotta, Dirk Griesbach, Matthew Garrett

On Thursday, August 21, 2014 08:08:54 PM Zhang Rui wrote:
> Hi, Rafael,
> 
> On Thu, 2014-08-21 at 06:04 +0200, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > 
> > We generally don't allow ACPI drivers to bind to ACPI device objects
> > that companion "physical" device objects are created for to avoid
> > situations in which two different drivers may attempt to handle one
> > device at the same time.
> 
> Yes, and I think we should not break this rule.

No, we broke the way the code worked previously.  We need to restore it first
and *then* try to fix it up, not the other way around.

> >   Recent ACPI device enumeration rework
> > extended that approach to ACPI PNP devices by starting to use a scan
> > handler for enumerating them.  However, we previously allowed ACPI
> > drivers to bind to ACPI device objects with existing PNP device
> > companions and changing that led to functional regressions on some
> > systems.
> > 
> Question: except the PNP0C01/PNP0C02 case, if we have an device have two
> ids that matches two different drivers, should we allow both drivers
> probe successfully?

No, we shouldn't, but in the cases in question we have only one driver (an
ACPI one).

> I think the answer is no.
> In the PNP0C01/PNP0C02 case, I think we can fix the issue by the
> following patch instead.

The right answer to me is to get rid of ACPI drviers entirely.

The thing below adds complexity to the resources management which I'm not
sure is necessary.

In any case, please let's do that on top of the $subject patch not
instead of it, because there are more cases we need to cover.  And we
need a fix for -stable.

Rafael


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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-08-21 12:08 ` Zhang Rui
  2014-08-21 16:36   ` Rafael J. Wysocki
@ 2014-08-21 17:10   ` Rafael J. Wysocki
  2014-08-22  2:00     ` Zhang Rui
  1 sibling, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2014-08-21 17:10 UTC (permalink / raw)
  To: Zhang Rui
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Gabriele Mazzotta, Dirk Griesbach, Matthew Garrett

On Thursday, August 21, 2014 08:08:54 PM Zhang Rui wrote:
> Hi, Rafael,
> 
> On Thu, 2014-08-21 at 06:04 +0200, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

[cut]

> Note that I've just tested on my machine and it works well.
> I still need the bug reporter to check if the patch fixes bug 81511 or not.

The FUJ02B1 and FUJ02E3 devices in bug 81971 have the same problem and
they aren't motherboard devices.  Yes, we need to convert that driver
to use a PNP driver structure or a platform device, but (1) we need a
-stable fix *first* and (2) the cases we already know about may not be
the only broken ones.

> From c6c388728d08a6368f21dab61d6f0a940e0ea13a Mon Sep 17 00:00:00 2001
> From: Zhang Rui <rui.zhang@intel.com>
> Date: Thu, 21 Aug 2014 13:39:47 +0800
> Subject: [RFC PATCH] ACPI: introduce motherboard resource management
> 
> ACPI Devices with _HID/_CID PNP0C01/PNP0C02 represents that
> they have some motherboard resources that needs to be reserved.
> 
> We used to enumerated those devices to PNP bus and rely on
> PNP system driver to do resource reservation.
> But this mechanism does not work well nowadays as many devices
> not only represent motherboard resources, but also represent
> physical devices that need native drivers other than PNP system
> driver for the device to work. For example,
> 1) https://bugzilla.kernel.org/show_bug.cgi?id=46741,
>     Device (NIPM)
>     {
>         Name (_HID, EisaId ("IPI0001"))  // _HID: Hardware ID
>         Name (_CID, EisaId ("PNP0C01"))  // _CID: Compatible ID
>    the NIPM device has _CID PNP0C01 but it is an IPMI device.
>    PNP system driver blocks the PNP IPMI driver to probe.

That is a good reason for PNP0C01 to be dropped from acpi_pnp_device_ids[].

> 2) https://bugzilla.kernel.org/show_bug.cgi?id=81511
>         Device (IFFS)
>         {
>             Name (_HID, EisaId ("INT3392"))  // _HID: Hardware ID
>             Name (_CID, EisaId ("PNP0C02"))  // _CID: Compatible ID
>    the IFFS device has _CID PNP0C02, but it is an intel rapid start
>    device, which already has an ACPI driver at
>    drivers/platform/x86/intel-rst.c

And which should be a platform driver really.

> 3) a couple of machines, including the on in
>    https://bugzilla.kernel.org/show_bug.cgi?id=81511, has the AML code
>    like following
>         Device (PTID)
>         {
>             Name (_HID, EisaId ("INT340E"))  // _HID: Hardware ID
>             Name (_CID, EisaId ("PNP0C02"))  // _CID: Compatible ID
>    the PTID device has _CID PNP0C02, but it is also represents an
>    INT340E device, there is a platform bus driver for this device
>    which will be introduced by myself soon.

Again, that's a good reason for dropping PNP0C02 from acpi_pnp_device_ids[].

> In any of the above cases, the current code for managing PNP0C01/PNP0C02
> resources in Linux kernel is broken, because it either blocks the physical
> device driver on the same bus, or results in multiple drivers loaded for
> the same ACPI device node, which may also has some potential risks.
> 
> Thus, IMO, we need a clean way to handle those motherboard resources.
> Given that PNP0C01/PNP0C02 is more like an indicator for reserving the
> resources, this patch
> 1. does the resource reservation in ACPI code directly, with the same logic
>    and time point in drivers/pnp/quirks.c and drivers/pnp/system.c.
> 2. makes PNP0C01/PNP0C02 PNP id transparent to Linux devices and drivers,
>    thus PNP system driver becomes a no-op for ACPI enumerated devices.
> 
> This is just a draft patch, and I'd like to see if this is
> the right direction to go. Any comments are welcome.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/acpi/acpi_pnp.c |   3 -
>  drivers/acpi/scan.c     | 208 +++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 204 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
> index 1f8b204..a7deae5 100644
> --- a/drivers/acpi/acpi_pnp.c
> +++ b/drivers/acpi/acpi_pnp.c
> @@ -134,9 +134,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
>  	{"FUJ02bf"},
>  	{"FUJ02B1"},
>  	{"FUJ02E3"},
> -	/* system */
> -	{"PNP0c02"},		/* General ID for reserving resources */
> -	{"PNP0c01"},		/* memory controller */
>  	/* rtc_cmos */
>  	{"PNP0b00"},
>  	{"PNP0b01"},
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index 0a817ad..674518b 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -11,6 +11,7 @@
>  #include <linux/kthread.h>
>  #include <linux/dmi.h>
>  #include <linux/nls.h>
> +#include <linux/pci.h>
>  
>  #include <asm/pgtable.h>
>  
> @@ -1781,12 +1782,201 @@ static bool acpi_object_is_system_bus(acpi_handle handle)
>  	return false;
>  }
>  
> +static bool acpi_is_motherboard_resource(char *id)
> +{
> +	return !(strncmp(id, "PNP0C01", sizeof("PNP0C01")) &&
> +		 strncmp(id, "PNP0C02", sizeof("PNP0C02")));
> +}

Can we use __acpi_match_device() for that?

> +
> +static LIST_HEAD(acpi_motherboard_resource_list);
> +
> +struct acpi_motherboard_resource {
> +	acpi_handle handle;
> +	struct list_head node;
> +};
> +
> +static void acpi_record_motherboard_resource(acpi_handle handle)
> +{
> +	struct acpi_motherboard_resource *res;
> +
> +	res = kzalloc(sizeof(struct acpi_motherboard_resource), GFP_KERNEL);
> +	if (!res)
> +		return;
> +	res->handle = handle;
> +	list_add(&res->node, &acpi_motherboard_resource_list);
> +}
> +
> +static void reserve_range(struct acpi_device *device, struct resource *r, int port)
> +{
> +	char *regionid;
> +	resource_size_t start = r->start, end = r->end;
> +	struct resource *res;
> +	int result;
> +
> +	regionid = kmalloc(20, GFP_KERNEL);
> +	if (!regionid)
> +		return;
> +
> +	snprintf(regionid, 20, "ACPI %s", dev_name(&device->dev));
> +		
> +	if (port)
> +		res = request_region(start, end - start + 1, regionid);
> +	else
> +		res = request_mem_region(start, end - start + 1, regionid);
> +	if (res)
> +		res->flags &= ~IORESOURCE_BUSY;
> +	else
> +		kfree(regionid);
> +
> +	dev_info(&device->dev, "%pR %s reserved\n", r,
> +			res ? "has been" : "could not be");
> +}
> +

The routine below should go into the PCI core.

> +static int is_pci_reserved(struct resource *res)
> +{
> +	struct pci_dev *pdev = NULL;
> +	resource_size_t acpi_start, acpi_end, pci_start, pci_end;
> +	int i;
> +
> +	/*
> +	 * Some BIOSes have motherboard devices with resources that
> +	 * partially overlap PCI BARs.
> +	 * Those resources should not be reserved, or else, it will
> +	 * prevent the normal PCI driver from requesting them later.
> +	 */
> +	for_each_pci_dev(pdev) {
> +		for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
> +			unsigned long type;
> +
> +			type = pci_resource_flags(pdev, i) & res->flags
> +			       & (IORESOURCE_IO | IORESOURCE_MEM);
> +			if (!type || pci_resource_len(pdev, i) == 0)
> +				continue;
> +
> +			pci_start = pci_resource_start(pdev, i);
> +			pci_end = pci_resource_end(pdev, i);
> +
> +			if (res->start == 0 && res->end == 0)
> +				continue;
> +
> +			acpi_start = res->start;
> +			acpi_end = res->end;
> +
> +			/*
> +			 * If the ACPI region doesn't overlap the PCI
> +			 * region at all, there's no problem.
> +			 */
> +			if (acpi_end < pci_start || acpi_start > pci_end)
> +				continue;
> +
> +			/*
> +			 * If the PNP region completely encloses (or is
> +			 * at least as large as) the PCI region, that's
> +			 * also OK.  For example, this happens when the
> +			 * PNP device describes a bridge with PCI
> +			 * behind it.
> +			 */
> +			if (acpi_start <= pci_start && acpi_end >= pci_end)
> +				continue;
> +
> +			/*
> +			 * Otherwise, the ACPI region overlaps *part* of
> +			 * the PCI region, and that might prevent a PCI
> +			 * driver from requesting its resources.
> +			 */
> +			return true;
> +		}
> +	}
> +	return false;
> +}
> +

The routine below should go into resource.c.

> +static acpi_status __init __acpi_reserve_motherboard_resource(struct acpi_resource *res,
> +							void *data)
> +{
> +	struct resource r = {0};
> +	acpi_handle handle = data;
> +	struct acpi_device *device;
> +	int result;
> +
> +	result = acpi_bus_get_device(handle, &device);
> +	if (result)
> +		return AE_OK;
> +
> +	if (!device->status.present)
> +		return AE_OK;
> +
> +	switch (res->type) {
> +	case ACPI_RESOURCE_TYPE_MEMORY24:
> +	case ACPI_RESOURCE_TYPE_MEMORY32:
> +	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
> +		if (!acpi_dev_resource_memory(res, &r))
> +			return AE_OK;
> +		break;
> +	case ACPI_RESOURCE_TYPE_IO:
> +	case ACPI_RESOURCE_TYPE_FIXED_IO:
> +		if (!acpi_dev_resource_io(res, &r))
> +			return AE_OK;
> +		break;
> +	case ACPI_RESOURCE_TYPE_ADDRESS16:
> +	case ACPI_RESOURCE_TYPE_ADDRESS32:
> +	case ACPI_RESOURCE_TYPE_ADDRESS64:
> +		if (!acpi_dev_resource_address_space(res, &r))
> +			return AE_OK;
> +		break;
> +	case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
> +		if (!acpi_dev_resource_ext_address_space(res, &r))
> +			return AE_OK;
> +		break;
> +	default:
> +		return AE_OK;
> +	}
> +
> +	if (r.flags & IORESOURCE_DISABLED)
> +		return AE_OK;
> +
> +	if (is_pci_reserved(&r))
> +		return AE_OK;
> +
> +	if (r.flags & IORESOURCE_IO) {
> +		if (r.start < 0x100)
> +		/*
> +		 * Below 0x100 is only standard PC hardware
> +		 * (pics, kbd, timer, dma, ...)
> +		 * We should not get resource conflicts there,
> +		 * and the kernel reserves these anyway
> +		 * (see arch/i386/kernel/setup.c).
> +		 * So, do nothing
> +		 */
> +			return AE_OK;
> +		if (r.end < r.start)
> +			return AE_OK;       /* invalid */
> +                reserve_range(device, &r, 1);
> +        } else if (r.flags & IORESOURCE_MEM) {
> +                reserve_range(device, &r, 0);
> +        }
> +
> +	return AE_OK;
> +}
> +
> +static int __init acpi_reserve_motherboard_resource(void)
> +{
> +	struct acpi_motherboard_resource *res;
> +
> +	list_for_each_entry(res, &acpi_motherboard_resource_list, node)
> +		acpi_walk_resources(res->handle, METHOD_NAME__CRS,
> +			__acpi_reserve_motherboard_resource, res->handle);
> +
> +	return 0;
> +}
> +fs_initcall(acpi_reserve_motherboard_resource);

Why don't we call that directly from acpi_scan_init() and do we need the
acpi_motherboard_resource_list list to be present any more after calling
this function?

> +
>  static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
>  				int device_type)
>  {
>  	acpi_status status;
>  	struct acpi_device_info *info;
>  	struct acpi_pnp_device_id_list *cid_list;
> +	int is_mb_resource = 0;
>  	int i;
>  
>  	switch (device_type) {
> @@ -1804,13 +1994,20 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
>  		}
>  
>  		if (info->valid & ACPI_VALID_HID) {
> -			acpi_add_id(pnp, info->hardware_id.string);
> -			pnp->type.platform_id = 1;
> +			if (!acpi_is_motherboard_resource(info->hardware_id.string)) {

I would reverse the check.  That is, do

			if (!acpi_is_motherboard_resource(info->hardware_id.string)) {
				is_mb_resource = 1;
			} else { ...

Also, don't we really want to create platform devices for the ACPI device objects
in question?

> +				acpi_add_id(pnp, info->hardware_id.string);
> +				pnp->type.platform_id = 1;
> +			} else
> +				is_mb_resource = 1;
>  		}
>  		if (info->valid & ACPI_VALID_CID) {
>  			cid_list = &info->compatible_id_list;
> -			for (i = 0; i < cid_list->count; i++)
> -				acpi_add_id(pnp, cid_list->ids[i].string);
> +			for (i = 0; i < cid_list->count; i++) {
> +				if (!acpi_is_motherboard_resource(cid_list->ids[i].string))
> +					acpi_add_id(pnp, cid_list->ids[i].string);
> +				else
> +					is_mb_resource = 1;
> +			}
>  		}
>  		if (info->valid & ACPI_VALID_ADR) {
>  			pnp->bus_address = info->address;
> @@ -1822,6 +2019,9 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
>  
>  		kfree(info);
>  
> +		if (is_mb_resource)
> +			acpi_record_motherboard_resource(handle);
> +
>  		/*
>  		 * Some devices don't reliably have _HIDs & _CIDs, so add
>  		 * synthetic HIDs to make sure drivers can find them.
> 

Overall, it looks reasonable, but it can't be a replacement for the $subject
patch.

I also should mention that I don't want the special case for PNP devices to
stay there forever, but in my opinion we do need it at the moment for a couple
of reasons.

Rafael


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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-08-21 17:10   ` Rafael J. Wysocki
@ 2014-08-22  2:00     ` Zhang Rui
  2014-08-22 17:53       ` Rafael J. Wysocki
  0 siblings, 1 reply; 11+ messages in thread
From: Zhang Rui @ 2014-08-22  2:00 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Gabriele Mazzotta, Dirk Griesbach, Matthew Garrett

On Thu, 2014-08-21 at 19:10 +0200, Rafael J. Wysocki wrote:
> On Thursday, August 21, 2014 08:08:54 PM Zhang Rui wrote:
> > Hi, Rafael,
> > 
> > On Thu, 2014-08-21 at 06:04 +0200, Rafael J. Wysocki wrote:
> > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> [cut]
> 
> > Note that I've just tested on my machine and it works well.
> > I still need the bug reporter to check if the patch fixes bug 81511 or not.
> 
> The FUJ02B1 and FUJ02E3 devices in bug 81971 have the same problem and
> they aren't motherboard devices.

Right, but IMO, the rootcause of that bug is that
1. the PNP id table in fujitsu-laptop driver was introduced for some
reason, probably it is used as an indicator for module auto-loading, and
nowadays, this is redundant because fujitsu-laptop driver probes ACPI
device only, and the driver will be loaded if the ACPI device objects
for FUJ02B1 and FUJ02E3 is created.
2. This "redundant" PNP id table results in that those IDs are added to
PNP ID list unnecessarily, and results in PNP device nodes for those
devices are created unnecessarily.

>   Yes, we need to convert that driver
> to use a PNP driver structure or a platform device, but (1) we need a
> -stable fix *first*

I agree.

>  and (2) the cases we already know about may not be
> the only broken ones.

Agree.
But the issue addressed in your patch is that PNP scan handler blocks
ACPI driver from being probed, right?
So my question would be,
1. If the id in PNP scan handler does not have a PNP driver, like the
   FUJ02B1/FUJ02E3 issue, what do we need the id in PNP scan handler?
   In fact, I think this is a good chance for us to cleanup the ACPI PNP
   id list, as long as we can fix them in time.
2. If the id in PNP scan handler has a PNP driver, should we allow both
   PNP driver and ACPI driver loaded? I think PNP system driver is the
   only case that makes us have to say yes, and what I'm trying to do
   is to fix this in the following patch.

Plus, IMO, your patch only fixes the PNP bus vs. ACPI bus issue. We
still may get bug report complaining some *PLATFORM* driver stops to
functional if the ACPI node has _CID PNP0C01/PNP0C02, sooner or later.
right?

thanks,
rui

> 
> > From c6c388728d08a6368f21dab61d6f0a940e0ea13a Mon Sep 17 00:00:00 2001
> > From: Zhang Rui <rui.zhang@intel.com>
> > Date: Thu, 21 Aug 2014 13:39:47 +0800
> > Subject: [RFC PATCH] ACPI: introduce motherboard resource management
> > 
> > ACPI Devices with _HID/_CID PNP0C01/PNP0C02 represents that
> > they have some motherboard resources that needs to be reserved.
> > 
> > We used to enumerated those devices to PNP bus and rely on
> > PNP system driver to do resource reservation.
> > But this mechanism does not work well nowadays as many devices
> > not only represent motherboard resources, but also represent
> > physical devices that need native drivers other than PNP system
> > driver for the device to work. For example,
> > 1) https://bugzilla.kernel.org/show_bug.cgi?id=46741,
> >     Device (NIPM)
> >     {
> >         Name (_HID, EisaId ("IPI0001"))  // _HID: Hardware ID
> >         Name (_CID, EisaId ("PNP0C01"))  // _CID: Compatible ID
> >    the NIPM device has _CID PNP0C01 but it is an IPMI device.
> >    PNP system driver blocks the PNP IPMI driver to probe.
> 
> That is a good reason for PNP0C01 to be dropped from acpi_pnp_device_ids[].
> 
> > 2) https://bugzilla.kernel.org/show_bug.cgi?id=81511
> >         Device (IFFS)
> >         {
> >             Name (_HID, EisaId ("INT3392"))  // _HID: Hardware ID
> >             Name (_CID, EisaId ("PNP0C02"))  // _CID: Compatible ID
> >    the IFFS device has _CID PNP0C02, but it is an intel rapid start
> >    device, which already has an ACPI driver at
> >    drivers/platform/x86/intel-rst.c
> 
> And which should be a platform driver really.
> 
> > 3) a couple of machines, including the on in
> >    https://bugzilla.kernel.org/show_bug.cgi?id=81511, has the AML code
> >    like following
> >         Device (PTID)
> >         {
> >             Name (_HID, EisaId ("INT340E"))  // _HID: Hardware ID
> >             Name (_CID, EisaId ("PNP0C02"))  // _CID: Compatible ID
> >    the PTID device has _CID PNP0C02, but it is also represents an
> >    INT340E device, there is a platform bus driver for this device
> >    which will be introduced by myself soon.
> 
> Again, that's a good reason for dropping PNP0C02 from acpi_pnp_device_ids[].
> 
> > In any of the above cases, the current code for managing PNP0C01/PNP0C02
> > resources in Linux kernel is broken, because it either blocks the physical
> > device driver on the same bus, or results in multiple drivers loaded for
> > the same ACPI device node, which may also has some potential risks.
> > 
> > Thus, IMO, we need a clean way to handle those motherboard resources.
> > Given that PNP0C01/PNP0C02 is more like an indicator for reserving the
> > resources, this patch
> > 1. does the resource reservation in ACPI code directly, with the same logic
> >    and time point in drivers/pnp/quirks.c and drivers/pnp/system.c.
> > 2. makes PNP0C01/PNP0C02 PNP id transparent to Linux devices and drivers,
> >    thus PNP system driver becomes a no-op for ACPI enumerated devices.
> > 
> > This is just a draft patch, and I'd like to see if this is
> > the right direction to go. Any comments are welcome.
> > 
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > ---
> >  drivers/acpi/acpi_pnp.c |   3 -
> >  drivers/acpi/scan.c     | 208 +++++++++++++++++++++++++++++++++++++++++++++++-
> >  2 files changed, 204 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
> > index 1f8b204..a7deae5 100644
> > --- a/drivers/acpi/acpi_pnp.c
> > +++ b/drivers/acpi/acpi_pnp.c
> > @@ -134,9 +134,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
> >  	{"FUJ02bf"},
> >  	{"FUJ02B1"},
> >  	{"FUJ02E3"},
> > -	/* system */
> > -	{"PNP0c02"},		/* General ID for reserving resources */
> > -	{"PNP0c01"},		/* memory controller */
> >  	/* rtc_cmos */
> >  	{"PNP0b00"},
> >  	{"PNP0b01"},
> > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> > index 0a817ad..674518b 100644
> > --- a/drivers/acpi/scan.c
> > +++ b/drivers/acpi/scan.c
> > @@ -11,6 +11,7 @@
> >  #include <linux/kthread.h>
> >  #include <linux/dmi.h>
> >  #include <linux/nls.h>
> > +#include <linux/pci.h>
> >  
> >  #include <asm/pgtable.h>
> >  
> > @@ -1781,12 +1782,201 @@ static bool acpi_object_is_system_bus(acpi_handle handle)
> >  	return false;
> >  }
> >  
> > +static bool acpi_is_motherboard_resource(char *id)
> > +{
> > +	return !(strncmp(id, "PNP0C01", sizeof("PNP0C01")) &&
> > +		 strncmp(id, "PNP0C02", sizeof("PNP0C02")));
> > +}
> 
> Can we use __acpi_match_device() for that?
> 
> > +
> > +static LIST_HEAD(acpi_motherboard_resource_list);
> > +
> > +struct acpi_motherboard_resource {
> > +	acpi_handle handle;
> > +	struct list_head node;
> > +};
> > +
> > +static void acpi_record_motherboard_resource(acpi_handle handle)
> > +{
> > +	struct acpi_motherboard_resource *res;
> > +
> > +	res = kzalloc(sizeof(struct acpi_motherboard_resource), GFP_KERNEL);
> > +	if (!res)
> > +		return;
> > +	res->handle = handle;
> > +	list_add(&res->node, &acpi_motherboard_resource_list);
> > +}
> > +
> > +static void reserve_range(struct acpi_device *device, struct resource *r, int port)
> > +{
> > +	char *regionid;
> > +	resource_size_t start = r->start, end = r->end;
> > +	struct resource *res;
> > +	int result;
> > +
> > +	regionid = kmalloc(20, GFP_KERNEL);
> > +	if (!regionid)
> > +		return;
> > +
> > +	snprintf(regionid, 20, "ACPI %s", dev_name(&device->dev));
> > +		
> > +	if (port)
> > +		res = request_region(start, end - start + 1, regionid);
> > +	else
> > +		res = request_mem_region(start, end - start + 1, regionid);
> > +	if (res)
> > +		res->flags &= ~IORESOURCE_BUSY;
> > +	else
> > +		kfree(regionid);
> > +
> > +	dev_info(&device->dev, "%pR %s reserved\n", r,
> > +			res ? "has been" : "could not be");
> > +}
> > +
> 
> The routine below should go into the PCI core.
> 
> > +static int is_pci_reserved(struct resource *res)
> > +{
> > +	struct pci_dev *pdev = NULL;
> > +	resource_size_t acpi_start, acpi_end, pci_start, pci_end;
> > +	int i;
> > +
> > +	/*
> > +	 * Some BIOSes have motherboard devices with resources that
> > +	 * partially overlap PCI BARs.
> > +	 * Those resources should not be reserved, or else, it will
> > +	 * prevent the normal PCI driver from requesting them later.
> > +	 */
> > +	for_each_pci_dev(pdev) {
> > +		for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
> > +			unsigned long type;
> > +
> > +			type = pci_resource_flags(pdev, i) & res->flags
> > +			       & (IORESOURCE_IO | IORESOURCE_MEM);
> > +			if (!type || pci_resource_len(pdev, i) == 0)
> > +				continue;
> > +
> > +			pci_start = pci_resource_start(pdev, i);
> > +			pci_end = pci_resource_end(pdev, i);
> > +
> > +			if (res->start == 0 && res->end == 0)
> > +				continue;
> > +
> > +			acpi_start = res->start;
> > +			acpi_end = res->end;
> > +
> > +			/*
> > +			 * If the ACPI region doesn't overlap the PCI
> > +			 * region at all, there's no problem.
> > +			 */
> > +			if (acpi_end < pci_start || acpi_start > pci_end)
> > +				continue;
> > +
> > +			/*
> > +			 * If the PNP region completely encloses (or is
> > +			 * at least as large as) the PCI region, that's
> > +			 * also OK.  For example, this happens when the
> > +			 * PNP device describes a bridge with PCI
> > +			 * behind it.
> > +			 */
> > +			if (acpi_start <= pci_start && acpi_end >= pci_end)
> > +				continue;
> > +
> > +			/*
> > +			 * Otherwise, the ACPI region overlaps *part* of
> > +			 * the PCI region, and that might prevent a PCI
> > +			 * driver from requesting its resources.
> > +			 */
> > +			return true;
> > +		}
> > +	}
> > +	return false;
> > +}
> > +
> 
> The routine below should go into resource.c.
> 
> > +static acpi_status __init __acpi_reserve_motherboard_resource(struct acpi_resource *res,
> > +							void *data)
> > +{
> > +	struct resource r = {0};
> > +	acpi_handle handle = data;
> > +	struct acpi_device *device;
> > +	int result;
> > +
> > +	result = acpi_bus_get_device(handle, &device);
> > +	if (result)
> > +		return AE_OK;
> > +
> > +	if (!device->status.present)
> > +		return AE_OK;
> > +
> > +	switch (res->type) {
> > +	case ACPI_RESOURCE_TYPE_MEMORY24:
> > +	case ACPI_RESOURCE_TYPE_MEMORY32:
> > +	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
> > +		if (!acpi_dev_resource_memory(res, &r))
> > +			return AE_OK;
> > +		break;
> > +	case ACPI_RESOURCE_TYPE_IO:
> > +	case ACPI_RESOURCE_TYPE_FIXED_IO:
> > +		if (!acpi_dev_resource_io(res, &r))
> > +			return AE_OK;
> > +		break;
> > +	case ACPI_RESOURCE_TYPE_ADDRESS16:
> > +	case ACPI_RESOURCE_TYPE_ADDRESS32:
> > +	case ACPI_RESOURCE_TYPE_ADDRESS64:
> > +		if (!acpi_dev_resource_address_space(res, &r))
> > +			return AE_OK;
> > +		break;
> > +	case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
> > +		if (!acpi_dev_resource_ext_address_space(res, &r))
> > +			return AE_OK;
> > +		break;
> > +	default:
> > +		return AE_OK;
> > +	}
> > +
> > +	if (r.flags & IORESOURCE_DISABLED)
> > +		return AE_OK;
> > +
> > +	if (is_pci_reserved(&r))
> > +		return AE_OK;
> > +
> > +	if (r.flags & IORESOURCE_IO) {
> > +		if (r.start < 0x100)
> > +		/*
> > +		 * Below 0x100 is only standard PC hardware
> > +		 * (pics, kbd, timer, dma, ...)
> > +		 * We should not get resource conflicts there,
> > +		 * and the kernel reserves these anyway
> > +		 * (see arch/i386/kernel/setup.c).
> > +		 * So, do nothing
> > +		 */
> > +			return AE_OK;
> > +		if (r.end < r.start)
> > +			return AE_OK;       /* invalid */
> > +                reserve_range(device, &r, 1);
> > +        } else if (r.flags & IORESOURCE_MEM) {
> > +                reserve_range(device, &r, 0);
> > +        }
> > +
> > +	return AE_OK;
> > +}
> > +
> > +static int __init acpi_reserve_motherboard_resource(void)
> > +{
> > +	struct acpi_motherboard_resource *res;
> > +
> > +	list_for_each_entry(res, &acpi_motherboard_resource_list, node)
> > +		acpi_walk_resources(res->handle, METHOD_NAME__CRS,
> > +			__acpi_reserve_motherboard_resource, res->handle);
> > +
> > +	return 0;
> > +}
> > +fs_initcall(acpi_reserve_motherboard_resource);
> 
> Why don't we call that directly from acpi_scan_init() and do we need the
> acpi_motherboard_resource_list list to be present any more after calling
> this function?
> 
> > +
> >  static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
> >  				int device_type)
> >  {
> >  	acpi_status status;
> >  	struct acpi_device_info *info;
> >  	struct acpi_pnp_device_id_list *cid_list;
> > +	int is_mb_resource = 0;
> >  	int i;
> >  
> >  	switch (device_type) {
> > @@ -1804,13 +1994,20 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
> >  		}
> >  
> >  		if (info->valid & ACPI_VALID_HID) {
> > -			acpi_add_id(pnp, info->hardware_id.string);
> > -			pnp->type.platform_id = 1;
> > +			if (!acpi_is_motherboard_resource(info->hardware_id.string)) {
> 
> I would reverse the check.  That is, do
> 
> 			if (!acpi_is_motherboard_resource(info->hardware_id.string)) {
> 				is_mb_resource = 1;
> 			} else { ...
> 
> Also, don't we really want to create platform devices for the ACPI device objects
> in question?
> 
> > +				acpi_add_id(pnp, info->hardware_id.string);
> > +				pnp->type.platform_id = 1;
> > +			} else
> > +				is_mb_resource = 1;
> >  		}
> >  		if (info->valid & ACPI_VALID_CID) {
> >  			cid_list = &info->compatible_id_list;
> > -			for (i = 0; i < cid_list->count; i++)
> > -				acpi_add_id(pnp, cid_list->ids[i].string);
> > +			for (i = 0; i < cid_list->count; i++) {
> > +				if (!acpi_is_motherboard_resource(cid_list->ids[i].string))
> > +					acpi_add_id(pnp, cid_list->ids[i].string);
> > +				else
> > +					is_mb_resource = 1;
> > +			}
> >  		}
> >  		if (info->valid & ACPI_VALID_ADR) {
> >  			pnp->bus_address = info->address;
> > @@ -1822,6 +2019,9 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
> >  
> >  		kfree(info);
> >  
> > +		if (is_mb_resource)
> > +			acpi_record_motherboard_resource(handle);
> > +
> >  		/*
> >  		 * Some devices don't reliably have _HIDs & _CIDs, so add
> >  		 * synthetic HIDs to make sure drivers can find them.
> > 
> 
> Overall, it looks reasonable, but it can't be a replacement for the $subject
> patch.
> 
> I also should mention that I don't want the special case for PNP devices to
> stay there forever, but in my opinion we do need it at the moment for a couple
> of reasons.
> 
> Rafael
> 



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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-08-22  2:00     ` Zhang Rui
@ 2014-08-22 17:53       ` Rafael J. Wysocki
  2014-08-23 15:21         ` Zhang Rui
  0 siblings, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2014-08-22 17:53 UTC (permalink / raw)
  To: Zhang Rui
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Gabriele Mazzotta, Dirk Griesbach, Matthew Garrett

On Friday, August 22, 2014 10:00:31 AM Zhang Rui wrote:
> On Thu, 2014-08-21 at 19:10 +0200, Rafael J. Wysocki wrote:
> > On Thursday, August 21, 2014 08:08:54 PM Zhang Rui wrote:
> > > Hi, Rafael,
> > > 
> > > On Thu, 2014-08-21 at 06:04 +0200, Rafael J. Wysocki wrote:
> > > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > 
> > [cut]
> > 
> > > Note that I've just tested on my machine and it works well.
> > > I still need the bug reporter to check if the patch fixes bug 81511 or not.
> > 
> > The FUJ02B1 and FUJ02E3 devices in bug 81971 have the same problem and
> > they aren't motherboard devices.
> 
> Right, but IMO, the rootcause of that bug is that
> 1. the PNP id table in fujitsu-laptop driver was introduced for some
> reason, probably it is used as an indicator for module auto-loading, and
> nowadays, this is redundant because fujitsu-laptop driver probes ACPI
> device only, and the driver will be loaded if the ACPI device objects
> for FUJ02B1 and FUJ02E3 is created.

We may be able to drop the Fujitsu devices from the ACPI PNP list and all may
work.  Still, does that fix all of the potential problems?

> 2. This "redundant" PNP id table results in that those IDs are added to
> PNP ID list unnecessarily, and results in PNP device nodes for those
> devices are created unnecessarily.

Yes, that may be the case, but the way to deal with that is not to break
thing and then see what's broken and fix it, but to get rid of ACPI drivers
one by one in which case we can control what's been changed and why.

> >   Yes, we need to convert that driver
> > to use a PNP driver structure or a platform device, but (1) we need a
> > -stable fix *first*
> 
> I agree.
> 
> >  and (2) the cases we already know about may not be
> > the only broken ones.
> 
> Agree.
> But the issue addressed in your patch is that PNP scan handler blocks
> ACPI driver from being probed, right?

Yes.

> So my question would be,
> 1. If the id in PNP scan handler does not have a PNP driver, like the
>    FUJ02B1/FUJ02E3 issue, what do we need the id in PNP scan handler?
>    In fact, I think this is a good chance for us to cleanup the ACPI PNP
>    id list, as long as we can fix them in time.

No.

We need -stable to work and there's no way I will mark the motherboard
resource changes for -stable.  Second, if we deal with it as I said (that is,
get rid of ACPI drivers gradually), we will clean up that list in the process
without breaking things for people in random ways.

> 2. If the id in PNP scan handler has a PNP driver, should we allow both
>    PNP driver and ACPI driver loaded? I think PNP system driver is the
>    only case that makes us have to say yes, and what I'm trying to do
>    is to fix this in the following patch.
> 
> Plus, IMO, your patch only fixes the PNP bus vs. ACPI bus issue. We
> still may get bug report complaining some *PLATFORM* driver stops to
> functional if the ACPI node has _CID PNP0C01/PNP0C02, sooner or later.
> right?

No.

We never allowed ACPI drivers to bind to ACPI device objects having platform
device companions, wherease we *did* allow that for ACPI device objects having
PNP device companions.  We simply need to go back to what we were doing and fix
things *on* *top* of that.

Any other approach pretty much guarantees leaving breakage in random places.

So I'm fine with cleaning up the PNP list *if* you convert the drivers in
question from ACPI drivers to something else (platform drivers preferably)
at the same time.

Rafael


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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-08-22 17:53       ` Rafael J. Wysocki
@ 2014-08-23 15:21         ` Zhang Rui
  2014-09-08 22:14           ` Rafael J. Wysocki
  0 siblings, 1 reply; 11+ messages in thread
From: Zhang Rui @ 2014-08-23 15:21 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Gabriele Mazzotta, Dirk Griesbach, Matthew Garrett

On Fri, 2014-08-22 at 19:53 +0200, Rafael J. Wysocki wrote:
> On Friday, August 22, 2014 10:00:31 AM Zhang Rui wrote:
> > On Thu, 2014-08-21 at 19:10 +0200, Rafael J. Wysocki wrote:
> > > On Thursday, August 21, 2014 08:08:54 PM Zhang Rui wrote:
> > > > Hi, Rafael,
> > > > 
> > > > On Thu, 2014-08-21 at 06:04 +0200, Rafael J. Wysocki wrote:
> > > > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > 
> > > [cut]
> > > 
> > > > Note that I've just tested on my machine and it works well.
> > > > I still need the bug reporter to check if the patch fixes bug 81511 or not.
> > > 
> > > The FUJ02B1 and FUJ02E3 devices in bug 81971 have the same problem and
> > > they aren't motherboard devices.
> > 
> > Right, but IMO, the rootcause of that bug is that
> > 1. the PNP id table in fujitsu-laptop driver was introduced for some
> > reason, probably it is used as an indicator for module auto-loading, and
> > nowadays, this is redundant because fujitsu-laptop driver probes ACPI
> > device only, and the driver will be loaded if the ACPI device objects
> > for FUJ02B1 and FUJ02E3 is created.
> 
> We may be able to drop the Fujitsu devices from the ACPI PNP list and all may
> work.  Still, does that fix all of the potential problems?
> 
> > 2. This "redundant" PNP id table results in that those IDs are added to
> > PNP ID list unnecessarily, and results in PNP device nodes for those
> > devices are created unnecessarily.
> 
> Yes, that may be the case, but the way to deal with that is not to break
> thing and then see what's broken and fix it, but to get rid of ACPI drivers
> one by one in which case we can control what's been changed and why.
> 
> > >   Yes, we need to convert that driver
> > > to use a PNP driver structure or a platform device, but (1) we need a
> > > -stable fix *first*
> > 
> > I agree.
> > 
> > >  and (2) the cases we already know about may not be
> > > the only broken ones.
> > 
> > Agree.
> > But the issue addressed in your patch is that PNP scan handler blocks
> > ACPI driver from being probed, right?
> 
> Yes.
> 
> > So my question would be,
> > 1. If the id in PNP scan handler does not have a PNP driver, like the
> >    FUJ02B1/FUJ02E3 issue, what do we need the id in PNP scan handler?
> >    In fact, I think this is a good chance for us to cleanup the ACPI PNP
> >    id list, as long as we can fix them in time.
> 
> No.
> 
> We need -stable to work and there's no way I will mark the motherboard
> resource changes for -stable.

I agree. And I would rather consider my patch as the start point of a
long term solution.

>   Second, if we deal with it as I said (that is,
> get rid of ACPI drivers gradually), we will clean up that list in the process
> without breaking things for people in random ways.

Agree.
> 
> > 2. If the id in PNP scan handler has a PNP driver, should we allow both
> >    PNP driver and ACPI driver loaded? I think PNP system driver is the
> >    only case that makes us have to say yes, and what I'm trying to do
> >    is to fix this in the following patch.
> > 
> > Plus, IMO, your patch only fixes the PNP bus vs. ACPI bus issue. We
> > still may get bug report complaining some *PLATFORM* driver stops to
> > functional if the ACPI node has _CID PNP0C01/PNP0C02, sooner or later.
> > right?
> 
> No.
> 
> We never allowed ACPI drivers to bind to ACPI device objects having platform
> device companions,

No, I mean, a platform device is used to be created as the ACPI device
object _HID was in the previous acpi_platform scan handler list, but if
this device has _CID PNP0C01/PNP0C02, the platform device will not be
created any more after the ACPI enumeration re-work patches.

>  wherease we *did* allow that for ACPI device objects having
> PNP device companions.  We simply need to go back to what we were doing and fix
> things *on* *top* of that.
> 
> Any other approach pretty much guarantees leaving breakage in random places.
> 
> So I'm fine with cleaning up the PNP list *if* you convert the drivers in
> question from ACPI drivers to something else (platform drivers preferably)
> at the same time.
> 
yes, I see.

So I guess the following patch can be upstream candidate, right?

>From e32c2de37750d622dae6ef9d2f5c448a528a7edb Mon Sep 17 00:00:00 2001
From: Zhang Rui <rui.zhang@intel.com>
Date: Fri, 22 Aug 2014 09:06:10 +0800
Subject: [PATCH] ACPI: remove Fujitsu backlight and hotkey device ID from ACPI
 PNP id list

Fujitsu backlight and hotkey devices have ACPI drivers.
The PNP MODULE_DEVICE_TABLE in fujitsu-laptop driver is just used as an
indicator for module autoloading. But this is wrong because what we need is
ACPI module device table instead because the driver is probing ACPI devices.

Thus remove those ids from ACPI PNP scan handler list as we don't
have PNP driver for them, and convert the fujitsu-laptop PNP
MODULE_DEVICE_TABLE to ACPI MODULE_DEVICE_TABLE.

Reference: https://bugzilla.kernel.org/show_bug.cgi?id=81971
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Tested-by: Dirk Griesbach <spamthis@freenet.de>
---
 drivers/acpi/acpi_pnp.c               |  4 ----
 drivers/platform/x86/fujitsu-laptop.c | 16 +++++++---------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
index 1f8b204..b193f84 100644
--- a/drivers/acpi/acpi_pnp.c
+++ b/drivers/acpi/acpi_pnp.c
@@ -130,10 +130,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
 	{"PNP0401"},		/* ECP Printer Port */
 	/* apple-gmux */
 	{"APP000B"},
-	/* fujitsu-laptop.c */
-	{"FUJ02bf"},
-	{"FUJ02B1"},
-	{"FUJ02E3"},
 	/* system */
 	{"PNP0c02"},		/* General ID for reserving resources */
 	{"PNP0c01"},		/* memory controller */
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 87aa28c..2655d4a 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -1050,6 +1050,13 @@ static struct acpi_driver acpi_fujitsu_hotkey_driver = {
 		},
 };
 
+static const struct acpi_device_id fujitsu_ids[] __used = {
+	{ACPI_FUJITSU_HID, 0},
+	{ACPI_FUJITSU_HOTKEY_HID, 0},
+	{"", 0}
+};
+MODULE_DEVICE_TABLE(acpi, fujitsu_ids);
+
 static int __init fujitsu_init(void)
 {
 	int ret, result, max_brightness;
@@ -1208,12 +1215,3 @@ MODULE_LICENSE("GPL");
 MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
 MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
 MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
-
-static struct pnp_device_id pnp_ids[] __used = {
-	{.id = "FUJ02bf"},
-	{.id = "FUJ02B1"},
-	{.id = "FUJ02E3"},
-	{.id = ""}
-};
-
-MODULE_DEVICE_TABLE(pnp, pnp_ids);
-- 
1.8.3.2

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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-08-21  4:04 [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects Rafael J. Wysocki
  2014-08-21 12:08 ` Zhang Rui
@ 2014-08-24  7:06 ` Zhang Rui
  2014-08-25 22:25   ` Rafael J. Wysocki
  1 sibling, 1 reply; 11+ messages in thread
From: Zhang Rui @ 2014-08-24  7:06 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Gabriele Mazzotta, Dirk Griesbach, Matthew Garrett

On Thu, 2014-08-21 at 06:04 +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> We generally don't allow ACPI drivers to bind to ACPI device objects
> that companion "physical" device objects are created for to avoid
> situations in which two different drivers may attempt to handle one
> device at the same time.  Recent ACPI device enumeration rework
> extended that approach to ACPI PNP devices by starting to use a scan
> handler for enumerating them.  However, we previously allowed ACPI
> drivers to bind to ACPI device objects with existing PNP device
> companions and changing that led to functional regressions on some
> systems.
> 
> For this reason, add a special check for PNP devices in
> acpi_device_probe() so that ACPI drivers can bind to ACPI device
> objects having existing PNP device companions as before.
> 
> Fixes: eec15edbb0e1 (ACPI / PNP: use device ID list for PNPACPI device enumeration)
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=81511
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=81971
> Reported-and-tested-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
> Reported-and-tested-by: Dirk Griesbach <spamthis@freenet.de>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/acpi/acpi_pnp.c |    5 +++++
>  drivers/acpi/internal.h |    1 +
>  drivers/acpi/scan.c     |    2 +-
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> Index: linux-pm/drivers/acpi/acpi_pnp.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/acpi_pnp.c
> +++ linux-pm/drivers/acpi/acpi_pnp.c
> @@ -396,3 +396,8 @@ void __init acpi_pnp_init(void)
>  {
>  	acpi_scan_add_handler(&acpi_pnp_handler);
>  }
> +
> +bool is_acpi_pnp_device(struct acpi_device *adev)
> +{
> +	return adev->handler == &acpi_pnp_handler;
> +}

can we reuse acpi_is_pnp_device()?
The only difference is that acpi_is_pnp_device() returns true for
RTC_CMOS devices, which is not a problem IMO because RTC CMOS devices
have PNP driver only.

thanks,
rui

> Index: linux-pm/drivers/acpi/internal.h
> ===================================================================
> --- linux-pm.orig/drivers/acpi/internal.h
> +++ linux-pm/drivers/acpi/internal.h
> @@ -86,6 +86,7 @@ void acpi_device_add_finalize(struct acp
>  void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
>  bool acpi_device_is_present(struct acpi_device *adev);
>  bool acpi_device_is_battery(struct acpi_device *adev);
> +bool is_acpi_pnp_device(struct acpi_device *adev);
>  
>  /* --------------------------------------------------------------------------
>                                    Power Resource
> Index: linux-pm/drivers/acpi/scan.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/scan.c
> +++ linux-pm/drivers/acpi/scan.c
> @@ -975,7 +975,7 @@ static int acpi_device_probe(struct devi
>  	struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
>  	int ret;
>  
> -	if (acpi_dev->handler)
> +	if (acpi_dev->handler && !is_acpi_pnp_device(acpi_dev))
>  		return -EINVAL;
>  
>  	if (!acpi_drv->ops.add)

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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-08-24  7:06 ` Zhang Rui
@ 2014-08-25 22:25   ` Rafael J. Wysocki
  0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2014-08-25 22:25 UTC (permalink / raw)
  To: Zhang Rui
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Gabriele Mazzotta, Dirk Griesbach, Matthew Garrett

On Sunday, August 24, 2014 03:06:50 PM Zhang Rui wrote:
> On Thu, 2014-08-21 at 06:04 +0200, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

[cut]

> >  3 files changed, 7 insertions(+), 1 deletion(-)
> > 
> > Index: linux-pm/drivers/acpi/acpi_pnp.c
> > ===================================================================
> > --- linux-pm.orig/drivers/acpi/acpi_pnp.c
> > +++ linux-pm/drivers/acpi/acpi_pnp.c
> > @@ -396,3 +396,8 @@ void __init acpi_pnp_init(void)
> >  {
> >  	acpi_scan_add_handler(&acpi_pnp_handler);
> >  }
> > +
> > +bool is_acpi_pnp_device(struct acpi_device *adev)
> > +{
> > +	return adev->handler == &acpi_pnp_handler;
> > +}
> 
> can we reuse acpi_is_pnp_device()?
> The only difference is that acpi_is_pnp_device() returns true for
> RTC_CMOS devices, which is not a problem IMO because RTC CMOS devices
> have PNP driver only.

Yes, we can.  Overlooked that.

Updated patch is appended.

Rafael


---
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Subject: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects

We generally don't allow ACPI drivers to bind to ACPI device objects
that companion "physical" device objects are created for to avoid
situations in which two different drivers may attempt to handle one
device at the same time.  Recent ACPI device enumeration rework
extended that approach to ACPI PNP devices by starting to use a scan
handler for enumerating them.  However, we previously allowed ACPI
drivers to bind to ACPI device objects with existing PNP device
companions and changing that led to functional regressions on some
systems.

For this reason, add a special check for PNP devices in
acpi_device_probe() so that ACPI drivers can bind to ACPI device
objects having existing PNP device companions as before.

Fixes: eec15edbb0e1 (ACPI / PNP: use device ID list for PNPACPI device enumeration)
Link: https://bugzilla.kernel.org/show_bug.cgi?id=81511
Link: https://bugzilla.kernel.org/show_bug.cgi?id=81971
Reported-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
Reported-by: Dirk Griesbach <spamthis@freenet.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/scan.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -975,7 +975,7 @@ static int acpi_device_probe(struct devi
 	struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
 	int ret;
 
-	if (acpi_dev->handler)
+	if (acpi_dev->handler && !acpi_is_pnp_device(acpi_dev))
 		return -EINVAL;
 
 	if (!acpi_drv->ops.add)

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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-08-23 15:21         ` Zhang Rui
@ 2014-09-08 22:14           ` Rafael J. Wysocki
  2014-09-08 22:32             ` Darren Hart
  0 siblings, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2014-09-08 22:14 UTC (permalink / raw)
  To: Zhang Rui, Darren Hart
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Gabriele Mazzotta, Dirk Griesbach, Matthew Garrett

On Saturday, August 23, 2014 11:21:17 PM Zhang Rui wrote:

[cut]

Darren, would there be any problems if I took the patch below from Rui for 3.18?

> 
> So I guess the following patch can be upstream candidate, right?
> 
> From e32c2de37750d622dae6ef9d2f5c448a528a7edb Mon Sep 17 00:00:00 2001
> From: Zhang Rui <rui.zhang@intel.com>
> Date: Fri, 22 Aug 2014 09:06:10 +0800
> Subject: [PATCH] ACPI: remove Fujitsu backlight and hotkey device ID from ACPI
>  PNP id list
> 
> Fujitsu backlight and hotkey devices have ACPI drivers.
> The PNP MODULE_DEVICE_TABLE in fujitsu-laptop driver is just used as an
> indicator for module autoloading. But this is wrong because what we need is
> ACPI module device table instead because the driver is probing ACPI devices.
> 
> Thus remove those ids from ACPI PNP scan handler list as we don't
> have PNP driver for them, and convert the fujitsu-laptop PNP
> MODULE_DEVICE_TABLE to ACPI MODULE_DEVICE_TABLE.
> 
> Reference: https://bugzilla.kernel.org/show_bug.cgi?id=81971
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> Tested-by: Dirk Griesbach <spamthis@freenet.de>
> ---
>  drivers/acpi/acpi_pnp.c               |  4 ----
>  drivers/platform/x86/fujitsu-laptop.c | 16 +++++++---------
>  2 files changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
> index 1f8b204..b193f84 100644
> --- a/drivers/acpi/acpi_pnp.c
> +++ b/drivers/acpi/acpi_pnp.c
> @@ -130,10 +130,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
>  	{"PNP0401"},		/* ECP Printer Port */
>  	/* apple-gmux */
>  	{"APP000B"},
> -	/* fujitsu-laptop.c */
> -	{"FUJ02bf"},
> -	{"FUJ02B1"},
> -	{"FUJ02E3"},
>  	/* system */
>  	{"PNP0c02"},		/* General ID for reserving resources */
>  	{"PNP0c01"},		/* memory controller */
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 87aa28c..2655d4a 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -1050,6 +1050,13 @@ static struct acpi_driver acpi_fujitsu_hotkey_driver = {
>  		},
>  };
>  
> +static const struct acpi_device_id fujitsu_ids[] __used = {
> +	{ACPI_FUJITSU_HID, 0},
> +	{ACPI_FUJITSU_HOTKEY_HID, 0},
> +	{"", 0}
> +};
> +MODULE_DEVICE_TABLE(acpi, fujitsu_ids);
> +
>  static int __init fujitsu_init(void)
>  {
>  	int ret, result, max_brightness;
> @@ -1208,12 +1215,3 @@ MODULE_LICENSE("GPL");
>  MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
>  MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
>  MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
> -
> -static struct pnp_device_id pnp_ids[] __used = {
> -	{.id = "FUJ02bf"},
> -	{.id = "FUJ02B1"},
> -	{.id = "FUJ02E3"},
> -	{.id = ""}
> -};
> -
> -MODULE_DEVICE_TABLE(pnp, pnp_ids);
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects
  2014-09-08 22:14           ` Rafael J. Wysocki
@ 2014-09-08 22:32             ` Darren Hart
  0 siblings, 0 replies; 11+ messages in thread
From: Darren Hart @ 2014-09-08 22:32 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Zhang Rui, Darren Hart, ACPI Devel Maling List,
	Linux Kernel Mailing List, Gabriele Mazzotta, Dirk Griesbach,
	Matthew Garrett

On Tue, Sep 09, 2014 at 12:14:04AM +0200, Rafael J. Wysocki wrote:
> On Saturday, August 23, 2014 11:21:17 PM Zhang Rui wrote:
> 
> [cut]
> 
> Darren, would there be any problems if I took the patch below from Rui for 3.18?
> 

No objection.

Acked-by: Darren Hart <dvhart@linux.intel.com>

> > 
> > So I guess the following patch can be upstream candidate, right?
> > 
> > From e32c2de37750d622dae6ef9d2f5c448a528a7edb Mon Sep 17 00:00:00 2001
> > From: Zhang Rui <rui.zhang@intel.com>
> > Date: Fri, 22 Aug 2014 09:06:10 +0800
> > Subject: [PATCH] ACPI: remove Fujitsu backlight and hotkey device ID from ACPI
> >  PNP id list
> > 
> > Fujitsu backlight and hotkey devices have ACPI drivers.
> > The PNP MODULE_DEVICE_TABLE in fujitsu-laptop driver is just used as an
> > indicator for module autoloading. But this is wrong because what we need is
> > ACPI module device table instead because the driver is probing ACPI devices.
> > 
> > Thus remove those ids from ACPI PNP scan handler list as we don't
> > have PNP driver for them, and convert the fujitsu-laptop PNP
> > MODULE_DEVICE_TABLE to ACPI MODULE_DEVICE_TABLE.
> > 
> > Reference: https://bugzilla.kernel.org/show_bug.cgi?id=81971
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > Tested-by: Dirk Griesbach <spamthis@freenet.de>
> > ---
> >  drivers/acpi/acpi_pnp.c               |  4 ----
> >  drivers/platform/x86/fujitsu-laptop.c | 16 +++++++---------
> >  2 files changed, 7 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
> > index 1f8b204..b193f84 100644
> > --- a/drivers/acpi/acpi_pnp.c
> > +++ b/drivers/acpi/acpi_pnp.c
> > @@ -130,10 +130,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
> >  	{"PNP0401"},		/* ECP Printer Port */
> >  	/* apple-gmux */
> >  	{"APP000B"},
> > -	/* fujitsu-laptop.c */
> > -	{"FUJ02bf"},
> > -	{"FUJ02B1"},
> > -	{"FUJ02E3"},
> >  	/* system */
> >  	{"PNP0c02"},		/* General ID for reserving resources */
> >  	{"PNP0c01"},		/* memory controller */
> > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> > index 87aa28c..2655d4a 100644
> > --- a/drivers/platform/x86/fujitsu-laptop.c
> > +++ b/drivers/platform/x86/fujitsu-laptop.c
> > @@ -1050,6 +1050,13 @@ static struct acpi_driver acpi_fujitsu_hotkey_driver = {
> >  		},
> >  };
> >  
> > +static const struct acpi_device_id fujitsu_ids[] __used = {
> > +	{ACPI_FUJITSU_HID, 0},
> > +	{ACPI_FUJITSU_HOTKEY_HID, 0},
> > +	{"", 0}
> > +};
> > +MODULE_DEVICE_TABLE(acpi, fujitsu_ids);
> > +
> >  static int __init fujitsu_init(void)
> >  {
> >  	int ret, result, max_brightness;
> > @@ -1208,12 +1215,3 @@ MODULE_LICENSE("GPL");
> >  MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
> >  MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
> >  MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
> > -
> > -static struct pnp_device_id pnp_ids[] __used = {
> > -	{.id = "FUJ02bf"},
> > -	{.id = "FUJ02B1"},
> > -	{.id = "FUJ02E3"},
> > -	{.id = ""}
> > -};
> > -
> > -MODULE_DEVICE_TABLE(pnp, pnp_ids);
> > 
> 
> -- 
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 
Darren Hart
Intel Open Source Technology Center

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

end of thread, other threads:[~2014-09-08 22:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-21  4:04 [PATCH] ACPI / scan: Allow ACPI drivers to bind to PNP device objects Rafael J. Wysocki
2014-08-21 12:08 ` Zhang Rui
2014-08-21 16:36   ` Rafael J. Wysocki
2014-08-21 17:10   ` Rafael J. Wysocki
2014-08-22  2:00     ` Zhang Rui
2014-08-22 17:53       ` Rafael J. Wysocki
2014-08-23 15:21         ` Zhang Rui
2014-09-08 22:14           ` Rafael J. Wysocki
2014-09-08 22:32             ` Darren Hart
2014-08-24  7:06 ` Zhang Rui
2014-08-25 22:25   ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.