1. 15 9月, 2015 1 次提交
    • R
      ACPI / property: Add support for data-only subnodes · 445b0eb0
      Rafael J. Wysocki 提交于
      In some cases, the information expressed via device properties is
      hierarchical by nature.  For example, the properties of a composite
      device consisting of multiple semi-dependent components may need
      to be represented in the form of a tree of property data sets
      corresponding to specific components of the device.
      
      Unfortunately, using ACPI device objects for this purpose turns out
      to be problematic, mostly due to the assumption made by some operating
      systems (that platform firmware generally needs to work with) that
      each device object in the ACPI namespace represents a device requiring
      a separate driver.  That assumption leads to complications which
      reportedly are impractically difficult to overcome and a different
      approach is needed for the sake of interoperability.
      
      The approach implemented here is based on extending _DSD via pointers
      (links) to additional ACPI objects returning data packages formatted
      in accordance with the _DSD formatting rules defined by Section 6.2.5
      of ACPI 6.  Those additional objects are referred to as data-only
      subnodes of the device object containing the _DSD pointing to them.
      
      The links to them need to be located in a separate section of the
      _DSD data package following UUID dbb8e3e6-5886-4ba6-8795-1319f52a966b
      referred to as the Hierarchical Data Extension UUID as defined in [1].
      Each of them is represented by a package of two strings.  The first
      string in that package (the key) is regarded as the name of the
      data-only subnode pointed to by the link.  The second string in it
      (the target) is expected to hold the ACPI namespace path (possibly
      utilizing the usual ACPI namespace search rules) of an ACPI object
      evaluating to a data package extending the _DSD.
      
      The device properties initialization code follows those links,
      creates a struct acpi_data_node object for each of them to store
      the data returned by the ACPI object pointed to by it and processes
      those data recursively (which may lead to the creation of more
      struct acpi_data_node objects if the returned data package contains
      the Hierarchical Data Extension UUID section with more links in it).
      
      All of the struct acpi_data_node objects are present until the the
      ACPI device object containing the _DSD with links to them is deleted
      and they are deleted along with that object.
      
      [1]: http://www.uefi.org/sites/default/files/resources/_DSD-hierarchical-data-extension-UUID-v1.pdfSigned-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      445b0eb0
  2. 08 7月, 2015 1 次提交
  3. 25 6月, 2015 1 次提交
  4. 15 6月, 2015 1 次提交
  5. 16 5月, 2015 1 次提交
    • R
      ACPI / PM: Rework device power management to follow ACPI 6 · 20dacb71
      Rafael J. Wysocki 提交于
      The ACPI 6 specification has made some changes in the device power
      management area.  In particular:
      
       * The D3hot power state is now supposed to be always available
         (instead of D3cold) and D3cold is only regarded as valid if the
         _PR3 object is present for the given device.
      
       * The required ordering of transitions into power states deeper than
         D0 is now such that for a transition into state Dx the _PSx method
         is supposed to be executed first, if present, and the states of
         the power resources the device depends on are supposed to be
         changed after that.
      
       * It is now explicitly forbidden to transition devices from
         lower-power (deeper) into higher-power (shallower) power states
         other than D0.
      
      Those changes have been made so the specification reflects the
      Windows' device power management code that the vast majority of
      systems using ACPI is validated against.
      
      To avoid artificial differences in ACPI device power management
      between Windows and Linux, modify the ACPI device power management
      code to follow the new specification.  Add comments explaining the
      code flow in some unclear places.
      
      This only may affect some real corner cases in which the OS behavior
      expected by the firmware is different from the Windows one, but that's
      quite unlikely.  The transition ordering change affects transitions
      to D1 and D2 which are rarely used (if at all) and into D3hot and
      D3cold for devices actually having _PR3, but those are likely to
      be validated against Windows anyway.  The other changes may affect
      code calling acpi_device_get_power() or acpi_device_update_power()
      where ACPI_STATE_D3_HOT may be returned instead of ACPI_STATE_D3_COLD
      (that's why the ACPI fan driver needs to be updated too) and since
      transitions into ACPI_STATE_D3_HOT may remove power now, it is better
      to avoid this one in acpi_pm_device_sleep_state() if the "no power
      off" PM QoS flag is set.
      
      The only existing user of acpi_device_can_poweroff() really cares
      about the case when _PR3 is present, so the change in that function
      should not cause any problems to happen too.
      
      A plus is that PCI_D3hot can be mapped to ACPI_STATE_D3_HOT
      now and the compatibility with older systems should be covered
      automatically.
      
      In any case, if any real problems result from this, it still will
      be better to follow the Windows' behavior (which now is reflected
      by the specification too) in general and handle the cases when it
      doesn't work via quirks.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      20dacb71
  6. 05 5月, 2015 1 次提交
    • R
      ACPI / property: Refine consistency check for PRP0001 · 5c53b262
      Rafael J. Wysocki 提交于
      Refine the check for the presence of the "compatible" property
      if the PRP0001 device ID is present in the device's list of
      ACPI/PNP IDs to also print the message if _DSD is missing
      entirely or the format of it is incorrect.
      
      One special case to take into accout is that the "compatible"
      property need not be provided for devices having the PRP0001
      device ID in their lists of ACPI/PNP IDs if they are ancestors
      of PRP0001 devices with the "compatible" property present.
      This is to cover heriarchies of device objects where the kernel
      is only supposed to use a struct device representation for the
      topmost one and the others represent, for example, functional
      blocks of a composite device.
      
      While at it, reduce the log level of the message to "info"
      and reduce the log level of the "broken _DSD" message to
      "debug" (noise reduction).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      5c53b262
  7. 18 3月, 2015 1 次提交
  8. 17 3月, 2015 1 次提交
  9. 13 12月, 2014 1 次提交
  10. 04 12月, 2014 1 次提交
  11. 24 11月, 2014 1 次提交
  12. 05 11月, 2014 4 次提交
    • R
      ACPI / GPIO: Driver GPIO mappings for ACPI GPIOs · f028d524
      Rafael J. Wysocki 提交于
      Provide a way for device drivers using GPIOs described by ACPI
      GpioIo resources in _CRS to tell the GPIO subsystem what names
      (connection IDs) to associate with specific GPIO pins defined
      in there.
      
      To do that, a driver needs to define a mapping table as a
      NULL-terminated array of struct acpi_gpio_mapping objects
      that each contain a name, a pointer to an array of line data
      (struct acpi_gpio_params) objects and the size of that array.
      
      Each struct acpi_gpio_params object consists of three fields,
      crs_entry_index, line_index, active_low, representing the index of
      the target GpioIo()/GpioInt() resource in _CRS starting from zero,
      the index of the target line in that resource starting from zero,
      and the active-low flag for that line, respectively.
      
      Next, the mapping table needs to be passed as the second
      argument to acpi_dev_add_driver_gpios() that will register it with
      the ACPI device object pointed to by its first argument.  That
      should be done in the driver's .probe() routine.
      
      On removal, the driver should unregister its GPIO mapping table
      by calling acpi_dev_remove_driver_gpios() on the ACPI device
      object where that table was previously registered.
      
      Included are fixes from Mika Westerberg.
      Acked-by: NAlexandre Courbot <acourbot@nvidia.com>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f028d524
    • R
      Driver core: Unified interface for firmware node properties · 8a0662d9
      Rafael J. Wysocki 提交于
      Add new generic routines are provided for retrieving properties from
      device description objects in the platform firmware in case there are
      no struct device objects for them (either those objects have not been
      created yet or they do not exist at all).
      
      The following functions are provided:
      
      fwnode_property_present()
      fwnode_property_read_u8()
      fwnode_property_read_u16()
      fwnode_property_read_u32()
      fwnode_property_read_u64()
      fwnode_property_read_string()
      fwnode_property_read_u8_array()
      fwnode_property_read_u16_array()
      fwnode_property_read_u32_array()
      fwnode_property_read_u64_array()
      fwnode_property_read_string_array()
      
      in analogy with the corresponding functions for struct device added
      previously.  For all of them, the first argument is a pointer to struct
      fwnode_handle (new type) that allows a device description object
      (depending on what platform firmware interface is in use) to be
      obtained.
      
      Add a new macro device_for_each_child_node() for iterating over the
      children of the device description object associated with a given
      device and a new function device_get_child_node_count() returning the
      number of a given device's child nodes.
      
      The interface covers both ACPI and Device Trees.
      Suggested-by: NGrant Likely <grant.likely@linaro.org>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NGrant Likely <grant.likely@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8a0662d9
    • M
      ACPI: Allow drivers to match using Device Tree compatible property · 733e6251
      Mika Westerberg 提交于
      We have lots of existing Device Tree enabled drivers and allocating
      separate _HID for each is not feasible. Instead we allocate special _HID
      "PRP0001" that means that the match should be done using Device Tree
      compatible property using driver's .of_match_table instead if the driver
      is missing .acpi_match_table.
      
      If there is a need to distinguish from where the device is enumerated
      (DT/ACPI) driver can check dev->of_node or ACPI_COMPATION(dev).
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Acked-by: NGrant Likely <grant.likely@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      733e6251
    • M
      ACPI: Add support for device specific properties · ffdcd955
      Mika Westerberg 提交于
      Device Tree is used in many embedded systems to describe the system
      configuration to the OS. It supports attaching properties or name-value
      pairs to the devices it describe. With these properties one can pass
      additional information to the drivers that would not be available
      otherwise.
      
      ACPI is another configuration mechanism (among other things) typically
      seen, but not limited to, x86 machines. ACPI allows passing arbitrary
      data from methods but there has not been mechanism equivalent to Device
      Tree until the introduction of _DSD in the recent publication of the
      ACPI 5.1 specification.
      
      In order to facilitate ACPI usage in systems where Device Tree is
      typically used, it would be beneficial to standardize a way to retrieve
      Device Tree style properties from ACPI devices, which is what we do in
      this patch.
      
      If a given device described in ACPI namespace wants to export properties it
      must implement _DSD method (Device Specific Data, introduced with ACPI 5.1)
      that returns the properties in a package of packages. For example:
      
      	Name (_DSD, Package () {
      		ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
      		Package () {
      			Package () {"name1", <VALUE1>},
      			Package () {"name2", <VALUE2>},
      			...
      		}
      	})
      
      The UUID reserved for properties is daffd814-6eba-4d8c-8a91-bc9bbf4aa301
      and is documented in the ACPI 5.1 companion document called "_DSD
      Implementation Guide" [1], [2].
      
      We add several helper functions that can be used to extract these
      properties and convert them to different Linux data types.
      
      The ultimate goal is that we only have one device property API that
      retrieves the requested properties from Device Tree or from ACPI
      transparent to the caller.
      
      [1] http://www.uefi.org/sites/default/files/resources/_DSD-implementation-guide-toplevel.htm
      [2] http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdfReviewed-by: NHanjun Guo <hanjun.guo@linaro.org>
      Reviewed-by: NJosh Triplett <josh@joshtriplett.org>
      Reviewed-by: NGrant Likely <grant.likely@linaro.org>
      Signed-off-by: NDarren Hart <dvhart@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ffdcd955
  13. 10 10月, 2014 1 次提交
  14. 21 9月, 2014 1 次提交
    • R
      ACPI / hotplug: Generate online uevents for ACPI containers · 8ab17fc9
      Rafael J. Wysocki 提交于
      Commit 46394fd0 (ACPI / hotplug: Move container-specific code out of
      the core) removed the generation of "online" uevents for containers,
      because "add" uevents are now generated for them automatically when
      container system devices are registered.  However, there are user
      space tools that need to be notified when the container and all of
      its children have been enumerated, which doesn't happen any more.
      
      For this reason, add a mechanism allowing "online" uevents to be
      generated for ACPI containers after enumerating the container along
      with all of its children.
      
      Fixes: 46394fd0 (ACPI / hotplug: Move container-specific code out of the core)
      Reported-and-tested-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Cc: 3.14+ <stable@vger.kernel.org> # 3.14+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8ab17fc9
  15. 16 9月, 2014 1 次提交
  16. 04 9月, 2014 1 次提交
  17. 23 7月, 2014 2 次提交
    • R
      ACPI / PM: Always enable wakeup GPEs when enabling device wakeup · f35cec25
      Rafael J. Wysocki 提交于
      Wakeup GPEs are currently only enabled when setting up devices for
      remote wakeup at run time.  During system-wide transitions they are
      enabled by ACPICA at the very last stage of suspend (before asking
      the BIOS to take over).  Of course, that only works for system
      sleep states supported by ACPI, so in particular it doesn't work
      for the "freeze" sleep state.
      
      For this reason, modify the ACPI core device PM code to enable wakeup
      GPEs for devices when setting them up for wakeup regardless of whether
      that is remote wakeup at runtime or system wakeup.  That allows the
      same device wakeup setup routine to be used for both runtime PM and
      system-wide PM and makes it possible to reduce code size quite a bit.
      
      This make ACPI-based PCI Wake-on-LAN work with the "freeze" sleep
      state on my venerable Toshiba Portege R500 and should help other
      systems too.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f35cec25
    • R
      ACPI / PM: Revork the handling of ACPI device wakeup notifications · c072530f
      Rafael J. Wysocki 提交于
      Since ACPI wakeup GPEs are going to be enabled during system suspend
      as well as for runtime wakeup by a subsequent patch and the same
      notify handlers will be used in both cases, rework the ACPI device
      wakeup notification framework so that the part specific to physical
      devices is always run asynchronously from the PM workqueue.  This
      prevents runtime resume callbacks for those devices from being
      run during system suspend and resume which may not be appropriate,
      among other things.
      
      Also make ACPI device wakeup notification handling a bit more robust
      agaist subsequent removal of ACPI device objects, whould that ever
      happen, and create a wakeup source object for each ACPI device
      configured for wakeup so that wakeup notifications for those
      devices can wake up the system from the "freeze" sleep state.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      c072530f
  18. 16 7月, 2014 1 次提交
  19. 07 7月, 2014 1 次提交
    • Z
      ACPI / PNP: do ACPI binding directly · f1b1dc84
      Zhang Rui 提交于
      PNPACPI uses acpi_bus_type to do ACPI binding for the PNPACPI devices.
      
      This is overkill because PNPACPI code already knows which ACPI
      device object to bind during PNPACPI device enumeration.
      
      This patch removes acpi_pnp_bus and does the binding by invoking
      acpi_bind_one() directly after device enumerated.
      
      This also fixes a bug in the previous code that some PNPACPI devices failed
      to be bound because
       1. the ACPI device _HID is not pnpid, e.g. "MSFT0001", but its _CID is,
          e.g. "PNP0303", thus ACPI _CID is used as the pnp device device id.
       2. device is bound only if the pnp device id matches the ACPI device _HID.
      Tested-by: NPrigent Christophe <christophe.prigent@intel.com>
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f1b1dc84
  20. 30 5月, 2014 2 次提交
  21. 27 5月, 2014 1 次提交
  22. 20 5月, 2014 1 次提交
  23. 05 3月, 2014 1 次提交
  24. 22 2月, 2014 2 次提交
  25. 21 2月, 2014 3 次提交
  26. 16 2月, 2014 1 次提交
    • R
      ACPI / dock: Dispatch dock notifications from the global notify handler · 1e2380cd
      Rafael J. Wysocki 提交于
      The ACPI dock station code carries out an extra namespace scan
      before the main one in order to find and register all of the dock
      device objects.  Then, it registers a notify handler for each of
      them for handling dock events.
      
      However, dock device objects need not be scanned for upfront.  They
      very well can be enumerated and registered during the first phase
      of the main namespace scan, before attaching scan handlers and ACPI
      drivers to ACPI device objects.  Then, the dependent devices can be
      added to the in the second phase.  That makes it possible to drop
      the extra namespace scan, so do it.
      
      Moreover, it is not necessary to register notify handlers for all
      of the dock stations' namespace nodes, becuase notifications may
      be dispatched from the global notify handler for them.  Do that and
      drop two functions used for dock notify handling, acpi_dock_deferred_cb()
      and dock_notify_handler(), that aren't necessary any more.
      
      Finally, some dock station objects have _HID objects matching the
      ACPI container scan handler which causes it to claim those objects
      and try to handle their hotplug, but that is not a good idea,
      because those objects have their own special hotplug handling anyway.
      For this reason, the hotplug_notify flag should not be set for ACPI
      device objects representing dock stations and the container scan
      handler should be made ignore those objects, so make that happen.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      1e2380cd
  27. 11 2月, 2014 1 次提交
    • R
      ACPI / scan: Add bind/unbind callbacks to struct acpi_scan_handler · 9cb32acf
      Rafael J. Wysocki 提交于
      In some cases it may be necessary to perform certain setup/cleanup
      operations on a device object representing a physical device after
      it has been associated with an ACPI companion by acpi_bind_one() or
      before disassociating it from that companion by acpi_unbind_one(),
      respectively.  If there is a struct acpi_bus_type object for the
      given device's bus type, the .setup()/.cleanup() callbacks from there
      are executed for these purposes.  However, an analogous mechanism will
      be necessary for devices whose bus types don't have corresponding
      struct acpi_bus_type objects and that have specific ACPI scan handlers.
      
      For those devices, add new .bind() and .unbind() callbacks to struct
      acpi_scan_handler that will be executed by acpi_platform_notify()
      right after the given device has been associated with an ACPI
      comapnion and by acpi_platform_notify_remove() right before calling
      acpi_unbind_one() for that device, respectively.
      
      To make that work for scan handlers registering new devices in their
      .attach() callbacks, modify acpi_scan_attach_handler() to set the
      ACPI device object's handler field before calling .attach() from the
      scan handler at hand.
      
      This changeset includes a fix from Mika Westerberg.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      9cb32acf
  28. 07 2月, 2014 3 次提交
    • R
      ACPI / hotplug / PCI: Hotplug notifications from acpi_bus_notify() · 1a699476
      Rafael J. Wysocki 提交于
      Since acpi_bus_notify() is executed on all notifications for all
      devices anyway, make it execute acpi_device_hotplug() for all
      hotplug events instead of installing notify handlers pointing to
      the same function for all hotplug devices.
      
      This change reduces both the size and complexity of ACPI-based device
      hotplug code.  Moreover, since acpi_device_hotplug() only does
      significant things for devices that have either an ACPI scan handler,
      or a hotplug context with .eject() defined, and those devices
      had notify handlers pointing to acpi_hotplug_notify_cb() installed
      before anyway, this modification shouldn't change functionality.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      1a699476
    • R
      ACPI / hotplug / PCI: Simplify acpi_install_hotplug_notify_handler() · 5e6f236c
      Rafael J. Wysocki 提交于
      Since acpi_hotplug_notify_cb() does not use its data argument any
      more, the second argument of acpi_install_hotplug_notify_handler()
      can be dropped, so do that and update its callers accordingly.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5e6f236c
    • R
      ACPI / hotplug / PCI: Consolidate ACPIPHP with ACPI core hotplug · 3c2cc7ff
      Rafael J. Wysocki 提交于
      The ACPI-based PCI hotplug (ACPIPHP) code currently attaches its
      hotplug context objects directly to ACPI namespace nodes representing
      hotplug devices.  However, after recent changes causing struct
      acpi_device to be created for every namespace node representing a
      device (regardless of its status), that is not necessary any more.
      Moreover, it's vulnerable to the theoretical issue that the ACPI
      handle passed in the context between handle_hotplug_event() and
      hotplug_event_work() may become invalid in the meantime (as a
      result of a concurrent table unload).
      
      In principle, this issue might be addressed by adding a non-empty
      release handler for ACPIPHP hotplug context objects analogous to
      acpi_scan_drop_device(), but that would duplicate the code in that
      function and in acpi_device_del_work_fn().  For this reason, it's
      better to modify ACPIPHP to attach its device hotplug contexts to
      struct device objects representing hotplug devices and make it
      use acpi_hotplug_notify_cb() as its notify handler.  At the same
      time, acpi_device_hotplug() can be modified to dispatch the new
      .hp.event() callback pointing to acpiphp_hotplug_event() from ACPI
      device objects associated with PCI devices or use the generic
      ACPI device hotplug code for device objects with matching scan
      handlers.
      
      This allows the existing code duplication between ACPIPHP and the
      ACPI core to be reduced too and makes further ACPI-based device
      hotplug consolidation possible.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      3c2cc7ff
  29. 06 2月, 2014 2 次提交
    • R
      ACPI / hotplug / PCI: Define hotplug context lock in the core · e525506f
      Rafael J. Wysocki 提交于
      Subsequent changes will require the ACPI core to acquire the lock
      protecting the ACPIPHP hotplug contexts, so move the definition of
      the lock to the core and change its name to be more generic.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      e525506f
    • R
      ACPI / hotplug: Fix potential race in acpi_bus_notify() · 78ea4639
      Rafael J. Wysocki 提交于
      There is a slight possibility for the ACPI device object pointed to
      by adev in acpi_hotplug_notify_cb() to become invalid between the
      acpi_bus_get_device() that it comes from and the subsequent dereference
      of that pointer under get_device().  Namely, if acpi_scan_drop_device()
      runs in parallel with acpi_hotplug_notify_cb(), acpi_device_del_work_fn()
      queued up by it may delete the device object in question right after
      a successful execution of acpi_bus_get_device() in acpi_bus_notify().
      
      An analogous problem is present in acpi_bus_notify() where the device
      pointer coming from acpi_bus_get_device() may become invalid before
      it subsequent dereference in the "if" block.
      
      To prevent that from happening, introduce a new function,
      acpi_bus_get_acpi_device(), working analogously to acpi_bus_get_device()
      except that it will grab a reference to the ACPI device object returned
      by it and it will do that under the ACPICA's namespace mutex.  Then,
      make both acpi_hotplug_notify_cb() and acpi_bus_notify() use
      acpi_bus_get_acpi_device() instead of acpi_bus_get_device() so as to
      ensure that the pointers used by them will not become stale at one
      point.
      
      In addition to that, introduce acpi_bus_put_acpi_device() as a wrapper
      around put_device() to be used along with acpi_bus_get_acpi_device()
      and make the (new) users of the latter use acpi_bus_put_acpi_device()
      too.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      78ea4639