2014-04-08 07:56:21

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH 0/4] ACPICA: Fix some mis-ordered inclusions.

This patch fixes some mis-ordered inclusions for Linux resident ACPICA.
There is no real issue in the Linux kernel, but this can help to cleanup
the inclusions so that:
1. Redundant environment definitions can be removed from <asm/acpi.h> and
<acpi/platform/aclinux.h>
2. Using ACPICA defined types in <asm/acpi.h> is possible.

Lv Zheng (4):
ACPICA: Add <acpi/platform/aclinuxxf.h> to remove mis-ordered
inclusion of <acpi/actypes.h> from <acpi/platform/aclinux.h>.
ACPICA: Add <asm/acenv.h> to remove mis-ordered inclusion of
<asm/acpi.h> from <acpi/platform/aclinux.h>.
ACPICA: Cleanup redudant definitions that already have defaults in
<acpi/platform/acenv.h>.
ACPICA: Remove deprecated _LINUX definitions for ACPICA.

arch/ia64/include/asm/acenv.h | 56 +++++++++++++++++
arch/ia64/include/asm/acpi.h | 50 ---------------
arch/x86/include/asm/acenv.h | 49 +++++++++++++++
arch/x86/include/asm/acpi.h | 45 --------------
include/acpi/platform/aclinux.h | 104 ++++---------------------------
include/acpi/platform/aclinuxxf.h | 122 +++++++++++++++++++++++++++++++++++++
include/linux/acpi.h | 4 --
7 files changed, 239 insertions(+), 191 deletions(-)
create mode 100644 arch/ia64/include/asm/acenv.h
create mode 100644 arch/x86/include/asm/acenv.h
create mode 100644 include/acpi/platform/aclinuxxf.h

--
1.7.10


2014-04-08 07:57:09

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH 2/4] ACPICA: Add <asm/acenv.h> to remove mis-ordered inclusion of <asm/acpi.h> from <acpi/platform/aclinux.h>.

There is a mis-order inclusion for <asm/acpi.h>.

As we will enforce including <linux/acpi.h> for all Linux ACPI users, we
can find the inclusion order is as follows:

<linux/acpi.h>
<acpi/acpi.h>
<acpi/platform/acenv.h>
(acenv.h before including aclinux.h)
<acpi/platform/aclinux.h>
...........................................................................
(aclinux.h before including asm/acpi.h)
<asm/acpi.h> @Redundant@
(ACPICA specific stuff)
...........................................................................
...........................................................................
(Linux ACPI specific stuff) ? - - - - - - - - - - - - +
(aclinux.h after including asm/acpi.h) @Invisible@ |
(acenv.h after including aclinux.h) @Invisible@ |
other ACPICA headers @Invisible@ |
............................................................|..............
<acpi/acpi_bus.h> |
<acpi/acpi_drivers.h> |
<asm/acpi.h> (Excluded) |
(Linux ACPI specific stuff) ! <- - - - - - - - - - - - - +

NOTE that, in ACPICA, <acpi/platform/acenv.h> is more like Kconfig
generated <generated/autoconf.h> for Linux, it is meant to be included
before including any ACPICA code.

In the above figure, there is a question mark for "Linux ACPI specific
stuff" in <asm/acpi.h> which should be included after including all other
ACPICA header files. Thus they really need to be moved to the position
marked with exclaimation mark or the definitions in the blocks marked with
"@Invisible@" will be invisible to such architecture specific "Linux ACPI
specific stuff" header blocks. This leaves 2 issues:
1. All environmental definitions in these blocks should have a copy in the
area marked with "@Redundant@" if they are required by the "Linux ACPI
specific stuff".
2. We cannot use any ACPICA defined types in <asm/acpi.h>.

This patch splits architecture specific ACPICA stuff from <asm/acpi.h> to
fix this issue.

Signed-off-by: Lv Zheng <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: [email protected]
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: [email protected]
---
arch/ia64/include/asm/acenv.h | 71 +++++++++++++++++++++++++++++++++++++++
arch/ia64/include/asm/acpi.h | 50 ---------------------------
arch/x86/include/asm/acenv.h | 65 +++++++++++++++++++++++++++++++++++
arch/x86/include/asm/acpi.h | 45 -------------------------
include/acpi/platform/aclinux.h | 2 +-
5 files changed, 137 insertions(+), 96 deletions(-)
create mode 100644 arch/ia64/include/asm/acenv.h
create mode 100644 arch/x86/include/asm/acenv.h

diff --git a/arch/ia64/include/asm/acenv.h b/arch/ia64/include/asm/acenv.h
new file mode 100644
index 0000000..e0896eb
--- /dev/null
+++ b/arch/ia64/include/asm/acenv.h
@@ -0,0 +1,71 @@
+/*
+ * IA64 specific ACPICA environments and implementation
+ *
+ * Copyright (C) 2014, Intel Corporation
+ * Author: Lv Zheng <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef _ASM_IA64_ACENV_H
+#define _ASM_IA64_ACENV_H
+
+#include <asm/intrinsics.h>
+
+#define COMPILER_DEPENDENT_INT64 long
+#define COMPILER_DEPENDENT_UINT64 unsigned long
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
+/* Asm macros */
+
+#define ACPI_FLUSH_CPU_CACHE()
+
+#ifdef CONFIG_ACPI
+
+static inline int
+ia64_acpi_acquire_global_lock(unsigned int *lock)
+{
+ unsigned int old, new, val;
+ do {
+ old = *lock;
+ new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
+ val = ia64_cmpxchg4_acq(lock, new, old);
+ } while (unlikely (val != old));
+ return (new < 3) ? -1 : 0;
+}
+
+static inline int
+ia64_acpi_release_global_lock(unsigned int *lock)
+{
+ unsigned int old, new, val;
+ do {
+ old = *lock;
+ new = old & ~0x3;
+ val = ia64_cmpxchg4_acq(lock, new, old);
+ } while (unlikely (val != old));
+ return old & 0x1;
+}
+
+#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
+ ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
+
+#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
+ ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
+
+#endif
+
+#endif /* _ASM_IA64_ACENV_H */
diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
index d651102..b0ddcfd 100644
--- a/arch/ia64/include/asm/acpi.h
+++ b/arch/ia64/include/asm/acpi.h
@@ -34,56 +34,6 @@
#include <linux/numa.h>
#include <asm/numa.h>

-#define COMPILER_DEPENDENT_INT64 long
-#define COMPILER_DEPENDENT_UINT64 unsigned long
-
-/*
- * Calling conventions:
- *
- * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
- * ACPI_EXTERNAL_XFACE - External ACPI interfaces
- * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
- * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
- */
-#define ACPI_SYSTEM_XFACE
-#define ACPI_EXTERNAL_XFACE
-#define ACPI_INTERNAL_XFACE
-#define ACPI_INTERNAL_VAR_XFACE
-
-/* Asm macros */
-
-#define ACPI_FLUSH_CPU_CACHE()
-
-static inline int
-ia64_acpi_acquire_global_lock (unsigned int *lock)
-{
- unsigned int old, new, val;
- do {
- old = *lock;
- new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
- val = ia64_cmpxchg4_acq(lock, new, old);
- } while (unlikely (val != old));
- return (new < 3) ? -1 : 0;
-}
-
-static inline int
-ia64_acpi_release_global_lock (unsigned int *lock)
-{
- unsigned int old, new, val;
- do {
- old = *lock;
- new = old & ~0x3;
- val = ia64_cmpxchg4_acq(lock, new, old);
- } while (unlikely (val != old));
- return old & 0x1;
-}
-
-#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
- ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
-
-#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
- ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
-
#ifdef CONFIG_ACPI
#define acpi_disabled 0 /* ACPI always enabled on IA64 */
#define acpi_noirq 0 /* ACPI always enabled on IA64 */
diff --git a/arch/x86/include/asm/acenv.h b/arch/x86/include/asm/acenv.h
new file mode 100644
index 0000000..6978584
--- /dev/null
+++ b/arch/x86/include/asm/acenv.h
@@ -0,0 +1,65 @@
+/*
+ * X86 specific ACPICA environments and implementation
+ *
+ * Copyright (C) 2014, Intel Corporation
+ * Author: Lv Zheng <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef _ASM_X86_ACENV_H
+#define _ASM_X86_ACENV_H
+
+#include <asm/special_insns.h>
+
+#define COMPILER_DEPENDENT_INT64 long long
+#define COMPILER_DEPENDENT_UINT64 unsigned long long
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
+/* Asm macros */
+
+#define ACPI_FLUSH_CPU_CACHE() wbinvd()
+
+#ifdef CONFIG_ACPI
+
+int __acpi_acquire_global_lock(unsigned int *lock);
+int __acpi_release_global_lock(unsigned int *lock);
+
+#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
+ ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
+
+#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
+ ((Acq) = __acpi_release_global_lock(&facs->global_lock))
+
+/*
+ * Math helper asm macros
+ */
+#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
+ asm("divl %2;" \
+ : "=a"(q32), "=d"(r32) \
+ : "r"(d32), \
+ "0"(n_lo), "1"(n_hi))
+
+#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
+ asm("shrl $1,%2 ;" \
+ "rcrl $1,%3;" \
+ : "=r"(n_hi), "=r"(n_lo) \
+ : "0"(n_hi), "1"(n_lo))
+
+#endif
+
+#endif /* _ASM_X86_ACENV_H */
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index c8c1e70..e06225e 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -32,51 +32,6 @@
#include <asm/mpspec.h>
#include <asm/realmode.h>

-#define COMPILER_DEPENDENT_INT64 long long
-#define COMPILER_DEPENDENT_UINT64 unsigned long long
-
-/*
- * Calling conventions:
- *
- * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
- * ACPI_EXTERNAL_XFACE - External ACPI interfaces
- * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
- * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
- */
-#define ACPI_SYSTEM_XFACE
-#define ACPI_EXTERNAL_XFACE
-#define ACPI_INTERNAL_XFACE
-#define ACPI_INTERNAL_VAR_XFACE
-
-/* Asm macros */
-
-#define ACPI_FLUSH_CPU_CACHE() wbinvd()
-
-int __acpi_acquire_global_lock(unsigned int *lock);
-int __acpi_release_global_lock(unsigned int *lock);
-
-#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
- ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
-
-#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
- ((Acq) = __acpi_release_global_lock(&facs->global_lock))
-
-/*
- * Math helper asm macros
- */
-#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
- asm("divl %2;" \
- : "=a"(q32), "=d"(r32) \
- : "r"(d32), \
- "0"(n_lo), "1"(n_hi))
-
-
-#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
- asm("shrl $1,%2 ;" \
- "rcrl $1,%3;" \
- : "=r"(n_hi), "=r"(n_lo) \
- : "0"(n_hi), "1"(n_lo))
-
#ifdef CONFIG_ACPI
extern int acpi_lapic;
extern int acpi_ioapic;
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index e3ac5a5..a12e9e0 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -71,7 +71,7 @@
#ifdef EXPORT_ACPI_INTERFACES
#include <linux/export.h>
#endif
-#include <asm/acpi.h>
+#include <asm/acenv.h>

/* Host-dependent types and defines for in-kernel ACPICA */

--
1.7.10

2014-04-08 07:58:59

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH 3/4] ACPICA: Cleanup redudant definitions that already have defaults in <acpi/platform/acenv.h>.

Since mis-order issues have been solved, we can cleanup redundant
definitions that already have defaults in <acpi/platform/acenv.h>.

This patch removes redudant environments for __KERNEL__ surrounded code.

Signed-off-by: Lv Zheng <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: [email protected]
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: [email protected]
---
arch/ia64/include/asm/acenv.h | 15 ---------------
arch/x86/include/asm/acenv.h | 16 ----------------
include/acpi/platform/aclinux.h | 1 -
3 files changed, 32 deletions(-)

diff --git a/arch/ia64/include/asm/acenv.h b/arch/ia64/include/asm/acenv.h
index e0896eb..3f9eaee 100644
--- a/arch/ia64/include/asm/acenv.h
+++ b/arch/ia64/include/asm/acenv.h
@@ -17,23 +17,8 @@
#define COMPILER_DEPENDENT_INT64 long
#define COMPILER_DEPENDENT_UINT64 unsigned long

-/*
- * Calling conventions:
- *
- * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
- * ACPI_EXTERNAL_XFACE - External ACPI interfaces
- * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
- * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
- */
-#define ACPI_SYSTEM_XFACE
-#define ACPI_EXTERNAL_XFACE
-#define ACPI_INTERNAL_XFACE
-#define ACPI_INTERNAL_VAR_XFACE
-
/* Asm macros */

-#define ACPI_FLUSH_CPU_CACHE()
-
#ifdef CONFIG_ACPI

static inline int
diff --git a/arch/x86/include/asm/acenv.h b/arch/x86/include/asm/acenv.h
index 6978584..6687329 100644
--- a/arch/x86/include/asm/acenv.h
+++ b/arch/x86/include/asm/acenv.h
@@ -14,22 +14,6 @@

#include <asm/special_insns.h>

-#define COMPILER_DEPENDENT_INT64 long long
-#define COMPILER_DEPENDENT_UINT64 unsigned long long
-
-/*
- * Calling conventions:
- *
- * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
- * ACPI_EXTERNAL_XFACE - External ACPI interfaces
- * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
- * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
- */
-#define ACPI_SYSTEM_XFACE
-#define ACPI_EXTERNAL_XFACE
-#define ACPI_INTERNAL_XFACE
-#define ACPI_INTERNAL_VAR_XFACE
-
/* Asm macros */

#define ACPI_FLUSH_CPU_CACHE() wbinvd()
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index a12e9e0..943c167 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -48,7 +48,6 @@

#define ACPI_USE_SYSTEM_CLIBRARY
#define ACPI_USE_DO_WHILE_0
-#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE

#ifdef __KERNEL__

--
1.7.10

2014-04-08 07:59:26

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH 1/4] ACPICA: Add <acpi/platform/aclinuxxf.h> to remove mis-ordered inclusion of <acpi/actypes.h> from <acpi/platform/aclinux.h>.

>From ACPICA's perspective, <acpi/actypes.h> should be included after
inclusion of <acpi/platform/acenv.h>. But currently in Linux,
<acpi/platform/aclinux.h> included by <acpi/platform/acenv.h> has
included <acpi/actypes.h> to find ACPICA types for inline functions.

This causes the following problem:
1. Redundant code in <asm/acpi.h> and <acpi/platform/aclinux.h>:
Linux must be careful to keep conditions for <acpi/actypes.h> inclusion
consistent with the conditions for <acpi/platform/aclinux.h> inclusion.
Which finally leads to the issue that we have to keep many useless macro
definitions in <acpi/platform/aclinux.h> or <asm/acpi.h>.
Such conditions include:
COMPILER_DEPENDENT_UINT64
COMPILER_DEPENDENT_INT64
ACPI_INLINE
ACPI_SYSTEM_XFACE
ACPI_EXTERNAL_XFACE
ACPI_INTERNAL_XFACE
ACPI_INTERNAL_VAR_XFACE
ACPI_MUTEX_TYPE
DEBUGGER_THREADING
ACPI_ACQUIRE_GLOBAL_LOCK
ACPI_RELEASE_GLOBAL_LOCK
ACPI_FLUSH_CPU_CACHE
They have default implementations in <include/acpi/platform/acenv.h>
while Linux need to keep a copy in <asm/acpi.h> to avoid build errors.
Typical Linux build error if we deletes COMPILER_DEPENDENT_x and
ACPI_x_XFACE definitions from asm/acpi.h:
CC init/main.o
In file included from include/acpi/platform/aclinux.h:293:0,
from include/acpi/platform/acenv.h:149,
from include/acpi/acpi.h:56,
from include/linux/acpi.h:41,
from init/main.c:27:
include/acpi/actypes.h:129:1: error: unknown type name 'COMPILER_DEPENDENT_UINT64'
include/acpi/actypes.h:130:1: error: unknown type name 'COMPILER_DEPENDENT_INT64'
In file included from include/acpi/platform/aclinux.h:293:0,
from include/acpi/platform/acenv.h:149,
from include/acpi/acpi.h:56,
from include/linux/acpi.h:41,
from init/main.c:27:
include/acpi/actypes.h:1025:21: error: expected ')' before '*' token
include/acpi/actypes.h:1028:21: error: expected ')' before '*' token
In file included from include/acpi/acpi.h:63:0,
from include/linux/acpi.h:41,
from init/main.c:27:
include/acpi/acpiosxf.h:240:7: error: unknown type name 'acpi_osd_handler'
include/acpi/acpiosxf.h:247:6: error: unknown type name 'acpi_osd_handler'
include/acpi/acpiosxf.h:260:3: error: unknown type name 'acpi_osd_exec_callback'

This patch introduces <acpi/platform/aclinuxxf.h> to fix this issue by
splitting conditions and declarations (most of them are inline functions)
into 2 header files so that the wrong inclusion of <acpi/actypes.h> can be
removed from <acpi/platform/aclinux.h>.

Signed-off-by: Lv Zheng <[email protected]>
---
include/acpi/platform/aclinux.h | 101 ++++--------------------------
include/acpi/platform/aclinuxxf.h | 122 +++++++++++++++++++++++++++++++++++++
2 files changed, 133 insertions(+), 90 deletions(-)
create mode 100644 include/acpi/platform/aclinuxxf.h

diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index f242909..e3ac5a5 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -130,73 +130,6 @@

#ifdef __KERNEL__

-/*
- * FIXME: Inclusion of actypes.h
- * Linux kernel need this before defining inline OSL interfaces as
- * actypes.h need to be included to find ACPICA type definitions.
- * Since from ACPICA's perspective, the actypes.h should be included after
- * acenv.h (aclinux.h), this leads to a inclusion mis-ordering issue.
- */
-#include <acpi/actypes.h>
-
-/*
- * Overrides for in-kernel ACPICA
- */
-acpi_status __init acpi_os_initialize(void);
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
-
-acpi_status acpi_os_terminate(void);
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
-
-/*
- * Memory allocation/deallocation
- */
-
-/*
- * The irqs_disabled() check is for resume from RAM.
- * Interrupts are off during resume, just like they are for boot.
- * However, boot has (system_state != SYSTEM_RUNNING)
- * to quiet __might_sleep() in kmalloc() and resume does not.
- */
-static inline void *acpi_os_allocate(acpi_size size)
-{
- return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
-
-/* Use native linux version of acpi_os_allocate_zeroed */
-
-static inline void *acpi_os_allocate_zeroed(acpi_size size)
-{
- return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
-#define USE_NATIVE_ALLOCATE_ZEROED
-
-static inline void acpi_os_free(void *memory)
-{
- kfree(memory);
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
-
-static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
-{
- return kmem_cache_zalloc(cache,
- irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
-
-static inline acpi_thread_id acpi_os_get_thread_id(void)
-{
- return (acpi_thread_id) (unsigned long)current;
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
-
#ifndef CONFIG_PREEMPT

/*
@@ -212,27 +145,18 @@ static inline acpi_thread_id acpi_os_get_thread_id(void)
#endif

/*
- * When lockdep is enabled, the spin_lock_init() macro stringifies it's
- * argument and uses that as a name for the lock in debugging.
- * By executing spin_lock_init() in a macro the key changes from "lock" for
- * all locks to the name of the argument of acpi_os_create_lock(), which
- * prevents lockdep from reporting false positives for ACPICA locks.
+ * Overrides for in-kernel ACPICA
*/
-#define acpi_os_create_lock(__handle) \
- ({ \
- spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
- if (lock) { \
- *(__handle) = lock; \
- spin_lock_init(*(__handle)); \
- } \
- lock ? AE_OK : AE_NO_MEMORY; \
- })
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
+#define USE_NATIVE_ALLOCATE_ZEROED
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
-
-void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
-
-void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory

/*
@@ -253,11 +177,8 @@ void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory

-/*
- * OSL interfaces added by Linux
- */
-void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size);
-
#endif /* __KERNEL__ */

+#define ACPI_NATIVE_INTERFACE_HEADER <acpi/platform/aclinuxxf.h>
+
#endif /* __ACLINUX_H__ */
diff --git a/include/acpi/platform/aclinuxxf.h b/include/acpi/platform/aclinuxxf.h
new file mode 100644
index 0000000..0b54085
--- /dev/null
+++ b/include/acpi/platform/aclinuxxf.h
@@ -0,0 +1,122 @@
+/******************************************************************************
+ *
+ * Name: aclinuxxf.h - Extra OS specific defines, etc. for Linux
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2014, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef __ACLINUXXF_H__
+#define __ACLINUXXF_H__
+
+#ifdef __KERNEL__
+
+/*
+ * Overrides for in-kernel ACPICA
+ */
+acpi_status __init acpi_os_initialize(void);
+
+acpi_status acpi_os_terminate(void);
+
+/*
+ * Memory allocation/deallocation
+ */
+
+/*
+ * The irqs_disabled() check is for resume from RAM.
+ * Interrupts are off during resume, just like they are for boot.
+ * However, boot has (system_state != SYSTEM_RUNNING)
+ * to quiet __might_sleep() in kmalloc() and resume does not.
+ */
+static inline void *acpi_os_allocate(acpi_size size)
+{
+ return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
+}
+
+/* Use native linux version of acpi_os_allocate_zeroed */
+
+static inline void *acpi_os_allocate_zeroed(acpi_size size)
+{
+ return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
+}
+
+static inline void acpi_os_free(void *memory)
+{
+ kfree(memory);
+}
+
+static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
+{
+ return kmem_cache_zalloc(cache,
+ irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
+}
+
+static inline acpi_thread_id acpi_os_get_thread_id(void)
+{
+ return (acpi_thread_id) (unsigned long)current;
+}
+
+/*
+ * When lockdep is enabled, the spin_lock_init() macro stringifies it's
+ * argument and uses that as a name for the lock in debugging.
+ * By executing spin_lock_init() in a macro the key changes from "lock" for
+ * all locks to the name of the argument of acpi_os_create_lock(), which
+ * prevents lockdep from reporting false positives for ACPICA locks.
+ */
+#define acpi_os_create_lock(__handle) \
+ ({ \
+ spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
+ if (lock) { \
+ *(__handle) = lock; \
+ spin_lock_init(*(__handle)); \
+ } \
+ lock ? AE_OK : AE_NO_MEMORY; \
+ })
+
+void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
+
+void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
+
+/*
+ * OSL interfaces added by Linux
+ */
+void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size);
+
+#endif /* __KERNEL__ */
+
+#endif /* __ACLINUX_H__ */
--
1.7.10

2014-04-08 08:03:13

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH 4/4] ACPICA: Remove deprecated _LINUX definitions for ACPICA.

There are _LINUX defined so that when Linux kernel is compiled using broken
compilers that having not __linux__ defined can still include
<acpi/platform/aclinux.h> from <acpi/platform/acenv.h>.

This behavior is deprecated as all drivers/acpi/acpica files are compiled
without including <linux/acpi.h>, thus without _LINUX defined. As there is
no issues encountered when we compile ACPICA code without _LINUX defined,
it is OK to remove _LINUX from <linux/acpi.h> now.

Signed-off-by: Lv Zheng <[email protected]>
---
include/linux/acpi.h | 4 ----
1 file changed, 4 deletions(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 7a8f2cd..9c559f7 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -31,10 +31,6 @@

#ifdef CONFIG_ACPI

-#ifndef _LINUX
-#define _LINUX
-#endif
-
#include <linux/list.h>
#include <linux/mod_devicetable.h>

--
1.7.10

2014-04-21 20:42:31

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 1/4] ACPICA: Add <acpi/platform/aclinuxxf.h> to remove mis-ordered inclusion of <acpi/actypes.h> from <acpi/platform/aclinux.h>.

On Tuesday, April 08, 2014 03:56:44 PM Lv Zheng wrote:
> From ACPICA's perspective, <acpi/actypes.h> should be included after
> inclusion of <acpi/platform/acenv.h>. But currently in Linux,
> <acpi/platform/aclinux.h> included by <acpi/platform/acenv.h> has
> included <acpi/actypes.h> to find ACPICA types for inline functions.
>
> This causes the following problem:
> 1. Redundant code in <asm/acpi.h> and <acpi/platform/aclinux.h>:
> Linux must be careful to keep conditions for <acpi/actypes.h> inclusion
> consistent with the conditions for <acpi/platform/aclinux.h> inclusion.
> Which finally leads to the issue that we have to keep many useless macro
> definitions in <acpi/platform/aclinux.h> or <asm/acpi.h>.
> Such conditions include:
> COMPILER_DEPENDENT_UINT64
> COMPILER_DEPENDENT_INT64
> ACPI_INLINE
> ACPI_SYSTEM_XFACE
> ACPI_EXTERNAL_XFACE
> ACPI_INTERNAL_XFACE
> ACPI_INTERNAL_VAR_XFACE
> ACPI_MUTEX_TYPE
> DEBUGGER_THREADING
> ACPI_ACQUIRE_GLOBAL_LOCK
> ACPI_RELEASE_GLOBAL_LOCK
> ACPI_FLUSH_CPU_CACHE
> They have default implementations in <include/acpi/platform/acenv.h>
> while Linux need to keep a copy in <asm/acpi.h> to avoid build errors.
> Typical Linux build error if we deletes COMPILER_DEPENDENT_x and
> ACPI_x_XFACE definitions from asm/acpi.h:
> CC init/main.o
> In file included from include/acpi/platform/aclinux.h:293:0,
> from include/acpi/platform/acenv.h:149,
> from include/acpi/acpi.h:56,
> from include/linux/acpi.h:41,
> from init/main.c:27:
> include/acpi/actypes.h:129:1: error: unknown type name 'COMPILER_DEPENDENT_UINT64'
> include/acpi/actypes.h:130:1: error: unknown type name 'COMPILER_DEPENDENT_INT64'
> In file included from include/acpi/platform/aclinux.h:293:0,
> from include/acpi/platform/acenv.h:149,
> from include/acpi/acpi.h:56,
> from include/linux/acpi.h:41,
> from init/main.c:27:
> include/acpi/actypes.h:1025:21: error: expected ')' before '*' token
> include/acpi/actypes.h:1028:21: error: expected ')' before '*' token
> In file included from include/acpi/acpi.h:63:0,
> from include/linux/acpi.h:41,
> from init/main.c:27:
> include/acpi/acpiosxf.h:240:7: error: unknown type name 'acpi_osd_handler'
> include/acpi/acpiosxf.h:247:6: error: unknown type name 'acpi_osd_handler'
> include/acpi/acpiosxf.h:260:3: error: unknown type name 'acpi_osd_exec_callback'
>
> This patch introduces <acpi/platform/aclinuxxf.h> to fix this issue by
> splitting conditions and declarations (most of them are inline functions)
> into 2 header files so that the wrong inclusion of <acpi/actypes.h> can be
> removed from <acpi/platform/aclinux.h>.
>
> Signed-off-by: Lv Zheng <[email protected]>
> ---
> include/acpi/platform/aclinux.h | 101 ++++--------------------------
> include/acpi/platform/aclinuxxf.h | 122 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 133 insertions(+), 90 deletions(-)
> create mode 100644 include/acpi/platform/aclinuxxf.h
>
> diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
> index f242909..e3ac5a5 100644
> --- a/include/acpi/platform/aclinux.h
> +++ b/include/acpi/platform/aclinux.h
> @@ -130,73 +130,6 @@
>
> #ifdef __KERNEL__
>
> -/*
> - * FIXME: Inclusion of actypes.h
> - * Linux kernel need this before defining inline OSL interfaces as
> - * actypes.h need to be included to find ACPICA type definitions.
> - * Since from ACPICA's perspective, the actypes.h should be included after
> - * acenv.h (aclinux.h), this leads to a inclusion mis-ordering issue.
> - */
> -#include <acpi/actypes.h>
> -
> -/*
> - * Overrides for in-kernel ACPICA
> - */
> -acpi_status __init acpi_os_initialize(void);
> -#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
> -
> -acpi_status acpi_os_terminate(void);
> -#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
> -
> -/*
> - * Memory allocation/deallocation
> - */
> -
> -/*
> - * The irqs_disabled() check is for resume from RAM.
> - * Interrupts are off during resume, just like they are for boot.
> - * However, boot has (system_state != SYSTEM_RUNNING)
> - * to quiet __might_sleep() in kmalloc() and resume does not.
> - */
> -static inline void *acpi_os_allocate(acpi_size size)
> -{
> - return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
> -}
> -
> -#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
> -
> -/* Use native linux version of acpi_os_allocate_zeroed */
> -
> -static inline void *acpi_os_allocate_zeroed(acpi_size size)
> -{
> - return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
> -}
> -
> -#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
> -#define USE_NATIVE_ALLOCATE_ZEROED
> -
> -static inline void acpi_os_free(void *memory)
> -{
> - kfree(memory);
> -}
> -
> -#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
> -
> -static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
> -{
> - return kmem_cache_zalloc(cache,
> - irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
> -}
> -
> -#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
> -
> -static inline acpi_thread_id acpi_os_get_thread_id(void)
> -{
> - return (acpi_thread_id) (unsigned long)current;
> -}
> -
> -#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
> -
> #ifndef CONFIG_PREEMPT
>
> /*
> @@ -212,27 +145,18 @@ static inline acpi_thread_id acpi_os_get_thread_id(void)
> #endif
>
> /*
> - * When lockdep is enabled, the spin_lock_init() macro stringifies it's
> - * argument and uses that as a name for the lock in debugging.
> - * By executing spin_lock_init() in a macro the key changes from "lock" for
> - * all locks to the name of the argument of acpi_os_create_lock(), which
> - * prevents lockdep from reporting false positives for ACPICA locks.
> + * Overrides for in-kernel ACPICA
> */
> -#define acpi_os_create_lock(__handle) \
> - ({ \
> - spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
> - if (lock) { \
> - *(__handle) = lock; \
> - spin_lock_init(*(__handle)); \
> - } \
> - lock ? AE_OK : AE_NO_MEMORY; \
> - })
> +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
> +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
> +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
> +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
> +#define USE_NATIVE_ALLOCATE_ZEROED
> +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
> +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
> +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
> #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
> -
> -void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
> #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
> -
> -void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
> #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory
>
> /*
> @@ -253,11 +177,8 @@ void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
> #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
> #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
>
> -/*
> - * OSL interfaces added by Linux
> - */
> -void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size);
> -
> #endif /* __KERNEL__ */
>
> +#define ACPI_NATIVE_INTERFACE_HEADER <acpi/platform/aclinuxxf.h>

This is not good.

We don't do things like this in the kernel, because they are confusing and hard
to debug if necessary, so please find a different way to make this work.

And the name aclinuxxf.h is not one of my favourite.

Thanks!

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

2014-04-22 02:02:07

by Zheng, Lv

[permalink] [raw]
Subject: RE: [PATCH 1/4] ACPICA: Add <acpi/platform/aclinuxxf.h> to remove mis-ordered inclusion of <acpi/actypes.h> from <acpi/platform/aclinux.h>.

Hi,

<skip>

> > +#define ACPI_NATIVE_INTERFACE_HEADER <acpi/platform/aclinuxxf.h>
>
> This is not good.
>
> We don't do things like this in the kernel, because they are confusing and hard
> to debug if necessary, so please find a different way to make this work.

I use this extra header file to collect:
1. static inline OSL functions
2. divergences of prototypes that haven't been back ported to ACPICA.
This file is useful for ACPICA release automation.

There are the following concerns that lead to the use of this solution:
1. for this extra header file itself
A. The new header file is OSPM specific, thus it needn't be upstreamed to ACPICA;
B. Since it needn't be upstreamed to ACPICA, ACPICA needn't determine the name of this extra header;
C. It has to be the last file included by <acpi/acpi.h>.
2. for the file that includes this extra header file
A. Currently there is no OSPM specific code in <acpi/acpi.h>.
Thus I use a macro so that there is still no OSPM specific code in <acpi/acpi.h> and the name of the extra header can be determined by OSPM.

If you want another solution, is the following acceptable?
1. In <acpi/platform/aclinux.h>
#define ACPI_INCLUDE_EXTRA_NATIVE_HEADER 1
2. In <acpi/acpi.h> <- this is an ACPICA header file,
#ifdef ACPI_INCLUDE_EXTRA_NATIVE_HEADER
#include <acpi/platform/acextra.h>
#endif
Note that in this solution, the name of the extra header file will be determined by ACPICA.

> And the name aclinuxxf.h is not one of my favourite.

Since this file needn't be upstreamed into ACPICA, could you help to determine it if the acextra.h was still not acceptable?

Thanks and best regards
-Lv

>
> Thanks!
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-04-22 10:59:49

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 1/4] ACPICA: Add <acpi/platform/aclinuxxf.h> to remove mis-ordered inclusion of <acpi/actypes.h> from <acpi/platform/aclinux.h>.

On Tuesday, April 22, 2014 02:01:57 AM Zheng, Lv wrote:
> Hi,
>
> <skip>
>
> > > +#define ACPI_NATIVE_INTERFACE_HEADER <acpi/platform/aclinuxxf.h>
> >
> > This is not good.
> >
> > We don't do things like this in the kernel, because they are confusing and hard
> > to debug if necessary, so please find a different way to make this work.
>
> I use this extra header file to collect:

I was not talking about the new header, which is basically OK, but about the
#define above, which is just too confusing to live.

Please use header file paths directly with #include.

> 1. static inline OSL functions
> 2. divergences of prototypes that haven't been back ported to ACPICA.
> This file is useful for ACPICA release automation.
>
> There are the following concerns that lead to the use of this solution:
> 1. for this extra header file itself
> A. The new header file is OSPM specific, thus it needn't be upstreamed to ACPICA;
> B. Since it needn't be upstreamed to ACPICA, ACPICA needn't determine the name of this extra header;
> C. It has to be the last file included by <acpi/acpi.h>.
> 2. for the file that includes this extra header file
> A. Currently there is no OSPM specific code in <acpi/acpi.h>.
> Thus I use a macro so that there is still no OSPM specific code in <acpi/acpi.h> and the name of the extra header can be determined by OSPM.
>
> If you want another solution, is the following acceptable?
> 1. In <acpi/platform/aclinux.h>
> #define ACPI_INCLUDE_EXTRA_NATIVE_HEADER 1
> 2. In <acpi/acpi.h> <- this is an ACPICA header file,
> #ifdef ACPI_INCLUDE_EXTRA_NATIVE_HEADER
> #include <acpi/platform/acextra.h>
> #endif
> Note that in this solution, the name of the extra header file will be determined by ACPICA.

I think I see what you're trying to do now. And I see that this ACPI_NATIVE_INTERFACE_HEADER
thing is already there in the Linus' tree which is not good at all.

I probably would create an extra ACPICA header, something like <acpios_opt.h>,
that would be empty for all hosts except for Linux and that would contain the
stuff you want to put into acextra.h in Linux.

That would be clean enough I suppose?

Rafael

2014-04-23 01:07:05

by Zheng, Lv

[permalink] [raw]
Subject: RE: [PATCH 1/4] ACPICA: Add <acpi/platform/aclinuxxf.h> to remove mis-ordered inclusion of <acpi/actypes.h> from <acpi/platform/aclinux.h>.

Hi, Rafael

> From: Rafael J. Wysocki [mailto:[email protected]]
> Sent: Tuesday, April 22, 2014 7:16 PM
>
> On Tuesday, April 22, 2014 02:01:57 AM Zheng, Lv wrote:
> > Hi,
> >
> > <skip>
> >
> > > > +#define ACPI_NATIVE_INTERFACE_HEADER <acpi/platform/aclinuxxf.h>
> > >
> > > This is not good.
> > >
> > > We don't do things like this in the kernel, because they are confusing and hard
> > > to debug if necessary, so please find a different way to make this work.
> >
> > I use this extra header file to collect:
>
> I was not talking about the new header, which is basically OK, but about the
> #define above, which is just too confusing to live.
>
> Please use header file paths directly with #include.

OK.

>
> > 1. static inline OSL functions
> > 2. divergences of prototypes that haven't been back ported to ACPICA.
> > This file is useful for ACPICA release automation.
> >
> > There are the following concerns that lead to the use of this solution:
> > 1. for this extra header file itself
> > A. The new header file is OSPM specific, thus it needn't be upstreamed to ACPICA;
> > B. Since it needn't be upstreamed to ACPICA, ACPICA needn't determine the name of this extra header;
> > C. It has to be the last file included by <acpi/acpi.h>.
> > 2. for the file that includes this extra header file
> > A. Currently there is no OSPM specific code in <acpi/acpi.h>.
> > Thus I use a macro so that there is still no OSPM specific code in <acpi/acpi.h> and the name of the extra header can be determined
> by OSPM.
> >
> > If you want another solution, is the following acceptable?
> > 1. In <acpi/platform/aclinux.h>
> > #define ACPI_INCLUDE_EXTRA_NATIVE_HEADER 1
> > 2. In <acpi/acpi.h> <- this is an ACPICA header file,
> > #ifdef ACPI_INCLUDE_EXTRA_NATIVE_HEADER
> > #include <acpi/platform/acextra.h>
> > #endif
> > Note that in this solution, the name of the extra header file will be determined by ACPICA.
>
> I think I see what you're trying to do now. And I see that this ACPI_NATIVE_INTERFACE_HEADER
> thing is already there in the Linus' tree which is not good at all.
>
> I probably would create an extra ACPICA header, something like <acpios_opt.h>,
> that would be empty for all hosts except for Linux and that would contain the
> stuff you want to put into acextra.h in Linux.
>
> That would be clean enough I suppose?

Yes, it is clear.
Thanks for the helping.
I'll update this patch and re-send this series.

Best regards
-Lv
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-04-23 06:53:53

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH v2 0/5] ACPICA: Fix some mis-ordered inclusions.

This patch fixes some mis-ordered inclusions for Linux resident ACPICA.

There is no real issue in the Linux kernel, but this can help to cleanup
the code so that (benefits):
1. Redundant environment definitions can be removed from <asm/acpi.h> and
<acpi/platform/aclinux.h>.
2. Lift a burden off the ACPICA release automation - copying default ACPICA
environment setting to all <asm/acpi.h> file each time a new environment
is introduced just in order to avoid build errors.
3. The wrong <acpi/actypes.h> inclusion can be removed from
<acpi/platform/aclinux.h>.
4. Using ACPICA defined types in <asm/acpi.h> is possible.
5. Using "static inline" to define ACPICA OSL functions is still possible
and won't cause build errors any longer.
6. All non back ported prototypes are collected in a single file.

The patch set has passed the following build/boot tests.
Build tests are performed as follows:
1. i386 + default + COFNIG_ACPI=y
2. i386 + default + COFNIG_ACPI=n
3. x86_64 + default + COFNIG_ACPI=y
4. x86_64 + default + COFNIG_ACPI=n
Boot tests are performed as follows:
1. i386 + default + COFNIG_ACPI=y
2. x86_64 + default + COFNIG_ACPI=y
Where:
1. i386: machine named as "Dell Inspiron Mini 1010"
2. x86_64: machine named as "HP Compaq 8200 Elite SFF PC"
3. default: kernel configuration with following items enabled:
All hardware drivers related to the machines of i386/x86_64
All drivers/acpi configurations
All platform drivers
All ACPI drivers
4 DRM drivers that implement ACPI opregion
All buses with ACPI bindings
All cpufreq configurations
All xen configurations
All ACPI tabln drivers

Lv Zheng (5):
ACPICA: OSL: Add direct inclusion of extra header.
ACPICA: Add <acpi/acpi_opt.h> to remove mis-ordered inclusion of
<acpi/actypes.h> from <acpi/platform/aclinux.h>.
ACPICA: Add <asm/acenv.h> to remove mis-ordered inclusion of
<asm/acpi.h> from <acpi/platform/aclinux.h>.
ACPICA: Cleanup redudant definitions that already have defaults in
<acpi/platform/acenv.h>.
ACPICA: Remove deprecated _LINUX definitions for ACPICA.

arch/ia64/include/asm/acenv.h | 56 +++++++++++++++++++++
arch/ia64/include/asm/acpi.h | 50 -------------------
arch/x86/include/asm/acenv.h | 49 ++++++++++++++++++
arch/x86/include/asm/acpi.h | 45 -----------------
include/acpi/acpi.h | 4 +-
include/acpi/acpi_opt.h | 90 +++++++++++++++++++++++++++++++++
include/acpi/platform/aclinux.h | 104 +++++----------------------------------
include/linux/acpi.h | 4 --
8 files changed, 209 insertions(+), 193 deletions(-)
create mode 100644 arch/ia64/include/asm/acenv.h
create mode 100644 arch/x86/include/asm/acenv.h
create mode 100644 include/acpi/acpi_opt.h

--
1.7.10

2014-04-23 06:54:03

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH v2 1/5] ACPICA: OSL: Add direct inclusion of extra header.

This is a linuxized result of an ACPICA commit to upgrade the extra
header mechanism.

This patch enhances the extra header solution to allow Linux to use
ACPI_USE_NATIVE_INTERFACE_HEADER and the file name can be automatically
replaced during ACPICA release process. Using this way, the rest of the
ACPICA users needn't know the name of the extra header file. Lv Zheng.

Signed-off-by: Lv Zheng <[email protected]>
---
include/acpi/acpi.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
index ca0cb60..682398b 100644
--- a/include/acpi/acpi.h
+++ b/include/acpi/acpi.h
@@ -62,8 +62,8 @@
#include <acpi/acrestyp.h> /* Resource Descriptor structs */
#include <acpi/acpiosxf.h> /* OSL interfaces (ACPICA-to-OS) */
#include <acpi/acpixf.h> /* ACPI core subsystem external interfaces */
-#ifdef ACPI_NATIVE_INTERFACE_HEADER
-#include ACPI_NATIVE_INTERFACE_HEADER
+#ifdef ACPI_USE_NATIVE_INTERFACE_HEADER
+#include <acpi/acpi_opt.h>
#endif

#endif /* __ACPI_H__ */
--
1.7.10

2014-04-23 06:54:08

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH v2 2/5] ACPICA: Add <acpi/acpi_opt.h> to remove mis-ordered inclusion of <acpi/actypes.h> from <acpi/platform/aclinux.h>.

>From ACPICA's perspective, <acpi/actypes.h> should be included after
inclusion of <acpi/platform/acenv.h>. But currently in Linux,
<acpi/platform/aclinux.h> included by <acpi/platform/acenv.h> has
included <acpi/actypes.h> to find ACPICA types for inline functions.

This causes the following problem:
1. Redundant code in <asm/acpi.h> and <acpi/platform/aclinux.h>:
Linux must be careful to keep conditions for <acpi/actypes.h> inclusion
consistent with the conditions for <acpi/platform/aclinux.h> inclusion.
Which finally leads to the issue that we have to keep many useless macro
definitions in <acpi/platform/aclinux.h> or <asm/acpi.h>.
Such conditions include:
COMPILER_DEPENDENT_UINT64
COMPILER_DEPENDENT_INT64
ACPI_INLINE
ACPI_SYSTEM_XFACE
ACPI_EXTERNAL_XFACE
ACPI_INTERNAL_XFACE
ACPI_INTERNAL_VAR_XFACE
ACPI_MUTEX_TYPE
DEBUGGER_THREADING
ACPI_ACQUIRE_GLOBAL_LOCK
ACPI_RELEASE_GLOBAL_LOCK
ACPI_FLUSH_CPU_CACHE
They have default implementations in <include/acpi/platform/acenv.h>
while Linux need to keep a copy in <asm/acpi.h> to avoid build errors.
Typical Linux build error if we deletes COMPILER_DEPENDENT_x and
ACPI_x_XFACE definitions from asm/acpi.h:
CC init/main.o
In file included from include/acpi/platform/aclinux.h:293:0,
from include/acpi/platform/acenv.h:149,
from include/acpi/acpi.h:56,
from include/linux/acpi.h:41,
from init/main.c:27:
include/acpi/actypes.h:129:1: error: unknown type name 'COMPILER_DEPENDENT_UINT64'
include/acpi/actypes.h:130:1: error: unknown type name 'COMPILER_DEPENDENT_INT64'
In file included from include/acpi/platform/aclinux.h:293:0,
from include/acpi/platform/acenv.h:149,
from include/acpi/acpi.h:56,
from include/linux/acpi.h:41,
from init/main.c:27:
include/acpi/actypes.h:1025:21: error: expected ')' before '*' token
include/acpi/actypes.h:1028:21: error: expected ')' before '*' token
In file included from include/acpi/acpi.h:63:0,
from include/linux/acpi.h:41,
from init/main.c:27:
include/acpi/acpiosxf.h:240:7: error: unknown type name 'acpi_osd_handler'
include/acpi/acpiosxf.h:247:6: error: unknown type name 'acpi_osd_handler'
include/acpi/acpiosxf.h:260:3: error: unknown type name 'acpi_osd_exec_callback'

This patch introduces <acpi/acpi_opt.h> to fix this issue by splitting
conditions and declarations (most of them are inline functions) into 2
header files so that the wrong inclusion of <acpi/actypes.h> can be removed
from <acpi/platform/aclinux.h>.

Signed-off-by: Lv Zheng <[email protected]>
---
include/acpi/acpi_opt.h | 90 ++++++++++++++++++++++++++++++++++
include/acpi/platform/aclinux.h | 101 +++++----------------------------------
2 files changed, 101 insertions(+), 90 deletions(-)
create mode 100644 include/acpi/acpi_opt.h

diff --git a/include/acpi/acpi_opt.h b/include/acpi/acpi_opt.h
new file mode 100644
index 0000000..51ccbe5
--- /dev/null
+++ b/include/acpi/acpi_opt.h
@@ -0,0 +1,90 @@
+/*
+ * Extra OS specific ACPI defines for Linux.
+ *
+ * Copyright (C) 2014, Intel Corporation
+ * Authors: Lv Zheng <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef _ACPI_OPT_H_
+#define _ACPI_OPT_H_
+
+#ifdef __KERNEL__
+
+/*
+ * Overrides for in-kernel ACPICA
+ */
+acpi_status __init acpi_os_initialize(void);
+
+acpi_status acpi_os_terminate(void);
+
+/*
+ * Memory allocation/deallocation
+ */
+
+/*
+ * The irqs_disabled() check is for resume from RAM.
+ * Interrupts are off during resume, just like they are for boot.
+ * However, boot has (system_state != SYSTEM_RUNNING)
+ * to quiet __might_sleep() in kmalloc() and resume does not.
+ */
+static inline void *acpi_os_allocate(acpi_size size)
+{
+ return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
+}
+
+/* Use native linux version of acpi_os_allocate_zeroed */
+
+static inline void *acpi_os_allocate_zeroed(acpi_size size)
+{
+ return kzalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
+}
+
+static inline void acpi_os_free(void *memory)
+{
+ kfree(memory);
+}
+
+static inline void *acpi_os_acquire_object(acpi_cache_t *cache)
+{
+ return kmem_cache_zalloc(cache,
+ irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
+}
+
+static inline acpi_thread_id acpi_os_get_thread_id(void)
+{
+ return (acpi_thread_id)(unsigned long)current;
+}
+
+/*
+ * When lockdep is enabled, the spin_lock_init() macro stringifies it's
+ * argument and uses that as a name for the lock in debugging.
+ * By executing spin_lock_init() in a macro the key changes from "lock" for
+ * all locks to the name of the argument of acpi_os_create_lock(), which
+ * prevents lockdep from reporting false positives for ACPICA locks.
+ */
+#define acpi_os_create_lock(__handle) \
+ ({ \
+ spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
+ if (lock) { \
+ *(__handle) = lock; \
+ spin_lock_init(*(__handle)); \
+ } \
+ lock ? AE_OK : AE_NO_MEMORY; \
+ })
+
+void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
+
+void acpi_os_unmap_memory(void __iomem *logical_address, acpi_size size);
+
+/*
+ * OSL interfaces added by Linux
+ */
+void early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size);
+
+#endif
+
+#endif
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index f242909..a20f051 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -130,73 +130,6 @@

#ifdef __KERNEL__

-/*
- * FIXME: Inclusion of actypes.h
- * Linux kernel need this before defining inline OSL interfaces as
- * actypes.h need to be included to find ACPICA type definitions.
- * Since from ACPICA's perspective, the actypes.h should be included after
- * acenv.h (aclinux.h), this leads to a inclusion mis-ordering issue.
- */
-#include <acpi/actypes.h>
-
-/*
- * Overrides for in-kernel ACPICA
- */
-acpi_status __init acpi_os_initialize(void);
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
-
-acpi_status acpi_os_terminate(void);
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
-
-/*
- * Memory allocation/deallocation
- */
-
-/*
- * The irqs_disabled() check is for resume from RAM.
- * Interrupts are off during resume, just like they are for boot.
- * However, boot has (system_state != SYSTEM_RUNNING)
- * to quiet __might_sleep() in kmalloc() and resume does not.
- */
-static inline void *acpi_os_allocate(acpi_size size)
-{
- return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
-
-/* Use native linux version of acpi_os_allocate_zeroed */
-
-static inline void *acpi_os_allocate_zeroed(acpi_size size)
-{
- return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
-#define USE_NATIVE_ALLOCATE_ZEROED
-
-static inline void acpi_os_free(void *memory)
-{
- kfree(memory);
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
-
-static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
-{
- return kmem_cache_zalloc(cache,
- irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
-
-static inline acpi_thread_id acpi_os_get_thread_id(void)
-{
- return (acpi_thread_id) (unsigned long)current;
-}
-
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
-
#ifndef CONFIG_PREEMPT

/*
@@ -212,27 +145,18 @@ static inline acpi_thread_id acpi_os_get_thread_id(void)
#endif

/*
- * When lockdep is enabled, the spin_lock_init() macro stringifies it's
- * argument and uses that as a name for the lock in debugging.
- * By executing spin_lock_init() in a macro the key changes from "lock" for
- * all locks to the name of the argument of acpi_os_create_lock(), which
- * prevents lockdep from reporting false positives for ACPICA locks.
+ * Overrides for in-kernel ACPICA
*/
-#define acpi_os_create_lock(__handle) \
- ({ \
- spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
- if (lock) { \
- *(__handle) = lock; \
- spin_lock_init(*(__handle)); \
- } \
- lock ? AE_OK : AE_NO_MEMORY; \
- })
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
+#define USE_NATIVE_ALLOCATE_ZEROED
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
+#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
-
-void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
-
-void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory

/*
@@ -253,11 +177,8 @@ void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory

-/*
- * OSL interfaces added by Linux
- */
-void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size);
-
#endif /* __KERNEL__ */

+#define ACPI_USE_NATIVE_INTERFACE_HEADER 1
+
#endif /* __ACLINUX_H__ */
--
1.7.10

2014-04-23 06:54:17

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH v2 3/5] ACPICA: Add <asm/acenv.h> to remove mis-ordered inclusion of <asm/acpi.h> from <acpi/platform/aclinux.h>.

There is a mis-order inclusion for <asm/acpi.h>.

As we will enforce including <linux/acpi.h> for all Linux ACPI users, we
can find the inclusion order is as follows:

<linux/acpi.h>
<acpi/acpi.h>
<acpi/platform/acenv.h>
(acenv.h before including aclinux.h)
<acpi/platform/aclinux.h>
...........................................................................
(aclinux.h before including asm/acpi.h)
<asm/acpi.h> @Redundant@
(ACPICA specific stuff)
...........................................................................
...........................................................................
(Linux ACPI specific stuff) ? - - - - - - - - - - - - +
(aclinux.h after including asm/acpi.h) @Invisible@ |
(acenv.h after including aclinux.h) @Invisible@ |
other ACPICA headers @Invisible@ |
............................................................|..............
<acpi/acpi_bus.h> |
<acpi/acpi_drivers.h> |
<asm/acpi.h> (Excluded) |
(Linux ACPI specific stuff) ! <- - - - - - - - - - - - - +

NOTE that, in ACPICA, <acpi/platform/acenv.h> is more like Kconfig
generated <generated/autoconf.h> for Linux, it is meant to be included
before including any ACPICA code.

In the above figure, there is a question mark for "Linux ACPI specific
stuff" in <asm/acpi.h> which should be included after including all other
ACPICA header files. Thus they really need to be moved to the position
marked with exclaimation mark or the definitions in the blocks marked with
"@Invisible@" will be invisible to such architecture specific "Linux ACPI
specific stuff" header blocks. This leaves 2 issues:
1. All environmental definitions in these blocks should have a copy in the
area marked with "@Redundant@" if they are required by the "Linux ACPI
specific stuff".
2. We cannot use any ACPICA defined types in <asm/acpi.h>.

This patch splits architecture specific ACPICA stuff from <asm/acpi.h> to
fix this issue.

Signed-off-by: Lv Zheng <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: [email protected]
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: [email protected]
---
arch/ia64/include/asm/acenv.h | 71 +++++++++++++++++++++++++++++++++++++++
arch/ia64/include/asm/acpi.h | 50 ---------------------------
arch/x86/include/asm/acenv.h | 65 +++++++++++++++++++++++++++++++++++
arch/x86/include/asm/acpi.h | 45 -------------------------
include/acpi/platform/aclinux.h | 2 +-
5 files changed, 137 insertions(+), 96 deletions(-)
create mode 100644 arch/ia64/include/asm/acenv.h
create mode 100644 arch/x86/include/asm/acenv.h

diff --git a/arch/ia64/include/asm/acenv.h b/arch/ia64/include/asm/acenv.h
new file mode 100644
index 0000000..e0896eb
--- /dev/null
+++ b/arch/ia64/include/asm/acenv.h
@@ -0,0 +1,71 @@
+/*
+ * IA64 specific ACPICA environments and implementation
+ *
+ * Copyright (C) 2014, Intel Corporation
+ * Author: Lv Zheng <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef _ASM_IA64_ACENV_H
+#define _ASM_IA64_ACENV_H
+
+#include <asm/intrinsics.h>
+
+#define COMPILER_DEPENDENT_INT64 long
+#define COMPILER_DEPENDENT_UINT64 unsigned long
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
+/* Asm macros */
+
+#define ACPI_FLUSH_CPU_CACHE()
+
+#ifdef CONFIG_ACPI
+
+static inline int
+ia64_acpi_acquire_global_lock(unsigned int *lock)
+{
+ unsigned int old, new, val;
+ do {
+ old = *lock;
+ new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
+ val = ia64_cmpxchg4_acq(lock, new, old);
+ } while (unlikely (val != old));
+ return (new < 3) ? -1 : 0;
+}
+
+static inline int
+ia64_acpi_release_global_lock(unsigned int *lock)
+{
+ unsigned int old, new, val;
+ do {
+ old = *lock;
+ new = old & ~0x3;
+ val = ia64_cmpxchg4_acq(lock, new, old);
+ } while (unlikely (val != old));
+ return old & 0x1;
+}
+
+#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
+ ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
+
+#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
+ ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
+
+#endif
+
+#endif /* _ASM_IA64_ACENV_H */
diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
index d651102..b0ddcfd 100644
--- a/arch/ia64/include/asm/acpi.h
+++ b/arch/ia64/include/asm/acpi.h
@@ -34,56 +34,6 @@
#include <linux/numa.h>
#include <asm/numa.h>

-#define COMPILER_DEPENDENT_INT64 long
-#define COMPILER_DEPENDENT_UINT64 unsigned long
-
-/*
- * Calling conventions:
- *
- * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
- * ACPI_EXTERNAL_XFACE - External ACPI interfaces
- * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
- * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
- */
-#define ACPI_SYSTEM_XFACE
-#define ACPI_EXTERNAL_XFACE
-#define ACPI_INTERNAL_XFACE
-#define ACPI_INTERNAL_VAR_XFACE
-
-/* Asm macros */
-
-#define ACPI_FLUSH_CPU_CACHE()
-
-static inline int
-ia64_acpi_acquire_global_lock (unsigned int *lock)
-{
- unsigned int old, new, val;
- do {
- old = *lock;
- new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
- val = ia64_cmpxchg4_acq(lock, new, old);
- } while (unlikely (val != old));
- return (new < 3) ? -1 : 0;
-}
-
-static inline int
-ia64_acpi_release_global_lock (unsigned int *lock)
-{
- unsigned int old, new, val;
- do {
- old = *lock;
- new = old & ~0x3;
- val = ia64_cmpxchg4_acq(lock, new, old);
- } while (unlikely (val != old));
- return old & 0x1;
-}
-
-#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
- ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
-
-#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
- ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
-
#ifdef CONFIG_ACPI
#define acpi_disabled 0 /* ACPI always enabled on IA64 */
#define acpi_noirq 0 /* ACPI always enabled on IA64 */
diff --git a/arch/x86/include/asm/acenv.h b/arch/x86/include/asm/acenv.h
new file mode 100644
index 0000000..6978584
--- /dev/null
+++ b/arch/x86/include/asm/acenv.h
@@ -0,0 +1,65 @@
+/*
+ * X86 specific ACPICA environments and implementation
+ *
+ * Copyright (C) 2014, Intel Corporation
+ * Author: Lv Zheng <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef _ASM_X86_ACENV_H
+#define _ASM_X86_ACENV_H
+
+#include <asm/special_insns.h>
+
+#define COMPILER_DEPENDENT_INT64 long long
+#define COMPILER_DEPENDENT_UINT64 unsigned long long
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
+/* Asm macros */
+
+#define ACPI_FLUSH_CPU_CACHE() wbinvd()
+
+#ifdef CONFIG_ACPI
+
+int __acpi_acquire_global_lock(unsigned int *lock);
+int __acpi_release_global_lock(unsigned int *lock);
+
+#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
+ ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
+
+#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
+ ((Acq) = __acpi_release_global_lock(&facs->global_lock))
+
+/*
+ * Math helper asm macros
+ */
+#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
+ asm("divl %2;" \
+ : "=a"(q32), "=d"(r32) \
+ : "r"(d32), \
+ "0"(n_lo), "1"(n_hi))
+
+#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
+ asm("shrl $1,%2 ;" \
+ "rcrl $1,%3;" \
+ : "=r"(n_hi), "=r"(n_lo) \
+ : "0"(n_hi), "1"(n_lo))
+
+#endif
+
+#endif /* _ASM_X86_ACENV_H */
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index c8c1e70..e06225e 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -32,51 +32,6 @@
#include <asm/mpspec.h>
#include <asm/realmode.h>

-#define COMPILER_DEPENDENT_INT64 long long
-#define COMPILER_DEPENDENT_UINT64 unsigned long long
-
-/*
- * Calling conventions:
- *
- * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
- * ACPI_EXTERNAL_XFACE - External ACPI interfaces
- * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
- * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
- */
-#define ACPI_SYSTEM_XFACE
-#define ACPI_EXTERNAL_XFACE
-#define ACPI_INTERNAL_XFACE
-#define ACPI_INTERNAL_VAR_XFACE
-
-/* Asm macros */
-
-#define ACPI_FLUSH_CPU_CACHE() wbinvd()
-
-int __acpi_acquire_global_lock(unsigned int *lock);
-int __acpi_release_global_lock(unsigned int *lock);
-
-#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
- ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
-
-#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
- ((Acq) = __acpi_release_global_lock(&facs->global_lock))
-
-/*
- * Math helper asm macros
- */
-#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
- asm("divl %2;" \
- : "=a"(q32), "=d"(r32) \
- : "r"(d32), \
- "0"(n_lo), "1"(n_hi))
-
-
-#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
- asm("shrl $1,%2 ;" \
- "rcrl $1,%3;" \
- : "=r"(n_hi), "=r"(n_lo) \
- : "0"(n_hi), "1"(n_lo))
-
#ifdef CONFIG_ACPI
extern int acpi_lapic;
extern int acpi_ioapic;
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index a20f051..99d0546 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -71,7 +71,7 @@
#ifdef EXPORT_ACPI_INTERFACES
#include <linux/export.h>
#endif
-#include <asm/acpi.h>
+#include <asm/acenv.h>

/* Host-dependent types and defines for in-kernel ACPICA */

--
1.7.10

2014-04-23 06:54:26

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH v2 4/5] ACPICA: Cleanup redudant definitions that already have defaults in <acpi/platform/acenv.h>.

Since mis-order issues have been solved, we can cleanup redundant
definitions that already have defaults in <acpi/platform/acenv.h>.

This patch removes redudant environments for __KERNEL__ surrounded code.

Signed-off-by: Lv Zheng <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: [email protected]
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: [email protected]
---
arch/ia64/include/asm/acenv.h | 15 ---------------
arch/x86/include/asm/acenv.h | 16 ----------------
include/acpi/platform/aclinux.h | 1 -
3 files changed, 32 deletions(-)

diff --git a/arch/ia64/include/asm/acenv.h b/arch/ia64/include/asm/acenv.h
index e0896eb..3f9eaee 100644
--- a/arch/ia64/include/asm/acenv.h
+++ b/arch/ia64/include/asm/acenv.h
@@ -17,23 +17,8 @@
#define COMPILER_DEPENDENT_INT64 long
#define COMPILER_DEPENDENT_UINT64 unsigned long

-/*
- * Calling conventions:
- *
- * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
- * ACPI_EXTERNAL_XFACE - External ACPI interfaces
- * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
- * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
- */
-#define ACPI_SYSTEM_XFACE
-#define ACPI_EXTERNAL_XFACE
-#define ACPI_INTERNAL_XFACE
-#define ACPI_INTERNAL_VAR_XFACE
-
/* Asm macros */

-#define ACPI_FLUSH_CPU_CACHE()
-
#ifdef CONFIG_ACPI

static inline int
diff --git a/arch/x86/include/asm/acenv.h b/arch/x86/include/asm/acenv.h
index 6978584..6687329 100644
--- a/arch/x86/include/asm/acenv.h
+++ b/arch/x86/include/asm/acenv.h
@@ -14,22 +14,6 @@

#include <asm/special_insns.h>

-#define COMPILER_DEPENDENT_INT64 long long
-#define COMPILER_DEPENDENT_UINT64 unsigned long long
-
-/*
- * Calling conventions:
- *
- * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
- * ACPI_EXTERNAL_XFACE - External ACPI interfaces
- * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
- * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
- */
-#define ACPI_SYSTEM_XFACE
-#define ACPI_EXTERNAL_XFACE
-#define ACPI_INTERNAL_XFACE
-#define ACPI_INTERNAL_VAR_XFACE
-
/* Asm macros */

#define ACPI_FLUSH_CPU_CACHE() wbinvd()
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 99d0546..90eea12 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -48,7 +48,6 @@

#define ACPI_USE_SYSTEM_CLIBRARY
#define ACPI_USE_DO_WHILE_0
-#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE

#ifdef __KERNEL__

--
1.7.10

2014-04-23 06:54:54

by Zheng, Lv

[permalink] [raw]
Subject: [PATCH v2 5/5] ACPICA: Remove deprecated _LINUX definitions for ACPICA.

There are _LINUX defined so that when Linux kernel is compiled using broken
compilers that having not __linux__ defined can still include
<acpi/platform/aclinux.h> from <acpi/platform/acenv.h>.

This behavior is deprecated as all drivers/acpi/acpica files are compiled
without including <linux/acpi.h>, thus without _LINUX defined. As there is
no issues encountered when we compile ACPICA code without _LINUX defined,
it is OK to remove _LINUX from <linux/acpi.h> now.

Signed-off-by: Lv Zheng <[email protected]>
---
include/linux/acpi.h | 4 ----
1 file changed, 4 deletions(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 7a8f2cd..9c559f7 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -31,10 +31,6 @@

#ifdef CONFIG_ACPI

-#ifndef _LINUX
-#define _LINUX
-#endif
-
#include <linux/list.h>
#include <linux/mod_devicetable.h>

--
1.7.10

2014-04-27 21:17:14

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v2 1/5] ACPICA: OSL: Add direct inclusion of extra header.

On Wednesday, April 23, 2014 02:53:52 PM Lv Zheng wrote:
> This is a linuxized result of an ACPICA commit to upgrade the extra
> header mechanism.
>
> This patch enhances the extra header solution to allow Linux to use
> ACPI_USE_NATIVE_INTERFACE_HEADER and the file name can be automatically
> replaced during ACPICA release process. Using this way, the rest of the
> ACPICA users needn't know the name of the extra header file. Lv Zheng.
>
> Signed-off-by: Lv Zheng <[email protected]>
> ---
> include/acpi/acpi.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
> index ca0cb60..682398b 100644
> --- a/include/acpi/acpi.h
> +++ b/include/acpi/acpi.h
> @@ -62,8 +62,8 @@
> #include <acpi/acrestyp.h> /* Resource Descriptor structs */
> #include <acpi/acpiosxf.h> /* OSL interfaces (ACPICA-to-OS) */
> #include <acpi/acpixf.h> /* ACPI core subsystem external interfaces */
> -#ifdef ACPI_NATIVE_INTERFACE_HEADER
> -#include ACPI_NATIVE_INTERFACE_HEADER
> +#ifdef ACPI_USE_NATIVE_INTERFACE_HEADER
> +#include <acpi/acpi_opt.h>
> #endif
>
> #endif /* __ACPI_H__ */

Well, I still think there's a better way.

Introduce <acpi/platform/acenvex.h> into ACPICA and put this into it:

#if defined(_LINUX) || defined(__linux__)
#include <acpi/platform/aclinuxex.h>

#endif

and then move stuff you want in acpi/acpi_opt.h into acpi/platform/aclinuxex.h.

Then, you'll have in acpi.h:

#include <acpi/acrestyp.h> /* Resource Descriptor structs */
#include <acpi/acpiosxf.h> /* OSL interfaces (ACPICA-to-OS) */
#include <acpi/acpixf.h> /* ACPI core subsystem external interfaces */
#include <acpi/platform/acenvex.h> /* Extra environment-specific items */


That should work I suppose, shouldn't it?


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

2014-04-27 21:20:25

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] ACPICA: Add <asm/acenv.h> to remove mis-ordered inclusion of <asm/acpi.h> from <acpi/platform/aclinux.h>.

On Wednesday, April 23, 2014 02:54:06 PM Lv Zheng wrote:
> There is a mis-order inclusion for <asm/acpi.h>.
>
> As we will enforce including <linux/acpi.h> for all Linux ACPI users, we
> can find the inclusion order is as follows:
>
> <linux/acpi.h>
> <acpi/acpi.h>
> <acpi/platform/acenv.h>
> (acenv.h before including aclinux.h)
> <acpi/platform/aclinux.h>
> ...........................................................................
> (aclinux.h before including asm/acpi.h)
> <asm/acpi.h> @Redundant@
> (ACPICA specific stuff)
> ...........................................................................
> ...........................................................................
> (Linux ACPI specific stuff) ? - - - - - - - - - - - - +
> (aclinux.h after including asm/acpi.h) @Invisible@ |
> (acenv.h after including aclinux.h) @Invisible@ |
> other ACPICA headers @Invisible@ |
> ............................................................|..............
> <acpi/acpi_bus.h> |
> <acpi/acpi_drivers.h> |
> <asm/acpi.h> (Excluded) |
> (Linux ACPI specific stuff) ! <- - - - - - - - - - - - - +
>
> NOTE that, in ACPICA, <acpi/platform/acenv.h> is more like Kconfig
> generated <generated/autoconf.h> for Linux, it is meant to be included
> before including any ACPICA code.
>
> In the above figure, there is a question mark for "Linux ACPI specific
> stuff" in <asm/acpi.h> which should be included after including all other
> ACPICA header files. Thus they really need to be moved to the position
> marked with exclaimation mark or the definitions in the blocks marked with
> "@Invisible@" will be invisible to such architecture specific "Linux ACPI
> specific stuff" header blocks. This leaves 2 issues:
> 1. All environmental definitions in these blocks should have a copy in the
> area marked with "@Redundant@" if they are required by the "Linux ACPI
> specific stuff".
> 2. We cannot use any ACPICA defined types in <asm/acpi.h>.
>
> This patch splits architecture specific ACPICA stuff from <asm/acpi.h> to
> fix this issue.
>
> Signed-off-by: Lv Zheng <[email protected]>
> Cc: Tony Luck <[email protected]>
> Cc: Fenghua Yu <[email protected]>
> Cc: [email protected]
> Cc: Thomas Gleixner <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: "H. Peter Anvin" <[email protected]>
> Cc: [email protected]
> ---
> arch/ia64/include/asm/acenv.h | 71 +++++++++++++++++++++++++++++++++++++++
> arch/ia64/include/asm/acpi.h | 50 ---------------------------
> arch/x86/include/asm/acenv.h | 65 +++++++++++++++++++++++++++++++++++
> arch/x86/include/asm/acpi.h | 45 -------------------------
> include/acpi/platform/aclinux.h | 2 +-

Please rename the files first (in a separate patch) and then modify the
renamed ones. That will make changes much easier to follow.

> 5 files changed, 137 insertions(+), 96 deletions(-)
> create mode 100644 arch/ia64/include/asm/acenv.h
> create mode 100644 arch/x86/include/asm/acenv.h
>
> diff --git a/arch/ia64/include/asm/acenv.h b/arch/ia64/include/asm/acenv.h
> new file mode 100644
> index 0000000..e0896eb
> --- /dev/null
> +++ b/arch/ia64/include/asm/acenv.h
> @@ -0,0 +1,71 @@
> +/*
> + * IA64 specific ACPICA environments and implementation
> + *
> + * Copyright (C) 2014, Intel Corporation
> + * Author: Lv Zheng <[email protected]>
> + *
> + * 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.
> + */
> +
> +#ifndef _ASM_IA64_ACENV_H
> +#define _ASM_IA64_ACENV_H
> +
> +#include <asm/intrinsics.h>
> +
> +#define COMPILER_DEPENDENT_INT64 long
> +#define COMPILER_DEPENDENT_UINT64 unsigned long
> +
> +/*
> + * Calling conventions:
> + *
> + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
> + * ACPI_EXTERNAL_XFACE - External ACPI interfaces
> + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
> + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
> + */
> +#define ACPI_SYSTEM_XFACE
> +#define ACPI_EXTERNAL_XFACE
> +#define ACPI_INTERNAL_XFACE
> +#define ACPI_INTERNAL_VAR_XFACE
> +
> +/* Asm macros */
> +
> +#define ACPI_FLUSH_CPU_CACHE()
> +
> +#ifdef CONFIG_ACPI
> +
> +static inline int
> +ia64_acpi_acquire_global_lock(unsigned int *lock)
> +{
> + unsigned int old, new, val;
> + do {
> + old = *lock;
> + new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
> + val = ia64_cmpxchg4_acq(lock, new, old);
> + } while (unlikely (val != old));
> + return (new < 3) ? -1 : 0;
> +}
> +
> +static inline int
> +ia64_acpi_release_global_lock(unsigned int *lock)
> +{
> + unsigned int old, new, val;
> + do {
> + old = *lock;
> + new = old & ~0x3;
> + val = ia64_cmpxchg4_acq(lock, new, old);
> + } while (unlikely (val != old));
> + return old & 0x1;
> +}
> +
> +#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
> + ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
> +
> +#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
> + ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
> +
> +#endif
> +
> +#endif /* _ASM_IA64_ACENV_H */
> diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
> index d651102..b0ddcfd 100644
> --- a/arch/ia64/include/asm/acpi.h
> +++ b/arch/ia64/include/asm/acpi.h
> @@ -34,56 +34,6 @@
> #include <linux/numa.h>
> #include <asm/numa.h>
>
> -#define COMPILER_DEPENDENT_INT64 long
> -#define COMPILER_DEPENDENT_UINT64 unsigned long
> -
> -/*
> - * Calling conventions:
> - *
> - * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
> - * ACPI_EXTERNAL_XFACE - External ACPI interfaces
> - * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
> - * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
> - */
> -#define ACPI_SYSTEM_XFACE
> -#define ACPI_EXTERNAL_XFACE
> -#define ACPI_INTERNAL_XFACE
> -#define ACPI_INTERNAL_VAR_XFACE
> -
> -/* Asm macros */
> -
> -#define ACPI_FLUSH_CPU_CACHE()
> -
> -static inline int
> -ia64_acpi_acquire_global_lock (unsigned int *lock)
> -{
> - unsigned int old, new, val;
> - do {
> - old = *lock;
> - new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
> - val = ia64_cmpxchg4_acq(lock, new, old);
> - } while (unlikely (val != old));
> - return (new < 3) ? -1 : 0;
> -}
> -
> -static inline int
> -ia64_acpi_release_global_lock (unsigned int *lock)
> -{
> - unsigned int old, new, val;
> - do {
> - old = *lock;
> - new = old & ~0x3;
> - val = ia64_cmpxchg4_acq(lock, new, old);
> - } while (unlikely (val != old));
> - return old & 0x1;
> -}
> -
> -#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
> - ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
> -
> -#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
> - ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
> -
> #ifdef CONFIG_ACPI
> #define acpi_disabled 0 /* ACPI always enabled on IA64 */
> #define acpi_noirq 0 /* ACPI always enabled on IA64 */
> diff --git a/arch/x86/include/asm/acenv.h b/arch/x86/include/asm/acenv.h
> new file mode 100644
> index 0000000..6978584
> --- /dev/null
> +++ b/arch/x86/include/asm/acenv.h
> @@ -0,0 +1,65 @@
> +/*
> + * X86 specific ACPICA environments and implementation
> + *
> + * Copyright (C) 2014, Intel Corporation
> + * Author: Lv Zheng <[email protected]>
> + *
> + * 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.
> + */
> +
> +#ifndef _ASM_X86_ACENV_H
> +#define _ASM_X86_ACENV_H
> +
> +#include <asm/special_insns.h>
> +
> +#define COMPILER_DEPENDENT_INT64 long long
> +#define COMPILER_DEPENDENT_UINT64 unsigned long long
> +
> +/*
> + * Calling conventions:
> + *
> + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
> + * ACPI_EXTERNAL_XFACE - External ACPI interfaces
> + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
> + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
> + */
> +#define ACPI_SYSTEM_XFACE
> +#define ACPI_EXTERNAL_XFACE
> +#define ACPI_INTERNAL_XFACE
> +#define ACPI_INTERNAL_VAR_XFACE
> +
> +/* Asm macros */
> +
> +#define ACPI_FLUSH_CPU_CACHE() wbinvd()
> +
> +#ifdef CONFIG_ACPI
> +
> +int __acpi_acquire_global_lock(unsigned int *lock);
> +int __acpi_release_global_lock(unsigned int *lock);
> +
> +#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
> + ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
> +
> +#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
> + ((Acq) = __acpi_release_global_lock(&facs->global_lock))
> +
> +/*
> + * Math helper asm macros
> + */
> +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
> + asm("divl %2;" \
> + : "=a"(q32), "=d"(r32) \
> + : "r"(d32), \
> + "0"(n_lo), "1"(n_hi))
> +
> +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
> + asm("shrl $1,%2 ;" \
> + "rcrl $1,%3;" \
> + : "=r"(n_hi), "=r"(n_lo) \
> + : "0"(n_hi), "1"(n_lo))
> +
> +#endif
> +
> +#endif /* _ASM_X86_ACENV_H */
> diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
> index c8c1e70..e06225e 100644
> --- a/arch/x86/include/asm/acpi.h
> +++ b/arch/x86/include/asm/acpi.h
> @@ -32,51 +32,6 @@
> #include <asm/mpspec.h>
> #include <asm/realmode.h>
>
> -#define COMPILER_DEPENDENT_INT64 long long
> -#define COMPILER_DEPENDENT_UINT64 unsigned long long
> -
> -/*
> - * Calling conventions:
> - *
> - * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
> - * ACPI_EXTERNAL_XFACE - External ACPI interfaces
> - * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
> - * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
> - */
> -#define ACPI_SYSTEM_XFACE
> -#define ACPI_EXTERNAL_XFACE
> -#define ACPI_INTERNAL_XFACE
> -#define ACPI_INTERNAL_VAR_XFACE
> -
> -/* Asm macros */
> -
> -#define ACPI_FLUSH_CPU_CACHE() wbinvd()
> -
> -int __acpi_acquire_global_lock(unsigned int *lock);
> -int __acpi_release_global_lock(unsigned int *lock);
> -
> -#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
> - ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
> -
> -#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
> - ((Acq) = __acpi_release_global_lock(&facs->global_lock))
> -
> -/*
> - * Math helper asm macros
> - */
> -#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
> - asm("divl %2;" \
> - : "=a"(q32), "=d"(r32) \
> - : "r"(d32), \
> - "0"(n_lo), "1"(n_hi))
> -
> -
> -#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
> - asm("shrl $1,%2 ;" \
> - "rcrl $1,%3;" \
> - : "=r"(n_hi), "=r"(n_lo) \
> - : "0"(n_hi), "1"(n_lo))
> -
> #ifdef CONFIG_ACPI
> extern int acpi_lapic;
> extern int acpi_ioapic;
> diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
> index a20f051..99d0546 100644
> --- a/include/acpi/platform/aclinux.h
> +++ b/include/acpi/platform/aclinux.h
> @@ -71,7 +71,7 @@
> #ifdef EXPORT_ACPI_INTERFACES
> #include <linux/export.h>
> #endif
> -#include <asm/acpi.h>
> +#include <asm/acenv.h>
>
> /* Host-dependent types and defines for in-kernel ACPICA */
>
>

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

2014-04-27 21:22:22

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v2 5/5] ACPICA: Remove deprecated _LINUX definitions for ACPICA.

On Wednesday, April 23, 2014 02:54:22 PM Lv Zheng wrote:
> There are _LINUX defined so that when Linux kernel is compiled using broken
> compilers that having not __linux__ defined can still include
> <acpi/platform/aclinux.h> from <acpi/platform/acenv.h>.
>
> This behavior is deprecated as all drivers/acpi/acpica files are compiled
> without including <linux/acpi.h>, thus without _LINUX defined. As there is
> no issues encountered when we compile ACPICA code without _LINUX defined,
> it is OK to remove _LINUX from <linux/acpi.h> now.
>
> Signed-off-by: Lv Zheng <[email protected]>
> ---
> include/linux/acpi.h | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 7a8f2cd..9c559f7 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -31,10 +31,6 @@
>
> #ifdef CONFIG_ACPI
>
> -#ifndef _LINUX
> -#define _LINUX
> -#endif
> -
> #include <linux/list.h>
> #include <linux/mod_devicetable.h>

What about <acpi/platform/acenv.h>? Should it still check if _LINUX is defined
after this change?


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

2014-04-28 03:02:23

by Zheng, Lv

[permalink] [raw]
Subject: RE: [PATCH v2 3/5] ACPICA: Add <asm/acenv.h> to remove mis-ordered inclusion of <asm/acpi.h> from <acpi/platform/aclinux.h>.

Hi, Rafael

> From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
> Sent: Monday, April 28, 2014 5:37 AM
> To: Zheng, Lv
>
> On Wednesday, April 23, 2014 02:54:06 PM Lv Zheng wrote:
> > There is a mis-order inclusion for <asm/acpi.h>.
> >
> > As we will enforce including <linux/acpi.h> for all Linux ACPI users, we
> > can find the inclusion order is as follows:
> >
> > <linux/acpi.h>
> > <acpi/acpi.h>
> > <acpi/platform/acenv.h>
> > (acenv.h before including aclinux.h)
> > <acpi/platform/aclinux.h>
> > ...........................................................................
> > (aclinux.h before including asm/acpi.h)
> > <asm/acpi.h> @Redundant@
> > (ACPICA specific stuff)
> > ...........................................................................
> > ...........................................................................
> > (Linux ACPI specific stuff) ? - - - - - - - - - - - - +
> > (aclinux.h after including asm/acpi.h) @Invisible@ |
> > (acenv.h after including aclinux.h) @Invisible@ |
> > other ACPICA headers @Invisible@ |
> > ............................................................|..............
> > <acpi/acpi_bus.h> |
> > <acpi/acpi_drivers.h> |
> > <asm/acpi.h> (Excluded) |
> > (Linux ACPI specific stuff) ! <- - - - - - - - - - - - - +
> >
> > NOTE that, in ACPICA, <acpi/platform/acenv.h> is more like Kconfig
> > generated <generated/autoconf.h> for Linux, it is meant to be included
> > before including any ACPICA code.
> >
> > In the above figure, there is a question mark for "Linux ACPI specific
> > stuff" in <asm/acpi.h> which should be included after including all other
> > ACPICA header files. Thus they really need to be moved to the position
> > marked with exclaimation mark or the definitions in the blocks marked with
> > "@Invisible@" will be invisible to such architecture specific "Linux ACPI
> > specific stuff" header blocks. This leaves 2 issues:
> > 1. All environmental definitions in these blocks should have a copy in the
> > area marked with "@Redundant@" if they are required by the "Linux ACPI
> > specific stuff".
> > 2. We cannot use any ACPICA defined types in <asm/acpi.h>.
> >
> > This patch splits architecture specific ACPICA stuff from <asm/acpi.h> to
> > fix this issue.
> >
> > Signed-off-by: Lv Zheng <[email protected]>
> > Cc: Tony Luck <[email protected]>
> > Cc: Fenghua Yu <[email protected]>
> > Cc: [email protected]
> > Cc: Thomas Gleixner <[email protected]>
> > Cc: Ingo Molnar <[email protected]>
> > Cc: "H. Peter Anvin" <[email protected]>
> > Cc: [email protected]
> > ---
> > arch/ia64/include/asm/acenv.h | 71 +++++++++++++++++++++++++++++++++++++++
> > arch/ia64/include/asm/acpi.h | 50 ---------------------------
> > arch/x86/include/asm/acenv.h | 65 +++++++++++++++++++++++++++++++++++
> > arch/x86/include/asm/acpi.h | 45 -------------------------
> > include/acpi/platform/aclinux.h | 2 +-
>
> Please rename the files first (in a separate patch) and then modify the
> renamed ones. That will make changes much easier to follow.

This patch doesn't provide a rename.
Currently, <asm/acpi.h> includes:
1. arch specific ACPI stuff
2. arch specific ACPICA stuff
This patch moves "2" to a separate file <asm/acenv.h>, thus no renaming happens here.

Thanks and best regards
-Lv

>
> > 5 files changed, 137 insertions(+), 96 deletions(-)
> > create mode 100644 arch/ia64/include/asm/acenv.h
> > create mode 100644 arch/x86/include/asm/acenv.h
> >
> > diff --git a/arch/ia64/include/asm/acenv.h b/arch/ia64/include/asm/acenv.h
> > new file mode 100644
> > index 0000000..e0896eb
> > --- /dev/null
> > +++ b/arch/ia64/include/asm/acenv.h
> > @@ -0,0 +1,71 @@
> > +/*
> > + * IA64 specific ACPICA environments and implementation
> > + *
> > + * Copyright (C) 2014, Intel Corporation
> > + * Author: Lv Zheng <[email protected]>
> > + *
> > + * 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.
> > + */
> > +
> > +#ifndef _ASM_IA64_ACENV_H
> > +#define _ASM_IA64_ACENV_H
> > +
> > +#include <asm/intrinsics.h>
> > +
> > +#define COMPILER_DEPENDENT_INT64 long
> > +#define COMPILER_DEPENDENT_UINT64 unsigned long
> > +
> > +/*
> > + * Calling conventions:
> > + *
> > + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
> > + * ACPI_EXTERNAL_XFACE - External ACPI interfaces
> > + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
> > + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
> > + */
> > +#define ACPI_SYSTEM_XFACE
> > +#define ACPI_EXTERNAL_XFACE
> > +#define ACPI_INTERNAL_XFACE
> > +#define ACPI_INTERNAL_VAR_XFACE
> > +
> > +/* Asm macros */
> > +
> > +#define ACPI_FLUSH_CPU_CACHE()
> > +
> > +#ifdef CONFIG_ACPI
> > +
> > +static inline int
> > +ia64_acpi_acquire_global_lock(unsigned int *lock)
> > +{
> > + unsigned int old, new, val;
> > + do {
> > + old = *lock;
> > + new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
> > + val = ia64_cmpxchg4_acq(lock, new, old);
> > + } while (unlikely (val != old));
> > + return (new < 3) ? -1 : 0;
> > +}
> > +
> > +static inline int
> > +ia64_acpi_release_global_lock(unsigned int *lock)
> > +{
> > + unsigned int old, new, val;
> > + do {
> > + old = *lock;
> > + new = old & ~0x3;
> > + val = ia64_cmpxchg4_acq(lock, new, old);
> > + } while (unlikely (val != old));
> > + return old & 0x1;
> > +}
> > +
> > +#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
> > + ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
> > +
> > +#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
> > + ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
> > +
> > +#endif
> > +
> > +#endif /* _ASM_IA64_ACENV_H */
> > diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
> > index d651102..b0ddcfd 100644
> > --- a/arch/ia64/include/asm/acpi.h
> > +++ b/arch/ia64/include/asm/acpi.h
> > @@ -34,56 +34,6 @@
> > #include <linux/numa.h>
> > #include <asm/numa.h>
> >
> > -#define COMPILER_DEPENDENT_INT64 long
> > -#define COMPILER_DEPENDENT_UINT64 unsigned long
> > -
> > -/*
> > - * Calling conventions:
> > - *
> > - * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
> > - * ACPI_EXTERNAL_XFACE - External ACPI interfaces
> > - * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
> > - * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
> > - */
> > -#define ACPI_SYSTEM_XFACE
> > -#define ACPI_EXTERNAL_XFACE
> > -#define ACPI_INTERNAL_XFACE
> > -#define ACPI_INTERNAL_VAR_XFACE
> > -
> > -/* Asm macros */
> > -
> > -#define ACPI_FLUSH_CPU_CACHE()
> > -
> > -static inline int
> > -ia64_acpi_acquire_global_lock (unsigned int *lock)
> > -{
> > - unsigned int old, new, val;
> > - do {
> > - old = *lock;
> > - new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
> > - val = ia64_cmpxchg4_acq(lock, new, old);
> > - } while (unlikely (val != old));
> > - return (new < 3) ? -1 : 0;
> > -}
> > -
> > -static inline int
> > -ia64_acpi_release_global_lock (unsigned int *lock)
> > -{
> > - unsigned int old, new, val;
> > - do {
> > - old = *lock;
> > - new = old & ~0x3;
> > - val = ia64_cmpxchg4_acq(lock, new, old);
> > - } while (unlikely (val != old));
> > - return old & 0x1;
> > -}
> > -
> > -#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
> > - ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
> > -
> > -#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
> > - ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
> > -
> > #ifdef CONFIG_ACPI
> > #define acpi_disabled 0 /* ACPI always enabled on IA64 */
> > #define acpi_noirq 0 /* ACPI always enabled on IA64 */
> > diff --git a/arch/x86/include/asm/acenv.h b/arch/x86/include/asm/acenv.h
> > new file mode 100644
> > index 0000000..6978584
> > --- /dev/null
> > +++ b/arch/x86/include/asm/acenv.h
> > @@ -0,0 +1,65 @@
> > +/*
> > + * X86 specific ACPICA environments and implementation
> > + *
> > + * Copyright (C) 2014, Intel Corporation
> > + * Author: Lv Zheng <[email protected]>
> > + *
> > + * 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.
> > + */
> > +
> > +#ifndef _ASM_X86_ACENV_H
> > +#define _ASM_X86_ACENV_H
> > +
> > +#include <asm/special_insns.h>
> > +
> > +#define COMPILER_DEPENDENT_INT64 long long
> > +#define COMPILER_DEPENDENT_UINT64 unsigned long long
> > +
> > +/*
> > + * Calling conventions:
> > + *
> > + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
> > + * ACPI_EXTERNAL_XFACE - External ACPI interfaces
> > + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
> > + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
> > + */
> > +#define ACPI_SYSTEM_XFACE
> > +#define ACPI_EXTERNAL_XFACE
> > +#define ACPI_INTERNAL_XFACE
> > +#define ACPI_INTERNAL_VAR_XFACE
> > +
> > +/* Asm macros */
> > +
> > +#define ACPI_FLUSH_CPU_CACHE() wbinvd()
> > +
> > +#ifdef CONFIG_ACPI
> > +
> > +int __acpi_acquire_global_lock(unsigned int *lock);
> > +int __acpi_release_global_lock(unsigned int *lock);
> > +
> > +#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
> > + ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
> > +
> > +#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
> > + ((Acq) = __acpi_release_global_lock(&facs->global_lock))
> > +
> > +/*
> > + * Math helper asm macros
> > + */
> > +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
> > + asm("divl %2;" \
> > + : "=a"(q32), "=d"(r32) \
> > + : "r"(d32), \
> > + "0"(n_lo), "1"(n_hi))
> > +
> > +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
> > + asm("shrl $1,%2 ;" \
> > + "rcrl $1,%3;" \
> > + : "=r"(n_hi), "=r"(n_lo) \
> > + : "0"(n_hi), "1"(n_lo))
> > +
> > +#endif
> > +
> > +#endif /* _ASM_X86_ACENV_H */
> > diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
> > index c8c1e70..e06225e 100644
> > --- a/arch/x86/include/asm/acpi.h
> > +++ b/arch/x86/include/asm/acpi.h
> > @@ -32,51 +32,6 @@
> > #include <asm/mpspec.h>
> > #include <asm/realmode.h>
> >
> > -#define COMPILER_DEPENDENT_INT64 long long
> > -#define COMPILER_DEPENDENT_UINT64 unsigned long long
> > -
> > -/*
> > - * Calling conventions:
> > - *
> > - * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
> > - * ACPI_EXTERNAL_XFACE - External ACPI interfaces
> > - * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
> > - * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
> > - */
> > -#define ACPI_SYSTEM_XFACE
> > -#define ACPI_EXTERNAL_XFACE
> > -#define ACPI_INTERNAL_XFACE
> > -#define ACPI_INTERNAL_VAR_XFACE
> > -
> > -/* Asm macros */
> > -
> > -#define ACPI_FLUSH_CPU_CACHE() wbinvd()
> > -
> > -int __acpi_acquire_global_lock(unsigned int *lock);
> > -int __acpi_release_global_lock(unsigned int *lock);
> > -
> > -#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
> > - ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
> > -
> > -#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
> > - ((Acq) = __acpi_release_global_lock(&facs->global_lock))
> > -
> > -/*
> > - * Math helper asm macros
> > - */
> > -#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
> > - asm("divl %2;" \
> > - : "=a"(q32), "=d"(r32) \
> > - : "r"(d32), \
> > - "0"(n_lo), "1"(n_hi))
> > -
> > -
> > -#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
> > - asm("shrl $1,%2 ;" \
> > - "rcrl $1,%3;" \
> > - : "=r"(n_hi), "=r"(n_lo) \
> > - : "0"(n_hi), "1"(n_lo))
> > -
> > #ifdef CONFIG_ACPI
> > extern int acpi_lapic;
> > extern int acpi_ioapic;
> > diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
> > index a20f051..99d0546 100644
> > --- a/include/acpi/platform/aclinux.h
> > +++ b/include/acpi/platform/aclinux.h
> > @@ -71,7 +71,7 @@
> > #ifdef EXPORT_ACPI_INTERFACES
> > #include <linux/export.h>
> > #endif
> > -#include <asm/acpi.h>
> > +#include <asm/acenv.h>
> >
> > /* Host-dependent types and defines for in-kernel ACPICA */
> >
> >
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-04-28 04:11:10

by Zheng, Lv

[permalink] [raw]
Subject: RE: [PATCH v2 5/5] ACPICA: Remove deprecated _LINUX definitions for ACPICA.

Hi, Rafael

> From: Rafael J. Wysocki [mailto:[email protected]]
> Sent: Monday, April 28, 2014 5:39 AM
>
> On Wednesday, April 23, 2014 02:54:22 PM Lv Zheng wrote:
> > There are _LINUX defined so that when Linux kernel is compiled using broken
> > compilers that having not __linux__ defined can still include
> > <acpi/platform/aclinux.h> from <acpi/platform/acenv.h>.
> >
> > This behavior is deprecated as all drivers/acpi/acpica files are compiled
> > without including <linux/acpi.h>, thus without _LINUX defined. As there is
> > no issues encountered when we compile ACPICA code without _LINUX defined,
> > it is OK to remove _LINUX from <linux/acpi.h> now.
> >
> > Signed-off-by: Lv Zheng <[email protected]>
> > ---
> > include/linux/acpi.h | 4 ----
> > 1 file changed, 4 deletions(-)
> >
> > diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> > index 7a8f2cd..9c559f7 100644
> > --- a/include/linux/acpi.h
> > +++ b/include/linux/acpi.h
> > @@ -31,10 +31,6 @@
> >
> > #ifdef CONFIG_ACPI
> >
> > -#ifndef _LINUX
> > -#define _LINUX
> > -#endif
> > -
> > #include <linux/list.h>
> > #include <linux/mod_devicetable.h>
>
> What about <acpi/platform/acenv.h>? Should it still check if _LINUX is defined
> after this change?

If you mean these lines:
#if defined(_LINUX) || defined(__linux__)
#include <acpi/platform/aclinux.h>
After deleting "_LINUX" from <linux/acpi.h>, acenv.h still can include aclinux.h because of "__linux__".
Actually all drivers/acpi/acpica source files are compiled without including <linux/acpi.h>, so "_LINUX" defined in this file is useless to Linux.
We needn't delete "_LINUX" from acenv.h.

"_LINUX" is only used in ACPICA makefiles, Linux never uses it:
https://github.com/acpica/acpica/blob/master/generate/unix/Makefile.config
ACPICA can be compiled using the following make command:
make HOST=_LINUX
I think this is the only usage of "_LINUX" for now.

Thanks and best regards
-Lv

>
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-04-28 04:13:05

by Zheng, Lv

[permalink] [raw]
Subject: RE: [PATCH v2 1/5] ACPICA: OSL: Add direct inclusion of extra header.

Hi, Rafael

> From: Rafael J. Wysocki [mailto:[email protected]]
> Sent: Monday, April 28, 2014 5:34 AM
>
> On Wednesday, April 23, 2014 02:53:52 PM Lv Zheng wrote:
> > This is a linuxized result of an ACPICA commit to upgrade the extra
> > header mechanism.
> >
> > This patch enhances the extra header solution to allow Linux to use
> > ACPI_USE_NATIVE_INTERFACE_HEADER and the file name can be automatically
> > replaced during ACPICA release process. Using this way, the rest of the
> > ACPICA users needn't know the name of the extra header file. Lv Zheng.
> >
> > Signed-off-by: Lv Zheng <[email protected]>
> > ---
> > include/acpi/acpi.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
> > index ca0cb60..682398b 100644
> > --- a/include/acpi/acpi.h
> > +++ b/include/acpi/acpi.h
> > @@ -62,8 +62,8 @@
> > #include <acpi/acrestyp.h> /* Resource Descriptor structs */
> > #include <acpi/acpiosxf.h> /* OSL interfaces (ACPICA-to-OS) */
> > #include <acpi/acpixf.h> /* ACPI core subsystem external interfaces */
> > -#ifdef ACPI_NATIVE_INTERFACE_HEADER
> > -#include ACPI_NATIVE_INTERFACE_HEADER
> > +#ifdef ACPI_USE_NATIVE_INTERFACE_HEADER
> > +#include <acpi/acpi_opt.h>
> > #endif
> >
> > #endif /* __ACPI_H__ */
>
> Well, I still think there's a better way.
>
> Introduce <acpi/platform/acenvex.h> into ACPICA and put this into it:
>
> #if defined(_LINUX) || defined(__linux__)
> #include <acpi/platform/aclinuxex.h>
>
> #endif
>
> and then move stuff you want in acpi/acpi_opt.h into acpi/platform/aclinuxex.h.
>
> Then, you'll have in acpi.h:
>
> #include <acpi/acrestyp.h> /* Resource Descriptor structs */
> #include <acpi/acpiosxf.h> /* OSL interfaces (ACPICA-to-OS) */
> #include <acpi/acpixf.h> /* ACPI core subsystem external interfaces */
> #include <acpi/platform/acenvex.h> /* Extra environment-specific items */
>
>
> That should work I suppose, shouldn't it?

I think this should work.
I'll modify this patch according the above suggestion.

Thanks and best regards
-Lv

> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-04-28 20:27:29

by Wysocki, Rafael J

[permalink] [raw]
Subject: Re: [PATCH v2 5/5] ACPICA: Remove deprecated _LINUX definitions for ACPICA.

On 4/28/2014 6:10 AM, Zheng, Lv wrote:
> Hi, Rafael
>
>> From: Rafael J. Wysocki [mailto:[email protected]]
>> Sent: Monday, April 28, 2014 5:39 AM
>>
>> On Wednesday, April 23, 2014 02:54:22 PM Lv Zheng wrote:
>>> There are _LINUX defined so that when Linux kernel is compiled using broken
>>> compilers that having not __linux__ defined can still include
>>> <acpi/platform/aclinux.h> from <acpi/platform/acenv.h>.
>>>
>>> This behavior is deprecated as all drivers/acpi/acpica files are compiled
>>> without including <linux/acpi.h>, thus without _LINUX defined. As there is
>>> no issues encountered when we compile ACPICA code without _LINUX defined,
>>> it is OK to remove _LINUX from <linux/acpi.h> now.
>>>
>>> Signed-off-by: Lv Zheng <[email protected]>
>>> ---
>>> include/linux/acpi.h | 4 ----
>>> 1 file changed, 4 deletions(-)
>>>
>>> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
>>> index 7a8f2cd..9c559f7 100644
>>> --- a/include/linux/acpi.h
>>> +++ b/include/linux/acpi.h
>>> @@ -31,10 +31,6 @@
>>>
>>> #ifdef CONFIG_ACPI
>>>
>>> -#ifndef _LINUX
>>> -#define _LINUX
>>> -#endif
>>> -
>>> #include <linux/list.h>
>>> #include <linux/mod_devicetable.h>
>> What about <acpi/platform/acenv.h>? Should it still check if _LINUX is defined
>> after this change?
> If you mean these lines:
> #if defined(_LINUX) || defined(__linux__)
> #include <acpi/platform/aclinux.h>
> After deleting "_LINUX" from <linux/acpi.h>, acenv.h still can include aclinux.h because of "__linux__".
> Actually all drivers/acpi/acpica source files are compiled without including <linux/acpi.h>, so "_LINUX" defined in this file is useless to Linux.
> We needn't delete "_LINUX" from acenv.h.
>
> "_LINUX" is only used in ACPICA makefiles, Linux never uses it:
> https://github.com/acpica/acpica/blob/master/generate/unix/Makefile.config
> ACPICA can be compiled using the following make command:
> make HOST=_LINUX
> I think this is the only usage of "_LINUX" for now.

Well, my point was: If we delete the definition of _LINUX, why don't we
drop the symbol itself from everywhere along with it?

It definitely is not useful to refer to a symbol that's never defined,
is it?

Rafael

2014-04-28 20:30:36

by Wysocki, Rafael J

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] ACPICA: Add <asm/acenv.h> to remove mis-ordered inclusion of <asm/acpi.h> from <acpi/platform/aclinux.h>.

On 4/28/2014 5:02 AM, Zheng, Lv wrote:
> Hi, Rafael
>
>> From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
>> Sent: Monday, April 28, 2014 5:37 AM
>> To: Zheng, Lv
>>
>> On Wednesday, April 23, 2014 02:54:06 PM Lv Zheng wrote:
>>> There is a mis-order inclusion for <asm/acpi.h>.
>>>
>>> As we will enforce including <linux/acpi.h> for all Linux ACPI users, we
>>> can find the inclusion order is as follows:
>>>
>>> <linux/acpi.h>
>>> <acpi/acpi.h>
>>> <acpi/platform/acenv.h>
>>> (acenv.h before including aclinux.h)
>>> <acpi/platform/aclinux.h>
>>> ...........................................................................
>>> (aclinux.h before including asm/acpi.h)
>>> <asm/acpi.h> @Redundant@
>>> (ACPICA specific stuff)
>>> ...........................................................................
>>> ...........................................................................
>>> (Linux ACPI specific stuff) ? - - - - - - - - - - - - +
>>> (aclinux.h after including asm/acpi.h) @Invisible@ |
>>> (acenv.h after including aclinux.h) @Invisible@ |
>>> other ACPICA headers @Invisible@ |
>>> ............................................................|..............
>>> <acpi/acpi_bus.h> |
>>> <acpi/acpi_drivers.h> |
>>> <asm/acpi.h> (Excluded) |
>>> (Linux ACPI specific stuff) ! <- - - - - - - - - - - - - +
>>>
>>> NOTE that, in ACPICA, <acpi/platform/acenv.h> is more like Kconfig
>>> generated <generated/autoconf.h> for Linux, it is meant to be included
>>> before including any ACPICA code.
>>>
>>> In the above figure, there is a question mark for "Linux ACPI specific
>>> stuff" in <asm/acpi.h> which should be included after including all other
>>> ACPICA header files. Thus they really need to be moved to the position
>>> marked with exclaimation mark or the definitions in the blocks marked with
>>> "@Invisible@" will be invisible to such architecture specific "Linux ACPI
>>> specific stuff" header blocks. This leaves 2 issues:
>>> 1. All environmental definitions in these blocks should have a copy in the
>>> area marked with "@Redundant@" if they are required by the "Linux ACPI
>>> specific stuff".
>>> 2. We cannot use any ACPICA defined types in <asm/acpi.h>.
>>>
>>> This patch splits architecture specific ACPICA stuff from <asm/acpi.h> to
>>> fix this issue.
>>>
>>> Signed-off-by: Lv Zheng <[email protected]>
>>> Cc: Tony Luck <[email protected]>
>>> Cc: Fenghua Yu <[email protected]>
>>> Cc: [email protected]
>>> Cc: Thomas Gleixner <[email protected]>
>>> Cc: Ingo Molnar <[email protected]>
>>> Cc: "H. Peter Anvin" <[email protected]>
>>> Cc: [email protected]
>>> ---
>>> arch/ia64/include/asm/acenv.h | 71 +++++++++++++++++++++++++++++++++++++++
>>> arch/ia64/include/asm/acpi.h | 50 ---------------------------
>>> arch/x86/include/asm/acenv.h | 65 +++++++++++++++++++++++++++++++++++
>>> arch/x86/include/asm/acpi.h | 45 -------------------------
>>> include/acpi/platform/aclinux.h | 2 +-
>> Please rename the files first (in a separate patch) and then modify the
>> renamed ones. That will make changes much easier to follow.
> This patch doesn't provide a rename.
> Currently, <asm/acpi.h> includes:
> 1. arch specific ACPI stuff
> 2. arch specific ACPICA stuff
> This patch moves "2" to a separate file <asm/acenv.h>, thus no renaming happens here.

Ah, I overlooked that, sorry.

Which I might not do if the changelog said what the patch was really doing.

Thanks,
Rafael

2014-04-29 07:49:37

by Zheng, Lv

[permalink] [raw]
Subject: RE: [PATCH v2 3/5] ACPICA: Add <asm/acenv.h> to remove mis-ordered inclusion of <asm/acpi.h> from <acpi/platform/aclinux.h>.

Hi, Rafael

> From: Wysocki, Rafael J
> Sent: Tuesday, April 29, 2014 4:30 AM
>
> On 4/28/2014 5:02 AM, Zheng, Lv wrote:
> > Hi, Rafael
> >
> >> From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
> >> Sent: Monday, April 28, 2014 5:37 AM
> >> To: Zheng, Lv
> >>
> >> On Wednesday, April 23, 2014 02:54:06 PM Lv Zheng wrote:
> >>> There is a mis-order inclusion for <asm/acpi.h>.
> >>>
> >>> As we will enforce including <linux/acpi.h> for all Linux ACPI users, we
> >>> can find the inclusion order is as follows:
> >>>
> >>> <linux/acpi.h>
> >>> <acpi/acpi.h>
> >>> <acpi/platform/acenv.h>
> >>> (acenv.h before including aclinux.h)
> >>> <acpi/platform/aclinux.h>
> >>> ...........................................................................
> >>> (aclinux.h before including asm/acpi.h)
> >>> <asm/acpi.h> @Redundant@
> >>> (ACPICA specific stuff)
> >>> ...........................................................................
> >>> ...........................................................................
> >>> (Linux ACPI specific stuff) ? - - - - - - - - - - - - +
> >>> (aclinux.h after including asm/acpi.h) @Invisible@ |
> >>> (acenv.h after including aclinux.h) @Invisible@ |
> >>> other ACPICA headers @Invisible@ |
> >>> ............................................................|..............
> >>> <acpi/acpi_bus.h> |
> >>> <acpi/acpi_drivers.h> |
> >>> <asm/acpi.h> (Excluded) |
> >>> (Linux ACPI specific stuff) ! <- - - - - - - - - - - - - +
> >>>
> >>> NOTE that, in ACPICA, <acpi/platform/acenv.h> is more like Kconfig
> >>> generated <generated/autoconf.h> for Linux, it is meant to be included
> >>> before including any ACPICA code.
> >>>
> >>> In the above figure, there is a question mark for "Linux ACPI specific
> >>> stuff" in <asm/acpi.h> which should be included after including all other
> >>> ACPICA header files. Thus they really need to be moved to the position
> >>> marked with exclaimation mark or the definitions in the blocks marked with
> >>> "@Invisible@" will be invisible to such architecture specific "Linux ACPI
> >>> specific stuff" header blocks. This leaves 2 issues:
> >>> 1. All environmental definitions in these blocks should have a copy in the
> >>> area marked with "@Redundant@" if they are required by the "Linux ACPI
> >>> specific stuff".
> >>> 2. We cannot use any ACPICA defined types in <asm/acpi.h>.
> >>>
> >>> This patch splits architecture specific ACPICA stuff from <asm/acpi.h> to
> >>> fix this issue.
> >>>
> >>> Signed-off-by: Lv Zheng <[email protected]>
> >>> Cc: Tony Luck <[email protected]>
> >>> Cc: Fenghua Yu <[email protected]>
> >>> Cc: [email protected]
> >>> Cc: Thomas Gleixner <[email protected]>
> >>> Cc: Ingo Molnar <[email protected]>
> >>> Cc: "H. Peter Anvin" <[email protected]>
> >>> Cc: [email protected]
> >>> ---
> >>> arch/ia64/include/asm/acenv.h | 71 +++++++++++++++++++++++++++++++++++++++
> >>> arch/ia64/include/asm/acpi.h | 50 ---------------------------
> >>> arch/x86/include/asm/acenv.h | 65 +++++++++++++++++++++++++++++++++++
> >>> arch/x86/include/asm/acpi.h | 45 -------------------------
> >>> include/acpi/platform/aclinux.h | 2 +-
> >> Please rename the files first (in a separate patch) and then modify the
> >> renamed ones. That will make changes much easier to follow.
> > This patch doesn't provide a rename.
> > Currently, <asm/acpi.h> includes:
> > 1. arch specific ACPI stuff
> > 2. arch specific ACPICA stuff
> > This patch moves "2" to a separate file <asm/acenv.h>, thus no renaming happens here.
>
> Ah, I overlooked that, sorry.
>
> Which I might not do if the changelog said what the patch was really doing.

Hmm, I'll refine the changelog in the next revision. :-)
Thanks for the helping.

Best regards
-Lv
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-04-29 07:51:15

by Zheng, Lv

[permalink] [raw]
Subject: RE: [PATCH v2 5/5] ACPICA: Remove deprecated _LINUX definitions for ACPICA.

Hi,

> From: Wysocki, Rafael J
> Sent: Tuesday, April 29, 2014 4:27 AM
>
> On 4/28/2014 6:10 AM, Zheng, Lv wrote:
> > Hi, Rafael
> >
> >> From: Rafael J. Wysocki [mailto:[email protected]]
> >> Sent: Monday, April 28, 2014 5:39 AM
> >>
> >> On Wednesday, April 23, 2014 02:54:22 PM Lv Zheng wrote:
> >>> There are _LINUX defined so that when Linux kernel is compiled using broken
> >>> compilers that having not __linux__ defined can still include
> >>> <acpi/platform/aclinux.h> from <acpi/platform/acenv.h>.
> >>>
> >>> This behavior is deprecated as all drivers/acpi/acpica files are compiled
> >>> without including <linux/acpi.h>, thus without _LINUX defined. As there is
> >>> no issues encountered when we compile ACPICA code without _LINUX defined,
> >>> it is OK to remove _LINUX from <linux/acpi.h> now.
> >>>
> >>> Signed-off-by: Lv Zheng <[email protected]>
> >>> ---
> >>> include/linux/acpi.h | 4 ----
> >>> 1 file changed, 4 deletions(-)
> >>>
> >>> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> >>> index 7a8f2cd..9c559f7 100644
> >>> --- a/include/linux/acpi.h
> >>> +++ b/include/linux/acpi.h
> >>> @@ -31,10 +31,6 @@
> >>>
> >>> #ifdef CONFIG_ACPI
> >>>
> >>> -#ifndef _LINUX
> >>> -#define _LINUX
> >>> -#endif
> >>> -
> >>> #include <linux/list.h>
> >>> #include <linux/mod_devicetable.h>
> >> What about <acpi/platform/acenv.h>? Should it still check if _LINUX is defined
> >> after this change?
> > If you mean these lines:
> > #if defined(_LINUX) || defined(__linux__)
> > #include <acpi/platform/aclinux.h>
> > After deleting "_LINUX" from <linux/acpi.h>, acenv.h still can include aclinux.h because of "__linux__".
> > Actually all drivers/acpi/acpica source files are compiled without including <linux/acpi.h>, so "_LINUX" defined in this file is useless to
> Linux.
> > We needn't delete "_LINUX" from acenv.h.
> >
> > "_LINUX" is only used in ACPICA makefiles, Linux never uses it:
> > https://github.com/acpica/acpica/blob/master/generate/unix/Makefile.config
> > ACPICA can be compiled using the following make command:
> > make HOST=_LINUX
> > I think this is the only usage of "_LINUX" for now.
>
> Well, my point was: If we delete the definition of _LINUX, why don't we
> drop the symbol itself from everywhere along with it?
>
> It definitely is not useful to refer to a symbol that's never defined,
> is it?

It sounds like I should clean up acenv.h first than deleting this.
OK, I'll drop this patch from this series.
I might re-do the deletion after cleaning up the acenv.h.

Thanks and best regards
-Lv

>
> Rafael

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?