Skip to content

RFC: ACPI: Interface for ACPI drivers to place quirk code which gets executed early

Thomas Renninger linux-acpi lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2RFC: ACPI: Interface for ACPI drivers to place quirk code which gets executed earlydrivers/acpi/Makefileindex 65d90c7..498cc6f 100644--- a/drivers/acpi/Makefile+++ b/drivers/acpi/Makefile@@ -59,3 +59,4 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o obj-$(CONFIG_ACPI_SBS) += sbshc.o obj-$(CONFIG_ACPI_SBS) += sbs.o+obj-y += quirks.o\ No newline at end of filediff --git a/drivers/acpi/acpi.h b/drivers/acpi/acpi.hnew file mode 100644index 0000000..95e29ca--- /dev/null+++ b/drivers/acpi/acpi.h@@ -0,0 +1,8 @@+#ifndef _LINUX_LOCAL_ACPI_H+#define _LINUX_LOCAL_ACPI_H++#include <linux/init.h>++void __init acpi_device_quirks(void);++#endif /* _LINUX_LOCAL_ACPI_H */diff --git a/drivers/acpi/quirks.c b/drivers/acpi/quirks.cnew file mode 100644index 0000000..844480e--- /dev/null+++ b/drivers/acpi/quirks.c@@ -0,0 +1,73 @@+/*+ * Copyright (c) 2008 Thomas Renninger <[email protected]>+ *+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ *+ * This program is free software; you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation; either version 2 of the License, or+ * (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+ *+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ */++#include <linux/mod_devicetable.h>+#include <acpi/acpi_bus.h>+#include "acpi.h"++struct acpi_device_fixup {+ const char *hid;+ int (*fixup_cb)(struct acpi_device*);+};++/*+ * Add a callback here if your module needs to process code after the ACPI+ * core has parsed the DSDT and initialized all devices, but the code must+ * be processed before module load time.+ * Good candiates are ACPI vs legacy driver decisions which must be made+ * before the driver is loaded.+ */+const struct acpi_device_fixup __initdata fixup_table[] = {+};++static acpi_status __init+acpi_device_quirks_callback(acpi_handle handle,+ u32 level, void *ctxt, void **retv)+{+ acpi_status status;+ struct acpi_device *dev;+ struct acpi_device_id dev_id;+ int x, ret;++ status = acpi_bus_get_device(handle, &dev);+ if (ACPI_FAILURE(status))+ return AE_OK;++ for (x = 0; x < ARRAY_SIZE(fixup_table); x++) {+ memcpy(&dev_id.id, fixup_table[x].hid, ACPI_ID_LEN);+ if (!acpi_match_device_ids(dev, &dev_id)) {+ ret = fixup_table[x].fixup_cb(dev);+ if (ret)+ printk (KERN_ERR "Fixup failed for device: "+ "%s\n", fixup_table[x].hid);+ }+ }+ return AE_OK;+}++void __init acpi_device_quirks(void) {++ acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,+ ACPI_UINT32_MAX,+ acpi_device_quirks_callback,+ NULL, NULL);+}diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.cindex c54d7b6..1c25747 100644--- a/drivers/acpi/scan.c+++ b/drivers/acpi/scan.c@@ -10,6 +10,7 @@ #include <linux/kthread.h> #include <acpi/acpi_drivers.h>+#include "acpi.h" #define _COMPONENT ACPI_BUS_COMPONENT ACPI_MODULE_NAME("scan");@@ -1562,6 +1563,8 @@ static int __init acpi_scan_init(void) if (result) acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);+ else+ acpi_device_quirks(); Done: return result;����{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�+0 -05 replies
2/2RFC: ACPI: Set enforce_resources to strict if a ATK0110 device is found in namespacedrivers/acpi/acpi.hindex 95e29ca..c08037e 100644--- a/drivers/acpi/acpi.h+++ b/drivers/acpi/acpi.h@@ -5,4 +5,28 @@ void __init acpi_device_quirks(void); +/* Check of resource interference between native drivers and ACPI+ * OperationRegions (SystemIO and System Memory only).+ * IO ports and memory declared in ACPI might be used by the ACPI subsystem+ * in arbitrary AML code and can interfere with legacy drivers.+ * acpi_enforce_resources= can be set to:+ *+ * - strict (2)+ * -> further driver trying to access the resources will not load+ * - lax (default) (1)+ * -> further driver trying to access the resources will load, but you+ * get a system message that something might go wrong...+ *+ * - no (0)+ * -> ACPI Operation Region resources will not be registered+ *+ */+#define ENFORCE_RESOURCES_AUTO 3+#define ENFORCE_RESOURCES_STRICT 2+#define ENFORCE_RESOURCES_LAX 1+#define ENFORCE_RESOURCES_NO 0++extern unsigned int acpi_enforce_resources;++ #endif /* _LINUX_LOCAL_ACPI_H */diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.cindex 6729a49..92e4226 100644--- a/drivers/acpi/osl.c+++ b/drivers/acpi/osl.c@@ -50,6 +50,7 @@ #include <acpi/acpi.h> #include <acpi/acpi_bus.h> #include <acpi/processor.h>+#include "acpi.h" #define _COMPONENT ACPI_OS_SERVICES ACPI_MODULE_NAME("osl");@@ -1057,27 +1058,7 @@ static int __init acpi_wake_gpes_always_on_setup(char *str) __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); -/* Check of resource interference between native drivers and ACPI- * OperationRegions (SystemIO and System Memory only).- * IO ports and memory declared in ACPI might be used by the ACPI subsystem- * in arbitrary AML code and can interfere with legacy drivers.- * acpi_enforce_resources= can be set to:- *- * - strict (2)- * -> further driver trying to access the resources will not load- * - lax (default) (1)- * -> further driver trying to access the resources will load, but you- * get a system message that something might go wrong...- *- * - no (0)- * -> ACPI Operation Region resources will not be registered- *- */-#define ENFORCE_RESOURCES_STRICT 2-#define ENFORCE_RESOURCES_LAX 1-#define ENFORCE_RESOURCES_NO 0--static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_LAX;+unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_AUTO; static int __init acpi_enforce_resources_setup(char *str) {diff --git a/drivers/acpi/quirks.c b/drivers/acpi/quirks.cindex 844480e..a0d0731 100644--- a/drivers/acpi/quirks.c+++ b/drivers/acpi/quirks.c@@ -30,6 +30,20 @@ struct acpi_device_fixup { }; /*+ * ATK0110 is known to interfere with several hwmon drivers, as it also+ * reads temperture, fan, etc. on the same device hwmon drivers do.+ * Make sure possibly interfering hwmon/i2c/smbus drivers touching IO areas+ * which already got declared as ACPI Operation Regions cannot be loaded.+ */+int __init atk0110_interfere_fixups (struct acpi_device *dev) {++ printk ("Found device: %s\n", acpi_device_bid(dev));+ if (acpi_enforce_resources == ENFORCE_RESOURCES_AUTO)+ acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;+ return 0;+}++/* * Add a callback here if your module needs to process code after the ACPI * core has parsed the DSDT and initialized all devices, but the code must * be processed before module load time.@@ -37,6 +51,7 @@ struct acpi_device_fixup { * before the driver is loaded. */ const struct acpi_device_fixup __initdata fixup_table[] = {+ { "ATK0110", atk0110_interfere_fixups }, }; static acpi_status __init����{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�+0 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread