1. 03 6月, 2019 1 次提交
  2. 01 5月, 2019 1 次提交
    • P
      ACPI / property: fix handling of data_nodes in acpi_get_next_subnode() · 23583f77
      Pierre-Louis Bossart 提交于
      When the DSDT tables expose devices with subdevices and a set of
      hierarchical _DSD properties, the data returned by
      acpi_get_next_subnode() is incorrect, with the results suggesting a bad
      pointer assignment. The parser works fine with device_nodes or
      data_nodes, but not with a combination of the two.
      
      The problem is traced to an invalid pointer used when jumping from
      handling device_nodes to data nodes. The existing code looks for data
      nodes below the last subdevice found instead of the common root. Fix
      by forcing the acpi_device pointer to be derived from the same fwnode
      for the two types of subnodes.
      
      This same problem of handling device and data nodes was already fixed
      in a similar way by 'commit bf4703fd ("ACPI / property: fix data
      node parsing in acpi_get_next_subnode()")' but broken later by 'commit
      34055190 ("ACPI / property: Add fwnode_get_next_child_node()")', so
      this should probably go to linux-stable all the way to 4.12
      Signed-off-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      23583f77
  3. 17 4月, 2019 1 次提交
  4. 05 12月, 2018 1 次提交
  5. 03 10月, 2018 2 次提交
  6. 23 7月, 2018 5 次提交
  7. 12 2月, 2018 2 次提交
  8. 13 12月, 2017 1 次提交
  9. 12 10月, 2017 2 次提交
  10. 20 9月, 2017 2 次提交
    • S
      ACPI: properties: Return _DSD hierarchical extension (data) sub-nodes correctly · 0c0bceb7
      Sakari Ailus 提交于
      The recently merged patch "ACPI: Prepare for constifying
      acpi_get_next_subnode() fwnode argument" was part of a patchset
      constifying the fwnode arguments across the fwnode property API. The
      purpose of the patch was to allow returning non-const fwnodes from a data
      structure the root of which is const.
      
      Unfortunately the patch introduced the functionality, in particular when
      starting parsed from an ACPI device node, the hierarchical data extension
      nodes would not be enumerated.
      
      Restore the old behaviour while still retaining constness properties of
      the patch.
      
      Fixes: 01c1da28 "ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument"
      Signed-off-by: NSakari Ailus <sakari.ailus@linux.intel.com>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0c0bceb7
    • J
      ACPI / bus: Make ACPI_HANDLE() work for non-GPL code again · 9e987b70
      John Hubbard 提交于
      Due to commit db3e50f3 (device property: Get rid of struct
      fwnode_handle type field), ACPI_HANDLE() inadvertently became
      a GPL-only call. The call path that led to that was:
      
      ACPI_HANDLE()
          ACPI_COMPANION()
              to_acpi_device_node()
                  is_acpi_device_node()
                      acpi_device_fwnode_ops
                          DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops);
      
      ...and the new DECLARE_ACPI_FWNODE_OPS() includes
      EXPORT_SYMBOL_GPL, whereas previously it was a static struct.
      
      In order to avoid changing any of that, let's instead provide ever
      so slightly better encapsulation of those struct fwnode_operations
      instances. Those do not really need to be directly used in
      inline function calls in header files. Simply moving two small
      functions (is_acpi_device_node and is_acpi_data_node) out of
      acpi_bus.h, and into a .c file, does that.
      
      That leaves the internals of struct fwnode_operations as GPL-only
      (which I think was the intent all along), but un-breaks any driver
      code out there that relies on the ACPI subsystem's being (historically)
      an EXPORT_SYMBOL-usable system. By that, I mean, ACPI_HANDLE() and
      other basic ACPI calls were non-GPL-protected.
      
      Also, while I'm there, remove a tiny bit of redundancy that was missed
      in the earlier commit, by having is_acpi_node() use the other two
      routines, instead of checking fwnode directly.
      
      Fixes: db3e50f3 (device property: Get rid of struct fwnode_handle type field)
      Signed-off-by: NJohn Hubbard <jhubbard@nvidia.com>
      Acked-by: NSakari Ailus <sakari.ailus@linux.intel.com>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      9e987b70
  11. 23 8月, 2017 1 次提交
  12. 04 8月, 2017 2 次提交
    • L
      ACPI / property: Support Apple _DSM properties · 899596e0
      Lukas Wunner 提交于
      While the rest of the world has standardized on _DSD as the way to store
      device properties in AML (introduced with ACPI 5.1 in 2014), Apple has
      been using a custom _DSM to achieve the same for much longer (ever since
      they switched from DeviceTree-based PowerPC to Intel in 2005, verified
      with MacOS X 10.4.11).
      
      The theory of operation on macOS is as follows:  AppleACPIPlatform.kext
      invokes mergeEFIproperties() and mergeDSMproperties() for each device to
      merge properties conveyed by EFI drivers as well as properties stored in
      AML into the I/O Kit registry from which they can be retrieved by
      drivers.  We've been supporting EFI properties since commit 58c5475a
      ("x86/efi: Retrieve and assign Apple device properties").  The present
      commit adds support for _DSM properties, thereby completing our support
      for Apple device properties.  The _DSM properties are made available
      under the primary fwnode, the EFI properties under the secondary fwnode.
      So for devices which possess both property types, they can all be
      elegantly accessed with the uniform API in <linux/property.h>.
      
      Until recently we had no need to support _DSM properties, they contained
      only uninteresting garbage.  The situation has changed with MacBooks and
      MacBook Pros introduced since 2015:  Their keyboard is attached with SPI
      instead of USB and the _CRS data which is necessary to initialize the
      spi driver only contains valid information if OSPM responds "false" to
      _OSI("Darwin").  If OSPM responds "true", _CRS is empty and the spi
      driver fails to initialize.  The rationale is very simple, Apple only
      cares about macOS and Windows:  On Windows, _CRS contains valid data,
      whereas on macOS it is empty.  Instead, macOS gleans the necessary data
      from the _DSM properties.
      
      Since Linux deliberately defaults to responding "true" to _OSI("Darwin"),
      we need to emulate macOS' behaviour by initializing the spi driver with
      data returned by the _DSM.
      
      An out-of-tree driver for the SPI keyboard exists which currently binds
      to the ACPI device, invokes the _DSM, parses the returned package and
      instantiates an SPI device with the data gleaned from the _DSM:
      https://github.com/cb22/macbook12-spi-driver/commit/9a416d699ef4
      https://github.com/cb22/macbook12-spi-driver/commit/0c34936ed9a1
      
      By adding support for Apple's _DSM properties in generic ACPI code, the
      out-of-tree driver will be able to register as a regular SPI driver,
      significantly reducing its amount of code and improving its chances to
      be mainlined.
      
      The SPI keyboard will not be the only user of this commit:  E.g. on the
      MacBook8,1, the UART-attached Bluetooth device likewise returns empty
      _CRS data if OSPM returns "true" to _OSI("Darwin").
      
      The _DSM returns a Package whose format unfortunately deviates slightly
      from the _DSD spec:  The properties are marshalled up in a single Package
      as alternating key/value elements, unlike _DSD which stores them as a
      Package of 2-element Packages.  The present commit therefore converts
      the Package to _DSD format and the ACPI core can then treat the data as
      if Apple would follow the standard.
      
      Well, except for one small annoyance:  The properties returned by the
      _DSM only ever have one of two types, Integer or Buffer.  The former is
      retrievable as usual with device_property_read_u64(), but the latter is
      not part of the _DSD spec and it is not possible to retrieve Buffer
      properties with the device_property_read_*() functions due to the type
      checking performed in drivers/acpi/property.c.  It is however possible
      to retrieve them with acpi_dev_get_property().  Apple is using the
      Buffer type somewhat sloppily to store null-terminated strings but also
      integers.  The real data type is not distinguishable by the ACPI core
      and the onus is on the caller to use the contents of the Buffer in an
      appropriate way.
      
      In case Apple moves to _DSD in the future, this commit first checks for
      _DSD and falls back to _DSM only if _DSD is not found.
      Tested-by: NRonald Tschalär <ronald@innovation.ch>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      899596e0
    • L
      ACPI / property: Don't evaluate objects for devices w/o handle · 75fc70e0
      Lukas Wunner 提交于
      Fabricated devices such as LNXPWRBN lack a handle, causing evaluation
      of _CCA and _DSD to always fail with AE_BAD_PARAMETER.  While that is
      merely a (negligible) waste of processing power, evaluating a _DSM for
      them (such as Apple's device properties _DSM which we're about to add)
      results in an ugly error:
      
          ACPI: \: failed to evaluate _DSM (0x1001)
      
      Avoid by not evaluating _DSD and the upcoming _DSM for devices without
      handle.
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      75fc70e0
  13. 26 7月, 2017 1 次提交
  14. 22 7月, 2017 5 次提交
  15. 22 6月, 2017 3 次提交
  16. 29 3月, 2017 4 次提交
  17. 24 11月, 2016 1 次提交
  18. 12 10月, 2016 1 次提交
    • M
      ACPI / property: Allow holes in reference properties · b60e4ea4
      Mika Westerberg 提交于
      DT allows holes or empty phandles for references. This is used for example
      in SPI subsystem where some chip selects are native and others are regular
      GPIOs. In ACPI _DSD we currently do not support this but instead the
      preceding reference consumes all following integer arguments.
      
      For example we would like to support something like the below ASL fragment
      for SPI:
      
        Package () {
            "cs-gpios",
            Package () {
                ^GPIO, 19, 0, 0, // GPIO CS0
                0,               // Native CS
                ^GPIO, 20, 0, 0, // GPIO CS1
            }
        }
      
      The zero in the middle means "no entry" or NULL reference. To support this
      we change acpi_data_get_property_reference() to take firmware node and
      num_args as argument and rename it to __acpi_node_get_property_reference().
      The function returns -ENOENT if the given index resolves to "no entry"
      reference and -ENODATA when there are no more entries in the property.
      
      We then add static inline wrapper acpi_node_get_property_reference() that
      passes MAX_ACPI_REFERENCE_ARGS as num_args to support the existing
      behaviour which some drivers have been relying on.
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      b60e4ea4
  19. 17 3月, 2016 1 次提交
  20. 07 12月, 2015 1 次提交
  21. 22 10月, 2015 1 次提交
  22. 15 9月, 2015 1 次提交
    • R
      ACPI / property: Extend device_get_next_child_node() to data-only nodes · 504a3374
      Rafael J. Wysocki 提交于
      Make device_get_next_child_node() work with ACPI data-only subnodes
      introduced previously.
      
      Namely, replace acpi_get_next_child() with acpi_get_next_subnode()
      that can handle (and return) child device objects as well as child
      data-only subnodes of the given device and modify the ACPI part
      of the GPIO subsystem to handle data-only subnodes returned by it.
      
      To that end, introduce acpi_node_get_gpiod() taking a struct
      fwnode_handle pointer as the first argument.  That argument may
      point to an ACPI device object as well as to a data-only subnode
      and the function should do the right thing (ie. look for the matching
      GPIO descriptor correctly) in either case.
      
      Next, modify fwnode_get_named_gpiod() to use acpi_node_get_gpiod()
      instead of acpi_get_gpiod_by_index() which automatically causes
      devm_get_gpiod_from_child() to work with ACPI data-only subnodes
      that may be returned by device_get_next_child_node() which in turn
      is required by the users of that function (the gpio_keys_polled
      and gpio-leds drivers).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Acked-by: NLinus Walleij <linus.walleij@linaro.org>
      504a3374