[PATCH v2 1/7] ACPICA: Debugger: Remove unnecessary status check

2015-11-10 Thread Lv Zheng
From: Colin Ian King <colin.k...@canonical.com>

ACPICA commit f9d5c6c9a25e9f5ac05458bfcd8b381e21bb2ba5

ACPICA BZ 1205. Colin Ian King.

Link: https://bugs.acpica.org/show_bug.cgi?id=1205
Link: https://github.com/acpica/acpica/commit/f9d5c6c9
Signed-off-by: Colin Ian King <colin.k...@canonical.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/dbinput.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
index 0480254..fe93f67 100644
--- a/drivers/acpi/acpica/dbinput.c
+++ b/drivers/acpi/acpica/dbinput.c
@@ -1246,9 +1246,6 @@ acpi_status acpi_db_user_commands(char prompt, union 
acpi_parse_object *op)
 * and wait for the command to complete.
 */
acpi_os_release_mutex(acpi_gbl_db_command_ready);
-   if (ACPI_FAILURE(status)) {
-   return (status);
-   }
 
status =
acpi_os_acquire_mutex(acpi_gbl_db_command_complete,
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 0/7] ACPICA / debugger: Add in-kernel AML debugger support

2015-11-10 Thread Lv Zheng
This patchset enables ACPICA debugger for Linux kernel and implements a
userspace utility to access it.

A. Build the AML debugger
In order to build the kernel support of AML debugger, the following kconfig
items should be enabled:
 CONFIG_ACPI_DEBUG=y
 CONFIG_ACPI_DEBUGGER=y
 CONFIG_DEBUG_FS=y
 CONFIG_ACPI_DEBUGGER_USER=m
The userspace tool can be found at tools/power/acpi/tools/acpidbg. To
build this utility, staying in tools folder and type "make acpi".

B. Load the AML debugger during runtime
In order to use the in-kernel AML debugger, the following command should be
executed using root user:
 # modprobe acpi_dbg
 # mount -t debugfs none /sys/kernel/debug
 # acpidbg

C. Batch mode
In order to support scripts, the userspace utility also supports single
command batch mode:
 # acpidbg -b "help"
 # acpidbg -b "tables"
 # acpidbg -b "find _LID"
 # acpidbg -b "execute \_SB.LID0._LID"
You can find the documentation about the ACPICA debugger commands in:
 https://acpica.org/sites/acpica/files/acpica-reference_17.pdf
 (The latest document can be found at https://acpica.org/documentation)
And refer to the chapter - ACPICA debugger reference to obtain the full
description of the debugger commands. Note that not all commands are
supported by an in-kernel AML debugger.

D. Unload the AML debugger during runtime
After terminating all acpidbg instances, the following command can be
executed to remove the AML debugger from kernel:
 # rmmod acpi_dbg

The following tasks are not completed:
1. .flush() support in the kernel debugger IO driver.
2. multi-commands batch mode.

v2:
1. Fix a help message issue for the userspace acpidbg utility (this is a
   typo fix).
2. Fix a batch mode issue by adding "\n" to the prompt sequence (this was
   lost due to too many rebase cycles).
3. Fix kconfig dependency for an intermediate patch (this is only useful in
   case the latter patches are reverted).
4. Add more accurate runtime debugger stub mechanism and remove old
   ACPI_DEBUGGER_EXEC() stub mechanism.
5. Add x86 acpi_os_readable() support.

Chen Yu (1):
  ACPI / x86: introduce acpi_os_readable() support

Colin Ian King (1):
  ACPICA: Debugger: Remove unnecessary status check

Lv Zheng (5):
  ACPICA: Debugger: Convert some mechanisms to OSPM specific
  ACPICA: Debugger: Fix runtime stub issues of ACPI_DEBUGGER_EXEC using
different stub mechanism
  ACPI / debugger: Add IO interface to access debugger functionalities
  tools/power/acpi: Add userspace AML interface support
  ACPI / debugger: Add module support for ACPI debugger

 arch/x86/Kconfig |1 +
 arch/x86/include/asm/acenv.h |1 +
 arch/x86/kernel/acpi/boot.c  |   14 +
 drivers/acpi/Kconfig |   16 +-
 drivers/acpi/Makefile|1 +
 drivers/acpi/acpi_dbg.c  |  818 ++
 drivers/acpi/acpica/acdebug.h|   36 +-
 drivers/acpi/acpica/acglobal.h   |5 -
 drivers/acpi/acpica/acmacros.h   |   11 -
 drivers/acpi/acpica/dbdisply.c   |   12 +
 drivers/acpi/acpica/dbinput.c|  100 +---
 drivers/acpi/acpica/dbxface.c|   93 ++--
 drivers/acpi/acpica/dscontrol.c  |   10 +-
 drivers/acpi/acpica/dsutils.c|   16 +-
 drivers/acpi/acpica/dswexec.c|   16 +-
 drivers/acpi/acpica/utmutex.c|   17 -
 drivers/acpi/bus.c   |1 +
 drivers/acpi/osl.c   |  262 +-
 include/acpi/acpiosxf.h  |   18 +-
 include/acpi/acpixf.h|   34 ++
 include/acpi/platform/aclinux.h  |3 +-
 include/acpi/platform/aclinuxex.h|8 +-
 include/linux/acpi.h |   71 +++
 tools/power/acpi/Makefile|   16 +-
 tools/power/acpi/tools/acpidbg/Makefile  |   27 +
 tools/power/acpi/tools/acpidbg/acpidbg.c |  438 
 26 files changed, 1833 insertions(+), 212 deletions(-)
 create mode 100644 drivers/acpi/acpi_dbg.c
 create mode 100644 tools/power/acpi/tools/acpidbg/Makefile
 create mode 100644 tools/power/acpi/tools/acpidbg/acpidbg.c

-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 7/7] ACPI / debugger: Add module support for ACPI debugger

2015-11-10 Thread Lv Zheng
This patch converts AML debugger into a loadable module.

Note that, it implements driver unloading at the level dependent on the
module reference count. Which means if ACPI debugger is being used by a
userspace program, "rmmod acpi_dbg" should result in failure.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/Kconfig |   12 ++-
 drivers/acpi/Makefile|2 +-
 drivers/acpi/acpi_dbg.c  |   80 --
 drivers/acpi/bus.c   |3 +-
 drivers/acpi/osl.c   |  207 --
 include/linux/acpi.h |   71 
 include/linux/acpi_dbg.h |   52 
 7 files changed, 338 insertions(+), 89 deletions(-)
 delete mode 100644 include/linux/acpi_dbg.h

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index e67b1b5..73b45f9 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -63,13 +63,23 @@ config ACPI_MEMORY_ACCESS_CHECK_SUPPORT
 config ACPI_DEBUGGER
bool "In-kernel debugger"
select ACPI_DEBUG
-   depends on DEBUG_FS
help
  Enable in-kernel debugging facilities: statistics, internal
  object dump, single step control method execution.
  This is still under development, currently enabling this only
  results in the compilation of the ACPICA debugger files.
 
+if ACPI_DEBUGGER
+
+config ACPI_DEBUGGER_USER
+   tristate "Userspace debugger accessiblity"
+   depends on DEBUG_FS
+   help
+ Export /sys/kernel/debug/acpi/acpidbg for userspace utilities
+ to access the debugger functionalities.
+
+endif
+
 config ACPI_SLEEP
bool
depends on SUSPEND || HIBERNATION
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 102b5e6..c6f236f 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -50,7 +50,6 @@ acpi-y+= sysfs.o
 acpi-y += property.o
 acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
 acpi-$(CONFIG_DEBUG_FS)+= debugfs.o
-acpi-$(CONFIG_ACPI_DEBUGGER)   += acpi_dbg.o
 acpi-$(CONFIG_ACPI_NUMA)   += numa.o
 acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
 acpi-y += acpi_lpat.o
@@ -80,6 +79,7 @@ obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o
 obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
 obj-$(CONFIG_ACPI_BGRT)+= bgrt.o
 obj-$(CONFIG_ACPI_CPPC_LIB)+= cppc_acpi.o
+obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o
 
 # processor has its own "processor." module_param namespace
 processor-y:= processor_driver.o
diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index 7be0851..8fcf752 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -21,7 +21,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include "internal.h"
 
 #define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
@@ -307,7 +307,7 @@ static int acpi_aml_readb_kern(void)
  * the debugger output and store the output into the debugger interface
  * buffer. Return the size of stored logs or errno.
  */
-ssize_t acpi_aml_write_log(const char *msg)
+static ssize_t acpi_aml_write_log(const char *msg)
 {
int ret = 0;
int count = 0, size = 0;
@@ -350,7 +350,6 @@ again:
}
return size > 0 ? size : ret;
 }
-EXPORT_SYMBOL(acpi_aml_write_log);
 
 /*
  * acpi_aml_read_cmd() - Capture debugger input
@@ -361,7 +360,7 @@ EXPORT_SYMBOL(acpi_aml_write_log);
  * the debugger input commands and store the input commands into the
  * debugger interface buffer. Return the size of stored commands or errno.
  */
-ssize_t acpi_aml_read_cmd(char *msg, size_t count)
+static ssize_t acpi_aml_read_cmd(char *msg, size_t count)
 {
int ret = 0;
int size = 0;
@@ -403,7 +402,6 @@ again:
}
return size > 0 ? size : ret;
 }
-EXPORT_SYMBOL(acpi_aml_read_cmd);
 
 static int acpi_aml_thread(void *unsed)
 {
@@ -440,7 +438,7 @@ static int acpi_aml_thread(void *unsed)
  * This function should be used to implement acpi_os_execute() which is
  * used by the ACPICA debugger to create the debugger thread.
  */
-int acpi_aml_create_thread(acpi_osd_exec_callback function, void *context)
+static int acpi_aml_create_thread(acpi_osd_exec_callback function, void 
*context)
 {
struct task_struct *t;
 
@@ -462,30 +460,27 @@ int acpi_aml_create_thread(acpi_osd_exec_callback 
function, void *context)
mutex_unlock(_aml_io.lock);
return 0;
 }
-EXPORT_SYMBOL(acpi_aml_create_thread);
 
-int acpi_aml_wait_command_ready(void)
+static int acpi_aml_wait_command_ready(bool single_step,
+  char *buffer, size_t length)
 {
acpi_status status;
 
-   if (!acpi_gbl_method_executing)
-   acpi_os_printf("\n%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
-   else
+   if (single_step)

[PATCH v2 3/7] ACPICA: Debugger: Fix runtime stub issues of ACPI_DEBUGGER_EXEC using different stub mechanism

2015-11-10 Thread Lv Zheng
The ACPI_DEBUGGER_EXEC is a problem now when the debugger code is compiled
but runtime disabled. They actually will get executed in this situation.
Although such executions are harmless if we can correctly make
acpi_db_single_step() a runtime stub, users may still do not want to see the
debugger print messages logged into OSPMs' kernel logs when a debugger
driver is not loaded to enable the debugger during runtime.

This patch fixes this issue by introducing new stub mechanism instead of
ACPI_DEBUGGER_EXEC. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acdebug.h   |   34 --
 drivers/acpi/acpica/acmacros.h  |   11 ---
 drivers/acpi/acpica/dbdisply.c  |   12 
 drivers/acpi/acpica/dbxface.c   |   30 ++
 drivers/acpi/acpica/dscontrol.c |   10 ++
 drivers/acpi/acpica/dsutils.c   |   16 
 drivers/acpi/acpica/dswexec.c   |   16 +++-
 include/acpi/acpixf.h   |   23 +++
 8 files changed, 106 insertions(+), 46 deletions(-)

diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 86474d8..dcaa15d 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -80,9 +80,15 @@ struct acpi_db_execute_walk {
 /*
  * dbxface - external debugger interfaces
  */
-acpi_status
-acpi_db_single_step(struct acpi_walk_state *walk_state,
-   union acpi_parse_object *op, u32 op_type);
+ACPI_DBR_DEPENDENT_RETURN_OK(acpi_status
+acpi_db_single_step(struct acpi_walk_state
+*walk_state,
+union acpi_parse_object *op,
+u32 op_type))
+ ACPI_DBR_DEPENDENT_RETURN_VOID(void
+   acpi_db_signal_break_point(struct
+  acpi_walk_state
+  *walk_state))
 
 /*
  * dbcmds - debug commands and output routines
@@ -182,11 +188,15 @@ void acpi_db_display_method_info(union acpi_parse_object 
*op);
 
 void acpi_db_decode_and_display_object(char *target, char *output_type);
 
-void
-acpi_db_display_result_object(union acpi_operand_object *obj_desc,
- struct acpi_walk_state *walk_state);
+ACPI_DBR_DEPENDENT_RETURN_VOID(void
+  acpi_db_display_result_object(union
+acpi_operand_object
+*obj_desc,
+struct
+acpi_walk_state
+*walk_state))
 
-acpi_status acpi_db_display_all_methods(char *display_count_arg);
+ acpi_status acpi_db_display_all_methods(char *display_count_arg);
 
 void acpi_db_display_arguments(void);
 
@@ -198,9 +208,13 @@ void acpi_db_display_calling_tree(void);
 
 void acpi_db_display_object_type(char *object_arg);
 
-void
-acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
-   struct acpi_walk_state *walk_state);
+ACPI_DBR_DEPENDENT_RETURN_VOID(void
+  acpi_db_display_argument_object(union
+  
acpi_operand_object
+  *obj_desc,
+  struct
+  acpi_walk_state
+  *walk_state))
 
 /*
  * dbexec - debugger control method execution
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index e85366c..bad5bca 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -401,17 +401,6 @@
 #endif
 
 /*
- * Some code only gets executed when the debugger is built in.
- * Note that this is entirely independent of whether the
- * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not.
- */
-#ifdef ACPI_DEBUGGER
-#define ACPI_DEBUGGER_EXEC(a)   a
-#else
-#define ACPI_DEBUGGER_EXEC(a)
-#endif
-
-/*
  * Macros used for ACPICA utilities only
  */
 
diff --git a/drivers/acpi/acpica/dbdisply.c b/drivers/acpi/acpica/dbdisply.c
index 672977e..c42ce8a 100644
--- a/drivers/acpi/acpica/dbdisply.c
+++ b/drivers/acpi/acpica/dbdisply.c
@@ -679,6 +679,12 @@ acpi_db_display_result_object(union acpi_operand_object 
*obj_desc,
  struct acpi_walk_state *walk_state)
 {
 
+#ifndef ACPI_APPLICATION
+   if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
+   return;
+   }
+#endif
+
/* Only display if 

[PATCH v2 4/7] ACPI / debugger: Add IO interface to access debugger functionalities

2015-11-10 Thread Lv Zheng
This patch adds /sys/kernel/debug/acpi/acpidbg, which can be used by
userspace programs to access ACPICA debugger functionalities.

Known issue:
1. IO flush support
   acpi_os_notify_command_complete() and acpi_os_wait_command_ready() can
   be used by acpi_dbg module to implement .flush() filesystem operation.
   While this patch doesn't go that far. It then becomes userspace tool's
   duty now to flush old commands before executing new batch mode commands.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/Kconfig  |3 +-
 drivers/acpi/Makefile |1 +
 drivers/acpi/acpi_dbg.c   |  792 +
 drivers/acpi/bus.c|2 +
 drivers/acpi/osl.c|   55 ++-
 include/acpi/platform/aclinux.h   |2 -
 include/acpi/platform/aclinuxex.h |   10 -
 include/linux/acpi_dbg.h  |   52 +++
 8 files changed, 900 insertions(+), 17 deletions(-)
 create mode 100644 drivers/acpi/acpi_dbg.c
 create mode 100644 include/linux/acpi_dbg.h

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 25dbb76..4de3517 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -58,8 +58,9 @@ config ACPI_CCA_REQUIRED
bool
 
 config ACPI_DEBUGGER
-   bool "In-kernel debugger (EXPERIMENTAL)"
+   bool "In-kernel debugger"
select ACPI_DEBUG
+   depends on DEBUG_FS
help
  Enable in-kernel debugging facilities: statistics, internal
  object dump, single step control method execution.
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 675eaf3..102b5e6 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -50,6 +50,7 @@ acpi-y+= sysfs.o
 acpi-y += property.o
 acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
 acpi-$(CONFIG_DEBUG_FS)+= debugfs.o
+acpi-$(CONFIG_ACPI_DEBUGGER)   += acpi_dbg.o
 acpi-$(CONFIG_ACPI_NUMA)   += numa.o
 acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
 acpi-y += acpi_lpat.o
diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
new file mode 100644
index 000..7be0851
--- /dev/null
+++ b/drivers/acpi/acpi_dbg.c
@@ -0,0 +1,792 @@
+/*
+ * ACPI AML interfacing support
+ *
+ * Copyright (C) 2015, Intel Corporation
+ * Authors: Lv Zheng <lv.zh...@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/* #define DEBUG */
+#define pr_fmt(fmt) "ACPI : AML: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "internal.h"
+
+#define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
+#define ACPI_AML_BUF_SIZE  PAGE_SIZE
+
+#define circ_count(circ) \
+   (CIRC_CNT((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+#define circ_count_to_end(circ) \
+   (CIRC_CNT_TO_END((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+#define circ_space(circ) \
+   (CIRC_SPACE((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+#define circ_space_to_end(circ) \
+   (CIRC_SPACE_TO_END((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+
+#define ACPI_AML_OPENED0x0001
+#define ACPI_AML_CLOSED0x0002
+#define ACPI_AML_IN_USER   0x0004 /* user space is writing cmd */
+#define ACPI_AML_IN_KERN   0x0008 /* kernel space is reading cmd */
+#define ACPI_AML_OUT_USER  0x0010 /* user space is reading log */
+#define ACPI_AML_OUT_KERN  0x0020 /* kernel space is writing log */
+#define ACPI_AML_USER  (ACPI_AML_IN_USER | ACPI_AML_OUT_USER)
+#define ACPI_AML_KERN  (ACPI_AML_IN_KERN | ACPI_AML_OUT_KERN)
+#define ACPI_AML_BUSY  (ACPI_AML_USER | ACPI_AML_KERN)
+#define ACPI_AML_OPEN  (ACPI_AML_OPENED | ACPI_AML_CLOSED)
+
+struct acpi_aml_io {
+   wait_queue_head_t wait;
+   unsigned long flags;
+   unsigned long users;
+   struct mutex lock;
+   struct task_struct *thread;
+   char out_buf[ACPI_AML_BUF_SIZE] __aligned(ACPI_AML_BUF_ALIGN);
+   struct circ_buf out_crc;
+   char in_buf[ACPI_AML_BUF_SIZE] __aligned(ACPI_AML_BUF_ALIGN);
+   struct circ_buf in_crc;
+   acpi_osd_exec_callback function;
+   void *context;
+   unsigned long usages;
+};
+
+static struct acpi_aml_io acpi_aml_io;
+static bool acpi_aml_initialized;
+static struct file *acpi_aml_active_reader;
+static struct dentry *acpi_aml_dentry;
+
+static inline bool __acpi_aml_running(void)
+{
+   return acpi_aml_io.thread ? true : false;
+}
+
+static inline bool __acpi_aml_access_ok(unsigned long flag)
+{
+   /*
+* The debugger interface is in opened state (OPENED && !CLOSED),
+* then it is allowed to access the debugger b

[PATCH v2 2/7] ACPICA: Debugger: Convert some mechanisms to OSPM specific

2015-11-10 Thread Lv Zheng
The following mechanisms are OSPM specific:
1. Redirect output destination to console: no file redirection will be
   needed by an in-kernel debugger, there is even no file can be accessed
   when the debugger is running in the kernel mode.
2. Output command prompts: programs other than acpiexec can have different
   prompt characters and the prompt characters may be implemented as a
   special character sequence to form a char device IO protocol.
3. Command ready/complete handshake: OSPM debugger may wait more conditions
   to implement OSPM specific semantics (for example, FIFO full/empty
   conditions for O_NONBLOCK or IO open/close conditions).
Leaving such OSPM specific stuffs in the ACPICA debugger core blocks
Linux debugger IO driver implementation.

Several new OSL APIs are provided by this patch:
1. acpi_os_initialize_command_signals: initialize command handshake mechanism
   or any other OSPM specific stuffs.
2. acpi_os_terminate_command_signals: reversal of
   acpi_os_initialize_command_signals.
3. acpi_os_wait_command_ready: putting debugger task into wait state when a
   command is not ready. OSPMs can terminate command loop by returning
   AE_CTRL_TERMINATE from this API. Normally, wait_event() or
   wait_for_multiple_object() may be used to implement this API.
4. acpi_os_notify_command_complete: putting user task into running state when a
   command has been completed. OSPMs can terminate command loop by
   returning AE_CTRL_TERMINATE from this API. Normally, wake_up() or
   set_event() may be used to implement this API.
This patch also converts current command signaling implementation into a
generic debugger layer (osgendbg.c) to be used by the existing OSPMs or
acpiexec, in return, Linux can have chance to implement its own command
handshake mechanism. This patch also implements acpiexec batch mode in a
multi-threading mode comaptible style as a demo (this can be confirmed by
configuring acpiexec into DEBUGGER_MULTI_THREADED mode where the batch mode
is still working). Lv Zheng.

Note that the OSPM specific command handshake mechanism is required by
Linux kernel because:
1. Linux kernel trends to use wait queue to synchronize two threads, using
   mutexes to achieve that will cause false "dead lock" warnings.
2. The command handshake mechanism implemented by ACPICA is implemented in
   this way because of a design issue in debugger IO streaming. Debugger IO
   outputs are simply cached using a giant buffer, this should be tuned by
   Linux in the future.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acdebug.h |2 +-
 drivers/acpi/acpica/acglobal.h|5 --
 drivers/acpi/acpica/dbinput.c |   97 -
 drivers/acpi/acpica/dbxface.c |   63 +++-
 drivers/acpi/acpica/utmutex.c |   17 ---
 include/acpi/acpiosxf.h   |   18 ++-
 include/acpi/acpixf.h |   11 +
 include/acpi/platform/aclinux.h   |4 ++
 include/acpi/platform/aclinuxex.h |   19 
 9 files changed, 89 insertions(+), 147 deletions(-)

diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index c928ba4..86474d8 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -257,7 +257,7 @@ acpi_db_command_dispatch(char *input_buffer,
 
 void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context);
 
-acpi_status acpi_db_user_commands(char prompt, union acpi_parse_object *op);
+acpi_status acpi_db_user_commands(void);
 
 char *acpi_db_get_next_token(char *string,
 char **next, acpi_object_type * return_type);
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index faa9760..3977134 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -326,7 +326,6 @@ ACPI_GLOBAL(struct acpi_external_file *, 
acpi_gbl_external_file_list);
 #ifdef ACPI_DEBUGGER
 
 ACPI_INIT_GLOBAL(u8, acpi_gbl_abort_method, FALSE);
-ACPI_INIT_GLOBAL(u8, acpi_gbl_method_executing, FALSE);
 ACPI_INIT_GLOBAL(acpi_thread_id, acpi_gbl_db_thread_id, 
ACPI_INVALID_THREAD_ID);
 
 ACPI_GLOBAL(u8, acpi_gbl_db_opt_no_ini_methods);
@@ -345,7 +344,6 @@ ACPI_GLOBAL(acpi_object_type, 
acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]);
 
 /* These buffers should all be the same size */
 
-ACPI_GLOBAL(char, acpi_gbl_db_line_buf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL(char, acpi_gbl_db_parsed_buf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL(char, acpi_gbl_db_scope_buf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL(char, acpi_gbl_db_debug_filename[ACPI_DB_LINE_BUFFER_SIZE]);
@@ -360,9 +358,6 @@ ACPI_GLOBAL(u16, acpi_gbl_node_type_count_misc);
 ACPI_GLOBAL(u32, acpi_gbl_num_nodes);
 ACPI_GLOBAL(u32, acpi_gbl_num_objects);
 
-ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_ready);
-ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_complete);
-
 #endif 

[RFC PATCH v2 4/5] tools/power/acpi: Add userspace AML interface support

2015-11-05 Thread Lv Zheng
This patch adds a userspace tool to access Linux kernel AML debugger
interface.

Tow modes are supported by this tool:
1. Interactive: Users are able to launch a debugging shell to talk with
   in-kernel AML debugger.
   Note that it's user duty to ensure kernel runtime integrity by using
   this debugging tool:
   A. Some control methods evaluated by the users may result in kernel
  panics if those control methods shouldn't be evaluated by the OSPMs
  according to the current BIOS/OS configurations.
   B. Currently if a single stepping evaluation couldn't run to an end,
  then the synchronization primitives acquired by the evaluation may
  block normal OSPM control method evaluations.
2. Batch: Users are able to execute debugger commands in a script.
   Note that in addition to the above duties, it's user duty to ensure
   script runtime integrity by using this debugging tool in this mode:
   C. Currently only those commands that are not used for single stepping
  are suitable to be used in this mode.
   D. If the execution of the command may cause a failure that could result
  in an endless kernel execution, the execution of the script may also
  get blocked.
To exit the utility, currently "exit/quit" commands are recommended, but
ctrl-C" can also be used.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 tools/power/acpi/Makefile|   16 +-
 tools/power/acpi/tools/acpidbg/Makefile  |   27 ++
 tools/power/acpi/tools/acpidbg/acpidbg.c |  438 ++
 3 files changed, 473 insertions(+), 8 deletions(-)
 create mode 100644 tools/power/acpi/tools/acpidbg/Makefile
 create mode 100644 tools/power/acpi/tools/acpidbg/acpidbg.c

diff --git a/tools/power/acpi/Makefile b/tools/power/acpi/Makefile
index e882c83..a8bf908 100644
--- a/tools/power/acpi/Makefile
+++ b/tools/power/acpi/Makefile
@@ -10,18 +10,18 @@
 
 include ../../scripts/Makefile.include
 
-all: acpidump ec
-clean: acpidump_clean ec_clean
-install: acpidump_install ec_install
-uninstall: acpidump_uninstall ec_uninstall
+all: acpidbg acpidump ec
+clean: acpidbg_clean acpidump_clean ec_clean
+install: acpidbg_install acpidump_install ec_install
+uninstall: acpidbg_uninstall acpidump_uninstall ec_uninstall
 
-acpidump ec: FORCE
+acpidbg acpidump ec: FORCE
$(call descend,tools/$@,all)
-acpidump_clean ec_clean:
+acpidbg_clean acpidump_clean ec_clean:
$(call descend,tools/$(@:_clean=),clean)
-acpidump_install ec_install:
+acpidbg_install acpidump_install ec_install:
$(call descend,tools/$(@:_install=),install)
-acpidump_uninstall ec_uninstall:
+acpidbg_uninstall acpidump_uninstall ec_uninstall:
$(call descend,tools/$(@:_uninstall=),uninstall)
 
 .PHONY: FORCE
diff --git a/tools/power/acpi/tools/acpidbg/Makefile 
b/tools/power/acpi/tools/acpidbg/Makefile
new file mode 100644
index 000..352df4b
--- /dev/null
+++ b/tools/power/acpi/tools/acpidbg/Makefile
@@ -0,0 +1,27 @@
+# tools/power/acpi/tools/acpidbg/Makefile - ACPI tool Makefile
+#
+# Copyright (c) 2015, Intel Corporation
+#   Author: Lv Zheng <lv.zh...@intel.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; version 2
+# of the License.
+
+include ../../Makefile.config
+
+TOOL = acpidbg
+vpath %.c \
+   ../../../../../drivers/acpi/acpica\
+   ../../common\
+   ../../os_specific/service_layers\
+   .
+CFLAGS += -DACPI_APPLICATION -DACPI_SINGLE_THREAD -DACPI_DEBUGGER\
+   -I.\
+   -I../../../../../drivers/acpi/acpica\
+   -I../../../../../include
+LDFLAGS += -lpthread
+TOOL_OBJS = \
+   acpidbg.o
+
+include ../../Makefile.rules
diff --git a/tools/power/acpi/tools/acpidbg/acpidbg.c 
b/tools/power/acpi/tools/acpidbg/acpidbg.c
new file mode 100644
index 000..e4e8316
--- /dev/null
+++ b/tools/power/acpi/tools/acpidbg/acpidbg.c
@@ -0,0 +1,438 @@
+/*
+ * ACPI AML interfacing userspace utility
+ *
+ * Copyright (C) 2015, Intel Corporation
+ * Authors: Lv Zheng <lv.zh...@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+
+/* Headers not included by include/acpi/platform/aclinux.h */
+#include 
+#include 
+#include 
+#include 
+
+#define ACPI_AML_FILE  "/sys/kernel/debug/acpi/acpidbg"
+#define ACPI_AML_SEC_TICK  1
+#define ACPI_AML_USEC_PEEK 200
+#define ACPI_AML_BUF_SIZE  4096
+
+#define ACPI_AML_BATCH_WRITE_CMD   0x00 /* Write command to kernel */
+#define ACPI_AML_BATCH_READ_LOG0x01 /* Read log from kernel */
+#define ACPI_AML_BATCH_WRITE_LOG   0x02 /* Write log to console */
+
+#define ACPI_AML_LOG_START 0x00
+#define ACPI_AML_PROMPT_START  0x01
+#define A

[RFC PATCH v2 2/5] ACPICA: Debugger: Convert some mechanisms to OSPM specific

2015-11-05 Thread Lv Zheng
The following mechanisms are OSPM specific:
1. Redirect output destination to console: no file redirection will be
   needed by an in-kernel debugger, there is even no file can be accessed
   when the debugger is running in the kernel mode.
2. Output command prompts: programs other than acpiexec can have different
   prompt characters and the prompt characters may be implemented as a
   special character sequence to form a char device IO protocol.
3. Command ready/complete handshake: OSPM debugger may wait more conditions
   to implement OSPM specific semantics (for example, FIFO full/empty
   conditions for O_NONBLOCK or IO open/close conditions).
Leaving such OSPM specific stuffs in the ACPICA debugger core blocks
Linux debugger IO driver implementation.

Several new OSL APIs are provided by this patch:
1. acpi_os_initialize_command_signals: initialize command handshake mechanism
   or any other OSPM specific stuffs.
2. acpi_os_terminate_command_signals: reversal of
   acpi_os_initialize_command_signals.
3. acpi_os_wait_command_ready: putting debugger task into wait state when a
   command is not ready. OSPMs can terminate command loop by returning
   AE_CTRL_TERMINATE from this API. Normally, wait_event() or
   wait_for_multiple_object() may be used to implement this API.
4. acpi_os_notify_command_complete: putting user task into running state when a
   command has been completed. OSPMs can terminate command loop by
   returning AE_CTRL_TERMINATE from this API. Normally, wake_up() or
   set_event() may be used to implement this API.
This patch also converts current command signaling implementation into a
generic debugger layer (osgendbg.c) to be used by the existing OSPMs or
acpiexec, in return, Linux can have chance to implement its own command
handshake mechanism. This patch also implements acpiexec batch mode in a
multi-threading mode comaptible style as a demo (this can be confirmed by
configuring acpiexec into DEBUGGER_MULTI_THREADED mode where the batch mode
is still working). Lv Zheng.

Note that the OSPM specific command handshake mechanism is required by
Linux kernel because:
1. Linux kernel trends to use wait queue to synchronize two threads, using
   mutexes to achieve that will cause false "dead lock" warnings.
2. The command handshake mechanism implemented by ACPICA is implemented in
   this way because of a design issue in debugger IO streaming. Debugger IO
   outputs are simply cached using a giant buffer, this should be tuned by
   Linux in the future.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acdebug.h |2 +-
 drivers/acpi/acpica/acglobal.h|5 --
 drivers/acpi/acpica/dbinput.c |   97 -
 drivers/acpi/acpica/dbxface.c |   63 +++-
 drivers/acpi/acpica/utmutex.c |   17 ---
 include/acpi/acpiosxf.h   |   18 ++-
 include/acpi/acpixf.h |   11 +
 include/acpi/platform/aclinux.h   |4 ++
 include/acpi/platform/aclinuxex.h |   19 
 9 files changed, 89 insertions(+), 147 deletions(-)

diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index c928ba4..86474d8 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -257,7 +257,7 @@ acpi_db_command_dispatch(char *input_buffer,
 
 void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context);
 
-acpi_status acpi_db_user_commands(char prompt, union acpi_parse_object *op);
+acpi_status acpi_db_user_commands(void);
 
 char *acpi_db_get_next_token(char *string,
 char **next, acpi_object_type * return_type);
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index faa9760..3977134 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -326,7 +326,6 @@ ACPI_GLOBAL(struct acpi_external_file *, 
acpi_gbl_external_file_list);
 #ifdef ACPI_DEBUGGER
 
 ACPI_INIT_GLOBAL(u8, acpi_gbl_abort_method, FALSE);
-ACPI_INIT_GLOBAL(u8, acpi_gbl_method_executing, FALSE);
 ACPI_INIT_GLOBAL(acpi_thread_id, acpi_gbl_db_thread_id, 
ACPI_INVALID_THREAD_ID);
 
 ACPI_GLOBAL(u8, acpi_gbl_db_opt_no_ini_methods);
@@ -345,7 +344,6 @@ ACPI_GLOBAL(acpi_object_type, 
acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]);
 
 /* These buffers should all be the same size */
 
-ACPI_GLOBAL(char, acpi_gbl_db_line_buf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL(char, acpi_gbl_db_parsed_buf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL(char, acpi_gbl_db_scope_buf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL(char, acpi_gbl_db_debug_filename[ACPI_DB_LINE_BUFFER_SIZE]);
@@ -360,9 +358,6 @@ ACPI_GLOBAL(u16, acpi_gbl_node_type_count_misc);
 ACPI_GLOBAL(u32, acpi_gbl_num_nodes);
 ACPI_GLOBAL(u32, acpi_gbl_num_objects);
 
-ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_ready);
-ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_complete);
-
 #endif 

[RFC PATCH v2 3/5] ACPI / debugger: Add IO interface to access debugger functionalities

2015-11-05 Thread Lv Zheng
This patch adds /sys/kernel/debug/acpi/acpidbg, which can be used by
userspace programs to access ACPICA debugger functionalities.

Known issue:
1. IO flush support
   acpi_os_notify_command_complete() and acpi_os_wait_command_ready() can
   be used by acpi_dbg module to implement .flush() filesystem operation.
   While this patch doesn't go that far. It then becomes userspace tool's
   duty now to flush old commands before executing new batch mode commands.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/Kconfig  |2 +-
 drivers/acpi/Makefile |1 +
 drivers/acpi/acpi_dbg.c   |  792 +
 drivers/acpi/bus.c|2 +
 drivers/acpi/osl.c|   55 ++-
 include/acpi/platform/aclinux.h   |2 -
 include/acpi/platform/aclinuxex.h |   10 -
 include/linux/acpi_dbg.h  |   52 +++
 8 files changed, 899 insertions(+), 17 deletions(-)
 create mode 100644 drivers/acpi/acpi_dbg.c
 create mode 100644 include/linux/acpi_dbg.h

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 25dbb76..2b89fd7 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -58,7 +58,7 @@ config ACPI_CCA_REQUIRED
bool
 
 config ACPI_DEBUGGER
-   bool "In-kernel debugger (EXPERIMENTAL)"
+   bool "In-kernel debugger"
select ACPI_DEBUG
help
  Enable in-kernel debugging facilities: statistics, internal
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 675eaf3..102b5e6 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -50,6 +50,7 @@ acpi-y+= sysfs.o
 acpi-y += property.o
 acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
 acpi-$(CONFIG_DEBUG_FS)+= debugfs.o
+acpi-$(CONFIG_ACPI_DEBUGGER)   += acpi_dbg.o
 acpi-$(CONFIG_ACPI_NUMA)   += numa.o
 acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
 acpi-y += acpi_lpat.o
diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
new file mode 100644
index 000..853ea94
--- /dev/null
+++ b/drivers/acpi/acpi_dbg.c
@@ -0,0 +1,792 @@
+/*
+ * ACPI AML interfacing support
+ *
+ * Copyright (C) 2015, Intel Corporation
+ * Authors: Lv Zheng <lv.zh...@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/* #define DEBUG */
+#define pr_fmt(fmt) "ACPI : AML: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "internal.h"
+
+#define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
+#define ACPI_AML_BUF_SIZE  PAGE_SIZE
+
+#define circ_count(circ) \
+   (CIRC_CNT((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+#define circ_count_to_end(circ) \
+   (CIRC_CNT_TO_END((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+#define circ_space(circ) \
+   (CIRC_SPACE((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+#define circ_space_to_end(circ) \
+   (CIRC_SPACE_TO_END((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+
+#define ACPI_AML_OPENED0x0001
+#define ACPI_AML_CLOSED0x0002
+#define ACPI_AML_IN_USER   0x0004 /* user space is writing cmd */
+#define ACPI_AML_IN_KERN   0x0008 /* kernel space is reading cmd */
+#define ACPI_AML_OUT_USER  0x0010 /* user space is reading log */
+#define ACPI_AML_OUT_KERN  0x0020 /* kernel space is writing log */
+#define ACPI_AML_USER  (ACPI_AML_IN_USER | ACPI_AML_OUT_USER)
+#define ACPI_AML_KERN  (ACPI_AML_IN_KERN | ACPI_AML_OUT_KERN)
+#define ACPI_AML_BUSY  (ACPI_AML_USER | ACPI_AML_KERN)
+#define ACPI_AML_OPEN  (ACPI_AML_OPENED | ACPI_AML_CLOSED)
+
+struct acpi_aml_io {
+   wait_queue_head_t wait;
+   unsigned long flags;
+   unsigned long users;
+   struct mutex lock;
+   struct task_struct *thread;
+   char out_buf[ACPI_AML_BUF_SIZE] __aligned(ACPI_AML_BUF_ALIGN);
+   struct circ_buf out_crc;
+   char in_buf[ACPI_AML_BUF_SIZE] __aligned(ACPI_AML_BUF_ALIGN);
+   struct circ_buf in_crc;
+   acpi_osd_exec_callback function;
+   void *context;
+   unsigned long usages;
+};
+
+static struct acpi_aml_io acpi_aml_io;
+static bool acpi_aml_initialized;
+static struct file *acpi_aml_active_reader;
+static struct dentry *acpi_aml_dentry;
+
+static inline bool __acpi_aml_running(void)
+{
+   return acpi_aml_io.thread ? true : false;
+}
+
+static inline bool __acpi_aml_access_ok(unsigned long flag)
+{
+   /*
+* The debugger interface is in opened state (OPENED && !CLOSED),
+* then it is allowed to access the debugger buffers from either
+* user space or the kernel space.
+* In addition, for the kernel

[RFC PATCH v2 1/5] ACPICA: Debugger: Remove unnecessary status check

2015-11-05 Thread Lv Zheng
From: Colin Ian King <colin.k...@canonical.com>

ACPICA commit f9d5c6c9a25e9f5ac05458bfcd8b381e21bb2ba5

ACPICA BZ 1205. Colin Ian King.

Link: https://bugs.acpica.org/show_bug.cgi?id=1205
Link: https://github.com/acpica/acpica/commit/f9d5c6c9
Signed-off-by: Colin Ian King <colin.k...@canonical.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/dbinput.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
index 0480254..fe93f67 100644
--- a/drivers/acpi/acpica/dbinput.c
+++ b/drivers/acpi/acpica/dbinput.c
@@ -1246,9 +1246,6 @@ acpi_status acpi_db_user_commands(char prompt, union 
acpi_parse_object *op)
 * and wait for the command to complete.
 */
acpi_os_release_mutex(acpi_gbl_db_command_ready);
-   if (ACPI_FAILURE(status)) {
-   return (status);
-   }
 
status =
acpi_os_acquire_mutex(acpi_gbl_db_command_complete,
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2 0/5] ACPICA / debugger: Add in-kernel AML debugger support

2015-11-05 Thread Lv Zheng
This patchset enables ACPICA debugger for Linux kernel and implements a
userspace utility to access it.

A. Build the AML debugger
In order to build the kernel support of AML debugger, the following kconfig
items should be enabled:
 CONFIG_ACPI_DEBUG=y
 CONFIG_ACPI_DEBUGGER=y
 CONFIG_DEBUG_FS=y
 CONFIG_ACPI_DEBUGGER_USER=m
The userspace tool can be found at tools/power/acpi/tools/acpidbg. To
build this utility, staying in tools folder and type "make acpi".

B. Load the AML debugger during runtime
In order to use the in-kernel AML debugger, the following command should be
executed using root user:
 # modprobe acpi_dbg
 # mount -t debugfs none /sys/kernel/debug
 # acpidbg

C. Batch mode
In order to support scripts, the userspace utility also supports single
command batch mode:
 # acpidbg -b "help"
 # acpidbg -b "tables"
 # acpidbg -b "find _LID"
 # acpidbg -b "execute \_SB.LID0._LID"
You can find the documentation about the ACPICA debugger commands in:
 https://acpica.org/sites/acpica/files/acpica-reference_17.pdf
 (The latest document can be found at https://acpica.org/documentation)
And refer to the chapter - ACPICA debugger reference to obtain the full
description of the debugger commands. Note that not all commands are
supported by an in-kernel AML debugger.

D. Unload the AML debugger during runtime
After terminating all acpidbg instances, the following command can be
executed to remove the AML debugger from kernel:
 # rmmod acpi_dbg

The following tasks are not completed:
1. .flush() support in the kernel debugger IO driver.
2. multi-commands batch mode.
3. upstream the userspace acpidbg to the ACPICA upstream.

Colin Ian King (1):
  ACPICA: Debugger: Remove unnecessary status check

Lv Zheng (4):
  ACPICA: Debugger: Convert some mechanisms to OSPM specific
  ACPI / debugger: Add IO interface to access debugger functionalities
  tools/power/acpi: Add userspace AML interface support
  ACPI / debugger: Add module support for ACPI debugger

 drivers/acpi/Kconfig |   13 +-
 drivers/acpi/Makefile|1 +
 drivers/acpi/acpi_dbg.c  |  818 ++
 drivers/acpi/acpica/acdebug.h|2 +-
 drivers/acpi/acpica/acglobal.h   |5 -
 drivers/acpi/acpica/dbinput.c|  100 +---
 drivers/acpi/acpica/dbxface.c|   63 +--
 drivers/acpi/acpica/utmutex.c|   17 -
 drivers/acpi/bus.c   |1 +
 drivers/acpi/osl.c   |  250 -
 include/acpi/acpiosxf.h  |   18 +-
 include/acpi/acpixf.h|   11 +
 include/acpi/platform/aclinux.h  |2 +
 include/acpi/platform/aclinuxex.h|9 +
 include/linux/acpi.h |   71 +++
 tools/power/acpi/Makefile|   16 +-
 tools/power/acpi/tools/acpidbg/Makefile  |   27 +
 tools/power/acpi/tools/acpidbg/acpidbg.c |  438 
 18 files changed, 1699 insertions(+), 163 deletions(-)
 create mode 100644 drivers/acpi/acpi_dbg.c
 create mode 100644 tools/power/acpi/tools/acpidbg/Makefile
 create mode 100644 tools/power/acpi/tools/acpidbg/acpidbg.c

-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2 5/5] ACPI / debugger: Add module support for ACPI debugger

2015-11-05 Thread Lv Zheng
This patch converts AML debugger into a loadable module.

Note that, it implements driver unloading at the level dependent on the
module reference count. Which means if ACPI debugger is being used by a
userspace program, "rmmod acpi_dbg" should result in failure.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/Kconfig |   11 +++
 drivers/acpi/Makefile|2 +-
 drivers/acpi/acpi_dbg.c  |   80 --
 drivers/acpi/bus.c   |3 +-
 drivers/acpi/osl.c   |  207 --
 include/linux/acpi.h |   71 
 include/linux/acpi_dbg.h |   52 
 7 files changed, 338 insertions(+), 88 deletions(-)
 delete mode 100644 include/linux/acpi_dbg.h

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 2b89fd7..c4d4a05 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -66,6 +66,17 @@ config ACPI_DEBUGGER
  This is still under development, currently enabling this only
  results in the compilation of the ACPICA debugger files.
 
+if ACPI_DEBUGGER
+
+config ACPI_DEBUGGER_USER
+   tristate "Userspace debugger accessiblity"
+   depends on DEBUG_FS
+   help
+ Export /sys/kernel/debug/acpi/acpidbg for userspace utilities
+ to access the debugger functionalities.
+
+endif
+
 config ACPI_SLEEP
bool
depends on SUSPEND || HIBERNATION
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 102b5e6..c6f236f 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -50,7 +50,6 @@ acpi-y+= sysfs.o
 acpi-y += property.o
 acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
 acpi-$(CONFIG_DEBUG_FS)+= debugfs.o
-acpi-$(CONFIG_ACPI_DEBUGGER)   += acpi_dbg.o
 acpi-$(CONFIG_ACPI_NUMA)   += numa.o
 acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
 acpi-y += acpi_lpat.o
@@ -80,6 +79,7 @@ obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o
 obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
 obj-$(CONFIG_ACPI_BGRT)+= bgrt.o
 obj-$(CONFIG_ACPI_CPPC_LIB)+= cppc_acpi.o
+obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o
 
 # processor has its own "processor." module_param namespace
 processor-y:= processor_driver.o
diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index 853ea94..7ca3202 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -21,7 +21,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include "internal.h"
 
 #define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
@@ -307,7 +307,7 @@ static int acpi_aml_readb_kern(void)
  * the debugger output and store the output into the debugger interface
  * buffer. Return the size of stored logs or errno.
  */
-ssize_t acpi_aml_write_log(const char *msg)
+static ssize_t acpi_aml_write_log(const char *msg)
 {
int ret = 0;
int count = 0, size = 0;
@@ -350,7 +350,6 @@ again:
}
return size > 0 ? size : ret;
 }
-EXPORT_SYMBOL(acpi_aml_write_log);
 
 /*
  * acpi_aml_read_cmd() - Capture debugger input
@@ -361,7 +360,7 @@ EXPORT_SYMBOL(acpi_aml_write_log);
  * the debugger input commands and store the input commands into the
  * debugger interface buffer. Return the size of stored commands or errno.
  */
-ssize_t acpi_aml_read_cmd(char *msg, size_t count)
+static ssize_t acpi_aml_read_cmd(char *msg, size_t count)
 {
int ret = 0;
int size = 0;
@@ -403,7 +402,6 @@ again:
}
return size > 0 ? size : ret;
 }
-EXPORT_SYMBOL(acpi_aml_read_cmd);
 
 static int acpi_aml_thread(void *unsed)
 {
@@ -440,7 +438,7 @@ static int acpi_aml_thread(void *unsed)
  * This function should be used to implement acpi_os_execute() which is
  * used by the ACPICA debugger to create the debugger thread.
  */
-int acpi_aml_create_thread(acpi_osd_exec_callback function, void *context)
+static int acpi_aml_create_thread(acpi_osd_exec_callback function, void 
*context)
 {
struct task_struct *t;
 
@@ -462,30 +460,27 @@ int acpi_aml_create_thread(acpi_osd_exec_callback 
function, void *context)
mutex_unlock(_aml_io.lock);
return 0;
 }
-EXPORT_SYMBOL(acpi_aml_create_thread);
 
-int acpi_aml_wait_command_ready(void)
+static int acpi_aml_wait_command_ready(bool single_step,
+  char *buffer, size_t length)
 {
acpi_status status;
 
-   if (!acpi_gbl_method_executing)
-   acpi_os_printf("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
-   else
+   if (single_step)
acpi_os_printf("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+   else
+   acpi_os_printf("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
 
-   status = acpi_os_get_line(acpi_gbl_db_line_buf,
- ACPI_DB_LINE_BUFFER_SIZE, NULL);
+ 

[PATCH v2 13/14] ACPICA: Debugger: Fix dead lock issue ocurred in single stepping mode

2015-10-18 Thread Lv Zheng
ACPICA commit 35273add90da19cd8790fdb5735f52e3c9861684

When single step execution is not ended, executing another control methods
leads to dead locks around interpreter lock/namespace lock/method
serialization lock. So we should only allow one execution from the debugger
at same time. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/35273add
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/dbexec.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/acpi/acpica/dbexec.c b/drivers/acpi/acpica/dbexec.c
index 258e615..d713e2d 100644
--- a/drivers/acpi/acpica/dbexec.c
+++ b/drivers/acpi/acpica/dbexec.c
@@ -370,7 +370,17 @@ acpi_db_execute(char *name, char **args, acpi_object_type 
* types, u32 flags)
 #ifdef ACPI_DEBUG_OUTPUT
u32 previous_allocations;
u32 allocations;
+#endif
 
+   /*
+* Allow one execution to be performed by debugger or single step
+* execution will be dead locked by the interpreter mutexes.
+*/
+   if (acpi_gbl_method_executing) {
+   acpi_os_printf("Only one debugger execution is allowed.\n");
+   return;
+   }
+#ifdef ACPI_DEBUG_OUTPUT
/* Memory allocation tracking */
 
previous_allocations = acpi_db_get_outstanding_allocations();
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 09/14] ACPICA: Debugger: Fix "quit/exit" command by cleaning up user commands termination logic

2015-10-18 Thread Lv Zheng
ACPICA commit 0dd68e16274cd38224aa4781eddc57dc2cbaa108

The quit/exit commands shouldn't invoke acpi_terminate_debugger() and
acpi_terminate() right in the user command loop, because when the debugger
exits, the kernel ACPI subsystem shouldn't be terminated (acpi_terminate())
and the debugger should only be terminated by its users
(acpi_terminate_debugger()) rather than being terminated itself. Leaving such
invocations causes kernel panic when the debugger is shipped in the Linux
kernel.

This patch fixes this issue. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/0dd68e16
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/acglobal.h |3 ++-
 drivers/acpi/acpica/dbinput.c  |   16 
 drivers/acpi/acpica/dbxface.c  |   20 
 drivers/acpi/acpica/utinit.c   |2 --
 drivers/acpi/acpica/utxface.c  |4 
 5 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 593de41..d82249c 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -324,7 +324,6 @@ ACPI_GLOBAL(struct acpi_external_file *, 
acpi_gbl_external_file_list);
 
 #ifdef ACPI_DEBUGGER
 
-ACPI_INIT_GLOBAL(u8, acpi_gbl_db_terminate_threads, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_abort_method, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_method_executing, FALSE);
 
@@ -336,6 +335,8 @@ ACPI_GLOBAL(char *, acpi_gbl_db_filename);
 ACPI_GLOBAL(u32, acpi_gbl_db_debug_level);
 ACPI_GLOBAL(u32, acpi_gbl_db_console_debug_level);
 ACPI_GLOBAL(struct acpi_namespace_node *, acpi_gbl_db_scope_node);
+ACPI_GLOBAL(u8, acpi_gbl_db_terminate_loop);
+ACPI_GLOBAL(u8, acpi_gbl_db_threads_terminated);
 
 ACPI_GLOBAL(char *, acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]);
 ACPI_GLOBAL(acpi_object_type, acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]);
diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
index 7f1b6ec..f8cddd6 100644
--- a/drivers/acpi/acpica/dbinput.c
+++ b/drivers/acpi/acpica/dbinput.c
@@ -694,7 +694,7 @@ acpi_db_command_dispatch(char *input_buffer,
 
/* If acpi_terminate has been called, terminate this thread */
 
-   if (acpi_gbl_db_terminate_threads) {
+   if (acpi_gbl_db_terminate_loop) {
return (AE_CTRL_TERMINATE);
}
 
@@ -1116,7 +1116,7 @@ acpi_db_command_dispatch(char *input_buffer,
 #ifdef ACPI_APPLICATION
acpi_db_close_debug_file();
 #endif
-   acpi_gbl_db_terminate_threads = TRUE;
+   acpi_gbl_db_terminate_loop = TRUE;
return (AE_CTRL_TERMINATE);
 
case CMD_NOT_FOUND:
@@ -1166,6 +1166,7 @@ void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void 
*context)
 
acpi_os_release_mutex(acpi_gbl_db_command_complete);
}
+   acpi_gbl_db_threads_terminated = TRUE;
 }
 
 
/***
@@ -1212,7 +1213,7 @@ acpi_status acpi_db_user_commands(char prompt, union 
acpi_parse_object *op)
 
/* TBD: [Restructure] Need a separate command line buffer for step mode 
*/
 
-   while (!acpi_gbl_db_terminate_threads) {
+   while (!acpi_gbl_db_terminate_loop) {
 
/* Force output to console until a command is entered */
 
@@ -1261,14 +1262,5 @@ acpi_status acpi_db_user_commands(char prompt, union 
acpi_parse_object *op)
}
}
 
-   /* Shut down the debugger */
-
-   acpi_terminate_debugger();
-
-   /*
-* Only this thread (the original thread) should actually terminate the
-* subsystem, because all the semaphores are deleted during termination
-*/
-   status = acpi_terminate();
return (status);
 }
diff --git a/drivers/acpi/acpica/dbxface.c b/drivers/acpi/acpica/dbxface.c
index 26023bd..bef5f4e 100644
--- a/drivers/acpi/acpica/dbxface.c
+++ b/drivers/acpi/acpica/dbxface.c
@@ -401,6 +401,10 @@ acpi_status acpi_initialize_debugger(void)
acpi_gbl_db_scope_buf[1] = 0;
acpi_gbl_db_scope_node = acpi_gbl_root_node;
 
+   /* Initialize user commands loop */
+
+   acpi_gbl_db_terminate_loop = FALSE;
+
/*
 * If configured for multi-thread support, the debug executor runs in
 * a separate thread so that the front end can be in another address
@@ -426,11 +430,13 @@ acpi_status acpi_initialize_debugger(void)
 
/* Create the debug execution thread to execute commands */
 
+   acpi_gbl_db_threads_terminated = FALSE;
status = acpi_os_execute(OSL_DEBUGGER_THREAD,
 acpi_db_execute_thread, NULL);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status,
"Could not start debugger thread"));
+   acpi_gbl_db_thr

[PATCH v2 02/14] ACPICA: iASL: Add symbolic operator support for Index() operator.

2015-10-18 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit fbe67c46830f10c839941f8512cac5bddcb86bd3

Index (, 2) is now supported by  [2]

This patch doesn't affect Linux kernel.

Link: https://github.com/acpica/acpica/commit/fbe67c46
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/aclocal.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 6f70826..8a66fef 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -848,7 +848,7 @@ struct acpi_parse_state {
 #define ACPI_PARSEOP_PARAMLIST  0x02
 #define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
 #define ACPI_PARSEOP_PREDEF_CHECKED 0x08
-#define ACPI_PARSEOP_SPECIAL0x10
+#define ACPI_PARSEOP_CLOSING_PAREN  0x10
 #define ACPI_PARSEOP_COMPOUND   0x20
 #define ACPI_PARSEOP_ASSIGNMENT 0x40
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 06/14] ACPICA: Improve typechecking, both compile-time and runtime

2015-10-18 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 8d0f96e2a11a4ceabb2cae4b41e0ce1f4d3786b9

Adds much stricter typechecking in the iASL compiler, and
also adds some additional checking in the interpreter.

Link: https://github.com/acpica/acpica/commit/8d0f96e2
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/aclocal.h  |8 ++-
 drivers/acpi/acpica/acopcode.h |4 +-
 drivers/acpi/acpica/amlcode.h  |   11 ++--
 drivers/acpi/acpica/exconvrt.c |1 +
 drivers/acpi/acpica/exresolv.c |1 -
 drivers/acpi/acpica/exresop.c  |2 +
 drivers/acpi/acpica/exstore.c  |  120 ++--
 drivers/acpi/acpica/exstoren.c |5 +-
 drivers/acpi/acpica/nspredef.c |2 +-
 drivers/acpi/acpica/utdecode.c |   19 ++-
 include/acpi/acexcep.h |7 ++-
 11 files changed, 134 insertions(+), 46 deletions(-)

diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 918f70d..4e41b43 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -285,13 +285,17 @@ acpi_status(*acpi_internal_method) (struct 
acpi_walk_state * walk_state);
 #define ACPI_BTYPE_BUFFER_FIELD 0x2000
 #define ACPI_BTYPE_DDB_HANDLE   0x4000
 #define ACPI_BTYPE_DEBUG_OBJECT 0x8000
-#define ACPI_BTYPE_REFERENCE0x0001
+#define ACPI_BTYPE_REFERENCE_OBJECT 0x0001 /* From Index(), 
ref_of(), etc (type6_opcodes) */
 #define ACPI_BTYPE_RESOURCE 0x0002
+#define ACPI_BTYPE_NAMED_REFERENCE  0x0004 /* Generic unresolved 
Name or Namepath */
 
 #define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | 
ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
 
 #define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA  | 
ACPI_BTYPE_PACKAGE)
-#define ACPI_BTYPE_DATA_REFERENCE   (ACPI_BTYPE_DATA | 
ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
+
+   /* Used by Copy, de_ref_of, Store, Printf, Fprintf */
+
+#define ACPI_BTYPE_DATA_REFERENCE   (ACPI_BTYPE_DATA | 
ACPI_BTYPE_REFERENCE_OBJECT | ACPI_BTYPE_DDB_HANDLE)
 #define ACPI_BTYPE_DEVICE_OBJECTS   (ACPI_BTYPE_DEVICE | 
ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
 #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001 /* ARG or LOCAL */
 #define ACPI_BTYPE_ALL_OBJECTS  0x
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index fd85ad0..f9acf92 100644
--- a/drivers/acpi/acpica/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
@@ -211,7 +211,7 @@
 #define ARGI_ARG4   ARG_NONE
 #define ARGI_ARG5   ARG_NONE
 #define ARGI_ARG6   ARG_NONE
-#define ARGI_BANK_FIELD_OP  ARGI_INVALID_OPCODE
+#define ARGI_BANK_FIELD_OP  ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER,
ARGI_INTEGER,   ARGI_TARGETREF)
 #define ARGI_BIT_NAND_OPARGI_LIST3 (ARGI_INTEGER,
ARGI_INTEGER,   ARGI_TARGETREF)
 #define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER,
ARGI_INTEGER,   ARGI_TARGETREF)
@@ -307,7 +307,7 @@
 #define ARGI_SLEEP_OP   ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_STALL_OP   ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_STATICSTRING_OPARGI_INVALID_OPCODE
-#define ARGI_STORE_OP   ARGI_LIST2 (ARGI_DATAREFOBJ, 
ARGI_TARGETREF)
+#define ARGI_STORE_OP   ARGI_LIST2 (ARGI_DATAREFOBJ, 
ARGI_STORE_TARGET)
 #define ARGI_STRING_OP  ARGI_INVALID_OPCODE
 #define ARGI_SUBTRACT_OPARGI_LIST3 (ARGI_INTEGER,
ARGI_INTEGER,   ARGI_TARGETREF)
 #define ARGI_THERMAL_ZONE_OPARGI_INVALID_OPCODE
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index be9fd00..883f20c 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -277,14 +277,15 @@
 #define ARGI_TARGETREF  0x0F   /* Target, subject to implicit 
conversion */
 #define ARGI_FIXED_TARGET   0x10   /* Target, no implicit 
conversion */
 #define ARGI_SIMPLE_TARGET  0x11   /* Name, Local, Arg -- no 
implicit conversion */
+#define ARGI_STORE_TARGET   0x12   /* Target for store is 
TARGETREF + package objects */
 
 /* Multiple/complex types */
 
-#define ARGI_DATAOBJECT 0x12   /* Buffer, String, package or 
reference to a node - Used only by size_of operator */
-#define ARGI_COMPLEXOBJ 0x13   /* Buffer, String, or package 
(Used by INDEX op only) */
-#define ARGI_REF_OR_STRING  0x14   /* Reference or String (Used by 
DEREFOF op only) */
-#define ARGI_REGION_OR_BUFFER   0x15   /* Used by LOAD op only */
-#define ARGI_DATAREFOBJ 0x16
+#define ARGI_DATAOBJECT 0x13   /* Buffer, String, package or 
reference to a node - Us

[PATCH v2 00/14] ACPICA: 20150930 Release

2015-10-18 Thread Lv Zheng
The 20150930 ACPICA kernel-resident subsystem updates are linuxized based
on the linux-pm/linux-next branch.

The patchset has passed the following build/boot tests.
Build tests are performed as follows:
1. i386 + allyes
2. i386 + allno
3. i386 + default + ACPI_DEBUGGER=y
4. i386 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y
5. i386 + default + ACPI_DEBUG=n + ACPI=y
6. i386 + default + ACPI=n
7. x86_64 + allyes
8. x86_64 + allno
9. x86_64 + default + ACPI_DEBUGGER=y
10.x86_64 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y
11.x86_64 + default + ACPI_DEBUG=n + ACPI=y
12.x86_64 + default + ACPI=n
Boot tests are performed as follows:
1. i386 + default + ACPI_DEBUGGER=y
2. x86_64 + default + ACPI_DEBUGGER=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 "drivers/platform" drivers
   All other drivers that link the APIs provided by ACPICA subsystem

The divergences checking result:
Before applying (20150818 Release):
  517 lines
After applying (20150930 Release):
  517 lines

Note there are still 2 ACPICA debugger patches not released during this
release cycle, so the debugger IO driver is not released in this cycle. In
this series the ACPICA debugger core is compile time enabled as all ACPICA
debugger files can be built with ACPI_DEBUGGER=y, but not runtime enabled
as there is no invocations calling ACPICA debugger APIs and its required
OSls are just stubs. The embedded debugger invocation acpi_db_single_step()
is also stubbed via debugger thread ID support.

Bob Moore (8):
  ACPICA: Remove unnecessary conditional compilation.
  ACPICA: iASL: Add symbolic operator support for Index() operator.
  ACPICA: Update exception code for "file not found" error
  ACPICA: Debugger: Update mutexes used for multithreaded debugger
  ACPICA: Update NFIT table to rename a flags field
  ACPICA: Improve typechecking, both compile-time and runtime
  ACPICA: iASL: General cleanup of the file suffix #defines
  ACPICA: Update version to 20150930

Lv Zheng (6):
  ACPICA: Linuxize: Export debugger files to Linux
  ACPICA: Debugger: Fix "quit/exit" command by cleaning up user
commands termination logic
  ACPICA: Debugger: Fix "terminate" command by cleaning up subsystem
shutdown logic
  ACPICA: Debugger: Add thread ID support so that single step mode can
only apply to the debugger thread
  ACPI: Enable build of AML interpreter debugger
  ACPICA: Debugger: Fix dead lock issue ocurred in single stepping mode

 drivers/acpi/Kconfig  |9 +
 drivers/acpi/acpica/Makefile  |   18 +-
 drivers/acpi/acpica/acapps.h  |2 +-
 drivers/acpi/acpica/acdebug.h |6 +
 drivers/acpi/acpica/acglobal.h|7 +-
 drivers/acpi/acpica/acinterp.h|2 -
 drivers/acpi/acpica/aclocal.h |   22 +-
 drivers/acpi/acpica/acnamesp.h|4 -
 drivers/acpi/acpica/acopcode.h|4 +-
 drivers/acpi/acpica/acparser.h|4 -
 drivers/acpi/acpica/acutils.h |2 -
 drivers/acpi/acpica/amlcode.h |   11 +-
 drivers/acpi/acpica/dbcmds.c  | 1187 +++
 drivers/acpi/acpica/dbconvert.c   |  484 +++
 drivers/acpi/acpica/dbdisply.c| 1108 +
 drivers/acpi/acpica/dbexec.c  |  764 +
 drivers/acpi/acpica/dbfileio.c|  256 ++
 drivers/acpi/acpica/dbhistry.c|  239 ++
 drivers/acpi/acpica/dbinput.c | 1267 +
 drivers/acpi/acpica/dbmethod.c|  369 +
 drivers/acpi/acpica/dbnames.c |  947 +
 drivers/acpi/acpica/dbobject.c|  533 
 drivers/acpi/acpica/dbstats.c |  546 +
 drivers/acpi/acpica/dbtest.c  | 1057 
 drivers/acpi/acpica/dbutils.c |  457 +++
 drivers/acpi/acpica/dbxface.c |  513 
 drivers/acpi/acpica/evxface.c |2 +-
 drivers/acpi/acpica/exconvrt.c|1 +
 drivers/acpi/acpica/exresolv.c|1 -
 drivers/acpi/acpica/exresop.c |2 +
 drivers/acpi/acpica/exstore.c |  120 ++-
 drivers/acpi/acpica/exstoren.c|5 +-
 drivers/acpi/acpica/nsdump.c  |6 -
 drivers/acpi/acpica/nspredef.c|2 +-
 drivers/acpi/acpica/pstree.c  |2 -
 drivers/acpi/acpica/psutils.c |2 -
 drivers/acpi/acpica/rsdump.c  |3 -
 drivers/acpi/acpica/rsutils.c |2 -
 drivers/acpi/acpica/rsxface.c |4 +-
 dr

[PATCH v2 01/14] ACPICA: Remove unnecessary conditional compilation.

2015-10-18 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit eea1f0e561893b6d6417913b2d224082fe3a0a5e

Remove use of ACPI_DEBUGGER and ACPI_DISASSEMBLER where these
defines are used around entire modules.

Note: This type of code also causes problems with IDEs.

Link: https://github.com/acpica/acpica/commit/eea1f0e5
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/Makefile  |2 +-
 drivers/acpi/acpica/acdebug.h |6 ++
 drivers/acpi/acpica/rsdump.c  |3 ---
 include/acpi/platform/acenv.h |2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index fedcc16..ac78d76 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -123,7 +123,6 @@ acpi-y +=   \
rsaddr.o\
rscalc.o\
rscreate.o  \
-   rsdump.o\
rsdumpinfo.o\
rsinfo.o\
rsio.o  \
@@ -179,6 +178,7 @@ acpi-y +=   \
utxfmutex.o
 
 acpi-$(ACPI_FUTURE_USAGE) +=   \
+   rsdump.o\
utcache.o   \
utfileio.o  \
utprint.o   \
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index eb2e926..c928ba4 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -44,6 +44,12 @@
 #ifndef __ACDEBUG_H__
 #define __ACDEBUG_H__
 
+/* The debugger is used in conjunction with the disassembler most of time */
+
+#ifdef ACPI_DISASSEMBLER
+#include "acdisasm.h"
+#endif
+
 #define ACPI_DEBUG_BUFFER_SIZE  0x4000 /* 16K buffer for return objects */
 
 struct acpi_db_command_info {
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index c428bb3..2a09288 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -51,7 +51,6 @@ ACPI_MODULE_NAME("rsdump")
 /*
  * All functions in this module are used by the AML Debugger only
  */
-#if defined(ACPI_DEBUGGER)
 /* Local prototypes */
 static void acpi_rs_out_string(char *title, char *value);
 
@@ -565,5 +564,3 @@ static void acpi_rs_dump_word_list(u16 length, u16 *data)
acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i, data[i]);
}
 }
-
-#endif
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index ec00e2b..15ef08c 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -142,7 +142,7 @@
 
 #ifdef ACPI_LIBRARY
 #define ACPI_USE_LOCAL_CACHE
-#define ACPI_FUTURE_USAGE
+#define ACPI_FULL_DEBUG
 #endif
 
 /* Common for all ACPICA applications */
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 05/14] ACPICA: Update NFIT table to rename a flags field

2015-10-18 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 534deab97fb416a13bfede15c538e2c9eac9384a

Updated one of the memory subtable flags to clarify.

Link: https://github.com/acpica/acpica/commit/534deab9
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/nfit.c   |6 +++---
 drivers/acpi/nfit.h   |2 +-
 include/acpi/actbl1.h |2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index c1b8d03..bc18aa2 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -706,7 +706,7 @@ static ssize_t flags_show(struct device *dev,
flags & ACPI_NFIT_MEM_SAVE_FAILED ? "save_fail " : "",
flags & ACPI_NFIT_MEM_RESTORE_FAILED ? "restore_fail " : "",
flags & ACPI_NFIT_MEM_FLUSH_FAILED ? "flush_fail " : "",
-   flags & ACPI_NFIT_MEM_ARMED ? "not_armed " : "",
+   flags & ACPI_NFIT_MEM_NOT_ARMED ? "not_armed " : "",
flags & ACPI_NFIT_MEM_HEALTH_OBSERVED ? "smart_event " : "");
 }
 static DEVICE_ATTR_RO(flags);
@@ -815,7 +815,7 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc 
*acpi_desc)
flags |= NDD_ALIASING;
 
mem_flags = __to_nfit_memdev(nfit_mem)->flags;
-   if (mem_flags & ACPI_NFIT_MEM_ARMED)
+   if (mem_flags & ACPI_NFIT_MEM_NOT_ARMED)
flags |= NDD_UNARMED;
 
rc = acpi_nfit_add_dimm(acpi_desc, nfit_mem, device_handle);
@@ -839,7 +839,7 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc 
*acpi_desc)
  mem_flags & ACPI_NFIT_MEM_SAVE_FAILED ? " save_fail" : "",
  mem_flags & ACPI_NFIT_MEM_RESTORE_FAILED ? " restore_fail":"",
  mem_flags & ACPI_NFIT_MEM_FLUSH_FAILED ? " flush_fail" : "",
- mem_flags & ACPI_NFIT_MEM_ARMED ? " not_armed" : "");
+ mem_flags & ACPI_NFIT_MEM_NOT_ARMED ? " not_armed" : "");
 
}
 
diff --git a/drivers/acpi/nfit.h b/drivers/acpi/nfit.h
index 7e74015..329a1eb 100644
--- a/drivers/acpi/nfit.h
+++ b/drivers/acpi/nfit.h
@@ -24,7 +24,7 @@
 #define UUID_NFIT_DIMM "4309ac30-0d11-11e4-9191-0800200c9a66"
 #define ACPI_NFIT_MEM_FAILED_MASK (ACPI_NFIT_MEM_SAVE_FAILED \
| ACPI_NFIT_MEM_RESTORE_FAILED | ACPI_NFIT_MEM_FLUSH_FAILED \
-   | ACPI_NFIT_MEM_ARMED)
+   | ACPI_NFIT_MEM_NOT_ARMED)
 
 enum nfit_uuids {
NFIT_SPA_VOLATILE,
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index fcd5709..1bb979e 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -1012,7 +1012,7 @@ struct acpi_nfit_memory_map {
 #define ACPI_NFIT_MEM_SAVE_FAILED   (1)/* 00: Last SAVE to Memory 
Device failed */
 #define ACPI_NFIT_MEM_RESTORE_FAILED(1<<1) /* 01: Last RESTORE from Memory 
Device failed */
 #define ACPI_NFIT_MEM_FLUSH_FAILED  (1<<2) /* 02: Platform flush failed */
-#define ACPI_NFIT_MEM_ARMED (1<<3) /* 03: Memory Device observed 
to be not armed */
+#define ACPI_NFIT_MEM_NOT_ARMED (1<<3) /* 03: Memory Device is not 
armed */
 #define ACPI_NFIT_MEM_HEALTH_OBSERVED   (1<<4) /* 04: Memory Device observed 
SMART/health events */
 #define ACPI_NFIT_MEM_HEALTH_ENABLED(1<<5) /* 05: SMART/health events 
enabled */
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 04/14] ACPICA: Debugger: Update mutexes used for multithreaded debugger

2015-10-18 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 6b2701f619040e803313363f516b200e362a9100

Make these mutex objects independent of the deadlock detection mechanism.
This mechanism caused failures with the multithread debugger.

This patch doesn't affect Linux kernel as debugger is currently not fully
functioning in the Linux kernel. And the further debugger cleanups will
take care of handling debugger command signalling correctly instead of
using such kind of mutexes. So it is safe to leave this patch as it is.

Link: https://github.com/acpica/acpica/commit/6b2701f6
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acglobal.h |3 +++
 drivers/acpi/acpica/aclocal.h  |4 +---
 drivers/acpi/acpica/utdecode.c |2 --
 drivers/acpi/acpica/utmutex.c  |   21 +
 include/acpi/platform/acenv.h  |6 +++---
 5 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 09f37b5..593de41 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -357,6 +357,9 @@ ACPI_GLOBAL(u16, acpi_gbl_node_type_count_misc);
 ACPI_GLOBAL(u32, acpi_gbl_num_nodes);
 ACPI_GLOBAL(u32, acpi_gbl_num_objects);
 
+ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_ready);
+ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_complete);
+
 #endif /* ACPI_DEBUGGER */
 
 /*
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 8a66fef..918f70d 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -83,10 +83,8 @@ union acpi_parse_object;
 #define ACPI_MTX_EVENTS 3  /* Data for ACPI events */
 #define ACPI_MTX_CACHES 4  /* Internal caches, general 
purposes */
 #define ACPI_MTX_MEMORY 5  /* Debug memory tracking lists 
*/
-#define ACPI_MTX_DEBUG_CMD_COMPLETE 6  /* AML debugger */
-#define ACPI_MTX_DEBUG_CMD_READY7  /* AML debugger */
 
-#define ACPI_MAX_MUTEX  7
+#define ACPI_MAX_MUTEX  5
 #define ACPI_NUM_MUTEX  ACPI_MAX_MUTEX+1
 
 /* Lock structure for reader/writer interfaces */
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
index 988e23b..d452a78 100644
--- a/drivers/acpi/acpica/utdecode.c
+++ b/drivers/acpi/acpica/utdecode.c
@@ -407,8 +407,6 @@ static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
"ACPI_MTX_Events",
"ACPI_MTX_Caches",
"ACPI_MTX_Memory",
-   "ACPI_MTX_CommandComplete",
-   "ACPI_MTX_CommandReady"
 };
 
 char *acpi_ut_get_mutex_name(u32 mutex_id)
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 37b8b58..ce406e3 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -108,6 +108,21 @@ acpi_status acpi_ut_mutex_initialize(void)
/* Create the reader/writer lock for namespace access */
 
status = acpi_ut_create_rw_lock(_gbl_namespace_rw_lock);
+   if (ACPI_FAILURE(status)) {
+   return_ACPI_STATUS(status);
+   }
+#ifdef ACPI_DEBUGGER
+
+   /* Debugger Support */
+
+   status = acpi_os_create_mutex(_gbl_db_command_ready);
+   if (ACPI_FAILURE(status)) {
+   return_ACPI_STATUS(status);
+   }
+
+   status = acpi_os_create_mutex(_gbl_db_command_complete);
+#endif
+
return_ACPI_STATUS(status);
 }
 
@@ -147,6 +162,12 @@ void acpi_ut_mutex_terminate(void)
/* Delete the reader/writer lock */
 
acpi_ut_delete_rw_lock(_gbl_namespace_rw_lock);
+
+#ifdef ACPI_DEBUGGER
+   acpi_os_delete_mutex(acpi_gbl_db_command_ready);
+   acpi_os_delete_mutex(acpi_gbl_db_command_complete);
+#endif
+
return_VOID;
 }
 
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index 15ef08c..056f245 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -304,11 +304,11 @@
  * multi-threaded if ACPI_APPLICATION is not set.
  */
 #ifndef DEBUGGER_THREADING
-#ifdef ACPI_APPLICATION
-#define DEBUGGER_THREADING  DEBUGGER_SINGLE_THREADED
+#if !defined (ACPI_APPLICATION) || defined (ACPI_EXEC_APP)
+#define DEBUGGER_THREADING  DEBUGGER_MULTI_THREADED
 
 #else
-#define DEBUGGER_THREADING  DEBUGGER_MULTI_THREADED
+#define DEBUGGER_THREADING  DEBUGGER_SINGLE_THREADED
 #endif
 #endif /* !DEBUGGER_THREADING */
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 10/14] ACPICA: Debugger: Fix "terminate" command by cleaning up subsystem shutdown logic

2015-10-18 Thread Lv Zheng
ACPICA commit 7e823714911480be47e310fb1b3590d289b9fd99

Segmentation fault can be seen for executing the "terminate" command. This
is because acpi_ut_subsystem_shutdown() is errnously called multiple times.

This patch cleans up acpi_ut_subsystem_shutdown() logics to fix this
issue. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/7e823714
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/dbinput.c |3 ++-
 drivers/acpi/acpica/utinit.c  |   13 +
 drivers/acpi/acpica/utxface.c |   13 -
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
index f8cddd6..0480254 100644
--- a/drivers/acpi/acpica/dbinput.c
+++ b/drivers/acpi/acpica/dbinput.c
@@ -1074,6 +1074,7 @@ acpi_db_command_dispatch(char *input_buffer,
 * re-creating the semaphores!
 */
 
+   acpi_gbl_db_terminate_loop = TRUE;
/*  acpi_initialize (NULL); */
break;
 
@@ -1151,7 +1152,7 @@ void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void 
*context)
acpi_status status = AE_OK;
acpi_status Mstatus;
 
-   while (status != AE_CTRL_TERMINATE) {
+   while (status != AE_CTRL_TERMINATE && !acpi_gbl_db_terminate_loop) {
acpi_gbl_method_executing = FALSE;
acpi_gbl_step_to_next_call = FALSE;
 
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index d8699df..ccd0745 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -282,6 +282,19 @@ void acpi_ut_subsystem_shutdown(void)
 {
ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
 
+   /* Just exit if subsystem is already shutdown */
+
+   if (acpi_gbl_shutdown) {
+   ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
+   return_VOID;
+   }
+
+   /* Subsystem appears active, go ahead and shut it down */
+
+   acpi_gbl_shutdown = TRUE;
+   acpi_gbl_startup_flags = 0;
+   ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
+
 #ifndef ACPI_ASL_COMPILER
 
/* Close the acpi_event Handling */
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index f183daf..a6b0eb0 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -67,19 +67,6 @@ acpi_status __init acpi_terminate(void)
 
ACPI_FUNCTION_TRACE(acpi_terminate);
 
-   /* Just exit if subsystem is already shutdown */
-
-   if (acpi_gbl_shutdown) {
-   ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
-   return_ACPI_STATUS(AE_OK);
-   }
-
-   /* Subsystem appears active, go ahead and shut it down */
-
-   acpi_gbl_shutdown = TRUE;
-   acpi_gbl_startup_flags = 0;
-   ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
-
/* Shutdown and free all resources */
 
acpi_ut_subsystem_shutdown();
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 12/14] ACPI: Enable build of AML interpreter debugger

2015-10-18 Thread Lv Zheng
This patch enables ACPICA debugger files using a configurable
CONFIG_ACPI_DEBUGGER configuration item. Those debugger related code that
was originally masked as ACPI_FUTURE_USAGE now gets unmasked.

Necessary OSL stubs are also added in this patch:
1. acpi_os_readable(): This should be arch specific in Linux, while this
patch doesn't introduce real implementation and a complex mechanism to
allow architecture specific acpi_os_readable() to be implemented to
validate the address. It may be done by future commits.
2. acpi_os_get_line(): This is used to obtain debugger command input. This
patch only introduces a simple KDB concept example in it and the
example should be co-working with the code implemented in
acpi_os_printf(). Since this KDB example won't be compiled unless
ENABLE_DEBUGGER is defined and it seems Linux has already stopped to
use ENABLE_DEBUGGER, thus do not expect it can work properly.

This patch also cleans up all other ACPI_FUTURE_USAGE surroundings
accordingly.
1. Since linkage error can be automatically detected, declaration in the
   headers needn't be surrounded by ACPI_FUTURE_USAGE.
   So only the following separate exported fuction bodies are masked by
   this macro (other exported fucntions may have already been masked at
   entire module level via drivers/acpi/acpica/Makefile):
 acpi_install_exception_handler()
 acpi_subsystem_status()
 acpi_get_system_info()
 acpi_get_statistics()
 acpi_install_initialization_handler()
2. Since strip can automatically zap the no-user functions, functions that
   are not marked with ACPI_EXPORT_SYMBOL() needn't get surrounded by
   ACPI_FUTURE_USAGE.
   So the following function which is not used by Linux kernel now won't
   get surrounded by this macro:
 acpi_ps_get_name()

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/Kconfig  |9 +
 drivers/acpi/acpica/Makefile  |   18 +-
 drivers/acpi/acpica/acinterp.h|2 --
 drivers/acpi/acpica/acnamesp.h|4 
 drivers/acpi/acpica/acparser.h|4 
 drivers/acpi/acpica/acutils.h |2 --
 drivers/acpi/acpica/evxface.c |2 +-
 drivers/acpi/acpica/nsdump.c  |6 --
 drivers/acpi/acpica/pstree.c  |2 --
 drivers/acpi/acpica/psutils.c |2 --
 drivers/acpi/acpica/rsutils.c |2 --
 drivers/acpi/acpica/rsxface.c |4 ++--
 drivers/acpi/acpica/utxface.c |2 +-
 drivers/acpi/osl.c|   11 +++
 include/acpi/acpixf.h |   10 --
 include/acpi/platform/aclinux.h   |7 +--
 include/acpi/platform/aclinuxex.h |5 +
 17 files changed, 43 insertions(+), 49 deletions(-)

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 5d1015c..706c2e9 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -57,6 +57,15 @@ config ACPI_SYSTEM_POWER_STATES_SUPPORT
 config ACPI_CCA_REQUIRED
bool
 
+config ACPI_DEBUGGER
+   bool "In-kernel debugger (EXPERIMENTAL)"
+   select ACPI_DEBUG
+   help
+ Enable in-kernel debugging facilities: statistics, internal
+ object dump, single step control method execution.
+ This is still under development, currently enabling this only
+ results in the compilation of the ACPICA debugger files.
+
 config ACPI_SLEEP
bool
depends on SUSPEND || HIBERNATION
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index ac78d76..885936f 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -177,8 +177,24 @@ acpi-y +=  \
utxferror.o \
utxfmutex.o
 
-acpi-$(ACPI_FUTURE_USAGE) +=   \
+acpi-$(CONFIG_ACPI_DEBUGGER) +=\
+   dbcmds.o\
+   dbconvert.o \
+   dbdisply.o  \
+   dbexec.o\
+   dbhistry.o  \
+   dbinput.o   \
+   dbmethod.o  \
+   dbnames.o   \
+   dbobject.o  \
+   dbstats.o   \
+   dbutils.o   \
+   dbxface.o   \
rsdump.o\
+
+acpi-$(ACPI_FUTURE_USAGE) +=   \
+   dbfileio.o  \
+   dbtest.o\
utcache.o   \
utfileio.o  \
utprint.o   \
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index e820ed8..e9e936e 100644
--- a/drivers/acpi/acpica/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
@@ -397,12 +397,10 @@ void
 acpi_ex_dump_operands(union acpi_operand_object **operands,
  const char *opcode_name, u32 num_opcodes);
 
-#ifdef ACPI_FUTURE_USAGE
 void
 acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags);
 
 void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32

[PATCH v2 11/14] ACPICA: Debugger: Add thread ID support so that single step mode can only apply to the debugger thread

2015-10-18 Thread Lv Zheng
When the debugger is running in the kernel mode, acpi_db_single_step() may
also be invoked by the kernel runtime code path but the single stepping
command prompt may be erronously logged as the kernel logs and runtime code
path cannot proceed.

This patch fixes this issue by adding acpi_gbl_db_thread_id for the debugger
thread and preventing acpi_db_single_step() to be invoked from other threads.

It is not suitable to add acpi_thread_id parameter for acpi_os_execute() as
the function may be implemented as work queue on some hosts. So it is
better to let the hosts invoke acpi_set_debugger_thread_id(). Currently
acpiexec is not configured as DEBUGGER_MULTI_THREADED, but we can do this.
When we do this, it is better to invoke acpi_set_debugger_thread_id() in
acpi_os_execute() when the execution type is OSL_DEBUGGER_MAIN_THREAD. The
support should look like:
  create_thread();
  if (type == OSL_DEBUGGER_MAIN_THREAD)
  acpi_set_debugger_thread_id(tid);
  resume_thread(tid);
Similarly, semop() may be used for pthread implementation. But this patch
simply skips debugger thread ID check for application instead of
introducing such complications as there is no need to skip
acpi_db_single_step() for an application debugger - acpiexec.

Note that the debugger thread ID can also be used by acpi_os_printf() to
filter out debugger output. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acglobal.h |1 +
 drivers/acpi/acpica/aclocal.h  |8 
 drivers/acpi/acpica/dbexec.c   |3 ++-
 drivers/acpi/acpica/dbxface.c  |   28 +++-
 include/acpi/acpiosxf.h|3 ++-
 include/acpi/acpixf.h  |2 ++
 6 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index d82249c..fdef15f 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -326,6 +326,7 @@ ACPI_GLOBAL(struct acpi_external_file *, 
acpi_gbl_external_file_list);
 
 ACPI_INIT_GLOBAL(u8, acpi_gbl_abort_method, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_method_executing, FALSE);
+ACPI_INIT_GLOBAL(acpi_thread_id, acpi_gbl_db_thread_id, 
ACPI_INVALID_THREAD_ID);
 
 ACPI_GLOBAL(u8, acpi_gbl_db_opt_no_ini_methods);
 ACPI_GLOBAL(u8, acpi_gbl_db_opt_no_region_support);
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 4e41b43..e1dd784 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -109,6 +109,14 @@ struct acpi_rw_lock {
 
 #define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0
 
+/* This Thread ID means an invalid thread ID */
+
+#ifdef ACPI_OS_INVALID_THREAD_ID
+#define ACPI_INVALID_THREAD_ID  ACPI_OS_INVALID_THREAD_ID
+#else
+#define ACPI_INVALID_THREAD_ID  ((acpi_thread_id) 0x)
+#endif
+
 /* Table for the global mutexes */
 
 struct acpi_mutex_info {
diff --git a/drivers/acpi/acpica/dbexec.c b/drivers/acpi/acpica/dbexec.c
index 8eef298..258e615 100644
--- a/drivers/acpi/acpica/dbexec.c
+++ b/drivers/acpi/acpica/dbexec.c
@@ -725,7 +725,8 @@ acpi_db_create_execution_threads(char *num_threads_arg,
 
for (i = 0; i < (num_threads); i++) {
status =
-   acpi_os_execute(OSL_DEBUGGER_THREAD, acpi_db_method_thread,
+   acpi_os_execute(OSL_DEBUGGER_EXEC_THREAD,
+   acpi_db_method_thread,
_gbl_db_method_info);
if (ACPI_FAILURE(status)) {
break;
diff --git a/drivers/acpi/acpica/dbxface.c b/drivers/acpi/acpica/dbxface.c
index bef5f4e..342298a 100644
--- a/drivers/acpi/acpica/dbxface.c
+++ b/drivers/acpi/acpica/dbxface.c
@@ -164,6 +164,12 @@ acpi_db_single_step(struct acpi_walk_state * walk_state,
 
ACPI_FUNCTION_ENTRY();
 
+#ifndef ACPI_APPLICATION
+   if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
+   return (AE_OK);
+   }
+#endif
+
/* Check the abort flag */
 
if (acpi_gbl_abort_method) {
@@ -431,7 +437,7 @@ acpi_status acpi_initialize_debugger(void)
/* Create the debug execution thread to execute commands */
 
acpi_gbl_db_threads_terminated = FALSE;
-   status = acpi_os_execute(OSL_DEBUGGER_THREAD,
+   status = acpi_os_execute(OSL_DEBUGGER_MAIN_THREAD,
 acpi_db_execute_thread, NULL);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status,
@@ -439,6 +445,8 @@ acpi_status acpi_initialize_debugger(void)
acpi_gbl_db_threads_terminated = TRUE;
return_ACPI_STATUS(status);
}
+   } else {
+   acpi_gbl_db_thread_id = acpi_os_get_thread_id();
}
 
return_ACPI_STATUS(AE_OK);
@@ -485,3 +493,21 @@ void acpi_terminate_debugger(void)
 }
 
 ACPI_EXPO

[PATCH v2 07/14] ACPICA: iASL: General cleanup of the file suffix #defines

2015-10-18 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit bed456ed2976bdaafdef406b982fdf6c539befc0

Removed some extraneous defines, reordered others.

Link: https://github.com/acpica/acpica/commit/bed456ed
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acapps.h  |2 +-
 tools/power/acpi/tools/acpidump/apfiles.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/acapps.h b/drivers/acpi/acpica/acapps.h
index e9f0833..e4cc48f 100644
--- a/drivers/acpi/acpica/acapps.h
+++ b/drivers/acpi/acpica/acapps.h
@@ -88,7 +88,7 @@
acpi_os_printf (" %-18s%s\n", name, description);
 
 #define FILE_SUFFIX_DISASSEMBLY "dsl"
-#define ACPI_TABLE_FILE_SUFFIX  ".dat"
+#define FILE_SUFFIX_BINARY_TABLE".dat" /* Needs the dot */
 
 /*
  * getopt
diff --git a/tools/power/acpi/tools/acpidump/apfiles.c 
b/tools/power/acpi/tools/acpidump/apfiles.c
index a37f970..a1c62de 100644
--- a/tools/power/acpi/tools/acpidump/apfiles.c
+++ b/tools/power/acpi/tools/acpidump/apfiles.c
@@ -150,7 +150,7 @@ int ap_write_to_binary_file(struct acpi_table_header 
*table, u32 instance)
strcat(filename, instance_str);
}
 
-   strcat(filename, ACPI_TABLE_FILE_SUFFIX);
+   strcat(filename, FILE_SUFFIX_BINARY_TABLE);
 
if (gbl_verbose_mode) {
acpi_log_error
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 03/14] ACPICA: Update exception code for "file not found" error

2015-10-18 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit ac1564c26d239348ef13455f61d5616f3961ff43

Used by the ACPICA applications.

This patch is a bit broken due to non-portable  inclusion as on
some platforms, there is no such a header file for their lib-c exports.
Fortunately, Linux doesn't compile utfileio.c for either the kernel
space ACPICA core (drivers/acpi/acpica) or the userspace ACPICA tools
(tools/power/acpi) for now, so it's safe to leave this patch as it is.

Link: https://github.com/acpica/acpica/commit/ac1564c2
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/utfileio.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/acpi/acpica/utfileio.c b/drivers/acpi/acpica/utfileio.c
index 75a94f5..d435b7b 100644
--- a/drivers/acpi/acpica/utfileio.c
+++ b/drivers/acpi/acpica/utfileio.c
@@ -45,6 +45,7 @@
 #include "accommon.h"
 #include "actables.h"
 #include "acapps.h"
+#include "errno.h"
 
 #ifdef ACPI_ASL_COMPILER
 #include "aslcompiler.h"
@@ -301,6 +302,11 @@ acpi_ut_read_table_from_file(char *filename, struct 
acpi_table_header ** table)
file = fopen(filename, "rb");
if (!file) {
perror("Could not open input file");
+
+   if (errno == ENOENT) {
+   return (AE_NOT_EXIST);
+   }
+
return (status);
}
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 14/14] ACPICA: Update version to 20150930

2015-10-18 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit e9c75ca267262326e80d49a290e8387a5963e2d2

Version 20150930.

Link: https://github.com/acpica/acpica/commit/e9c75ca2
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 include/acpi/acpixf.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index ded9fa3..386 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in MMDD format */
 
-#define ACPI_CA_VERSION 0x20150818
+#define ACPI_CA_VERSION 0x20150930
 
 #include 
 #include 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ACPICA: Tables: Fix FADT dependency regression

2015-10-13 Thread Lv Zheng
Some logics actually relying on the existence of FADT, currently relies on
the number of loaded tables. This false dependency can easily trigger
regressions. The reported regression can be seen on the following commit:
  Commit: 8ec3f459073e67e5c6d78507dec693064b3040a2
  Subject: ACPICA: Tables: Fix global table list issues by removing fixed table
The commit changing the fixed table indexes results in the change of FADT
table index, originally, it was 3 (thus the installed table count should be
greater than 4), while currently it is 0 (and the installed table count may
be 3).

This patch fixes this regression by cleaning up the code. Lv Zheng.

Reference: https://bugzilla.kernel.org/show_bug.cgi?id=105351
Reported-and-tested-by: Meelis Roos <mr...@linux.ee>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acglobal.h |1 +
 drivers/acpi/acpica/actables.h |4 +---
 drivers/acpi/acpica/evxfevnt.c |2 +-
 drivers/acpi/acpica/tbfadt.c   |   10 +-
 drivers/acpi/acpica/tbutils.c  |   26 ++
 5 files changed, 10 insertions(+), 33 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 09f37b5..4dde37c 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -61,6 +61,7 @@ ACPI_GLOBAL(struct acpi_table_header, 
acpi_gbl_original_dsdt_header);
 ACPI_INIT_GLOBAL(u32, acpi_gbl_dsdt_index, ACPI_INVALID_TABLE_INDEX);
 ACPI_INIT_GLOBAL(u32, acpi_gbl_facs_index, ACPI_INVALID_TABLE_INDEX);
 ACPI_INIT_GLOBAL(u32, acpi_gbl_xfacs_index, ACPI_INVALID_TABLE_INDEX);
+ACPI_INIT_GLOBAL(u32, acpi_gbl_fadt_index, ACPI_INVALID_TABLE_INDEX);
 
 #if (!ACPI_REDUCED_HARDWARE)
 ACPI_GLOBAL(struct acpi_table_facs *, acpi_gbl_FACS);
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index f7731f2..591ea95 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -85,7 +85,7 @@ void acpi_tb_set_table_loaded_flag(u32 table_index, u8 
is_loaded);
 /*
  * tbfadt - FADT parse/convert/validate
  */
-void acpi_tb_parse_fadt(u32 table_index);
+void acpi_tb_parse_fadt(void);
 
 void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length);
 
@@ -138,8 +138,6 @@ acpi_status acpi_tb_get_owner_id(u32 table_index, 
acpi_owner_id *owner_id);
  */
 acpi_status acpi_tb_initialize_facs(void);
 
-u8 acpi_tb_tables_loaded(void);
-
 void
 acpi_tb_print_table_header(acpi_physical_address address,
   struct acpi_table_header *header);
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index faad911..10ce48e 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -71,7 +71,7 @@ acpi_status acpi_enable(void)
 
/* ACPI tables must be present */
 
-   if (!acpi_tb_tables_loaded()) {
+   if (acpi_gbl_fadt_index == ACPI_INVALID_TABLE_INDEX) {
return_ACPI_STATUS(AE_NO_ACPI_TABLES);
}
 
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 455a070..a6454f4 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -298,7 +298,7 @@ acpi_tb_select_address(char *register_name, u32 address32, 
u64 address64)
  *
  * FUNCTION:acpi_tb_parse_fadt
  *
- * PARAMETERS:  table_index - Index for the FADT
+ * PARAMETERS:  None
  *
  * RETURN:  None
  *
@@ -307,7 +307,7 @@ acpi_tb_select_address(char *register_name, u32 address32, 
u64 address64)
  *
  
**/
 
-void acpi_tb_parse_fadt(u32 table_index)
+void acpi_tb_parse_fadt(void)
 {
u32 length;
struct acpi_table_header *table;
@@ -319,11 +319,11 @@ void acpi_tb_parse_fadt(u32 table_index)
 * Get a local copy of the FADT and convert it to a common format
 * Map entire FADT, assumed to be smaller than one page.
 */
-   length = acpi_gbl_root_table_list.tables[table_index].length;
+   length = acpi_gbl_root_table_list.tables[acpi_gbl_fadt_index].length;
 
table =
-   acpi_os_map_memory(acpi_gbl_root_table_list.tables[table_index].
-  address, length);
+   acpi_os_map_memory(acpi_gbl_root_table_list.
+  tables[acpi_gbl_fadt_index].address, length);
if (!table) {
return;
}
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 4337990..d8ddef3 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -99,29 +99,6 @@ acpi_status acpi_tb_initialize_facs(void)
 
 
/***
  *
- * FUNCTION:acpi_tb_tables_loaded
- *
- * PARAMETERS:  None
- *
- * RETURN:  TRUE if required ACPI tables are loaded
- *
- * DESCRIPTION: Determine if the minimum required ACPI tables are present
- *  (FADT

[PATCH 05/13] ACPICA: Update NFIT table to rename a flags field

2015-10-14 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 534deab97fb416a13bfede15c538e2c9eac9384a

Updated one of the memory subtable flags to clarify.

Link: https://github.com/acpica/acpica/commit/534deab9
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/nfit.c   |6 +++---
 drivers/acpi/nfit.h   |2 +-
 include/acpi/actbl1.h |2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index c1b8d03..bc18aa2 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -706,7 +706,7 @@ static ssize_t flags_show(struct device *dev,
flags & ACPI_NFIT_MEM_SAVE_FAILED ? "save_fail " : "",
flags & ACPI_NFIT_MEM_RESTORE_FAILED ? "restore_fail " : "",
flags & ACPI_NFIT_MEM_FLUSH_FAILED ? "flush_fail " : "",
-   flags & ACPI_NFIT_MEM_ARMED ? "not_armed " : "",
+   flags & ACPI_NFIT_MEM_NOT_ARMED ? "not_armed " : "",
flags & ACPI_NFIT_MEM_HEALTH_OBSERVED ? "smart_event " : "");
 }
 static DEVICE_ATTR_RO(flags);
@@ -815,7 +815,7 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc 
*acpi_desc)
flags |= NDD_ALIASING;
 
mem_flags = __to_nfit_memdev(nfit_mem)->flags;
-   if (mem_flags & ACPI_NFIT_MEM_ARMED)
+   if (mem_flags & ACPI_NFIT_MEM_NOT_ARMED)
flags |= NDD_UNARMED;
 
rc = acpi_nfit_add_dimm(acpi_desc, nfit_mem, device_handle);
@@ -839,7 +839,7 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc 
*acpi_desc)
  mem_flags & ACPI_NFIT_MEM_SAVE_FAILED ? " save_fail" : "",
  mem_flags & ACPI_NFIT_MEM_RESTORE_FAILED ? " restore_fail":"",
  mem_flags & ACPI_NFIT_MEM_FLUSH_FAILED ? " flush_fail" : "",
- mem_flags & ACPI_NFIT_MEM_ARMED ? " not_armed" : "");
+ mem_flags & ACPI_NFIT_MEM_NOT_ARMED ? " not_armed" : "");
 
}
 
diff --git a/drivers/acpi/nfit.h b/drivers/acpi/nfit.h
index 7e74015..329a1eb 100644
--- a/drivers/acpi/nfit.h
+++ b/drivers/acpi/nfit.h
@@ -24,7 +24,7 @@
 #define UUID_NFIT_DIMM "4309ac30-0d11-11e4-9191-0800200c9a66"
 #define ACPI_NFIT_MEM_FAILED_MASK (ACPI_NFIT_MEM_SAVE_FAILED \
| ACPI_NFIT_MEM_RESTORE_FAILED | ACPI_NFIT_MEM_FLUSH_FAILED \
-   | ACPI_NFIT_MEM_ARMED)
+   | ACPI_NFIT_MEM_NOT_ARMED)
 
 enum nfit_uuids {
NFIT_SPA_VOLATILE,
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index fcd5709..1bb979e 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -1012,7 +1012,7 @@ struct acpi_nfit_memory_map {
 #define ACPI_NFIT_MEM_SAVE_FAILED   (1)/* 00: Last SAVE to Memory 
Device failed */
 #define ACPI_NFIT_MEM_RESTORE_FAILED(1<<1) /* 01: Last RESTORE from Memory 
Device failed */
 #define ACPI_NFIT_MEM_FLUSH_FAILED  (1<<2) /* 02: Platform flush failed */
-#define ACPI_NFIT_MEM_ARMED (1<<3) /* 03: Memory Device observed 
to be not armed */
+#define ACPI_NFIT_MEM_NOT_ARMED (1<<3) /* 03: Memory Device is not 
armed */
 #define ACPI_NFIT_MEM_HEALTH_OBSERVED   (1<<4) /* 04: Memory Device observed 
SMART/health events */
 #define ACPI_NFIT_MEM_HEALTH_ENABLED(1<<5) /* 05: SMART/health events 
enabled */
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/13] ACPICA: Remove unnecessary conditional compilation.

2015-10-14 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit eea1f0e561893b6d6417913b2d224082fe3a0a5e

Remove use of ACPI_DEBUGGER and ACPI_DISASSEMBLER where these
defines are used around entire modules.

Note: This type of code also causes problems with IDEs.

Link: https://github.com/acpica/acpica/commit/eea1f0e5
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acdebug.h |6 ++
 drivers/acpi/acpica/rsdump.c  |3 ---
 include/acpi/platform/acenv.h |2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index eb2e926..c928ba4 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -44,6 +44,12 @@
 #ifndef __ACDEBUG_H__
 #define __ACDEBUG_H__
 
+/* The debugger is used in conjunction with the disassembler most of time */
+
+#ifdef ACPI_DISASSEMBLER
+#include "acdisasm.h"
+#endif
+
 #define ACPI_DEBUG_BUFFER_SIZE  0x4000 /* 16K buffer for return objects */
 
 struct acpi_db_command_info {
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index c428bb3..2a09288 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -51,7 +51,6 @@ ACPI_MODULE_NAME("rsdump")
 /*
  * All functions in this module are used by the AML Debugger only
  */
-#if defined(ACPI_DEBUGGER)
 /* Local prototypes */
 static void acpi_rs_out_string(char *title, char *value);
 
@@ -565,5 +564,3 @@ static void acpi_rs_dump_word_list(u16 length, u16 *data)
acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i, data[i]);
}
 }
-
-#endif
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index ec00e2b..15ef08c 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -142,7 +142,7 @@
 
 #ifdef ACPI_LIBRARY
 #define ACPI_USE_LOCAL_CACHE
-#define ACPI_FUTURE_USAGE
+#define ACPI_FULL_DEBUG
 #endif
 
 /* Common for all ACPICA applications */
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/13] ACPICA: iASL: General cleanup of the file suffix #defines

2015-10-14 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit bed456ed2976bdaafdef406b982fdf6c539befc0

Removed some extraneous defines, reordered others.

Link: https://github.com/acpica/acpica/commit/bed456ed
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acapps.h  |2 +-
 tools/power/acpi/tools/acpidump/apfiles.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/acapps.h b/drivers/acpi/acpica/acapps.h
index e9f0833..e4cc48f 100644
--- a/drivers/acpi/acpica/acapps.h
+++ b/drivers/acpi/acpica/acapps.h
@@ -88,7 +88,7 @@
acpi_os_printf (" %-18s%s\n", name, description);
 
 #define FILE_SUFFIX_DISASSEMBLY "dsl"
-#define ACPI_TABLE_FILE_SUFFIX  ".dat"
+#define FILE_SUFFIX_BINARY_TABLE".dat" /* Needs the dot */
 
 /*
  * getopt
diff --git a/tools/power/acpi/tools/acpidump/apfiles.c 
b/tools/power/acpi/tools/acpidump/apfiles.c
index a37f970..a1c62de 100644
--- a/tools/power/acpi/tools/acpidump/apfiles.c
+++ b/tools/power/acpi/tools/acpidump/apfiles.c
@@ -150,7 +150,7 @@ int ap_write_to_binary_file(struct acpi_table_header 
*table, u32 instance)
strcat(filename, instance_str);
}
 
-   strcat(filename, ACPI_TABLE_FILE_SUFFIX);
+   strcat(filename, FILE_SUFFIX_BINARY_TABLE);
 
if (gbl_verbose_mode) {
acpi_log_error
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 09/13] ACPICA: Debugger: Fix "quit/exit" command by cleaning up user commands termination logic

2015-10-14 Thread Lv Zheng
ACPICA commit 0dd68e16274cd38224aa4781eddc57dc2cbaa108

The quit/exit commands shouldn't invoke acpi_terminate_debugger() and
acpi_terminate() right in the user command loop, because when the debugger
exits, the kernel ACPI subsystem shouldn't be terminated (acpi_terminate())
and the debugger should only be terminated by its users
(acpi_terminate_debugger()) rather than being terminated itself. Leaving such
invocations causes kernel panic when the debugger is shipped in the Linux
kernel.

This patch fixes this issue. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/0dd68e16
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/acglobal.h |3 ++-
 drivers/acpi/acpica/dbinput.c  |   16 
 drivers/acpi/acpica/dbxface.c  |   20 
 drivers/acpi/acpica/utinit.c   |2 --
 drivers/acpi/acpica/utxface.c  |4 
 5 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 593de41..d82249c 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -324,7 +324,6 @@ ACPI_GLOBAL(struct acpi_external_file *, 
acpi_gbl_external_file_list);
 
 #ifdef ACPI_DEBUGGER
 
-ACPI_INIT_GLOBAL(u8, acpi_gbl_db_terminate_threads, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_abort_method, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_method_executing, FALSE);
 
@@ -336,6 +335,8 @@ ACPI_GLOBAL(char *, acpi_gbl_db_filename);
 ACPI_GLOBAL(u32, acpi_gbl_db_debug_level);
 ACPI_GLOBAL(u32, acpi_gbl_db_console_debug_level);
 ACPI_GLOBAL(struct acpi_namespace_node *, acpi_gbl_db_scope_node);
+ACPI_GLOBAL(u8, acpi_gbl_db_terminate_loop);
+ACPI_GLOBAL(u8, acpi_gbl_db_threads_terminated);
 
 ACPI_GLOBAL(char *, acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]);
 ACPI_GLOBAL(acpi_object_type, acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]);
diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
index 7f1b6ec..f8cddd6 100644
--- a/drivers/acpi/acpica/dbinput.c
+++ b/drivers/acpi/acpica/dbinput.c
@@ -694,7 +694,7 @@ acpi_db_command_dispatch(char *input_buffer,
 
/* If acpi_terminate has been called, terminate this thread */
 
-   if (acpi_gbl_db_terminate_threads) {
+   if (acpi_gbl_db_terminate_loop) {
return (AE_CTRL_TERMINATE);
}
 
@@ -1116,7 +1116,7 @@ acpi_db_command_dispatch(char *input_buffer,
 #ifdef ACPI_APPLICATION
acpi_db_close_debug_file();
 #endif
-   acpi_gbl_db_terminate_threads = TRUE;
+   acpi_gbl_db_terminate_loop = TRUE;
return (AE_CTRL_TERMINATE);
 
case CMD_NOT_FOUND:
@@ -1166,6 +1166,7 @@ void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void 
*context)
 
acpi_os_release_mutex(acpi_gbl_db_command_complete);
}
+   acpi_gbl_db_threads_terminated = TRUE;
 }
 
 
/***
@@ -1212,7 +1213,7 @@ acpi_status acpi_db_user_commands(char prompt, union 
acpi_parse_object *op)
 
/* TBD: [Restructure] Need a separate command line buffer for step mode 
*/
 
-   while (!acpi_gbl_db_terminate_threads) {
+   while (!acpi_gbl_db_terminate_loop) {
 
/* Force output to console until a command is entered */
 
@@ -1261,14 +1262,5 @@ acpi_status acpi_db_user_commands(char prompt, union 
acpi_parse_object *op)
}
}
 
-   /* Shut down the debugger */
-
-   acpi_terminate_debugger();
-
-   /*
-* Only this thread (the original thread) should actually terminate the
-* subsystem, because all the semaphores are deleted during termination
-*/
-   status = acpi_terminate();
return (status);
 }
diff --git a/drivers/acpi/acpica/dbxface.c b/drivers/acpi/acpica/dbxface.c
index 26023bd..bef5f4e 100644
--- a/drivers/acpi/acpica/dbxface.c
+++ b/drivers/acpi/acpica/dbxface.c
@@ -401,6 +401,10 @@ acpi_status acpi_initialize_debugger(void)
acpi_gbl_db_scope_buf[1] = 0;
acpi_gbl_db_scope_node = acpi_gbl_root_node;
 
+   /* Initialize user commands loop */
+
+   acpi_gbl_db_terminate_loop = FALSE;
+
/*
 * If configured for multi-thread support, the debug executor runs in
 * a separate thread so that the front end can be in another address
@@ -426,11 +430,13 @@ acpi_status acpi_initialize_debugger(void)
 
/* Create the debug execution thread to execute commands */
 
+   acpi_gbl_db_threads_terminated = FALSE;
status = acpi_os_execute(OSL_DEBUGGER_THREAD,
 acpi_db_execute_thread, NULL);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status,
"Could not start debugger thread"));
+   acpi_gbl_db_thr

[PATCH 06/13] ACPICA: Improve typechecking, both compile-time and runtime

2015-10-14 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 8d0f96e2a11a4ceabb2cae4b41e0ce1f4d3786b9

Adds much stricter typechecking in the iASL compiler, and
also adds some additional checking in the interpreter.

Link: https://github.com/acpica/acpica/commit/8d0f96e2
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/aclocal.h  |8 ++-
 drivers/acpi/acpica/acopcode.h |4 +-
 drivers/acpi/acpica/amlcode.h  |   11 ++--
 drivers/acpi/acpica/exconvrt.c |1 +
 drivers/acpi/acpica/exresolv.c |1 -
 drivers/acpi/acpica/exresop.c  |2 +
 drivers/acpi/acpica/exstore.c  |  120 ++--
 drivers/acpi/acpica/exstoren.c |5 +-
 drivers/acpi/acpica/nspredef.c |2 +-
 drivers/acpi/acpica/utdecode.c |   19 ++-
 include/acpi/acexcep.h |7 ++-
 11 files changed, 134 insertions(+), 46 deletions(-)

diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 918f70d..4e41b43 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -285,13 +285,17 @@ acpi_status(*acpi_internal_method) (struct 
acpi_walk_state * walk_state);
 #define ACPI_BTYPE_BUFFER_FIELD 0x2000
 #define ACPI_BTYPE_DDB_HANDLE   0x4000
 #define ACPI_BTYPE_DEBUG_OBJECT 0x8000
-#define ACPI_BTYPE_REFERENCE0x0001
+#define ACPI_BTYPE_REFERENCE_OBJECT 0x0001 /* From Index(), 
ref_of(), etc (type6_opcodes) */
 #define ACPI_BTYPE_RESOURCE 0x0002
+#define ACPI_BTYPE_NAMED_REFERENCE  0x0004 /* Generic unresolved 
Name or Namepath */
 
 #define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | 
ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
 
 #define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA  | 
ACPI_BTYPE_PACKAGE)
-#define ACPI_BTYPE_DATA_REFERENCE   (ACPI_BTYPE_DATA | 
ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
+
+   /* Used by Copy, de_ref_of, Store, Printf, Fprintf */
+
+#define ACPI_BTYPE_DATA_REFERENCE   (ACPI_BTYPE_DATA | 
ACPI_BTYPE_REFERENCE_OBJECT | ACPI_BTYPE_DDB_HANDLE)
 #define ACPI_BTYPE_DEVICE_OBJECTS   (ACPI_BTYPE_DEVICE | 
ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
 #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001 /* ARG or LOCAL */
 #define ACPI_BTYPE_ALL_OBJECTS  0x
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index fd85ad0..f9acf92 100644
--- a/drivers/acpi/acpica/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
@@ -211,7 +211,7 @@
 #define ARGI_ARG4   ARG_NONE
 #define ARGI_ARG5   ARG_NONE
 #define ARGI_ARG6   ARG_NONE
-#define ARGI_BANK_FIELD_OP  ARGI_INVALID_OPCODE
+#define ARGI_BANK_FIELD_OP  ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER,
ARGI_INTEGER,   ARGI_TARGETREF)
 #define ARGI_BIT_NAND_OPARGI_LIST3 (ARGI_INTEGER,
ARGI_INTEGER,   ARGI_TARGETREF)
 #define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER,
ARGI_INTEGER,   ARGI_TARGETREF)
@@ -307,7 +307,7 @@
 #define ARGI_SLEEP_OP   ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_STALL_OP   ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_STATICSTRING_OPARGI_INVALID_OPCODE
-#define ARGI_STORE_OP   ARGI_LIST2 (ARGI_DATAREFOBJ, 
ARGI_TARGETREF)
+#define ARGI_STORE_OP   ARGI_LIST2 (ARGI_DATAREFOBJ, 
ARGI_STORE_TARGET)
 #define ARGI_STRING_OP  ARGI_INVALID_OPCODE
 #define ARGI_SUBTRACT_OPARGI_LIST3 (ARGI_INTEGER,
ARGI_INTEGER,   ARGI_TARGETREF)
 #define ARGI_THERMAL_ZONE_OPARGI_INVALID_OPCODE
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index be9fd00..883f20c 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -277,14 +277,15 @@
 #define ARGI_TARGETREF  0x0F   /* Target, subject to implicit 
conversion */
 #define ARGI_FIXED_TARGET   0x10   /* Target, no implicit 
conversion */
 #define ARGI_SIMPLE_TARGET  0x11   /* Name, Local, Arg -- no 
implicit conversion */
+#define ARGI_STORE_TARGET   0x12   /* Target for store is 
TARGETREF + package objects */
 
 /* Multiple/complex types */
 
-#define ARGI_DATAOBJECT 0x12   /* Buffer, String, package or 
reference to a node - Used only by size_of operator */
-#define ARGI_COMPLEXOBJ 0x13   /* Buffer, String, or package 
(Used by INDEX op only) */
-#define ARGI_REF_OR_STRING  0x14   /* Reference or String (Used by 
DEREFOF op only) */
-#define ARGI_REGION_OR_BUFFER   0x15   /* Used by LOAD op only */
-#define ARGI_DATAREFOBJ 0x16
+#define ARGI_DATAOBJECT 0x13   /* Buffer, String, package or 
reference to a node - Us

[PATCH 00/13] ACPICA: 20150930 Release

2015-10-14 Thread Lv Zheng
The 20150930 ACPICA kernel-resident subsystem updates are linuxized based
on the linux-pm/linux-next branch.

The patchset has passed the following build/boot tests.
Build tests are performed as follows:
1. i386 + allyes
2. i386 + allno
3. i386 + default + ACPI_DEBUGGER=y
4. i386 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y
5. i386 + default + ACPI_DEBUG=n + ACPI=y
6. i386 + default + ACPI=n
7. x86_64 + allyes
8. x86_64 + allno
9. x86_64 + default + ACPI_DEBUGGER=y
10.x86_64 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y
11.x86_64 + default + ACPI_DEBUG=n + ACPI=y
12.x86_64 + default + ACPI=n
Boot tests are performed as follows:
1. i386 + default + ACPI_DEBUGGER=y
2. x86_64 + default + ACPI_DEBUGGER=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 "drivers/platform" drivers
   All other drivers that link the APIs provided by ACPICA subsystem

The divergences checking result:
Before applying (20150818 Release):
  517 lines
After applying (20150930 Release):
  517 lines

Note there are still 2 ACPICA debugger patches not released during this
release cycle, so the debugger IO driver is not released in this cycle. In
this series the ACPICA debugger core is compile time enabled as all ACPICA
debugger files can be built with ACPI_DEBUGGER=y, but not runtime enabled
as there is no invocations calling ACPICA debugger APIs and its required
OSls are just stubs.

Bob Moore (8):
  ACPICA: Remove unnecessary conditional compilation.
  ACPICA: iASL: Add symbolic operator support for Index() operator.
  ACPICA: Update exception code for "file not found" error
  ACPICA: Debugger: Update mutexes used for multithreaded debugger
  ACPICA: Update NFIT table to rename a flags field
  ACPICA: Improve typechecking, both compile-time and runtime
  ACPICA: iASL: General cleanup of the file suffix #defines
  ACPICA: Update version to 20150930

Lv Zheng (5):
  ACPICA: Linuxize: Export debugger files to Linux
  ACPICA: Debugger: Fix "quit/exit" command by cleaning up user
commands termination logic
  ACPICA: Debugger: Fix "terminate" command by cleaning up subsystem
shutdown logic
  ACPI: Enable build of AML interpreter debugger
  ACPICA: Debugger: Fix dead lock issue ocurred in single stepping mode

 drivers/acpi/Kconfig  |9 +
 drivers/acpi/acpica/Makefile  |   16 +
 drivers/acpi/acpica/acapps.h  |2 +-
 drivers/acpi/acpica/acdebug.h |6 +
 drivers/acpi/acpica/acglobal.h|6 +-
 drivers/acpi/acpica/acinterp.h|2 -
 drivers/acpi/acpica/aclocal.h |   14 +-
 drivers/acpi/acpica/acnamesp.h|4 -
 drivers/acpi/acpica/acopcode.h|4 +-
 drivers/acpi/acpica/acparser.h|4 -
 drivers/acpi/acpica/acutils.h |2 -
 drivers/acpi/acpica/amlcode.h |   11 +-
 drivers/acpi/acpica/dbcmds.c  | 1187 +++
 drivers/acpi/acpica/dbconvert.c   |  484 +++
 drivers/acpi/acpica/dbdisply.c| 1108 +
 drivers/acpi/acpica/dbexec.c  |  763 +
 drivers/acpi/acpica/dbfileio.c|  256 ++
 drivers/acpi/acpica/dbhistry.c|  239 ++
 drivers/acpi/acpica/dbinput.c | 1267 +
 drivers/acpi/acpica/dbmethod.c|  369 +
 drivers/acpi/acpica/dbnames.c |  947 +
 drivers/acpi/acpica/dbobject.c|  533 
 drivers/acpi/acpica/dbstats.c |  546 +
 drivers/acpi/acpica/dbtest.c  | 1057 
 drivers/acpi/acpica/dbutils.c |  457 +++
 drivers/acpi/acpica/dbxface.c |  487 +++
 drivers/acpi/acpica/evxface.c |2 +-
 drivers/acpi/acpica/exconvrt.c|1 +
 drivers/acpi/acpica/exresolv.c|1 -
 drivers/acpi/acpica/exresop.c |2 +
 drivers/acpi/acpica/exstore.c |  120 ++-
 drivers/acpi/acpica/exstoren.c|5 +-
 drivers/acpi/acpica/nsdump.c  |6 -
 drivers/acpi/acpica/nspredef.c|2 +-
 drivers/acpi/acpica/pstree.c  |2 -
 drivers/acpi/acpica/psutils.c |2 -
 drivers/acpi/acpica/rsdump.c  |3 -
 drivers/acpi/acpica/rsutils.c |2 -
 drivers/acpi/acpica/rsxface.c |4 +-
 drivers/acpi/acpica/utdecode.c|   21 +-
 drivers/acpi/acpica/utfileio.c|6 +
 drivers/acpi/acpica/utinit.c  |   15 +-
 drivers/acpi/acpica/utmutex.c |   21 +
 dr

[PATCH 11/13] ACPI: Enable build of AML interpreter debugger

2015-10-14 Thread Lv Zheng
This patch enables ACPICA debugger files using a configurable
CONFIG_ACPI_DEBUGGER configuration item. Those debugger related code that
was originally masked as ACPI_FUTURE_USAGE now gets unmasked.

Necessary OSL stubs are also added in this patch:
1. acpi_os_readable(): This should be arch specific in Linux, while this
patch doesn't introduce real implementation and a complex mechanism to
allow architecture specific acpi_os_readable() to be implemented to
validate the address. It may be done by future commits.
2. acpi_os_get_line(): This is used to obtain debugger command input. This
patch only introduces a simple KDB concept example in it and the
example should be co-working with the code implemented in
acpi_os_printf(). Since this KDB example won't be compiled unless
ENABLE_DEBUGGER is defined and it seems Linux has already stopped to
use ENABLE_DEBUGGER, thus do not expect it can work properly.

This patch also cleans up all other ACPI_FUTURE_USAGE surroundings
accordingly.
1. Since linkage error can be automatically detected, declaration in the
   headers needn't be surrounded by ACPI_FUTURE_USAGE.
   So only the following separate exported fuction bodies are masked by
   this macro (other exported fucntions may have already been masked at
   entire module level via drivers/acpi/acpica/Makefile):
 acpi_install_exception_handler()
 acpi_subsystem_status()
 acpi_get_system_info()
 acpi_get_statistics()
 acpi_install_initialization_handler()
2. Since strip can automatically zap the no-user functions, functions that
   are not marked with ACPI_EXPORT_SYMBOL() needn't get surrounded by
   ACPI_FUTURE_USAGE.
   So the following function which is not used by Linux kernel now won't
   get surrounded by this macro:
 acpi_ps_get_name()

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/Kconfig  |9 +
 drivers/acpi/acpica/Makefile  |   16 
 drivers/acpi/acpica/acinterp.h|2 --
 drivers/acpi/acpica/acnamesp.h|4 
 drivers/acpi/acpica/acparser.h|4 
 drivers/acpi/acpica/acutils.h |2 --
 drivers/acpi/acpica/evxface.c |2 +-
 drivers/acpi/acpica/nsdump.c  |6 --
 drivers/acpi/acpica/pstree.c  |2 --
 drivers/acpi/acpica/psutils.c |2 --
 drivers/acpi/acpica/rsutils.c |2 --
 drivers/acpi/acpica/rsxface.c |4 ++--
 drivers/acpi/acpica/utxface.c |2 +-
 drivers/acpi/osl.c|   11 +++
 include/acpi/acpixf.h |   10 --
 include/acpi/platform/aclinux.h   |7 +--
 include/acpi/platform/aclinuxex.h |5 +
 17 files changed, 42 insertions(+), 48 deletions(-)

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 5d1015c..706c2e9 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -57,6 +57,15 @@ config ACPI_SYSTEM_POWER_STATES_SUPPORT
 config ACPI_CCA_REQUIRED
bool
 
+config ACPI_DEBUGGER
+   bool "In-kernel debugger (EXPERIMENTAL)"
+   select ACPI_DEBUG
+   help
+ Enable in-kernel debugging facilities: statistics, internal
+ object dump, single step control method execution.
+ This is still under development, currently enabling this only
+ results in the compilation of the ACPICA debugger files.
+
 config ACPI_SLEEP
bool
depends on SUSPEND || HIBERNATION
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index fedcc16..a57f019 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -178,7 +178,23 @@ acpi-y +=  \
utxferror.o \
utxfmutex.o
 
+acpi-$(CONFIG_ACPI_DEBUGGER) +=\
+   dbcmds.o\
+   dbconvert.o \
+   dbdisply.o  \
+   dbexec.o\
+   dbhistry.o  \
+   dbinput.o   \
+   dbmethod.o  \
+   dbnames.o   \
+   dbobject.o  \
+   dbstats.o   \
+   dbutils.o   \
+   dbxface.o
+
 acpi-$(ACPI_FUTURE_USAGE) +=   \
+   dbfileio.o  \
+   dbtest.o\
utcache.o   \
utfileio.o  \
utprint.o   \
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index e820ed8..e9e936e 100644
--- a/drivers/acpi/acpica/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
@@ -397,12 +397,10 @@ void
 acpi_ex_dump_operands(union acpi_operand_object **operands,
  const char *opcode_name, u32 num_opcodes);
 
-#ifdef ACPI_FUTURE_USAGE
 void
 acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags);
 
 void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags);
-#endif /* ACPI_FUTURE_USAGE */
 
 /*
  * exnames - AML namestring support
diff --gi

[PATCH 13/13] ACPICA: Update version to 20150930

2015-10-14 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit e9c75ca267262326e80d49a290e8387a5963e2d2

Version 20150930.

Link: https://github.com/acpica/acpica/commit/e9c75ca2
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 include/acpi/acpixf.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 89a4018..b9ee2fb 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in MMDD format */
 
-#define ACPI_CA_VERSION 0x20150818
+#define ACPI_CA_VERSION 0x20150930
 
 #include 
 #include 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/13] ACPICA: Update exception code for "file not found" error

2015-10-14 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit ac1564c26d239348ef13455f61d5616f3961ff43

Used by the ACPICA applications.

This patch is a bit broken due to non-portable  inclusion as on
some platforms, there is no such a header file for their lib-c exports.
Fortunately, Linux doesn't compile utfileio.c for either the kernel
space ACPICA core (drivers/acpi/acpica) or the userspace ACPICA tools
(tools/power/acpi) for now, so it's safe to leave this patch as it is.

Link: https://github.com/acpica/acpica/commit/ac1564c2
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/utfileio.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/acpi/acpica/utfileio.c b/drivers/acpi/acpica/utfileio.c
index 75a94f5..d435b7b 100644
--- a/drivers/acpi/acpica/utfileio.c
+++ b/drivers/acpi/acpica/utfileio.c
@@ -45,6 +45,7 @@
 #include "accommon.h"
 #include "actables.h"
 #include "acapps.h"
+#include "errno.h"
 
 #ifdef ACPI_ASL_COMPILER
 #include "aslcompiler.h"
@@ -301,6 +302,11 @@ acpi_ut_read_table_from_file(char *filename, struct 
acpi_table_header ** table)
file = fopen(filename, "rb");
if (!file) {
perror("Could not open input file");
+
+   if (errno == ENOENT) {
+   return (AE_NOT_EXIST);
+   }
+
return (status);
}
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/13] ACPICA: Debugger: Fix "terminate" command by cleaning up subsystem shutdown logic

2015-10-14 Thread Lv Zheng
ACPICA commit 7e823714911480be47e310fb1b3590d289b9fd99

Segmentation fault can be seen for executing the "terminate" command. This
is because acpi_ut_subsystem_shutdown() is errnously called multiple times.

This patch cleans up acpi_ut_subsystem_shutdown() logics to fix this
issue. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/7e823714
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/dbinput.c |3 ++-
 drivers/acpi/acpica/utinit.c  |   13 +
 drivers/acpi/acpica/utxface.c |   13 -
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
index f8cddd6..0480254 100644
--- a/drivers/acpi/acpica/dbinput.c
+++ b/drivers/acpi/acpica/dbinput.c
@@ -1074,6 +1074,7 @@ acpi_db_command_dispatch(char *input_buffer,
 * re-creating the semaphores!
 */
 
+   acpi_gbl_db_terminate_loop = TRUE;
/*  acpi_initialize (NULL); */
break;
 
@@ -1151,7 +1152,7 @@ void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void 
*context)
acpi_status status = AE_OK;
acpi_status Mstatus;
 
-   while (status != AE_CTRL_TERMINATE) {
+   while (status != AE_CTRL_TERMINATE && !acpi_gbl_db_terminate_loop) {
acpi_gbl_method_executing = FALSE;
acpi_gbl_step_to_next_call = FALSE;
 
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index d8699df..ccd0745 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -282,6 +282,19 @@ void acpi_ut_subsystem_shutdown(void)
 {
ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
 
+   /* Just exit if subsystem is already shutdown */
+
+   if (acpi_gbl_shutdown) {
+   ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
+   return_VOID;
+   }
+
+   /* Subsystem appears active, go ahead and shut it down */
+
+   acpi_gbl_shutdown = TRUE;
+   acpi_gbl_startup_flags = 0;
+   ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
+
 #ifndef ACPI_ASL_COMPILER
 
/* Close the acpi_event Handling */
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index f183daf..a6b0eb0 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -67,19 +67,6 @@ acpi_status __init acpi_terminate(void)
 
ACPI_FUNCTION_TRACE(acpi_terminate);
 
-   /* Just exit if subsystem is already shutdown */
-
-   if (acpi_gbl_shutdown) {
-   ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
-   return_ACPI_STATUS(AE_OK);
-   }
-
-   /* Subsystem appears active, go ahead and shut it down */
-
-   acpi_gbl_shutdown = TRUE;
-   acpi_gbl_startup_flags = 0;
-   ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
-
/* Shutdown and free all resources */
 
acpi_ut_subsystem_shutdown();
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/13] ACPICA: Debugger: Fix dead lock issue ocurred in single stepping mode

2015-10-14 Thread Lv Zheng
ACPICA commit 35273add90da19cd8790fdb5735f52e3c9861684

When single step execution is not ended, executing another control methods
leads to dead locks around interpreter lock/namespace lock/method
serialization lock. So we should only allow one execution from the debugger
at same time. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/35273add
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/dbexec.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/acpi/acpica/dbexec.c b/drivers/acpi/acpica/dbexec.c
index 8eef298..9da2daa 100644
--- a/drivers/acpi/acpica/dbexec.c
+++ b/drivers/acpi/acpica/dbexec.c
@@ -370,7 +370,17 @@ acpi_db_execute(char *name, char **args, acpi_object_type 
* types, u32 flags)
 #ifdef ACPI_DEBUG_OUTPUT
u32 previous_allocations;
u32 allocations;
+#endif
 
+   /*
+* Allow one execution to be performed by debugger or single step
+* execution will be dead locked by the interpreter mutexes.
+*/
+   if (acpi_gbl_method_executing) {
+   acpi_os_printf("Only one debugger execution is allowed.\n");
+   return;
+   }
+#ifdef ACPI_DEBUG_OUTPUT
/* Memory allocation tracking */
 
previous_allocations = acpi_db_get_outstanding_allocations();
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/13] ACPICA: Debugger: Update mutexes used for multithreaded debugger

2015-10-14 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 6b2701f619040e803313363f516b200e362a9100

Make these mutex objects independent of the deadlock detection mechanism.
This mechanism caused failures with the multithread debugger.

This patch doesn't affect Linux kernel as debugger is currently not fully
functioning in the Linux kernel. And the further debugger cleanups will
take care of handling debugger command signalling correctly instead of
using such kind of mutexes. So it is safe to leave this patch as it is.

Link: https://github.com/acpica/acpica/commit/6b2701f6
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acglobal.h |3 +++
 drivers/acpi/acpica/aclocal.h  |4 +---
 drivers/acpi/acpica/utdecode.c |2 --
 drivers/acpi/acpica/utmutex.c  |   21 +
 include/acpi/platform/acenv.h  |6 +++---
 5 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 09f37b5..593de41 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -357,6 +357,9 @@ ACPI_GLOBAL(u16, acpi_gbl_node_type_count_misc);
 ACPI_GLOBAL(u32, acpi_gbl_num_nodes);
 ACPI_GLOBAL(u32, acpi_gbl_num_objects);
 
+ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_ready);
+ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_complete);
+
 #endif /* ACPI_DEBUGGER */
 
 /*
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 8a66fef..918f70d 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -83,10 +83,8 @@ union acpi_parse_object;
 #define ACPI_MTX_EVENTS 3  /* Data for ACPI events */
 #define ACPI_MTX_CACHES 4  /* Internal caches, general 
purposes */
 #define ACPI_MTX_MEMORY 5  /* Debug memory tracking lists 
*/
-#define ACPI_MTX_DEBUG_CMD_COMPLETE 6  /* AML debugger */
-#define ACPI_MTX_DEBUG_CMD_READY7  /* AML debugger */
 
-#define ACPI_MAX_MUTEX  7
+#define ACPI_MAX_MUTEX  5
 #define ACPI_NUM_MUTEX  ACPI_MAX_MUTEX+1
 
 /* Lock structure for reader/writer interfaces */
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
index 988e23b..d452a78 100644
--- a/drivers/acpi/acpica/utdecode.c
+++ b/drivers/acpi/acpica/utdecode.c
@@ -407,8 +407,6 @@ static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
"ACPI_MTX_Events",
"ACPI_MTX_Caches",
"ACPI_MTX_Memory",
-   "ACPI_MTX_CommandComplete",
-   "ACPI_MTX_CommandReady"
 };
 
 char *acpi_ut_get_mutex_name(u32 mutex_id)
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 37b8b58..ce406e3 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -108,6 +108,21 @@ acpi_status acpi_ut_mutex_initialize(void)
/* Create the reader/writer lock for namespace access */
 
status = acpi_ut_create_rw_lock(_gbl_namespace_rw_lock);
+   if (ACPI_FAILURE(status)) {
+   return_ACPI_STATUS(status);
+   }
+#ifdef ACPI_DEBUGGER
+
+   /* Debugger Support */
+
+   status = acpi_os_create_mutex(_gbl_db_command_ready);
+   if (ACPI_FAILURE(status)) {
+   return_ACPI_STATUS(status);
+   }
+
+   status = acpi_os_create_mutex(_gbl_db_command_complete);
+#endif
+
return_ACPI_STATUS(status);
 }
 
@@ -147,6 +162,12 @@ void acpi_ut_mutex_terminate(void)
/* Delete the reader/writer lock */
 
acpi_ut_delete_rw_lock(_gbl_namespace_rw_lock);
+
+#ifdef ACPI_DEBUGGER
+   acpi_os_delete_mutex(acpi_gbl_db_command_ready);
+   acpi_os_delete_mutex(acpi_gbl_db_command_complete);
+#endif
+
return_VOID;
 }
 
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index 15ef08c..056f245 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -304,11 +304,11 @@
  * multi-threaded if ACPI_APPLICATION is not set.
  */
 #ifndef DEBUGGER_THREADING
-#ifdef ACPI_APPLICATION
-#define DEBUGGER_THREADING  DEBUGGER_SINGLE_THREADED
+#if !defined (ACPI_APPLICATION) || defined (ACPI_EXEC_APP)
+#define DEBUGGER_THREADING  DEBUGGER_MULTI_THREADED
 
 #else
-#define DEBUGGER_THREADING  DEBUGGER_MULTI_THREADED
+#define DEBUGGER_THREADING  DEBUGGER_SINGLE_THREADED
 #endif
 #endif /* !DEBUGGER_THREADING */
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/13] ACPICA: iASL: Add symbolic operator support for Index() operator.

2015-10-14 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit fbe67c46830f10c839941f8512cac5bddcb86bd3

Index (, 2) is now supported by  [2]

This patch doesn't affect Linux kernel.

Link: https://github.com/acpica/acpica/commit/fbe67c46
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/aclocal.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 6f70826..8a66fef 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -848,7 +848,7 @@ struct acpi_parse_state {
 #define ACPI_PARSEOP_PARAMLIST  0x02
 #define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
 #define ACPI_PARSEOP_PREDEF_CHECKED 0x08
-#define ACPI_PARSEOP_SPECIAL0x10
+#define ACPI_PARSEOP_CLOSING_PAREN  0x10
 #define ACPI_PARSEOP_COMPOUND   0x20
 #define ACPI_PARSEOP_ASSIGNMENT 0x40
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/20] ACPICA: Table handling: Cleanup and update debug output for tools.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit 93862bd7a227543bc617d822ef5c4f8a5d68b519

Add output of table OEM ID along with signature to support lots
of SSDTs.

Cleanup use of table pointers.

Link: https://github.com/acpica/acpica/commit/93862bd7
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/dsinit.c   |   11 +
 drivers/acpi/acpica/tbxfload.c |   53 ++--
 2 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index bbf52f0..920f1b1 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -247,11 +247,12 @@ acpi_ds_initialize_objects(u32 table_index,
/* Summary of objects initialized */
 
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
- Table [%4.4s] (id %4.4X) - %4u Objects with %3u 
Devices, 
- %3u Regions, %3u Methods (%u/%u/%u 
Serial/Non/Cvt)\n,
- table-signature, owner_id, info.object_count,
- info.device_count, info.op_region_count,
- info.method_count, info.serial_method_count,
+ Table [%4.4s:%8.8s] (id %.2X) - %4u Objects with 
%3u Devices, 
+ %3u Regions, %4u Methods (%u/%u/%u 
Serial/Non/Cvt)\n,
+ table-signature, table-oem_table_id, owner_id,
+ info.object_count, info.device_count,
+ info.op_region_count, info.method_count,
+ info.serial_method_count,
  info.non_serial_method_count,
  info.serialized_method_count));
 
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index 96b82a8..55ee14c 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -105,6 +105,7 @@ acpi_status acpi_tb_load_namespace(void)
acpi_status status;
u32 i;
struct acpi_table_header *new_dsdt;
+   struct acpi_table_desc *table;
u32 tables_loaded = 0;
u32 tables_failed = 0;
 
@@ -116,15 +117,11 @@ acpi_status acpi_tb_load_namespace(void)
 * Load the namespace. The DSDT is required, but any SSDT and
 * PSDT tables are optional. Verify the DSDT.
 */
+   table = acpi_gbl_root_table_list.tables[acpi_gbl_dsdt_index];
+
if (!acpi_gbl_root_table_list.current_table_count ||
-   !ACPI_COMPARE_NAME(
-  (acpi_gbl_root_table_list.
-   tables[acpi_gbl_dsdt_index].signature),
-  ACPI_SIG_DSDT)
-   ||
-   ACPI_FAILURE(acpi_tb_validate_table
-(acpi_gbl_root_table_list.
- tables[acpi_gbl_dsdt_index]))) {
+   !ACPI_COMPARE_NAME(table-signature.ascii, ACPI_SIG_DSDT) ||
+   ACPI_FAILURE(acpi_tb_validate_table(table))) {
status = AE_NO_ACPI_TABLES;
goto unlock_and_exit;
}
@@ -135,8 +132,7 @@ acpi_status acpi_tb_load_namespace(void)
 * array can change dynamically as tables are loaded at run-time. Note:
 * .Pointer field is not validated until after call to 
acpi_tb_validate_table.
 */
-   acpi_gbl_DSDT =
-   acpi_gbl_root_table_list.tables[acpi_gbl_dsdt_index].pointer;
+   acpi_gbl_DSDT = table-pointer;
 
/*
 * Optionally copy the entire DSDT to local memory (instead of simply
@@ -174,21 +170,15 @@ acpi_status acpi_tb_load_namespace(void)
 
(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
for (i = 0; i  acpi_gbl_root_table_list.current_table_count; ++i) {
+   table = acpi_gbl_root_table_list.tables[i];
+
if (!acpi_gbl_root_table_list.tables[i].address ||
-   (!ACPI_COMPARE_NAME
-((acpi_gbl_root_table_list.tables[i].signature),
- ACPI_SIG_SSDT)
-
-!ACPI_COMPARE_NAME(
-   (acpi_gbl_root_table_list.tables[i].
-signature), ACPI_SIG_PSDT)
-
-!ACPI_COMPARE_NAME(
-   (acpi_gbl_root_table_list.tables[i].
-signature), ACPI_SIG_OSDT))
-   ||
-   ACPI_FAILURE(acpi_tb_validate_table
-(acpi_gbl_root_table_list.tables[i]))) {
+   (!ACPI_COMPARE_NAME(table-signature.ascii, ACPI_SIG_SSDT)
+ !ACPI_COMPARE_NAME(table-signature.ascii,
+  ACPI_SIG_PSDT)
+ !ACPI_COMPARE_NAME(table-signature.ascii

[PATCH 12/20] ACPICA: Add additional debug info/statements.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit 74094ca9f51e2652a9b5f01722d8640a653cc75a

For _REG methods and module-level code blocks.
For acpiexec, add deletion of module-level blocks in case
of an early abort.

Link: https://github.com/acpica/acpica/commit/74094ca9
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/aclocal.h  |7 +++
 drivers/acpi/acpica/evregion.c |   22 ++
 drivers/acpi/acpica/nseval.c   |3 ++-
 drivers/acpi/acpica/nsutils.c  |   17 +
 drivers/acpi/acpica/psloop.c   |   14 +-
 5 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 92cbaee..acbf68b 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -406,6 +406,13 @@ struct acpi_simple_repair_info {
 
 #define ACPI_NUM_RTYPES 5  /* Number of actual object 
types */
 
+/* Info for running the _REG methods */
+
+struct acpi_reg_walk_info {
+   acpi_adr_space_type space_id;
+   u32 reg_run_count;
+};
+
 /*
  *
  * Event typedefs and structs
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 2ba28a6..5ee79a1 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -626,9 +626,17 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node 
*node,
acpi_adr_space_type space_id)
 {
acpi_status status;
+   struct acpi_reg_walk_info info;
 
ACPI_FUNCTION_TRACE(ev_execute_reg_methods);
 
+   info.space_id = space_id;
+   info.reg_run_count = 0;
+
+   ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
+ Running _REG methods for SpaceId %s\n,
+ acpi_ut_get_region_name(info.space_id)));
+
/*
 * Run all _REG methods for all Operation Regions for this space ID. 
This
 * is a separate walk in order to handle any interdependencies between
@@ -637,7 +645,7 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node 
*node,
 */
status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
-   NULL, space_id, NULL);
+   NULL, info, NULL);
 
/* Special case for EC: handle orphan _REG methods with no region */
 
@@ -645,6 +653,11 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node 
*node,
acpi_ev_orphan_ec_reg_method(node);
}
 
+   ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
+ Executed %u _REG methods for SpaceId %s\n,
+ info.reg_run_count,
+ acpi_ut_get_region_name(info.space_id)));
+
return_ACPI_STATUS(status);
 }
 
@@ -664,10 +677,10 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 {
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
-   acpi_adr_space_type space_id;
acpi_status status;
+   struct acpi_reg_walk_info *info;
 
-   space_id = *ACPI_CAST_PTR(acpi_adr_space_type, context);
+   info = ACPI_CAST_PTR(struct acpi_reg_walk_info, context);
 
/* Convert and validate the device handle */
 
@@ -696,13 +709,14 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 
/* Object is a Region */
 
-   if (obj_desc-region.space_id != space_id) {
+   if (obj_desc-region.space_id != info-space_id) {
 
/* This region is for a different address space, just ignore it 
*/
 
return (AE_OK);
}
 
+   info-reg_run_count++;
status = acpi_ev_execute_reg_method(obj_desc, ACPI_REG_CONNECT);
return (status);
 }
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index 88822b7a..7eba578 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -465,7 +465,8 @@ acpi_ns_exec_module_code(union acpi_operand_object 
*method_obj,
 
status = acpi_ns_evaluate(info);
 
-   ACPI_DEBUG_PRINT((ACPI_DB_INIT, Executed module-level code at %p\n,
+   ACPI_DEBUG_PRINT((ACPI_DB_INIT_NAMES,
+ Executed module-level code at %p\n,
  method_obj-method.aml_start));
 
/* Delete a possible implicit return value (in slack mode) */
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index 9a34c5f..d1261fe 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -596,6 +596,23 @@ void acpi_ns_terminate(void)
 
ACPI_FUNCTION_TRACE(ns_terminate);
 
+#ifdef ACPI_EXEC_APP
+   {
+   union acpi_operand_object *prev;
+   union acpi_operand_object *next

[PATCH 10/20] ACPICA: acpiexec/acpinames: Support very large number of ACPI tables.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit ca3bd4c5cdc39a9009280032adbbc20f34e94c47

Fix a couple of issues with 40 ACPI tables.
Return exit error for acpinames to enable use with BIOS builds.

The new exported function is used by acpinames. For Linux kernel, this
change is a no-op.

Link: https://github.com/acpica/acpica/commit/ca3bd4c5
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/actables.h |5 +
 drivers/acpi/acpica/tbxfload.c |   17 -
 drivers/acpi/acpica/utfileio.c |2 +-
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index ab7f3a0..f7731f2 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -165,4 +165,9 @@ acpi_status acpi_tb_parse_root_table(acpi_physical_address 
rsdp_address);
 
 u8 acpi_is_valid_signature(char *signature);
 
+/*
+ * tbxfload
+ */
+acpi_status acpi_tb_load_namespace(void);
+
 #endif /* __ACTABLES_H__ */
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index fb4d4e6..96b82a8 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -51,9 +51,6 @@
 #define _COMPONENT  ACPI_TABLES
 ACPI_MODULE_NAME(tbxfload)
 
-/* Local prototypes */
-static acpi_status acpi_tb_load_namespace(void);
-
 
/***
  *
  * FUNCTION:acpi_load_tables
@@ -65,7 +62,6 @@ static acpi_status acpi_tb_load_namespace(void);
  * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
  *
  
**/
-
 acpi_status __init acpi_load_tables(void)
 {
acpi_status status;
@@ -75,6 +71,13 @@ acpi_status __init acpi_load_tables(void)
/* Load the namespace from the tables */
 
status = acpi_tb_load_namespace();
+
+   /* Don't let single failures abort the load */
+
+   if (status == AE_CTRL_TERMINATE) {
+   status = AE_OK;
+   }
+
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status,
While loading namespace from ACPI tables));
@@ -97,7 +100,7 @@ ACPI_EXPORT_SYMBOL_INIT(acpi_load_tables)
  *  the RSDT/XSDT.
  *
  
**/
-static acpi_status acpi_tb_load_namespace(void)
+acpi_status acpi_tb_load_namespace(void)
 {
acpi_status status;
u32 i;
@@ -214,6 +217,10 @@ static acpi_status acpi_tb_load_namespace(void)
ACPI_ERROR((AE_INFO,
%u ACPI AML tables successfully acquired and 
loaded, %u failed,
tables_loaded, tables_failed));
+
+   /* Indicate at least one failure */
+
+   status = AE_CTRL_TERMINATE;
}
 
 unlock_and_exit:
diff --git a/drivers/acpi/acpica/utfileio.c b/drivers/acpi/acpica/utfileio.c
index 857af82..75a94f5 100644
--- a/drivers/acpi/acpica/utfileio.c
+++ b/drivers/acpi/acpica/utfileio.c
@@ -312,7 +312,7 @@ acpi_ut_read_table_from_file(char *filename, struct 
acpi_table_header ** table)
/* Get the entire file */
 
fprintf(stderr,
-   Reading ACPI table from file %10s - Length %.8u (0x%06X)\n,
+   Reading ACPI table from file %12s - Length %.8u (0x%06X)\n,
filename, file_size, file_size);
 
status = acpi_ut_read_table(file, table, table_length);
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/20] ACPICA: Debugger: Add option to display namespace summary/counts.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit bba222c15c2ce79076eb3a5e9d4d5f7120db8a00

If Objects command is invoked with no arguments, the counts
for each object type are displayed.

Linux kernel is not affected by this commit as currently debugger is
not enabled in the Linux kernel.

Link: https://github.com/acpica/acpica/commit/bba222c1
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/acglobal.h |4 ++--
 drivers/acpi/acpica/aclocal.h  |4 
 include/acpi/actypes.h |2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 95ed861..c597192 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -346,8 +346,8 @@ ACPI_GLOBAL(char, 
acpi_gbl_db_debug_filename[ACPI_DB_LINE_BUFFER_SIZE]);
 /*
  * Statistic globals
  */
-ACPI_GLOBAL(u16, acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX + 1]);
-ACPI_GLOBAL(u16, acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX + 1]);
+ACPI_GLOBAL(u16, acpi_gbl_obj_type_count[ACPI_TOTAL_TYPES]);
+ACPI_GLOBAL(u16, acpi_gbl_node_type_count[ACPI_TOTAL_TYPES]);
 ACPI_GLOBAL(u16, acpi_gbl_obj_type_count_misc);
 ACPI_GLOBAL(u16, acpi_gbl_node_type_count_misc);
 ACPI_GLOBAL(u32, acpi_gbl_num_nodes);
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index acbf68b..6f70826 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -1131,6 +1131,10 @@ struct acpi_integrity_info {
 #define ACPI_DB_CONSOLE_OUTPUT  0x02
 #define ACPI_DB_DUPLICATE_OUTPUT0x03
 
+struct acpi_object_info {
+   u32 types[ACPI_TOTAL_TYPES];
+};
+
 /*
  *
  * Debug
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 531eca4..f914958 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -662,6 +662,7 @@ typedef u32 acpi_object_type;
 #define ACPI_TYPE_DEBUG_OBJECT  0x10
 
 #define ACPI_TYPE_EXTERNAL_MAX  0x10
+#define ACPI_NUM_TYPES  (ACPI_TYPE_EXTERNAL_MAX + 1)
 
 /*
  * These are object types that do not map directly to the ACPI
@@ -683,6 +684,7 @@ typedef u32 acpi_object_type;
 #define ACPI_TYPE_LOCAL_SCOPE   0x1B   /* 1 Name, multiple object_list 
Nodes */
 
 #define ACPI_TYPE_NS_NODE_MAX   0x1B   /* Last typecode used within a 
NS Node */
+#define ACPI_TOTAL_TYPES(ACPI_TYPE_NS_NODE_MAX + 1)
 
 /*
  * These are special object types that never appear in
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/20] ACPICA: Headers: Fix some comments, no functional change.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit 539f8c03fe64305725bd85343e42f3b6c42aad14

A couple typos and long lines.

Link: https://github.com/acpica/acpica/commit/539f8c03
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 include/acpi/platform/acenv.h |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index 3cedd43..1332537 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -89,8 +89,8 @@
 #endif
 
 /*
- * acpi_bin/acpi_dump/acpi_help/acpi_names/acpi_src/acpi_xtract/Example 
configuration.
- * All single threaded.
+ * acpi_bin/acpi_dump/acpi_help/acpi_names/acpi_src/acpi_xtract/Example
+ * configuration. All single threaded.
  */
 #if (defined ACPI_BIN_APP)  || \
(defined ACPI_DUMP_APP) || \
@@ -123,7 +123,7 @@
 #define ACPI_USE_NATIVE_RSDP_POINTER
 #endif
 
-/* acpi_dump configuration. Native mapping used if provied by OSPMs */
+/* acpi_dump configuration. Native mapping used if provided by the host */
 
 #ifdef ACPI_DUMP_APP
 #define ACPI_USE_NATIVE_MEMORY_MAPPING
@@ -323,8 +323,8 @@
  * ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
  *  the standard header files may be used.
  *
- * The ACPICA subsystem only uses low level C library functions that do not 
call
- * operating system services and may therefore be inlined in the code.
+ * The ACPICA subsystem only uses low level C library functions that do not
+ * call operating system services and may therefore be inlined in the code.
  *
  * It may be necessary to tailor these include files to the target
  * generation environment.
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 20/20] ACPICA: Update version to 20150818.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit d93470de8febeecdc20633fde11cb0b200fa773b

Version 20150818.

Link: https://github.com/acpica/acpica/commit/d93470de
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 include/acpi/acpixf.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index d3d7ea0..c33eeab 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in MMDD format */
 
-#define ACPI_CA_VERSION 0x20150717
+#define ACPI_CA_VERSION 0x20150818
 
 #include acpi/acconfig.h
 #include acpi/actypes.h
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 17/20] ACPICA: Disassembler: Cleanup acpi_gbl_db_opt_disasm.

2015-08-24 Thread Lv Zheng
ACPICA commit 969989cf7f85e2a2a0cd048cd25fc706246a48a2

This patch cleans up the following global variable - acpi_gbl_db_opt_disasm:
The setting is used to control the full disassembly feature for iasl. ACPI
debugger (acpiexec) shall have nothing to do with it. Actually, acpiexec
never links to ad_aml_disassemble().

This patch thus renames this global option to acpi_gbl_dm_opt_disasm and
removes all acpiexec and debugger references on it. Lv Zheng.

This patch doesn't affect Linux kernel.

Link: https://github.com/acpica/acpica/commit/969989cf
Signed-off-by: Lv Zheng lv.zh...@intel.com
Signed-off-by: Bob Moore robert.mo...@intel.com
---
 drivers/acpi/acpica/acglobal.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 03c443b..0007eb7 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -313,7 +313,7 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_ignore_noop_operator, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_cstyle_disassembly, TRUE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_force_aml_disassembly, FALSE);
 
-ACPI_GLOBAL(u8, acpi_gbl_db_opt_disasm);
+ACPI_GLOBAL(u8, acpi_gbl_dm_opt_disasm);
 ACPI_GLOBAL(u8, acpi_gbl_dm_opt_listing);
 ACPI_GLOBAL(u8, acpi_gbl_db_opt_verbose);
 ACPI_GLOBAL(u8, acpi_gbl_num_external_methods);
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19/20] ACPICA: Debugger: Cleanup debugging outputs to dump name path without trailing underscores.

2015-08-24 Thread Lv Zheng
ACPICA commit 51a49c2fb4a73f302a6df2b8ddc1350dd261684d

It is better to use unified ASL path name to interact with the developers.

There are following acpi_ns_build_normalized_pathname() users invoking it for
debugging purposes (acpiexec test results are attached):

1. acpi_ut_display_init_pathname (acpi_ns_handle_to_pathname):
 -
  Initializing Region\_SB.H_EC.ECF2
 -
2. acpi_ns_print_node_pathname (acpi_ns_handle_to_pathname):
 -
 - ex \_SB.H_EC._STA
 Evaluating \_SB.H_EC._STA
 -
3. acpi_ds_print_node_pathname (acpi_ns_handle_to_pathname):
 -
 - level 211b console
 - execute \M1
 ...
  Exception AE_AML_UNINITIALIZED_ARG during execution of method [\M1] 
(Node 009CB6B8)
 -
4. acpi_ex_dump_reference_obj (acpi_ns_handle_to_pathname):
 -
 - dump \_TZ.FAN4._PR0
 ...
 [00] 00835E98 [Object Reference] Type [Named Object] 05 00828878 \_TZ.FN04
 -
5. acpi_db_bus_walk (acpi_ns_handle_to_pathname):
 -
 - businfo
 \_SB.PCI0Type 6
 ...
 -
6. acpi_db_walk_and_match_name (acpi_ns_handle_to_pathname):
 -
 - find _PR0
   \_TZ.FAN4._PR0 Package  002D8DF8 01 Elements 01
 -
7. acpi_db_walk_for_specific_objects (acpi_ns_handle_to_pathname):
 -
 - methods
 ...
   \_SB.PCI0._PRT Method   0026D918 01 Args 0 Len 0005 
Aml 0026B199
 ...
 -
8. acpi_db_decode_and_dispaly_object (acpi_get_name):
 -
 - gpes
 Block 0 - Info 003AC7B0  device_node 003A0E08 [\_GPE] - FADT-defined GPE 
block
 ...
 -
9. acpi_db_display_gpes (acpi_get_name):
 -
 - dump \_GPE
 Object (003A0E08) Pathname:  \_GPE
 -
10.ae_miscellaneous_tests (acpi_get_name):
 No output available

This patch cleans up all of the above usages. ACPICA BZ 1178, Lv Zheng.

Linux kernel's ACPICA debugging messages may also be changed.

Link: https://github.com/acpica/acpica/commit/51a49c2f
Signed-off-by: Lv Zheng lv.zh...@intel.com
Signed-off-by: Bob Moore robert.mo...@intel.com
---
 drivers/acpi/acpica/dsdebug.c |2 +-
 drivers/acpi/acpica/exdump.c  |2 +-
 drivers/acpi/acpica/nsutils.c |2 +-
 drivers/acpi/acpica/utmisc.c  |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpica/dsdebug.c b/drivers/acpi/acpica/dsdebug.c
index a651d30..309556e 100644
--- a/drivers/acpi/acpica/dsdebug.c
+++ b/drivers/acpi/acpica/dsdebug.c
@@ -89,7 +89,7 @@ acpi_ds_print_node_pathname(struct acpi_namespace_node *node,
 
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
 
-   status = acpi_ns_handle_to_pathname(node, buffer, FALSE);
+   status = acpi_ns_handle_to_pathname(node, buffer, TRUE);
if (ACPI_SUCCESS(status)) {
if (message) {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH, %s ,
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index b6495fb..d836f88 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -996,7 +996,7 @@ static void acpi_ex_dump_reference_obj(union 
acpi_operand_object *obj_desc)
acpi_os_printf( %p , obj_desc-reference.node);
 
status = acpi_ns_handle_to_pathname(obj_desc-reference.node,
-   ret_buf, FALSE);
+   ret_buf, TRUE);
if (ACPI_FAILURE(status)) {
acpi_os_printf( Could not convert name to pathname\n);
} else {
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index d1261fe..de325ae 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -83,7 +83,7 @@ acpi_ns_print_node_pathname(struct acpi_namespace_node *node,
 
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
 
-   status = acpi_ns_handle_to_pathname(node, buffer, FALSE);
+   status = acpi_ns_handle_to_pathname(node, buffer, TRUE);
if (ACPI_SUCCESS(status)) {
if (message) {
acpi_os_printf(%s , message);
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi

[PATCH 18/20] ACPICA: Disassembler: Cleanup acpi_gbl_db_opt_verbose acpiexec usage.

2015-08-24 Thread Lv Zheng
ACPICA commit 42d7ad7bfb1cfb95183c1386c77509f2036f521d

When acpi_gbl_db_opt_verbose is used in acpi_dm_descending_op() (invoked by
acpi_dm_disassemble()), it is actually exported by the disassembler but used
by the debugger to distinguish the output of the disassembler for different
debugger commands. It is by default TRUE but is set to FALSE for control
method disassembly command - disassemble. So it's initialization should
be a part of the ACPI_DISASSEMBLER conditioned code. This patch uses
ACPI_INIT_GLOBAL to achieve a clean manner so that when ACPI_DISASSEMBLER
is not defined, ACPI_DEBUGGER conditioned code needn't link to this option.
Since it is a disassembler exported variable, it is renamed to
acpi_gbl_dm_opt_Verbose in this patch.

As VERBOSE_PRINT() macro has only one user, this patch also removes the
definition of this macro. Lv Zheng.

This patch doesn't affect Linux kernel.

Link: https://github.com/acpica/acpica/commit/42d7ad7b
Signed-off-by: Lv Zheng lv.zh...@intel.com
Signed-off-by: Bob Moore robert.mo...@intel.com
---
 drivers/acpi/acpica/acdebug.h  |3 ---
 drivers/acpi/acpica/acglobal.h |2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 447f6d3..eb2e926 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -67,9 +67,6 @@ struct acpi_db_execute_walk {
 };
 
 #define PARAM_LIST(pl)  pl
-#define DBTEST_OUTPUT_LEVEL(lvl)if (acpi_gbl_db_opt_verbose)
-#define VERBOSE_PRINT(fp)   DBTEST_OUTPUT_LEVEL(lvl) {\
- acpi_os_printf PARAM_LIST(fp);}
 
 #define EX_NO_SINGLE_STEP   1
 #define EX_SINGLE_STEP  2
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 0007eb7..09f37b5 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -312,10 +312,10 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_no_resource_disassembly, 
FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_ignore_noop_operator, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_cstyle_disassembly, TRUE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_force_aml_disassembly, FALSE);
+ACPI_INIT_GLOBAL(u8, acpi_gbl_dm_opt_verbose, TRUE);
 
 ACPI_GLOBAL(u8, acpi_gbl_dm_opt_disasm);
 ACPI_GLOBAL(u8, acpi_gbl_dm_opt_listing);
-ACPI_GLOBAL(u8, acpi_gbl_db_opt_verbose);
 ACPI_GLOBAL(u8, acpi_gbl_num_external_methods);
 ACPI_GLOBAL(u32, acpi_gbl_resolved_external_methods);
 ACPI_GLOBAL(struct acpi_external_list *, acpi_gbl_external_list);
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 14/20] ACPICA: Make the max-number-of-loops runtime configurable.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit a9d9c2d0c2d077bb3175ec9c252cf0e5da3efd45

Was previously compile-time only.
Add support option for acpiexec.

Link: https://github.com/acpica/acpica/commit/a9d9c2d0
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/acglobal.h  |4 
 drivers/acpi/acpica/dscontrol.c |2 +-
 drivers/acpi/acpica/utinit.c|1 +
 include/acpi/acconfig.h |4 
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index c597192..03c443b 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -236,6 +236,10 @@ ACPI_INIT_GLOBAL(u32, acpi_gbl_nesting_level, 0);
 
 ACPI_GLOBAL(struct acpi_thread_state *, acpi_gbl_current_walk_list);
 
+/* Maximum number of While() loop iterations before forced abort */
+
+ACPI_GLOBAL(u16, acpi_gbl_max_loop_iterations);
+
 /* Control method single step flag */
 
 ACPI_GLOBAL(u8, acpi_gbl_cm_single_step);
diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c
index 39da9da..435fc16 100644
--- a/drivers/acpi/acpica/dscontrol.c
+++ b/drivers/acpi/acpica/dscontrol.c
@@ -212,7 +212,7 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * 
walk_state,
 */
control_state-control.loop_count++;
if (control_state-control.loop_count 
-   ACPI_MAX_LOOP_ITERATIONS) {
+   acpi_gbl_max_loop_iterations) {
status = AE_AML_INFINITE_LOOP;
break;
}
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index 7f897c6..28ab3a1 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -207,6 +207,7 @@ acpi_status acpi_ut_init_globals(void)
acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
acpi_gbl_osi_mutex = NULL;
acpi_gbl_reg_methods_executed = FALSE;
+   acpi_gbl_max_loop_iterations = 0x;
 
/* Hardware oriented */
 
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index 03aacfb..e11611c 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -136,10 +136,6 @@
 
 #define ACPI_ROOT_TABLE_SIZE_INCREMENT  4
 
-/* Maximum number of While() loop iterations before forced abort */
-
-#define ACPI_MAX_LOOP_ITERATIONS0x
-
 /* Maximum sleep allowed via Sleep() operator */
 
 #define ACPI_MAX_SLEEP  2000   /* 2000 millisec == two seconds 
*/
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 15/20] ACPICA: Header support to improve compatibility with MSVC.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit 5b4087fba991d8383046b550bbe22f3d8d9b9c8f

Needed to improve MSVC editor support for symbols.

For Linux kernel, this change is a no-op.

Link: https://github.com/acpica/acpica/commit/5b4087fb
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 include/acpi/platform/acenv.h |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index 1332537..ec00e2b 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -70,13 +70,14 @@
 
 #ifdef ACPI_ASL_COMPILER
 #define ACPI_APPLICATION
-#define ACPI_DISASSEMBLER
 #define ACPI_DEBUG_OUTPUT
 #define ACPI_CONSTANT_EVAL_ONLY
 #define ACPI_LARGE_NAMESPACE_NODE
 #define ACPI_DATA_TABLE_DISASSEMBLY
 #define ACPI_SINGLE_THREADED
 #define ACPI_32BIT_PHYSICAL_ADDRESS
+
+#define ACPI_DISASSEMBLER 1
 #endif
 
 /* acpi_exec configuration. Multithreaded with full AML debugger */
@@ -151,12 +152,12 @@
 #define ACPI_USE_LOCAL_CACHE
 #endif
 
-/* Common debug support */
+/* Common debug/disassembler support */
 
 #ifdef ACPI_FULL_DEBUG
-#define ACPI_DEBUGGER
 #define ACPI_DEBUG_OUTPUT
-#define ACPI_DISASSEMBLER
+#define ACPI_DEBUGGER 1
+#define ACPI_DISASSEMBLER 1
 #endif
 
 
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/20] ACPICA: Disassembler: Update for new listing mode.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit 2ed09bb7619d25f5a5c065c33a8a775a6db3a856
ACPICA commit 2fefacf73825b0ec96bbfc4f70a256735b715d6c

This mode emits AML code along with the ASL code.
A new global was needed to ensure the listing mode is
completely separate from the debugger verbose mode.

Emits the correct AML offset for the AML code.
The -l option now works for both the compiler and disassembler.

Linux kernel is not affected by this commit.

Link: https://github.com/acpica/acpica/commit/2fefacf7
Link: https://github.com/acpica/acpica/commit/2ed09bb7
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/acglobal.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 79eb35d..1283b19 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -307,9 +307,9 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_no_resource_disassembly, 
FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_ignore_noop_operator, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_cstyle_disassembly, TRUE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_force_aml_disassembly, FALSE);
-ACPI_INIT_GLOBAL(union acpi_parse_object *, acpi_gbl_previous_op, NULL);
 
 ACPI_GLOBAL(u8, acpi_gbl_db_opt_disasm);
+ACPI_GLOBAL(u8, acpi_gbl_dm_opt_listing);
 ACPI_GLOBAL(u8, acpi_gbl_db_opt_verbose);
 ACPI_GLOBAL(u8, acpi_gbl_num_external_methods);
 ACPI_GLOBAL(u32, acpi_gbl_resolved_external_methods);
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/20] ACPICA: Tables: Fix global table list issues by removing fixed table indexes.

2015-08-24 Thread Lv Zheng
ACPICA commit c0b38b4c3982c2336ee92a2a14716107248bd941

The fixed table indexes leave holes in the global table list:
1. One hole can be seen when there is only 1 FACS provided by the BIOS.
2. Tow holes can be seen when it is a reduced hardware platform.
The holes do not break OSPMs but have broken ACPI debugger tables
command.

Also the fixed table indexes mechanism may make the descriptors of the
standard tables installed earlier than DSDT to be overwritten by the
descriptors of the fixed tables. For example, FACP disappears from the
global table list after DSDT is installed.

This patch fixes all above issues by removing the fixed table indexes
mechanism which is too complicated to be maintained in a regression safe
manner. After removal, the table loader will determine the indexes of the
fixed tables. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/c0b38b4c
Cc: sta...@vger.kernel.org
Signed-off-by: Lv Zheng lv.zh...@intel.com
Signed-off-by: Bob Moore robert.mo...@intel.com
---
 drivers/acpi/acpica/acglobal.h |3 +++
 drivers/acpi/acpica/aclocal.h  |6 ++
 drivers/acpi/acpica/actables.h |7 +++
 drivers/acpi/acpica/tbfadt.c   |6 +++---
 drivers/acpi/acpica/tbinstal.c |   40 +---
 drivers/acpi/acpica/tbutils.c  |   37 ++---
 drivers/acpi/acpica/tbxfload.c |   10 +-
 7 files changed, 51 insertions(+), 58 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 1283b19..e78667e 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -58,6 +58,9 @@ ACPI_GLOBAL(struct acpi_table_list, acpi_gbl_root_table_list);
 
 ACPI_GLOBAL(struct acpi_table_header *, acpi_gbl_DSDT);
 ACPI_GLOBAL(struct acpi_table_header, acpi_gbl_original_dsdt_header);
+ACPI_INIT_GLOBAL(u32, acpi_gbl_dsdt_index, ACPI_INVALID_TABLE_INDEX);
+ACPI_INIT_GLOBAL(u32, acpi_gbl_facs_index, ACPI_INVALID_TABLE_INDEX);
+ACPI_INIT_GLOBAL(u32, acpi_gbl_xfacs_index, ACPI_INVALID_TABLE_INDEX);
 
 #if (!ACPI_REDUCED_HARDWARE)
 ACPI_GLOBAL(struct acpi_table_facs *, acpi_gbl_FACS);
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index a6b6887..92cbaee 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -213,11 +213,9 @@ struct acpi_table_list {
 #define ACPI_ROOT_ORIGIN_ALLOCATED  (1)
 #define ACPI_ROOT_ALLOW_RESIZE  (2)
 
-/* Predefined (fixed) table indexes */
+/* Predefined table indexes */
 
-#define ACPI_TABLE_INDEX_DSDT   (0)
-#define ACPI_TABLE_INDEX_FACS   (1)
-#define ACPI_TABLE_INDEX_X_FACS (2)
+#define ACPI_INVALID_TABLE_INDEX(0x)
 
 struct acpi_find_context {
char *search_for;
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 58497b7..ab7f3a0 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -154,13 +154,12 @@ void acpi_tb_check_dsdt_header(void);
 struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index);
 
 void
-acpi_tb_install_table_with_override(u32 table_index,
-   struct acpi_table_desc *new_table_desc,
-   u8 override);
+acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
+   u8 override, u32 *table_index);
 
 acpi_status
 acpi_tb_install_fixed_table(acpi_physical_address address,
-   char *signature, u32 table_index);
+   char *signature, u32 *table_index);
 
 acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address);
 
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 6253001..455a070 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -345,7 +345,7 @@ void acpi_tb_parse_fadt(u32 table_index)
/* Obtain the DSDT and FACS tables via their addresses within the FADT 
*/
 
acpi_tb_install_fixed_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt,
-   ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
+   ACPI_SIG_DSDT, acpi_gbl_dsdt_index);
 
/* If Hardware Reduced flag is set, there is no FACS */
 
@@ -354,13 +354,13 @@ void acpi_tb_parse_fadt(u32 table_index)
acpi_tb_install_fixed_table((acpi_physical_address)
acpi_gbl_FADT.facs,
ACPI_SIG_FACS,
-   ACPI_TABLE_INDEX_FACS);
+   acpi_gbl_facs_index);
}
if (acpi_gbl_FADT.Xfacs) {
acpi_tb_install_fixed_table((acpi_physical_address)
acpi_gbl_FADT.Xfacs

[PATCH 05/20] ACPICA: Update info messages during ACPICA init.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit 4ccf8a1cc499ec8f00345f662a5887483980e1dd

Small cleanup of messages.

Link: https://github.com/acpica/acpica/commit/4ccf8a1c
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/dsinit.c   |9 +
 drivers/acpi/acpica/tbxfload.c |4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index 95779e8..bbf52f0 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -237,6 +237,15 @@ acpi_ds_initialize_objects(u32 table_index,
return_ACPI_STATUS(status);
}
 
+   /* DSDT is always the first AML table */
+
+   if (ACPI_COMPARE_NAME(table-signature, ACPI_SIG_DSDT)) {
+   ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
+ \nInitializing Namespace objects:\n));
+   }
+
+   /* Summary of objects initialized */
+
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
  Table [%4.4s] (id %4.4X) - %4u Objects with %3u 
Devices, 
  %3u Regions, %3u Methods (%u/%u/%u 
Serial/Non/Cvt)\n,
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index 7862cf0..6cbb2f7 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -208,11 +208,11 @@ static acpi_status acpi_tb_load_namespace(void)
 
if (!tables_failed) {
ACPI_INFO((AE_INFO,
-  All (%u) ACPI AML tables successfully loaded,
+  %u ACPI AML tables successfully acquired and 
loaded,
   tables_loaded));
} else {
ACPI_ERROR((AE_INFO,
-   %u ACPI AML tables loaded, %u failed,
+   %u ACPI AML tables successfully acquired and 
loaded, %u failed,
tables_loaded, tables_failed));
}
 
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 09/20] ACPICA: acpinames: Add new options and wildcard support.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit 0ecf5b5a41c3d2e09af48f0fdbc9ae784f631788

- Add wilcard support for input filenames.
- Add -l option to load tables and exit, no display. This is
useful for validation of the namespace during BIOS generation.
- Add -x option for specifying debug level.

Linux kernel is not affected by this commit.

Link: https://github.com/acpica/acpica/commit/0ecf5b5a
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/acutils.h |2 +-
 drivers/acpi/acpica/utmisc.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 566ff4df..fb2aa50 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -517,7 +517,7 @@ const struct acpi_exception_info 
*acpi_ut_validate_exception(acpi_status
 
 u8 acpi_ut_is_pci_root_bridge(char *id);
 
-#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP)
+#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined 
ACPI_NAMES_APP)
 u8 acpi_ut_is_aml_table(struct acpi_table_header *table);
 #endif
 
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 98087ea..517a5ec 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -75,7 +75,7 @@ u8 acpi_ut_is_pci_root_bridge(char *id)
return (FALSE);
 }
 
-#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP)
+#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined 
ACPI_NAMES_APP)
 
/***
  *
  * FUNCTION:acpi_ut_is_aml_table
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/20] ACPICA: Tables: Cleanup to reduce FACS globals.

2015-08-24 Thread Lv Zheng
ACPICA commit 3f42ba76e2a0453976d3108296d5f656fdf2bd6e

In this patch, FACS table mapping is also tuned a bit so that only the
selected FACS table will be mapped by the OSPM (mapped on demand) and the
FACS related global variables can be reduced. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/3f42ba76
Signed-off-by: Lv Zheng lv.zh...@intel.com
Signed-off-by: Bob Moore robert.mo...@intel.com
---
 drivers/acpi/acpica/acglobal.h  |2 --
 drivers/acpi/acpica/hwxfsleep.c |   15 ++-
 drivers/acpi/acpica/tbutils.c   |9 +
 3 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index e78667e..95ed861 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -64,8 +64,6 @@ ACPI_INIT_GLOBAL(u32, acpi_gbl_xfacs_index, 
ACPI_INVALID_TABLE_INDEX);
 
 #if (!ACPI_REDUCED_HARDWARE)
 ACPI_GLOBAL(struct acpi_table_facs *, acpi_gbl_FACS);
-ACPI_GLOBAL(struct acpi_table_facs *, acpi_gbl_facs32);
-ACPI_GLOBAL(struct acpi_table_facs *, acpi_gbl_facs64);
 
 #endif /* !ACPI_REDUCED_HARDWARE */
 
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
index 52dfd0d..d62a616 100644
--- a/drivers/acpi/acpica/hwxfsleep.c
+++ b/drivers/acpi/acpica/hwxfsleep.c
@@ -160,19 +160,8 @@ acpi_set_firmware_waking_vectors(acpi_physical_address 
physical_address,
 
ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vectors);
 
-   /* If Hardware Reduced flag is set, there is no FACS */
-
-   if (acpi_gbl_reduced_hardware) {
-   return_ACPI_STATUS (AE_OK);
-   }
-
-   if (acpi_gbl_facs32) {
-   (void)acpi_hw_set_firmware_waking_vectors(acpi_gbl_facs32,
- physical_address,
- physical_address64);
-   }
-   if (acpi_gbl_facs64) {
-   (void)acpi_hw_set_firmware_waking_vectors(acpi_gbl_facs64,
+   if (acpi_gbl_FACS) {
+   (void)acpi_hw_set_firmware_waking_vectors(acpi_gbl_FACS,
  physical_address,
  physical_address64);
}
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index b1d500e..4337990 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -68,6 +68,7 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 
table_entry_size);
 
 acpi_status acpi_tb_initialize_facs(void)
 {
+   struct acpi_table_facs *facs;
 
/* If Hardware Reduced flag is set, there is no FACS */
 
@@ -80,14 +81,14 @@ acpi_status acpi_tb_initialize_facs(void)
(void)acpi_get_table_by_index(acpi_gbl_xfacs_index,
  ACPI_CAST_INDIRECT_PTR(struct
 
acpi_table_header,
-
acpi_gbl_facs32));
-   acpi_gbl_FACS = acpi_gbl_facs32;
+facs));
+   acpi_gbl_FACS = facs;
} else if (acpi_gbl_FADT.facs) {
(void)acpi_get_table_by_index(acpi_gbl_facs_index,
  ACPI_CAST_INDIRECT_PTR(struct
 
acpi_table_header,
-
acpi_gbl_facs64));
-   acpi_gbl_FACS = acpi_gbl_facs64;
+facs));
+   acpi_gbl_FACS = facs;
}
 
/* If there is no FACS, just continue. There was already an error msg */
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/20] ACPICA: Update parameter validation for data_table_region and load_table.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit 51ab555e60b4a3de3cc4a846e86d0de255be441a

Add additional validation for the table signature and
the OEM strings. Eliminates buffer read overrun in data_table_region.
ACPICA BZ 1184.

Link: https://bugs.acpica.org/show_bug.cgi?id=1184
Link: https://github.com/acpica/acpica/commit/51ab555e
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/actables.h |2 ++
 drivers/acpi/acpica/dsopcode.c |   31 ---
 drivers/acpi/acpica/exconfig.c |8 
 drivers/acpi/acpica/tbfind.c   |   15 ++-
 drivers/acpi/acpica/tbutils.c  |   33 +
 5 files changed, 69 insertions(+), 20 deletions(-)

diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 7e0b6f1..58497b7 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -164,4 +164,6 @@ acpi_tb_install_fixed_table(acpi_physical_address address,
 
 acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address);
 
+u8 acpi_is_valid_signature(char *signature);
+
 #endif /* __ACTABLES_H__ */
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index ea0cc4e..81d7b986 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -480,8 +480,8 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state 
*walk_state,
union acpi_operand_object **operand;
struct acpi_namespace_node *node;
union acpi_parse_object *next_op;
-   u32 table_index;
struct acpi_table_header *table;
+   u32 table_index;
 
ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op);
 
@@ -504,6 +504,8 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state 
*walk_state,
return_ACPI_STATUS(status);
}
 
+   operand = walk_state-operands[0];
+
/*
 * Resolve the Signature string, oem_id string,
 * and oem_table_id string operands
@@ -511,32 +513,34 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state 
*walk_state,
status = acpi_ex_resolve_operands(op-common.aml_opcode,
  ACPI_WALK_OPERANDS, walk_state);
if (ACPI_FAILURE(status)) {
-   return_ACPI_STATUS(status);
+   goto cleanup;
}
 
-   operand = walk_state-operands[0];
-
/* Find the ACPI table */
 
status = acpi_tb_find_table(operand[0]-string.pointer,
operand[1]-string.pointer,
operand[2]-string.pointer, table_index);
if (ACPI_FAILURE(status)) {
-   return_ACPI_STATUS(status);
+   if (status == AE_NOT_FOUND) {
+   ACPI_ERROR((AE_INFO,
+   ACPI Table [%4.4s] OEM:(%s, %s) not found 
in RSDT/XSDT,
+   operand[0]-string.pointer,
+   operand[1]-string.pointer,
+   operand[2]-string.pointer));
+   }
+   goto cleanup;
}
 
-   acpi_ut_remove_reference(operand[0]);
-   acpi_ut_remove_reference(operand[1]);
-   acpi_ut_remove_reference(operand[2]);
-
status = acpi_get_table_by_index(table_index, table);
if (ACPI_FAILURE(status)) {
-   return_ACPI_STATUS(status);
+   goto cleanup;
}
 
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
-   return_ACPI_STATUS(AE_NOT_EXIST);
+   status = AE_NOT_EXIST;
+   goto cleanup;
}
 
obj_desc-region.address = ACPI_PTR_TO_PHYSADDR(table);
@@ -551,6 +555,11 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state 
*walk_state,
 
obj_desc-region.flags |= AOPOBJ_DATA_VALID;
 
+cleanup:
+   acpi_ut_remove_reference(operand[0]);
+   acpi_ut_remove_reference(operand[1]);
+   acpi_ut_remove_reference(operand[2]);
+
return_ACPI_STATUS(status);
 }
 
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 24a4c5c..b540913 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -162,14 +162,6 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
 
ACPI_FUNCTION_TRACE(ex_load_table_op);
 
-   /* Validate lengths for the Signature, oem_id, and oem_table_id strings 
*/
-
-   if ((operand[0]-string.length  ACPI_NAME_SIZE) ||
-   (operand[1]-string.length  ACPI_OEM_ID_SIZE) ||
-   (operand[2]-string.length  ACPI_OEM_TABLE_ID_SIZE)) {
-   return_ACPI_STATUS(AE_AML_STRING_LIMIT);
-   }
-
/* Find the ACPI table in the RSDT/XSDT */
 
status = acpi_tb_find_table(operand[0]-string.pointer,
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers

[PATCH 01/20] ACPICA: Correctly cleanup after a ACPI table load failure.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit ed7769e832de6c7ba90615480d916c85fd100422

If a table load fails, delete all namespace objects created by the
table, otherwise these objects will be uninitialized, causing
problems later. This appears to be a very rare problem.
Also handle the unitialized node problem to prevent possible
faults. ACPICA BZ 1185.

Link: https://github.com/acpica/acpica/commit/ed7769e8
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/exresnte.c |2 +-
 drivers/acpi/acpica/exresolv.c |   16 +++-
 drivers/acpi/acpica/nseval.c   |1 +
 drivers/acpi/acpica/nsload.c   |   16 +++-
 drivers/acpi/acpica/tbxfload.c |   29 ++---
 include/acpi/acexcep.h |7 +--
 6 files changed, 59 insertions(+), 12 deletions(-)

diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index c7e3b92..1b372ef 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -126,7 +126,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node 
**object_ptr,
if (!source_desc) {
ACPI_ERROR((AE_INFO, No object attached to node [%4.4s] %p,
node-name.ascii, node));
-   return_ACPI_STATUS(AE_AML_NO_OPERAND);
+   return_ACPI_STATUS(AE_AML_UNINITIALIZED_NODE);
}
 
/*
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index b6b7f3a..7b10912 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -337,8 +337,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
 acpi_object_type * return_type,
 union acpi_operand_object **return_desc)
 {
-   union acpi_operand_object *obj_desc = (void *)operand;
-   struct acpi_namespace_node *node;
+   union acpi_operand_object *obj_desc = ACPI_CAST_PTR(void, operand);
+   struct acpi_namespace_node *node =
+   ACPI_CAST_PTR(struct acpi_namespace_node, operand);
acpi_object_type type;
acpi_status status;
 
@@ -355,9 +356,7 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
case ACPI_DESC_TYPE_NAMED:
 
type = ((struct acpi_namespace_node *)obj_desc)-type;
-   obj_desc =
-   acpi_ns_get_attached_object((struct acpi_namespace_node *)
-   obj_desc);
+   obj_desc = acpi_ns_get_attached_object(node);
 
/* If we had an Alias node, use the attached object for type 
info */
 
@@ -368,6 +367,13 @@ acpi_ex_resolve_multiple(struct acpi_walk_state 
*walk_state,
 acpi_namespace_node *)
obj_desc);
}
+
+   if (!obj_desc) {
+   ACPI_ERROR((AE_INFO,
+   [%4.4s] Node is unresolved or 
uninitialized,
+   acpi_ut_get_node_name(node)));
+   return_ACPI_STATUS(AE_AML_UNINITIALIZED_NODE);
+   }
break;
 
default:
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index 80670cb..88822b7a 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -274,6 +274,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info 
*info)
acpi_ex_exit_interpreter();
 
if (ACPI_FAILURE(status)) {
+   info-return_object = NULL;
goto cleanup;
}
 
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index bd6cd4a..14ab836 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -111,7 +111,21 @@ acpi_ns_load_table(u32 table_index, struct 
acpi_namespace_node *node)
if (ACPI_SUCCESS(status)) {
acpi_tb_set_table_loaded_flag(table_index, TRUE);
} else {
-   (void)acpi_tb_release_owner_id(table_index);
+   /*
+* On error, delete any namespace objects created by this table.
+* We cannot initialize these objects, so delete them. There are
+* a couple of expecially bad cases:
+* AE_ALREADY_EXISTS - namespace collision.
+* AE_NOT_FOUND - the target of a Scope operator does not
+* exist. This target of Scope must already exist in the
+* namespace, as per the ACPI specification.
+*/
+   (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+   acpi_ns_delete_namespace_by_owner(acpi_gbl_root_table_list.
+ tables[table_index].owner_id);
+   acpi_tb_release_owner_id

[PATCH 00/20] ACPICA: 20150818 Release

2015-08-24 Thread Lv Zheng
The 20150818 ACPICA kernel-resident subsystem updates are linuxized based
on the linux-pm/linux-next branch.

The patchset has passed the following build/boot tests.
Build tests are performed as follows:
1. i386 + default + COFNIG_ACPI=y
2. i386 + allyes + CONFIG_ACPI=y
3. i386 + default + COFNIG_ACPI=n
4. i386 + allyes + CONFIG_ACPI=n
5. x86_64 + default + COFNIG_ACPI=y
6. x86_64 + allyes + CONFIG_ACPI=y
7. x86_64 + default + COFNIG_ACPI=n
8. x86_64 + allyes + CONFIG_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 drivers/platform drivers
   All other drivers that link the APIs provided by ACPICA subsystem

The divergences checking result:
Before applying (20150717 Release):
  518 lines
After applying (20150818 Release):
  517 lines

Bob Moore (14):
  ACPICA: Correctly cleanup after a ACPI table load failure.
  ACPICA: Disassembler: Remove duplicate code in _PLD processing.
  ACPICA: Update parameter validation for data_table_region and
load_table.
  ACPICA: Disassembler: Update for new listing mode.
  ACPICA: Update info messages during ACPICA init.
  ACPICA: Headers: Fix some comments, no functional change.
  ACPICA: acpinames: Add new options and wildcard support.
  ACPICA: acpiexec/acpinames: Support very large number of ACPI tables.
  ACPICA: Table handling: Cleanup and update debug output for tools.
  ACPICA: Add additional debug info/statements.
  ACPICA: Debugger: Add option to display namespace summary/counts.
  ACPICA: Make the max-number-of-loops runtime configurable.
  ACPICA: Header support to improve compatibility with MSVC.
  ACPICA: Update version to 20150818.

Lv Zheng (6):
  ACPICA: Tables: Fix global table list issues by removing fixed table
indexes.
  ACPICA: Tables: Cleanup to reduce FACS globals.
  ACPICA: Debugger: Split debugger initialization/termination APIs.
  ACPICA: Disassembler: Cleanup acpi_gbl_db_opt_disasm.
  ACPICA: Disassembler: Cleanup acpi_gbl_db_opt_verbose acpiexec usage.
  ACPICA: Debugger: Cleanup debugging outputs to dump name path without
trailing underscores.

 drivers/acpi/acpica/acdebug.h   |7 ---
 drivers/acpi/acpica/acglobal.h  |   19 +---
 drivers/acpi/acpica/aclocal.h   |   17 +--
 drivers/acpi/acpica/actables.h  |   14 --
 drivers/acpi/acpica/acutils.h   |2 +-
 drivers/acpi/acpica/dscontrol.c |2 +-
 drivers/acpi/acpica/dsdebug.c   |2 +-
 drivers/acpi/acpica/dsinit.c|   20 ++---
 drivers/acpi/acpica/dsopcode.c  |   31 -
 drivers/acpi/acpica/evregion.c  |   22 +++--
 drivers/acpi/acpica/exconfig.c  |8 
 drivers/acpi/acpica/exdump.c|2 +-
 drivers/acpi/acpica/exresnte.c  |2 +-
 drivers/acpi/acpica/exresolv.c  |   16 ---
 drivers/acpi/acpica/hwxfsleep.c |   15 +--
 drivers/acpi/acpica/nseval.c|4 +-
 drivers/acpi/acpica/nsload.c|   16 ++-
 drivers/acpi/acpica/nsutils.c   |   19 +++-
 drivers/acpi/acpica/psloop.c|   14 +-
 drivers/acpi/acpica/tbfadt.c|6 +--
 drivers/acpi/acpica/tbfind.c|   15 ++-
 drivers/acpi/acpica/tbinstal.c  |   40 +
 drivers/acpi/acpica/tbutils.c   |   73 --
 drivers/acpi/acpica/tbxfload.c  |   93 +--
 drivers/acpi/acpica/utfileio.c  |2 +-
 drivers/acpi/acpica/utinit.c|1 +
 drivers/acpi/acpica/utmisc.c|4 +-
 drivers/acpi/acpica/utxface.c   |   12 ++---
 drivers/acpi/acpica/utxfinit.c  |   11 -
 include/acpi/acbuffer.h |1 +
 include/acpi/acconfig.h |4 --
 include/acpi/acexcep.h  |7 ++-
 include/acpi/acpixf.h   |5 ++-
 include/acpi/actypes.h  |2 +
 include/acpi/platform/acenv.h   |   19 
 35 files changed, 330 insertions(+), 197 deletions(-)

-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 16/20] ACPICA: Debugger: Split debugger initialization/termination APIs.

2015-08-24 Thread Lv Zheng
ACPICA commit 7a3f22baab000b186779dac64ad71d9776b8f432

It is likely that the debugger is enabled only when a userspace program
explicitly tells a kernel to do so, so it shouldn't be initialized as
early as current implementation.

The only tool requiring ACPI_DEBUGGER is acpiexec, so acpiexec need to call
the new APIs by itself. And BSD developers may also get notified to invoke
the APIs for DDB enabling. Lv Zheng.

This patch doesn't affect Linux kernel as debugger is currently not enabled
in the Linux kernel.

Link: https://github.com/acpica/acpica/commit/7a3f22ba
Signed-off-by: Lv Zheng lv.zh...@intel.com
Signed-off-by: Bob Moore robert.mo...@intel.com
---
 drivers/acpi/acpica/acdebug.h  |4 
 drivers/acpi/acpica/utxface.c  |7 ---
 drivers/acpi/acpica/utxfinit.c |   11 ---
 include/acpi/acpixf.h  |3 +++
 4 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index b5a9c51..447f6d3 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -77,10 +77,6 @@ struct acpi_db_execute_walk {
 /*
  * dbxface - external debugger interfaces
  */
-acpi_status acpi_db_initialize(void);
-
-void acpi_db_terminate(void);
-
 acpi_status
 acpi_db_single_step(struct acpi_walk_state *walk_state,
union acpi_parse_object *op, u32 op_type);
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index c2bd5e2..4f33281 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -92,13 +92,6 @@ acpi_status __init acpi_terminate(void)
 
acpi_ut_mutex_terminate();
 
-#ifdef ACPI_DEBUGGER
-
-   /* Shut down the debugger */
-
-   acpi_db_terminate();
-#endif
-
/* Now we can shutdown the OS-dependent layer */
 
status = acpi_os_terminate();
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
index 42a32a6..a7137ec 100644
--- a/drivers/acpi/acpica/utxfinit.c
+++ b/drivers/acpi/acpica/utxfinit.c
@@ -124,17 +124,6 @@ acpi_status __init acpi_initialize_subsystem(void)
return_ACPI_STATUS(status);
}
 
-   /* If configured, initialize the AML debugger */
-
-#ifdef ACPI_DEBUGGER
-   status = acpi_db_initialize();
-   if (ACPI_FAILURE(status)) {
-   ACPI_EXCEPTION((AE_INFO, status,
-   During Debugger initialization));
-   return_ACPI_STATUS(status);
-   }
-#endif
-
return_ACPI_STATUS(AE_OK);
 }
 
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index f2e2327..d3d7ea0 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -917,6 +917,9 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(void
 ACPI_APP_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(1)
void ACPI_INTERNAL_VAR_XFACE
acpi_log_error(const char *format, ...))
+ acpi_status acpi_initialize_debugger(void);
+
+void acpi_terminate_debugger(void);
 
 /*
  * Divergences
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/20] ACPICA: Disassembler: Remove duplicate code in _PLD processing.

2015-08-24 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

ACPICA commit 6d9c827b540837b6e54059e17756a06985e4a196

ACPICA BZ 1176.

Link: https://bugs.acpica.org/show_bug.cgi?id=1176
Link: https://github.com/acpica/acpica/commit/6d9c827b
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/utxface.c |5 +++--
 include/acpi/acbuffer.h   |1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index 51cf52d..c2bd5e2 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -517,7 +517,8 @@ acpi_decode_pld_buffer(u8 *in_buffer,
 
/* Parameter validation */
 
-   if (!in_buffer || !return_buffer || (length  16)) {
+   if (!in_buffer || !return_buffer
+   || (length  ACPI_PLD_REV1_BUFFER_SIZE)) {
return (AE_BAD_PARAMETER);
}
 
@@ -567,7 +568,7 @@ acpi_decode_pld_buffer(u8 *in_buffer,
pld_info-rotation = ACPI_PLD_GET_ROTATION(dword);
pld_info-order = ACPI_PLD_GET_ORDER(dword);
 
-   if (length = ACPI_PLD_BUFFER_SIZE) {
+   if (length = ACPI_PLD_REV2_BUFFER_SIZE) {
 
/* Fifth 32-bit DWord (Revision 2 of _PLD) */
 
diff --git a/include/acpi/acbuffer.h b/include/acpi/acbuffer.h
index 6b040f4..fcf9080 100644
--- a/include/acpi/acbuffer.h
+++ b/include/acpi/acbuffer.h
@@ -147,6 +147,7 @@ struct acpi_pld_info {
  *(Intended for BIOS use only)
  */
 #define ACPI_PLD_REV1_BUFFER_SIZE   16 /* For Revision 1 of 
the buffer (From ACPI spec) */
+#define ACPI_PLD_REV2_BUFFER_SIZE   20 /* For Revision 2 of 
the buffer (From ACPI spec) */
 #define ACPI_PLD_BUFFER_SIZE20 /* For Revision 2 of 
the buffer (From ACPI spec) */
 
 /* First 32-bit dword, bits 0:32 */
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] ACPI / EC: Fix query handler related issues

2015-09-24 Thread Lv Zheng
1. acpi_ec_remove_query_handlers()
This patch refines the query handler removal logic implemented in
acpi_ec_remove_query_handler(), making it to invoke new
acpi_ec_remove_query_handlers() API, and ensuring all other removal code
paths to invoke the new API to honor the reference count of the query
handlers.

2. acpi_ec_get_query_handler_by_value()
This patch also refines the query handler search logic originally
implemented in acpi_ec_query(), collecting it into
acpi_ec_get_query_handler_by_value(). And since schedule_work() can ensure
the serilization of acpi_ec_event_handler(), we needn't put the
mutex_lock() around schedule_work().

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/ec.c |   73 +
 1 file changed, 45 insertions(+), 28 deletions(-)

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 42c66b6..ddaaa9d 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -929,6 +929,23 @@ acpi_ec_get_query_handler(struct acpi_ec_query_handler 
*handler)
return handler;
 }
 
+static struct acpi_ec_query_handler *
+acpi_ec_get_query_handler_by_value(struct acpi_ec *ec, u8 value)
+{
+   struct acpi_ec_query_handler *handler;
+   bool found = false;
+
+   mutex_lock(>mutex);
+   list_for_each_entry(handler, >list, node) {
+   if (value == handler->query_bit) {
+   found = true;
+   break;
+   }
+   }
+   mutex_unlock(>mutex);
+   return found ? acpi_ec_get_query_handler(handler) : NULL;
+}
+
 static void acpi_ec_query_handler_release(struct kref *kref)
 {
struct acpi_ec_query_handler *handler =
@@ -964,14 +981,15 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 
query_bit,
 }
 EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
 
-void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
+static void acpi_ec_remove_query_handlers(struct acpi_ec *ec,
+ bool remove_all, u8 query_bit)
 {
struct acpi_ec_query_handler *handler, *tmp;
LIST_HEAD(free_list);
 
mutex_lock(>mutex);
list_for_each_entry_safe(handler, tmp, >list, node) {
-   if (query_bit == handler->query_bit) {
+   if (remove_all || query_bit == handler->query_bit) {
list_del_init(>node);
list_add(>node, _list);
}
@@ -980,6 +998,11 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 
query_bit)
list_for_each_entry_safe(handler, tmp, _list, node)
acpi_ec_put_query_handler(handler);
 }
+
+void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
+{
+   acpi_ec_remove_query_handlers(ec, false, query_bit);
+}
 EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
 
 static struct acpi_ec_query *acpi_ec_create_query(u8 *pval)
@@ -1025,7 +1048,6 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
 {
u8 value = 0;
int result;
-   struct acpi_ec_query_handler *handler;
struct acpi_ec_query *q;
 
q = acpi_ec_create_query();
@@ -1043,25 +1065,26 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
if (result)
goto err_exit;
 
-   mutex_lock(>mutex);
-   result = -ENODATA;
-   list_for_each_entry(handler, >list, node) {
-   if (value == handler->query_bit) {
-   result = 0;
-   q->handler = acpi_ec_get_query_handler(handler);
-   ec_dbg_evt("Query(0x%02x) scheduled",
-  q->handler->query_bit);
-   /*
-* It is reported that _Qxx are evaluated in a
-* parallel way on Windows:
-* https://bugzilla.kernel.org/show_bug.cgi?id=94411
-*/
-   if (!schedule_work(>work))
-   result = -EBUSY;
-   break;
-   }
+   q->handler = acpi_ec_get_query_handler_by_value(ec, value);
+   if (!q->handler) {
+   result = -ENODATA;
+   goto err_exit;
+   }
+
+   /*
+* It is reported that _Qxx are evaluated in a parallel way on
+* Windows:
+* https://bugzilla.kernel.org/show_bug.cgi?id=94411
+*
+* Put this log entry before schedule_work() in order to make
+* it appearing before any other log entries occurred during the
+* work queue execution.
+*/
+   ec_dbg_evt("Query(0x%02x) scheduled", value);
+   if (!schedule_work(>work)) {
+   ec_dbg_evt("Query(0x%02x) overlapped", value);
+   result = -EBUSY;
}
-   mutex_unlock(>mutex);
 
 err_exit:
if (result && q)
@@ -1354,19 +

[PATCH 3/3] ACPI / EC: Fix a race issue in acpi_ec_guard_event()

2015-09-24 Thread Lv Zheng
In acpi_ec_guard_event(), EC transaction state machine variables should be
checked with the EC spinlock locked.
The bug doesn't trigger any real issue now because this bug can only occur
when the ec_event_clearing=event mode is applied while there is no user
currently using this mode.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/ec.c |   42 +-
 1 file changed, 29 insertions(+), 13 deletions(-)

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index ddaaa9d..2687a01 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -441,17 +441,31 @@ static void acpi_ec_complete_query(struct acpi_ec *ec)
 
 static bool acpi_ec_guard_event(struct acpi_ec *ec)
 {
+   bool guarded = true;
+   unsigned long flags;
+
+   spin_lock_irqsave(>lock, flags);
+   /*
+* If firmware SCI_EVT clearing timing is "event", we actually
+* don't know when the SCI_EVT will be cleared by firmware after
+* evaluating _Qxx, so we need to re-check SCI_EVT after waiting an
+* acceptable period.
+*
+* The guarding period begins when EC_FLAGS_QUERY_PENDING is
+* flagged, which means SCI_EVT check has just been performed.
+* But if the current transaction is ACPI_EC_COMMAND_QUERY, the
+* guarding should have already been performed (via
+* EC_FLAGS_QUERY_GUARDING) and should not be applied so that the
+* ACPI_EC_COMMAND_QUERY transaction can be transitioned into
+* ACPI_EC_COMMAND_POLL state immediately.
+*/
if (ec_event_clearing == ACPI_EC_EVT_TIMING_STATUS ||
ec_event_clearing == ACPI_EC_EVT_TIMING_QUERY ||
!test_bit(EC_FLAGS_QUERY_PENDING, >flags) ||
(ec->curr && ec->curr->command == ACPI_EC_COMMAND_QUERY))
-   return false;
-
-   /*
-* Postpone the query submission to allow the firmware to proceed,
-* we shouldn't check SCI_EVT before the firmware reflagging it.
-*/
-   return true;
+   guarded = false;
+   spin_unlock_irqrestore(>lock, flags);
+   return guarded;
 }
 
 static int ec_transaction_polled(struct acpi_ec *ec)
@@ -597,6 +611,7 @@ static int ec_guard(struct acpi_ec *ec)
unsigned long guard = usecs_to_jiffies(ec_polling_guard);
unsigned long timeout = ec->timestamp + guard;
 
+   /* Ensure guarding period before polling EC status */
do {
if (ec_busy_polling) {
/* Perform busy polling */
@@ -606,11 +621,13 @@ static int ec_guard(struct acpi_ec *ec)
} else {
/*
 * Perform wait polling
-*
-* For SCI_EVT clearing timing of "event",
-* performing guarding before re-checking the
-* SCI_EVT. Otherwise, such guarding is not needed
-* due to the old practices.
+* 1. Wait the transaction to be completed by the
+*GPE handler after the transaction enters
+*ACPI_EC_COMMAND_POLL state.
+* 2. A special guarding logic is also required
+*for event clearing mode "event" before the
+*transaction enters ACPI_EC_COMMAND_POLL
+*state.
 */
if (!ec_transaction_polled(ec) &&
!acpi_ec_guard_event(ec))
@@ -620,7 +637,6 @@ static int ec_guard(struct acpi_ec *ec)
   guard))
return 0;
}
-   /* Guard the register accesses for the polling modes */
} while (time_before(jiffies, timeout));
return -ETIME;
 }
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] ACPI / EC: Fix a memory leak issue in acpi_ec_query()

2015-09-24 Thread Lv Zheng
When query handler is not found, "result" is actually stil 0, and
"struct acpi_ec_query" is not NULL, so the deletion code of
"struct acpi_ec_query" at the end of the function cannot be invoked.
As a consequence, memory leak can be observed.

The issue is introduced by this commit:
  Commit: 02b771b64b73226052d6e731a0987db3b47281e9
  Subject: ACPI / EC: Fix an issue caused by the serialized _Qxx

This patch fixes such memory leakage.

Cc: sta...@vger.kernel.org  # 4.3.1+
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/ec.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 2614a83..42c66b6 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1044,8 +1044,10 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
goto err_exit;
 
mutex_lock(>mutex);
+   result = -ENODATA;
list_for_each_entry(handler, >list, node) {
if (value == handler->query_bit) {
+   result = 0;
q->handler = acpi_ec_get_query_handler(handler);
ec_dbg_evt("Query(0x%02x) scheduled",
   q->handler->query_bit);
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] ACPI / EC: Fix several code coverity issues

2015-09-24 Thread Lv Zheng
This patch fixes several code coverity issues in the EC driver.
One serious issue that can cause memory leak is marked as stable material.

Lv Zheng (3):
  ACPI / EC: Fix a memory leak issue in acpi_ec_query()
  ACPI / EC: Fix query handler related issues
  ACPI / EC: Fix a race issue in acpi_ec_guard_event()

 drivers/acpi/ec.c |  113 +++--
 1 file changed, 74 insertions(+), 39 deletions(-)

-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 7/7] ACPI / x86: introduce acpi_os_readable() support

2015-12-02 Thread Lv Zheng
From: Chen Yu <yu.c.c...@intel.com>

This patch implements acpi_os_readable(). The function is used by ACPICA
AML debugger to validate user specified pointers for dumping the memory as
ACPICA descriptor objects.

Signed-off-by: Chen Yu <yu.c.c...@intel.com>
Tested-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 arch/x86/Kconfig  |1 +
 arch/x86/include/asm/acenv.h  |1 +
 arch/x86/kernel/acpi/boot.c   |   44 +
 drivers/acpi/Kconfig  |3 +++
 drivers/acpi/osl.c|   12 ++
 include/acpi/platform/aclinux.h   |1 -
 include/acpi/platform/aclinuxex.h |5 -
 7 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index db3622f..6593b6a 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -19,6 +19,7 @@ config X86
def_bool y
select ACPI_LEGACY_TABLES_LOOKUPif ACPI
select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
+   select ACPI_MEMORY_ACCESS_CHECK_SUPPORT if ACPI
select ANON_INODES
select ARCH_CLOCKSOURCE_DATA
select ARCH_DISCARD_MEMBLOCK
diff --git a/arch/x86/include/asm/acenv.h b/arch/x86/include/asm/acenv.h
index 1b010a8..a2a2849 100644
--- a/arch/x86/include/asm/acenv.h
+++ b/arch/x86/include/asm/acenv.h
@@ -20,6 +20,7 @@
 
 int __acpi_acquire_global_lock(unsigned int *lock);
 int __acpi_release_global_lock(unsigned int *lock);
+bool __acpi_memory_readable(void *pointer, size_t length);
 
 #define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
((Acq) = __acpi_acquire_global_lock(>global_lock))
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index e759076..4a5e22e 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1699,6 +1699,50 @@ int __acpi_release_global_lock(unsigned int *lock)
return old & 0x1;
 }
 
+bool __acpi_memory_readable(void *pointer, size_t length)
+{
+   unsigned long obj_start, obj_end;
+   unsigned long start_pfn, end_pfn;
+
+   /*
+* All direct mapped PFNs should have been recorded by the mapped
+* PFN ranges. But pfn_range_is_mapped() requires the following
+* sanity checks to be performed before invoking.
+*/
+   obj_start = ACPI_TO_INTEGER(pointer);
+   obj_end = obj_start + length;
+
+   /*
+* ACPICA core doesn't validate if the object is wrapped over, so
+* we should.
+*/
+   if (length && (obj_end - 1) < obj_start)
+   return false;
+
+   /*
+* None direct mapping ranges contain holes. For example, high
+* kernel map holes (lower than _text or higher than _brk_end).
+* Converting a virtual address that belongs to the high map hole
+* results in a valid PFN because its low map has been recorded as
+* a mapped range.
+*/
+   if (obj_start < PAGE_OFFSET ||
+   obj_start >= (unsigned long)high_memory ||
+   (length && (obj_end - 1) >= (unsigned long)high_memory))
+   return false;
+
+   /*
+* It is required to pass a range (end_pfn - start_pfn > 0) to
+* pfn_range_is_mapped().
+*/
+   start_pfn = PFN_DOWN(__pa(obj_start));
+   end_pfn = PFN_UP(__pa(obj_end));
+   if (unlikely(end_pfn == start_pfn))
+   end_pfn++;
+
+   return pfn_range_is_mapped(start_pfn, end_pfn);
+}
+
 void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
 {
e820_add_region(addr, size, E820_ACPI);
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 82b96ee..9422133 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -57,6 +57,9 @@ config ACPI_SYSTEM_POWER_STATES_SUPPORT
 config ACPI_CCA_REQUIRED
bool
 
+config ACPI_MEMORY_ACCESS_CHECK_SUPPORT
+   bool
+
 config ACPI_DEBUGGER
bool "AML debugger interface"
select ACPI_DEBUG
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index bb66093..14a3beb 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1585,6 +1585,18 @@ acpi_status acpi_os_get_line(char *buffer, u32 
buffer_length, u32 *bytes_read)
 }
 EXPORT_SYMBOL(acpi_os_get_line);
 
+#ifdef CONFIG_ACPI_MEMORY_ACCESS_CHECK_SUPPORT
+u8 acpi_os_readable(void *pointer, acpi_size length)
+{
+   return __acpi_memory_readable(pointer, length) ? TRUE : FALSE;
+}
+#else
+u8 acpi_os_readable(void *pointer, acpi_size length)
+{
+   return TRUE;
+}
+#endif
+
 acpi_status acpi_os_wait_command_ready(void)
 {
int ret;
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index e21857d..b3c493e 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -148,7 +148,6 @@
 /*
  * OSL interfaces used by debugger/disassembler
  */
-#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_

[PATCH v4 0/7] ACPICA / debugger: Add in-kernel AML debugger support

2015-12-02 Thread Lv Zheng
This patchset enables ACPICA debugger for Linux kernel and implements a
userspace utility to access it.

A. Build the AML debugger
In order to build the kernel support of AML debugger, the following kconfig
items should be enabled:
 CONFIG_ACPI_DEBUG=y
 CONFIG_ACPI_DEBUGGER=y
 CONFIG_DEBUG_FS=y
 CONFIG_ACPI_DEBUGGER_USER=m
The userspace tool can be found at tools/power/acpi/tools/acpidbg. To
build this utility, staying in tools folder and type "make acpi".

B. Load the AML debugger during runtime
In order to use the in-kernel AML debugger, the following command should be
executed using root user:
 # modprobe acpi_dbg
 # mount -t debugfs none /sys/kernel/debug
 # acpidbg

C. Batch mode
In order to support scripts, the userspace utility also supports single
command batch mode:
 # acpidbg -b "help"
 # acpidbg -b "tables"
 # acpidbg -b "find _LID"
 # acpidbg -b "execute \_SB.LID0._LID"
You can find the documentation about the ACPICA debugger commands in:
 https://acpica.org/sites/acpica/files/acpica-reference_17.pdf
 (The latest document can be found at https://acpica.org/documentation)
And refer to the chapter - ACPICA debugger reference to obtain the full
description of the debugger commands. Note that not all commands are
supported by an in-kernel AML debugger.

D. Unload the AML debugger during runtime
After terminating all acpidbg instances, the following command can be
executed to remove the AML debugger from kernel:
 # rmmod acpi_dbg

The following tasks are not completed:
1. .flush() support in the kernel debugger IO driver.
2. multi-commands batch mode.

v2:
1. Fix a help message issue for the userspace acpidbg utility (this is a
   typo fix).
2. Fix a batch mode issue by adding "\n" to the prompt sequence (this was
   lost due to too many rebase cycles).
3. Fix kconfig dependency for an intermediate patch (this is only useful in
   case the latter patches are reverted).
4. Add more accurate runtime debugger stub mechanism and remove old
   ACPI_DEBUGGER_EXEC() stub mechanism.
5. Add x86 acpi_os_readable() support.

v3:
1. Remove acpi_os_readable() support from this patchset. It's sent separately.
2. Delete some deprecated comments.

v4:
1. Rebase patch 4/6 because of Kconfig changes.
2. Include acpi_os_readable() back as no objections, also test result is
   positive.

Chen Yu (1):
  ACPI / x86: introduce acpi_os_readable() support

Colin Ian King (1):
  ACPICA: Debugger: Remove unnecessary status check

Lv Zheng (5):
  ACPICA: Debugger: Convert some mechanisms to OSPM specific
  ACPICA: Debugger: Fix runtime stub issues of ACPI_DEBUGGER_EXEC using
different stub mechanism
  ACPI / debugger: Add IO interface to access debugger functionalities
  tools/power/acpi: Add userspace AML interface support
  ACPI / debugger: Add module support for ACPI debugger

 arch/x86/Kconfig |1 +
 arch/x86/include/asm/acenv.h |1 +
 arch/x86/kernel/acpi/boot.c  |   44 ++
 drivers/acpi/Kconfig |   20 +-
 drivers/acpi/Makefile|1 +
 drivers/acpi/acpi_dbg.c  |  805 ++
 drivers/acpi/acpica/acdebug.h|   36 +-
 drivers/acpi/acpica/acglobal.h   |5 -
 drivers/acpi/acpica/acmacros.h   |   11 -
 drivers/acpi/acpica/dbdisply.c   |   12 +
 drivers/acpi/acpica/dbinput.c|  100 +---
 drivers/acpi/acpica/dbxface.c|   93 ++--
 drivers/acpi/acpica/dscontrol.c  |   10 +-
 drivers/acpi/acpica/dsutils.c|   16 +-
 drivers/acpi/acpica/dswexec.c|   16 +-
 drivers/acpi/acpica/utmutex.c|   17 -
 drivers/acpi/bus.c   |1 +
 drivers/acpi/osl.c   |  262 +-
 include/acpi/acpiosxf.h  |   18 +-
 include/acpi/acpixf.h|   34 ++
 include/acpi/platform/aclinux.h  |3 +-
 include/acpi/platform/aclinuxex.h|8 +-
 include/linux/acpi.h |   71 +++
 tools/power/acpi/Makefile|   16 +-
 tools/power/acpi/tools/acpidbg/Makefile  |   27 +
 tools/power/acpi/tools/acpidbg/acpidbg.c |  438 
 26 files changed, 1852 insertions(+), 214 deletions(-)
 create mode 100644 drivers/acpi/acpi_dbg.c
 create mode 100644 tools/power/acpi/tools/acpidbg/Makefile
 create mode 100644 tools/power/acpi/tools/acpidbg/acpidbg.c

-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/7] ACPI / debugger: Add IO interface to access debugger functionalities

2015-12-02 Thread Lv Zheng
This patch adds /sys/kernel/debug/acpi/acpidbg, which can be used by
userspace programs to access ACPICA debugger functionalities.

Known issue:
1. IO flush support
   acpi_os_notify_command_complete() and acpi_os_wait_command_ready() can
   be used by acpi_dbg module to implement .flush() filesystem operation.
   While this patch doesn't go that far. It then becomes userspace tool's
   duty now to flush old commands before executing new batch mode commands.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/Kconfig  |3 +-
 drivers/acpi/Makefile |1 +
 drivers/acpi/acpi_dbg.c   |  779 +
 drivers/acpi/bus.c|2 +
 drivers/acpi/osl.c|   55 ++-
 include/acpi/platform/aclinux.h   |2 -
 include/acpi/platform/aclinuxex.h |   10 -
 include/linux/acpi_dbg.h  |   52 +++
 8 files changed, 887 insertions(+), 17 deletions(-)
 create mode 100644 drivers/acpi/acpi_dbg.c
 create mode 100644 include/linux/acpi_dbg.h

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 5eef4cb..2a7e6d4 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -58,8 +58,9 @@ config ACPI_CCA_REQUIRED
bool
 
 config ACPI_DEBUGGER
-   bool "AML debugger interface (EXPERIMENTAL)"
+   bool "AML debugger interface"
select ACPI_DEBUG
+   depends on DEBUG_FS
help
  Enable in-kernel debugging of AML facilities: statistics, internal
  object dump, single step control method execution.
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 675eaf3..102b5e6 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -50,6 +50,7 @@ acpi-y+= sysfs.o
 acpi-y += property.o
 acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
 acpi-$(CONFIG_DEBUG_FS)+= debugfs.o
+acpi-$(CONFIG_ACPI_DEBUGGER)   += acpi_dbg.o
 acpi-$(CONFIG_ACPI_NUMA)   += numa.o
 acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
 acpi-y += acpi_lpat.o
diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
new file mode 100644
index 000..abc23b2
--- /dev/null
+++ b/drivers/acpi/acpi_dbg.c
@@ -0,0 +1,779 @@
+/*
+ * ACPI AML interfacing support
+ *
+ * Copyright (C) 2015, Intel Corporation
+ * Authors: Lv Zheng <lv.zh...@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/* #define DEBUG */
+#define pr_fmt(fmt) "ACPI : AML: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "internal.h"
+
+#define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
+#define ACPI_AML_BUF_SIZE  PAGE_SIZE
+
+#define circ_count(circ) \
+   (CIRC_CNT((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+#define circ_count_to_end(circ) \
+   (CIRC_CNT_TO_END((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+#define circ_space(circ) \
+   (CIRC_SPACE((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+#define circ_space_to_end(circ) \
+   (CIRC_SPACE_TO_END((circ)->head, (circ)->tail, ACPI_AML_BUF_SIZE))
+
+#define ACPI_AML_OPENED0x0001
+#define ACPI_AML_CLOSED0x0002
+#define ACPI_AML_IN_USER   0x0004 /* user space is writing cmd */
+#define ACPI_AML_IN_KERN   0x0008 /* kernel space is reading cmd */
+#define ACPI_AML_OUT_USER  0x0010 /* user space is reading log */
+#define ACPI_AML_OUT_KERN  0x0020 /* kernel space is writing log */
+#define ACPI_AML_USER  (ACPI_AML_IN_USER | ACPI_AML_OUT_USER)
+#define ACPI_AML_KERN  (ACPI_AML_IN_KERN | ACPI_AML_OUT_KERN)
+#define ACPI_AML_BUSY  (ACPI_AML_USER | ACPI_AML_KERN)
+#define ACPI_AML_OPEN  (ACPI_AML_OPENED | ACPI_AML_CLOSED)
+
+struct acpi_aml_io {
+   wait_queue_head_t wait;
+   unsigned long flags;
+   unsigned long users;
+   struct mutex lock;
+   struct task_struct *thread;
+   char out_buf[ACPI_AML_BUF_SIZE] __aligned(ACPI_AML_BUF_ALIGN);
+   struct circ_buf out_crc;
+   char in_buf[ACPI_AML_BUF_SIZE] __aligned(ACPI_AML_BUF_ALIGN);
+   struct circ_buf in_crc;
+   acpi_osd_exec_callback function;
+   void *context;
+   unsigned long usages;
+};
+
+static struct acpi_aml_io acpi_aml_io;
+static bool acpi_aml_initialized;
+static struct file *acpi_aml_active_reader;
+static struct dentry *acpi_aml_dentry;
+
+static inline bool __acpi_aml_running(void)
+{
+   return acpi_aml_io.thread ? true : false;
+}
+
+static inline bool __acpi_aml_access_ok(unsigned long flag)
+{
+   /*
+* The debugger interface is in opened state (OPENED && !CLOSED),
+* then it is allowed 

[PATCH v4 3/7] ACPICA: Debugger: Fix runtime stub issues of ACPI_DEBUGGER_EXEC using different stub mechanism

2015-12-02 Thread Lv Zheng
ACPICA commit 11522d6b894054fc4d62dd4f9863ec151296b386

The ACPI_DEBUGGER_EXEC is a problem now when the debugger code is compiled
but runtime disabled. They actually will get executed in this situation.
Although such executions are harmless if we can correctly make
acpi_db_single_step() a runtime stub, users may still do not want to see the
debugger print messages logged into OSPMs' kernel logs when a debugger
driver is not loaded to enable the debugger during runtime.

This patch fixes this issue by introducing new stub mechanism instead of
ACPI_DEBUGGER_EXEC. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/11522d6b
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acdebug.h   |   34 --
 drivers/acpi/acpica/acmacros.h  |   11 ---
 drivers/acpi/acpica/dbdisply.c  |   12 
 drivers/acpi/acpica/dbxface.c   |   30 ++
 drivers/acpi/acpica/dscontrol.c |   10 ++
 drivers/acpi/acpica/dsutils.c   |   16 
 drivers/acpi/acpica/dswexec.c   |   16 +++-
 include/acpi/acpixf.h   |   23 +++
 8 files changed, 106 insertions(+), 46 deletions(-)

diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 86474d8..dcaa15d 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -80,9 +80,15 @@ struct acpi_db_execute_walk {
 /*
  * dbxface - external debugger interfaces
  */
-acpi_status
-acpi_db_single_step(struct acpi_walk_state *walk_state,
-   union acpi_parse_object *op, u32 op_type);
+ACPI_DBR_DEPENDENT_RETURN_OK(acpi_status
+acpi_db_single_step(struct acpi_walk_state
+*walk_state,
+union acpi_parse_object *op,
+u32 op_type))
+ ACPI_DBR_DEPENDENT_RETURN_VOID(void
+   acpi_db_signal_break_point(struct
+  acpi_walk_state
+  *walk_state))
 
 /*
  * dbcmds - debug commands and output routines
@@ -182,11 +188,15 @@ void acpi_db_display_method_info(union acpi_parse_object 
*op);
 
 void acpi_db_decode_and_display_object(char *target, char *output_type);
 
-void
-acpi_db_display_result_object(union acpi_operand_object *obj_desc,
- struct acpi_walk_state *walk_state);
+ACPI_DBR_DEPENDENT_RETURN_VOID(void
+  acpi_db_display_result_object(union
+acpi_operand_object
+*obj_desc,
+struct
+acpi_walk_state
+*walk_state))
 
-acpi_status acpi_db_display_all_methods(char *display_count_arg);
+ acpi_status acpi_db_display_all_methods(char *display_count_arg);
 
 void acpi_db_display_arguments(void);
 
@@ -198,9 +208,13 @@ void acpi_db_display_calling_tree(void);
 
 void acpi_db_display_object_type(char *object_arg);
 
-void
-acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
-   struct acpi_walk_state *walk_state);
+ACPI_DBR_DEPENDENT_RETURN_VOID(void
+  acpi_db_display_argument_object(union
+  
acpi_operand_object
+  *obj_desc,
+  struct
+  acpi_walk_state
+  *walk_state))
 
 /*
  * dbexec - debugger control method execution
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index e85366c..bad5bca 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -401,17 +401,6 @@
 #endif
 
 /*
- * Some code only gets executed when the debugger is built in.
- * Note that this is entirely independent of whether the
- * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not.
- */
-#ifdef ACPI_DEBUGGER
-#define ACPI_DEBUGGER_EXEC(a)   a
-#else
-#define ACPI_DEBUGGER_EXEC(a)
-#endif
-
-/*
  * Macros used for ACPICA utilities only
  */
 
diff --git a/drivers/acpi/acpica/dbdisply.c b/drivers/acpi/acpica/dbdisply.c
index 672977e..c42ce8a 100644
--- a/drivers/acpi/acpica/dbdisply.c
+++ b/drivers/acpi/acpica/dbdisply.c
@@ -679,6 +679,12 @@ acpi_db_display_result_object(union acpi_operand_object 
*obj_desc,
  struct acpi_walk_state *walk_state)
 {
 
+#ifndef ACPI_APPLICATION
+   if (acpi_gbl_db_thr

[PATCH v4 1/7] ACPICA: Debugger: Remove unnecessary status check

2015-12-02 Thread Lv Zheng
From: Colin Ian King <colin.k...@canonical.com>

ACPICA commit f9d5c6c9a25e9f5ac05458bfcd8b381e21bb2ba5

ACPICA BZ 1205. Colin Ian King.

Link: https://bugs.acpica.org/show_bug.cgi?id=1205
Link: https://github.com/acpica/acpica/commit/f9d5c6c9
Signed-off-by: Colin Ian King <colin.k...@canonical.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/dbinput.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
index 0480254..fe93f67 100644
--- a/drivers/acpi/acpica/dbinput.c
+++ b/drivers/acpi/acpica/dbinput.c
@@ -1246,9 +1246,6 @@ acpi_status acpi_db_user_commands(char prompt, union 
acpi_parse_object *op)
 * and wait for the command to complete.
 */
acpi_os_release_mutex(acpi_gbl_db_command_ready);
-   if (ACPI_FAILURE(status)) {
-   return (status);
-   }
 
status =
acpi_os_acquire_mutex(acpi_gbl_db_command_complete,
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/7] ACPICA: Debugger: Convert some mechanisms to OSPM specific

2015-12-02 Thread Lv Zheng
The following mechanisms are OSPM specific:
1. Redirect output destination to console: no file redirection will be
   needed by an in-kernel debugger, there is even no file can be accessed
   when the debugger is running in the kernel mode.
2. Output command prompts: programs other than acpiexec can have different
   prompt characters and the prompt characters may be implemented as a
   special character sequence to form a char device IO protocol.
3. Command ready/complete handshake: OSPM debugger may wait more conditions
   to implement OSPM specific semantics (for example, FIFO full/empty
   conditions for O_NONBLOCK or IO open/close conditions).
Leaving such OSPM specific stuffs in the ACPICA debugger core blocks
Linux debugger IO driver implementation.

Several new OSL APIs are provided by this patch:
1. acpi_os_initialize_command_signals: initialize command handshake mechanism
   or any other OSPM specific stuffs.
2. acpi_os_terminate_command_signals: reversal of
   acpi_os_initialize_command_signals.
3. acpi_os_wait_command_ready: putting debugger task into wait state when a
   command is not ready. OSPMs can terminate command loop by returning
   AE_CTRL_TERMINATE from this API. Normally, wait_event() or
   wait_for_multiple_object() may be used to implement this API.
4. acpi_os_notify_command_complete: putting user task into running state when a
   command has been completed. OSPMs can terminate command loop by
   returning AE_CTRL_TERMINATE from this API. Normally, wake_up() or
   set_event() may be used to implement this API.
This patch also converts current command signaling implementation into a
generic debugger layer (osgendbg.c) to be used by the existing OSPMs or
acpiexec, in return, Linux can have chance to implement its own command
handshake mechanism. This patch also implements acpiexec batch mode in a
multi-threading mode comaptible style as a demo (this can be confirmed by
configuring acpiexec into DEBUGGER_MULTI_THREADED mode where the batch mode
is still working). Lv Zheng.

Note that the OSPM specific command handshake mechanism is required by
Linux kernel because:
1. Linux kernel trends to use wait queue to synchronize two threads, using
   mutexes to achieve that will cause false "dead lock" warnings.
2. The command handshake mechanism implemented by ACPICA is implemented in
   this way because of a design issue in debugger IO streaming. Debugger IO
   outputs are simply cached using a giant buffer, this should be tuned by
   Linux in the future.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acdebug.h |2 +-
 drivers/acpi/acpica/acglobal.h|5 --
 drivers/acpi/acpica/dbinput.c |   97 -
 drivers/acpi/acpica/dbxface.c |   63 +++-
 drivers/acpi/acpica/utmutex.c |   17 ---
 include/acpi/acpiosxf.h   |   18 ++-
 include/acpi/acpixf.h |   11 +
 include/acpi/platform/aclinux.h   |4 ++
 include/acpi/platform/aclinuxex.h |   19 
 9 files changed, 89 insertions(+), 147 deletions(-)

diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index c928ba4..86474d8 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -257,7 +257,7 @@ acpi_db_command_dispatch(char *input_buffer,
 
 void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context);
 
-acpi_status acpi_db_user_commands(char prompt, union acpi_parse_object *op);
+acpi_status acpi_db_user_commands(void);
 
 char *acpi_db_get_next_token(char *string,
 char **next, acpi_object_type * return_type);
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index faa9760..3977134 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -326,7 +326,6 @@ ACPI_GLOBAL(struct acpi_external_file *, 
acpi_gbl_external_file_list);
 #ifdef ACPI_DEBUGGER
 
 ACPI_INIT_GLOBAL(u8, acpi_gbl_abort_method, FALSE);
-ACPI_INIT_GLOBAL(u8, acpi_gbl_method_executing, FALSE);
 ACPI_INIT_GLOBAL(acpi_thread_id, acpi_gbl_db_thread_id, 
ACPI_INVALID_THREAD_ID);
 
 ACPI_GLOBAL(u8, acpi_gbl_db_opt_no_ini_methods);
@@ -345,7 +344,6 @@ ACPI_GLOBAL(acpi_object_type, 
acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]);
 
 /* These buffers should all be the same size */
 
-ACPI_GLOBAL(char, acpi_gbl_db_line_buf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL(char, acpi_gbl_db_parsed_buf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL(char, acpi_gbl_db_scope_buf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL(char, acpi_gbl_db_debug_filename[ACPI_DB_LINE_BUFFER_SIZE]);
@@ -360,9 +358,6 @@ ACPI_GLOBAL(u16, acpi_gbl_node_type_count_misc);
 ACPI_GLOBAL(u32, acpi_gbl_num_nodes);
 ACPI_GLOBAL(u32, acpi_gbl_num_objects);
 
-ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_ready);
-ACPI_GLOBAL(acpi_mutex, acpi_gbl_db_command_complete);
-
 #endif 

[PATCH v4 5/7] tools/power/acpi: Add userspace AML interface support

2015-12-02 Thread Lv Zheng
This patch adds a userspace tool to access Linux kernel AML debugger
interface.

Tow modes are supported by this tool:
1. Interactive: Users are able to launch a debugging shell to talk with
   in-kernel AML debugger.
   Note that it's user duty to ensure kernel runtime integrity by using
   this debugging tool:
   A. Some control methods evaluated by the users may result in kernel
  panics if those control methods shouldn't be evaluated by the OSPMs
  according to the current BIOS/OS configurations.
   B. Currently if a single stepping evaluation couldn't run to an end,
  then the synchronization primitives acquired by the evaluation may
  block normal OSPM control method evaluations.
2. Batch: Users are able to execute debugger commands in a script.
   Note that in addition to the above duties, it's user duty to ensure
   script runtime integrity by using this debugging tool in this mode:
   C. Currently only those commands that are not used for single stepping
  are suitable to be used in this mode.
   D. If the execution of the command may cause a failure that could result
  in an endless kernel execution, the execution of the script may also
  get blocked.
To exit the utility, currently "exit/quit" commands are recommended, but
ctrl-C" can also be used.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 tools/power/acpi/Makefile|   16 +-
 tools/power/acpi/tools/acpidbg/Makefile  |   27 ++
 tools/power/acpi/tools/acpidbg/acpidbg.c |  438 ++
 3 files changed, 473 insertions(+), 8 deletions(-)
 create mode 100644 tools/power/acpi/tools/acpidbg/Makefile
 create mode 100644 tools/power/acpi/tools/acpidbg/acpidbg.c

diff --git a/tools/power/acpi/Makefile b/tools/power/acpi/Makefile
index e882c83..a8bf908 100644
--- a/tools/power/acpi/Makefile
+++ b/tools/power/acpi/Makefile
@@ -10,18 +10,18 @@
 
 include ../../scripts/Makefile.include
 
-all: acpidump ec
-clean: acpidump_clean ec_clean
-install: acpidump_install ec_install
-uninstall: acpidump_uninstall ec_uninstall
+all: acpidbg acpidump ec
+clean: acpidbg_clean acpidump_clean ec_clean
+install: acpidbg_install acpidump_install ec_install
+uninstall: acpidbg_uninstall acpidump_uninstall ec_uninstall
 
-acpidump ec: FORCE
+acpidbg acpidump ec: FORCE
$(call descend,tools/$@,all)
-acpidump_clean ec_clean:
+acpidbg_clean acpidump_clean ec_clean:
$(call descend,tools/$(@:_clean=),clean)
-acpidump_install ec_install:
+acpidbg_install acpidump_install ec_install:
$(call descend,tools/$(@:_install=),install)
-acpidump_uninstall ec_uninstall:
+acpidbg_uninstall acpidump_uninstall ec_uninstall:
$(call descend,tools/$(@:_uninstall=),uninstall)
 
 .PHONY: FORCE
diff --git a/tools/power/acpi/tools/acpidbg/Makefile 
b/tools/power/acpi/tools/acpidbg/Makefile
new file mode 100644
index 000..352df4b
--- /dev/null
+++ b/tools/power/acpi/tools/acpidbg/Makefile
@@ -0,0 +1,27 @@
+# tools/power/acpi/tools/acpidbg/Makefile - ACPI tool Makefile
+#
+# Copyright (c) 2015, Intel Corporation
+#   Author: Lv Zheng <lv.zh...@intel.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; version 2
+# of the License.
+
+include ../../Makefile.config
+
+TOOL = acpidbg
+vpath %.c \
+   ../../../../../drivers/acpi/acpica\
+   ../../common\
+   ../../os_specific/service_layers\
+   .
+CFLAGS += -DACPI_APPLICATION -DACPI_SINGLE_THREAD -DACPI_DEBUGGER\
+   -I.\
+   -I../../../../../drivers/acpi/acpica\
+   -I../../../../../include
+LDFLAGS += -lpthread
+TOOL_OBJS = \
+   acpidbg.o
+
+include ../../Makefile.rules
diff --git a/tools/power/acpi/tools/acpidbg/acpidbg.c 
b/tools/power/acpi/tools/acpidbg/acpidbg.c
new file mode 100644
index 000..d070fcc
--- /dev/null
+++ b/tools/power/acpi/tools/acpidbg/acpidbg.c
@@ -0,0 +1,438 @@
+/*
+ * ACPI AML interfacing userspace utility
+ *
+ * Copyright (C) 2015, Intel Corporation
+ * Authors: Lv Zheng <lv.zh...@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+
+/* Headers not included by include/acpi/platform/aclinux.h */
+#include 
+#include 
+#include 
+#include 
+
+#define ACPI_AML_FILE  "/sys/kernel/debug/acpi/acpidbg"
+#define ACPI_AML_SEC_TICK  1
+#define ACPI_AML_USEC_PEEK 200
+#define ACPI_AML_BUF_SIZE  4096
+
+#define ACPI_AML_BATCH_WRITE_CMD   0x00 /* Write command to kernel */
+#define ACPI_AML_BATCH_READ_LOG0x01 /* Read log from kernel */
+#define ACPI_AML_BATCH_WRITE_LOG   0x02 /* Write log to console */
+
+#define ACPI_AML_LOG_START 0x00
+#define ACPI_AML_PROMPT_START  0x01
+#define A

[PATCH v4 6/7] ACPI / debugger: Add module support for ACPI debugger

2015-12-02 Thread Lv Zheng
This patch converts AML debugger into a loadable module.

Note that, it implements driver unloading at the level dependent on the
module reference count. Which means if ACPI debugger is being used by a
userspace program, "rmmod acpi_dbg" should result in failure.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/Kconfig |   16 +++-
 drivers/acpi/Makefile|2 +-
 drivers/acpi/acpi_dbg.c  |   80 --
 drivers/acpi/bus.c   |3 +-
 drivers/acpi/osl.c   |  207 --
 include/linux/acpi.h |   71 
 include/linux/acpi_dbg.h |   52 
 7 files changed, 340 insertions(+), 91 deletions(-)
 delete mode 100644 include/linux/acpi_dbg.h

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 2a7e6d4..82b96ee 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -60,13 +60,23 @@ config ACPI_CCA_REQUIRED
 config ACPI_DEBUGGER
bool "AML debugger interface"
select ACPI_DEBUG
-   depends on DEBUG_FS
help
- Enable in-kernel debugging of AML facilities: statistics, internal
- object dump, single step control method execution.
+ Enable in-kernel debugging of AML facilities: statistics,
+ internal object dump, single step control method execution.
  This is still under development, currently enabling this only
  results in the compilation of the ACPICA debugger files.
 
+if ACPI_DEBUGGER
+
+config ACPI_DEBUGGER_USER
+   tristate "Userspace debugger accessiblity"
+   depends on DEBUG_FS
+   help
+ Export /sys/kernel/debug/acpi/acpidbg for userspace utilities
+ to access the debugger functionalities.
+
+endif
+
 config ACPI_SLEEP
bool
depends on SUSPEND || HIBERNATION
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 102b5e6..c6f236f 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -50,7 +50,6 @@ acpi-y+= sysfs.o
 acpi-y += property.o
 acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
 acpi-$(CONFIG_DEBUG_FS)+= debugfs.o
-acpi-$(CONFIG_ACPI_DEBUGGER)   += acpi_dbg.o
 acpi-$(CONFIG_ACPI_NUMA)   += numa.o
 acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
 acpi-y += acpi_lpat.o
@@ -80,6 +79,7 @@ obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o
 obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
 obj-$(CONFIG_ACPI_BGRT)+= bgrt.o
 obj-$(CONFIG_ACPI_CPPC_LIB)+= cppc_acpi.o
+obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o
 
 # processor has its own "processor." module_param namespace
 processor-y:= processor_driver.o
diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index abc23b2..381beb2 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -21,7 +21,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include "internal.h"
 
 #define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
@@ -307,7 +307,7 @@ static int acpi_aml_readb_kern(void)
  * the debugger output and store the output into the debugger interface
  * buffer. Return the size of stored logs or errno.
  */
-ssize_t acpi_aml_write_log(const char *msg)
+static ssize_t acpi_aml_write_log(const char *msg)
 {
int ret = 0;
int count = 0, size = 0;
@@ -337,7 +337,6 @@ again:
}
return size > 0 ? size : ret;
 }
-EXPORT_SYMBOL(acpi_aml_write_log);
 
 /*
  * acpi_aml_read_cmd() - Capture debugger input
@@ -348,7 +347,7 @@ EXPORT_SYMBOL(acpi_aml_write_log);
  * the debugger input commands and store the input commands into the
  * debugger interface buffer. Return the size of stored commands or errno.
  */
-ssize_t acpi_aml_read_cmd(char *msg, size_t count)
+static ssize_t acpi_aml_read_cmd(char *msg, size_t count)
 {
int ret = 0;
int size = 0;
@@ -390,7 +389,6 @@ again:
}
return size > 0 ? size : ret;
 }
-EXPORT_SYMBOL(acpi_aml_read_cmd);
 
 static int acpi_aml_thread(void *unsed)
 {
@@ -427,7 +425,7 @@ static int acpi_aml_thread(void *unsed)
  * This function should be used to implement acpi_os_execute() which is
  * used by the ACPICA debugger to create the debugger thread.
  */
-int acpi_aml_create_thread(acpi_osd_exec_callback function, void *context)
+static int acpi_aml_create_thread(acpi_osd_exec_callback function, void 
*context)
 {
struct task_struct *t;
 
@@ -449,30 +447,27 @@ int acpi_aml_create_thread(acpi_osd_exec_callback 
function, void *context)
mutex_unlock(_aml_io.lock);
return 0;
 }
-EXPORT_SYMBOL(acpi_aml_create_thread);
 
-int acpi_aml_wait_command_ready(void)
+static int acpi_aml_wait_command_ready(bool single_step,
+  char *buffer, size_t length)
 {
acpi_status status;
 
-   if (!acpi_gbl_method_executing)
-   acpi_o

[PATCH] ACPI / debugger: Fix a redundant mutex unlock issue in acpi_aml_open()

2015-12-24 Thread Lv Zheng
Fix a double mutex_unlock() issue where acpi_initialize_debugger() is
called with the mutex already unlocked.

Reported-by: Dan Carpenter <dan.carpen...@oracle.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpi_dbg.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index fa18bd0..9c31b08 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -514,7 +514,7 @@ static int acpi_aml_open(struct inode *inode, struct file 
*file)
if (ACPI_FAILURE(status)) {
pr_err("Failed to initialize debugger.\n");
ret = -EINVAL;
-   goto err_lock;
+   goto err_exit;
}
pr_debug("Debugger thread initialized.\n");
 
@@ -531,6 +531,7 @@ err_lock:
acpi_aml_active_reader = NULL;
}
mutex_unlock(_aml_io.lock);
+err_exit:
return ret;
 }
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/42] ACPICA: Debugger: Remove some unecessary NULL checks

2015-12-28 Thread Lv Zheng
From: Markus Elfring <elfr...@users.sourceforge.net>

ACPICA commit 36fcc1b98def3fb6e20cf5e877ffc3c1592d0140

local strupr function already checks for NULL pointers.
Original linux patch submitted by:
Markus Elfring <elfr...@users.sourceforge.net>

Link: https://github.com/acpica/acpica/commit/36fcc1b9
Signed-off-by: Markus Elfring <elfr...@users.sourceforge.net>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/dbcmds.c  |9 ++---
 drivers/acpi/acpica/dbinput.c |4 +---
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/acpica/dbcmds.c b/drivers/acpi/acpica/dbcmds.c
index 84ab1c2..328c35b 100644
--- a/drivers/acpi/acpica/dbcmds.c
+++ b/drivers/acpi/acpica/dbcmds.c
@@ -1131,13 +1131,8 @@ void acpi_db_trace(char *enable_arg, char *method_arg, 
char *once_arg)
u32 debug_layer = 0;
u32 flags = 0;
 
-   if (enable_arg) {
-   acpi_ut_strupr(enable_arg);
-   }
-
-   if (once_arg) {
-   acpi_ut_strupr(once_arg);
-   }
+   acpi_ut_strupr(enable_arg);
+   acpi_ut_strupr(once_arg);
 
if (method_arg) {
if (acpi_db_trace_method_name) {
diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
index 802779a..6203001 100644
--- a/drivers/acpi/acpica/dbinput.c
+++ b/drivers/acpi/acpica/dbinput.c
@@ -625,9 +625,7 @@ static u32 acpi_db_get_line(char *input_buffer)
 
/* Uppercase the actual command */
 
-   if (acpi_gbl_db_args[0]) {
-   acpi_ut_strupr(acpi_gbl_db_args[0]);
-   }
+   acpi_ut_strupr(acpi_gbl_db_args[0]);
 
count = i;
if (count) {
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/42] ACPICA: acpiexec: Add support for AML files containing multiple tables

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 301f16e4037275888f65b88aec7231c1cd64339f

Add support for multi-AML-table files that originate from
either acpixtract or iASL.

Link: https://github.com/acpica/acpica/commit/301f16e4
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acutils.h  |4 
 drivers/acpi/acpica/utfileio.c |   23 +++
 2 files changed, 27 insertions(+)

diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 7495421..5d3ae91 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -356,6 +356,10 @@ acpi_ut_execute_power_methods(struct acpi_namespace_node 
*device_node,
  * utfileio - file operations
  */
 #ifdef ACPI_APPLICATION
+
+acpi_status
+acpi_ut_read_tables_from_file(FILE * file, struct acpi_table_header **table);
+
 acpi_status
 acpi_ut_read_table_from_file(char *filename, struct acpi_table_header **table);
 #endif
diff --git a/drivers/acpi/acpica/utfileio.c b/drivers/acpi/acpica/utfileio.c
index be49c71..e729486 100644
--- a/drivers/acpi/acpica/utfileio.c
+++ b/drivers/acpi/acpica/utfileio.c
@@ -292,6 +292,29 @@ acpi_ut_read_table(FILE * fp,
  
**/
 
 acpi_status
+acpi_ut_read_tables_from_file(FILE * file, struct acpi_table_header ** table)
+{
+   struct acpi_table_header table_header;
+   s32 count;
+   long position;
+
+   position = ftell(file);
+   count = fread(_header, 1, sizeof(struct acpi_table_header), file);
+   if (count < sizeof(struct acpi_table_header)) {
+   return (AE_CTRL_TERMINATE);
+   }
+
+   /* Allocate a buffer for the table */
+
+   *table = acpi_os_allocate((size_t) table_header.length);
+   fseek(file, position, SEEK_SET);
+
+   count = fread(*table, 1, table_header.length, file);
+
+   return (AE_OK);
+}
+
+acpi_status
 acpi_ut_read_table_from_file(char *filename, struct acpi_table_header ** table)
 {
FILE *file;
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/42] ACPICA: Disassembler/tools: Support for multiple ACPI tables in one file

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 5be7dc4d0d69b2953d156f5bc4d3e8a65a390837

Matches the support in iASL and acpi_exec.

Link: https://github.com/acpica/acpica/commit/5be7dc4d
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/Makefile   |1 -
 drivers/acpi/acpica/acapps.h   |   39 ++---
 drivers/acpi/acpica/acdebug.h  |5 +-
 drivers/acpi/acpica/aclocal.h  |7 +
 drivers/acpi/acpica/acutils.h  |   12 --
 drivers/acpi/acpica/dbfileio.c |  123 ++
 drivers/acpi/acpica/dbinput.c  |   19 ++-
 drivers/acpi/acpica/tbxfload.c |2 +-
 drivers/acpi/acpica/utfileio.c |  359 
 9 files changed, 53 insertions(+), 514 deletions(-)
 delete mode 100644 drivers/acpi/acpica/utfileio.c

diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index e75f401..f682374 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -197,7 +197,6 @@ acpi-$(ACPI_FUTURE_USAGE) +=\
dbfileio.o  \
dbtest.o\
utcache.o   \
-   utfileio.o  \
utprint.o   \
uttrack.o   \
utuuid.o
diff --git a/drivers/acpi/acpica/acapps.h b/drivers/acpi/acpica/acapps.h
index e4cc48f..185c2eb 100644
--- a/drivers/acpi/acpica/acapps.h
+++ b/drivers/acpi/acpica/acapps.h
@@ -44,6 +44,8 @@
 #ifndef _ACAPPS
 #define _ACAPPS
 
+#include 
+
 /* Common info for tool signons */
 
 #define ACPICA_NAME "Intel ACPI Component Architecture"
@@ -90,6 +92,18 @@
 #define FILE_SUFFIX_DISASSEMBLY "dsl"
 #define FILE_SUFFIX_BINARY_TABLE".dat" /* Needs the dot */
 
+/* acfileio */
+
+acpi_status
+acpi_ac_get_all_tables_from_file(char *filename,
+u8 get_only_aml_tables,
+struct acpi_new_table_desc **return_list_head);
+
+/* Values for get_only_aml_tables */
+
+#define ACPI_GET_ONLY_AML_TABLESTRUE
+#define ACPI_GET_ALL_TABLES FALSE
+
 /*
  * getopt
  */
@@ -107,30 +121,6 @@ extern char *acpi_gbl_optarg;
  */
 u32 cm_get_file_size(ACPI_FILE file);
 
-#ifndef ACPI_DUMP_APP
-/*
- * adisasm
- */
-acpi_status
-ad_aml_disassemble(u8 out_to_file,
-  char *filename, char *prefix, char **out_filename);
-
-void ad_print_statistics(void);
-
-acpi_status ad_find_dsdt(u8 **dsdt_ptr, u32 *dsdt_length);
-
-void ad_dump_tables(void);
-
-acpi_status ad_get_local_tables(void);
-
-acpi_status
-ad_parse_table(struct acpi_table_header *table,
-  acpi_owner_id * owner_id, u8 load_table, u8 external);
-
-acpi_status ad_display_tables(char *filename, struct acpi_table_header *table);
-
-acpi_status ad_display_statistics(void);
-
 /*
  * adwalk
  */
@@ -168,6 +158,5 @@ char *ad_generate_filename(char *prefix, char *table_id);
 void
 ad_write_table(struct acpi_table_header *table,
   u32 length, char *table_name, char *oem_table_id);
-#endif
 
 #endif /* _ACAPPS */
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index dcaa15d..ecb05f1 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -245,10 +245,7 @@ void acpi_db_open_debug_file(char *name);
 
 acpi_status acpi_db_load_acpi_table(char *filename);
 
-acpi_status
-acpi_db_get_table_from_file(char *filename,
-   struct acpi_table_header **table,
-   u8 must_be_aml_table);
+acpi_status acpi_db_load_tables(struct acpi_new_table_desc *list_head);
 
 /*
  * dbhistry - debugger HISTORY command
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index e1dd784..4fd5040 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -219,6 +219,13 @@ struct acpi_table_list {
 #define ACPI_ROOT_ORIGIN_ALLOCATED  (1)
 #define ACPI_ROOT_ALLOW_RESIZE  (2)
 
+/* List to manage incoming ACPI tables */
+
+struct acpi_new_table_desc {
+   struct acpi_table_header *table;
+   struct acpi_new_table_desc *next;
+};
+
 /* Predefined table indexes */
 
 #define ACPI_INVALID_TABLE_INDEX(0x)
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 5d3ae91..6776348 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -353,18 +353,6 @@ acpi_ut_execute_power_methods(struct acpi_namespace_node 
*device_node,
  u8 method_count, u8 *out_values);
 
 /*
- * utfileio - file operations
- */
-#ifdef ACPI_APPLICATION
-
-acpi_status
-acpi_ut_read_tables_from_file(FILE * file, struct acpi_table_header **table);
-
-acpi_status
-acpi_ut_read_table_from_file(char *filename, struct acpi_table_header **table);
-#endif
-
-/*
  * utids - device ID support
  */
 acpi_status
diff --git a/drivers/acpi/acpica/d

[PATCH 09/42] ACPICA: Split interpreter tracing functions to a new file

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit a3f85a7d26a52ee0d9103feb4fbec8d7b6ba4c11

Split out functions from exdebug.c to extrace.c

Link: https://github.com/acpica/acpica/commit/a3f85a7d
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/Makefile  |3 +-
 drivers/acpi/acpica/exdebug.c |  325 ---
 drivers/acpi/acpica/extrace.c |  377 +
 3 files changed, 379 insertions(+), 326 deletions(-)
 create mode 100644 drivers/acpi/acpica/extrace.c

diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 885936f..e75f401 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -50,6 +50,7 @@ acpi-y += \
exdump.o\
exfield.o   \
exfldio.o   \
+   exmisc.o\
exmutex.o   \
exnames.o   \
exoparg1.o  \
@@ -57,7 +58,6 @@ acpi-y += \
exoparg3.o  \
exoparg6.o  \
exprep.o\
-   exmisc.o\
exregion.o  \
exresnte.o  \
exresolv.o  \
@@ -66,6 +66,7 @@ acpi-y += \
exstoren.o  \
exstorob.o  \
exsystem.o  \
+   extrace.o   \
exutils.o
 
 acpi-y +=  \
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c
index 665a4b9..815442b 100644
--- a/drivers/acpi/acpica/exdebug.c
+++ b/drivers/acpi/acpica/exdebug.c
@@ -43,21 +43,11 @@
 
 #include 
 #include "accommon.h"
-#include "acnamesp.h"
 #include "acinterp.h"
-#include "acparser.h"
 
 #define _COMPONENT  ACPI_EXECUTER
 ACPI_MODULE_NAME("exdebug")
 
-static union acpi_operand_object *acpi_gbl_trace_method_object = NULL;
-
-/* Local prototypes */
-
-#ifdef ACPI_DEBUG_OUTPUT
-static const char *acpi_ex_get_trace_event_name(acpi_trace_event_type type);
-#endif
-
 #ifndef ACPI_NO_ERROR_MESSAGES
 
/***
  *
@@ -80,7 +70,6 @@ static const char 
*acpi_ex_get_trace_event_name(acpi_trace_event_type type);
  * enabled if necessary.
  *
  
**/
-
 void
 acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
u32 level, u32 index)
@@ -319,317 +308,3 @@ acpi_ex_do_debug_object(union acpi_operand_object 
*source_desc,
return_VOID;
 }
 #endif
-
-/***
- *
- * FUNCTION:acpi_ex_interpreter_trace_enabled
- *
- * PARAMETERS:  name- Whether method name should be matched,
- *this should be checked before starting
- *the tracer
- *
- * RETURN:  TRUE if interpreter trace is enabled.
- *
- * DESCRIPTION: Check whether interpreter trace is enabled
- *
- 
**/
-
-static u8 acpi_ex_interpreter_trace_enabled(char *name)
-{
-
-   /* Check if tracing is enabled */
-
-   if (!(acpi_gbl_trace_flags & ACPI_TRACE_ENABLED)) {
-   return (FALSE);
-   }
-
-   /*
-* Check if tracing is filtered:
-*
-* 1. If the tracer is started, acpi_gbl_trace_method_object should have
-*been filled by the trace starter
-* 2. If the tracer is not started, acpi_gbl_trace_method_name should be
-*matched if it is specified
-* 3. If the tracer is oneshot style, acpi_gbl_trace_method_name should
-*not be cleared by the trace stopper during the first match
-*/
-   if (acpi_gbl_trace_method_object) {
-   return (TRUE);
-   }
-   if (name &&
-   (acpi_gbl_trace_method_name &&
-strcmp(acpi_gbl_trace_method_name, name))) {
-   return (FALSE);
-   }
-   if ((acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT) &&
-   !acpi_gbl_trace_method_name) {
-   return (FALSE);
-   }
-
-   return (TRUE);
-}
-
-/***
- *
- * FUNCTION:acpi_ex_get_trace_event_name
- *
- * PARAMETERS:  type- Trace event type
- *
- * RETURN:  Trace event name.
- *
- * DESCRIPTION: Used to obtain the full trace event name.
- *
- 
**/
-
-#ifdef ACPI_DEBUG_OUTPUT
-
-static const char *acpi_ex_get_trace_event_name(acpi_trace_event_type type)
-{
-   switch (type) {
-   case ACPI_TRACE_AML_METHOD:
-
-   return "Method";
-
-   case ACPI_TRACE_AML_OPCODE:
-
-

[PATCH 06/42] ACPICA: Add "const" to some functions that return fixed strings

2015-12-28 Thread Lv Zheng
From: LABBE Corentin <clabbe.montj...@gmail.com>

ACPICA commit 28645f8a113f346c8db103a4f7565fcba88c746f

Most of the "get_name" - style functions can return "const char *"
with no ill side-effects. Original linux patch from
LABBE Corentin <clabbe.montj...@gmail.com> and backported to
ACPICA.

Link: https://github.com/acpica/acpica/commit/28645f8a
Signed-off-by: LABBE Corentin <clabbe.montj...@gmail.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acutils.h  |   14 +++---
 drivers/acpi/acpica/nsxfname.c |2 +-
 drivers/acpi/acpica/utdecode.c |   29 +
 drivers/acpi/acpica/uthex.c|2 +-
 4 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 8b8fef6..7495421 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -184,24 +184,24 @@ acpi_status acpi_ut_init_globals(void);
 
 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 
-char *acpi_ut_get_mutex_name(u32 mutex_id);
+const char *acpi_ut_get_mutex_name(u32 mutex_id);
 
 const char *acpi_ut_get_notify_name(u32 notify_value, acpi_object_type type);
 #endif
 
-char *acpi_ut_get_type_name(acpi_object_type type);
+const char *acpi_ut_get_type_name(acpi_object_type type);
 
-char *acpi_ut_get_node_name(void *object);
+const char *acpi_ut_get_node_name(void *object);
 
-char *acpi_ut_get_descriptor_name(void *object);
+const char *acpi_ut_get_descriptor_name(void *object);
 
 const char *acpi_ut_get_reference_name(union acpi_operand_object *object);
 
-char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc);
+const char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc);
 
-char *acpi_ut_get_region_name(u8 space_id);
+const char *acpi_ut_get_region_name(u8 space_id);
 
-char *acpi_ut_get_event_name(u32 event_id);
+const char *acpi_ut_get_event_name(u32 event_id);
 
 char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
 
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index 4b4d2f4..138cf5e 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -159,7 +159,7 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct 
acpi_buffer * buffer)
 {
acpi_status status;
struct acpi_namespace_node *node;
-   char *node_name;
+   const char *node_name;
 
/* Parameter validation */
 
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
index ecaaaff..7e14400 100644
--- a/drivers/acpi/acpica/utdecode.c
+++ b/drivers/acpi/acpica/utdecode.c
@@ -114,7 +114,7 @@ const char 
*acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
"PCC"   /* 0x0A */
 };
 
-char *acpi_ut_get_region_name(u8 space_id)
+const char *acpi_ut_get_region_name(u8 space_id)
 {
 
if (space_id >= ACPI_USER_REGION_BEGIN) {
@@ -127,7 +127,7 @@ char *acpi_ut_get_region_name(u8 space_id)
return ("InvalidSpaceId");
}
 
-   return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
+   return (acpi_gbl_region_types[space_id]);
 }
 
 
/***
@@ -152,14 +152,14 @@ static const char 
*acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
"RealTimeClock",
 };
 
-char *acpi_ut_get_event_name(u32 event_id)
+const char *acpi_ut_get_event_name(u32 event_id)
 {
 
if (event_id > ACPI_EVENT_MAX) {
return ("InvalidEventID");
}
 
-   return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
+   return (acpi_gbl_event_types[event_id]);
 }
 
 
/***
@@ -220,17 +220,17 @@ static const char *acpi_gbl_ns_type_names[] = {
/* 30 */ "Invalid"
 };
 
-char *acpi_ut_get_type_name(acpi_object_type type)
+const char *acpi_ut_get_type_name(acpi_object_type type)
 {
 
if (type > ACPI_TYPE_INVALID) {
-   return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
+   return (acpi_gbl_bad_type);
}
 
-   return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
+   return (acpi_gbl_ns_type_names[type]);
 }
 
-char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
+const char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
 {
ACPI_FUNCTION_TRACE(ut_get_object_type_name);
 
@@ -267,7 +267,7 @@ char *acpi_ut_get_object_type_name(union 
acpi_operand_object *obj_desc)
  *
  
**/
 
-char *acpi_ut_get_node_name(void *object)
+const char *acpi_ut_get_node_name(void *object)
 {
struct acpi_namespace_node *node = (struct acpi_namespace_

[PATCH 07/42] ACPICA: exmutex: General cleanup, restructured some code

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit c2a7d000b6be34313b1c50c8a718df16113f0f32

Should be no functional change.

Link: https://github.com/acpica/acpica/commit/c2a7d000
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/exmutex.c |   80 ++---
 1 file changed, 59 insertions(+), 21 deletions(-)

diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index a97f520..843c60a 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -185,8 +185,9 @@ acpi_ex_acquire_mutex_object(u16 timeout,
if (obj_desc == acpi_gbl_global_lock_mutex) {
status = acpi_ev_acquire_global_lock(timeout);
} else {
-   status = acpi_ex_system_wait_mutex(obj_desc->mutex.os_mutex,
-  timeout);
+   status =
+   acpi_ex_system_wait_mutex(obj_desc->mutex.os_mutex,
+ timeout);
}
 
if (ACPI_FAILURE(status)) {
@@ -243,20 +244,30 @@ acpi_ex_acquire_mutex(union acpi_operand_object 
*time_desc,
}
 
/*
-* Current sync level must be less than or equal to the sync level of 
the
-* mutex. This mechanism provides some deadlock prevention
+* Current sync level must be less than or equal to the sync level
+* of the mutex. This mechanism provides some deadlock prevention.
 */
if (walk_state->thread->current_sync_level > 
obj_desc->mutex.sync_level) {
ACPI_ERROR((AE_INFO,
-   "Cannot acquire Mutex [%4.4s], current SyncLevel is 
too large (%u)",
+   "Cannot acquire Mutex [%4.4s], "
+   "current SyncLevel is too large (%u)",
acpi_ut_get_node_name(obj_desc->mutex.node),
walk_state->thread->current_sync_level));
return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
}
 
+   ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
+ "Acquiring: Mutex SyncLevel %u, Thread SyncLevel %u, "
+ "Depth %u TID %p\n",
+ obj_desc->mutex.sync_level,
+ walk_state->thread->current_sync_level,
+ obj_desc->mutex.acquisition_depth,
+ walk_state->thread));
+
status = acpi_ex_acquire_mutex_object((u16)time_desc->integer.value,
  obj_desc,
  walk_state->thread->thread_id);
+
if (ACPI_SUCCESS(status) && obj_desc->mutex.acquisition_depth == 1) {
 
/* Save Thread object, original/current sync levels */
@@ -272,6 +283,12 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
acpi_ex_link_mutex(obj_desc, walk_state->thread);
}
 
+   ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
+ "Acquired: Mutex SyncLevel %u, Thread SyncLevel %u, 
Depth %u\n",
+ obj_desc->mutex.sync_level,
+ walk_state->thread->current_sync_level,
+ obj_desc->mutex.acquisition_depth));
+
return_ACPI_STATUS(status);
 }
 
@@ -356,9 +373,9 @@ acpi_status
 acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
  struct acpi_walk_state *walk_state)
 {
-   acpi_status status = AE_OK;
u8 previous_sync_level;
struct acpi_thread_state *owner_thread;
+   acpi_status status = AE_OK;
 
ACPI_FUNCTION_TRACE(ex_release_mutex);
 
@@ -409,7 +426,8 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
 */
if (obj_desc->mutex.sync_level != owner_thread->current_sync_level) {
ACPI_ERROR((AE_INFO,
-   "Cannot release Mutex [%4.4s], SyncLevel mismatch: 
mutex %u current %u",
+   "Cannot release Mutex [%4.4s], SyncLevel mismatch: "
+   "mutex %u current %u",
acpi_ut_get_node_name(obj_desc->mutex.node),
obj_desc->mutex.sync_level,
walk_state->thread->current_sync_level));
@@ -424,6 +442,15 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
previous_sync_level =
owner_thread->acquired_mutex_list->mutex.original_sync_level;
 
+   ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
+ "Releasing: Object SyncLevel %u, Thread SyncLevel %u, 
"
+ "Prev SyncLevel %u, Depth %u TID %p\n"

[PATCH 34/42] ACPICA: Events: Uses common_notify for address space handlers

2015-12-28 Thread Lv Zheng
ACPICA commit 5ea0fb75fdf1aa7c0aba067dfa4d5dc3a9279461

The address space handlers can be attached to not only Device but also
Processor/thermal_zone objects, so it is better to use their common
class 'CommonNotify' instead. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/5ea0fb75
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/dbdisply.c  |6 +++---
 drivers/acpi/acpica/evhandler.c |   12 +++-
 drivers/acpi/acpica/evrgnini.c  |   10 +-
 drivers/acpi/acpica/evxfregn.c  |4 ++--
 4 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/acpica/dbdisply.c b/drivers/acpi/acpica/dbdisply.c
index a66b4ae..1965b48 100644
--- a/drivers/acpi/acpica/dbdisply.c
+++ b/drivers/acpi/acpica/dbdisply.c
@@ -957,7 +957,7 @@ void acpi_db_display_handlers(void)
 
handler_obj =
acpi_ev_find_region_handler(space_id,
-   obj_desc->device.
+   obj_desc->common_notify.
handler);
if (handler_obj) {
acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
@@ -980,7 +980,7 @@ found_handler:  ;
 
/* Find all handlers for user-defined space_IDs */
 
-   handler_obj = obj_desc->device.handler;
+   handler_obj = obj_desc->common_notify.handler;
while (handler_obj) {
if (handler_obj->address_space.space_id >=
ACPI_USER_REGION_BEGIN) {
@@ -1082,7 +1082,7 @@ acpi_db_display_non_root_handlers(acpi_handle obj_handle,
 
/* Display all handlers associated with this device */
 
-   handler_obj = obj_desc->device.handler;
+   handler_obj = obj_desc->common_notify.handler;
while (handler_obj) {
acpi_os_printf(ACPI_PREDEFINED_PREFIX,
   acpi_ut_get_region_name((u8)handler_obj->
diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c
index 6a7fc11..709419c 100644
--- a/drivers/acpi/acpica/evhandler.c
+++ b/drivers/acpi/acpica/evhandler.c
@@ -159,7 +159,7 @@ acpi_ev_has_default_handler(struct acpi_namespace_node 
*node,
 
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
-   handler_obj = obj_desc->device.handler;
+   handler_obj = obj_desc->common_notify.handler;
 
/* Walk the linked list of handlers for this object */
 
@@ -250,7 +250,8 @@ acpi_ev_install_handler(acpi_handle obj_handle,
next_handler_obj =
acpi_ev_find_region_handler(handler_obj->address_space.
space_id,
-   obj_desc->device.handler);
+   obj_desc->common_notify.
+   handler);
if (next_handler_obj) {
 
/* Found a handler, is it for the same address space? */
@@ -444,7 +445,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * 
node,
 * the handler is not already installed.
 */
handler_obj = acpi_ev_find_region_handler(space_id,
- obj_desc->device.
+ obj_desc->
+ common_notify.
  handler);
 
if (handler_obj) {
@@ -531,13 +533,13 @@ acpi_ev_install_space_handler(struct acpi_namespace_node 
* node,
 
/* Install at head of Device.address_space list */
 
-   handler_obj->address_space.next = obj_desc->device.handler;
+   handler_obj->address_space.next = obj_desc->common_notify.handler;
 
/*
 * The Device object is the first reference on the handler_obj.
 * Each region that uses the handler adds a reference.
 */
-   obj_desc->device.handler = handler_obj;
+   obj_desc->common_notify.handler = handler_obj;
 
/*
 * Walk the namespace finding all of the regions this handler will
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 4df81b5..024689d 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -566,18 +566,10 @@ acpi_ev_initialize_region(union acpi_operand_object 
*region_obj,
 
switch (node->type) {
case ACPI_TYPE_DEVICE:
-
-   handler_obj = obj_desc->device.handler;
-

[PATCH 35/42] ACPICA: Utilities: Reorder initialization code

2015-12-28 Thread Lv Zheng
ACPICA commit 3894fa9d071343e6ebc7ea480255fa4f27a290be

This patch re-orders initialization code in acpi_enable_subsystem()
so that all hardware reduced stuffs can be collected together.

Note this patch contains code from the following 2 ACPICA upstream commits
so that the changes can be made clearer for the reviewers:
 https://github.com/acpica/acpica/commit/071eff73
 https://github.com/acpica/acpica/commit/3894fa9d
And additional change to remove the global variable and unused code
fragments due to the test result. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/3894fa9d
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/utxfinit.c |   31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
index 8586260..7d8eb60 100644
--- a/drivers/acpi/acpica/utxfinit.c
+++ b/drivers/acpi/acpica/utxfinit.c
@@ -154,6 +154,21 @@ acpi_status __init acpi_enable_subsystem(u32 flags)
 */
acpi_gbl_early_initialization = FALSE;
 
+   /*
+* Install the default operation region handlers. These are the
+* handlers that are defined by the ACPI specification to be
+* "always accessible" -- namely, system_memory, system_IO, and
+* PCI_Config. This also means that no _REG methods need to be
+* run for these address spaces. We need to have these handlers
+* installed before any AML code can be executed, especially any
+* module-level code (11/2015).
+*/
+   status = acpi_ev_install_region_handlers();
+   if (ACPI_FAILURE(status)) {
+   ACPI_EXCEPTION((AE_INFO, status,
+   "During Region initialization"));
+   return_ACPI_STATUS(status);
+   }
 #if (!ACPI_REDUCED_HARDWARE)
 
/* Enable ACPI mode */
@@ -182,24 +197,8 @@ acpi_status __init acpi_enable_subsystem(u32 flags)
return_ACPI_STATUS(status);
}
}
-#endif /* !ACPI_REDUCED_HARDWARE */
 
/*
-* Install the default op_region handlers. These are installed unless
-* other handlers have already been installed via the
-* install_address_space_handler interface.
-*/
-   if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
-   ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
- "[Init] Installing default address space 
handlers\n"));
-
-   status = acpi_ev_install_region_handlers();
-   if (ACPI_FAILURE(status)) {
-   return_ACPI_STATUS(status);
-   }
-   }
-#if (!ACPI_REDUCED_HARDWARE)
-   /*
 * Initialize ACPI Event handling (Fixed and General Purpose)
 *
 * Note1: We must have the hardware and events initialized before we can
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 33/42] ACPICA: Events: Deploys acpi_ev_find_region_handler()

2015-12-28 Thread Lv Zheng
ACPICA commit b916a0a0ae9e81db1a85523c63ec6aa32d5c70c8

There are code fragments that can be substituted by
acpi_ev_find_region_handler().
This patch cleans up these code fragments. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/b916a0a0
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/acevents.h  |5 +++
 drivers/acpi/acpica/dbdisply.c  |   30 
 drivers/acpi/acpica/evhandler.c |   58 ++-
 drivers/acpi/acpica/evrgnini.c  |   73 +--
 4 files changed, 75 insertions(+), 91 deletions(-)

diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 228704b7..42975ab 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -161,6 +161,11 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info 
*gpe_xrupt_info,
 /*
  * evhandler - Address space handling
  */
+union acpi_operand_object *acpi_ev_find_region_handler(acpi_adr_space_type
+  space_id,
+  union acpi_operand_object
+  *handler_obj);
+
 u8
 acpi_ev_has_default_handler(struct acpi_namespace_node *node,
acpi_adr_space_type space_id);
diff --git a/drivers/acpi/acpica/dbdisply.c b/drivers/acpi/acpica/dbdisply.c
index 390a7ca..a66b4ae 100644
--- a/drivers/acpi/acpica/dbdisply.c
+++ b/drivers/acpi/acpica/dbdisply.c
@@ -48,6 +48,7 @@
 #include "acnamesp.h"
 #include "acparser.h"
 #include "acinterp.h"
+#include "acevents.h"
 #include "acdebug.h"
 
 #define _COMPONENT  ACPI_CA_DEBUGGER
@@ -949,28 +950,25 @@ void acpi_db_display_handlers(void)
if (obj_desc) {
for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) 
{
space_id = acpi_gbl_space_id_list[i];
-   handler_obj = obj_desc->device.handler;
 
acpi_os_printf(ACPI_PREDEFINED_PREFIX,
   acpi_ut_get_region_name((u8)space_id),
   space_id);
 
-   while (handler_obj) {
-   if (acpi_gbl_space_id_list[i] ==
-   handler_obj->address_space.space_id) {
-   acpi_os_printf
-   (ACPI_HANDLER_PRESENT_STRING,
-(handler_obj->address_space.
- handler_flags &
- 
ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
-? "Default" : "User",
-handler_obj->address_space.
-handler);
-
-   goto found_handler;
-   }
+   handler_obj =
+   acpi_ev_find_region_handler(space_id,
+   obj_desc->device.
+   handler);
+   if (handler_obj) {
+   acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
+  (handler_obj->address_space.
+   handler_flags &
+   
ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
+  ? "Default" : "User",
+  handler_obj->address_space.
+  handler);
 
-   handler_obj = handler_obj->address_space.next;
+   goto found_handler;
}
 
/* There is no handler for this space_id */
diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c
index 5d6a3b5..6a7fc11 100644
--- a/drivers/acpi/acpica/evhandler.c
+++ b/drivers/acpi/acpica/evhandler.c
@@ -55,10 +55,6 @@ static acpi_status
 acpi_ev_install_handler(acpi_handle obj_handle,
u32 level, void *context, void **return_value);
 
-static union acpi_operand_object
-*acpi_ev_find_region_handler(acpi_adr_space_type space_id,
-union acpi_operand_object *handler_obj);
-
 /* These are the address spaces that will get default handlers */
 
 u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
@@ -251,35 +247,30 @@ acpi_ev_install_handler(acpi_handle obj_handle,
 
/* Check if this Dev

[PATCH 32/42] ACPICA: Cleanup code related to the per-table module level improvement

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 071eff738c59eda1792ac24b3b688b61691d7e7c

This patch collects cleanups from per-table module level improvement. By
splitting this patch from that commit, we can make per-table module level
improvement clearer for the revewers. This is a no-op change.

Link: https://github.com/acpica/acpica/commit/071eff73
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acglobal.h  |1 +
 drivers/acpi/acpica/evhandler.c |  113 +--
 drivers/acpi/acpica/evregion.c  |6 +++
 drivers/acpi/acpica/evrgnini.c  |2 +-
 drivers/acpi/acpica/exdump.c|6 ++-
 drivers/acpi/acpica/utxfinit.c  |7 +++
 6 files changed, 91 insertions(+), 44 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 3977134..ef0abf4 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -145,6 +145,7 @@ ACPI_GLOBAL(acpi_cache_t *, acpi_gbl_operand_cache);
 
 ACPI_INIT_GLOBAL(u32, acpi_gbl_startup_flags, 0);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_shutdown, TRUE);
+ACPI_INIT_GLOBAL(u8, acpi_gbl_early_initialization, TRUE);
 
 /* Global handlers */
 
diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c
index 74e8595..5d6a3b5 100644
--- a/drivers/acpi/acpica/evhandler.c
+++ b/drivers/acpi/acpica/evhandler.c
@@ -55,6 +55,10 @@ static acpi_status
 acpi_ev_install_handler(acpi_handle obj_handle,
u32 level, void *context, void **return_value);
 
+static union acpi_operand_object
+*acpi_ev_find_region_handler(acpi_adr_space_type space_id,
+union acpi_operand_object *handler_obj);
+
 /* These are the address spaces that will get default handlers */
 
 u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
@@ -309,6 +313,43 @@ acpi_ev_install_handler(acpi_handle obj_handle,
 
 
/***
  *
+ * FUNCTION:acpi_ev_find_region_handler
+ *
+ * PARAMETERS:  space_id- The address space ID
+ *  handler_obj - Head of the handler object list
+ *
+ * RETURN:  Matching handler object. NULL if space ID not matched
+ *
+ * DESCRIPTION: Search a handler object list for a match on the address
+ *  space ID.
+ *
+ 
**/
+
+static union acpi_operand_object
+*acpi_ev_find_region_handler(acpi_adr_space_type space_id,
+union acpi_operand_object *handler_obj)
+{
+
+   /* Walk the handler list for this device */
+
+   while (handler_obj) {
+
+   /* Same space_id indicates a handler is installed */
+
+   if (handler_obj->address_space.space_id == space_id) {
+   return (handler_obj);
+   }
+
+   /* Next handler object */
+
+   handler_obj = handler_obj->address_space.next;
+   }
+
+   return (NULL);
+}
+
+/***
+ *
  * FUNCTION:acpi_ev_install_space_handler
  *
  * PARAMETERS:  node- Namespace node for the device
@@ -332,15 +373,15 @@ acpi_ev_install_space_handler(struct acpi_namespace_node 
* node,
 {
union acpi_operand_object *obj_desc;
union acpi_operand_object *handler_obj;
-   acpi_status status;
+   acpi_status status = AE_OK;
acpi_object_type type;
u8 flags = 0;
 
ACPI_FUNCTION_TRACE(ev_install_space_handler);
 
/*
-* This registration is valid for only the types below and the root. 
This
-* is where the default handlers get placed.
+* This registration is valid for only the types below and the root.
+* The root node is where the default handlers get installed.
 */
if ((node->type != ACPI_TYPE_DEVICE) &&
(node->type != ACPI_TYPE_PROCESSOR) &&
@@ -407,38 +448,29 @@ acpi_ev_install_space_handler(struct acpi_namespace_node 
* node,
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
/*
-* The attached device object already exists. Make sure the 
handler
-* is not already installed.
+* The attached device object already exists. Now make sure
+* the handler is not already installed.
 */
-   handler_obj = obj_desc->device.handler;
-
-   /* Walk the handler list for this device */
-
-   while (handler_obj) {
+   handler_obj = acpi_ev_find_region_handler(space_id,
+ obj_desc->device.
+ handler);
 
-   

[PATCH 31/42] ACPICA: Update for CondRefOf and RefOf operators

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 725c094f1a7a2ae28e623ee77be400af1c36b180

The SuperName parameters for these operators were incorrect. This
represents two problems in the ACPI specification itself.

Link: https://github.com/acpica/acpica/commit/725c094f
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/acopcode.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index c6b2f42..324512d 100644
--- a/drivers/acpi/acpica/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
@@ -92,7 +92,7 @@
 #define ARGP_BYTELIST_OPARGP_LIST1 (ARGP_NAMESTRING)
 #define ARGP_CONCAT_OP  ARGP_LIST3 (ARGP_TERMARG,
ARGP_TERMARG,   ARGP_TARGET)
 #define ARGP_CONCAT_RES_OP  ARGP_LIST3 (ARGP_TERMARG,
ARGP_TERMARG,   ARGP_TARGET)
-#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME,  
ARGP_SUPERNAME)
+#define ARGP_COND_REF_OF_OP ARGP_LIST2 
(ARGP_NAME_OR_REF,ARGP_TARGET)
 #define ARGP_CONNECTFIELD_OPARGP_LIST1 (ARGP_NAMESTRING)
 #define ARGP_CONTINUE_OPARG_NONE
 #define ARGP_COPY_OPARGP_LIST2 (ARGP_TERMARG,
ARGP_SIMPLENAME)
@@ -159,7 +159,7 @@
 #define ARGP_POWER_RES_OP   ARGP_LIST5 (ARGP_PKGLENGTH,  
ARGP_NAME,  ARGP_BYTEDATA,  ARGP_WORDDATA,  ARGP_OBJLIST)
 #define ARGP_PROCESSOR_OP   ARGP_LIST6 (ARGP_PKGLENGTH,  
ARGP_NAME,  ARGP_BYTEDATA,  ARGP_DWORDDATA, ARGP_BYTEDATA,  
ARGP_OBJLIST)
 #define ARGP_QWORD_OP   ARGP_LIST1 (ARGP_QWORDDATA)
-#define ARGP_REF_OF_OP  ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_REF_OF_OP  ARGP_LIST1 (ARGP_NAME_OR_REF)
 #define ARGP_REGION_OP  ARGP_LIST4 (ARGP_NAME,   
ARGP_BYTEDATA,  ARGP_TERMARG,   ARGP_TERMARG)
 #define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME)
 #define ARGP_RESERVEDFIELD_OP   ARGP_LIST1 (ARGP_NAMESTRING)
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 39/42] ACPICA: Events: Introduce ACPI_REG_DISCONNECT invocation to acpi_ev_execute_reg_methods()

2015-12-28 Thread Lv Zheng
ACPICA commit 1cf1a1e090f61f0c27f1dcf1905c7cc79a9c51c8

It is likely that we should synchronously invoke _REG(DISCONNECT) only when
the acpi_remove_address_space_handler() is invoked because of dependencies.
If it is invoked when the object is not referenced, problem may occur
if the operation region fields accessed in _REG are no longer driven by any
device driver.

Noticed that _REG(CONNECT)/_REG(DISCONNECT) only mean to inform the AML of
the handler availability, no return value is required for the caller.

This patch only introduces ACPI_REG_DISCONNECT invaocation, but doesn't
introduce a real change. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/1cf1a1e0
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/acevents.h |4 ++--
 drivers/acpi/acpica/aclocal.h  |1 +
 drivers/acpi/acpica/evregion.c |   26 +-
 drivers/acpi/acpica/evxfregn.c |2 +-
 4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 772ee3c..d18f184 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -200,9 +200,9 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
 
 void acpi_ev_associate_reg_method(union acpi_operand_object *region_obj);
 
-acpi_status
+void
 acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
-   acpi_adr_space_type space_id);
+   acpi_adr_space_type space_id, u32 function);
 
 acpi_status
 acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 
function);
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 034402d..24928ec 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -428,6 +428,7 @@ struct acpi_simple_repair_info {
 
 struct acpi_reg_walk_info {
acpi_adr_space_type space_id;
+   u32 function;
u32 reg_run_count;
 };
 
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index cf6e878..a43178f 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -97,10 +97,9 @@ acpi_status acpi_ev_initialize_op_regions(void)
if (acpi_ev_has_default_handler(acpi_gbl_root_node,
acpi_gbl_default_address_spaces
[i])) {
-   status =
-   acpi_ev_execute_reg_methods(acpi_gbl_root_node,
-   
acpi_gbl_default_address_spaces
-   [i]);
+   acpi_ev_execute_reg_methods(acpi_gbl_root_node,
+   
acpi_gbl_default_address_spaces
+   [i], ACPI_REG_CONNECT);
}
}
 
@@ -683,24 +682,25 @@ cleanup1:
  *
  * PARAMETERS:  node- Namespace node for the device
  *  space_id- The address space ID
+ *  function- Passed to _REG: On (1) or Off (0)
  *
- * RETURN:  Status
+ * RETURN:  None
  *
  * DESCRIPTION: Run all _REG methods for the input Space ID;
  *  Note: assumes namespace is locked, or system init time.
  *
  
**/
 
-acpi_status
+void
 acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
-   acpi_adr_space_type space_id)
+   acpi_adr_space_type space_id, u32 function)
 {
-   acpi_status status;
struct acpi_reg_walk_info info;
 
ACPI_FUNCTION_TRACE(ev_execute_reg_methods);
 
info.space_id = space_id;
+   info.function = function;
info.reg_run_count = 0;
 
ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
@@ -713,9 +713,9 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node 
*node,
 * regions and _REG methods. (i.e. handlers must be installed for all
 * regions of this Space ID before we can run any _REG methods)
 */
-   status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
-   ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
-   NULL, , NULL);
+   (void)acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
+ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, NULL,
+, NULL);
 
/* Special case for EC: handle "orphan" _REG methods with no region */
 
@@ -728,7 +728,7 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node 
*node,
  info.reg_run_count,
  acpi_ut_get_region_name(info.space_id)));
 
-   ret

[PATCH 38/42] ACPICA: Events: Enhance acpi_ev_execute_reg_method() to ensure no _REG evaluations can happen during OS early boot stages

2015-12-28 Thread Lv Zheng
ACPICA commit 31178590dde82368fdb0f6b0e466b6c0add96c57

We can ensure no early _REG evaluations by ensuring the following rules in
acpi_ev_execute_reg_method():
1. If an address space handler is installed during early stage,
   _REG(CONNECT) evaluations are blocked. This is achieved using
   acpi_gbl_reg_methods_enabled which is renamed from
   acpi_gbl_reg_methods_executed.
2. If _REG(CONNECT) has never been evalauted for the region object,
   _REG(DISCONNECT) evaluations are blocked. This is achieved by a new
   region object flag: AOPOBJ_REG_CONNECTED.
Note that, after applying this patch, we can ensure _REG(DISCONNECT) is
always paired to _REG(CONNECT). Lv Zheng

Link: https://github.com/acpica/acpica/commit/31178590
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/acglobal.h |2 +-
 drivers/acpi/acpica/acobject.h |7 ---
 drivers/acpi/acpica/evregion.c |   25 ++---
 drivers/acpi/acpica/evxfregn.c |   33 -
 drivers/acpi/acpica/excreate.c |3 ++-
 drivers/acpi/acpica/utinit.c   |1 -
 drivers/acpi/acpica/utxfinit.c |1 +
 7 files changed, 30 insertions(+), 42 deletions(-)

diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index ef0abf4..73462ca 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -165,7 +165,7 @@ ACPI_GLOBAL(u8, acpi_gbl_next_owner_id_offset);
 
 /* Initialization sequencing */
 
-ACPI_GLOBAL(u8, acpi_gbl_reg_methods_executed);
+ACPI_INIT_GLOBAL(u8, acpi_gbl_reg_methods_enabled, FALSE);
 
 /* Misc */
 
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index 0bd02c4..2b154cf 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -93,9 +93,10 @@
 #define AOPOBJ_AML_CONSTANT 0x01   /* Integer is an AML constant */
 #define AOPOBJ_STATIC_POINTER   0x02   /* Data is part of an ACPI 
table, don't delete */
 #define AOPOBJ_DATA_VALID   0x04   /* Object is initialized and 
data is valid */
-#define AOPOBJ_OBJECT_INITIALIZED   0x08   /* Region is initialized, _REG 
was run */
-#define AOPOBJ_SETUP_COMPLETE   0x10   /* Region setup is complete */
-#define AOPOBJ_INVALID  0x20   /* Host OS won't allow a Region 
address */
+#define AOPOBJ_OBJECT_INITIALIZED   0x08   /* Region is initialized */
+#define AOPOBJ_REG_CONNECTED0x10   /* _REG was run */
+#define AOPOBJ_SETUP_COMPLETE   0x20   /* Region setup is complete */
+#define AOPOBJ_INVALID  0x40   /* Host OS won't allow a Region 
address */
 
 /**
  *
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 432b810..cf6e878 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -104,8 +104,6 @@ acpi_status acpi_ev_initialize_op_regions(void)
}
}
 
-   acpi_gbl_reg_methods_executed = TRUE;
-
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(status);
 }
@@ -601,7 +599,18 @@ acpi_ev_execute_reg_method(union acpi_operand_object 
*region_obj, u32 function)
return_ACPI_STATUS(AE_NOT_EXIST);
}
 
-   if (region_obj2->extra.method_REG == NULL) {
+   if (region_obj2->extra.method_REG == NULL ||
+   region_obj->region.handler == NULL ||
+   !acpi_gbl_reg_methods_enabled) {
+   return_ACPI_STATUS(AE_OK);
+   }
+
+   /* _REG(DISCONNECT) should be paired with _REG(CONNECT) */
+
+   if ((function == ACPI_REG_CONNECT &&
+region_obj->common.flags & AOPOBJ_REG_CONNECTED) ||
+   (function == ACPI_REG_DISCONNECT &&
+!(region_obj->common.flags & AOPOBJ_REG_CONNECTED))) {
return_ACPI_STATUS(AE_OK);
}
 
@@ -650,6 +659,16 @@ acpi_ev_execute_reg_method(union acpi_operand_object 
*region_obj, u32 function)
status = acpi_ns_evaluate(info);
acpi_ut_remove_reference(args[1]);
 
+   if (ACPI_FAILURE(status)) {
+   goto cleanup2;
+   }
+
+   if (function == ACPI_REG_CONNECT) {
+   region_obj->common.flags |= AOPOBJ_REG_CONNECTED;
+   } else {
+   region_obj->common.flags &= ~AOPOBJ_REG_CONNECTED;
+   }
+
 cleanup2:
acpi_ut_remove_reference(args[0]);
 
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index 3c90508..29f9f39 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -112,39 +112,6 @@ acpi_install_address_space_handler(acpi_handle device,
goto unlock_and_exit;
}
 
-   /*
-* For the default space_IDs, (the IDs for which there are default 
region handlers
-* installed

[PATCH 37/42] ACPICA: Events: Split acpi_ev_associate_reg_method() from region initialization code

2015-12-28 Thread Lv Zheng
ACPICA commit 87c85610250ff7141a84507f68dbc1e00f2936db

This patch introduces a new region initialization function
acpi_ev_associate_reg_method(), which is invoked to associate the _REG method
to its related region object.

Region object's default value assignments are also sorted by cleaning up
the code using this new function. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/87c85610
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/acevents.h |2 ++
 drivers/acpi/acpica/evregion.c |   46 
 drivers/acpi/acpica/evrgnini.c |   30 ++
 drivers/acpi/acpica/excreate.c |6 +-
 4 files changed, 55 insertions(+), 29 deletions(-)

diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 42975ab..772ee3c 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -198,6 +198,8 @@ void
 acpi_ev_detach_region(union acpi_operand_object *region_obj,
  u8 acpi_ns_is_locked);
 
+void acpi_ev_associate_reg_method(union acpi_operand_object *region_obj);
+
 acpi_status
 acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
acpi_adr_space_type space_id);
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 19a4e69..432b810 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -529,6 +529,52 @@ acpi_ev_attach_region(union acpi_operand_object 
*handler_obj,
 
 
/***
  *
+ * FUNCTION:acpi_ev_associate_reg_method
+ *
+ * PARAMETERS:  region_obj  - Region object
+ *
+ * RETURN:  Status
+ *
+ * DESCRIPTION: Find and associate _REG method to a region
+ *
+ 
**/
+
+void acpi_ev_associate_reg_method(union acpi_operand_object *region_obj)
+{
+   acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
+   struct acpi_namespace_node *method_node;
+   struct acpi_namespace_node *node;
+   union acpi_operand_object *region_obj2;
+   acpi_status status;
+
+   ACPI_FUNCTION_TRACE(ev_associate_reg_method);
+
+   region_obj2 = acpi_ns_get_secondary_object(region_obj);
+   if (!region_obj2) {
+   return_VOID;
+   }
+
+   node = region_obj->region.node->parent;
+
+   /* Find any "_REG" method associated with this region definition */
+
+   status =
+   acpi_ns_search_one_scope(*reg_name_ptr, node, ACPI_TYPE_METHOD,
+_node);
+   if (ACPI_SUCCESS(status)) {
+   /*
+* The _REG method is optional and there can be only one per 
region
+* definition. This will be executed when the handler is 
attached
+* or removed
+*/
+   region_obj2->extra.method_REG = method_node;
+   }
+
+   return_VOID;
+}
+
+/***
+ *
  * FUNCTION:acpi_ev_execute_reg_method
  *
  * PARAMETERS:  region_obj  - Region object
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 024689d..bb2e529 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -507,9 +507,6 @@ acpi_ev_initialize_region(union acpi_operand_object 
*region_obj,
acpi_adr_space_type space_id;
struct acpi_namespace_node *node;
acpi_status status;
-   struct acpi_namespace_node *method_node;
-   acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
-   union acpi_operand_object *region_obj2;
 
ACPI_FUNCTION_TRACE_U32(ev_initialize_region, acpi_ns_locked);
 
@@ -521,35 +518,12 @@ acpi_ev_initialize_region(union acpi_operand_object 
*region_obj,
return_ACPI_STATUS(AE_OK);
}
 
-   region_obj2 = acpi_ns_get_secondary_object(region_obj);
-   if (!region_obj2) {
-   return_ACPI_STATUS(AE_NOT_EXIST);
-   }
+   acpi_ev_associate_reg_method(region_obj);
+   region_obj->common.flags |= AOPOBJ_OBJECT_INITIALIZED;
 
node = region_obj->region.node->parent;
space_id = region_obj->region.space_id;
 
-   /* Setup defaults */
-
-   region_obj->region.handler = NULL;
-   region_obj2->extra.method_REG = NULL;
-   region_obj->common.flags &= ~(AOPOBJ_SETUP_COMPLETE);
-   region_obj->common.flags |= AOPOBJ_OBJECT_INITIALIZED;
-
-   /* Find any "_REG" method associated with this region definition */
-
-   status =
-   acpi_ns_search_one_scope(*reg_name_ptr, node, ACPI_TYPE_METHOD,
-_node);
-   if (ACPI_SUCCESS(status)) {
-   /*
-  

[PATCH 42/42] ACPICA: Update version to 20151218

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit e81cedadd3a847d40f30bc9c52dfe441620ed12f

Version 20151218.

Link: https://github.com/acpica/acpica/commit/e81cedad
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 include/acpi/acpixf.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 8c95e82..1b462d8 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in MMDD format */
 
-#define ACPI_CA_VERSION 0x20150930
+#define ACPI_CA_VERSION 0x20151218
 
 #include 
 #include 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 41/42] ACPICA: Add per-table execution of module-level code

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 071eff738c59eda1792ac24b3b688b61691d7e7c

Execute any module-level code after each ACPI table (DSDT or SSDT)
is loaded into the namespace (rather than after all AML tables have
been loaded. This matches the behavior of other ACPI
implementations and is required to support BIOS code that
depends on this behavior.

Link: https://github.com/acpica/acpica/commit/071eff73
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/nsload.c   |   17 +
 drivers/acpi/acpica/utxfinit.c |8 +++-
 include/acpi/acpixf.h  |5 +
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index c106916..14c953e 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -149,6 +149,23 @@ unlock:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  " Completed Table Object Initialization\n"));
 
+   /*
+* Execute any module-level code that was detected during the table load
+* phase. Although illegal since ACPI 2.0, there are many machines that
+* contain this type of code. Each block of detected executable AML code
+* outside of any control method is wrapped with a temporary control
+* method object and placed on a global list. The methods on this list
+* are executed below.
+*
+* This case executes the module-level code for each table immediately
+* after the table has been loaded. This provides compatibility with
+* other ACPI implementations. Optionally, the execution can be deferred
+* until later, see acpi_initialize_objects.
+*/
+   if (!acpi_gbl_group_module_level_code) {
+   acpi_ns_exec_module_code_list();
+   }
+
return_ACPI_STATUS(status);
 }
 
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
index 1c7ed49..e38facd 100644
--- a/drivers/acpi/acpica/utxfinit.c
+++ b/drivers/acpi/acpica/utxfinit.c
@@ -292,8 +292,14 @@ acpi_status __init acpi_initialize_objects(u32 flags)
 * outside of any control method is wrapped with a temporary control
 * method object and placed on a global list. The methods on this list
 * are executed below.
+*
+* This case executes the module-level code for all tables only after
+* all of the tables have been loaded. It is a legacy option and is
+* not compatible with other ACPI implementations. See 
acpi_ns_load_table.
 */
-   acpi_ns_exec_module_code_list();
+   if (acpi_gbl_group_module_level_code) {
+   acpi_ns_exec_module_code_list();
+   }
 
/*
 * Initialize the objects that remain uninitialized. This runs the
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index d60507b7..8c95e82 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -190,6 +190,11 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_copy_dsdt_locally, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_do_not_use_xsdt, FALSE);
 
 /*
+ * Optionally support group module level code.
+ */
+ACPI_INIT_GLOBAL(u8, acpi_gbl_group_module_level_code, TRUE);
+
+/*
  * Optionally use 32-bit FADT addresses if and when there is a conflict
  * (address mismatch) between the 32-bit and 64-bit versions of the
  * address. Although ACPICA adheres to the ACPI specification which
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 40/42] ACPICA: Add "root node" case to the ACPI name repair code

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 95b40b31aa8148629fbe5de0356725fc01298003

Special-case the namespace root node, it has an unusual name.
This case can occur if there are errors during the execution
of module-level code.

Link: https://github.com/acpica/acpica/commit/95b40b31
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/utstring.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c
index 0c2e2d2..958b2f7 100644
--- a/drivers/acpi/acpica/utstring.c
+++ b/drivers/acpi/acpica/utstring.c
@@ -240,6 +240,14 @@ void acpi_ut_repair_name(char *name)
 
ACPI_FUNCTION_NAME(ut_repair_name);
 
+   /*
+* Special case for the root node. This can happen if we get an
+* error during the execution of module-level code.
+*/
+   if (ACPI_COMPARE_NAME(name, "\\___")) {
+   return;
+   }
+
ACPI_MOVE_NAME(_name, name);
 
/* Check each character in the name */
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 36/42] ACPICA: Events: Fix an issue that region object is re-attached to another scope when it is already attached

2015-12-28 Thread Lv Zheng
ACPICA commit 6ebcb24d3225b6c7715a3ce061c327b4c3a6b76e

The logic in acpi_ev_attach_region() is not correct, it can break address
space handler link. This patch fixes this problem. But be aware that this
fix must be applied along with a region object race issue fix. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/6ebcb24d
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/evregion.c |   13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 6717e57..19a4e69 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -504,6 +504,12 @@ acpi_ev_attach_region(union acpi_operand_object 
*handler_obj,
 
ACPI_FUNCTION_TRACE(ev_attach_region);
 
+   /* Install the region's handler */
+
+   if (region_obj->region.handler) {
+   return_ACPI_STATUS(AE_ALREADY_EXISTS);
+   }
+
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
  "Adding Region [%4.4s] %p to address handler %p 
[%s]\n",
  acpi_ut_get_node_name(region_obj->region.node),
@@ -515,13 +521,6 @@ acpi_ev_attach_region(union acpi_operand_object 
*handler_obj,
 
region_obj->region.next = handler_obj->address_space.region_list;
handler_obj->address_space.region_list = region_obj;
-
-   /* Install the region's handler */
-
-   if (region_obj->region.handler) {
-   return_ACPI_STATUS(AE_ALREADY_EXISTS);
-   }
-
region_obj->region.handler = handler_obj;
acpi_ut_add_reference(handler_obj);
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/42] ACPICA: Linuxize: reduce divergences for 20151218 release

2015-12-28 Thread Lv Zheng
The patch reduces source code differences between the Linux kernel and the
ACPICA upstream so that the linuxized ACPICA 20151218 release can be
applied with reduced human intervention.

The pscode.c has already been out of sync for months, and it becomes more
and more difficult to merge pscode.c changes, so instead of update the
affected lines of pscode.c, this patch synchronizes entire pscode.c file.

Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/dsfield.c |8 +-
 drivers/acpi/acpica/dsutils.c |4 +-
 drivers/acpi/acpica/exconvrt.c|4 +-
 drivers/acpi/acpica/excreate.c|5 +-
 drivers/acpi/acpica/exfield.c |2 +-
 drivers/acpi/acpica/exmutex.c |2 +-
 drivers/acpi/acpica/exoparg3.c|6 +-
 drivers/acpi/acpica/hwgpe.c   |1 +
 drivers/acpi/acpica/nsrepair2.c   |2 +-
 drivers/acpi/acpica/psopcode.c|  604 ++---
 drivers/acpi/acpica/rsmisc.c  |6 +-
 drivers/acpi/acpica/utobject.c|4 +-
 include/acpi/platform/aclinuxex.h |1 +
 13 files changed, 325 insertions(+), 324 deletions(-)

diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index 20de148..37e11a3 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -310,8 +310,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
switch (arg->common.aml_opcode) {
case AML_INT_RESERVEDFIELD_OP:
 
-   position = (u64) info->field_bit_position
-   + (u64) arg->common.value.size;
+   position = (u64)info->field_bit_position
+   + (u64)arg->common.value.size;
 
if (position > ACPI_UINT32_MAX) {
ACPI_ERROR((AE_INFO,
@@ -425,8 +425,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
 
/* Keep track of bit position for the next field */
 
-   position = (u64) info->field_bit_position
-   + (u64) arg->common.value.size;
+   position = (u64)info->field_bit_position
+   + (u64)arg->common.value.size;
 
if (position > ACPI_UINT32_MAX) {
ACPI_ERROR((AE_INFO,
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index e4293a8..cecba39 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -504,8 +504,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
if ((walk_state->deferred_node) &&
(walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD)
&& (arg_index ==
-   (u32) ((walk_state->opcode ==
-   AML_CREATE_FIELD_OP) ? 3 : 2))) {
+   (u32)((walk_state->opcode ==
+  AML_CREATE_FIELD_OP) ? 3 : 2))) {
obj_desc =
ACPI_CAST_PTR(union acpi_operand_object,
  walk_state->deferred_node);
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 1e4c5b6..145de28 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -355,8 +355,8 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, 
u8 data_width)
/* Get one hex digit, most significant digits first */
 
string[k] =
-   (u8) acpi_ut_hex_to_ascii_char(integer,
-  ACPI_MUL_4(j));
+   (u8)acpi_ut_hex_to_ascii_char(integer,
+ ACPI_MUL_4(j));
k++;
}
break;
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index ccb7219..95fe464 100644
--- a/drivers/acpi/acpica/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -492,10 +492,9 @@ acpi_ex_create_method(u8 * aml_start,
 * Disassemble the method flags. Split off the arg_count, Serialized
 * flag, and sync_level for efficiency.
 */
-   method_flags = (u8) operand[1]->integer.value;
-
+   method_flags = (u8)operand[1]->integer.value;
obj_desc->method.param_count =
-   (u8) (method_flags & AML_METHOD_ARG_COUNT);
+   (u8)(method_flags & AML_METHOD_ARG_COUNT);
 
/*
 * Get the sync_level. If method is serialized, a mutex will be
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index 61fd9c7..c95fd18 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -439,7 +439,7 @@ acpi_ex_w

[PATCH 00/42] ACPICA: 20151218 Release

2015-12-28 Thread Lv Zheng
The 20151218 ACPICA kernel-resident subsystem updates are linuxized based
on the linux-pm/linux-next branch.

The patchset has passed the following build/boot tests.
Build tests are performed as follows:
1. i386 + allyes
2. i386 + allno
3. i386 + default + ACPI_DEBUGGER=y
4. i386 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y
5. i386 + default + ACPI_DEBUG=n + ACPI=y
6. i386 + default + ACPI=n
7. x86_64 + allyes
8. x86_64 + allno
9. x86_64 + default + ACPI_DEBUGGER=y
10.x86_64 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y
11.x86_64 + default + ACPI_DEBUG=n + ACPI=y
12.x86_64 + default + ACPI=n
Boot tests are performed as follows:
1. i386 + default + ACPI_DEBUGGER=y
2. x86_64 + default + ACPI_DEBUGGER=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 "drivers/platform" drivers
   All other drivers that link the APIs provided by ACPICA subsystem

The divergences checking result:
Before applying (20150930 Release):
  517 lines
After applying (20151218 Release):
  506 lines

Bob Moore (25):
  ACPICA: exmutex: General cleanup, restructured some code
  ACPICA: Core: Major update for code formatting, no functional changes
  ACPICA: Split interpreter tracing functions to a new file
  ACPICA: acpiexec: Add support for AML files containing multiple
tables
  ACPICA: Disassembler/tools: Support for multiple ACPI tables in one
file
  ACPICA: iasl/acpiexec: Update input file handling and verification
  ACPICA: Revert "acpi_get_object_info: Add support for ACPI 5.0 _SUB
method."
  ACPICA: Add comment explaining _SUB removal
  ACPICA: acpiexec/acpinames: Update for error checking macros
  ACPICA: Concatenate operator: Add extensions to support all ACPI
objects
  ACPICA: Debug Object: Cleanup output
  ACPICA: Debug object: Fix output for a NULL object
  ACPICA: Update for output of the Debug Object
  ACPICA: getopt: Comment update, no functional change
  ACPICA: Add new exception code, AE_IO_ERROR
  ACPICA: iasl/Disassembler: Support ASL ElseIf operator
  ACPICA: Parser: Add constants for internal namepath function
  ACPICA: Parser: Fix for SuperName method invocation
  ACPICA: Update parameter type for ObjectType operator
  ACPICA: Update internal #defines for ObjectType operator. No
functional change
  ACPICA: Update for CondRefOf and RefOf operators
  ACPICA: Cleanup code related to the per-table module level
improvement
  ACPICA: Add "root node" case to the ACPI name repair code
  ACPICA: Add per-table execution of module-level code
  ACPICA: Update version to 20151218

Colin Ian King (1):
  ACPICA: Tools: Add spacing and missing options in acpibin tool

David E. Box (1):
  ACPICA: Fix SyncLevel support interaction with method
auto-serialization

LABBE Corentin (1):
  ACPICA: Add "const" to some functions that return fixed strings

Lv Zheng (12):
  ACPICA: Linuxize: reduce divergences for 20151218 release
  ACPICA: Namespace: Fix wrong error log
  ACPICA: Debugger: reduce old external path format
  ACPICA: Namespace: Add scope information to the simple object repair
mechanism
  ACPICA: Namespace: Add String -> ObjectReference conversion support
  ACPICA: Events: Deploys acpi_ev_find_region_handler()
  ACPICA: Events: Uses common_notify for address space handlers
  ACPICA: Utilities: Reorder initialization code
  ACPICA: Events: Fix an issue that region object is re-attached to
another scope when it is already attached
  ACPICA: Events: Split acpi_ev_associate_reg_method() from region
initialization code
  ACPICA: Events: Enhance acpi_ev_execute_reg_method() to ensure no
_REG evaluations can happen during OS early boot stages
  ACPICA: Events: Introduce ACPI_REG_DISCONNECT invocation to
acpi_ev_execute_reg_methods()

Markus Elfring (1):
  ACPICA: Debugger: Remove some unecessary NULL checks

Prarit Bhargava (1):
  ACPICA: acpi_get_sleep_type_data: Reduce warnings

 drivers/acpi/acpica/Makefile   |4 +-
 drivers/acpi/acpica/acapps.h   |   58 +-
 drivers/acpi/acpica/acdebug.h  |5 +-
 drivers/acpi/acpica/acevents.h |   11 +-
 drivers/acpi/acpica/acglobal.h |3 +-
 drivers/acpi/acpica/aclocal.h  |   12 +-
 drivers/acpi/acpica/acnamesp.h |   12 +-
 drivers/acpi/acpica/acobject.h |7 +-
 drivers/acpi/acpica/acopcode.h |   10 +-
 drivers/acpi/acpica/acparser.h |8 +-
 drivers/acpi/acpica/acutils.h  |   26 +-
 drivers/acpi/acpica/amlcode.h  |5 +-
 drivers/acpi/acpica/dbcmds.c   |   11 +-
 drivers/a

[PATCH 04/42] ACPICA: Debugger: reduce old external path format

2015-12-28 Thread Lv Zheng
ACPICA commit 75c0da9e796bdf9bdd46d75f028a3e1779903214

In the error logs and debugger outputs, use new external path format that
does not contain a trailing underscore.
This patch takes care of acpi_ns_get_external_pathname() invocations, chaning
them into acpi_ns_get_normalized_pathname(TRUE) where possible. Along with some
error log fixes, the following debugger commands are fixed: resources,
handlers, paths. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/75c0da9e
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/dbcmds.c|2 +-
 drivers/acpi/acpica/dbdisply.c  |2 +-
 drivers/acpi/acpica/dbnames.c   |2 +-
 drivers/acpi/acpica/dbtest.c|2 +-
 drivers/acpi/acpica/nsdump.c|2 +-
 drivers/acpi/acpica/nseval.c|2 +-
 drivers/acpi/acpica/nsinit.c|3 ++-
 drivers/acpi/acpica/nssearch.c  |2 +-
 drivers/acpi/acpica/utaddress.c |5 +++--
 9 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/acpica/dbcmds.c b/drivers/acpi/acpica/dbcmds.c
index 30414b3..84ab1c2 100644
--- a/drivers/acpi/acpica/dbcmds.c
+++ b/drivers/acpi/acpica/dbcmds.c
@@ -798,7 +798,7 @@ acpi_db_device_resources(acpi_handle obj_handle,
acpi_status status;
 
node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
-   parent_path = acpi_ns_get_external_pathname(node);
+   parent_path = acpi_ns_get_normalized_pathname(node, TRUE);
if (!parent_path) {
return (AE_NO_MEMORY);
}
diff --git a/drivers/acpi/acpica/dbdisply.c b/drivers/acpi/acpica/dbdisply.c
index c42ce8a..3acc3a5 100644
--- a/drivers/acpi/acpica/dbdisply.c
+++ b/drivers/acpi/acpica/dbdisply.c
@@ -1091,7 +1091,7 @@ acpi_db_display_non_root_handlers(acpi_handle obj_handle,
return (AE_OK);
}
 
-   pathname = acpi_ns_get_external_pathname(node);
+   pathname = acpi_ns_get_normalized_pathname(node, TRUE);
if (!pathname) {
return (AE_OK);
}
diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
index 04ff1eb..4f68dfc 100644
--- a/drivers/acpi/acpica/dbnames.c
+++ b/drivers/acpi/acpica/dbnames.c
@@ -438,7 +438,7 @@ acpi_db_walk_for_predefined_names(acpi_handle obj_handle,
return (AE_OK);
}
 
-   pathname = acpi_ns_get_external_pathname(node);
+   pathname = acpi_ns_get_normalized_pathname(node, TRUE);
if (!pathname) {
return (AE_OK);
}
diff --git a/drivers/acpi/acpica/dbtest.c b/drivers/acpi/acpica/dbtest.c
index 10ea8bf..68b4e8d 100644
--- a/drivers/acpi/acpica/dbtest.c
+++ b/drivers/acpi/acpica/dbtest.c
@@ -953,7 +953,7 @@ acpi_db_evaluate_one_predefined_name(acpi_handle obj_handle,
return (AE_OK);
}
 
-   pathname = acpi_ns_get_external_pathname(node);
+   pathname = acpi_ns_get_normalized_pathname(node, TRUE);
if (!pathname) {
return (AE_OK);
}
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index 37aa5c4..e071956 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -717,7 +717,7 @@ acpi_ns_dump_one_object_path(acpi_handle obj_handle,
return (AE_OK);
}
 
-   pathname = acpi_ns_get_external_pathname(node);
+   pathname = acpi_ns_get_normalized_pathname(node, TRUE);
 
path_indent = 1;
if (level <= max_level) {
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index 7eba578..15e0b2e 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -135,7 +135,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info 
*info)
 
/* Get the full pathname to the object, for use in warning messages */
 
-   info->full_pathname = acpi_ns_get_external_pathname(info->node);
+   info->full_pathname = acpi_ns_get_normalized_pathname(info->node, TRUE);
if (!info->full_pathname) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 656eacf..ac59929 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -582,7 +582,8 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
 
/* Ignore error and move on to next device */
 
-   char *scope_name = acpi_ns_get_external_pathname(device_node);
+   char *scope_name =
+   acpi_ns_get_normalized_pathname(device_node, TRUE);
 
ACPI_EXCEPTION((AE_INFO, status, "during %s._INI execution",
scope_name));
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index d739040..9cc3564d 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -105,7 +105,7 @@ acpi_ns_search_one_scope(u32 target_name,
  

[PATCH 03/42] ACPICA: Namespace: Fix wrong error log

2015-12-28 Thread Lv Zheng
ACPICA commit 20228e39e125d92f9d80c6e07d3767b225d0536e

The Info->Node in acpi_ns_init_one_device() may not be initialized. Even it is
initialized, the redundant "._INI" can be seen for this log entry. This
patch fixes this issue by using device_node instead. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/20228e39
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
---
 drivers/acpi/acpica/nsinit.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index b744a53..656eacf 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -582,7 +582,7 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
 
/* Ignore error and move on to next device */
 
-   char *scope_name = acpi_ns_get_external_pathname(info->node);
+   char *scope_name = acpi_ns_get_external_pathname(device_node);
 
ACPI_EXCEPTION((AE_INFO, status, "during %s._INI execution",
scope_name));
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/42] ACPICA: acpi_get_sleep_type_data: Reduce warnings

2015-12-28 Thread Lv Zheng
From: Prarit Bhargava <pra...@redhat.com>

ACPICA commit 7bb77313091e52a846df4c9c2bea90be31bfb9d8

Eliminate warnings for "not found" _Sx errors, since these
are optional. Original NOT_FOUND status is still returned.

Original changes by Prarit Bhargava.
ACPICA BZ 1208.

Link: https://github.com/acpica/acpica/commit/7bb77313
Link: https://bugs.acpica.org/show_bug.cgi?id=1208
Signed-off-by: Prarit Bhargava <pra...@redhat.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/hwxface.c |   24 +---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 5f97468..b2e50d8 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -504,11 +504,20 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 
*sleep_type_a, u8 *sleep_type_b)
 * Evaluate the \_Sx namespace object containing the register values
 * for this state
 */
-   info->relative_pathname =
-   ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]);
+   info->relative_pathname = ACPI_CAST_PTR(char,
+   acpi_gbl_sleep_state_names
+   [sleep_state]);
+
status = acpi_ns_evaluate(info);
if (ACPI_FAILURE(status)) {
-   goto cleanup;
+   if (status == AE_NOT_FOUND) {
+
+   /* The _Sx states are optional, ignore NOT_FOUND */
+
+   goto final_cleanup;
+   }
+
+   goto warning_cleanup;
}
 
/* Must have a return object */
@@ -517,7 +526,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, 
u8 *sleep_type_b)
ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]",
info->relative_pathname));
status = AE_AML_NO_RETURN_VALUE;
-   goto cleanup;
+   goto warning_cleanup;
}
 
/* Return object must be of type Package */
@@ -526,7 +535,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, 
u8 *sleep_type_b)
ACPI_ERROR((AE_INFO,
"Sleep State return object is not a Package"));
status = AE_AML_OPERAND_TYPE;
-   goto cleanup1;
+   goto return_value_cleanup;
}
 
/*
@@ -570,16 +579,17 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 
*sleep_type_a, u8 *sleep_type_b)
break;
}
 
-cleanup1:
+return_value_cleanup:
acpi_ut_remove_reference(info->return_object);
 
-cleanup:
+warning_cleanup:
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status,
"While evaluating Sleep State [%s]",
info->relative_pathname));
}
 
+final_cleanup:
ACPI_FREE(info);
return_ACPI_STATUS(status);
 }
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/42] ACPICA: Fix SyncLevel support interaction with method auto-serialization

2015-12-28 Thread Lv Zheng
From: "David E. Box" <david.e@linux.intel.com>

ACPICA commit 253e3c03efc1a495d2aa61eee09ab1d0842a3dce

The control method auto-serialization can interfere with existing
ASL code that makes use of Mutex/Method SyncLevel support. This
change makes the auto-serialization transparent to the SyncLevel
support and management. David Box.

Link: https://github.com/acpica/acpica/commit/253e3c03
Signed-off-by: David E. Box <david.e@linux.intel.com>
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/dsmethod.c |   15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index bc32f31..49ba082 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -411,8 +411,19 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node 
*method_node,
 
obj_desc->method.mutex->mutex.thread_id =
walk_state->thread->thread_id;
-   walk_state->thread->current_sync_level =
-   obj_desc->method.sync_level;
+
+   /*
+* Update the current sync_level only if this 
is not an auto-
+* serialized method. In the auto case, we have 
to ignore
+* the sync level for the method mutex (created 
for the
+* auto-serialization) because we have no idea 
of what the
+* sync level should be. Therefore, just ignore 
it.
+*/
+   if (!(obj_desc->method.info_flags &
+ ACPI_METHOD_IGNORE_SYNC_LEVEL)) {
+   walk_state->thread->current_sync_level =
+   obj_desc->method.sync_level;
+   }
} else {
obj_desc->method.mutex->mutex.
original_sync_level =
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/42] ACPICA: Core: Major update for code formatting, no functional changes

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit dfa394471f6c01b2ee9433dbc143ec70cb9bca72

Mostly indentation inconsistencies across the code. Split
some long lines, etc.

Link: https://github.com/acpica/acpica/commit/dfa39447
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/dbstats.c  |1 +
 drivers/acpi/acpica/dbutils.c  |1 +
 drivers/acpi/acpica/dsargs.c   |7 +-
 drivers/acpi/acpica/dsdebug.c  |5 +-
 drivers/acpi/acpica/dsfield.c  |   39 +-
 drivers/acpi/acpica/dsinit.c   |2 +-
 drivers/acpi/acpica/dsmethod.c |   24 +++---
 drivers/acpi/acpica/dsmthdat.c |   20 ++---
 drivers/acpi/acpica/dsobject.c |   19 +++--
 drivers/acpi/acpica/dsopcode.c |   21 ++---
 drivers/acpi/acpica/dsutils.c  |   29 ---
 drivers/acpi/acpica/dswexec.c  |   19 ++---
 drivers/acpi/acpica/dswload.c  |   10 +--
 drivers/acpi/acpica/dswload2.c |   10 +--
 drivers/acpi/acpica/dswscope.c |1 +
 drivers/acpi/acpica/evgpe.c|2 +-
 drivers/acpi/acpica/evgpeblk.c |1 +
 drivers/acpi/acpica/evgpeutil.c|1 +
 drivers/acpi/acpica/evmisc.c   |5 +-
 drivers/acpi/acpica/evxface.c  |9 +--
 drivers/acpi/acpica/evxfregn.c |1 +
 drivers/acpi/acpica/exconfig.c |8 +-
 drivers/acpi/acpica/exconvrt.c |9 +--
 drivers/acpi/acpica/excreate.c |   10 +--
 drivers/acpi/acpica/exdebug.c  |1 +
 drivers/acpi/acpica/exfield.c  |   74 ++
 drivers/acpi/acpica/exfldio.c  |   35 +
 drivers/acpi/acpica/exmisc.c   |   10 ++-
 drivers/acpi/acpica/exnames.c  |4 +-
 drivers/acpi/acpica/exoparg1.c |   31 +---
 drivers/acpi/acpica/exoparg2.c |   12 ++-
 drivers/acpi/acpica/exoparg3.c |   19 +++--
 drivers/acpi/acpica/exoparg6.c |1 +
 drivers/acpi/acpica/exprep.c   |   25 +++---
 drivers/acpi/acpica/exregion.c |   13 ++--
 drivers/acpi/acpica/exresnte.c |2 +-
 drivers/acpi/acpica/exresolv.c |   10 +--
 drivers/acpi/acpica/exresop.c  |   43 ++-
 drivers/acpi/acpica/exstore.c  |   17 ++--
 drivers/acpi/acpica/exstorob.c |7 +-
 drivers/acpi/acpica/exsystem.c |6 +-
 drivers/acpi/acpica/exutils.c  |7 +-
 drivers/acpi/acpica/hwesleep.c |4 +-
 drivers/acpi/acpica/hwgpe.c|7 +-
 drivers/acpi/acpica/hwsleep.c  |4 +-
 drivers/acpi/acpica/hwxfsleep.c|1 +
 drivers/acpi/acpica/nsconvert.c|   18 ++---
 drivers/acpi/acpica/nsdump.c   |3 +
 drivers/acpi/acpica/nsload.c   |1 -
 drivers/acpi/acpica/nsnames.c  |6 +-
 drivers/acpi/acpica/nsparse.c  |5 +-
 drivers/acpi/acpica/nsprepkg.c |   10 ++-
 drivers/acpi/acpica/nsrepair.c |6 +-
 drivers/acpi/acpica/nsrepair2.c|   22 --
 drivers/acpi/acpica/nsutils.c  |8 +-
 drivers/acpi/acpica/nsxfeval.c |4 +-
 drivers/acpi/acpica/nsxfname.c |1 +
 drivers/acpi/acpica/nsxfobj.c  |6 +-
 drivers/acpi/acpica/psargs.c   |1 +
 drivers/acpi/acpica/psloop.c   |4 +-
 drivers/acpi/acpica/psparse.c  |8 +-
 drivers/acpi/acpica/psutils.c  |4 +-
 drivers/acpi/acpica/pswalk.c   |1 +
 drivers/acpi/acpica/rsaddr.c   |4 +-
 drivers/acpi/acpica/rscalc.c   |   81 ++--
 drivers/acpi/acpica/rscreate.c |   32 
 drivers/acpi/acpica/rsdump.c   |6 ++
 drivers/acpi/acpica/rslist.c   |9 ++-
 drivers/acpi/acpica/rsmisc.c   |   22 +++---
 drivers/acpi/acpica/rsutils.c  |   42 +-
 drivers/acpi/acpica/rsxface.c  |2 +-
 drivers/acpi/acpica/tbdata.c   |1 +
 drivers/acpi/acpica/tbinstal.c |4 +-
 d

[PATCH 28/42] ACPICA: Parser: Fix for SuperName method invocation

2015-12-28 Thread Lv Zheng
From: Bob Moore <robert.mo...@intel.com>

ACPICA commit 4b86d1046d06e462dae83ebcd5a66cc132a08f8f

SuperName parameters that are in fact control method invocations were
not handled correctly by the parser. This change fixes the problem
by identifying these properly as method invocations. This affects
about 14 different ASL operators that contain SuperName parameters.
ACPICA BZ 1002.

Link: https://github.com/acpica/acpica/commit/4b86d104
Link: https://bugs.acpica.org/show_bug.cgi?id=1002
Signed-off-by: Bob Moore <robert.mo...@intel.com>
Signed-off-by: Lv Zheng <lv.zh...@intel.com>
---
 drivers/acpi/acpica/psargs.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index 0fdb7fc..f84e546 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -269,7 +269,8 @@ acpi_ps_get_next_namepath(struct acpi_walk_state 
*walk_state,
 */
if (ACPI_SUCCESS(status) &&
possible_method_call && (node->type == ACPI_TYPE_METHOD)) {
-   if (walk_state->opcode == AML_UNLOAD_OP) {
+   if (GET_CURRENT_ARG_TYPE(walk_state->arg_types) ==
+   ARGP_SUPERNAME) {
/*
 * acpi_ps_get_next_namestring has increased the AML 
pointer,
 * so we need to restore the saved AML pointer for 
method call.
@@ -696,7 +697,7 @@ static union acpi_parse_object 
*acpi_ps_get_next_field(struct acpi_parse_state
  *
  * PARAMETERS:  walk_state  - Current state
  *  parser_state- Current parser state object
- *  arg_type- The argument type (AML_*_ARG)
+ *  arg_type- The parser argument type (ARGP_*)
  *  return_arg  - Where the next arg is returned
  *
  * RETURN:  Status, and an op object containing the next argument.
@@ -815,9 +816,9 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
return_ACPI_STATUS(AE_NO_MEMORY);
}
 
-   /* To support super_name arg of Unload */
+   /* super_name allows argument to be a method call */
 
-   if (walk_state->opcode == AML_UNLOAD_OP) {
+   if (arg_type == ARGP_SUPERNAME) {
status =
acpi_ps_get_next_namepath(walk_state,
  parser_state, arg,
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


<    1   2   3   4   5   6   7   8   9   10   >