1. 23 11月, 2013 9 次提交
    • R
      ACPI: Introduce acpi_set_device_status() · 25db115b
      Rafael J. Wysocki 提交于
      Introduce a static inline function for setting the status field
      of struct acpi_device on the basis of a supplied u32 number,
      acpi_set_device_status(), and use it instead of the horrible
      horrible STRUCT_TO_INT() macro wherever applicable.  Having done
      that, drop STRUCT_TO_INT() (and pretend that it has never existed).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      25db115b
    • R
      ACPI / hotplug: Drop unfinished global notification handling routines · f4b734c3
      Rafael J. Wysocki 提交于
      There are two global hotplug notification handling routines in bus.c,
      acpi_bus_check_device() and acpi_bus_check_scope(), that have never
      been finished and don't do anything useful, so drop them.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f4b734c3
    • R
      ACPI / hotplug: Rework generic code to handle suprise removals · 443fc820
      Rafael J. Wysocki 提交于
      The generic ACPI hotplug code used for several types of device
      doesn't handle surprise removals, mostly because those devices
      currently cannot be removed by surprise in the majority of systems.
      However, surprise removals should be handled by that code as well
      as surprise additions of devices, so make it do that.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      443fc820
    • R
      ACPI / hotplug: Move container-specific code out of the core · 46394fd0
      Rafael J. Wysocki 提交于
      Move container-specific uevents from the core hotplug code to the
      container scan handler's .attach() and .detach() callbacks.
      
      This way the core will not have to special-case containers and
      the uevents will be guaranteed to happen every time a container
      is either scanned or trimmed as appropriate.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      46394fd0
    • R
      ACPI / hotplug: Make ACPI PCI root hotplug use common hotplug code · 3338db00
      Rafael J. Wysocki 提交于
      Rework the common ACPI device hotplug code so that it is suitable
      for PCI host bridge hotplug and switch the PCI host bridge scan
      handler to using the common hotplug code.
      
      This allows quite a few lines of code that are not necessary any more
      to be dropped from the PCI host bridge scan handler and removes
      arbitrary differences in behavior between PCI host bridge hotplug
      and ACPI-based hotplug of other components, like CPUs and memory.
      
      Also acpi_device_hotplug() can be static now.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      3338db00
    • R
      ACPI / hotplug: Introduce common hotplug function acpi_device_hotplug() · c27b2c33
      Rafael J. Wysocki 提交于
      Modify the common ACPI device hotplug code to always queue up the
      same function, acpi_device_hotplug(), using acpi_hotplug_execute()
      and make the PCI host bridge hotplug code use that function too for
      device hot removal.
      
      This allows some code duplication to be reduced and a race condition
      where the relevant ACPI handle may become invalid between the
      notification handler and the function queued up by it via
      acpi_hotplug_execute() to be avoided.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      c27b2c33
    • R
      ACPI / hotplug: Do not fail bus and device checks for disabled hotplug · 1ceaba05
      Rafael J. Wysocki 提交于
      If the scan handler for the given device has hotplug.enabled
      unset, it doesn't really make sense to fail bus check and device
      check notifications.
      
      First, bus check may not have anything to do with the device it is
      signaled for, but it may concern another device on the bus below
      this one.  For this reason, bus check notifications should not be
      failed if hotplug is disabled for the target device.
      
      Second, device check notifications are signaled only after a device
      has already appeared (or disappeared), so failing it can only prevent
      scan handlers and drivers from attaching to that (already existing)
      device, which is not very useful.
      
      Consequently, if device hotplug is disabled through the device's
      scan handler, fail eject request notifications only.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      1ceaba05
    • R
      ACPI / scan: Add acpi_device objects for all device nodes in the namespace · 202317a5
      Rafael J. Wysocki 提交于
      Modify the ACPI namespace scanning code to register a struct
      acpi_device object for every namespace node representing a device,
      processor and so on, even if the device represented by that namespace
      node is reported to be not present and not functional by _STA.
      
      There are multiple reasons to do that.  First of all, it avoids
      quite a lot of overhead when struct acpi_device objects are
      deleted every time acpi_bus_trim() is run and then added again
      by a subsequent acpi_bus_scan() for the same scope, although the
      namespace objects they correspond to stay in memory all the time
      (which always is the case on a vast majority of systems).
      
      Second, it will allow user space to see that there are namespace
      nodes representing devices that are not present at the moment and may
      be added to the system.  It will also allow user space to evaluate
      _SUN for those nodes to check what physical slots the "missing"
      devices may be put into and it will make sense to add a sysfs
      attribute for _STA evaluation after this change (that will be
      useful for thermal management on some systems).
      
      Next, it will help to consolidate the ACPI hotplug handling among
      subsystems by making it possible to store hotplug-related information
      in struct acpi_device objects in a standard common way.
      
      Finally, it will help to avoid a race condition related to the
      deletion of ACPI namespace nodes.  Namely, namespace nodes may be
      deleted as a result of a table unload triggered by _EJ0 or _DCK.
      If a hotplug notification for one of those nodes is triggered
      right before the deletion and it executes a hotplug callback
      via acpi_hotplug_execute(), the ACPI handle passed to that
      callback may be stale when the callback actually runs.  One way
      to work around that is to always pass struct acpi_device pointers
      to hotplug callbacks after doing a get_device() on the objects in
      question which eliminates the use-after-free possibility (the ACPI
      handles in those objects are invalidated by acpi_scan_drop_device(),
      so they will trigger ACPICA errors on attempts to use them).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      202317a5
    • R
      ACPI / scan: Define non-empty device removal handler · d783156e
      Rafael J. Wysocki 提交于
      If an ACPI namespace node is removed (usually, as a result of a
      table unload), and there is a data object attached to that node,
      acpi_ns_delete_node() executes the removal handler submitted to
      acpi_attach_data() for that object.  That handler is currently empty
      for struct acpi_device objects, so it is necessary to detach those
      objects from the corresponding ACPI namespace nodes in advance every
      time a table unload may happen.  That is cumbersome and inefficient
      and leads to some design constraints that turn out to be quite
      inconvenient (in particular, struct acpi_device objects cannot be
      registered for namespace nodes representing devices that are not
      reported as present or functional by _STA).
      
      For this reason, introduce a non-empty removal handler for ACPI
      device objects that will unregister them when their ACPI namespace
      nodes go away.
      
      This code modification alone should not change functionality except
      for the ordering of the ACPI hotplug workqueue which should not
      matter (without subsequent code changes).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      d783156e
  2. 21 11月, 2013 4 次提交
  3. 20 11月, 2013 3 次提交
    • T
      ACPI / hotplug: Fix conflicted PCI bridge notify handlers · ca499fc8
      Toshi Kani 提交于
      The PCI host bridge scan handler installs its own notify handler,
      handle_hotplug_event_root(), by itself.  Nevertheless, the ACPI
      hotplug framework also installs the common notify handler,
      acpi_hotplug_notify_cb(), for PCI root bridges.  This causes
      acpi_hotplug_notify_cb() to call _OST method with unsupported
      error as hotplug.enabled is not set.
      
      To address this issue, introduce hotplug.ignore flag, which
      indicates that the scan handler installs its own notify handler by
      itself.  The ACPI hotplug framework does not install the common
      notify handler when this flag is set.
      Signed-off-by: NToshi Kani <toshi.kani@hp.com>
      [rjw: Changed the name of the new flag]
      Cc: 3.9+ <stable@vger.kernel.org> # 3.9+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ca499fc8
    • J
      genetlink: make multicast groups const, prevent abuse · 2a94fe48
      Johannes Berg 提交于
      Register generic netlink multicast groups as an array with
      the family and give them contiguous group IDs. Then instead
      of passing the global group ID to the various functions that
      send messages, pass the ID relative to the family - for most
      families that's just 0 because the only have one group.
      
      This avoids the list_head and ID in each group, adding a new
      field for the mcast group ID offset to the family.
      
      At the same time, this allows us to prevent abusing groups
      again like the quota and dropmon code did, since we can now
      check that a family only uses a group it owns.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2a94fe48
    • J
      genetlink: pass family to functions using groups · 68eb5503
      Johannes Berg 提交于
      This doesn't really change anything, but prepares for the
      next patch that will change the APIs to pass the group ID
      within the family, rather than the global group ID.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      68eb5503
  4. 19 11月, 2013 4 次提交
  5. 16 11月, 2013 2 次提交
  6. 15 11月, 2013 4 次提交
    • L
      ACPI / AC: Remove struct acpi_device pointer from struct acpi_ac · 86b0cc12
      Lan Tianyu 提交于
      Now the pointer of struct acpi_device can be got by
      ACPI_COMPANION(struct acpi_ac->pdev->dev). So the pointer
      is not necessary and remove it.
      Signed-off-by: NLan Tianyu <tianyu.lan@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      86b0cc12
    • R
      ACPI / bind: Use (put|get)_device() on ACPI device objects too · a104b4d4
      Rafael J. Wysocki 提交于
      When associating a "physical" device with an ACPI device object
      acpi_bind_one() only uses get_device() to increment the reference
      counter of the former, but there is no reason not to do that with
      the latter too.  Among other things, that may help to avoid
      use-after-free when an ACPI device object is freed without calling
      acpi_unbind_one() for all "physical" devices associated with it
      (that only can happen in buggy code, but then it's better if the
      kernel doesn't crash as a result of a bug).
      
      For this reason, modify acpi_bind_one() to apply get_device() to
      the ACPI device object too and update acpi_unbind_one() to drop
      that reference using put_device() as appropriate.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NLan Tianyu <tianyu.lan@intel.com>
      a104b4d4
    • R
      ACPI: Eliminate the DEVICE_ACPI_HANDLE() macro · 3a83f992
      Rafael J. Wysocki 提交于
      Since DEVICE_ACPI_HANDLE() is now literally identical to
      ACPI_HANDLE(), replace it with the latter everywhere and drop its
      definition from include/acpi.h.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3a83f992
    • R
      ACPI / driver core: Store an ACPI device pointer in struct acpi_dev_node · 7b199811
      Rafael J. Wysocki 提交于
      Modify struct acpi_dev_node to contain a pointer to struct acpi_device
      associated with the given device object (that is, its ACPI companion
      device) instead of an ACPI handle corresponding to it.  Introduce two
      new macros for manipulating that pointer in a CONFIG_ACPI-safe way,
      ACPI_COMPANION() and ACPI_COMPANION_SET(), and rework the
      ACPI_HANDLE() macro to take the above changes into account.
      Drop the ACPI_HANDLE_SET() macro entirely and rework its users to
      use ACPI_COMPANION_SET() instead.  For some of them who used to
      pass the result of acpi_get_child() directly to ACPI_HANDLE_SET()
      introduce a helper routine acpi_preset_companion() doing an
      equivalent thing.
      
      The main motivation for doing this is that there are things
      represented by struct acpi_device objects that don't have valid
      ACPI handles (so called fixed ACPI hardware features, such as
      power and sleep buttons) and we would like to create platform
      device objects for them and "glue" them to their ACPI companions
      in the usual way (which currently is impossible due to the
      lack of valid ACPI handles).  However, there are more reasons
      why it may be useful.
      
      First, struct acpi_device pointers allow of much better type checking
      than void pointers which are ACPI handles, so it should be more
      difficult to write buggy code using modified struct acpi_dev_node
      and the new macros.  Second, the change should help to reduce (over
      time) the number of places in which the result of ACPI_HANDLE() is
      passed to acpi_bus_get_device() in order to obtain a pointer to the
      struct acpi_device associated with the given "physical" device,
      because now that pointer is returned by ACPI_COMPANION() directly.
      Finally, the change should make it easier to write generic code that
      will build both for CONFIG_ACPI set and unset without adding explicit
      compiler directives to it.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> # on Haswell
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: Aaron Lu <aaron.lu@intel.com> # for ATA and SDIO part
      7b199811
  7. 13 11月, 2013 2 次提交
  8. 11 11月, 2013 1 次提交
  9. 08 11月, 2013 1 次提交
    • R
      ACPI / hotplug: Consolidate deferred execution of ACPI hotplug routines · 7b98118a
      Rafael J. Wysocki 提交于
      There are two different interfaces for queuing up work items on the
      ACPI hotplug workqueue, alloc_acpi_hp_work() used by PCI and PCI host
      bridge hotplug code and acpi_os_hotplug_execute() used by the common
      ACPI hotplug code and docking stations.  They both are somewhat
      cumbersome to use and work slightly differently.
      
      The users of alloc_acpi_hp_work() have to submit a work function that
      will extract the necessary data items from a struct acpi_hp_work
      object allocated by alloc_acpi_hp_work() and then will free that
      object, while it would be more straightforward to simply use a work
      function with one more argument and let the interface take care of
      the execution details.
      
      The users of acpi_os_hotplug_execute() also have to deal with the
      fact that it takes only one argument in addition to the work function
      pointer, although acpi_os_execute_deferred() actually takes care of
      the allocation and freeing of memory, so it would have been able to
      pass more arguments to the work function if it hadn't been
      constrained by the connection with acpi_os_execute().
      
      Moreover, while alloc_acpi_hp_work() makes GFP_KERNEL memory
      allocations, which is correct, because hotplug work items are
      always queued up from process context, acpi_os_hotplug_execute()
      uses GFP_ATOMIC, as that is needed by acpi_os_execute().  Also,
      acpi_os_execute_deferred() queued up by it waits for the ACPI event
      workqueues to flush before executing the work function, whereas
      alloc_acpi_hp_work() can't do anything similar.  That leads to
      somewhat arbitrary differences in behavior between various ACPI
      hotplug code paths and has to be straightened up.
      
      For this reason, replace both alloc_acpi_hp_work() and
      acpi_os_hotplug_execute() with a single interface,
      acpi_hotplug_execute(), combining their behavior and being more
      friendly to its users than any of the two.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      7b98118a
  10. 07 11月, 2013 10 次提交