1. 30 5月, 2017 1 次提交
    • L
      ACPICA: Tables: Fix regression introduced by a too early mechanism enabling · 2ea65321
      Lv Zheng 提交于
      In the Linux kernel, acpi_get_table() "clones" haven't been fully
      balanced by acpi_put_table() invocations.  In upstream ACPICA, due to
      the design change, there are also unbalanced acpi_get_table_by_index()
      invocations requiring special care.
      
      acpi_get_table() reference counting mismatches may occor due to that
      and printing error messages related to them is not useful at this
      point.  The strict balanced validation count check should only be
      enabled after confirming that all invocations are safe and aligned
      with their designed purposes.
      
      Thus this patch removes the error value returned by acpi_tb_get_table()
      in that case along with the accompanying error message to fix the
      issue.
      
      Fixes: 174cc718 (ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel)
      Cc: 4.10+ <stable@vger.kernel.org> # 4.10+
      Reported-by: NAnush Seetharaman <anush.seetharaman@intel.com>
      Reported-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NLv Zheng <lv.zheng@intel.com>
      [ rjw: Changelog ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      2ea65321
  2. 29 4月, 2017 1 次提交
  3. 27 4月, 2017 11 次提交
  4. 14 4月, 2017 1 次提交
  5. 12 4月, 2017 1 次提交
    • L
      ACPICA: Add non-linux host build support · 6895baa6
      Lv Zheng 提交于
      _LINUX: used to detect a target build is a linux kernel/application.
      __linux__: used to detect a build is on a linux hosts.
      
      Thus we can see: if a linux kernel build is performed on environments other
      than linux hosts, __linux__ may not be defined by the compiler and _LINUX
      cannot cover linux kernel resident ACPICA files, as it's only defined in
      <linux/acpi.h> and hence only allows non ACPICA kernel files to correctly
      include aclinux.h.
      As a conclusion, we don't actually support such build.
      
      This patch adds -D_LINUX for ACPICA files so that kernel builds on any
      hosts can use unified _LINUX as a linux kernel target indication to
      correctly include aclinux.h.
      Tested-by: NAl Stone <ahs3@redhat.com>
      Signed-off-by: NLv Zheng <lv.zheng@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6895baa6
  6. 28 2月, 2017 1 次提交
  7. 09 2月, 2017 2 次提交
  8. 20 1月, 2017 1 次提交
    • L
      ACPICA: Tables: Fix hidden logic related to acpi_tb_install_standard_table() · 7a37052a
      Lv Zheng 提交于
      There is a hidden logic for acpi_tb_install_standard_table() as it can be
      invoked from the boot stage and during runtime.
      
       1. When it is invoked from the OS boot stage, the ACPICA mutex may not have
          been initialized yet and so acpi_ut_acquire_mutex()/acpi_ut_release_mutex()
          are not invoked in these code paths:
      
         acpi_initialize_tables
           acpi_tb_parse_root_table
             acpi_tb_install_standard_table (4 invocations)
         acpi_install_table
             acpi_tb_install_standard_table
      
       2. When it is invoked during the runtime, ACPICA mutex is used as
          appropriate:
      
         acpi_ex_load_op
           acpi_tb_install_and_load_table
             acpi_tb_install_standard_table
         acpi_load_table
           acpi_tb_install_and_load_table
             acpi_tb_install_standard_table
      
      The mutex is now used in acpi_tb_install_and_load_table(), while it actually
      should be in acpi_tb_install_standard_table().
      
      This introduces another problem in acpi_tb_install_standard_table() where
      acpi_gbl_table_handler is invoked from and the lock contexts are thus not
      consistent for the table handlers. This triggers a regression when
      acpi_get_table()/acpi_put_table() start to hold table mutex during runtime.
      
      The regression is noticed by LKP as new errors reported by ACPICA mutex
      debugging facility.
      
      [    2.043693] ACPI Error: Mutex [ACPI_MTX_Tables] already acquired by this thread [497483776] (20160930/utmutex-254)
      [    2.054084] ACPI Error: Mutex [0x2] is not acquired, cannot release (20160930/utmutex-326)
      
      And it triggers a deadlock:
      
      [  247.066214] INFO: task swapper/0:1 blocked for more than 120 seconds.
      ...
      [  247.091271] Call Trace:
      ...
      [  247.121523]  down_timeout+0x47/0x50
      [  247.125065]  acpi_os_wait_semaphore+0x47/0x62
      [  247.129475]  acpi_ut_acquire_mutex+0x43/0x81
      [  247.133798]  acpi_get_table+0x2d/0x84
      [  247.137513]  acpi_table_attr_init+0xcd/0x100
      [  247.146590]  acpi_sysfs_table_handler+0x5d/0xb8
      [  247.151174]  acpi_bus_table_handler+0x23/0x2a
      [  247.155583]  acpi_tb_install_standard_table+0xe0/0x213
      [  247.164489]  acpi_tb_install_and_load_table+0x3a/0x82
      [  247.169592]  acpi_ex_load_op+0x194/0x201
      ...
      [  247.200108]  acpi_ns_evaluate+0x1bb/0x247
      [  247.204170]  acpi_evaluate_object+0x178/0x274
      [  247.213249]  acpi_processor_set_pdc+0x154/0x17b
      ...
      The table mutex is held in acpi_tb_install_and_load_table() and is re-visited by
      acpi_get_table().
      
      Noticing that the early mutex requirement actually belongs to the OSL layer
      and has already been handled in acpi_os_wait_semaphore()/acpi_os_signal_semaphore(),
      the regression canbe fixed by removing this hidden logic from the ACPICA core
      to the OS-specific code.
      
      Fixes: 174cc718 ("ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel")
      Reported-and-tested-by: NTomi Sarvela <tomi.p.sarvela@intel.com>
      Reported-by: NYe Xiaolong <xiaolong.ye@intel.com>
      Signed-off-by: NLv Zheng <lv.zheng@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      7a37052a
  9. 05 1月, 2017 4 次提交
  10. 03 1月, 2017 10 次提交
  11. 21 12月, 2016 2 次提交
    • L
      ACPICA: Tables: Allow FADT to be customized with virtual address · 66360faa
      Lv Zheng 提交于
      ACPICA commit d98de9ca14891130efc5dcdc871b97eb27b4b0f5
      
      FADT parsing code requires FADT to be installed as
      ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, using new
      acpi_tb_get_table()/acpi_tb_put_table(), other address types can also be allowed,
      thus facilitates FADT customization with virtual address. Lv Zheng.
      
      Link: https://github.com/acpica/acpica/commit/d98de9caSigned-off-by: NLv Zheng <lv.zheng@intel.com>
      Signed-off-by: NBob Moore <robert.moore@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      66360faa
    • L
      ACPICA: Tables: Back port acpi_get_table_with_size() and... · 174cc718
      Lv Zheng 提交于
      ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
      
      ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
      
      This patch back ports Linux acpi_get_table_with_size() and
      early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
      
      The 2 APIs are used by Linux as table management APIs for long time, it
      contains a hidden logic that during the early stage, the mapped tables
      should be unmapped before the early stage ends.
      
      During the early stage, tables are handled by the following sequence:
       acpi_get_table_with_size();
       parse the table
       early_acpi_os_unmap_memory();
      During the late stage, tables are handled by the following sequence:
       acpi_get_table();
       parse the table
      Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
      late stage.
      
      The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
      remember the early mapped pointer in acpi_get_table() and Linux isn't able to
      prevent ACPICA from using the wrong early mapped pointer during the late
      stage as there is no API provided from ACPICA to be an inverse of
      acpi_get_table() to forget the early mapped pointer.
      
      But how ACPICA can work with the early/late stage requirement? Inside of
      ACPICA, tables are ensured to be remained in "INSTALLED" state during the
      early stage, and they are carefully not transitioned to "VALIDATED" state
      until the late stage. So the same logic is in fact implemented inside of
      ACPICA in a different way. The gap is only that the feature is not provided
      to the OSPMs in an accessible external API style.
      
      It then is possible to fix the gap by providing an inverse of
      acpi_get_table() from ACPICA, so that the two Linux sequences can be
      combined:
       acpi_get_table();
       parse the table
       acpi_put_table();
      In order to work easier with the current Linux code, acpi_get_table() and
      acpi_put_table() is implemented in a usage counting based style:
       1. When the usage count of the table is increased from 0 to 1, table is
          mapped and .Pointer is set with the mapping address (VALIDATED);
       2. When the usage count of the table is decreased from 1 to 0, .Pointer
          is unset and the mapping address is unmapped (INVALIDATED).
      So that we can deploy the new APIs to Linux with minimal effort by just
      invoking acpi_get_table() in acpi_get_table_with_size() and invoking
      acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
      
      Link: https://github.com/acpica/acpica/commit/cac67909Signed-off-by: NLv Zheng <lv.zheng@intel.com>
      Signed-off-by: NBob Moore <robert.moore@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      174cc718
  12. 09 12月, 2016 1 次提交
  13. 01 12月, 2016 4 次提交