linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V7 00/11] ACPI: ACPI enumeration rework
@ 2014-05-22 18:02 Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 01/11] ACPI: introduce .match() callback for ACPI scan handler Zhang Rui
                   ` (11 more replies)
  0 siblings, 12 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

Hi, all,

Currently, PNP bus is used as the default bus for for enumerating ACPI
devices with _HID/_CID.
For a device that needs to be enumerated to platform bus, we need to add
its id string to the platform scan handler white list explicitly.

This becomes a problem as more and more _HID devices need to be
enumerated to platform bus nowadays, thus the list is continuously growing.

So, a solution that uses platform bus for _HID enumeration by default
is preferred.

In order to do this, this patch set
First (Patch 1~4), changes the way of enumerating PNP devices.
We introduce a white list to create PNP devices instead. The white list contains
all the pnp_device_id strings in all the pnp drivers, thus this change is
transparent to PNP core and all the PNP drivers.
Second (Patch 5~11), changes the code to enumerate ACPI _HID devices to platform
bus by default.

Tis patch set has been tested on my desktop machine,
and a TOSHIBA PORTEGE Z830 ultrabook.

Clarification:
Although it seems that we are introducing a much bigger white list to replace
a small one, the benefit is that
1. without the patch, the acpi_platform scan handler white list is
   continuously growing.
2. with the patch set, the PNPACPI scan handler white list will become
   smaller and smaller by
   a) remove the ids from the PNPACPI white list, for the devices
      that are never enumerated via ACPI
   b) remove the ids from the PNPACPI whilte list and convert the drivers to
      platform bus drivers, for the devices that are not PNP devices in nature.
   which will be done later.

Known Issue:
PNP bus does not check the device resources when adding a new PNP device,
while Platform bus does by invoking insert_resource() in platform_device_add().
This results in failure when creating platform device node for some ACPI
device objects in case there is resource conflict.
In my desktop, I can see that
Creating PNP0C02:02 fails because its resource (IO: 0x72 ~ 0x7f)
conflicts with "0070-0077 : PNP0B00:00" (CMOS RTC).

Known Issue:
Currently, we can't enumerate devices with _CID PNP0C01/PNP0C02 to platform bus
because we need them in PNP bus in order to reserve mother board resources.

thanks,
rui

----------------------------------------------------------------
Changes in V7:
1. always registering the same scan handler, but with an optional NULL .attach() callback
   instead of registering a dummy handler.
2. avoid enumerting SPB slave devices by checking the SPB resources
   instead of introduing & setting & checking a flag in the SPB master device.

Changes in V6:
1. Patch re-ordering to avoid bisect breakage.
2. rework the patch for fixing the "redudent platform devices created for lpss
   slaves" issue according to Rafael' comments.

Changes in V5:
1. fix a problem that ACPI tries to enumerate lpss slaves to platform bus
2. rebased on 3.14 kernel

Changes in V4:
1. coding style cleanups, fix checkpatch warnings/errors.

Changes in V3:
1. rename enumerable_id to platform_id according to Rafael' suggestion.
2. drop two patches to handle devices with _CID PNP0C01/PNP0C02 enumeration
   because the code in drivers/pnp/system.c is still under discussion.
3. make cmos rtc scan handler return 1 so that the device will not be
   enumerated to platform bus.

Changes in V2:
1.move acpi pnp scan handler from drivers/pnp/pnpacpi/core.c to
  drivers/acpi/acpi-pnp.c, because the scan handler needs to be always built
  in to prevent platform devices from being created for those ACPI devices.
2.remove the __init tag for the acpi pnp scan handler because the scan
  handler is still needed after system initialization, for hotplug.
3.introduce enumerable_id flag for devices that can be enumerated to platform
  bus.
4.introduce excluded id list for creating platform devices, because some
  devices have _HID but they will never be associated with a platform driver.
5.introduce dummy lpss/container/memory_hotplug scan handler to prevent
  platform devices from being created for those ACPI device objects.

----------------------------------------------------------------
Zhang Rui (11):
      ACPI: introduce .match() callback for ACPI scan handler
      PNPACPI: use whilte list for pnpacpi device enumeration
      ACPI: remove ids that does not comply with the ACPI PNP id rule
      ACPI: remove unsupported serial PNP ids from acpi pnp scan handler id lsit
      ACPI: allow scan handlers without .attach() callback
      ACPI: always register container scan handler even if CONFIG_ACPI_CONTAINER is cleared
      ACPI: always register memory hotplug scan handler even if CONFIG_ACPI_HOTPLUG_MEMORY is cleared
      ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS is cleared
      ACPI: introduce platform_id flag
      ACPI: use platform bus as the default bus for _HID enumeration
      ACPI: introduce acpi platform exclude id list

 drivers/acpi/Makefile          |   7 ++--
 drivers/acpi/acpi_cmos_rtc.c   |   2 +-
 drivers/acpi/acpi_lpss.c       |  63 ++++++++++++++++++----------
 drivers/acpi/acpi_memhotplug.c |  46 ++++++++++----------
 drivers/acpi/acpi_platform.c   |  39 ++++++-----------
 drivers/acpi/acpi_pnp.c        | 382 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/acpi/container.c       |  18 +++++---
 drivers/acpi/internal.h        |  15 +------
 drivers/acpi/scan.c            |  83 +++++++++++++++++++++++++++++++-----
 drivers/pnp/pnpacpi/core.c     |  28 ++-----------
 include/acpi/acpi_bus.h        |   4 +-
 include/linux/acpi.h           |   2 +
 12 files changed, 560 insertions(+), 129 deletions(-)
 create mode 100644 drivers/acpi/acpi_pnp.c

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

* [PATCH V7 01/11] ACPI: introduce .match() callback for ACPI scan handler
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 02/11] PNPACPI: use whilte list for pnpacpi device enumeration Zhang Rui
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

Currently, ACPI scan handler uses strcmp() to match device ids
and scan handler ids.

When converting PNPACPI enumeration into a scan handler, which I will do
later in this patch set, the current code becomes not flexible enough
because ACPI pnp scan handler requires wildcase and case insensitive support.

Thus a per scan handler .match() callback is introduced in this patch,
so that specified scan handler can have more flexible matching mechanism
by introduce its own .match() callback.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/scan.c     | 17 +++++++++++------
 include/acpi/acpi_bus.h |  1 +
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 7efe546..e46e51c 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1974,14 +1974,19 @@ static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
 	const struct acpi_device_id *devid;
 
 	for (devid = handler->ids; devid->id[0]; devid++)
-		if (!strcmp((char *)devid->id, idstr)) {
-			if (matchid)
-				*matchid = devid;
-
-			return true;
-		}
+		if (handler->match) {
+			if (handler->match(idstr, (char *)devid->id))
+				goto success;
+		} else
+			if (!strcmp((char *)devid->id, idstr))
+				goto success;
 
 	return false;
+
+success:
+	if (matchid)
+		*matchid = devid;
+	return true;
 }
 
 static struct acpi_scan_handler *acpi_scan_match_handler(char *idstr,
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 84a2e29..ba679af 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -131,6 +131,7 @@ static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(
 struct acpi_scan_handler {
 	const struct acpi_device_id *ids;
 	struct list_head list_node;
+	int (*match)(char *devid, char *handler_id);
 	int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
 	void (*detach)(struct acpi_device *dev);
 	void (*bind)(struct device *phys_dev);
-- 
1.8.3.2


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

* [PATCH V7 02/11] PNPACPI: use whilte list for pnpacpi device enumeration
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 01/11] ACPI: introduce .match() callback for ACPI scan handler Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-22 18:14   ` Bjorn Helgaas
  2014-05-22 18:02 ` [PATCH V7 03/11] ACPI: remove ids that does not comply with the ACPI PNP id rule Zhang Rui
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

ACPI can be used to enumerate PNP devices, but the code does not
handle this in a good manner.

Currently, if an ACPI device
1. has _CRS method,
2. has an identifications of
   "three capital charactors followed by four hex numbers",
3. is not in the excluded id list,
it is enumerated to PNP bus.

So actually, PNP bus is used as the default bus for enumerating _HID devices.

But, nowadays, more and more _HID devices are needed to be enumerate to
platform bus instead. And a white list is used for those devices to avoid
overlapping with PNP bus.
The problem is that this list is continuously growing.

So, a solution that uses platform bus as the default bus for _HID enumeration
is preferred.
In order to do this, this patch changes the way of enumerating PNP devices.
As the first step, we use a white list (scan handler) to create PNP devices
instead. This white list contains all the pnp_device_id strings in all the pnp
drivers, thus this change is transparent to PNP core and all the PNP drivers.

Note: I just grep all the id strings in all pnp_device_id instances and
      copy them to the new white list, with a few changes to the comments
      only, to follow the format of:

      /* driver name, or file name if not a PNP driver */
      {"id-string"}, /* optional comments for the id-string */
      ...

Note: the PNPACPI devices are created in two step,
      1. mark the PNPACPI devices by the acpi pnp scan handler.
      2. create the PNPACPI devices in PNPACPI code in a fs_initcall()
      In this case, if PNP/PNPACPI is not set or "pnpacpi=off" kernel option
      is used, the acpi pnp scan handler is still there, to prevent those
      PNPACPI devices from being created to platform bus.

Note: For CMOS RTC devices, the acpi pnp scan handler does not work because
      there is already a cmos rtc scan handler installed, thus we need to
      check those devices and enumerate them to PNP bus explicitly.
      Plus, the cmos rtc scan handler needs to return 1 so that it will not
      be enumerated to platform bus.

TODO: Reduce this PNPACPI white list by
      1. remove the ids for the devices that are never enumerated via ACPI
      2. remove the ids and convert the drivers to platform bus drivers
         for the devices that are not PNP devices in nature.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/Makefile        |   1 +
 drivers/acpi/acpi_cmos_rtc.c |   2 +-
 drivers/acpi/acpi_pnp.c      | 388 +++++++++++++++++++++++++++++++++++++++++++
 drivers/acpi/internal.h      |   1 +
 drivers/acpi/scan.c          |   1 +
 drivers/pnp/pnpacpi/core.c   |  28 +---
 include/linux/acpi.h         |   2 +
 7 files changed, 398 insertions(+), 25 deletions(-)
 create mode 100644 drivers/acpi/acpi_pnp.c

diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 0331f91..9a43893 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -41,6 +41,7 @@ acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
 acpi-y				+= pci_root.o pci_link.o pci_irq.o
 acpi-$(CONFIG_X86_INTEL_LPSS)	+= acpi_lpss.o
 acpi-y				+= acpi_platform.o
+acpi-y				+= acpi_pnp.o
 acpi-y				+= power.o
 acpi-y				+= event.o
 acpi-y				+= sysfs.o
diff --git a/drivers/acpi/acpi_cmos_rtc.c b/drivers/acpi/acpi_cmos_rtc.c
index 961b45d..2da8660 100644
--- a/drivers/acpi/acpi_cmos_rtc.c
+++ b/drivers/acpi/acpi_cmos_rtc.c
@@ -68,7 +68,7 @@ static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev,
 		return -ENODEV;
 	}
 
-	return 0;
+	return 1;
 }
 
 static void acpi_remove_cmos_rtc_space_handler(struct acpi_device *adev)
diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
new file mode 100644
index 0000000..57d14ed
--- /dev/null
+++ b/drivers/acpi/acpi_pnp.c
@@ -0,0 +1,388 @@
+/*
+ * ACPI support for PNP bus type
+ *
+ * Copyright (C) 2014, Intel Corporation
+ * Authors: Zhang Rui <rui.zhang@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/module.h>
+
+static const struct acpi_device_id acpi_pnp_device_ids[] = {
+	/* pata_isapnp */
+	{"PNP0600"},		/* Generic ESDI/IDE/ATA compatible hard disk controller */
+	/* floppy */
+	{"PNP0700"},
+	/* ipmi_si */
+	{"IPI0001"},
+	/* tpm_inf_pnp */
+	{"IFX0101"},		/* Infineon TPMs */
+	{"IFX0102"},		/* Infineon TPMs */
+	/*tpm_tis */
+	{"PNP0C31"},		/* TPM */
+	{"ATM1200"},		/* Atmel */
+	{"IFX0102"},		/* Infineon */
+	{"BCM0101"},		/* Broadcom */
+	{"BCM0102"},		/* Broadcom */
+	{"NSC1200"},		/* National */
+	{"ICO0102"},		/* Intel */
+	/* ide   */
+	{"PNP0600"},		/* Generic ESDI/IDE/ATA compatible hard disk controller */
+	/* ns558 */
+	{"@P@0001"},		/* ALS 100 */
+	{"@P@0020"},		/* ALS 200 */
+	{"@P@1001"},		/* ALS 100+ */
+	{"@P@2001"},		/* ALS 120 */
+	{"ASB16fd"},		/* AdLib NSC16 */
+	{"AZT3001"},		/* AZT1008 */
+	{"CDC0001"},		/* Opl3-SAx */
+	{"CSC0001"},		/* CS4232 */
+	{"CSC000f"},		/* CS4236 */
+	{"CSC0101"},		/* CS4327 */
+	{"CTL7001"},		/* SB16 */
+	{"CTL7002"},		/* AWE64 */
+	{"CTL7005"},		/* Vibra16 */
+	{"ENS2020"},		/* SoundscapeVIVO */
+	{"ESS0001"},		/* ES1869 */
+	{"ESS0005"},		/* ES1878 */
+	{"ESS6880"},		/* ES688 */
+	{"IBM0012"},		/* CS4232 */
+	{"OPT0001"},		/* OPTi Audio16 */
+	{"YMH0006"},		/* Opl3-SA */
+	{"YMH0022"},		/* Opl3-SAx */
+	{"PNPb02f"},		/* Generic */
+	/* i8042 kbd */
+	{"PNP0300"},
+	{"PNP0301"},
+	{"PNP0302"},
+	{"PNP0303"},
+	{"PNP0304"},
+	{"PNP0305"},
+	{"PNP0306"},
+	{"PNP0309"},
+	{"PNP030a"},
+	{"PNP030b"},
+	{"PNP0320"},
+	{"PNP0343"},
+	{"PNP0344"},
+	{"PNP0345"},
+	{"CPQA0D7"},
+	/* i8042 aux */
+	{"AUI0200"},
+	{"FJC6000"},
+	{"FJC6001"},
+	{"PNP0f03"},
+	{"PNP0f0b"},
+	{"PNP0f0e"},
+	{"PNP0f12"},
+	{"PNP0f13"},
+	{"PNP0f19"},
+	{"PNP0f1c"},
+	{"SYN0801"},
+	/* fcpnp */
+	{"AVM0900"},
+	/* radio-cadet */
+	{"MSM0c24"},		/* ADS Cadet AM/FM Radio Card */
+	/* radio-gemtek */
+	{"ADS7183"},		/* AOpen FX-3D/Pro Radio */
+	/* radio-sf16fmr2 */
+	{"MFRad13"},		/* tuner subdevice of SF16-FMD2 */
+	/* ene_ir */
+	{"ENE0100"},
+	{"ENE0200"},
+	{"ENE0201"},
+	{"ENE0202"},
+	/* fintek-cir */
+	{"FIT0002"},		/* CIR */
+	/* ite-cir */
+	{"ITE8704"},		/* Default model */
+	{"ITE8713"},		/* CIR found in EEEBox 1501U */
+	{"ITE8708"},		/* Bridged IT8512 */
+	{"ITE8709"},		/* SRAM-Bridged IT8512 */
+	/* nuvoton-cir */
+	{"WEC0530"},		/* CIR */
+	{"NTN0530"},		/* CIR for new chip's pnp id */
+	/* Winbond CIR */
+	{"WEC1022"},
+	/* wbsd */
+	{"WEC0517"},
+	{"WEC0518"},
+	/* Winbond CIR */
+	{"TCM5090"},		/* 3Com Etherlink III (TP) */
+	{"TCM5091"},		/* 3Com Etherlink III */
+	{"TCM5094"},		/* 3Com Etherlink III (combo) */
+	{"TCM5095"},		/* 3Com Etherlink III (TPO) */
+	{"TCM5098"},		/* 3Com Etherlink III (TPC) */
+	{"PNP80f7"},		/* 3Com Etherlink III compatible */
+	{"PNP80f8"},		/* 3Com Etherlink III compatible */
+	/* nsc-ircc */
+	{"NSC6001"},
+	{"HWPC224"},
+	{"IBM0071"},
+	/* smsc-ircc2 */
+	{"SMCf010"},
+	/* sb1000 */
+	{"GIC1000"},
+	/* parport_pc */
+	{"PNP0400"},		/* Standard LPT Printer Port */
+	{"PNP0401"},		/* ECP Printer Port */
+	/* apple-gmux */
+	{"APP000B"},
+	/* fujitsu-laptop.c */
+	{"FUJ02bf"},
+	{"FUJ02B1"},
+	{"FUJ02E3"},
+	/* system */
+	{"PNP0c02"},		/* General ID for reserving resources */
+	{"PNP0c01"},		/* memory controller */
+	/* rtc_cmos */
+	{"PNP0b00"},
+	{"PNP0b01"},
+	{"PNP0b02"},
+	/* c6xdigio */
+	{"PNP0400"},		/* Standard LPT Printer Port */
+	{"PNP0401"},		/* ECP Printer Port */
+	/* ni_atmio.c */
+	{"NIC1900"},
+	{"NIC2400"},
+	{"NIC2500"},
+	{"NIC2600"},
+	{"NIC2700"},
+	/* serial */
+	{"AAC000F"},		/* Archtek America Corp. Archtek SmartLink Modem 3334BT Plug & Play */
+	{"ADC0001"},		/* Anchor Datacomm BV. SXPro 144 External Data Fax Modem Plug & Play */
+	{"ADC0002"},		/* SXPro 288 External Data Fax Modem Plug & Play */
+	{"AEI0250"},		/* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
+	{"AEI1240"},		/* Actiontec ISA PNP 56K X2 Fax Modem */
+	{"AKY1021"},		/* Rockwell 56K ACF II Fax+Data+Voice Modem */
+	{"AZT4001"},		/* AZT3005 PnP SOUND DEVICE */
+	{"BDP3336"},		/* Best Data Products Inc. Smart One 336F PnP Modem */
+	{"BRI0A49"},		/* Boca Complete Ofc Communicator 14.4 Data-FAX */
+	{"BRI1400"},		/* Boca Research 33,600 ACF Modem */
+	{"BRI3400"},		/* Boca 33.6 Kbps Internal FD34FSVD */
+	{"BRI0A49"},		/* Boca 33.6 Kbps Internal FD34FSVD */
+	{"BDP3336"},		/* Best Data Products Inc. Smart One 336F PnP Modem */
+	{"CPI4050"},		/* Computer Peripherals Inc. EuroViVa CommCenter-33.6 SP PnP */
+	{"CTL3001"},		/* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
+	{"CTL3011"},		/* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
+	{"DAV0336"},		/* Davicom ISA 33.6K Modem */
+	{"DMB1032"},		/* Creative Modem Blaster Flash56 DI5601-1 */
+	{"DMB2001"},		/* Creative Modem Blaster V.90 DI5660 */
+	{"ETT0002"},		/* E-Tech CyberBULLET PC56RVP */
+	{"FUJ0202"},		/* Fujitsu 33600 PnP-I2 R Plug & Play */
+	{"FUJ0205"},		/* Fujitsu FMV-FX431 Plug & Play */
+	{"FUJ0206"},		/* Fujitsu 33600 PnP-I4 R Plug & Play */
+	{"FUJ0209"},		/* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
+	{"GVC000F"},		/* Archtek SmartLink Modem 3334BT Plug & Play */
+	{"GVC0303"},		/* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
+	{"HAY0001"},		/* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
+	{"HAY000C"},		/* Hayes Optima 336 V.34 + FAX + Voice PnP */
+	{"HAY000D"},		/* Hayes Optima 336B V.34 + FAX + Voice PnP */
+	{"HAY5670"},		/* Hayes Accura 56K Ext Fax Modem PnP */
+	{"HAY5674"},		/* Hayes Accura 56K Ext Fax Modem PnP */
+	{"HAY5675"},		/* Hayes Accura 56K Fax Modem PnP */
+	{"HAYF000"},		/* Hayes 288, V.34 + FAX */
+	{"HAYF001"},		/* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
+	{"IBM0033"},		/* IBM Thinkpad 701 Internal Modem Voice */
+	{"PNP4972"},		/* Intermec CV60 touchscreen port */
+	{"IXDC801"},		/* Intertex 28k8 33k6 Voice EXT PnP */
+	{"IXDC901"},		/* Intertex 33k6 56k Voice EXT PnP */
+	{"IXDD801"},		/* Intertex 28k8 33k6 Voice SP EXT PnP */
+	{"IXDD901"},		/* Intertex 33k6 56k Voice SP EXT PnP */
+	{"IXDF401"},		/* Intertex 28k8 33k6 Voice SP INT PnP */
+	{"IXDF801"},		/* Intertex 28k8 33k6 Voice SP EXT PnP */
+	{"IXDF901"},		/* Intertex 33k6 56k Voice SP EXT PnP */
+	{"KOR4522"},		/* KORTEX 28800 Externe PnP */
+	{"KORF661"},		/* KXPro 33.6 Vocal ASVD PnP */
+	{"LAS4040"},		/* LASAT Internet 33600 PnP */
+	{"LAS4540"},		/* Lasat Safire 560 PnP */
+	{"LAS5440"},		/* Lasat Safire 336  PnP */
+	{"MNP0281"},		/* Microcom TravelPorte FAST V.34 Plug & Play */
+	{"MNP0336"},		/* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
+	{"MNP0339"},		/* Microcom DeskPorte FAST EP 28.8 Plug & Play */
+	{"MNP0342"},		/* Microcom DeskPorte 28.8P Plug & Play */
+	{"MNP0500"},		/* Microcom DeskPorte FAST ES 28.8 Plug & Play */
+	{"MNP0501"},		/* Microcom DeskPorte FAST ES 28.8 Plug & Play */
+	{"MNP0502"},		/* Microcom DeskPorte 28.8S Internal Plug & Play */
+	{"MOT1105"},		/* Motorola BitSURFR Plug & Play */
+	{"MOT1111"},		/* Motorola TA210 Plug & Play */
+	{"MOT1114"},		/* Motorola HMTA 200 (ISDN) Plug & Play */
+	{"MOT1115"},		/* Motorola BitSURFR Plug & Play */
+	{"MOT1190"},		/* Motorola Lifestyle 28.8 Internal */
+	{"MOT1501"},		/* Motorola V.3400 Plug & Play */
+	{"MOT1502"},		/* Motorola Lifestyle 28.8 V.34 Plug & Play */
+	{"MOT1505"},		/* Motorola Power 28.8 V.34 Plug & Play */
+	{"MOT1509"},		/* Motorola ModemSURFR External 28.8 Plug & Play */
+	{"MOT150A"},		/* Motorola Premier 33.6 Desktop Plug & Play */
+	{"MOT150F"},		/* Motorola VoiceSURFR 56K External PnP */
+	{"MOT1510"},		/* Motorola ModemSURFR 56K External PnP */
+	{"MOT1550"},		/* Motorola ModemSURFR 56K Internal PnP */
+	{"MOT1560"},		/* Motorola ModemSURFR Internal 28.8 Plug & Play */
+	{"MOT1580"},		/* Motorola Premier 33.6 Internal Plug & Play */
+	{"MOT15B0"},		/* Motorola OnlineSURFR 28.8 Internal Plug & Play */
+	{"MOT15F0"},		/* Motorola VoiceSURFR 56K Internal PnP */
+	{"MVX00A1"},		/*  Deskline K56 Phone System PnP */
+	{"MVX00F2"},		/* PC Rider K56 Phone System PnP */
+	{"nEC8241"},		/* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
+	{"PMC2430"},		/* Pace 56 Voice Internal Plug & Play Modem */
+	{"PNP0500"},		/* Generic standard PC COM port     */
+	{"PNP0501"},		/* Generic 16550A-compatible COM port */
+	{"PNPC000"},		/* Compaq 14400 Modem */
+	{"PNPC001"},		/* Compaq 2400/9600 Modem */
+	{"PNPC031"},		/* Dial-Up Networking Serial Cable between 2 PCs */
+	{"PNPC032"},		/* Dial-Up Networking Parallel Cable between 2 PCs */
+	{"PNPC100"},		/* Standard 9600 bps Modem */
+	{"PNPC101"},		/* Standard 14400 bps Modem */
+	{"PNPC102"},		/*  Standard 28800 bps Modem */
+	{"PNPC103"},		/*  Standard Modem */
+	{"PNPC104"},		/*  Standard 9600 bps Modem */
+	{"PNPC105"},		/*  Standard 14400 bps Modem */
+	{"PNPC106"},		/*  Standard 28800 bps Modem */
+	{"PNPC107"},		/*  Standard Modem */
+	{"PNPC108"},		/* Standard 9600 bps Modem */
+	{"PNPC109"},		/* Standard 14400 bps Modem */
+	{"PNPC10A"},		/* Standard 28800 bps Modem */
+	{"PNPC10B"},		/* Standard Modem */
+	{"PNPC10C"},		/* Standard 9600 bps Modem */
+	{"PNPC10D"},		/* Standard 14400 bps Modem */
+	{"PNPC10E"},		/* Standard 28800 bps Modem */
+	{"PNPC10F"},		/* Standard Modem */
+	{"PNP2000"},		/* Standard PCMCIA Card Modem */
+	{"ROK0030"},		/* Rockwell 33.6 DPF Internal PnP, Modular Technology 33.6 Internal PnP */
+	{"ROK0100"},		/* KORTEX 14400 Externe PnP */
+	{"ROK4120"},		/* Rockwell 28.8 */
+	{"ROK4920"},		/* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
+	{"RSS00A0"},		/* Rockwell 33.6 DPF External PnP, BT Prologue 33.6 External PnP, Modular Technology 33.6 External PnP */
+	{"RSS0262"},		/* Viking 56K FAX INT */
+	{"RSS0250"},		/* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
+	{"SUP1310"},		/* SupraExpress 28.8 Data/Fax PnP modem */
+	{"SUP1381"},		/* SupraExpress 336i PnP Voice Modem */
+	{"SUP1421"},		/* SupraExpress 33.6 Data/Fax PnP modem */
+	{"SUP1590"},		/* SupraExpress 33.6 Data/Fax PnP modem */
+	{"SUP1620"},		/* SupraExpress 336i Sp ASVD */
+	{"SUP1760"},		/* SupraExpress 33.6 Data/Fax PnP modem */
+	{"SUP2171"},		/* SupraExpress 56i Sp Intl */
+	{"TEX0011"},		/* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
+	{"UAC000F"},		/* Archtek SmartLink Modem 3334BT Plug & Play */
+	{"USR0000"},		/* 3Com Corp. Gateway Telepath IIvi 33.6 */
+	{"USR0002"},		/* U.S. Robotics Sporster 33.6K Fax INT PnP */
+	{"USR0004"},		/*  Sportster Vi 14.4 PnP FAX Voicemail */
+	{"USR0006"},		/* U.S. Robotics 33.6K Voice INT PnP */
+	{"USR0007"},		/* U.S. Robotics 33.6K Voice EXT PnP */
+	{"USR0009"},		/* U.S. Robotics Courier V.Everything INT PnP */
+	{"USR2002"},		/* U.S. Robotics 33.6K Voice INT PnP */
+	{"USR2070"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"USR2080"},		/* U.S. Robotics 56K Voice EXT PnP */
+	{"USR3031"},		/* U.S. Robotics 56K FAX INT */
+	{"USR3050"},		/* U.S. Robotics 56K FAX INT */
+	{"USR3070"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"USR3080"},		/* U.S. Robotics 56K Voice EXT PnP */
+	{"USR3090"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"USR9100"},		/* U.S. Robotics 56K Message  */
+	{"USR9160"},		/* U.S. Robotics 56K FAX EXT PnP */
+	{"USR9170"},		/* U.S. Robotics 56K FAX INT PnP */
+	{"USR9180"},		/* U.S. Robotics 56K Voice EXT PnP */
+	{"USR9190"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"WACFXXX"},		/* Wacom tablets */
+	{"FPI2002"},		/* Compaq touchscreen */
+	{"FUJ02B2"},		/* Fujitsu Stylistic touchscreens */
+	{"FUJ02B3"},
+	{"FUJ02B4"},		/* Fujitsu Stylistic LT touchscreens */
+	{"FUJ02B6"},		/* Passive Fujitsu Stylistic touchscreens */
+	{"FUJ02B7"},
+	{"FUJ02B8"},
+	{"FUJ02B9"},
+	{"FUJ02BC"},
+	{"FUJ02E5"},		/* Fujitsu Wacom Tablet PC device */
+	{"FUJ02E6"},		/* Fujitsu P-series tablet PC device */
+	{"FUJ02E7"},		/* Fujitsu Wacom 2FGT Tablet PC device */
+	{"FUJ02E9"},		/* Fujitsu Wacom 1FGT Tablet PC device */
+	{"LTS0001"},		/* LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in disguise) */
+	{"WCI0003"},		/* Rockwell's (PORALiNK) 33600 INT PNP */
+	{"WEC1022"},		/* Winbond CIR port, should not be probed. We should keep track of it to prevent the legacy serial driver from probing it */
+	{"PNPCXXX"},		/* Unknown PnP modems */
+	{"PNPDXXX"},		/* More unknown PnP modems */
+	/* scl200wdt */
+	{"NSC0800"},		/* National Semiconductor PC87307/PC97307 watchdog component */
+	/* mpu401 */
+	{"PNPb006"},
+	/* cs423x-pnpbios */
+	{"CSC0100"},
+	{"CSC0000"},
+	{"GIM0100"},		/* Guillemot Turtlebeach something appears to be cs4232 compatible */
+	/* es18xx-pnpbios */
+	{"ESS1869"},
+	{"ESS1879"},
+	/* snd-opl3sa2-pnpbios */
+	{"YMH0021"},
+	{"NMX2210"},		/* Gateway Solo 2500 */
+	{""},
+};
+
+static int acpi_pnp_scan_handler_attach(struct acpi_device *adev,
+					const struct acpi_device_id *id)
+{
+	return 1;
+}
+
+static int acpi_pnp_scan_handler_match(char *devid, char *handlerid)
+{
+	int i;
+
+	if (memcmp(devid, handlerid, 3))
+		return 0;
+
+	for (i = 3; i < 7; i++) {
+		/* Not a HEX value */
+		if (!((devid[i] >= '0' && devid[i] <= '9') ||
+		      (devid[i] > 'A' && devid[i] <= 'F')))
+			return 0;
+
+		/* Not a wildcard and not match */
+		if ((handlerid[i] != 'X') &&
+		    toupper(devid[i]) != toupper(handlerid[i]))
+			return 0;
+	}
+	return 1;
+}
+
+static struct acpi_scan_handler acpi_pnp_handler = {
+	.ids = acpi_pnp_device_ids,
+	.match = acpi_pnp_scan_handler_match,
+	.attach = acpi_pnp_scan_handler_attach,
+};
+
+/*
+ * For CMOS RTC devices, the acpi pnp spcan handler does not work because
+ * there is already a cmos rtc scan handler installed, thus we need to
+ * check those devices and enumerate them to PNP bus explicitly.
+ */
+static int is_cmos_rtc_device(struct acpi_device *adev)
+{
+	struct acpi_device_id ids[] = {
+		{ "PNP0B00" },
+		{ "PNP0B01" },
+		{ "PNP0B02" },
+		{""},
+	};
+	return !acpi_match_device_ids(adev, ids);
+}
+
+bool acpi_is_pnp_device(struct acpi_device *device)
+{
+	if (device->handler == &acpi_pnp_handler)
+		return true;
+	if (is_cmos_rtc_device(device))
+		return true;
+	return false;
+}
+EXPORT_SYMBOL_GPL(acpi_is_pnp_device);
+
+void __init acpi_pnp_init(void)
+{
+	acpi_scan_add_handler(&acpi_pnp_handler);
+}
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 9573913..3a12866 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -30,6 +30,7 @@ void acpi_pci_root_init(void);
 void acpi_pci_link_init(void);
 void acpi_processor_init(void);
 void acpi_platform_init(void);
+void acpi_pnp_init(void);
 int acpi_sysfs_init(void);
 #ifdef CONFIG_ACPI_CONTAINER
 void acpi_container_init(void);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index e46e51c..c82ab73 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2251,6 +2251,7 @@ int __init acpi_scan_init(void)
 	acpi_cmos_rtc_init();
 	acpi_container_init();
 	acpi_memory_hotplug_init();
+	acpi_pnp_init();
 
 	mutex_lock(&acpi_scan_lock);
 	/*
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index c31aa07..b81448b 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -30,26 +30,6 @@
 
 static int num;
 
-/* We need only to blacklist devices that have already an acpi driver that
- * can't use pnp layer. We don't need to blacklist device that are directly
- * used by the kernel (PCI root, ...), as it is harmless and there were
- * already present in pnpbios. But there is an exception for devices that
- * have irqs (PIC, Timer) because we call acpi_register_gsi.
- * Finally, only devices that have a CRS method need to be in this list.
- */
-static struct acpi_device_id excluded_id_list[] __initdata = {
-	{"PNP0C09", 0},		/* EC */
-	{"PNP0C0F", 0},		/* Link device */
-	{"PNP0000", 0},		/* PIC */
-	{"PNP0100", 0},		/* Timer */
-	{"", 0},
-};
-
-static inline int __init is_exclusive_device(struct acpi_device *dev)
-{
-	return (!acpi_match_device_ids(dev, excluded_id_list));
-}
-
 /*
  * Compatible Device IDs
  */
@@ -266,7 +246,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
 	if (!pnpid)
 		return 0;
 
-	if (is_exclusive_device(device) || !device->status.present)
+	if (!device->status.present)
 		return 0;
 
 	dev = pnp_alloc_dev(&pnpacpi_protocol, num, pnpid);
@@ -326,10 +306,10 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
 {
 	struct acpi_device *device;
 
-	if (!acpi_bus_get_device(handle, &device))
-		pnpacpi_add_device(device);
-	else
+	if (acpi_bus_get_device(handle, &device))
 		return AE_CTRL_DEPTH;
+	if (acpi_is_pnp_device(device))
+		pnpacpi_add_device(device);
 	return AE_OK;
 }
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 7a8f2cd..27e2d29 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -184,6 +184,8 @@ extern int ec_transaction(u8 command,
                           u8 *rdata, unsigned rdata_len);
 extern acpi_handle ec_get_handle(void);
 
+extern bool acpi_is_pnp_device(struct acpi_device *);
+
 #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE)
 
 typedef void (*wmi_notify_handler) (u32 value, void *context);
-- 
1.8.3.2


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

* [PATCH V7 03/11] ACPI: remove ids that does not comply with the ACPI PNP id rule
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 01/11] ACPI: introduce .match() callback for ACPI scan handler Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 02/11] PNPACPI: use whilte list for pnpacpi device enumeration Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 04/11] ACPI: remove unsupported serial PNP ids from acpi pnp scan handler id lsit Zhang Rui
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

The acpi pnp scan handler id list just copies all the ids from all the
struct pnp_device_id instances, but some of them do not
comply with the ACPI PNP id rule (3 Alpha Charactors + 4 Hex numbers).

For those ids, the coressponding devices will never be enumerated
via ACPI, so it is safe to remove those ids from the PNPACPI white list.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/acpi_pnp.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
index 57d14ed..d206616 100644
--- a/drivers/acpi/acpi_pnp.c
+++ b/drivers/acpi/acpi_pnp.c
@@ -33,10 +33,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
 	/* ide   */
 	{"PNP0600"},		/* Generic ESDI/IDE/ATA compatible hard disk controller */
 	/* ns558 */
-	{"@P@0001"},		/* ALS 100 */
-	{"@P@0020"},		/* ALS 200 */
-	{"@P@1001"},		/* ALS 100+ */
-	{"@P@2001"},		/* ALS 120 */
 	{"ASB16fd"},		/* AdLib NSC16 */
 	{"AZT3001"},		/* AZT1008 */
 	{"CDC0001"},		/* Opl3-SAx */
-- 
1.8.3.2


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

* [PATCH V7 04/11] ACPI: remove unsupported serial PNP ids from acpi pnp scan handler id lsit
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
                   ` (2 preceding siblings ...)
  2014-05-22 18:02 ` [PATCH V7 03/11] ACPI: remove ids that does not comply with the ACPI PNP id rule Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 05/11] ACPI: allow scan handlers without .attach() callback Zhang Rui
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

The "serial" pnp driver supports some unknown PNP modems (PNPCXXX/PNPDXXX)
by matching magic strings in the pnp device name or the pnp device card name.

ACPI enumerated PNP device neither supports pnp card, nor supports those magic
strings in its device name, which means this mechamism never works for ACPI
enumerated PNPCXXX/PNPDXXX devices.
So it is safe to remove those two ids from the ACPI pnp scan handler id list.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/acpi_pnp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
index d206616..a563a27 100644
--- a/drivers/acpi/acpi_pnp.c
+++ b/drivers/acpi/acpi_pnp.c
@@ -300,8 +300,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
 	{"LTS0001"},		/* LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in disguise) */
 	{"WCI0003"},		/* Rockwell's (PORALiNK) 33600 INT PNP */
 	{"WEC1022"},		/* Winbond CIR port, should not be probed. We should keep track of it to prevent the legacy serial driver from probing it */
-	{"PNPCXXX"},		/* Unknown PnP modems */
-	{"PNPDXXX"},		/* More unknown PnP modems */
 	/* scl200wdt */
 	{"NSC0800"},		/* National Semiconductor PC87307/PC97307 watchdog component */
 	/* mpu401 */
-- 
1.8.3.2


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

* [PATCH V7 05/11] ACPI: allow scan handlers without .attach() callback
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
                   ` (3 preceding siblings ...)
  2014-05-22 18:02 ` [PATCH V7 04/11] ACPI: remove unsupported serial PNP ids from acpi pnp scan handler id lsit Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 06/11] ACPI: always register container scan handler even if CONFIG_ACPI_CONTAINER is cleared Zhang Rui
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

Devices that can be attached to scan handlers, are kind of different from
the others, because they are known that some special actions should be taken.

But we do not mark this difference when the configurable scan handlers
are compiled out. This is harmless currently, but it will be when
we want to take some common actions to the other "non-special" devices,
which will be done in a later patch.

This patch makes .attach() of the acpi scan handler optional.
So that the configurable scan handlers can provide NULL .attach() callback
when not supported.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/scan.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index c82ab73..e9c2f6f 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -84,7 +84,7 @@ EXPORT_SYMBOL_GPL(acpi_initialize_hp_context);
 
 int acpi_scan_add_handler(struct acpi_scan_handler *handler)
 {
-	if (!handler || !handler->attach)
+	if (!handler)
 		return -EINVAL;
 
 	list_add_tail(&handler->list_node, &acpi_scan_handlers_list);
@@ -2066,6 +2066,12 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
 	return AE_OK;
 }
 
+static int acpi_scan_handler_dummy_attach(struct acpi_device *device,
+				const struct acpi_device_id *devid)
+{
+	return 1;
+}
+
 static int acpi_scan_attach_handler(struct acpi_device *device)
 {
 	struct acpi_hardware_id *hwid;
@@ -2078,7 +2084,10 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
 		handler = acpi_scan_match_handler(hwid->id, &devid);
 		if (handler) {
 			device->handler = handler;
-			ret = handler->attach(device, devid);
+			if (handler->attach)
+				ret = handler->attach(device, devid);
+			else
+				ret = acpi_scan_handler_dummy_attach(device, devid);
 			if (ret > 0)
 				break;
 
-- 
1.8.3.2


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

* [PATCH V7 06/11] ACPI: always register container scan handler even if CONFIG_ACPI_CONTAINER is cleared
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
                   ` (4 preceding siblings ...)
  2014-05-22 18:02 ` [PATCH V7 05/11] ACPI: allow scan handlers without .attach() callback Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 07/11] ACPI: always register memory hotplug scan handler even if CONFIG_ACPI_HOTPLUG_MEMORY " Zhang Rui
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

The new ACPI device enumeration mechanism, which will be introduced
in a later patch, will enumerate the _HID devices w/o any scan
handler attached to platform bus.
This means that, for the devices that are attached to a configurable
scan handler, we should make sure no platform devices would be
created for them even if the scan handler is compiled out.

Fix this problem for container devices by always registering the
container scan handler, but with meaningful callbacks
only when CONFIG_ACPI_CONTAINER is set.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/Makefile    |  2 +-
 drivers/acpi/container.c | 18 ++++++++++++------
 drivers/acpi/internal.h  |  4 ----
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 9a43893..5611a07 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -63,7 +63,7 @@ obj-$(CONFIG_ACPI_FAN)		+= fan.o
 obj-$(CONFIG_ACPI_VIDEO)	+= video.o
 obj-$(CONFIG_ACPI_PCI_SLOT)	+= pci_slot.o
 obj-$(CONFIG_ACPI_PROCESSOR)	+= processor.o
-obj-$(CONFIG_ACPI_CONTAINER)	+= container.o
+obj-y				+= container.o
 obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
 obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
 obj-$(CONFIG_ACPI_BATTERY)	+= battery.o
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 63119d0..b78f52e 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -41,6 +41,8 @@ static const struct acpi_device_id container_device_ids[] = {
 	{"", 0},
 };
 
+#ifdef CONFIG_ACPI_CONTAINER
+
 static int acpi_container_offline(struct container_dev *cdev)
 {
 	struct acpi_device *adev = ACPI_COMPANION(&cdev->dev);
@@ -97,17 +99,21 @@ static void container_device_detach(struct acpi_device *adev)
 		device_unregister(dev);
 }
 
+#endif /* CONFIG_ACPI_CONTAINER */
+
 static struct acpi_scan_handler container_handler = {
 	.ids = container_device_ids,
-	.attach = container_device_attach,
-	.detach = container_device_detach,
-	.hotplug = {
-		.enabled = true,
-		.demand_offline = true,
-	},
 };
 
 void __init acpi_container_init(void)
 {
+#ifdef CONFIG_ACPI_CONTAINER
+	container_handler.attach = container_device_attach;
+	container_handler.detach = container_device_detach;
+	container_handler.hotplug.enabled = true;
+	container_handler.hotplug.demand_offline = true;
 	acpi_scan_add_handler_with_hotplug(&container_handler, "container");
+#else
+	acpi_scan_add_handler(&container_handler);
+#endif /* CONFIG_ACPI_CONTAINER */
 }
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 3a12866..499908e 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -32,11 +32,7 @@ void acpi_processor_init(void);
 void acpi_platform_init(void);
 void acpi_pnp_init(void);
 int acpi_sysfs_init(void);
-#ifdef CONFIG_ACPI_CONTAINER
 void acpi_container_init(void);
-#else
-static inline void acpi_container_init(void) {}
-#endif
 #ifdef CONFIG_ACPI_DOCK
 void register_dock_dependent_device(struct acpi_device *adev,
 				    acpi_handle dshandle);
-- 
1.8.3.2


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

* [PATCH V7 07/11] ACPI: always register memory hotplug scan handler even if CONFIG_ACPI_HOTPLUG_MEMORY is cleared
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
                   ` (5 preceding siblings ...)
  2014-05-22 18:02 ` [PATCH V7 06/11] ACPI: always register container scan handler even if CONFIG_ACPI_CONTAINER is cleared Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS " Zhang Rui
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

The new ACPI device enumeration mechanism, which will be introduced
in a later patch, will enumerate the _HID devices w/o any scan
handler attached to platform bus.
This means that, for the devices that are attached to a configurable
scan handler, we should make sure no platform devices would be
created for them even if the scan handler is compiled out.

Fix this problem for memory hotplug devices by always register the
memery hotplug scan handler, but with meaningful callbacks
only when CONFIG_ACPI_HOTPLUG_MEMORY is set.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/Makefile          |  2 +-
 drivers/acpi/acpi_memhotplug.c | 46 ++++++++++++++++++++++--------------------
 drivers/acpi/internal.h        |  6 +-----
 3 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 5611a07..171efc2 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -65,7 +65,7 @@ obj-$(CONFIG_ACPI_PCI_SLOT)	+= pci_slot.o
 obj-$(CONFIG_ACPI_PROCESSOR)	+= processor.o
 obj-y				+= container.o
 obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
-obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
+obj-y				+= acpi_memhotplug.o
 obj-$(CONFIG_ACPI_BATTERY)	+= battery.o
 obj-$(CONFIG_ACPI_SBS)		+= sbshc.o
 obj-$(CONFIG_ACPI_SBS)		+= sbs.o
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index b67be85..c54f824 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -44,15 +44,6 @@
 
 ACPI_MODULE_NAME("acpi_memhotplug");
 
-/* Memory Device States */
-#define MEMORY_INVALID_STATE	0
-#define MEMORY_POWER_ON_STATE	1
-#define MEMORY_POWER_OFF_STATE	2
-
-static int acpi_memory_device_add(struct acpi_device *device,
-				  const struct acpi_device_id *not_used);
-static void acpi_memory_device_remove(struct acpi_device *device);
-
 static const struct acpi_device_id memory_device_ids[] = {
 	{ACPI_MEMORY_DEVICE_HID, 0},
 	{"", 0},
@@ -60,13 +51,15 @@ static const struct acpi_device_id memory_device_ids[] = {
 
 static struct acpi_scan_handler memory_device_handler = {
 	.ids = memory_device_ids,
-	.attach = acpi_memory_device_add,
-	.detach = acpi_memory_device_remove,
-	.hotplug = {
-		.enabled = true,
-	},
 };
 
+#ifdef CONFIG_ACPI_HOTPLUG_MEMORY
+
+/* Memory Device States */
+#define MEMORY_INVALID_STATE	0
+#define MEMORY_POWER_ON_STATE	1
+#define MEMORY_POWER_OFF_STATE	2
+
 struct acpi_memory_info {
 	struct list_head list;
 	u64 start_addr;		/* Memory Range start physical addr */
@@ -362,17 +355,26 @@ static void acpi_memory_device_remove(struct acpi_device *device)
 
 static bool __initdata acpi_no_memhotplug;
 
-void __init acpi_memory_hotplug_init(void)
-{
-	if (acpi_no_memhotplug)
-		return;
-
-	acpi_scan_add_handler_with_hotplug(&memory_device_handler, "memory");
-}
-
 static int __init disable_acpi_memory_hotplug(char *str)
 {
 	acpi_no_memhotplug = true;
 	return 1;
 }
 __setup("acpi_no_memhotplug", disable_acpi_memory_hotplug);
+
+#endif
+
+void __init acpi_memory_hotplug_init(void)
+{
+#ifdef CONFIG_ACPI_HOTPLUG_MEMORY
+	if (!acpi_no_memhotplug) {
+		memory_device_handler.attach = acpi_memory_device_add;
+		memory_device_handler.detach = acpi_memory_device_remove;
+		memory_device_handler.hotplug.enabled = true;
+		acpi_scan_add_handler_with_hotplug(&memory_device_handler,
+						"memory");
+		return;
+	}
+#endif
+	acpi_scan_add_handler(&memory_device_handler);
+}
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 499908e..4a9e999 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -33,6 +33,7 @@ void acpi_platform_init(void);
 void acpi_pnp_init(void);
 int acpi_sysfs_init(void);
 void acpi_container_init(void);
+void acpi_memory_hotplug_init(void);
 #ifdef CONFIG_ACPI_DOCK
 void register_dock_dependent_device(struct acpi_device *adev,
 				    acpi_handle dshandle);
@@ -44,11 +45,6 @@ static inline void register_dock_dependent_device(struct acpi_device *adev,
 static inline int dock_notify(struct acpi_device *adev, u32 event) { return -ENODEV; }
 static inline void acpi_dock_add(struct acpi_device *adev) {}
 #endif
-#ifdef CONFIG_ACPI_HOTPLUG_MEMORY
-void acpi_memory_hotplug_init(void);
-#else
-static inline void acpi_memory_hotplug_init(void) {}
-#endif
 #ifdef CONFIG_X86
 void acpi_cmos_rtc_init(void);
 #else
-- 
1.8.3.2


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

* [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS is cleared
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
                   ` (6 preceding siblings ...)
  2014-05-22 18:02 ` [PATCH V7 07/11] ACPI: always register memory hotplug scan handler even if CONFIG_ACPI_HOTPLUG_MEMORY " Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-26 10:56   ` Mika Westerberg
  2014-05-22 18:02 ` [PATCH V7 09/11] ACPI: introduce platform_id flag Zhang Rui
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

The new ACPI device enumeration mechanism, which will be introduced
in a later patch, will enumerate the _HID devices w/o any scan
handler attached to platform bus.
This means that, for the devices that are attached to a configurable
scan handler, we should make sure no platform devices would be
created for them even if the scan handler is compiled out.

Fix this problem for lpss devices by always register the lpss scan handler,
but with meaningful callbacks only when CONFIG_X86_INTEL_LPSS is set.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/Makefile    |  2 +-
 drivers/acpi/acpi_lpss.c | 63 ++++++++++++++++++++++++++++++------------------
 drivers/acpi/internal.h  |  4 ---
 3 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 171efc2..605eff7 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -39,7 +39,7 @@ acpi-y				+= processor_core.o
 acpi-y				+= ec.o
 acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
 acpi-y				+= pci_root.o pci_link.o pci_irq.o
-acpi-$(CONFIG_X86_INTEL_LPSS)	+= acpi_lpss.o
+acpi-y				+= acpi_lpss.o
 acpi-y				+= acpi_platform.o
 acpi-y				+= acpi_pnp.o
 acpi-y				+= power.o
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 69e29f4..bb5b3f2 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -24,6 +24,8 @@
 
 ACPI_MODULE_NAME("acpi_lpss");
 
+#ifdef CONFIG_X86_INTEL_LPSS
+
 #define LPSS_CLK_SIZE	0x04
 #define LPSS_LTR_SIZE	0x18
 
@@ -159,40 +161,50 @@ static struct lpss_device_desc byt_i2c_dev_desc = {
 	.shared_clock = &i2c_clock,
 };
 
+#define LPSS_PTR(desc) ((unsigned long)&desc)
+
+#else
+
+#define LPSS_PTR(desc) 0
+
+#endif
+
 static const struct acpi_device_id acpi_lpss_device_ids[] = {
 	/* Generic LPSS devices */
-	{ "INTL9C60", (unsigned long)&lpss_dma_desc },
+	{ "INTL9C60", LPSS_PTR(lpss_dma_desc) },
 
 	/* Lynxpoint LPSS devices */
-	{ "INT33C0", (unsigned long)&lpt_dev_desc },
-	{ "INT33C1", (unsigned long)&lpt_dev_desc },
-	{ "INT33C2", (unsigned long)&lpt_dev_desc },
-	{ "INT33C3", (unsigned long)&lpt_dev_desc },
-	{ "INT33C4", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT33C5", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT33C6", (unsigned long)&lpt_sdio_dev_desc },
+	{ "INT33C0", LPSS_PTR(lpt_dev_desc) },
+	{ "INT33C1", LPSS_PTR(lpt_dev_desc) },
+	{ "INT33C2", LPSS_PTR(lpt_dev_desc) },
+	{ "INT33C3", LPSS_PTR(lpt_dev_desc) },
+	{ "INT33C4", LPSS_PTR(lpt_uart_dev_desc) },
+	{ "INT33C5", LPSS_PTR(lpt_uart_dev_desc) },
+	{ "INT33C6", LPSS_PTR(lpt_sdio_dev_desc) },
 	{ "INT33C7", },
 
 	/* BayTrail LPSS devices */
-	{ "80860F09", (unsigned long)&byt_pwm_dev_desc },
-	{ "80860F0A", (unsigned long)&byt_uart_dev_desc },
-	{ "80860F0E", (unsigned long)&byt_spi_dev_desc },
-	{ "80860F14", (unsigned long)&byt_sdio_dev_desc },
-	{ "80860F41", (unsigned long)&byt_i2c_dev_desc },
+	{ "80860F09", LPSS_PTR(byt_pwm_dev_desc) },
+	{ "80860F0A", LPSS_PTR(byt_uart_dev_desc) },
+	{ "80860F0E", LPSS_PTR(byt_spi_dev_desc) },
+	{ "80860F14", LPSS_PTR(byt_sdio_dev_desc) },
+	{ "80860F41", LPSS_PTR(byt_i2c_dev_desc) },
 	{ "INT33B2", },
 
-	{ "INT3430", (unsigned long)&lpt_dev_desc },
-	{ "INT3431", (unsigned long)&lpt_dev_desc },
-	{ "INT3432", (unsigned long)&lpt_dev_desc },
-	{ "INT3433", (unsigned long)&lpt_dev_desc },
-	{ "INT3434", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT3435", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT3436", (unsigned long)&lpt_sdio_dev_desc },
+	{ "INT3430", LPSS_PTR(lpt_dev_desc) },
+	{ "INT3431", LPSS_PTR(lpt_dev_desc) },
+	{ "INT3432", LPSS_PTR(lpt_dev_desc) },
+	{ "INT3433", LPSS_PTR(lpt_dev_desc) },
+	{ "INT3434", LPSS_PTR(lpt_uart_dev_desc) },
+	{ "INT3435", LPSS_PTR(lpt_uart_dev_desc) },
+	{ "INT3436", LPSS_PTR(lpt_sdio_dev_desc) },
 	{ "INT3437", },
 
 	{ }
 };
 
+#ifdef CONFIG_X86_INTEL_LPSS
+
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
 	struct resource r;
@@ -503,18 +515,23 @@ static void acpi_lpss_unbind(struct device *dev)
 {
 	dev->power.set_latency_tolerance = NULL;
 }
+#endif /* CONFIG_X86_INTEL_LPSS */
 
 static struct acpi_scan_handler lpss_handler = {
 	.ids = acpi_lpss_device_ids,
-	.attach = acpi_lpss_create_device,
-	.bind = acpi_lpss_bind,
-	.unbind = acpi_lpss_unbind,
 };
 
 void __init acpi_lpss_init(void)
 {
+#ifdef CONFIG_X86_INTEL_LPSS
 	if (!lpt_clk_init()) {
 		bus_register_notifier(&platform_bus_type, &acpi_lpss_nb);
+		lpss_handler.attach = acpi_lpss_create_device;
+		lpss_handler.bind = acpi_lpss_bind;
+		lpss_handler.unbind = acpi_lpss_unbind;
 		acpi_scan_add_handler(&lpss_handler);
+		return;
 	}
+#endif
+	acpi_scan_add_handler(&lpss_handler);
 }
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 4a9e999..bc7d102 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -65,11 +65,7 @@ int acpi_debugfs_init(void);
 #else
 static inline void acpi_debugfs_init(void) { return; }
 #endif
-#ifdef CONFIG_X86_INTEL_LPSS
 void acpi_lpss_init(void);
-#else
-static inline void acpi_lpss_init(void) {}
-#endif
 
 acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
 bool acpi_queue_hotplug_work(struct work_struct *work);
-- 
1.8.3.2


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

* [PATCH V7 09/11] ACPI: introduce platform_id flag
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
                   ` (7 preceding siblings ...)
  2014-05-22 18:02 ` [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS " Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-22 18:02 ` [PATCH V7 10/11] ACPI: use platform bus as the default bus for _HID enumeration Zhang Rui
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

Only certain kind of ACPI device objects can be enumerated to platform bus.
These ACPI device objects include
1. ACPI device objects that have _HID control method.
2. some ACPI device objects that have Linux specified HID strings.

In order to distinguish those device objects from the others, a new flag
platform_id and a new function acpi_add_platform_id() are introduced
in this patch.

Currently, only devices with _HID method have this flag set.
If you want platform devices to be created for device objects without _HID,
use acpi_add_platform_id() when adding artificial Linux-specific ID strings
to them.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/scan.c     | 9 ++++++++-
 include/acpi/acpi_bus.h | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index e9c2f6f..6d50916 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1730,6 +1730,13 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
 	pnp->type.hardware_id = 1;
 }
 
+static void acpi_add_platform_id(struct acpi_device_pnp *pnp,
+				 const char *dev_id)
+{
+	acpi_add_id(pnp, dev_id);
+	pnp->type.platform_id = 1;
+}
+
 /*
  * Old IBM workstations have a DSDT bug wherein the SMBus object
  * lacks the SMBUS01 HID and the methods do not have the necessary "_"
@@ -1794,7 +1801,7 @@ 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);
+			acpi_add_platform_id(pnp, info->hardware_id.string);
 		if (info->valid & ACPI_VALID_CID) {
 			cid_list = &info->compatible_id_list;
 			for (i = 0; i < cid_list->count; i++)
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index ba679af..ec92ad3 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -233,7 +233,8 @@ struct acpi_hardware_id {
 struct acpi_pnp_type {
 	u32 hardware_id:1;
 	u32 bus_address:1;
-	u32 reserved:30;
+	u32 platform_id:1;
+	u32 reserved:29;
 };
 
 struct acpi_device_pnp {
-- 
1.8.3.2


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

* [PATCH V7 10/11] ACPI: use platform bus as the default bus for _HID enumeration
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
                   ` (8 preceding siblings ...)
  2014-05-22 18:02 ` [PATCH V7 09/11] ACPI: introduce platform_id flag Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-26 10:21   ` Mika Westerberg
  2014-05-22 18:02 ` [PATCH V7 11/11] ACPI: introduce acpi platform exclude id list Zhang Rui
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
  11 siblings, 1 reply; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

Because of the growing demand for enumerating ACPI devices to
platform bus, this patch changes the code to enumerate ACPI
devices to platform bus by default, if the device
1. has _HID.
2. does not have a scan handler attached.
3. is not SPB slave device, which should be enumerated by its parent.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/acpi_platform.c | 28 ----------------------------
 drivers/acpi/scan.c          | 43 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index dbfe49e..33376a9 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -22,24 +22,6 @@
 
 ACPI_MODULE_NAME("platform");
 
-/*
- * The following ACPI IDs are known to be suitable for representing as
- * platform devices.
- */
-static const struct acpi_device_id acpi_platform_device_ids[] = {
-
-	{ "PNP0D40" },
-	{ "ACPI0003" },
-	{ "VPC2004" },
-	{ "BCM4752" },
-
-	/* Intel Smart Sound Technology */
-	{ "INT33C8" },
-	{ "80860F28" },
-
-	{ }
-};
-
 /**
  * acpi_create_platform_device - Create platform device for ACPI device node
  * @adev: ACPI device node to create a platform device for.
@@ -125,13 +107,3 @@ int acpi_create_platform_device(struct acpi_device *adev,
 	kfree(resources);
 	return 1;
 }
-
-static struct acpi_scan_handler platform_handler = {
-	.ids = acpi_platform_device_ids,
-	.attach = acpi_create_platform_device,
-};
-
-void __init acpi_platform_init(void)
-{
-	acpi_scan_add_handler(&platform_handler);
-}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 6d50916..c061284 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2079,6 +2079,45 @@ static int acpi_scan_handler_dummy_attach(struct acpi_device *device,
 	return 1;
 }
 
+static int acpi_check_spb_slave(struct acpi_resource *ares, void *data)
+{
+	int *is_spb_slave = data;
+
+	if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
+		*is_spb_slave = 1;
+		/* no need to do more checking */
+		return -1;
+	}
+	return 1;
+}
+
+static void acpi_do_default_enumeration(struct acpi_device *device)
+{
+	struct list_head resource_list;
+	int is_spb_slave = 0;
+
+	/* Do not do enumeration for device object w/o platform_id */
+	if (!device->pnp.type.platform_id)
+		return;
+
+	/* Do not do enumeration for device object with scan handler attached */
+	if (device->handler)
+		return;
+
+	/*
+	 * Do not do enemeration for SPB slaves
+	 * as they will be enuerated by their parents
+	 */
+	INIT_LIST_HEAD(&resource_list);
+	acpi_dev_get_resources(device, &resource_list,
+				acpi_check_spb_slave, &is_spb_slave);
+	acpi_dev_free_resource_list(&resource_list);
+	if (is_spb_slave)
+		return;
+
+	acpi_create_platform_device(device, NULL);
+}
+
 static int acpi_scan_attach_handler(struct acpi_device *device)
 {
 	struct acpi_hardware_id *hwid;
@@ -2103,6 +2142,9 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
 				break;
 		}
 	}
+
+	acpi_do_default_enumeration(device);
+
 	return ret;
 }
 
@@ -2262,7 +2304,6 @@ int __init acpi_scan_init(void)
 	acpi_pci_root_init();
 	acpi_pci_link_init();
 	acpi_processor_init();
-	acpi_platform_init();
 	acpi_lpss_init();
 	acpi_cmos_rtc_init();
 	acpi_container_init();
-- 
1.8.3.2


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

* [PATCH V7 11/11] ACPI: introduce acpi platform exclude id list
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
                   ` (9 preceding siblings ...)
  2014-05-22 18:02 ` [PATCH V7 10/11] ACPI: use platform bus as the default bus for _HID enumeration Zhang Rui
@ 2014-05-22 18:02 ` Zhang Rui
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
  11 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-22 18:02 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: bhelgaas, matthew.garrett, rafael.j.wysocki, dmitry.torokhov,
	mika.westerberg, Zhang Rui

For ACPI PIC (PNP0000), Timer (PNP0100) and DMA controller (PNP0200)
device objects, although they have _HID control method, but they
should not be enumerated to platform bus, because there will never be
any platform drivers for them.

Thus an exclude id list is introduced in this patch to prevent
those platform device nodes from being created.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/acpi_platform.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 33376a9..db89480 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -22,6 +22,18 @@
 
 ACPI_MODULE_NAME("platform");
 
+static const struct acpi_device_id excluded_id_list[] = {
+	{"PNP0000", 0},	/* PIC */
+	{"PNP0100", 0},	/* Timer */
+	{"PNP0200", 0}, /* AT DMA Controller */
+	{"", 0},
+};
+
+static bool is_exclusive_device(struct acpi_device *dev)
+{
+	return !acpi_match_device_ids(dev, excluded_id_list);
+}
+
 /**
  * acpi_create_platform_device - Create platform device for ACPI device node
  * @adev: ACPI device node to create a platform device for.
@@ -48,6 +60,9 @@ int acpi_create_platform_device(struct acpi_device *adev,
 	if (adev->physical_node_count)
 		return 0;
 
+	if (is_exclusive_device(adev))
+		return 0;
+
 	INIT_LIST_HEAD(&resource_list);
 	count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
 	if (count < 0) {
-- 
1.8.3.2


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

* Re: [PATCH V7 02/11] PNPACPI: use whilte list for pnpacpi device enumeration
  2014-05-22 18:02 ` [PATCH V7 02/11] PNPACPI: use whilte list for pnpacpi device enumeration Zhang Rui
@ 2014-05-22 18:14   ` Bjorn Helgaas
  2014-05-23  0:00     ` Zhang Rui
  0 siblings, 1 reply; 40+ messages in thread
From: Bjorn Helgaas @ 2014-05-22 18:14 UTC (permalink / raw)
  To: Zhang Rui
  Cc: linux-acpi, linux-kernel, Matthew Garrett, Rafael J. Wysocki,
	Dmitry Torokhov, Mika Westerberg

"white" is misspelled in the subject line.  I mentioned this before.

On Thu, May 22, 2014 at 12:02 PM, Zhang Rui <rui.zhang@intel.com> wrote:
> ACPI can be used to enumerate PNP devices, but the code does not
> handle this in a good manner.
> ...

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

* Re: [PATCH V7 02/11] PNPACPI: use whilte list for pnpacpi device enumeration
  2014-05-22 18:14   ` Bjorn Helgaas
@ 2014-05-23  0:00     ` Zhang Rui
  0 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-23  0:00 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-acpi, linux-kernel, Matthew Garrett, Rafael J. Wysocki,
	Dmitry Torokhov, Mika Westerberg

On Thu, 2014-05-22 at 12:14 -0600, Bjorn Helgaas wrote:
> "white" is misspelled in the subject line.  I mentioned this before.
> 
oops, forgot to update, thanks for the reminder.

>From a8e08d7a6e050f31cec069cc1704f21214b90566 Mon Sep 17 00:00:00 2001
From: Zhang Rui <rui.zhang@intel.com>
Date: Tue, 8 Apr 2014 00:06:49 +0800
Subject: [PATCH V7 02/11] PNPACPI: use white list for pnpacpi device
 enumeration

ACPI can be used to enumerate PNP devices, but the code does not
handle this in a good manner.

Currently, if an ACPI device
1. has _CRS method,
2. has an identifications of
   "three capital charactors followed by four hex numbers",
3. is not in the excluded id list,
it is enumerated to PNP bus.

So actually, PNP bus is used as the default bus for enumerating _HID devices.

But, nowadays, more and more _HID devices are needed to be enumerate to
platform bus instead. And a white list is used for those devices to avoid
overlapping with PNP bus.
The problem is that this list is continuously growing.

So, a solution that uses platform bus as the default bus for _HID enumeration
is preferred.
In order to do this, this patch changes the way of enumerating PNP devices.
As the first step, we use a white list (scan handler) to create PNP devices
instead. This white list contains all the pnp_device_id strings in all the pnp
drivers, thus this change is transparent to PNP core and all the PNP drivers.

Note: I just grep all the id strings in all pnp_device_id instances and
      copy them to the new white list, with a few changes to the comments
      only, to follow the format of:

      /* driver name, or file name if not a PNP driver */
      {"id-string"}, /* optional comments for the id-string */
      ...

Note: the PNPACPI devices are created in two step,
      1. mark the PNPACPI devices by the acpi pnp scan handler.
      2. create the PNPACPI devices in PNPACPI code in a fs_initcall()
      In this case, if PNP/PNPACPI is not set or "pnpacpi=off" kernel option
      is used, the acpi pnp scan handler is still there, to prevent those
      PNPACPI devices from being created to platform bus.

Note: For CMOS RTC devices, the acpi pnp scan handler does not work because
      there is already a cmos rtc scan handler installed, thus we need to
      check those devices and enumerate them to PNP bus explicitly.
      Plus, the cmos rtc scan handler needs to return 1 so that it will not
      be enumerated to platform bus.

TODO: Reduce this PNPACPI white list by
      1. remove the ids for the devices that are never enumerated via ACPI
      2. remove the ids and convert the drivers to platform bus drivers
         for the devices that are not PNP devices in nature.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/Makefile        |   1 +
 drivers/acpi/acpi_cmos_rtc.c |   2 +-
 drivers/acpi/acpi_pnp.c      | 388 +++++++++++++++++++++++++++++++++++++++++++
 drivers/acpi/internal.h      |   1 +
 drivers/acpi/scan.c          |   1 +
 drivers/pnp/pnpacpi/core.c   |  28 +---
 include/linux/acpi.h         |   2 +
 7 files changed, 398 insertions(+), 25 deletions(-)
 create mode 100644 drivers/acpi/acpi_pnp.c

diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 0331f91..9a43893 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -41,6 +41,7 @@ acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
 acpi-y				+= pci_root.o pci_link.o pci_irq.o
 acpi-$(CONFIG_X86_INTEL_LPSS)	+= acpi_lpss.o
 acpi-y				+= acpi_platform.o
+acpi-y				+= acpi_pnp.o
 acpi-y				+= power.o
 acpi-y				+= event.o
 acpi-y				+= sysfs.o
diff --git a/drivers/acpi/acpi_cmos_rtc.c b/drivers/acpi/acpi_cmos_rtc.c
index 961b45d..2da8660 100644
--- a/drivers/acpi/acpi_cmos_rtc.c
+++ b/drivers/acpi/acpi_cmos_rtc.c
@@ -68,7 +68,7 @@ static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev,
 		return -ENODEV;
 	}
 
-	return 0;
+	return 1;
 }
 
 static void acpi_remove_cmos_rtc_space_handler(struct acpi_device *adev)
diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
new file mode 100644
index 0000000..57d14ed
--- /dev/null
+++ b/drivers/acpi/acpi_pnp.c
@@ -0,0 +1,388 @@
+/*
+ * ACPI support for PNP bus type
+ *
+ * Copyright (C) 2014, Intel Corporation
+ * Authors: Zhang Rui <rui.zhang@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/module.h>
+
+static const struct acpi_device_id acpi_pnp_device_ids[] = {
+	/* pata_isapnp */
+	{"PNP0600"},		/* Generic ESDI/IDE/ATA compatible hard disk controller */
+	/* floppy */
+	{"PNP0700"},
+	/* ipmi_si */
+	{"IPI0001"},
+	/* tpm_inf_pnp */
+	{"IFX0101"},		/* Infineon TPMs */
+	{"IFX0102"},		/* Infineon TPMs */
+	/*tpm_tis */
+	{"PNP0C31"},		/* TPM */
+	{"ATM1200"},		/* Atmel */
+	{"IFX0102"},		/* Infineon */
+	{"BCM0101"},		/* Broadcom */
+	{"BCM0102"},		/* Broadcom */
+	{"NSC1200"},		/* National */
+	{"ICO0102"},		/* Intel */
+	/* ide   */
+	{"PNP0600"},		/* Generic ESDI/IDE/ATA compatible hard disk controller */
+	/* ns558 */
+	{"@P@0001"},		/* ALS 100 */
+	{"@P@0020"},		/* ALS 200 */
+	{"@P@1001"},		/* ALS 100+ */
+	{"@P@2001"},		/* ALS 120 */
+	{"ASB16fd"},		/* AdLib NSC16 */
+	{"AZT3001"},		/* AZT1008 */
+	{"CDC0001"},		/* Opl3-SAx */
+	{"CSC0001"},		/* CS4232 */
+	{"CSC000f"},		/* CS4236 */
+	{"CSC0101"},		/* CS4327 */
+	{"CTL7001"},		/* SB16 */
+	{"CTL7002"},		/* AWE64 */
+	{"CTL7005"},		/* Vibra16 */
+	{"ENS2020"},		/* SoundscapeVIVO */
+	{"ESS0001"},		/* ES1869 */
+	{"ESS0005"},		/* ES1878 */
+	{"ESS6880"},		/* ES688 */
+	{"IBM0012"},		/* CS4232 */
+	{"OPT0001"},		/* OPTi Audio16 */
+	{"YMH0006"},		/* Opl3-SA */
+	{"YMH0022"},		/* Opl3-SAx */
+	{"PNPb02f"},		/* Generic */
+	/* i8042 kbd */
+	{"PNP0300"},
+	{"PNP0301"},
+	{"PNP0302"},
+	{"PNP0303"},
+	{"PNP0304"},
+	{"PNP0305"},
+	{"PNP0306"},
+	{"PNP0309"},
+	{"PNP030a"},
+	{"PNP030b"},
+	{"PNP0320"},
+	{"PNP0343"},
+	{"PNP0344"},
+	{"PNP0345"},
+	{"CPQA0D7"},
+	/* i8042 aux */
+	{"AUI0200"},
+	{"FJC6000"},
+	{"FJC6001"},
+	{"PNP0f03"},
+	{"PNP0f0b"},
+	{"PNP0f0e"},
+	{"PNP0f12"},
+	{"PNP0f13"},
+	{"PNP0f19"},
+	{"PNP0f1c"},
+	{"SYN0801"},
+	/* fcpnp */
+	{"AVM0900"},
+	/* radio-cadet */
+	{"MSM0c24"},		/* ADS Cadet AM/FM Radio Card */
+	/* radio-gemtek */
+	{"ADS7183"},		/* AOpen FX-3D/Pro Radio */
+	/* radio-sf16fmr2 */
+	{"MFRad13"},		/* tuner subdevice of SF16-FMD2 */
+	/* ene_ir */
+	{"ENE0100"},
+	{"ENE0200"},
+	{"ENE0201"},
+	{"ENE0202"},
+	/* fintek-cir */
+	{"FIT0002"},		/* CIR */
+	/* ite-cir */
+	{"ITE8704"},		/* Default model */
+	{"ITE8713"},		/* CIR found in EEEBox 1501U */
+	{"ITE8708"},		/* Bridged IT8512 */
+	{"ITE8709"},		/* SRAM-Bridged IT8512 */
+	/* nuvoton-cir */
+	{"WEC0530"},		/* CIR */
+	{"NTN0530"},		/* CIR for new chip's pnp id */
+	/* Winbond CIR */
+	{"WEC1022"},
+	/* wbsd */
+	{"WEC0517"},
+	{"WEC0518"},
+	/* Winbond CIR */
+	{"TCM5090"},		/* 3Com Etherlink III (TP) */
+	{"TCM5091"},		/* 3Com Etherlink III */
+	{"TCM5094"},		/* 3Com Etherlink III (combo) */
+	{"TCM5095"},		/* 3Com Etherlink III (TPO) */
+	{"TCM5098"},		/* 3Com Etherlink III (TPC) */
+	{"PNP80f7"},		/* 3Com Etherlink III compatible */
+	{"PNP80f8"},		/* 3Com Etherlink III compatible */
+	/* nsc-ircc */
+	{"NSC6001"},
+	{"HWPC224"},
+	{"IBM0071"},
+	/* smsc-ircc2 */
+	{"SMCf010"},
+	/* sb1000 */
+	{"GIC1000"},
+	/* parport_pc */
+	{"PNP0400"},		/* Standard LPT Printer Port */
+	{"PNP0401"},		/* ECP Printer Port */
+	/* apple-gmux */
+	{"APP000B"},
+	/* fujitsu-laptop.c */
+	{"FUJ02bf"},
+	{"FUJ02B1"},
+	{"FUJ02E3"},
+	/* system */
+	{"PNP0c02"},		/* General ID for reserving resources */
+	{"PNP0c01"},		/* memory controller */
+	/* rtc_cmos */
+	{"PNP0b00"},
+	{"PNP0b01"},
+	{"PNP0b02"},
+	/* c6xdigio */
+	{"PNP0400"},		/* Standard LPT Printer Port */
+	{"PNP0401"},		/* ECP Printer Port */
+	/* ni_atmio.c */
+	{"NIC1900"},
+	{"NIC2400"},
+	{"NIC2500"},
+	{"NIC2600"},
+	{"NIC2700"},
+	/* serial */
+	{"AAC000F"},		/* Archtek America Corp. Archtek SmartLink Modem 3334BT Plug & Play */
+	{"ADC0001"},		/* Anchor Datacomm BV. SXPro 144 External Data Fax Modem Plug & Play */
+	{"ADC0002"},		/* SXPro 288 External Data Fax Modem Plug & Play */
+	{"AEI0250"},		/* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
+	{"AEI1240"},		/* Actiontec ISA PNP 56K X2 Fax Modem */
+	{"AKY1021"},		/* Rockwell 56K ACF II Fax+Data+Voice Modem */
+	{"AZT4001"},		/* AZT3005 PnP SOUND DEVICE */
+	{"BDP3336"},		/* Best Data Products Inc. Smart One 336F PnP Modem */
+	{"BRI0A49"},		/* Boca Complete Ofc Communicator 14.4 Data-FAX */
+	{"BRI1400"},		/* Boca Research 33,600 ACF Modem */
+	{"BRI3400"},		/* Boca 33.6 Kbps Internal FD34FSVD */
+	{"BRI0A49"},		/* Boca 33.6 Kbps Internal FD34FSVD */
+	{"BDP3336"},		/* Best Data Products Inc. Smart One 336F PnP Modem */
+	{"CPI4050"},		/* Computer Peripherals Inc. EuroViVa CommCenter-33.6 SP PnP */
+	{"CTL3001"},		/* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
+	{"CTL3011"},		/* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
+	{"DAV0336"},		/* Davicom ISA 33.6K Modem */
+	{"DMB1032"},		/* Creative Modem Blaster Flash56 DI5601-1 */
+	{"DMB2001"},		/* Creative Modem Blaster V.90 DI5660 */
+	{"ETT0002"},		/* E-Tech CyberBULLET PC56RVP */
+	{"FUJ0202"},		/* Fujitsu 33600 PnP-I2 R Plug & Play */
+	{"FUJ0205"},		/* Fujitsu FMV-FX431 Plug & Play */
+	{"FUJ0206"},		/* Fujitsu 33600 PnP-I4 R Plug & Play */
+	{"FUJ0209"},		/* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
+	{"GVC000F"},		/* Archtek SmartLink Modem 3334BT Plug & Play */
+	{"GVC0303"},		/* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
+	{"HAY0001"},		/* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
+	{"HAY000C"},		/* Hayes Optima 336 V.34 + FAX + Voice PnP */
+	{"HAY000D"},		/* Hayes Optima 336B V.34 + FAX + Voice PnP */
+	{"HAY5670"},		/* Hayes Accura 56K Ext Fax Modem PnP */
+	{"HAY5674"},		/* Hayes Accura 56K Ext Fax Modem PnP */
+	{"HAY5675"},		/* Hayes Accura 56K Fax Modem PnP */
+	{"HAYF000"},		/* Hayes 288, V.34 + FAX */
+	{"HAYF001"},		/* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
+	{"IBM0033"},		/* IBM Thinkpad 701 Internal Modem Voice */
+	{"PNP4972"},		/* Intermec CV60 touchscreen port */
+	{"IXDC801"},		/* Intertex 28k8 33k6 Voice EXT PnP */
+	{"IXDC901"},		/* Intertex 33k6 56k Voice EXT PnP */
+	{"IXDD801"},		/* Intertex 28k8 33k6 Voice SP EXT PnP */
+	{"IXDD901"},		/* Intertex 33k6 56k Voice SP EXT PnP */
+	{"IXDF401"},		/* Intertex 28k8 33k6 Voice SP INT PnP */
+	{"IXDF801"},		/* Intertex 28k8 33k6 Voice SP EXT PnP */
+	{"IXDF901"},		/* Intertex 33k6 56k Voice SP EXT PnP */
+	{"KOR4522"},		/* KORTEX 28800 Externe PnP */
+	{"KORF661"},		/* KXPro 33.6 Vocal ASVD PnP */
+	{"LAS4040"},		/* LASAT Internet 33600 PnP */
+	{"LAS4540"},		/* Lasat Safire 560 PnP */
+	{"LAS5440"},		/* Lasat Safire 336  PnP */
+	{"MNP0281"},		/* Microcom TravelPorte FAST V.34 Plug & Play */
+	{"MNP0336"},		/* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
+	{"MNP0339"},		/* Microcom DeskPorte FAST EP 28.8 Plug & Play */
+	{"MNP0342"},		/* Microcom DeskPorte 28.8P Plug & Play */
+	{"MNP0500"},		/* Microcom DeskPorte FAST ES 28.8 Plug & Play */
+	{"MNP0501"},		/* Microcom DeskPorte FAST ES 28.8 Plug & Play */
+	{"MNP0502"},		/* Microcom DeskPorte 28.8S Internal Plug & Play */
+	{"MOT1105"},		/* Motorola BitSURFR Plug & Play */
+	{"MOT1111"},		/* Motorola TA210 Plug & Play */
+	{"MOT1114"},		/* Motorola HMTA 200 (ISDN) Plug & Play */
+	{"MOT1115"},		/* Motorola BitSURFR Plug & Play */
+	{"MOT1190"},		/* Motorola Lifestyle 28.8 Internal */
+	{"MOT1501"},		/* Motorola V.3400 Plug & Play */
+	{"MOT1502"},		/* Motorola Lifestyle 28.8 V.34 Plug & Play */
+	{"MOT1505"},		/* Motorola Power 28.8 V.34 Plug & Play */
+	{"MOT1509"},		/* Motorola ModemSURFR External 28.8 Plug & Play */
+	{"MOT150A"},		/* Motorola Premier 33.6 Desktop Plug & Play */
+	{"MOT150F"},		/* Motorola VoiceSURFR 56K External PnP */
+	{"MOT1510"},		/* Motorola ModemSURFR 56K External PnP */
+	{"MOT1550"},		/* Motorola ModemSURFR 56K Internal PnP */
+	{"MOT1560"},		/* Motorola ModemSURFR Internal 28.8 Plug & Play */
+	{"MOT1580"},		/* Motorola Premier 33.6 Internal Plug & Play */
+	{"MOT15B0"},		/* Motorola OnlineSURFR 28.8 Internal Plug & Play */
+	{"MOT15F0"},		/* Motorola VoiceSURFR 56K Internal PnP */
+	{"MVX00A1"},		/*  Deskline K56 Phone System PnP */
+	{"MVX00F2"},		/* PC Rider K56 Phone System PnP */
+	{"nEC8241"},		/* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
+	{"PMC2430"},		/* Pace 56 Voice Internal Plug & Play Modem */
+	{"PNP0500"},		/* Generic standard PC COM port     */
+	{"PNP0501"},		/* Generic 16550A-compatible COM port */
+	{"PNPC000"},		/* Compaq 14400 Modem */
+	{"PNPC001"},		/* Compaq 2400/9600 Modem */
+	{"PNPC031"},		/* Dial-Up Networking Serial Cable between 2 PCs */
+	{"PNPC032"},		/* Dial-Up Networking Parallel Cable between 2 PCs */
+	{"PNPC100"},		/* Standard 9600 bps Modem */
+	{"PNPC101"},		/* Standard 14400 bps Modem */
+	{"PNPC102"},		/*  Standard 28800 bps Modem */
+	{"PNPC103"},		/*  Standard Modem */
+	{"PNPC104"},		/*  Standard 9600 bps Modem */
+	{"PNPC105"},		/*  Standard 14400 bps Modem */
+	{"PNPC106"},		/*  Standard 28800 bps Modem */
+	{"PNPC107"},		/*  Standard Modem */
+	{"PNPC108"},		/* Standard 9600 bps Modem */
+	{"PNPC109"},		/* Standard 14400 bps Modem */
+	{"PNPC10A"},		/* Standard 28800 bps Modem */
+	{"PNPC10B"},		/* Standard Modem */
+	{"PNPC10C"},		/* Standard 9600 bps Modem */
+	{"PNPC10D"},		/* Standard 14400 bps Modem */
+	{"PNPC10E"},		/* Standard 28800 bps Modem */
+	{"PNPC10F"},		/* Standard Modem */
+	{"PNP2000"},		/* Standard PCMCIA Card Modem */
+	{"ROK0030"},		/* Rockwell 33.6 DPF Internal PnP, Modular Technology 33.6 Internal PnP */
+	{"ROK0100"},		/* KORTEX 14400 Externe PnP */
+	{"ROK4120"},		/* Rockwell 28.8 */
+	{"ROK4920"},		/* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
+	{"RSS00A0"},		/* Rockwell 33.6 DPF External PnP, BT Prologue 33.6 External PnP, Modular Technology 33.6 External PnP */
+	{"RSS0262"},		/* Viking 56K FAX INT */
+	{"RSS0250"},		/* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
+	{"SUP1310"},		/* SupraExpress 28.8 Data/Fax PnP modem */
+	{"SUP1381"},		/* SupraExpress 336i PnP Voice Modem */
+	{"SUP1421"},		/* SupraExpress 33.6 Data/Fax PnP modem */
+	{"SUP1590"},		/* SupraExpress 33.6 Data/Fax PnP modem */
+	{"SUP1620"},		/* SupraExpress 336i Sp ASVD */
+	{"SUP1760"},		/* SupraExpress 33.6 Data/Fax PnP modem */
+	{"SUP2171"},		/* SupraExpress 56i Sp Intl */
+	{"TEX0011"},		/* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
+	{"UAC000F"},		/* Archtek SmartLink Modem 3334BT Plug & Play */
+	{"USR0000"},		/* 3Com Corp. Gateway Telepath IIvi 33.6 */
+	{"USR0002"},		/* U.S. Robotics Sporster 33.6K Fax INT PnP */
+	{"USR0004"},		/*  Sportster Vi 14.4 PnP FAX Voicemail */
+	{"USR0006"},		/* U.S. Robotics 33.6K Voice INT PnP */
+	{"USR0007"},		/* U.S. Robotics 33.6K Voice EXT PnP */
+	{"USR0009"},		/* U.S. Robotics Courier V.Everything INT PnP */
+	{"USR2002"},		/* U.S. Robotics 33.6K Voice INT PnP */
+	{"USR2070"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"USR2080"},		/* U.S. Robotics 56K Voice EXT PnP */
+	{"USR3031"},		/* U.S. Robotics 56K FAX INT */
+	{"USR3050"},		/* U.S. Robotics 56K FAX INT */
+	{"USR3070"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"USR3080"},		/* U.S. Robotics 56K Voice EXT PnP */
+	{"USR3090"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"USR9100"},		/* U.S. Robotics 56K Message  */
+	{"USR9160"},		/* U.S. Robotics 56K FAX EXT PnP */
+	{"USR9170"},		/* U.S. Robotics 56K FAX INT PnP */
+	{"USR9180"},		/* U.S. Robotics 56K Voice EXT PnP */
+	{"USR9190"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"WACFXXX"},		/* Wacom tablets */
+	{"FPI2002"},		/* Compaq touchscreen */
+	{"FUJ02B2"},		/* Fujitsu Stylistic touchscreens */
+	{"FUJ02B3"},
+	{"FUJ02B4"},		/* Fujitsu Stylistic LT touchscreens */
+	{"FUJ02B6"},		/* Passive Fujitsu Stylistic touchscreens */
+	{"FUJ02B7"},
+	{"FUJ02B8"},
+	{"FUJ02B9"},
+	{"FUJ02BC"},
+	{"FUJ02E5"},		/* Fujitsu Wacom Tablet PC device */
+	{"FUJ02E6"},		/* Fujitsu P-series tablet PC device */
+	{"FUJ02E7"},		/* Fujitsu Wacom 2FGT Tablet PC device */
+	{"FUJ02E9"},		/* Fujitsu Wacom 1FGT Tablet PC device */
+	{"LTS0001"},		/* LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in disguise) */
+	{"WCI0003"},		/* Rockwell's (PORALiNK) 33600 INT PNP */
+	{"WEC1022"},		/* Winbond CIR port, should not be probed. We should keep track of it to prevent the legacy serial driver from probing it */
+	{"PNPCXXX"},		/* Unknown PnP modems */
+	{"PNPDXXX"},		/* More unknown PnP modems */
+	/* scl200wdt */
+	{"NSC0800"},		/* National Semiconductor PC87307/PC97307 watchdog component */
+	/* mpu401 */
+	{"PNPb006"},
+	/* cs423x-pnpbios */
+	{"CSC0100"},
+	{"CSC0000"},
+	{"GIM0100"},		/* Guillemot Turtlebeach something appears to be cs4232 compatible */
+	/* es18xx-pnpbios */
+	{"ESS1869"},
+	{"ESS1879"},
+	/* snd-opl3sa2-pnpbios */
+	{"YMH0021"},
+	{"NMX2210"},		/* Gateway Solo 2500 */
+	{""},
+};
+
+static int acpi_pnp_scan_handler_attach(struct acpi_device *adev,
+					const struct acpi_device_id *id)
+{
+	return 1;
+}
+
+static int acpi_pnp_scan_handler_match(char *devid, char *handlerid)
+{
+	int i;
+
+	if (memcmp(devid, handlerid, 3))
+		return 0;
+
+	for (i = 3; i < 7; i++) {
+		/* Not a HEX value */
+		if (!((devid[i] >= '0' && devid[i] <= '9') ||
+		      (devid[i] > 'A' && devid[i] <= 'F')))
+			return 0;
+
+		/* Not a wildcard and not match */
+		if ((handlerid[i] != 'X') &&
+		    toupper(devid[i]) != toupper(handlerid[i]))
+			return 0;
+	}
+	return 1;
+}
+
+static struct acpi_scan_handler acpi_pnp_handler = {
+	.ids = acpi_pnp_device_ids,
+	.match = acpi_pnp_scan_handler_match,
+	.attach = acpi_pnp_scan_handler_attach,
+};
+
+/*
+ * For CMOS RTC devices, the acpi pnp spcan handler does not work because
+ * there is already a cmos rtc scan handler installed, thus we need to
+ * check those devices and enumerate them to PNP bus explicitly.
+ */
+static int is_cmos_rtc_device(struct acpi_device *adev)
+{
+	struct acpi_device_id ids[] = {
+		{ "PNP0B00" },
+		{ "PNP0B01" },
+		{ "PNP0B02" },
+		{""},
+	};
+	return !acpi_match_device_ids(adev, ids);
+}
+
+bool acpi_is_pnp_device(struct acpi_device *device)
+{
+	if (device->handler == &acpi_pnp_handler)
+		return true;
+	if (is_cmos_rtc_device(device))
+		return true;
+	return false;
+}
+EXPORT_SYMBOL_GPL(acpi_is_pnp_device);
+
+void __init acpi_pnp_init(void)
+{
+	acpi_scan_add_handler(&acpi_pnp_handler);
+}
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 9573913..3a12866 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -30,6 +30,7 @@ void acpi_pci_root_init(void);
 void acpi_pci_link_init(void);
 void acpi_processor_init(void);
 void acpi_platform_init(void);
+void acpi_pnp_init(void);
 int acpi_sysfs_init(void);
 #ifdef CONFIG_ACPI_CONTAINER
 void acpi_container_init(void);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index e46e51c..c82ab73 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2251,6 +2251,7 @@ int __init acpi_scan_init(void)
 	acpi_cmos_rtc_init();
 	acpi_container_init();
 	acpi_memory_hotplug_init();
+	acpi_pnp_init();
 
 	mutex_lock(&acpi_scan_lock);
 	/*
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index c31aa07..b81448b 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -30,26 +30,6 @@
 
 static int num;
 
-/* We need only to blacklist devices that have already an acpi driver that
- * can't use pnp layer. We don't need to blacklist device that are directly
- * used by the kernel (PCI root, ...), as it is harmless and there were
- * already present in pnpbios. But there is an exception for devices that
- * have irqs (PIC, Timer) because we call acpi_register_gsi.
- * Finally, only devices that have a CRS method need to be in this list.
- */
-static struct acpi_device_id excluded_id_list[] __initdata = {
-	{"PNP0C09", 0},		/* EC */
-	{"PNP0C0F", 0},		/* Link device */
-	{"PNP0000", 0},		/* PIC */
-	{"PNP0100", 0},		/* Timer */
-	{"", 0},
-};
-
-static inline int __init is_exclusive_device(struct acpi_device *dev)
-{
-	return (!acpi_match_device_ids(dev, excluded_id_list));
-}
-
 /*
  * Compatible Device IDs
  */
@@ -266,7 +246,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
 	if (!pnpid)
 		return 0;
 
-	if (is_exclusive_device(device) || !device->status.present)
+	if (!device->status.present)
 		return 0;
 
 	dev = pnp_alloc_dev(&pnpacpi_protocol, num, pnpid);
@@ -326,10 +306,10 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
 {
 	struct acpi_device *device;
 
-	if (!acpi_bus_get_device(handle, &device))
-		pnpacpi_add_device(device);
-	else
+	if (acpi_bus_get_device(handle, &device))
 		return AE_CTRL_DEPTH;
+	if (acpi_is_pnp_device(device))
+		pnpacpi_add_device(device);
 	return AE_OK;
 }
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 7a8f2cd..27e2d29 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -184,6 +184,8 @@ extern int ec_transaction(u8 command,
                           u8 *rdata, unsigned rdata_len);
 extern acpi_handle ec_get_handle(void);
 
+extern bool acpi_is_pnp_device(struct acpi_device *);
+
 #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE)
 
 typedef void (*wmi_notify_handler) (u32 value, void *context);
-- 
1.8.3.2




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

* Re: [PATCH V7 10/11] ACPI: use platform bus as the default bus for _HID enumeration
  2014-05-22 18:02 ` [PATCH V7 10/11] ACPI: use platform bus as the default bus for _HID enumeration Zhang Rui
@ 2014-05-26 10:21   ` Mika Westerberg
  2014-05-28  7:16     ` Zhang Rui
  0 siblings, 1 reply; 40+ messages in thread
From: Mika Westerberg @ 2014-05-26 10:21 UTC (permalink / raw)
  To: Zhang Rui
  Cc: linux-acpi, linux-kernel, bhelgaas, matthew.garrett,
	rafael.j.wysocki, dmitry.torokhov, Heikki Krogerus

On Fri, May 23, 2014 at 02:02:32AM +0800, Zhang Rui wrote:
> Because of the growing demand for enumerating ACPI devices to
> platform bus, this patch changes the code to enumerate ACPI
> devices to platform bus by default, if the device
> 1. has _HID.
> 2. does not have a scan handler attached.
> 3. is not SPB slave device, which should be enumerated by its parent.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/acpi/acpi_platform.c | 28 ----------------------------
>  drivers/acpi/scan.c          | 43 ++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 42 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
> index dbfe49e..33376a9 100644
> --- a/drivers/acpi/acpi_platform.c
> +++ b/drivers/acpi/acpi_platform.c
> @@ -22,24 +22,6 @@
>  
>  ACPI_MODULE_NAME("platform");
>  
> -/*
> - * The following ACPI IDs are known to be suitable for representing as
> - * platform devices.
> - */
> -static const struct acpi_device_id acpi_platform_device_ids[] = {
> -
> -	{ "PNP0D40" },
> -	{ "ACPI0003" },
> -	{ "VPC2004" },
> -	{ "BCM4752" },

You can't remove this one as it is bluetooth connected to HS-UART and
thus has UARTSerialBus() connector.

> -
> -	/* Intel Smart Sound Technology */
> -	{ "INT33C8" },
> -	{ "80860F28" },
> -
> -	{ }
> -};

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

* Re: [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS is cleared
  2014-05-22 18:02 ` [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS " Zhang Rui
@ 2014-05-26 10:56   ` Mika Westerberg
  2014-05-26 11:53     ` Rafael J. Wysocki
  0 siblings, 1 reply; 40+ messages in thread
From: Mika Westerberg @ 2014-05-26 10:56 UTC (permalink / raw)
  To: Zhang Rui
  Cc: linux-acpi, linux-kernel, bhelgaas, matthew.garrett,
	rafael.j.wysocki, dmitry.torokhov

On Fri, May 23, 2014 at 02:02:30AM +0800, Zhang Rui wrote:
> The new ACPI device enumeration mechanism, which will be introduced
> in a later patch, will enumerate the _HID devices w/o any scan
> handler attached to platform bus.
> This means that, for the devices that are attached to a configurable
> scan handler, we should make sure no platform devices would be
> created for them even if the scan handler is compiled out.
> 
> Fix this problem for lpss devices by always register the lpss scan handler,
> but with meaningful callbacks only when CONFIG_X86_INTEL_LPSS is set.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/acpi/Makefile    |  2 +-
>  drivers/acpi/acpi_lpss.c | 63 ++++++++++++++++++++++++++++++------------------
>  drivers/acpi/internal.h  |  4 ---
>  3 files changed, 41 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index 171efc2..605eff7 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -39,7 +39,7 @@ acpi-y				+= processor_core.o
>  acpi-y				+= ec.o
>  acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
>  acpi-y				+= pci_root.o pci_link.o pci_irq.o
> -acpi-$(CONFIG_X86_INTEL_LPSS)	+= acpi_lpss.o
> +acpi-y				+= acpi_lpss.o
>  acpi-y				+= acpi_platform.o
>  acpi-y				+= acpi_pnp.o
>  acpi-y				+= power.o
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index 69e29f4..bb5b3f2 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -24,6 +24,8 @@
>  
>  ACPI_MODULE_NAME("acpi_lpss");
>  
> +#ifdef CONFIG_X86_INTEL_LPSS
> +
>  #define LPSS_CLK_SIZE	0x04
>  #define LPSS_LTR_SIZE	0x18
>  
> @@ -159,40 +161,50 @@ static struct lpss_device_desc byt_i2c_dev_desc = {
>  	.shared_clock = &i2c_clock,
>  };
>  
> +#define LPSS_PTR(desc) ((unsigned long)&desc)
> +
> +#else
> +
> +#define LPSS_PTR(desc) 0
> +
> +#endif
> +
>  static const struct acpi_device_id acpi_lpss_device_ids[] = {
>  	/* Generic LPSS devices */
> -	{ "INTL9C60", (unsigned long)&lpss_dma_desc },
> +	{ "INTL9C60", LPSS_PTR(lpss_dma_desc) },
>  
>  	/* Lynxpoint LPSS devices */
> -	{ "INT33C0", (unsigned long)&lpt_dev_desc },
> -	{ "INT33C1", (unsigned long)&lpt_dev_desc },
> -	{ "INT33C2", (unsigned long)&lpt_dev_desc },
> -	{ "INT33C3", (unsigned long)&lpt_dev_desc },
> -	{ "INT33C4", (unsigned long)&lpt_uart_dev_desc },
> -	{ "INT33C5", (unsigned long)&lpt_uart_dev_desc },
> -	{ "INT33C6", (unsigned long)&lpt_sdio_dev_desc },
> +	{ "INT33C0", LPSS_PTR(lpt_dev_desc) },
> +	{ "INT33C1", LPSS_PTR(lpt_dev_desc) },
> +	{ "INT33C2", LPSS_PTR(lpt_dev_desc) },
> +	{ "INT33C3", LPSS_PTR(lpt_dev_desc) },
> +	{ "INT33C4", LPSS_PTR(lpt_uart_dev_desc) },
> +	{ "INT33C5", LPSS_PTR(lpt_uart_dev_desc) },
> +	{ "INT33C6", LPSS_PTR(lpt_sdio_dev_desc) },
>  	{ "INT33C7", },
>  
>  	/* BayTrail LPSS devices */
> -	{ "80860F09", (unsigned long)&byt_pwm_dev_desc },
> -	{ "80860F0A", (unsigned long)&byt_uart_dev_desc },
> -	{ "80860F0E", (unsigned long)&byt_spi_dev_desc },
> -	{ "80860F14", (unsigned long)&byt_sdio_dev_desc },
> -	{ "80860F41", (unsigned long)&byt_i2c_dev_desc },
> +	{ "80860F09", LPSS_PTR(byt_pwm_dev_desc) },
> +	{ "80860F0A", LPSS_PTR(byt_uart_dev_desc) },
> +	{ "80860F0E", LPSS_PTR(byt_spi_dev_desc) },
> +	{ "80860F14", LPSS_PTR(byt_sdio_dev_desc) },
> +	{ "80860F41", LPSS_PTR(byt_i2c_dev_desc) },
>  	{ "INT33B2", },
>  
> -	{ "INT3430", (unsigned long)&lpt_dev_desc },
> -	{ "INT3431", (unsigned long)&lpt_dev_desc },
> -	{ "INT3432", (unsigned long)&lpt_dev_desc },
> -	{ "INT3433", (unsigned long)&lpt_dev_desc },
> -	{ "INT3434", (unsigned long)&lpt_uart_dev_desc },
> -	{ "INT3435", (unsigned long)&lpt_uart_dev_desc },
> -	{ "INT3436", (unsigned long)&lpt_sdio_dev_desc },
> +	{ "INT3430", LPSS_PTR(lpt_dev_desc) },
> +	{ "INT3431", LPSS_PTR(lpt_dev_desc) },
> +	{ "INT3432", LPSS_PTR(lpt_dev_desc) },
> +	{ "INT3433", LPSS_PTR(lpt_dev_desc) },
> +	{ "INT3434", LPSS_PTR(lpt_uart_dev_desc) },
> +	{ "INT3435", LPSS_PTR(lpt_uart_dev_desc) },
> +	{ "INT3436", LPSS_PTR(lpt_sdio_dev_desc) },
>  	{ "INT3437", },
>  
>  	{ }
>  };
>  
> +#ifdef CONFIG_X86_INTEL_LPSS
> +
>  static int is_memory(struct acpi_resource *res, void *not_used)
>  {
>  	struct resource r;
> @@ -503,18 +515,23 @@ static void acpi_lpss_unbind(struct device *dev)
>  {
>  	dev->power.set_latency_tolerance = NULL;
>  }
> +#endif /* CONFIG_X86_INTEL_LPSS */
>  
>  static struct acpi_scan_handler lpss_handler = {
>  	.ids = acpi_lpss_device_ids,
> -	.attach = acpi_lpss_create_device,
> -	.bind = acpi_lpss_bind,
> -	.unbind = acpi_lpss_unbind,
>  };
>  
>  void __init acpi_lpss_init(void)
>  {
> +#ifdef CONFIG_X86_INTEL_LPSS
>  	if (!lpt_clk_init()) {
>  		bus_register_notifier(&platform_bus_type, &acpi_lpss_nb);
> +		lpss_handler.attach = acpi_lpss_create_device;
> +		lpss_handler.bind = acpi_lpss_bind;
> +		lpss_handler.unbind = acpi_lpss_unbind;
>  		acpi_scan_add_handler(&lpss_handler);
> +		return;
>  	}
> +#endif
> +	acpi_scan_add_handler(&lpss_handler);

I'm wondering whether it is worth the ugliness to get platform bus
enumeration the default?

Since you already have the PNP whitelist, can't we just use that for PNP
and keep these files as they are? In other words, don't make any kind of
physical device by default and let the scan handlers to decide.

>  }
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 4a9e999..bc7d102 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -65,11 +65,7 @@ int acpi_debugfs_init(void);
>  #else
>  static inline void acpi_debugfs_init(void) { return; }
>  #endif
> -#ifdef CONFIG_X86_INTEL_LPSS
>  void acpi_lpss_init(void);
> -#else
> -static inline void acpi_lpss_init(void) {}
> -#endif
>  
>  acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
>  bool acpi_queue_hotplug_work(struct work_struct *work);
> -- 
> 1.8.3.2

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

* Re: [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS is cleared
  2014-05-26 11:53     ` Rafael J. Wysocki
@ 2014-05-26 11:52       ` Mika Westerberg
  2014-05-26 12:40         ` Rafael J. Wysocki
  0 siblings, 1 reply; 40+ messages in thread
From: Mika Westerberg @ 2014-05-26 11:52 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Zhang Rui, linux-acpi, linux-kernel, bhelgaas, matthew.garrett,
	rafael.j.wysocki, dmitry.torokhov

On Mon, May 26, 2014 at 01:53:39PM +0200, Rafael J. Wysocki wrote:
> > I'm wondering whether it is worth the ugliness to get platform bus
> > enumeration the default?
> > 
> > Since you already have the PNP whitelist, can't we just use that for PNP
> > and keep these files as they are? In other words, don't make any kind of
> > physical device by default and let the scan handlers to decide.
> 
> Well, that's tempting, but then we'd get one more whitelist pretty much without
> any benefit, because we'd be still going to have the list in acpi_platform.c.
> 
> The purpose of the whole exercise is not to prevent PNP devices from being
> created by default (which admittedly is a nice side effect), but to get rid
> of the white list in acpi_platform.c - and in particular, to avoid the
> necessity to add every ACPI-enumerated platform device to that list in the
> future.

Yes, I understand but that list currently has only 5 entries. Are
we expecting to have much more entries there in the future?

For LPSS devices we can't get rid of the list since we need to pass
->driver_data based on the _HID anyway.

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

* Re: [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS is cleared
  2014-05-26 10:56   ` Mika Westerberg
@ 2014-05-26 11:53     ` Rafael J. Wysocki
  2014-05-26 11:52       ` Mika Westerberg
  0 siblings, 1 reply; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-26 11:53 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Zhang Rui, linux-acpi, linux-kernel, bhelgaas, matthew.garrett,
	rafael.j.wysocki, dmitry.torokhov

On Monday, May 26, 2014 01:56:36 PM Mika Westerberg wrote:
> On Fri, May 23, 2014 at 02:02:30AM +0800, Zhang Rui wrote:
> > The new ACPI device enumeration mechanism, which will be introduced
> > in a later patch, will enumerate the _HID devices w/o any scan
> > handler attached to platform bus.
> > This means that, for the devices that are attached to a configurable
> > scan handler, we should make sure no platform devices would be
> > created for them even if the scan handler is compiled out.
> > 
> > Fix this problem for lpss devices by always register the lpss scan handler,
> > but with meaningful callbacks only when CONFIG_X86_INTEL_LPSS is set.
> > 
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > ---
> >  drivers/acpi/Makefile    |  2 +-
> >  drivers/acpi/acpi_lpss.c | 63 ++++++++++++++++++++++++++++++------------------
> >  drivers/acpi/internal.h  |  4 ---
> >  3 files changed, 41 insertions(+), 28 deletions(-)
> > 
> > diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> > index 171efc2..605eff7 100644
> > --- a/drivers/acpi/Makefile
> > +++ b/drivers/acpi/Makefile
> > @@ -39,7 +39,7 @@ acpi-y				+= processor_core.o
> >  acpi-y				+= ec.o
> >  acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
> >  acpi-y				+= pci_root.o pci_link.o pci_irq.o
> > -acpi-$(CONFIG_X86_INTEL_LPSS)	+= acpi_lpss.o
> > +acpi-y				+= acpi_lpss.o
> >  acpi-y				+= acpi_platform.o
> >  acpi-y				+= acpi_pnp.o
> >  acpi-y				+= power.o
> > diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> > index 69e29f4..bb5b3f2 100644
> > --- a/drivers/acpi/acpi_lpss.c
> > +++ b/drivers/acpi/acpi_lpss.c
> > @@ -24,6 +24,8 @@
> >  
> >  ACPI_MODULE_NAME("acpi_lpss");
> >  
> > +#ifdef CONFIG_X86_INTEL_LPSS
> > +
> >  #define LPSS_CLK_SIZE	0x04
> >  #define LPSS_LTR_SIZE	0x18
> >  
> > @@ -159,40 +161,50 @@ static struct lpss_device_desc byt_i2c_dev_desc = {
> >  	.shared_clock = &i2c_clock,
> >  };
> >  
> > +#define LPSS_PTR(desc) ((unsigned long)&desc)
> > +
> > +#else
> > +
> > +#define LPSS_PTR(desc) 0
> > +
> > +#endif
> > +
> >  static const struct acpi_device_id acpi_lpss_device_ids[] = {
> >  	/* Generic LPSS devices */
> > -	{ "INTL9C60", (unsigned long)&lpss_dma_desc },
> > +	{ "INTL9C60", LPSS_PTR(lpss_dma_desc) },
> >  
> >  	/* Lynxpoint LPSS devices */
> > -	{ "INT33C0", (unsigned long)&lpt_dev_desc },
> > -	{ "INT33C1", (unsigned long)&lpt_dev_desc },
> > -	{ "INT33C2", (unsigned long)&lpt_dev_desc },
> > -	{ "INT33C3", (unsigned long)&lpt_dev_desc },
> > -	{ "INT33C4", (unsigned long)&lpt_uart_dev_desc },
> > -	{ "INT33C5", (unsigned long)&lpt_uart_dev_desc },
> > -	{ "INT33C6", (unsigned long)&lpt_sdio_dev_desc },
> > +	{ "INT33C0", LPSS_PTR(lpt_dev_desc) },
> > +	{ "INT33C1", LPSS_PTR(lpt_dev_desc) },
> > +	{ "INT33C2", LPSS_PTR(lpt_dev_desc) },
> > +	{ "INT33C3", LPSS_PTR(lpt_dev_desc) },
> > +	{ "INT33C4", LPSS_PTR(lpt_uart_dev_desc) },
> > +	{ "INT33C5", LPSS_PTR(lpt_uart_dev_desc) },
> > +	{ "INT33C6", LPSS_PTR(lpt_sdio_dev_desc) },
> >  	{ "INT33C7", },
> >  
> >  	/* BayTrail LPSS devices */
> > -	{ "80860F09", (unsigned long)&byt_pwm_dev_desc },
> > -	{ "80860F0A", (unsigned long)&byt_uart_dev_desc },
> > -	{ "80860F0E", (unsigned long)&byt_spi_dev_desc },
> > -	{ "80860F14", (unsigned long)&byt_sdio_dev_desc },
> > -	{ "80860F41", (unsigned long)&byt_i2c_dev_desc },
> > +	{ "80860F09", LPSS_PTR(byt_pwm_dev_desc) },
> > +	{ "80860F0A", LPSS_PTR(byt_uart_dev_desc) },
> > +	{ "80860F0E", LPSS_PTR(byt_spi_dev_desc) },
> > +	{ "80860F14", LPSS_PTR(byt_sdio_dev_desc) },
> > +	{ "80860F41", LPSS_PTR(byt_i2c_dev_desc) },
> >  	{ "INT33B2", },
> >  
> > -	{ "INT3430", (unsigned long)&lpt_dev_desc },
> > -	{ "INT3431", (unsigned long)&lpt_dev_desc },
> > -	{ "INT3432", (unsigned long)&lpt_dev_desc },
> > -	{ "INT3433", (unsigned long)&lpt_dev_desc },
> > -	{ "INT3434", (unsigned long)&lpt_uart_dev_desc },
> > -	{ "INT3435", (unsigned long)&lpt_uart_dev_desc },
> > -	{ "INT3436", (unsigned long)&lpt_sdio_dev_desc },
> > +	{ "INT3430", LPSS_PTR(lpt_dev_desc) },
> > +	{ "INT3431", LPSS_PTR(lpt_dev_desc) },
> > +	{ "INT3432", LPSS_PTR(lpt_dev_desc) },
> > +	{ "INT3433", LPSS_PTR(lpt_dev_desc) },
> > +	{ "INT3434", LPSS_PTR(lpt_uart_dev_desc) },
> > +	{ "INT3435", LPSS_PTR(lpt_uart_dev_desc) },
> > +	{ "INT3436", LPSS_PTR(lpt_sdio_dev_desc) },
> >  	{ "INT3437", },
> >  
> >  	{ }
> >  };
> >  
> > +#ifdef CONFIG_X86_INTEL_LPSS
> > +
> >  static int is_memory(struct acpi_resource *res, void *not_used)
> >  {
> >  	struct resource r;
> > @@ -503,18 +515,23 @@ static void acpi_lpss_unbind(struct device *dev)
> >  {
> >  	dev->power.set_latency_tolerance = NULL;
> >  }
> > +#endif /* CONFIG_X86_INTEL_LPSS */
> >  
> >  static struct acpi_scan_handler lpss_handler = {
> >  	.ids = acpi_lpss_device_ids,
> > -	.attach = acpi_lpss_create_device,
> > -	.bind = acpi_lpss_bind,
> > -	.unbind = acpi_lpss_unbind,
> >  };
> >  
> >  void __init acpi_lpss_init(void)
> >  {
> > +#ifdef CONFIG_X86_INTEL_LPSS
> >  	if (!lpt_clk_init()) {
> >  		bus_register_notifier(&platform_bus_type, &acpi_lpss_nb);
> > +		lpss_handler.attach = acpi_lpss_create_device;
> > +		lpss_handler.bind = acpi_lpss_bind;
> > +		lpss_handler.unbind = acpi_lpss_unbind;
> >  		acpi_scan_add_handler(&lpss_handler);
> > +		return;
> >  	}
> > +#endif
> > +	acpi_scan_add_handler(&lpss_handler);
> 
> I'm wondering whether it is worth the ugliness to get platform bus
> enumeration the default?
> 
> Since you already have the PNP whitelist, can't we just use that for PNP
> and keep these files as they are? In other words, don't make any kind of
> physical device by default and let the scan handlers to decide.

Well, that's tempting, but then we'd get one more whitelist pretty much without
any benefit, because we'd be still going to have the list in acpi_platform.c.

The purpose of the whole exercise is not to prevent PNP devices from being
created by default (which admittedly is a nice side effect), but to get rid
of the white list in acpi_platform.c - and in particular, to avoid the
necessity to add every ACPI-enumerated platform device to that list in the
future.

Rafael


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

* Re: [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS is cleared
  2014-05-26 11:52       ` Mika Westerberg
@ 2014-05-26 12:40         ` Rafael J. Wysocki
  2014-05-26 12:58           ` Mika Westerberg
  0 siblings, 1 reply; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-26 12:40 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Zhang Rui, linux-acpi, linux-kernel, bhelgaas, matthew.garrett,
	rafael.j.wysocki, dmitry.torokhov

On Monday, May 26, 2014 02:52:35 PM Mika Westerberg wrote:
> On Mon, May 26, 2014 at 01:53:39PM +0200, Rafael J. Wysocki wrote:
> > > I'm wondering whether it is worth the ugliness to get platform bus
> > > enumeration the default?
> > > 
> > > Since you already have the PNP whitelist, can't we just use that for PNP
> > > and keep these files as they are? In other words, don't make any kind of
> > > physical device by default and let the scan handlers to decide.
> > 
> > Well, that's tempting, but then we'd get one more whitelist pretty much without
> > any benefit, because we'd be still going to have the list in acpi_platform.c.
> > 
> > The purpose of the whole exercise is not to prevent PNP devices from being
> > created by default (which admittedly is a nice side effect), but to get rid
> > of the white list in acpi_platform.c - and in particular, to avoid the
> > necessity to add every ACPI-enumerated platform device to that list in the
> > future.
> 
> Yes, I understand but that list currently has only 5 entries. Are
> we expecting to have much more entries there in the future?

Yes, we are.  Pretty much anything that's DT-enumerable today may be
ACPI-enumerable in the future.  But you should know that. ;-)

> For LPSS devices we can't get rid of the list since we need to pass
> ->driver_data based on the _HID anyway.

Obviously.

Rafael


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

* Re: [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS is cleared
  2014-05-26 12:40         ` Rafael J. Wysocki
@ 2014-05-26 12:58           ` Mika Westerberg
  0 siblings, 0 replies; 40+ messages in thread
From: Mika Westerberg @ 2014-05-26 12:58 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Zhang Rui, linux-acpi, linux-kernel, bhelgaas, matthew.garrett,
	rafael.j.wysocki, dmitry.torokhov

On Mon, May 26, 2014 at 02:40:58PM +0200, Rafael J. Wysocki wrote:
> On Monday, May 26, 2014 02:52:35 PM Mika Westerberg wrote:
> > On Mon, May 26, 2014 at 01:53:39PM +0200, Rafael J. Wysocki wrote:
> > > > I'm wondering whether it is worth the ugliness to get platform bus
> > > > enumeration the default?
> > > > 
> > > > Since you already have the PNP whitelist, can't we just use that for PNP
> > > > and keep these files as they are? In other words, don't make any kind of
> > > > physical device by default and let the scan handlers to decide.
> > > 
> > > Well, that's tempting, but then we'd get one more whitelist pretty much without
> > > any benefit, because we'd be still going to have the list in acpi_platform.c.
> > > 
> > > The purpose of the whole exercise is not to prevent PNP devices from being
> > > created by default (which admittedly is a nice side effect), but to get rid
> > > of the white list in acpi_platform.c - and in particular, to avoid the
> > > necessity to add every ACPI-enumerated platform device to that list in the
> > > future.
> > 
> > Yes, I understand but that list currently has only 5 entries. Are
> > we expecting to have much more entries there in the future?
> 
> Yes, we are.  Pretty much anything that's DT-enumerable today may be
> ACPI-enumerable in the future.  But you should know that. ;-)

OK. Then I guess having platform enumeration the default makes sense and
we just need to live with the ugly #ifdefs in acpi_lpss.c.

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

* Re: [PATCH V7 10/11] ACPI: use platform bus as the default bus for _HID enumeration
  2014-05-26 10:21   ` Mika Westerberg
@ 2014-05-28  7:16     ` Zhang Rui
  0 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-28  7:16 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: linux-acpi, linux-kernel, bhelgaas, matthew.garrett,
	rafael.j.wysocki, dmitry.torokhov, Heikki Krogerus

On Mon, 2014-05-26 at 13:21 +0300, Mika Westerberg wrote:
> On Fri, May 23, 2014 at 02:02:32AM +0800, Zhang Rui wrote:
> > Because of the growing demand for enumerating ACPI devices to
> > platform bus, this patch changes the code to enumerate ACPI
> > devices to platform bus by default, if the device
> > 1. has _HID.
> > 2. does not have a scan handler attached.
> > 3. is not SPB slave device, which should be enumerated by its parent.
> > 
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > ---
> >  drivers/acpi/acpi_platform.c | 28 ----------------------------
> >  drivers/acpi/scan.c          | 43 ++++++++++++++++++++++++++++++++++++++++++-
> >  2 files changed, 42 insertions(+), 29 deletions(-)
> > 
> > diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
> > index dbfe49e..33376a9 100644
> > --- a/drivers/acpi/acpi_platform.c
> > +++ b/drivers/acpi/acpi_platform.c
> > @@ -22,24 +22,6 @@
> >  
> >  ACPI_MODULE_NAME("platform");
> >  
> > -/*
> > - * The following ACPI IDs are known to be suitable for representing as
> > - * platform devices.
> > - */
> > -static const struct acpi_device_id acpi_platform_device_ids[] = {
> > -
> > -	{ "PNP0D40" },
> > -	{ "ACPI0003" },
> > -	{ "VPC2004" },
> > -	{ "BCM4752" },
> 
> You can't remove this one as it is bluetooth connected to HS-UART and
> thus has UARTSerialBus() connector.

refreshed patch attached.

>From 50f67c33fc686c8dc86507e478a5e7d6f01805c9 Mon Sep 17 00:00:00 2001
From: Zhang Rui <rui.zhang@intel.com>
Date: Thu, 22 May 2014 21:30:37 +0800
Subject: [PATCH 10/11] ACPI: use platform bus as the default bus for _HID
 enumeration

Because of the growing demand for enumerating ACPI devices to
platform bus, this patch changes the code to enumerate ACPI
devices to platform bus by default, if the device
1. has _HID.
2. does not have a scan handler attached.
3. is not SPI/I2C slave device, which should be enumerated
   to SPI/I2C bus by its parent.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/acpi_platform.c | 28 ------------------------
 drivers/acpi/scan.c          | 51 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 29 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index dbfe49e..33376a9 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -22,24 +22,6 @@
 
 ACPI_MODULE_NAME("platform");
 
-/*
- * The following ACPI IDs are known to be suitable for representing as
- * platform devices.
- */
-static const struct acpi_device_id acpi_platform_device_ids[] = {
-
-	{ "PNP0D40" },
-	{ "ACPI0003" },
-	{ "VPC2004" },
-	{ "BCM4752" },
-
-	/* Intel Smart Sound Technology */
-	{ "INT33C8" },
-	{ "80860F28" },
-
-	{ }
-};
-
 /**
  * acpi_create_platform_device - Create platform device for ACPI device node
  * @adev: ACPI device node to create a platform device for.
@@ -125,13 +107,3 @@ int acpi_create_platform_device(struct acpi_device *adev,
 	kfree(resources);
 	return 1;
 }
-
-static struct acpi_scan_handler platform_handler = {
-	.ids = acpi_platform_device_ids,
-	.attach = acpi_create_platform_device,
-};
-
-void __init acpi_platform_init(void)
-{
-	acpi_scan_add_handler(&platform_handler);
-}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 6d50916..73417d6 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2079,6 +2079,53 @@ static int acpi_scan_handler_dummy_attach(struct acpi_device *device,
 	return 1;
 }
 
+static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
+{
+	struct acpi_resource_common_serialbus *res;
+	int *is_spi_i2c_slave = data;
+
+	if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
+		res = &ares->data.common_serial_bus;
+
+		/*
+		 * devices that are connected to UART still need to
+		 * be enumerated to platform bus
+		 */
+		if (res->type != ACPI_RESOURCE_SERIAL_TYPE_UART)
+			*is_spi_i2c_slave = 1;
+		 /* no need to do more checking */
+		return -1;
+	}
+	return 1;
+}
+
+static void acpi_do_default_enumeration(struct acpi_device *device)
+{
+	struct list_head resource_list;
+	int is_spi_i2c_slave = 0;
+
+	/* Do not do enumeration for device object w/o platform_id */
+	if (!device->pnp.type.platform_id)
+		return;
+
+	/* Do not do enumeration for device object with scan handler attached */
+	if (device->handler)
+		return;
+
+	/*
+	 * Do not do enemeration for SPI/I2C slaves
+	 * as they will be enuerated to SPI/I2C bus by their parents
+	 */
+	INIT_LIST_HEAD(&resource_list);
+	acpi_dev_get_resources(device, &resource_list,
+				acpi_check_spi_i2c_slave, &is_spi_i2c_slave);
+	acpi_dev_free_resource_list(&resource_list);
+	if (is_spi_i2c_slave)
+		return;
+
+	acpi_create_platform_device(device, NULL);
+}
+
 static int acpi_scan_attach_handler(struct acpi_device *device)
 {
 	struct acpi_hardware_id *hwid;
@@ -2103,6 +2150,9 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
 				break;
 		}
 	}
+
+	acpi_do_default_enumeration(device);
+
 	return ret;
 }
 
@@ -2262,7 +2312,6 @@ int __init acpi_scan_init(void)
 	acpi_pci_root_init();
 	acpi_pci_link_init();
 	acpi_processor_init();
-	acpi_platform_init();
 	acpi_lpss_init();
 	acpi_cmos_rtc_init();
 	acpi_container_init();
-- 
1.8.3.2





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

* [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework)
  2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
                   ` (10 preceding siblings ...)
  2014-05-22 18:02 ` [PATCH V7 11/11] ACPI: introduce acpi platform exclude id list Zhang Rui
@ 2014-05-30  2:20 ` Rafael J. Wysocki
  2014-05-30  2:21   ` [PATCH 1/10] ACPI / scan: .match() callback for ACPI scan handlers Rafael J. Wysocki
                     ` (11 more replies)
  11 siblings, 12 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:20 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

On Friday, May 23, 2014 02:02:22 AM Zhang Rui wrote:
> Hi, all,
> 
> Currently, PNP bus is used as the default bus for for enumerating ACPI
> devices with _HID/_CID.
> For a device that needs to be enumerated to platform bus, we need to add
> its id string to the platform scan handler white list explicitly.
> 
> This becomes a problem as more and more _HID devices need to be
> enumerated to platform bus nowadays, thus the list is continuously growing.
> 
> So, a solution that uses platform bus for _HID enumeration by default
> is preferred.
> 

OK, this has had several rounds of review already and we're really starting
to run out of time with it, so my version of this patchset follows.

It is mostly based on your patches, but reordered and with some major
changes.  Compiled only for now, so please let me know if there's any
breakage in it.  [The last patch will not apply without update of the
device list being removed, but generally this is on top of linux-next
material.]

Thanks,
Rafael


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

* [PATCH 1/10] ACPI / scan: .match() callback for ACPI scan handlers
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
@ 2014-05-30  2:21   ` Rafael J. Wysocki
  2014-05-30  2:23   ` [PATCH 2/10] ACPI / PNP: use device ID list for PNPACPI device enumeration Rafael J. Wysocki
                     ` (10 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:21 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

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

Introduce a .match() callback for ACPI scan handlers to allow them to
use more elaborate matching algorithms if necessary.  That is needed
for the upcoming PNP scan handler in particular.

This change is based on a Zhang Rui's prototype.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

---
drivers/acpi/scan.c     | 17 +++++++++++------
 drivers/acpi/scan.c     |    3 +++
 include/acpi/acpi_bus.h |    1 +
 2 files changed, 4 insertions(+)

Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -1977,6 +1977,9 @@ static bool acpi_scan_handler_matching(s
 {
 	const struct acpi_device_id *devid;
 
+	if (handler->match)
+		return handler->match(idstr, matchid);
+
 	for (devid = handler->ids; devid->id[0]; devid++)
 		if (!strcmp((char *)devid->id, idstr)) {
 			if (matchid)
Index: linux-pm/include/acpi/acpi_bus.h
===================================================================
--- linux-pm.orig/include/acpi/acpi_bus.h
+++ linux-pm/include/acpi/acpi_bus.h
@@ -131,6 +131,7 @@ static inline struct acpi_hotplug_profil
 struct acpi_scan_handler {
 	const struct acpi_device_id *ids;
 	struct list_head list_node;
+	bool (*match)(char *idstr, const struct acpi_device_id **matchid);
 	int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
 	void (*detach)(struct acpi_device *dev);
 	void (*bind)(struct device *phys_dev);


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

* [PATCH 2/10] ACPI / PNP: use device ID list for PNPACPI device enumeration
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
  2014-05-30  2:21   ` [PATCH 1/10] ACPI / scan: .match() callback for ACPI scan handlers Rafael J. Wysocki
@ 2014-05-30  2:23   ` Rafael J. Wysocki
  2014-05-30  2:24   ` [PATCH 3/10] ACPI / scan: drop IDs that do not comply with the ACPI PNP ID rule Rafael J. Wysocki
                     ` (9 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:23 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

From: Zhang Rui <rui.zhang@intel.com>

ACPI can be used to enumerate PNP devices, but the code does not
handle this in the right way currently.  Namely, if an ACPI device
object
 1. Has a _CRS method,
 2. Has an identification of
    "three capital characters followed by four hex digits",
 3. Is not in the excluded IDs list,
it will be enumerated to PNP bus (that is, a PNP device object will
be create for it).  This means that, actually, the PNP bus type is
used as the default bus type for enumerating _HID devices in ACPI.

However, more and more _HID devices need to be enumerated to the
platform bus instead (that is, platform device objects need to be
created for them).  As a result, the device ID list in acpi_platform.c
is used to enforce creating platform device objects rather than PNP
device objects for matching devices.  That list has been continuously
growing recently, unfortunately, and it is pretty much guaranteed to
grow even more in the future.

To address that problem it is better to enumerate _HID devices
as platform devices by default.  To this end, change the way of
enumerating PNP devices by adding a PNP ACPI scan handler that
will use a device ID list to create PNP devices for the ACPI
device objects whose device IDs are present in that list.

The initial device ID list in the PNP ACPI scan handler contains
all of the pnp_device_id strings from all the existing PNP drivers,
so this change should be transparent to the PNP core and all of the
PNP drivers.  Still, in the future it should be possible to reduce
its size by converting PNP drivers that need not be PNP for any
technical reasons into platform drivers.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[rjw: Rewrote the changelog, modified the PNP ACPI scan handler code]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/Makefile        |    1 
 drivers/acpi/acpi_cmos_rtc.c |    2 
 drivers/acpi/acpi_pnp.c      |  401 +++++++++++++++++++++++++++++++++++++++++++
 drivers/acpi/internal.h      |    1 
 drivers/acpi/scan.c          |    1 
 drivers/pnp/pnpacpi/core.c   |   28 ---
 include/linux/acpi.h         |    2 
 7 files changed, 411 insertions(+), 25 deletions(-)
 create mode 100644 drivers/acpi/acpi_pnp.c

Index: linux-pm/drivers/acpi/Makefile
===================================================================
--- linux-pm.orig/drivers/acpi/Makefile
+++ linux-pm/drivers/acpi/Makefile
@@ -41,6 +41,7 @@ acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
 acpi-y				+= pci_root.o pci_link.o pci_irq.o
 acpi-$(CONFIG_X86_INTEL_LPSS)	+= acpi_lpss.o
 acpi-y				+= acpi_platform.o
+acpi-y				+= acpi_pnp.o
 acpi-y				+= power.o
 acpi-y				+= event.o
 acpi-y				+= sysfs.o
Index: linux-pm/drivers/acpi/acpi_cmos_rtc.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_cmos_rtc.c
+++ linux-pm/drivers/acpi/acpi_cmos_rtc.c
@@ -68,7 +68,7 @@ static int acpi_install_cmos_rtc_space_h
 		return -ENODEV;
 	}
 
-	return 0;
+	return 1;
 }
 
 static void acpi_remove_cmos_rtc_space_handler(struct acpi_device *adev)
Index: linux-pm/drivers/acpi/acpi_pnp.c
===================================================================
--- /dev/null
+++ linux-pm/drivers/acpi/acpi_pnp.c
@@ -0,0 +1,401 @@
+/*
+ * ACPI support for PNP bus type
+ *
+ * Copyright (C) 2014, Intel Corporation
+ * Authors: Zhang Rui <rui.zhang@intel.com>
+ *          Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/module.h>
+
+static const struct acpi_device_id acpi_pnp_device_ids[] = {
+	/* pata_isapnp */
+	{"PNP0600"},		/* Generic ESDI/IDE/ATA compatible hard disk controller */
+	/* floppy */
+	{"PNP0700"},
+	/* ipmi_si */
+	{"IPI0001"},
+	/* tpm_inf_pnp */
+	{"IFX0101"},		/* Infineon TPMs */
+	{"IFX0102"},		/* Infineon TPMs */
+	/*tpm_tis */
+	{"PNP0C31"},		/* TPM */
+	{"ATM1200"},		/* Atmel */
+	{"IFX0102"},		/* Infineon */
+	{"BCM0101"},		/* Broadcom */
+	{"BCM0102"},		/* Broadcom */
+	{"NSC1200"},		/* National */
+	{"ICO0102"},		/* Intel */
+	/* ide   */
+	{"PNP0600"},		/* Generic ESDI/IDE/ATA compatible hard disk controller */
+	/* ns558 */
+	{"@P@0001"},		/* ALS 100 */
+	{"@P@0020"},		/* ALS 200 */
+	{"@P@1001"},		/* ALS 100+ */
+	{"@P@2001"},		/* ALS 120 */
+	{"ASB16fd"},		/* AdLib NSC16 */
+	{"AZT3001"},		/* AZT1008 */
+	{"CDC0001"},		/* Opl3-SAx */
+	{"CSC0001"},		/* CS4232 */
+	{"CSC000f"},		/* CS4236 */
+	{"CSC0101"},		/* CS4327 */
+	{"CTL7001"},		/* SB16 */
+	{"CTL7002"},		/* AWE64 */
+	{"CTL7005"},		/* Vibra16 */
+	{"ENS2020"},		/* SoundscapeVIVO */
+	{"ESS0001"},		/* ES1869 */
+	{"ESS0005"},		/* ES1878 */
+	{"ESS6880"},		/* ES688 */
+	{"IBM0012"},		/* CS4232 */
+	{"OPT0001"},		/* OPTi Audio16 */
+	{"YMH0006"},		/* Opl3-SA */
+	{"YMH0022"},		/* Opl3-SAx */
+	{"PNPb02f"},		/* Generic */
+	/* i8042 kbd */
+	{"PNP0300"},
+	{"PNP0301"},
+	{"PNP0302"},
+	{"PNP0303"},
+	{"PNP0304"},
+	{"PNP0305"},
+	{"PNP0306"},
+	{"PNP0309"},
+	{"PNP030a"},
+	{"PNP030b"},
+	{"PNP0320"},
+	{"PNP0343"},
+	{"PNP0344"},
+	{"PNP0345"},
+	{"CPQA0D7"},
+	/* i8042 aux */
+	{"AUI0200"},
+	{"FJC6000"},
+	{"FJC6001"},
+	{"PNP0f03"},
+	{"PNP0f0b"},
+	{"PNP0f0e"},
+	{"PNP0f12"},
+	{"PNP0f13"},
+	{"PNP0f19"},
+	{"PNP0f1c"},
+	{"SYN0801"},
+	/* fcpnp */
+	{"AVM0900"},
+	/* radio-cadet */
+	{"MSM0c24"},		/* ADS Cadet AM/FM Radio Card */
+	/* radio-gemtek */
+	{"ADS7183"},		/* AOpen FX-3D/Pro Radio */
+	/* radio-sf16fmr2 */
+	{"MFRad13"},		/* tuner subdevice of SF16-FMD2 */
+	/* ene_ir */
+	{"ENE0100"},
+	{"ENE0200"},
+	{"ENE0201"},
+	{"ENE0202"},
+	/* fintek-cir */
+	{"FIT0002"},		/* CIR */
+	/* ite-cir */
+	{"ITE8704"},		/* Default model */
+	{"ITE8713"},		/* CIR found in EEEBox 1501U */
+	{"ITE8708"},		/* Bridged IT8512 */
+	{"ITE8709"},		/* SRAM-Bridged IT8512 */
+	/* nuvoton-cir */
+	{"WEC0530"},		/* CIR */
+	{"NTN0530"},		/* CIR for new chip's pnp id */
+	/* Winbond CIR */
+	{"WEC1022"},
+	/* wbsd */
+	{"WEC0517"},
+	{"WEC0518"},
+	/* Winbond CIR */
+	{"TCM5090"},		/* 3Com Etherlink III (TP) */
+	{"TCM5091"},		/* 3Com Etherlink III */
+	{"TCM5094"},		/* 3Com Etherlink III (combo) */
+	{"TCM5095"},		/* 3Com Etherlink III (TPO) */
+	{"TCM5098"},		/* 3Com Etherlink III (TPC) */
+	{"PNP80f7"},		/* 3Com Etherlink III compatible */
+	{"PNP80f8"},		/* 3Com Etherlink III compatible */
+	/* nsc-ircc */
+	{"NSC6001"},
+	{"HWPC224"},
+	{"IBM0071"},
+	/* smsc-ircc2 */
+	{"SMCf010"},
+	/* sb1000 */
+	{"GIC1000"},
+	/* parport_pc */
+	{"PNP0400"},		/* Standard LPT Printer Port */
+	{"PNP0401"},		/* ECP Printer Port */
+	/* apple-gmux */
+	{"APP000B"},
+	/* fujitsu-laptop.c */
+	{"FUJ02bf"},
+	{"FUJ02B1"},
+	{"FUJ02E3"},
+	/* system */
+	{"PNP0c02"},		/* General ID for reserving resources */
+	{"PNP0c01"},		/* memory controller */
+	/* rtc_cmos */
+	{"PNP0b00"},
+	{"PNP0b01"},
+	{"PNP0b02"},
+	/* c6xdigio */
+	{"PNP0400"},		/* Standard LPT Printer Port */
+	{"PNP0401"},		/* ECP Printer Port */
+	/* ni_atmio.c */
+	{"NIC1900"},
+	{"NIC2400"},
+	{"NIC2500"},
+	{"NIC2600"},
+	{"NIC2700"},
+	/* serial */
+	{"AAC000F"},		/* Archtek America Corp. Archtek SmartLink Modem 3334BT Plug & Play */
+	{"ADC0001"},		/* Anchor Datacomm BV. SXPro 144 External Data Fax Modem Plug & Play */
+	{"ADC0002"},		/* SXPro 288 External Data Fax Modem Plug & Play */
+	{"AEI0250"},		/* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
+	{"AEI1240"},		/* Actiontec ISA PNP 56K X2 Fax Modem */
+	{"AKY1021"},		/* Rockwell 56K ACF II Fax+Data+Voice Modem */
+	{"AZT4001"},		/* AZT3005 PnP SOUND DEVICE */
+	{"BDP3336"},		/* Best Data Products Inc. Smart One 336F PnP Modem */
+	{"BRI0A49"},		/* Boca Complete Ofc Communicator 14.4 Data-FAX */
+	{"BRI1400"},		/* Boca Research 33,600 ACF Modem */
+	{"BRI3400"},		/* Boca 33.6 Kbps Internal FD34FSVD */
+	{"BRI0A49"},		/* Boca 33.6 Kbps Internal FD34FSVD */
+	{"BDP3336"},		/* Best Data Products Inc. Smart One 336F PnP Modem */
+	{"CPI4050"},		/* Computer Peripherals Inc. EuroViVa CommCenter-33.6 SP PnP */
+	{"CTL3001"},		/* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
+	{"CTL3011"},		/* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
+	{"DAV0336"},		/* Davicom ISA 33.6K Modem */
+	{"DMB1032"},		/* Creative Modem Blaster Flash56 DI5601-1 */
+	{"DMB2001"},		/* Creative Modem Blaster V.90 DI5660 */
+	{"ETT0002"},		/* E-Tech CyberBULLET PC56RVP */
+	{"FUJ0202"},		/* Fujitsu 33600 PnP-I2 R Plug & Play */
+	{"FUJ0205"},		/* Fujitsu FMV-FX431 Plug & Play */
+	{"FUJ0206"},		/* Fujitsu 33600 PnP-I4 R Plug & Play */
+	{"FUJ0209"},		/* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
+	{"GVC000F"},		/* Archtek SmartLink Modem 3334BT Plug & Play */
+	{"GVC0303"},		/* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
+	{"HAY0001"},		/* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
+	{"HAY000C"},		/* Hayes Optima 336 V.34 + FAX + Voice PnP */
+	{"HAY000D"},		/* Hayes Optima 336B V.34 + FAX + Voice PnP */
+	{"HAY5670"},		/* Hayes Accura 56K Ext Fax Modem PnP */
+	{"HAY5674"},		/* Hayes Accura 56K Ext Fax Modem PnP */
+	{"HAY5675"},		/* Hayes Accura 56K Fax Modem PnP */
+	{"HAYF000"},		/* Hayes 288, V.34 + FAX */
+	{"HAYF001"},		/* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
+	{"IBM0033"},		/* IBM Thinkpad 701 Internal Modem Voice */
+	{"PNP4972"},		/* Intermec CV60 touchscreen port */
+	{"IXDC801"},		/* Intertex 28k8 33k6 Voice EXT PnP */
+	{"IXDC901"},		/* Intertex 33k6 56k Voice EXT PnP */
+	{"IXDD801"},		/* Intertex 28k8 33k6 Voice SP EXT PnP */
+	{"IXDD901"},		/* Intertex 33k6 56k Voice SP EXT PnP */
+	{"IXDF401"},		/* Intertex 28k8 33k6 Voice SP INT PnP */
+	{"IXDF801"},		/* Intertex 28k8 33k6 Voice SP EXT PnP */
+	{"IXDF901"},		/* Intertex 33k6 56k Voice SP EXT PnP */
+	{"KOR4522"},		/* KORTEX 28800 Externe PnP */
+	{"KORF661"},		/* KXPro 33.6 Vocal ASVD PnP */
+	{"LAS4040"},		/* LASAT Internet 33600 PnP */
+	{"LAS4540"},		/* Lasat Safire 560 PnP */
+	{"LAS5440"},		/* Lasat Safire 336  PnP */
+	{"MNP0281"},		/* Microcom TravelPorte FAST V.34 Plug & Play */
+	{"MNP0336"},		/* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
+	{"MNP0339"},		/* Microcom DeskPorte FAST EP 28.8 Plug & Play */
+	{"MNP0342"},		/* Microcom DeskPorte 28.8P Plug & Play */
+	{"MNP0500"},		/* Microcom DeskPorte FAST ES 28.8 Plug & Play */
+	{"MNP0501"},		/* Microcom DeskPorte FAST ES 28.8 Plug & Play */
+	{"MNP0502"},		/* Microcom DeskPorte 28.8S Internal Plug & Play */
+	{"MOT1105"},		/* Motorola BitSURFR Plug & Play */
+	{"MOT1111"},		/* Motorola TA210 Plug & Play */
+	{"MOT1114"},		/* Motorola HMTA 200 (ISDN) Plug & Play */
+	{"MOT1115"},		/* Motorola BitSURFR Plug & Play */
+	{"MOT1190"},		/* Motorola Lifestyle 28.8 Internal */
+	{"MOT1501"},		/* Motorola V.3400 Plug & Play */
+	{"MOT1502"},		/* Motorola Lifestyle 28.8 V.34 Plug & Play */
+	{"MOT1505"},		/* Motorola Power 28.8 V.34 Plug & Play */
+	{"MOT1509"},		/* Motorola ModemSURFR External 28.8 Plug & Play */
+	{"MOT150A"},		/* Motorola Premier 33.6 Desktop Plug & Play */
+	{"MOT150F"},		/* Motorola VoiceSURFR 56K External PnP */
+	{"MOT1510"},		/* Motorola ModemSURFR 56K External PnP */
+	{"MOT1550"},		/* Motorola ModemSURFR 56K Internal PnP */
+	{"MOT1560"},		/* Motorola ModemSURFR Internal 28.8 Plug & Play */
+	{"MOT1580"},		/* Motorola Premier 33.6 Internal Plug & Play */
+	{"MOT15B0"},		/* Motorola OnlineSURFR 28.8 Internal Plug & Play */
+	{"MOT15F0"},		/* Motorola VoiceSURFR 56K Internal PnP */
+	{"MVX00A1"},		/*  Deskline K56 Phone System PnP */
+	{"MVX00F2"},		/* PC Rider K56 Phone System PnP */
+	{"nEC8241"},		/* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
+	{"PMC2430"},		/* Pace 56 Voice Internal Plug & Play Modem */
+	{"PNP0500"},		/* Generic standard PC COM port     */
+	{"PNP0501"},		/* Generic 16550A-compatible COM port */
+	{"PNPC000"},		/* Compaq 14400 Modem */
+	{"PNPC001"},		/* Compaq 2400/9600 Modem */
+	{"PNPC031"},		/* Dial-Up Networking Serial Cable between 2 PCs */
+	{"PNPC032"},		/* Dial-Up Networking Parallel Cable between 2 PCs */
+	{"PNPC100"},		/* Standard 9600 bps Modem */
+	{"PNPC101"},		/* Standard 14400 bps Modem */
+	{"PNPC102"},		/*  Standard 28800 bps Modem */
+	{"PNPC103"},		/*  Standard Modem */
+	{"PNPC104"},		/*  Standard 9600 bps Modem */
+	{"PNPC105"},		/*  Standard 14400 bps Modem */
+	{"PNPC106"},		/*  Standard 28800 bps Modem */
+	{"PNPC107"},		/*  Standard Modem */
+	{"PNPC108"},		/* Standard 9600 bps Modem */
+	{"PNPC109"},		/* Standard 14400 bps Modem */
+	{"PNPC10A"},		/* Standard 28800 bps Modem */
+	{"PNPC10B"},		/* Standard Modem */
+	{"PNPC10C"},		/* Standard 9600 bps Modem */
+	{"PNPC10D"},		/* Standard 14400 bps Modem */
+	{"PNPC10E"},		/* Standard 28800 bps Modem */
+	{"PNPC10F"},		/* Standard Modem */
+	{"PNP2000"},		/* Standard PCMCIA Card Modem */
+	{"ROK0030"},		/* Rockwell 33.6 DPF Internal PnP, Modular Technology 33.6 Internal PnP */
+	{"ROK0100"},		/* KORTEX 14400 Externe PnP */
+	{"ROK4120"},		/* Rockwell 28.8 */
+	{"ROK4920"},		/* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
+	{"RSS00A0"},		/* Rockwell 33.6 DPF External PnP, BT Prologue 33.6 External PnP, Modular Technology 33.6 External PnP */
+	{"RSS0262"},		/* Viking 56K FAX INT */
+	{"RSS0250"},		/* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
+	{"SUP1310"},		/* SupraExpress 28.8 Data/Fax PnP modem */
+	{"SUP1381"},		/* SupraExpress 336i PnP Voice Modem */
+	{"SUP1421"},		/* SupraExpress 33.6 Data/Fax PnP modem */
+	{"SUP1590"},		/* SupraExpress 33.6 Data/Fax PnP modem */
+	{"SUP1620"},		/* SupraExpress 336i Sp ASVD */
+	{"SUP1760"},		/* SupraExpress 33.6 Data/Fax PnP modem */
+	{"SUP2171"},		/* SupraExpress 56i Sp Intl */
+	{"TEX0011"},		/* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
+	{"UAC000F"},		/* Archtek SmartLink Modem 3334BT Plug & Play */
+	{"USR0000"},		/* 3Com Corp. Gateway Telepath IIvi 33.6 */
+	{"USR0002"},		/* U.S. Robotics Sporster 33.6K Fax INT PnP */
+	{"USR0004"},		/*  Sportster Vi 14.4 PnP FAX Voicemail */
+	{"USR0006"},		/* U.S. Robotics 33.6K Voice INT PnP */
+	{"USR0007"},		/* U.S. Robotics 33.6K Voice EXT PnP */
+	{"USR0009"},		/* U.S. Robotics Courier V.Everything INT PnP */
+	{"USR2002"},		/* U.S. Robotics 33.6K Voice INT PnP */
+	{"USR2070"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"USR2080"},		/* U.S. Robotics 56K Voice EXT PnP */
+	{"USR3031"},		/* U.S. Robotics 56K FAX INT */
+	{"USR3050"},		/* U.S. Robotics 56K FAX INT */
+	{"USR3070"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"USR3080"},		/* U.S. Robotics 56K Voice EXT PnP */
+	{"USR3090"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"USR9100"},		/* U.S. Robotics 56K Message  */
+	{"USR9160"},		/* U.S. Robotics 56K FAX EXT PnP */
+	{"USR9170"},		/* U.S. Robotics 56K FAX INT PnP */
+	{"USR9180"},		/* U.S. Robotics 56K Voice EXT PnP */
+	{"USR9190"},		/* U.S. Robotics 56K Voice INT PnP */
+	{"WACFXXX"},		/* Wacom tablets */
+	{"FPI2002"},		/* Compaq touchscreen */
+	{"FUJ02B2"},		/* Fujitsu Stylistic touchscreens */
+	{"FUJ02B3"},
+	{"FUJ02B4"},		/* Fujitsu Stylistic LT touchscreens */
+	{"FUJ02B6"},		/* Passive Fujitsu Stylistic touchscreens */
+	{"FUJ02B7"},
+	{"FUJ02B8"},
+	{"FUJ02B9"},
+	{"FUJ02BC"},
+	{"FUJ02E5"},		/* Fujitsu Wacom Tablet PC device */
+	{"FUJ02E6"},		/* Fujitsu P-series tablet PC device */
+	{"FUJ02E7"},		/* Fujitsu Wacom 2FGT Tablet PC device */
+	{"FUJ02E9"},		/* Fujitsu Wacom 1FGT Tablet PC device */
+	{"LTS0001"},		/* LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in disguise) */
+	{"WCI0003"},		/* Rockwell's (PORALiNK) 33600 INT PNP */
+	{"WEC1022"},		/* Winbond CIR port, should not be probed. We should keep track of it to prevent the legacy serial driver from probing it */
+	{"PNPCXXX"},		/* Unknown PnP modems */
+	{"PNPDXXX"},		/* More unknown PnP modems */
+	/* scl200wdt */
+	{"NSC0800"},		/* National Semiconductor PC87307/PC97307 watchdog component */
+	/* mpu401 */
+	{"PNPb006"},
+	/* cs423x-pnpbios */
+	{"CSC0100"},
+	{"CSC0000"},
+	{"GIM0100"},		/* Guillemot Turtlebeach something appears to be cs4232 compatible */
+	/* es18xx-pnpbios */
+	{"ESS1869"},
+	{"ESS1879"},
+	/* snd-opl3sa2-pnpbios */
+	{"YMH0021"},
+	{"NMX2210"},		/* Gateway Solo 2500 */
+	{""},
+};
+
+static bool is_hex_digit(char c)
+{
+	return (c >= 0 && c <= '9') || (c >= 'A' && c <= 'F');
+}
+
+static bool matching_id(char *idstr, char *list_id)
+{
+	int i;
+
+	if (memcmp(idstr, list_id, 3))
+		return false;
+
+	for (i = 3; i < 7; i++) {
+		char c = toupper(idstr[i]);
+
+		if (!is_hex_digit(c)
+		    || (list_id[i] != 'X' && c != toupper(list_id[i])))
+			return false;
+	}
+	return true;
+}
+
+static bool acpi_pnp_match(char *idstr, const struct acpi_device_id **matchid)
+{
+	const struct acpi_device_id *devid;
+
+	for (devid = acpi_pnp_device_ids; devid->id[0]; devid++)
+		if (matching_id(idstr, (char *)devid->id)) {
+			if (matchid)
+				*matchid = devid;
+
+			return true;
+		}
+
+	return false;
+}
+
+static int acpi_pnp_attach(struct acpi_device *adev,
+			   const struct acpi_device_id *id)
+{
+	return 1;
+}
+
+static struct acpi_scan_handler acpi_pnp_handler = {
+	.ids = acpi_pnp_device_ids,
+	.match = acpi_pnp_match,
+	.attach = acpi_pnp_attach,
+};
+
+/*
+ * For CMOS RTC devices, the PNP ACPI scan handler does not work, because
+ * there is a CMOS RTC ACPI scan handler installed already, so we need to
+ * check those devices and enumerate them to the PNP bus directly.
+ */
+static int is_cmos_rtc_device(struct acpi_device *adev)
+{
+	struct acpi_device_id ids[] = {
+		{ "PNP0B00" },
+		{ "PNP0B01" },
+		{ "PNP0B02" },
+		{""},
+	};
+	return !acpi_match_device_ids(adev, ids);
+}
+
+bool acpi_is_pnp_device(struct acpi_device *adev)
+{
+	return adev->handler == &acpi_pnp_handler || is_cmos_rtc_device(adev);
+}
+EXPORT_SYMBOL_GPL(acpi_is_pnp_device);
+
+void __init acpi_pnp_init(void)
+{
+	acpi_scan_add_handler(&acpi_pnp_handler);
+}
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -30,6 +30,7 @@ void acpi_pci_root_init(void);
 void acpi_pci_link_init(void);
 void acpi_processor_init(void);
 void acpi_platform_init(void);
+void acpi_pnp_init(void);
 int acpi_sysfs_init(void);
 #ifdef CONFIG_ACPI_CONTAINER
 void acpi_container_init(void);
Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -2253,6 +2253,7 @@ int __init acpi_scan_init(void)
 	acpi_cmos_rtc_init();
 	acpi_container_init();
 	acpi_memory_hotplug_init();
+	acpi_pnp_init();
 
 	mutex_lock(&acpi_scan_lock);
 	/*
Index: linux-pm/drivers/pnp/pnpacpi/core.c
===================================================================
--- linux-pm.orig/drivers/pnp/pnpacpi/core.c
+++ linux-pm/drivers/pnp/pnpacpi/core.c
@@ -30,26 +30,6 @@
 
 static int num;
 
-/* We need only to blacklist devices that have already an acpi driver that
- * can't use pnp layer. We don't need to blacklist device that are directly
- * used by the kernel (PCI root, ...), as it is harmless and there were
- * already present in pnpbios. But there is an exception for devices that
- * have irqs (PIC, Timer) because we call acpi_register_gsi.
- * Finally, only devices that have a CRS method need to be in this list.
- */
-static struct acpi_device_id excluded_id_list[] __initdata = {
-	{"PNP0C09", 0},		/* EC */
-	{"PNP0C0F", 0},		/* Link device */
-	{"PNP0000", 0},		/* PIC */
-	{"PNP0100", 0},		/* Timer */
-	{"", 0},
-};
-
-static inline int __init is_exclusive_device(struct acpi_device *dev)
-{
-	return (!acpi_match_device_ids(dev, excluded_id_list));
-}
-
 /*
  * Compatible Device IDs
  */
@@ -266,7 +246,7 @@ static int __init pnpacpi_add_device(str
 	if (!pnpid)
 		return 0;
 
-	if (is_exclusive_device(device) || !device->status.present)
+	if (!device->status.present)
 		return 0;
 
 	dev = pnp_alloc_dev(&pnpacpi_protocol, num, pnpid);
@@ -326,10 +306,10 @@ static acpi_status __init pnpacpi_add_de
 {
 	struct acpi_device *device;
 
-	if (!acpi_bus_get_device(handle, &device))
-		pnpacpi_add_device(device);
-	else
+	if (acpi_bus_get_device(handle, &device))
 		return AE_CTRL_DEPTH;
+	if (acpi_is_pnp_device(device))
+		pnpacpi_add_device(device);
 	return AE_OK;
 }
 
Index: linux-pm/include/linux/acpi.h
===================================================================
--- linux-pm.orig/include/linux/acpi.h
+++ linux-pm/include/linux/acpi.h
@@ -184,6 +184,8 @@ extern int ec_transaction(u8 command,
                           u8 *rdata, unsigned rdata_len);
 extern acpi_handle ec_get_handle(void);
 
+extern bool acpi_is_pnp_device(struct acpi_device *);
+
 #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE)
 
 typedef void (*wmi_notify_handler) (u32 value, void *context);


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

* [PATCH 3/10] ACPI / scan: drop IDs that do not comply with the ACPI PNP ID rule
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
  2014-05-30  2:21   ` [PATCH 1/10] ACPI / scan: .match() callback for ACPI scan handlers Rafael J. Wysocki
  2014-05-30  2:23   ` [PATCH 2/10] ACPI / PNP: use device ID list for PNPACPI device enumeration Rafael J. Wysocki
@ 2014-05-30  2:24   ` Rafael J. Wysocki
  2014-05-30  2:25   ` [PATCH 4/10] ACPI / scan: drop unsupported serial IDs from PNP ACPI scan handler ID list Rafael J. Wysocki
                     ` (8 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:24 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

From: Zhang Rui <rui.zhang@intel.com>

The PNP ACPI scan handler device ID list includes all the IDs from
all of the struct pnp_device_id instances in the tree, but some of
them do not follow the ACPI PNP ID rule (3 letters + 4 hex digits).

For those IDs, the coressponding devices will never be enumerated
via ACPI, so it is safe to remove them from the PNP ACPI ID list.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[rjw: Subject and changelog]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_pnp.c | 4 ----
 drivers/acpi/acpi_pnp.c |    4 ----
 1 file changed, 4 deletions(-)

Index: linux-pm/drivers/acpi/acpi_pnp.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_pnp.c
+++ linux-pm/drivers/acpi/acpi_pnp.c
@@ -34,10 +34,6 @@ static const struct acpi_device_id acpi_
 	/* ide   */
 	{"PNP0600"},		/* Generic ESDI/IDE/ATA compatible hard disk controller */
 	/* ns558 */
-	{"@P@0001"},		/* ALS 100 */
-	{"@P@0020"},		/* ALS 200 */
-	{"@P@1001"},		/* ALS 100+ */
-	{"@P@2001"},		/* ALS 120 */
 	{"ASB16fd"},		/* AdLib NSC16 */
 	{"AZT3001"},		/* AZT1008 */
 	{"CDC0001"},		/* Opl3-SAx */


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

* [PATCH 4/10] ACPI / scan: drop unsupported serial IDs from PNP ACPI scan handler ID list
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
                     ` (2 preceding siblings ...)
  2014-05-30  2:24   ` [PATCH 3/10] ACPI / scan: drop IDs that do not comply with the ACPI PNP ID rule Rafael J. Wysocki
@ 2014-05-30  2:25   ` Rafael J. Wysocki
  2014-05-30  2:26   ` [PATCH 5/10] ACPI / scan: introduce platform_id device PNP type flag Rafael J. Wysocki
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:25 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

From: Zhang Rui <rui.zhang@intel.com>

The "serial" PNP driver supports some "unknown" PNP modems
(PNPCXXX/PNPDXXX) by matching magic strings in the PNP device name
or the PNP device card name.

ACPI enumerated PNP devices neither are PNP cards, nor have those
magic strings in device names, so this mechamism never actually works
for ACPI enumerated PNPCXXX/PNPDXXX devices.

Consequently, it is safe to remove those two IDs from the PNP ACPI scan
handler's device ID list.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[rjw: Subject and changelog]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_pnp.c | 2 --
 drivers/acpi/acpi_pnp.c |    2 --
 1 file changed, 2 deletions(-)

Index: linux-pm/drivers/acpi/acpi_pnp.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_pnp.c
+++ linux-pm/drivers/acpi/acpi_pnp.c
@@ -301,8 +301,6 @@ static const struct acpi_device_id acpi_
 	{"LTS0001"},		/* LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in disguise) */
 	{"WCI0003"},		/* Rockwell's (PORALiNK) 33600 INT PNP */
 	{"WEC1022"},		/* Winbond CIR port, should not be probed. We should keep track of it to prevent the legacy serial driver from probing it */
-	{"PNPCXXX"},		/* Unknown PnP modems */
-	{"PNPDXXX"},		/* More unknown PnP modems */
 	/* scl200wdt */
 	{"NSC0800"},		/* National Semiconductor PC87307/PC97307 watchdog component */
 	/* mpu401 */


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

* [PATCH 5/10] ACPI / scan: introduce platform_id device PNP type flag
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
                     ` (3 preceding siblings ...)
  2014-05-30  2:25   ` [PATCH 4/10] ACPI / scan: drop unsupported serial IDs from PNP ACPI scan handler ID list Rafael J. Wysocki
@ 2014-05-30  2:26   ` Rafael J. Wysocki
  2014-05-30  2:27   ` [PATCH 6/10] ACPI / scan: Change the meaning of missing .attach() in scan handlers Rafael J. Wysocki
                     ` (6 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:26 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

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

Only certain types of ACPI device objects can be enumerated as
platform devices, so in order to distinguish them from the others
introduce a new ACPI device PNP type flag, platform_id, and set it
for devices with a valid _HID to start with.

This change is based on a Zhang Rui's prototype.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

---
drivers/acpi/scan.c     | 9 ++++++++-
 drivers/acpi/scan.c     |    4 +++-
 include/acpi/acpi_bus.h |    3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -1797,8 +1797,10 @@ static void acpi_set_pnp_ids(acpi_handle
 			return;
 		}
 
-		if (info->valid & ACPI_VALID_HID)
+		if (info->valid & ACPI_VALID_HID) {
 			acpi_add_id(pnp, info->hardware_id.string);
+			pnp->type.platform_id = 1;
+		}
 		if (info->valid & ACPI_VALID_CID) {
 			cid_list = &info->compatible_id_list;
 			for (i = 0; i < cid_list->count; i++)
Index: linux-pm/include/acpi/acpi_bus.h
===================================================================
--- linux-pm.orig/include/acpi/acpi_bus.h
+++ linux-pm/include/acpi/acpi_bus.h
@@ -233,7 +233,8 @@ struct acpi_hardware_id {
 struct acpi_pnp_type {
 	u32 hardware_id:1;
 	u32 bus_address:1;
-	u32 reserved:30;
+	u32 platform_id:1;
+	u32 reserved:29;
 };
 
 struct acpi_device_pnp {


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

* [PATCH 6/10] ACPI / scan: Change the meaning of missing .attach() in scan handlers
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
                     ` (4 preceding siblings ...)
  2014-05-30  2:26   ` [PATCH 5/10] ACPI / scan: introduce platform_id device PNP type flag Rafael J. Wysocki
@ 2014-05-30  2:27   ` Rafael J. Wysocki
  2014-05-30  2:28   ` [PATCH 7/10] ACPI / scan: always register container scan handler Rafael J. Wysocki
                     ` (5 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:27 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

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

Currently, some scan handlers can be compiled out entirely, which
leaves the device objects they normally attach to without a scan
handler.  This isn't a problem as long as we don't have any default
enumeration mechanism that applies to all devices without a scan
handler.  However, if such a default enumeration is added, it still
should not be applied to devices that are normally attached to by
scan handlers, because that may result in creating "physical" device
objects of a wrong type for them.

Since we are going to create platform device objects for all ACPI
device objects with pnp.type.platform_id set by default, clear
pnp.type.platform_id where there is a matching scan handler without
an .attach() callback and otherwise simply treat that scan handler
as though the .attach() callback was present but always returned 0.

This will allow us to compile out scan handler callbacks and leave
the device ID lists used by them so as to prevent creating platform
device objects for the matching ACPI devices.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/scan.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -84,7 +84,7 @@ EXPORT_SYMBOL_GPL(acpi_initialize_hp_con
 
 int acpi_scan_add_handler(struct acpi_scan_handler *handler)
 {
-	if (!handler || !handler->attach)
+	if (!handler)
 		return -EINVAL;
 
 	list_add_tail(&handler->list_node, &acpi_scan_handlers_list);
@@ -2081,6 +2081,10 @@ static int acpi_scan_attach_handler(stru
 
 		handler = acpi_scan_match_handler(hwid->id, &devid);
 		if (handler) {
+			if (!handler->attach) {
+				device->pnp.type.platform_id = 0;
+				continue;
+			}
 			device->handler = handler;
 			ret = handler->attach(device, devid);
 			if (ret > 0)


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

* [PATCH 7/10] ACPI / scan: always register container scan handler
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
                     ` (5 preceding siblings ...)
  2014-05-30  2:27   ` [PATCH 6/10] ACPI / scan: Change the meaning of missing .attach() in scan handlers Rafael J. Wysocki
@ 2014-05-30  2:28   ` Rafael J. Wysocki
  2014-05-30  2:29   ` [PATCH 8/10] ACPI / scan: always register memory hotplug " Rafael J. Wysocki
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:28 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

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

Prevent platform devices from being created for ACPI containers
if CONFIG_ACPI_CONTAINER is unset by compiling out the container
scan handler's callbacks only in that case and still compiling
its device ID list in and registering the scan handler in either
case.

This change is based on a prototype from Zhang Rui.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

---
drivers/acpi/Makefile    |  2 +-
 drivers/acpi/Makefile    |    2 +-
 drivers/acpi/container.c |   15 +++++++++++++++
 drivers/acpi/internal.h  |    4 ----
 3 files changed, 16 insertions(+), 5 deletions(-)

Index: linux-pm/drivers/acpi/Makefile
===================================================================
--- linux-pm.orig/drivers/acpi/Makefile
+++ linux-pm/drivers/acpi/Makefile
@@ -64,7 +64,7 @@ obj-$(CONFIG_ACPI_FAN)		+= fan.o
 obj-$(CONFIG_ACPI_VIDEO)	+= video.o
 obj-$(CONFIG_ACPI_PCI_SLOT)	+= pci_slot.o
 obj-$(CONFIG_ACPI_PROCESSOR)	+= processor.o
-obj-$(CONFIG_ACPI_CONTAINER)	+= container.o
+obj-y				+= container.o
 obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
 obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
 obj-$(CONFIG_ACPI_BATTERY)	+= battery.o
Index: linux-pm/drivers/acpi/container.c
===================================================================
--- linux-pm.orig/drivers/acpi/container.c
+++ linux-pm/drivers/acpi/container.c
@@ -41,6 +41,8 @@ static const struct acpi_device_id conta
 	{"", 0},
 };
 
+#ifdef CONFIG_ACPI_CONTAINER
+
 static int acpi_container_offline(struct container_dev *cdev)
 {
 	struct acpi_device *adev = ACPI_COMPANION(&cdev->dev);
@@ -109,5 +111,18 @@ static struct acpi_scan_handler containe
 
 void __init acpi_container_init(void)
 {
+	acpi_scan_add_handler(&container_handler);
+}
+
+#else
+
+static struct acpi_scan_handler container_handler = {
+	.ids = container_device_ids,
+};
+
+void __init acpi_container_init(void)
+{
 	acpi_scan_add_handler_with_hotplug(&container_handler, "container");
 }
+
+#endif /* CONFIG_ACPI_CONTAINER */
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -32,11 +32,7 @@ void acpi_processor_init(void);
 void acpi_platform_init(void);
 void acpi_pnp_init(void);
 int acpi_sysfs_init(void);
-#ifdef CONFIG_ACPI_CONTAINER
 void acpi_container_init(void);
-#else
-static inline void acpi_container_init(void) {}
-#endif
 #ifdef CONFIG_ACPI_DOCK
 void register_dock_dependent_device(struct acpi_device *adev,
 				    acpi_handle dshandle);


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

* [PATCH 8/10] ACPI / scan: always register memory hotplug scan handler
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
                     ` (6 preceding siblings ...)
  2014-05-30  2:28   ` [PATCH 7/10] ACPI / scan: always register container scan handler Rafael J. Wysocki
@ 2014-05-30  2:29   ` Rafael J. Wysocki
  2014-05-30  2:30   ` [PATCH 9/10] ACPI / scan: always register ACPI LPSS " Rafael J. Wysocki
                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:29 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

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

Prevent platform devices from being created for ACPI memory device
objects if CONFIG_ACPI_HOTPLUG_MEMORY is unset by compiling out the
memory hotplug scan handler's callbacks only in that case and still
compiling its device ID list in and registering the scan handler in
either case.

Also unset the memory hotplug scan handler's .attach() callback
if acpi_no_memhotplug is set, but still register the scan handler to
avoid creating platform devices for ACPI memory devices in that case
too.

This change is based on a prototype from Zhang Rui.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

---
drivers/acpi/Makefile          |  2 +-
 drivers/acpi/Makefile          |    2 +-
 drivers/acpi/acpi_memhotplug.c |   31 ++++++++++++++++++++++++-------
 drivers/acpi/internal.h        |    6 +-----
 3 files changed, 26 insertions(+), 13 deletions(-)

Index: linux-pm/drivers/acpi/Makefile
===================================================================
--- linux-pm.orig/drivers/acpi/Makefile
+++ linux-pm/drivers/acpi/Makefile
@@ -66,7 +66,7 @@ obj-$(CONFIG_ACPI_PCI_SLOT)	+= pci_slot.
 obj-$(CONFIG_ACPI_PROCESSOR)	+= processor.o
 obj-y				+= container.o
 obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
-obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
+obj-y				+= acpi_memhotplug.o
 obj-$(CONFIG_ACPI_BATTERY)	+= battery.o
 obj-$(CONFIG_ACPI_SBS)		+= sbshc.o
 obj-$(CONFIG_ACPI_SBS)		+= sbs.o
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -33,6 +33,7 @@ void acpi_platform_init(void);
 void acpi_pnp_init(void);
 int acpi_sysfs_init(void);
 void acpi_container_init(void);
+void acpi_memory_hotplug_init(void);
 #ifdef CONFIG_ACPI_DOCK
 void register_dock_dependent_device(struct acpi_device *adev,
 				    acpi_handle dshandle);
@@ -44,11 +45,6 @@ static inline void register_dock_depende
 static inline int dock_notify(struct acpi_device *adev, u32 event) { return -ENODEV; }
 static inline void acpi_dock_add(struct acpi_device *adev) {}
 #endif
-#ifdef CONFIG_ACPI_HOTPLUG_MEMORY
-void acpi_memory_hotplug_init(void);
-#else
-static inline void acpi_memory_hotplug_init(void) {}
-#endif
 #ifdef CONFIG_X86
 void acpi_cmos_rtc_init(void);
 #else
Index: linux-pm/drivers/acpi/acpi_memhotplug.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_memhotplug.c
+++ linux-pm/drivers/acpi/acpi_memhotplug.c
@@ -44,6 +44,13 @@
 
 ACPI_MODULE_NAME("acpi_memhotplug");
 
+static const struct acpi_device_id memory_device_ids[] = {
+	{ACPI_MEMORY_DEVICE_HID, 0},
+	{"", 0},
+};
+
+#ifdef CONFIG_ACPI_HOTPLUG_MEMORY
+
 /* Memory Device States */
 #define MEMORY_INVALID_STATE	0
 #define MEMORY_POWER_ON_STATE	1
@@ -53,11 +60,6 @@ static int acpi_memory_device_add(struct
 				  const struct acpi_device_id *not_used);
 static void acpi_memory_device_remove(struct acpi_device *device);
 
-static const struct acpi_device_id memory_device_ids[] = {
-	{ACPI_MEMORY_DEVICE_HID, 0},
-	{"", 0},
-};
-
 static struct acpi_scan_handler memory_device_handler = {
 	.ids = memory_device_ids,
 	.attach = acpi_memory_device_add,
@@ -364,9 +366,11 @@ static bool __initdata acpi_no_memhotplu
 
 void __init acpi_memory_hotplug_init(void)
 {
-	if (acpi_no_memhotplug)
+	if (acpi_no_memhotplug) {
+		memory_device_handler.attach = NULL;
+		acpi_scan_add_handler(&memory_device_handler);
 		return;
-
+	}
 	acpi_scan_add_handler_with_hotplug(&memory_device_handler, "memory");
 }
 
@@ -376,3 +380,16 @@ static int __init disable_acpi_memory_ho
 	return 1;
 }
 __setup("acpi_no_memhotplug", disable_acpi_memory_hotplug);
+
+#else
+
+static struct acpi_scan_handler memory_device_handler = {
+	.ids = memory_device_ids,
+};
+
+void __init acpi_memory_hotplug_init(void)
+{
+	acpi_scan_add_handler(&memory_device_handler);
+}
+
+#endif /* CONFIG_ACPI_HOTPLUG_MEMORY */


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

* [PATCH 9/10] ACPI / scan: always register ACPI LPSS scan handler
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
                     ` (7 preceding siblings ...)
  2014-05-30  2:29   ` [PATCH 8/10] ACPI / scan: always register memory hotplug " Rafael J. Wysocki
@ 2014-05-30  2:30   ` Rafael J. Wysocki
  2014-05-30 12:34     ` [Update][PATCH " Rafael J. Wysocki
  2014-05-30  2:30   ` [PATCH 10/10] ACPI / scan: use platform bus type by default for _HID enumeration Rafael J. Wysocki
                     ` (2 subsequent siblings)
  11 siblings, 1 reply; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:30 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

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

Prevent platform devices from being created for ACPI LPSS devices
if CONFIG_X86_INTEL_LPSS is unset by compiling out the LPSS scan
handler's callbacks only in that case and still compiling its device
ID list in and registering the scan handler in either case.

This change is based on a prototype from Zhang Rui.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

---
drivers/acpi/Makefile    |  2 +-
 drivers/acpi/Makefile    |    2 -
 drivers/acpi/acpi_lpss.c |   65 ++++++++++++++++++++++++++++++++---------------
 drivers/acpi/internal.h  |    4 --
 3 files changed, 46 insertions(+), 25 deletions(-)

Index: linux-pm/drivers/acpi/Makefile
===================================================================
--- linux-pm.orig/drivers/acpi/Makefile
+++ linux-pm/drivers/acpi/Makefile
@@ -39,7 +39,7 @@ acpi-y				+= processor_core.o
 acpi-y				+= ec.o
 acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
 acpi-y				+= pci_root.o pci_link.o pci_irq.o
-acpi-$(CONFIG_X86_INTEL_LPSS)	+= acpi_lpss.o
+acpi-y				+= acpi_lpss.o
 acpi-y				+= acpi_platform.o
 acpi-y				+= acpi_pnp.o
 acpi-y				+= power.o
Index: linux-pm/drivers/acpi/acpi_lpss.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_lpss.c
+++ linux-pm/drivers/acpi/acpi_lpss.c
@@ -25,6 +25,10 @@
 
 ACPI_MODULE_NAME("acpi_lpss");
 
+#ifdef CONFIG_X86_INTEL_LPSS
+
+#define LPSS_PTR(desc) ((unsigned long)&desc)
+
 #define LPSS_CLK_SIZE	0x04
 #define LPSS_LTR_SIZE	0x18
 
@@ -168,40 +172,48 @@ static struct lpss_device_desc byt_i2c_d
 	.shared_clock = &i2c_clock,
 };
 
+#else
+
+#define LPSS_PTR(desc) (NULL)
+
+#endif /* CONFIG_X86_INTEL_LPSS */
+
 static const struct acpi_device_id acpi_lpss_device_ids[] = {
 	/* Generic LPSS devices */
-	{ "INTL9C60", (unsigned long)&lpss_dma_desc },
+	{ "INTL9C60", LPSS_PTR(lpss_dma_desc) },
 
 	/* Lynxpoint LPSS devices */
-	{ "INT33C0", (unsigned long)&lpt_dev_desc },
-	{ "INT33C1", (unsigned long)&lpt_dev_desc },
-	{ "INT33C2", (unsigned long)&lpt_dev_desc },
-	{ "INT33C3", (unsigned long)&lpt_dev_desc },
-	{ "INT33C4", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT33C5", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT33C6", (unsigned long)&lpt_sdio_dev_desc },
+	{ "INT33C0", LPSS_PTR(lpt_dev_desc) },
+	{ "INT33C1", LPSS_PTR(lpt_dev_desc) },
+	{ "INT33C2", LPSS_PTR(lpt_dev_desc) },
+	{ "INT33C3", LPSS_PTR(lpt_dev_desc) },
+	{ "INT33C4", LPSS_PTR(lpt_uart_dev_desc) },
+	{ "INT33C5", LPSS_PTR(lpt_uart_dev_desc) },
+	{ "INT33C6", LPSS_PTR(lpt_sdio_dev_desc) },
 	{ "INT33C7", },
 
 	/* BayTrail LPSS devices */
-	{ "80860F09", (unsigned long)&byt_pwm_dev_desc },
-	{ "80860F0A", (unsigned long)&byt_uart_dev_desc },
-	{ "80860F0E", (unsigned long)&byt_spi_dev_desc },
-	{ "80860F14", (unsigned long)&byt_sdio_dev_desc },
-	{ "80860F41", (unsigned long)&byt_i2c_dev_desc },
+	{ "80860F09", LPSS_PTR(byt_pwm_dev_desc) },
+	{ "80860F0A", LPSS_PTR(byt_uart_dev_desc) },
+	{ "80860F0E", LPSS_PTR(byt_spi_dev_desc) },
+	{ "80860F14", LPSS_PTR(byt_sdio_dev_desc) },
+	{ "80860F41", LPSS_PTR(byt_i2c_dev_desc) },
 	{ "INT33B2", },
 
-	{ "INT3430", (unsigned long)&lpt_dev_desc },
-	{ "INT3431", (unsigned long)&lpt_dev_desc },
-	{ "INT3432", (unsigned long)&lpt_dev_desc },
-	{ "INT3433", (unsigned long)&lpt_dev_desc },
-	{ "INT3434", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT3435", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT3436", (unsigned long)&lpt_sdio_dev_desc },
+	{ "INT3430", LPSS_PTR(lpt_dev_desc) },
+	{ "INT3431", LPSS_PTR(lpt_dev_desc) },
+	{ "INT3432", LPSS_PTR(lpt_dev_desc) },
+	{ "INT3433", LPSS_PTR(lpt_dev_desc) },
+	{ "INT3434", LPSS_PTR(lpt_uart_dev_desc) },
+	{ "INT3435", LPSS_PTR(lpt_uart_dev_desc) },
+	{ "INT3436", LPSS_PTR(lpt_sdio_dev_desc) },
 	{ "INT3437", },
 
 	{ }
 };
 
+#ifdef CONFIG_X86_INTEL_LPSS
+
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
 	struct resource r;
@@ -666,3 +678,16 @@ void __init acpi_lpss_init(void)
 		acpi_scan_add_handler(&lpss_handler);
 	}
 }
+
+#else
+
+static struct acpi_scan_handler lpss_handler = {
+	.ids = acpi_lpss_device_ids,
+};
+
+void __init acpi_lpss_init(void)
+{
+	acpi_scan_add_handler(&lpss_handler);
+}
+
+#endif /* CONFIG_X86_INTEL_LPSS */
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -65,11 +65,7 @@ int acpi_debugfs_init(void);
 #else
 static inline void acpi_debugfs_init(void) { return; }
 #endif
-#ifdef CONFIG_X86_INTEL_LPSS
 void acpi_lpss_init(void);
-#else
-static inline void acpi_lpss_init(void) {}
-#endif
 
 acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
 bool acpi_queue_hotplug_work(struct work_struct *work);


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

* [PATCH 10/10] ACPI / scan: use platform bus type by default for _HID enumeration
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
                     ` (8 preceding siblings ...)
  2014-05-30  2:30   ` [PATCH 9/10] ACPI / scan: always register ACPI LPSS " Rafael J. Wysocki
@ 2014-05-30  2:30   ` Rafael J. Wysocki
  2014-05-30 12:35     ` [Update][PATCH " Rafael J. Wysocki
  2014-05-30  8:33   ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Mika Westerberg
  2014-05-31 14:46   ` Zhang Rui
  11 siblings, 1 reply; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30  2:30 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

From: Zhang Rui <rui.zhang@intel.com>

Because of the growing demand for enumerating ACPI devices to
platform bus, change the code to enumerate ACPI devices to platform
bus by default.  That will happen if the device object
 1. Has pnp.type.platform_id set (device objects with _HID currently).
 2. Does not have a scan handler attached.
 3. Is not an SPI/I2C slave device, which should be enumerated
    to the appropriate bus bus by its parent.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[rjw: Subject and changelog, rebase and code cleanup]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_platform.c | 28 ------------------------
 drivers/acpi/acpi_platform.c |   40 +++++++--------------------------------
 drivers/acpi/scan.c          |   44 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 33 deletions(-)

Index: linux-pm/drivers/acpi/acpi_platform.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_platform.c
+++ linux-pm/drivers/acpi/acpi_platform.c
@@ -22,21 +22,11 @@
 
 ACPI_MODULE_NAME("platform");
 
-/*
- * The following ACPI IDs are known to be suitable for representing as
- * platform devices.
- */
-static const struct acpi_device_id acpi_platform_device_ids[] = {
-
-	{ "PNP0D40" },
-	{ "VPC2004" },
-	{ "BCM4752" },
-
-	/* Intel Smart Sound Technology */
-	{ "INT33C8" },
-	{ "80860F28" },
-
-	{ }
+static const struct acpi_device_id forbidden_id_list[] = {
+	{"PNP0000", 0},	/* PIC */
+	{"PNP0100", 0},	/* Timer */
+	{"PNP0200", 0},	/* AT DMA Controller */
+	{"", 0},
 };
 
 /**
@@ -63,6 +53,9 @@ struct platform_device *acpi_create_plat
 	if (adev->physical_node_count)
 		return NULL;
 
+	if (!acpi_match_device_ids(adev, forbidden_id_list))
+		return ERR_PTR(-EINVAL);
+
 	INIT_LIST_HEAD(&resource_list);
 	count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
 	if (count < 0) {
@@ -120,20 +113,3 @@ struct platform_device *acpi_create_plat
 	kfree(resources);
 	return pdev;
 }
-
-static int acpi_platform_attach(struct acpi_device *adev,
-				const struct acpi_device_id *id)
-{
-	acpi_create_platform_device(adev);
-	return 1;
-}
-
-static struct acpi_scan_handler platform_handler = {
-	.ids = acpi_platform_device_ids,
-	.attach = acpi_platform_attach,
-};
-
-void __init acpi_platform_init(void)
-{
-	acpi_scan_add_handler(&platform_handler);
-}
Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -2070,6 +2070,46 @@ static acpi_status acpi_bus_check_add(ac
 	return AE_OK;
 }
 
+static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
+{
+	bool *is_spi_i2c_slave_p = data;
+
+	if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
+		return 1;
+
+	/*
+	 * devices that are connected to UART still need to be enumerated to
+	 * platform bus
+	 */
+	if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
+		*is_spi_i2c_slave_p = true;
+
+	 /* no need to do more checking */
+	return -1;
+}
+
+static void acpi_default_enumeration(struct acpi_device *device)
+{
+	struct list_head resource_list;
+	bool is_spi_i2c_slave = false;
+
+	if (!device->pnp.type.platform_id || device->handler)
+		return;
+
+	/*
+	 * Do not enemerate SPI/I2C slaves as they will be enuerated to by their
+	 * respective parents.
+	 */
+	INIT_LIST_HEAD(&resource_list);
+	acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
+			       &is_spi_i2c_slave);
+	acpi_dev_free_resource_list(&resource_list);
+	if (is_spi_i2c_slave)
+		return;
+
+	acpi_create_platform_device(device);
+}
+
 static int acpi_scan_attach_handler(struct acpi_device *device)
 {
 	struct acpi_hardware_id *hwid;
@@ -2095,6 +2135,9 @@ static int acpi_scan_attach_handler(stru
 				break;
 		}
 	}
+	if (!ret)
+		acpi_default_enumeration(device);
+
 	return ret;
 }
 
@@ -2254,7 +2297,6 @@ int __init acpi_scan_init(void)
 	acpi_pci_root_init();
 	acpi_pci_link_init();
 	acpi_processor_init();
-	acpi_platform_init();
 	acpi_lpss_init();
 	acpi_cmos_rtc_init();
 	acpi_container_init();


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

* Re: [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework)
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
                     ` (9 preceding siblings ...)
  2014-05-30  2:30   ` [PATCH 10/10] ACPI / scan: use platform bus type by default for _HID enumeration Rafael J. Wysocki
@ 2014-05-30  8:33   ` Mika Westerberg
  2014-05-30 12:17     ` Rafael J. Wysocki
  2014-05-31 14:46   ` Zhang Rui
  11 siblings, 1 reply; 40+ messages in thread
From: Mika Westerberg @ 2014-05-30  8:33 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Zhang Rui, linux-acpi, linux-kernel, matthew.garrett

On Fri, May 30, 2014 at 04:20:41AM +0200, Rafael J. Wysocki wrote:
> On Friday, May 23, 2014 02:02:22 AM Zhang Rui wrote:
> > Hi, all,
> > 
> > Currently, PNP bus is used as the default bus for for enumerating ACPI
> > devices with _HID/_CID.
> > For a device that needs to be enumerated to platform bus, we need to add
> > its id string to the platform scan handler white list explicitly.
> > 
> > This becomes a problem as more and more _HID devices need to be
> > enumerated to platform bus nowadays, thus the list is continuously growing.
> > 
> > So, a solution that uses platform bus for _HID enumeration by default
> > is preferred.
> > 
> 
> OK, this has had several rounds of review already and we're really starting
> to run out of time with it, so my version of this patchset follows.
> 
> It is mostly based on your patches, but reordered and with some major
> changes.  Compiled only for now, so please let me know if there's any
> breakage in it.  [The last patch will not apply without update of the
> device list being removed, but generally this is on top of linux-next
> material.]

The series looks good to me now.

You can add

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

to all the patches if you like.

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

* Re: [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework)
  2014-05-30  8:33   ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Mika Westerberg
@ 2014-05-30 12:17     ` Rafael J. Wysocki
  0 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30 12:17 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: Zhang Rui, linux-acpi, linux-kernel, matthew.garrett

On Friday, May 30, 2014 11:33:25 AM Mika Westerberg wrote:
> On Fri, May 30, 2014 at 04:20:41AM +0200, Rafael J. Wysocki wrote:
> > On Friday, May 23, 2014 02:02:22 AM Zhang Rui wrote:
> > > Hi, all,
> > > 
> > > Currently, PNP bus is used as the default bus for for enumerating ACPI
> > > devices with _HID/_CID.
> > > For a device that needs to be enumerated to platform bus, we need to add
> > > its id string to the platform scan handler white list explicitly.
> > > 
> > > This becomes a problem as more and more _HID devices need to be
> > > enumerated to platform bus nowadays, thus the list is continuously growing.
> > > 
> > > So, a solution that uses platform bus for _HID enumeration by default
> > > is preferred.
> > > 
> > 
> > OK, this has had several rounds of review already and we're really starting
> > to run out of time with it, so my version of this patchset follows.
> > 
> > It is mostly based on your patches, but reordered and with some major
> > changes.  Compiled only for now, so please let me know if there's any
> > breakage in it.  [The last patch will not apply without update of the
> > device list being removed, but generally this is on top of linux-next
> > material.]
> 
> The series looks good to me now.
> 
> You can add
> 
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> 
> to all the patches if you like.

I will, thanks! :-)

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

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

* [Update][PATCH 9/10] ACPI / scan: always register ACPI LPSS scan handler
  2014-05-30  2:30   ` [PATCH 9/10] ACPI / scan: always register ACPI LPSS " Rafael J. Wysocki
@ 2014-05-30 12:34     ` Rafael J. Wysocki
  0 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30 12:34 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

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

Prevent platform devices from being created for ACPI LPSS devices
if CONFIG_X86_INTEL_LPSS is unset by compiling out the LPSS scan
handler's callbacks only in that case and still compiling its device
ID list in and registering the scan handler in either case.

This change is based on a prototype from Zhang Rui.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

---

The LPSS_PTR macro has been renamed to LPSS_ADDR (because it returns a number,
not a pointer) and the "trivial" version is now (OUL).

Thanks!

---
drivers/acpi/Makefile    |  2 +-
 drivers/acpi/Makefile    |    2 -
 drivers/acpi/acpi_lpss.c |   65 ++++++++++++++++++++++++++++++++---------------
 drivers/acpi/internal.h  |    4 --
 3 files changed, 46 insertions(+), 25 deletions(-)

Index: linux-pm/drivers/acpi/Makefile
===================================================================
--- linux-pm.orig/drivers/acpi/Makefile
+++ linux-pm/drivers/acpi/Makefile
@@ -39,7 +39,7 @@ acpi-y				+= processor_core.o
 acpi-y				+= ec.o
 acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
 acpi-y				+= pci_root.o pci_link.o pci_irq.o
-acpi-$(CONFIG_X86_INTEL_LPSS)	+= acpi_lpss.o
+acpi-y				+= acpi_lpss.o
 acpi-y				+= acpi_platform.o
 acpi-y				+= acpi_pnp.o
 acpi-y				+= power.o
Index: linux-pm/drivers/acpi/acpi_lpss.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_lpss.c
+++ linux-pm/drivers/acpi/acpi_lpss.c
@@ -25,6 +25,10 @@
 
 ACPI_MODULE_NAME("acpi_lpss");
 
+#ifdef CONFIG_X86_INTEL_LPSS
+
+#define LPSS_ADDR(desc) ((unsigned long)&desc)
+
 #define LPSS_CLK_SIZE	0x04
 #define LPSS_LTR_SIZE	0x18
 
@@ -168,40 +172,48 @@ static struct lpss_device_desc byt_i2c_d
 	.shared_clock = &i2c_clock,
 };
 
+#else
+
+#define LPSS_ADDR(desc) (0UL)
+
+#endif /* CONFIG_X86_INTEL_LPSS */
+
 static const struct acpi_device_id acpi_lpss_device_ids[] = {
 	/* Generic LPSS devices */
-	{ "INTL9C60", (unsigned long)&lpss_dma_desc },
+	{ "INTL9C60", LPSS_ADDR(lpss_dma_desc) },
 
 	/* Lynxpoint LPSS devices */
-	{ "INT33C0", (unsigned long)&lpt_dev_desc },
-	{ "INT33C1", (unsigned long)&lpt_dev_desc },
-	{ "INT33C2", (unsigned long)&lpt_dev_desc },
-	{ "INT33C3", (unsigned long)&lpt_dev_desc },
-	{ "INT33C4", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT33C5", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT33C6", (unsigned long)&lpt_sdio_dev_desc },
+	{ "INT33C0", LPSS_ADDR(lpt_dev_desc) },
+	{ "INT33C1", LPSS_ADDR(lpt_dev_desc) },
+	{ "INT33C2", LPSS_ADDR(lpt_dev_desc) },
+	{ "INT33C3", LPSS_ADDR(lpt_dev_desc) },
+	{ "INT33C4", LPSS_ADDR(lpt_uart_dev_desc) },
+	{ "INT33C5", LPSS_ADDR(lpt_uart_dev_desc) },
+	{ "INT33C6", LPSS_ADDR(lpt_sdio_dev_desc) },
 	{ "INT33C7", },
 
 	/* BayTrail LPSS devices */
-	{ "80860F09", (unsigned long)&byt_pwm_dev_desc },
-	{ "80860F0A", (unsigned long)&byt_uart_dev_desc },
-	{ "80860F0E", (unsigned long)&byt_spi_dev_desc },
-	{ "80860F14", (unsigned long)&byt_sdio_dev_desc },
-	{ "80860F41", (unsigned long)&byt_i2c_dev_desc },
+	{ "80860F09", LPSS_ADDR(byt_pwm_dev_desc) },
+	{ "80860F0A", LPSS_ADDR(byt_uart_dev_desc) },
+	{ "80860F0E", LPSS_ADDR(byt_spi_dev_desc) },
+	{ "80860F14", LPSS_ADDR(byt_sdio_dev_desc) },
+	{ "80860F41", LPSS_ADDR(byt_i2c_dev_desc) },
 	{ "INT33B2", },
 
-	{ "INT3430", (unsigned long)&lpt_dev_desc },
-	{ "INT3431", (unsigned long)&lpt_dev_desc },
-	{ "INT3432", (unsigned long)&lpt_dev_desc },
-	{ "INT3433", (unsigned long)&lpt_dev_desc },
-	{ "INT3434", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT3435", (unsigned long)&lpt_uart_dev_desc },
-	{ "INT3436", (unsigned long)&lpt_sdio_dev_desc },
+	{ "INT3430", LPSS_ADDR(lpt_dev_desc) },
+	{ "INT3431", LPSS_ADDR(lpt_dev_desc) },
+	{ "INT3432", LPSS_ADDR(lpt_dev_desc) },
+	{ "INT3433", LPSS_ADDR(lpt_dev_desc) },
+	{ "INT3434", LPSS_ADDR(lpt_uart_dev_desc) },
+	{ "INT3435", LPSS_ADDR(lpt_uart_dev_desc) },
+	{ "INT3436", LPSS_ADDR(lpt_sdio_dev_desc) },
 	{ "INT3437", },
 
 	{ }
 };
 
+#ifdef CONFIG_X86_INTEL_LPSS
+
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
 	struct resource r;
@@ -666,3 +678,16 @@ void __init acpi_lpss_init(void)
 		acpi_scan_add_handler(&lpss_handler);
 	}
 }
+
+#else
+
+static struct acpi_scan_handler lpss_handler = {
+	.ids = acpi_lpss_device_ids,
+};
+
+void __init acpi_lpss_init(void)
+{
+	acpi_scan_add_handler(&lpss_handler);
+}
+
+#endif /* CONFIG_X86_INTEL_LPSS */
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -65,11 +65,7 @@ int acpi_debugfs_init(void);
 #else
 static inline void acpi_debugfs_init(void) { return; }
 #endif
-#ifdef CONFIG_X86_INTEL_LPSS
 void acpi_lpss_init(void);
-#else
-static inline void acpi_lpss_init(void) {}
-#endif
 
 acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
 bool acpi_queue_hotplug_work(struct work_struct *work);


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

* [Update][PATCH 10/10] ACPI / scan: use platform bus type by default for _HID enumeration
  2014-05-30  2:30   ` [PATCH 10/10] ACPI / scan: use platform bus type by default for _HID enumeration Rafael J. Wysocki
@ 2014-05-30 12:35     ` Rafael J. Wysocki
  2014-05-31  5:56       ` Zhang Rui
  0 siblings, 1 reply; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30 12:35 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

From: Zhang Rui <rui.zhang@intel.com>

Because of the growing demand for enumerating ACPI devices to
platform bus, change the code to enumerate ACPI device objects to
platform bus by default.  Namely, create platform devices for the
ACPI device objects that
 1. Have pnp.type.platform_id set (device objects with _HID currently).
 2. Do not have a scan handler attached.
 3. Are not SPI/I2C slave devices (that should be enumerated to the
    appropriate buses bus by their parent).

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[rjw: Subject and changelog, rebase and code cleanup]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

Changelog rework and minor cleanups.

Thanks!

---
 drivers/acpi/acpi_platform.c |   40 ++++++++--------------------------------
 drivers/acpi/scan.c          |   42 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 33 deletions(-)

Index: linux-pm/drivers/acpi/acpi_platform.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_platform.c
+++ linux-pm/drivers/acpi/acpi_platform.c
@@ -22,21 +22,11 @@
 
 ACPI_MODULE_NAME("platform");
 
-/*
- * The following ACPI IDs are known to be suitable for representing as
- * platform devices.
- */
-static const struct acpi_device_id acpi_platform_device_ids[] = {
-
-	{ "PNP0D40" },
-	{ "VPC2004" },
-	{ "BCM4752" },
-
-	/* Intel Smart Sound Technology */
-	{ "INT33C8" },
-	{ "80860F28" },
-
-	{ }
+static const struct acpi_device_id forbidden_id_list[] = {
+	{"PNP0000", 0},	/* PIC */
+	{"PNP0100", 0},	/* Timer */
+	{"PNP0200", 0},	/* AT DMA Controller */
+	{"", 0},
 };
 
 /**
@@ -63,6 +53,9 @@ struct platform_device *acpi_create_plat
 	if (adev->physical_node_count)
 		return NULL;
 
+	if (!acpi_match_device_ids(adev, forbidden_id_list))
+		return ERR_PTR(-EINVAL);
+
 	INIT_LIST_HEAD(&resource_list);
 	count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
 	if (count < 0) {
@@ -120,20 +113,3 @@ struct platform_device *acpi_create_plat
 	kfree(resources);
 	return pdev;
 }
-
-static int acpi_platform_attach(struct acpi_device *adev,
-				const struct acpi_device_id *id)
-{
-	acpi_create_platform_device(adev);
-	return 1;
-}
-
-static struct acpi_scan_handler platform_handler = {
-	.ids = acpi_platform_device_ids,
-	.attach = acpi_platform_attach,
-};
-
-void __init acpi_platform_init(void)
-{
-	acpi_scan_add_handler(&platform_handler);
-}
Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -2070,6 +2070,44 @@ static acpi_status acpi_bus_check_add(ac
 	return AE_OK;
 }
 
+static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
+{
+	bool *is_spi_i2c_slave_p = data;
+
+	if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
+		return 1;
+
+	/*
+	 * devices that are connected to UART still need to be enumerated to
+	 * platform bus
+	 */
+	if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
+		*is_spi_i2c_slave_p = true;
+
+	 /* no need to do more checking */
+	return -1;
+}
+
+static void acpi_default_enumeration(struct acpi_device *device)
+{
+	struct list_head resource_list;
+	bool is_spi_i2c_slave = false;
+
+	if (!device->pnp.type.platform_id || device->handler)
+		return;
+
+	/*
+	 * Do not enemerate SPI/I2C slaves as they will be enuerated by their
+	 * respective parents.
+	 */
+	INIT_LIST_HEAD(&resource_list);
+	acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
+			       &is_spi_i2c_slave);
+	acpi_dev_free_resource_list(&resource_list);
+	if (!is_spi_i2c_slave)
+		acpi_create_platform_device(device);
+}
+
 static int acpi_scan_attach_handler(struct acpi_device *device)
 {
 	struct acpi_hardware_id *hwid;
@@ -2095,6 +2133,9 @@ static int acpi_scan_attach_handler(stru
 				break;
 		}
 	}
+	if (!ret)
+		acpi_default_enumeration(device);
+
 	return ret;
 }
 
@@ -2254,7 +2295,6 @@ int __init acpi_scan_init(void)
 	acpi_pci_root_init();
 	acpi_pci_link_init();
 	acpi_processor_init();
-	acpi_platform_init();
 	acpi_lpss_init();
 	acpi_cmos_rtc_init();
 	acpi_container_init();


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

* Re: [Update][PATCH 10/10] ACPI / scan: use platform bus type by default for _HID enumeration
  2014-05-30 12:35     ` [Update][PATCH " Rafael J. Wysocki
@ 2014-05-31  5:56       ` Zhang Rui
  2014-05-31  6:29         ` Zhang Rui
  0 siblings, 1 reply; 40+ messages in thread
From: Zhang Rui @ 2014-05-31  5:56 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

On Fri, 2014-05-30 at 14:35 +0200, Rafael J. Wysocki wrote:
> From: Zhang Rui <rui.zhang@intel.com>
> 
> Because of the growing demand for enumerating ACPI devices to
> platform bus, change the code to enumerate ACPI device objects to
> platform bus by default.  Namely, create platform devices for the
> ACPI device objects that
>  1. Have pnp.type.platform_id set (device objects with _HID currently).
>  2. Do not have a scan handler attached.
>  3. Are not SPI/I2C slave devices (that should be enumerated to the
>     appropriate buses bus by their parent).
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> [rjw: Subject and changelog, rebase and code cleanup]
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> 
> Changelog rework and minor cleanups.
> 
> Thanks!
> 
> ---
>  drivers/acpi/acpi_platform.c |   40 ++++++++--------------------------------
>  drivers/acpi/scan.c          |   42 +++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 49 insertions(+), 33 deletions(-)
> 
> Index: linux-pm/drivers/acpi/acpi_platform.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/acpi_platform.c
> +++ linux-pm/drivers/acpi/acpi_platform.c
> @@ -22,21 +22,11 @@
>  
>  ACPI_MODULE_NAME("platform");
>  
> -/*
> - * The following ACPI IDs are known to be suitable for representing as
> - * platform devices.
> - */
> -static const struct acpi_device_id acpi_platform_device_ids[] = {
> -
> -	{ "PNP0D40" },
> -	{ "VPC2004" },
> -	{ "BCM4752" },
> -
> -	/* Intel Smart Sound Technology */
> -	{ "INT33C8" },
> -	{ "80860F28" },
> -
> -	{ }
> +static const struct acpi_device_id forbidden_id_list[] = {
> +	{"PNP0000", 0},	/* PIC */
> +	{"PNP0100", 0},	/* Timer */
> +	{"PNP0200", 0},	/* AT DMA Controller */
> +	{"", 0},
>  };
>  
>  /**
> @@ -63,6 +53,9 @@ struct platform_device *acpi_create_plat
>  	if (adev->physical_node_count)
>  		return NULL;
>  
> +	if (!acpi_match_device_ids(adev, forbidden_id_list))
> +		return ERR_PTR(-EINVAL);
> +
>  	INIT_LIST_HEAD(&resource_list);
>  	count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
>  	if (count < 0) {
> @@ -120,20 +113,3 @@ struct platform_device *acpi_create_plat
>  	kfree(resources);
>  	return pdev;
>  }
> -
> -static int acpi_platform_attach(struct acpi_device *adev,
> -				const struct acpi_device_id *id)
> -{
> -	acpi_create_platform_device(adev);
> -	return 1;
> -}
> -
this patch does not apply.
we do not have the above code in drivers/acpi/acpi_platform.c.

thanks,
rui
> -static struct acpi_scan_handler platform_handler = {
> -	.ids = acpi_platform_device_ids,
> -	.attach = acpi_platform_attach,
> -};
> -
> -void __init acpi_platform_init(void)
> -{
> -	acpi_scan_add_handler(&platform_handler);
> -}
> Index: linux-pm/drivers/acpi/scan.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/scan.c
> +++ linux-pm/drivers/acpi/scan.c
> @@ -2070,6 +2070,44 @@ static acpi_status acpi_bus_check_add(ac
>  	return AE_OK;
>  }
>  
> +static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
> +{
> +	bool *is_spi_i2c_slave_p = data;
> +
> +	if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
> +		return 1;
> +
> +	/*
> +	 * devices that are connected to UART still need to be enumerated to
> +	 * platform bus
> +	 */
> +	if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
> +		*is_spi_i2c_slave_p = true;
> +
> +	 /* no need to do more checking */
> +	return -1;
> +}
> +
> +static void acpi_default_enumeration(struct acpi_device *device)
> +{
> +	struct list_head resource_list;
> +	bool is_spi_i2c_slave = false;
> +
> +	if (!device->pnp.type.platform_id || device->handler)
> +		return;
> +
> +	/*
> +	 * Do not enemerate SPI/I2C slaves as they will be enuerated by their
> +	 * respective parents.
> +	 */
> +	INIT_LIST_HEAD(&resource_list);
> +	acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
> +			       &is_spi_i2c_slave);
> +	acpi_dev_free_resource_list(&resource_list);
> +	if (!is_spi_i2c_slave)
> +		acpi_create_platform_device(device);
> +}
> +
>  static int acpi_scan_attach_handler(struct acpi_device *device)
>  {
>  	struct acpi_hardware_id *hwid;
> @@ -2095,6 +2133,9 @@ static int acpi_scan_attach_handler(stru
>  				break;
>  		}
>  	}
> +	if (!ret)
> +		acpi_default_enumeration(device);
> +
>  	return ret;
>  }
>  
> @@ -2254,7 +2295,6 @@ int __init acpi_scan_init(void)
>  	acpi_pci_root_init();
>  	acpi_pci_link_init();
>  	acpi_processor_init();
> -	acpi_platform_init();
>  	acpi_lpss_init();
>  	acpi_cmos_rtc_init();
>  	acpi_container_init();
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" 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] 40+ messages in thread

* Re: [Update][PATCH 10/10] ACPI / scan: use platform bus type by default for _HID enumeration
  2014-05-31  5:56       ` Zhang Rui
@ 2014-05-31  6:29         ` Zhang Rui
  0 siblings, 0 replies; 40+ messages in thread
From: Zhang Rui @ 2014-05-31  6:29 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

On Sat, 2014-05-31 at 13:56 +0800, Zhang Rui wrote:
> On Fri, 2014-05-30 at 14:35 +0200, Rafael J. Wysocki wrote:
> > From: Zhang Rui <rui.zhang@intel.com>
> > 
> > Because of the growing demand for enumerating ACPI devices to
> > platform bus, change the code to enumerate ACPI device objects to
> > platform bus by default.  Namely, create platform devices for the
> > ACPI device objects that
> >  1. Have pnp.type.platform_id set (device objects with _HID currently).
> >  2. Do not have a scan handler attached.
> >  3. Are not SPI/I2C slave devices (that should be enumerated to the
> >     appropriate buses bus by their parent).
> > 
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > [rjw: Subject and changelog, rebase and code cleanup]
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> > 
> > Changelog rework and minor cleanups.
> > 
> > Thanks!
> > 
> > ---
> >  drivers/acpi/acpi_platform.c |   40 ++++++++--------------------------------
> >  drivers/acpi/scan.c          |   42 +++++++++++++++++++++++++++++++++++++++++-
> >  2 files changed, 49 insertions(+), 33 deletions(-)
> > 
> > Index: linux-pm/drivers/acpi/acpi_platform.c
> > ===================================================================
> > --- linux-pm.orig/drivers/acpi/acpi_platform.c
> > +++ linux-pm/drivers/acpi/acpi_platform.c
> > @@ -22,21 +22,11 @@
> >  
> >  ACPI_MODULE_NAME("platform");
> >  
> > -/*
> > - * The following ACPI IDs are known to be suitable for representing as
> > - * platform devices.
> > - */
> > -static const struct acpi_device_id acpi_platform_device_ids[] = {
> > -
> > -	{ "PNP0D40" },
> > -	{ "VPC2004" },
> > -	{ "BCM4752" },
> > -
> > -	/* Intel Smart Sound Technology */
> > -	{ "INT33C8" },
> > -	{ "80860F28" },
> > -
> > -	{ }
> > +static const struct acpi_device_id forbidden_id_list[] = {
> > +	{"PNP0000", 0},	/* PIC */
> > +	{"PNP0100", 0},	/* Timer */
> > +	{"PNP0200", 0},	/* AT DMA Controller */
> > +	{"", 0},
> >  };
> >  
> >  /**
> > @@ -63,6 +53,9 @@ struct platform_device *acpi_create_plat
> >  	if (adev->physical_node_count)
> >  		return NULL;
> >  
> > +	if (!acpi_match_device_ids(adev, forbidden_id_list))
> > +		return ERR_PTR(-EINVAL);
> > +
> >  	INIT_LIST_HEAD(&resource_list);
> >  	count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
> >  	if (count < 0) {
> > @@ -120,20 +113,3 @@ struct platform_device *acpi_create_plat
> >  	kfree(resources);
> >  	return pdev;
> >  }
> > -
> > -static int acpi_platform_attach(struct acpi_device *adev,
> > -				const struct acpi_device_id *id)
> > -{
> > -	acpi_create_platform_device(adev);
> > -	return 1;
> > -}
> > -
> this patch does not apply.
> we do not have the above code in drivers/acpi/acpi_platform.c.

I see. this patch is made based on the drivers/acpi/acpi_platform.c
changes in your linux-next branch. Sorry for the noise.

thanks,
rui
> 
> thanks,
> rui
> > -static struct acpi_scan_handler platform_handler = {
> > -	.ids = acpi_platform_device_ids,
> > -	.attach = acpi_platform_attach,
> > -};
> > -
> > -void __init acpi_platform_init(void)
> > -{
> > -	acpi_scan_add_handler(&platform_handler);
> > -}
> > Index: linux-pm/drivers/acpi/scan.c
> > ===================================================================
> > --- linux-pm.orig/drivers/acpi/scan.c
> > +++ linux-pm/drivers/acpi/scan.c
> > @@ -2070,6 +2070,44 @@ static acpi_status acpi_bus_check_add(ac
> >  	return AE_OK;
> >  }
> >  
> > +static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
> > +{
> > +	bool *is_spi_i2c_slave_p = data;
> > +
> > +	if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
> > +		return 1;
> > +
> > +	/*
> > +	 * devices that are connected to UART still need to be enumerated to
> > +	 * platform bus
> > +	 */
> > +	if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
> > +		*is_spi_i2c_slave_p = true;
> > +
> > +	 /* no need to do more checking */
> > +	return -1;
> > +}
> > +
> > +static void acpi_default_enumeration(struct acpi_device *device)
> > +{
> > +	struct list_head resource_list;
> > +	bool is_spi_i2c_slave = false;
> > +
> > +	if (!device->pnp.type.platform_id || device->handler)
> > +		return;
> > +
> > +	/*
> > +	 * Do not enemerate SPI/I2C slaves as they will be enuerated by their
> > +	 * respective parents.
> > +	 */
> > +	INIT_LIST_HEAD(&resource_list);
> > +	acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
> > +			       &is_spi_i2c_slave);
> > +	acpi_dev_free_resource_list(&resource_list);
> > +	if (!is_spi_i2c_slave)
> > +		acpi_create_platform_device(device);
> > +}
> > +
> >  static int acpi_scan_attach_handler(struct acpi_device *device)
> >  {
> >  	struct acpi_hardware_id *hwid;
> > @@ -2095,6 +2133,9 @@ static int acpi_scan_attach_handler(stru
> >  				break;
> >  		}
> >  	}
> > +	if (!ret)
> > +		acpi_default_enumeration(device);
> > +
> >  	return ret;
> >  }
> >  
> > @@ -2254,7 +2295,6 @@ int __init acpi_scan_init(void)
> >  	acpi_pci_root_init();
> >  	acpi_pci_link_init();
> >  	acpi_processor_init();
> > -	acpi_platform_init();
> >  	acpi_lpss_init();
> >  	acpi_cmos_rtc_init();
> >  	acpi_container_init();
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" 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] 40+ messages in thread

* Re: [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework)
  2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
                     ` (10 preceding siblings ...)
  2014-05-30  8:33   ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Mika Westerberg
@ 2014-05-31 14:46   ` Zhang Rui
  2014-05-31 22:29     ` Rafael J. Wysocki
  11 siblings, 1 reply; 40+ messages in thread
From: Zhang Rui @ 2014-05-31 14:46 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

On Fri, 2014-05-30 at 04:20 +0200, Rafael J. Wysocki wrote:
> On Friday, May 23, 2014 02:02:22 AM Zhang Rui wrote:
> > Hi, all,
> > 
> > Currently, PNP bus is used as the default bus for for enumerating ACPI
> > devices with _HID/_CID.
> > For a device that needs to be enumerated to platform bus, we need to add
> > its id string to the platform scan handler white list explicitly.
> > 
> > This becomes a problem as more and more _HID devices need to be
> > enumerated to platform bus nowadays, thus the list is continuously growing.
> > 
> > So, a solution that uses platform bus for _HID enumeration by default
> > is preferred.
> > 
> 
> OK, this has had several rounds of review already and we're really starting
> to run out of time with it, so my version of this patchset follows.
> 
> It is mostly based on your patches, but reordered and with some major
> changes.  Compiled only for now, so please let me know if there's any
> breakage in it.  [The last patch will not apply without update of the
> device list being removed, but generally this is on top of linux-next
> material.]
> 
Applied the patch set on top of linux-pm tree linux-next branch, with
some modifications of Patch 9/10 because of the updated lpss id list,
it works as expected on an IVB Ultrabook.

Tested-by: Zhang Rui <rui.zhang@intel.com>

thanks,
rui


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

* Re: [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework)
  2014-05-31 14:46   ` Zhang Rui
@ 2014-05-31 22:29     ` Rafael J. Wysocki
  0 siblings, 0 replies; 40+ messages in thread
From: Rafael J. Wysocki @ 2014-05-31 22:29 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, linux-kernel, matthew.garrett, mika.westerberg

On Saturday, May 31, 2014 10:46:36 PM Zhang Rui wrote:
> On Fri, 2014-05-30 at 04:20 +0200, Rafael J. Wysocki wrote:
> > On Friday, May 23, 2014 02:02:22 AM Zhang Rui wrote:
> > > Hi, all,
> > > 
> > > Currently, PNP bus is used as the default bus for for enumerating ACPI
> > > devices with _HID/_CID.
> > > For a device that needs to be enumerated to platform bus, we need to add
> > > its id string to the platform scan handler white list explicitly.
> > > 
> > > This becomes a problem as more and more _HID devices need to be
> > > enumerated to platform bus nowadays, thus the list is continuously growing.
> > > 
> > > So, a solution that uses platform bus for _HID enumeration by default
> > > is preferred.
> > > 
> > 
> > OK, this has had several rounds of review already and we're really starting
> > to run out of time with it, so my version of this patchset follows.
> > 
> > It is mostly based on your patches, but reordered and with some major
> > changes.  Compiled only for now, so please let me know if there's any
> > breakage in it.  [The last patch will not apply without update of the
> > device list being removed, but generally this is on top of linux-next
> > material.]
> > 
> Applied the patch set on top of linux-pm tree linux-next branch, with
> some modifications of Patch 9/10 because of the updated lpss id list,
> it works as expected on an IVB Ultrabook.
> 
> Tested-by: Zhang Rui <rui.zhang@intel.com>

Thanks for doing that, much appreciated!

Rafael


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

end of thread, other threads:[~2014-05-31 22:12 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22 18:02 [PATCH V7 00/11] ACPI: ACPI enumeration rework Zhang Rui
2014-05-22 18:02 ` [PATCH V7 01/11] ACPI: introduce .match() callback for ACPI scan handler Zhang Rui
2014-05-22 18:02 ` [PATCH V7 02/11] PNPACPI: use whilte list for pnpacpi device enumeration Zhang Rui
2014-05-22 18:14   ` Bjorn Helgaas
2014-05-23  0:00     ` Zhang Rui
2014-05-22 18:02 ` [PATCH V7 03/11] ACPI: remove ids that does not comply with the ACPI PNP id rule Zhang Rui
2014-05-22 18:02 ` [PATCH V7 04/11] ACPI: remove unsupported serial PNP ids from acpi pnp scan handler id lsit Zhang Rui
2014-05-22 18:02 ` [PATCH V7 05/11] ACPI: allow scan handlers without .attach() callback Zhang Rui
2014-05-22 18:02 ` [PATCH V7 06/11] ACPI: always register container scan handler even if CONFIG_ACPI_CONTAINER is cleared Zhang Rui
2014-05-22 18:02 ` [PATCH V7 07/11] ACPI: always register memory hotplug scan handler even if CONFIG_ACPI_HOTPLUG_MEMORY " Zhang Rui
2014-05-22 18:02 ` [PATCH V7 08/11] ACPI: always register memory hotplug scan handler even if CONFIG_X86_INTEL_LPSS " Zhang Rui
2014-05-26 10:56   ` Mika Westerberg
2014-05-26 11:53     ` Rafael J. Wysocki
2014-05-26 11:52       ` Mika Westerberg
2014-05-26 12:40         ` Rafael J. Wysocki
2014-05-26 12:58           ` Mika Westerberg
2014-05-22 18:02 ` [PATCH V7 09/11] ACPI: introduce platform_id flag Zhang Rui
2014-05-22 18:02 ` [PATCH V7 10/11] ACPI: use platform bus as the default bus for _HID enumeration Zhang Rui
2014-05-26 10:21   ` Mika Westerberg
2014-05-28  7:16     ` Zhang Rui
2014-05-22 18:02 ` [PATCH V7 11/11] ACPI: introduce acpi platform exclude id list Zhang Rui
2014-05-30  2:20 ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Rafael J. Wysocki
2014-05-30  2:21   ` [PATCH 1/10] ACPI / scan: .match() callback for ACPI scan handlers Rafael J. Wysocki
2014-05-30  2:23   ` [PATCH 2/10] ACPI / PNP: use device ID list for PNPACPI device enumeration Rafael J. Wysocki
2014-05-30  2:24   ` [PATCH 3/10] ACPI / scan: drop IDs that do not comply with the ACPI PNP ID rule Rafael J. Wysocki
2014-05-30  2:25   ` [PATCH 4/10] ACPI / scan: drop unsupported serial IDs from PNP ACPI scan handler ID list Rafael J. Wysocki
2014-05-30  2:26   ` [PATCH 5/10] ACPI / scan: introduce platform_id device PNP type flag Rafael J. Wysocki
2014-05-30  2:27   ` [PATCH 6/10] ACPI / scan: Change the meaning of missing .attach() in scan handlers Rafael J. Wysocki
2014-05-30  2:28   ` [PATCH 7/10] ACPI / scan: always register container scan handler Rafael J. Wysocki
2014-05-30  2:29   ` [PATCH 8/10] ACPI / scan: always register memory hotplug " Rafael J. Wysocki
2014-05-30  2:30   ` [PATCH 9/10] ACPI / scan: always register ACPI LPSS " Rafael J. Wysocki
2014-05-30 12:34     ` [Update][PATCH " Rafael J. Wysocki
2014-05-30  2:30   ` [PATCH 10/10] ACPI / scan: use platform bus type by default for _HID enumeration Rafael J. Wysocki
2014-05-30 12:35     ` [Update][PATCH " Rafael J. Wysocki
2014-05-31  5:56       ` Zhang Rui
2014-05-31  6:29         ` Zhang Rui
2014-05-30  8:33   ` [PATCH 0/10] ACPI enumeration rework (was: Re: [PATCH V7 00/11] ACPI: ACPI enumeration rework) Mika Westerberg
2014-05-30 12:17     ` Rafael J. Wysocki
2014-05-31 14:46   ` Zhang Rui
2014-05-31 22:29     ` Rafael J. Wysocki

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