07 Nov, 2015

2 commits

  • * acpi-pci:
    PCI: ACPI: Add support for PCI device DMA coherency
    PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
    of/pci: Fix pci_get_host_bridge_device leak
    device property: ACPI: Remove unused DMA APIs
    device property: ACPI: Make use of the new DMA Attribute APIs
    device property: Adding DMA Attribute APIs for Generic Devices
    ACPI: Adding DMA Attribute APIs for ACPI Device
    device property: Introducing enum dev_dma_attr
    ACPI: Honor ACPI _CCA attribute setting

    Conflicts:
    drivers/crypto/ccp/ccp-platform.c

    Rafael J. Wysocki
     
  • Now that we have the new DMA attribute APIs, we can replace the older
    acpi_check_dma() and device_dma_is_coherent().

    Signed-off-by: Suravee Suthikulpanit
    Acked-by: Bjorn Helgaas
    Reviewed-by: Hanjun Guo
    Signed-off-by: Rafael J. Wysocki

    Suthikulpanit, Suravee
     

15 Sep, 2015

1 commit


15 Jun, 2015

1 commit

  • This patch implements support for ACPI _CCA object, which is introduced in
    ACPIv5.1, can be used for specifying device DMA coherency attribute.

    The parsing logic traverses device namespace to parse coherency
    information, and stores it in acpi_device_flags. Then uses it to call
    arch_setup_dma_ops() when creating each device enumerated in DSDT
    during ACPI scan.

    This patch also introduces acpi_dma_is_coherent(), which provides
    an interface for device drivers to check the coherency information
    similarly to the of_dma_is_coherent().

    Signed-off-by: Mark Salter
    Signed-off-by: Suravee Suthikulpanit
    Signed-off-by: Rafael J. Wysocki

    Suthikulpanit, Suravee
     

17 Mar, 2015

1 commit

  • Now that the ACPI companions of devices are represented by pointers
    to struct fwnode_handle, it is not quite efficient to check whether
    or not an ACPI companion of a device is present by evaluating the
    ACPI_COMPANION() macro.

    For this reason, introduce a special static inline routine for that,
    has_acpi_companion(), and update the code to use it where applicable.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

11 Feb, 2014

1 commit

  • 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: Rafael J. Wysocki

    Rafael J. Wysocki
     

07 Dec, 2013

7 commits

  • Since drivers/ide/ide-acpi.c is the only remaining user of
    acpi_get_child(), move that function into that file as a static
    routine.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • There is no reason to pass an ACPI handle to acpi_bind_one() instead
    of a struct acpi_device pointer to the target device object, so
    modify that function to take a struct acpi_device pointer as its
    second argument and update all code depending on it accordingly.

    Signed-off-by: Rafael J. Wysocki
    Tested-by: Lan Tianyu # for USB/ACPI

    Rafael J. Wysocki
     
  • Replace the .find_device function pointer in struct acpi_bus_type
    with a new one, .find_companion, that is supposed to point to a
    function returning struct acpi_device pointer (instead of an int)
    and takes one argument (instead of two). This way the role of
    this callback is more clear and the implementation of it can
    be more straightforward.

    Update all of the users of struct acpi_bus_type (PCI, PNP/ACPI and
    USB) to reflect the structure change.

    Signed-off-by: Rafael J. Wysocki
    Tested-by: Lan Tianyu # for USB/ACPI

    Rafael J. Wysocki
     
  • Modify acpi_preset_companion() to take a struct acpi_device pointer
    instead of an ACPI handle as its second argument and redefine it as
    a static inline wrapper around ACPI_COMPANION_SET() passing the
    return value of acpi_find_child_device() directly as the second
    argument to it. Update its users to pass struct acpi_device
    pointers instead of ACPI handles to it.

    This allows some unnecessary acpi_bus_get_device() calls to be
    avoided.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Aaron Lu
    Tested-by: Aaron Lu # for ATA binding

    Rafael J. Wysocki
     
  • Since acpi_get_child() is the only user of acpi_find_child() now,
    drop the static inline definition of the former and redefine the
    latter as new acpi_get_child().

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Aaron Lu
    Tested-by: Aaron Lu # for ATA binding

    Rafael J. Wysocki
     
  • It is much more efficient to use acpi_find_child_device()
    for child devices lookup in acpi_pci_find_device() and pass
    ACPI_COMPANION(dev->parent) to it directly instead of obtaining
    ACPI_HANDLE() of ACPI_COMPANION(dev->parent) and passing it to
    acpi_find_child() which has to run acpi_bus_get_device() to
    obtain ACPI_COMPANION(dev->parent) from that again.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Aaron Lu

    Rafael J. Wysocki
     
  • Now that we create a struct acpi_device object for every ACPI
    namespace node representing a device, it is not necessary to
    use acpi_walk_namespace() for child device lookup in
    acpi_find_child() any more. Instead, we can simply walk the
    list of children of the given struct acpi_device object and
    return the matching one (or the one which is the best match if
    there are more of them). The checks done during the matching
    loop can be simplified too so that the secondary namespace walks
    in find_child_checks() are not necessary any more.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Aaron Lu

    Rafael J. Wysocki
     

15 Nov, 2013

2 commits

  • 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: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman
    Reviewed-by: Lan Tianyu

    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: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman
    Tested-by: Mika Westerberg # on Haswell
    Reviewed-by: Mika Westerberg
    Reviewed-by: Aaron Lu # for ATA and SDIO part

    Rafael J. Wysocki
     

10 Sep, 2013

1 commit

  • As reported at https://bugzilla.kernel.org/show_bug.cgi?id=60829,
    there still are cases in which do_find_child() doesn't choose the
    ACPI device object it is "expected" to choose if there are more such
    objects matching one PCI device present. This particular problem may
    be worked around by making do_find_child() return device obejcts witn
    _STA whose result indicates that the device is enabled before device
    objects without _STA if there's more than one device object to choose
    from.

    This change doesn't affect the case in which there's only one
    matching ACPI device object per PCI device.

    References: https://bugzilla.kernel.org/show_bug.cgi?id=60829
    Reported-by: Peter Wu
    Tested-by: Felix Lisczyk
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

09 Aug, 2013

2 commits


08 Aug, 2013

7 commits

  • The error code path in acpi_unbind_one() is unnecessarily complicated
    (in particular, the err label is not really necessary) and the error
    message printed by it is inaccurate (there's nothing called
    'acpi_handle' in that function), so clean up those things.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Toshi Kani
    Acked-by: Yasuaki Ishimatsu

    Rafael J. Wysocki
     
  • Since acpi_unbind_one() walks physical_node_list under the ACPI
    device object's physical_node_lock mutex and the walk may be
    terminated as soon as the matching entry has been found, it is
    not necessary to use list_for_each_safe() for that walk, so use
    list_for_each_entry() instead and make the code slightly more
    straightforward.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Toshi Kani
    Acked-by: Yasuaki Ishimatsu

    Rafael J. Wysocki
     
  • Clean up some inconsistent use of whitespace in acpi_bind_one() and
    acpi_unbind_one().

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Toshi Kani
    Acked-by: Yasuaki Ishimatsu

    Rafael J. Wysocki
     
  • Put the creation of symlinks in acpi_bind_one() under the
    physical_node_lock mutex of the given ACPI device object, because
    that is part of the binding operation logically (those links are
    already removed under that mutex too).

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Toshi Kani
    Acked-by: Yasuaki Ishimatsu

    Rafael J. Wysocki
     
  • Move some duplicated code from acpi_bind_one() and acpi_unbind_one()
    into a separate function and make that function use snprintf()
    instead of sprintf() for extra safety.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Toshi Kani
    Acked-by: Yasuaki Ishimatsu

    Rafael J. Wysocki
     
  • Modify acpi_bind_one() so that it doesn't fail if the device
    represented by its first argument has already been bound to the
    given ACPI handle (second argument), because that is not a good
    enough reason for returning an error code.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Lan Tianyu
    Acked-by: Toshi Kani

    Rafael J. Wysocki
     
  • In theory, under a given ACPI namespace node there should be only
    one child device object with _ADR whose value matches a given bus
    address exactly. In practice, however, there are systems in which
    multiple child device objects under a given parent have _ADR matching
    exactly the same address. In those cases we use _STA to determine
    which of the multiple matching devices is enabled, since some systems
    are known to indicate which ACPI device object to associate with the
    given physical (usually PCI) device this way.

    Unfortunately, as it turns out, there are systems in which many
    device objects under the same parent have _ADR matching exactly the
    same bus address and none of them has _STA, in which case they all
    should be regarded as enabled according to the spec. Still, if
    those device objects are supposed to represent bridges (e.g. this
    is the case for device objects corresponding to PCIe ports), we can
    try harder and skip the ones that have no child device objects in the
    ACPI namespace. With luck, we can avoid using device objects that we
    are not expected to use this way.

    Although this only works for bridges whose children also have ACPI
    namespace representation, it is sufficient to address graphics
    adapter detection issues on some systems, so rework the code finding
    a matching device ACPI handle for a given bus address to implement
    this idea.

    Introduce a new function, acpi_find_child(), taking three arguments:
    the ACPI handle of the device's parent, a bus address suitable for
    the device's bus type and a bool indicating if the device is a
    bridge and make it work as outlined above. Reimplement the function
    currently used for this purpose, acpi_get_child(), as a call to
    acpi_find_child() with the last argument set to 'false' and make
    the PCI subsystem use acpi_find_child() with the bridge information
    passed as the last argument to it. [Lan Tianyu notices that it is
    not sufficient to use pci_is_bridge() for that, because the device's
    subordinate pointer hasn't been set yet at this point, so use
    hdr_type instead.]

    This change fixes a regression introduced inadvertently by commit
    33f767d (ACPI: Rework acpi_get_child() to be more efficient) which
    overlooked the fact that for acpi_walk_namespace() "post-order" means
    "after all children have been visited" rather than "on the way back",
    so for device objects without children and for namespace walks of
    depth 1, as in the acpi_get_child() case, the "post-order" callbacks
    ordering is actually the same as the ordering of "pre-order" ones.
    Since that commit changed the namespace walk in acpi_get_child() to
    terminate after finding the first matching object instead of going
    through all of them and returning the last one, it effectively
    changed the result returned by that function in some rare cases and
    that led to problems (the switch from a "pre-order" to a "post-order"
    callback was supposed to prevent that from happening, but it was
    ineffective).

    As it turns out, the systems where the change made by commit
    33f767d actually matters are those where there are multiple ACPI
    device objects representing the same PCIe port (which effectively
    is a bridge). Moreover, only one of them, and the one we are
    expected to use, has child device objects in the ACPI namespace,
    so the regression can be addressed as described above.

    References: https://bugzilla.kernel.org/show_bug.cgi?id=60561
    Reported-by: Peter Wu
    Tested-by: Vladimir Lalov
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Bjorn Helgaas
    Cc: 3.9+ # 3.9+

    Rafael J. Wysocki
     

06 Aug, 2013

1 commit

  • The physical_node_id_bitmap in struct acpi_device is only used for
    looking up the first currently unused dependent phyiscal node ID
    by acpi_bind_one(). It is not really necessary, however, because
    acpi_bind_one() walks the entire physical_node_list of the given
    device object for sanity checking anyway and if that list is always
    sorted by node_id, it is straightforward to find the first gap
    between the currently used node IDs and use that number as the ID
    of the new list node.

    This also removes the artificial limit of the maximum number of
    dependent physical devices per ACPI device object, which now depends
    only on the capacity of unsigend int. As a result, it fixes a
    regression introduced by commit e2ff394 (ACPI / memhotplug: Bind
    removable memory blocks to ACPI device nodes) that caused
    acpi_memory_enable_device() to fail when the number of 128 MB blocks
    within one removable memory module was greater than 32.

    Reported-and-tested-by: Yasuaki Ishimatsu
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Toshi Kani
    Reviewed-by: Yasuaki Ishimatsu

    Rafael J. Wysocki
     

28 Jun, 2013

1 commit

  • * acpi-assorted:
    ACPI / EC: Add HP Folio 13 to ec_dmi_table in order to skip DSDT scan
    ACPI: Add CMOS RTC Operation Region handler support
    ACPI: Remove unused flags in acpi_device_flags
    ACPI: Remove useless initializers
    ACPI / battery: Make sure all spaces are in correct places
    ACPI: add _STA evaluation at do_acpi_find_child()
    ACPI / EC: access user space with get_user()/put_user()

    Rafael J. Wysocki
     

20 Jun, 2013

1 commit

  • Once do_acpi_find_child() has found the first matching handle, it
    makes the acpi_get_child() loop stop and return that handle. On some
    platforms, though, there are multiple devices with the same value of
    "_ADR" in the same namespace scope, and if one of them is enabled,
    the others will be disabled. For example:

    Address : 0x1FFFF ; path : SB_PCI0.SATA.DEV0
    Address : 0x1FFFF ; path : SB_PCI0.SATA.DEV1
    Address : 0x1FFFF ; path : SB_PCI0.SATA.DEV2

    If DEV0 and DEV1 are disabled and DEV2 is enabled, the handle of DEV2
    should be returned, but actually the function always returns the
    handle of DEV0.

    To address that issue, make do_acpi_find_child() evaluate _STA to
    check the device status. If a matching device object exists, but is
    disabled, acpi_get_child() will continue to walk the namespace in the
    hope of finding an enabled one. If one is found, its handle will be
    returned, but otherwise the function will return the handle of the
    disabled object found before (in case it is enabled going forward).

    [rjw: Changelog]
    Signed-off-by: Jeff Wu
    Signed-off-by: Rafael J. Wysocki

    Jeff Wu
     

12 May, 2013

1 commit

  • Split the ACPI processor driver into two parts, one that is
    non-modular, resides in the ACPI core and handles the enumeration
    and hotplug of processors and one that implements the rest of the
    existing processor driver functionality.

    The non-modular part uses an ACPI scan handler object to enumerate
    processors on the basis of information provided by the ACPI namespace
    and to hook up with the common ACPI hotplug infrastructure. It also
    populates the ACPI handle of each processor device having a
    corresponding object in the ACPI namespace, which allows the driver
    proper to bind to those devices, and makes the driver bind to them
    if it is readily available (i.e. loaded) when the scan handler's
    .attach() routine is running.

    There are a few reasons to make this change.

    First, switching the ACPI processor driver to using the common ACPI
    hotplug infrastructure reduces code duplication and size considerably,
    even though a new file is created along with a header comment etc.

    Second, since the common hotplug code attempts to offline devices
    before starting the (non-reversible) removal procedure, it will abort
    (and possibly roll back) hot-remove operations involving processors
    if cpu_down() returns an error code for one of them instead of
    continuing them blindly (if /sys/firmware/acpi/hotplug/force_remove
    is unset). That is a more desirable behavior than what the current
    code does.

    Finally, the separation of the scan/hotplug part from the driver
    proper makes it possible to simplify the driver's .remove() routine,
    because it doesn't need to worry about the possible cleanup related
    to processor removal any more (the scan/hotplug part is responsible
    for that now) and can handle device removal and driver removal
    symmetricaly (i.e. as appropriate).

    Some user-visible changes in sysfs are made (for example, the
    'sysdev' link from the ACPI device node to the processor device's
    directory is gone and a 'physical_node' link is present instead
    and a corresponding 'firmware_node' is present in the processor
    device's directory, the processor driver is now visible under
    /sys/bus/cpu/drivers/ and bound to the processor device), but
    that shouldn't affect the functionality that users care about
    (frequency scaling, C-states and thermal management).

    Tested on my venerable Toshiba Portege R500.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman
    Reviewed-by: Toshi Kani

    Rafael J. Wysocki
     

04 Mar, 2013

2 commits

  • After PCI and USB have stopped using the .find_bridge() callback in
    struct acpi_bus_type, the only remaining user of it is SATA, but SATA
    only pretends to be a user, because it points that callback to a stub
    always returning -ENODEV.

    For this reason, drop the SATA's dummy .find_bridge() callback and
    remove .find_bridge(), which is not used any more, from struct
    acpi_bus_type entirely.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Yinghai Lu
    Acked-by: Jeff Garzik

    Rafael J. Wysocki
     
  • USB uses the .find_bridge() callback from struct acpi_bus_type
    incorrectly, because as a result of the way it is used by USB every
    device in the system that doesn't have a bus type or parent is
    passed to usb_acpi_find_device() for inspection.

    What USB actually needs, though, is to call usb_acpi_find_device()
    for USB ports that don't have a bus type defined, but have
    usb_port_device_type as their device type, as well as for USB
    devices.

    To fix that replace the struct bus_type pointer in struct
    acpi_bus_type used for matching devices to specific subsystems
    with a .match() callback to be used for this purpose and update
    the users of struct acpi_bus_type, including USB, accordingly.
    Define the .match() callback routine for USB, usb_acpi_bus_match(),
    in such a way that it will cover both USB devices and USB ports
    and remove the now redundant .find_bridge() callback pointer from
    usb_acpi_bus.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman
    Acked-by: Yinghai Lu
    Acked-by: Jeff Garzik

    Rafael J. Wysocki
     

15 Feb, 2013

1 commit

  • * acpi-assorted:
    ACPI: Add DMI entry for Sony VGN-FW41E_H
    ACPI: fix obsolete comment in custom_method.c
    ACPI / thermal: Use mode to enable/disable kernel thermal processing
    ACPI thermal: remove unnecessary newline from exception message
    ACPI sysfs: remove unnecessary newline from exception
    ACPI video: remove unnecessary newline from error messages
    ACPI: SRAT: report non-volatile memory in debug
    ACPI: Rework acpi_get_child() to be more efficient

    Rafael J. Wysocki
     

11 Feb, 2013

1 commit

  • * acpi-scan: (30 commits)
    ACPI / scan: Fix acpi_bus_get_device() check in acpi_match_device()
    ACPI / scan: Make namespace scanning and trimming mutually exclusive
    ACPI / scan: Make it clear that acpi_bus_trim() cannot fail
    ACPI / scan: Drop acpi_bus_add() and use acpi_bus_scan() instead
    ACPI: update ej_event interface to take acpi_device
    ACPI / scan: Add second pass to acpi_bus_trim()
    ACPI / scan: Change the implementation of acpi_bus_trim()
    ACPI / scan: Drop the second argument of acpi_bus_trim()
    ACPI / scan: Drop the second argument of acpi_device_unregister()
    ACPI: Remove the ops field from struct acpi_device
    ACPI: remove unused acpi_op_bind and acpi_op_unbind
    ACPI / scan: Fix check of device_attach() return value.
    ACPI / scan: Treat power resources in a special way
    ACPI: Remove unused struct acpi_pci_root.id member
    ACPI: Drop ACPI device .bind() and .unbind() callbacks
    ACPI / PCI: Move the _PRT setup and cleanup code to pci-acpi.c
    ACPI / PCI: Rework the setup and cleanup of device wakeup
    ACPI: Add .setup() and .cleanup() callbacks to struct acpi_bus_type
    ACPI: Make acpi_bus_scan() and acpi_bus_add() take only one argument
    ACPI: Replace ACPI device add_type field with a match_driver flag
    ...

    Rafael J. Wysocki
     

26 Jan, 2013

1 commit

  • Observe that acpi_get_child() doesn't need to use the helper
    struct acpi_find_child structure and change it to work without it.
    Also, using acpi_get_object_info() to get the output of _ADR for the
    given device is overkill, because that function does much more than
    just evaluating _ADR (let alone the additional memory allocation
    done by it).

    Moreover, acpi_get_child() doesn't need to loop any more once it has
    found a matching handle, so make it stop in that case. To prevent
    the results from changing, make it use do_acpi_find_child() as
    a post-order callback.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

12 Jan, 2013

1 commit

  • If ACPI_GLUE_DEBUG is different from 0 (setting this requires a
    manual change of glue.c), build breaks because of a leftover
    reference to dev->acpi_handle in acpi_platform_notify(). Fix this
    by using ACPI_HANDLE(dev) instead as appropriate.

    [rjw: Subject and changelog]
    Signed-off-by: Yinghai Lu
    Signed-off-by: Rafael J. Wysocki

    Yinghai Lu
     

03 Jan, 2013

2 commits

  • Currently these DBG statements are emitted at KERN_DEFAULT.
    Change the macro to emit at KERN_DEBUG.

    This can help avoid unexpected message interleaving.

    Signed-off-by: Joe Perches
    Signed-off-by: Rafael J. Wysocki

    Joe Perches
     
  • Add two new callbacks,.setup() and .cleanup(), struct acpi_bus_type
    and modify acpi_platform_notify() to call .setup() after executing
    acpi_bind_one() successfully and acpi_platform_notify_remove() to
    call .cleanup() before running acpi_unbind_one(). This will allow
    the users of struct acpi_bus_type, PCI in particular, to specify
    operations to be executed right after the given device has been
    associated with a companion struct acpi_device and right before
    it's going to be detached from that companion, respectively.

    The main motivation is to be able to get rid of acpi_pci_bind()
    and acpi_pci_unbind(), which are horrible horrible stuff. [In short,
    there are three problems with them: The way they populate the .bind()
    and .unbind() callbacks of ACPI devices is rather less than
    straightforward, they require special hotplug-specific paths to be
    present in the ACPI namespace scanning code and by the time
    acpi_pci_unbind() is called the PCI device object in question may
    not exist any more.]

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Yinghai Lu
    Acked-by: Toshi Kani

    Rafael J. Wysocki
     

21 Nov, 2012

2 commits

  • To avoid adding an ACPI handle pointer to struct device on
    architectures that don't use ACPI, or generally when CONFIG_ACPI is
    not set, in which cases that pointer is useless, define struct
    acpi_dev_node that will contain the handle pointer if CONFIG_ACPI is
    set and will be empty otherwise and use it to represent the ACPI
    device node field in struct device.

    In addition to that define macros for reading and setting the ACPI
    handle of a device that don't generate code when CONFIG_ACPI is
    unset. Modify the ACPI subsystem to use those macros instead of
    referring to the given device's ACPI handle directly.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg
    Acked-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • Currently, the ACPI handles of devices are initialized from within
    device_add(), by acpi_bind_one() called from acpi_platform_notify()
    which first uses the .find_device() routine provided by the device's
    bus type to find the matching device node in the ACPI namespace.
    This is a source of some computational overhead and, moreover, the
    correctness of the result depends on the implementation of
    .find_device() which is known to fail occasionally for some bus types
    (e.g. PCI). In some cases, however, the corresponding ACPI device
    node is known already before calling device_add() for the given
    struct device object and the whole .find_device() dance in
    acpi_platform_notify() is then simply unnecessary.

    For this reason, make it possible to initialize the ACPI handles of
    devices before calling device_add() for them. Modify
    acpi_platform_notify() to call acpi_bind_one() in advance to check
    the device's existing ACPI handle and skip the .find_device()
    search if that is successful. Change acpi_bind_one() accordingly.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg

    Rafael J. Wysocki
     

15 Nov, 2012

1 commit

  • With ACPI 5 we are starting to see devices that don't natively support
    discovery but can be enumerated with the help of the ACPI namespace.
    Typically, these devices can be represented in the Linux device driver
    model as platform devices or some serial bus devices, like SPI or I2C
    devices.

    Since we want to re-use existing drivers for those devices, we need a
    way for drivers to specify the ACPI IDs of supported devices, so that
    they can be matched against device nodes in the ACPI namespace. To
    this end, it is sufficient to add a pointer to an array of supported
    ACPI device IDs, that can be provided by the driver, to struct device.

    Moreover, things like ACPI power management need to have access to
    the ACPI handle of each supported device, because that handle is used
    to invoke AML methods associated with the corresponding ACPI device
    node. The ACPI handles of devices are now stored in the archdata
    member structure of struct device whose definition depends on the
    architecture and includes the ACPI handle only on x86 and ia64. Since
    the pointer to an array of supported ACPI IDs is added to struct
    device_driver in an architecture-independent way, it is logical to
    move the ACPI handle from archdata to struct device itself at the same
    time. This also makes code more straightforward in some places and
    follows the example of Device Trees that have a poiter to struct
    device_node in there too.

    This changeset is based on Mika Westerberg's work.

    Signed-off-by: Mika Westerberg
    Acked-by: Greg Kroah-Hartman
    Acked-by: H. Peter Anvin
    Acked-by: Tony Luck
    Signed-off-by: Rafael J. Wysocki

    Mika Westerberg