1. 18 9月, 2017 1 次提交
  2. 29 8月, 2017 1 次提交
  3. 28 8月, 2017 1 次提交
  4. 07 8月, 2017 1 次提交
  5. 22 7月, 2017 3 次提交
  6. 07 7月, 2017 1 次提交
  7. 13 6月, 2017 1 次提交
    • J
      driver core: add helper to reuse a device-tree node · 4e75e1d7
      Johan Hovold 提交于
      Add a helper function to be used when reusing the device-tree node of
      another device.
      
      It is fairly common for drivers to reuse the device-tree node of a
      parent (or other ancestor) device when creating class or bus devices
      (e.g. gpio chips, i2c adapters, iio chips, spi masters, serdev, phys,
      usb root hubs). But reusing a device-tree node may cause problems if the
      new device is later probed as for example driver core would currently
      attempt to reinitialise an already active associated pinmux
      configuration.
      
      Other potential issues include the platform-bus code unconditionally
      dropping the device-tree node reference in its device destructor,
      reinitialisation of other bus-managed resources such as clocks, and the
      recently added DMA-setup in driver core.
      
      Note that for most examples above this is currently not an issue as the
      devices are never probed, but this is a problem for the USB bus which
      has recently gained device-tree support. This was discovered and
      worked-around in a rather ad-hoc fashion by commit dc5878ab ("usb:
      core: move root hub's device node assignment after it is added to bus")
      by not setting the of_node pointer until after the root-hub device has
      been registered.
      
      Instead we can allow devices to reuse a device-tree node by setting a
      flag in their struct device that can be used by core, bus and driver
      code to avoid resources from being over-allocated.
      
      Note that the helper also grabs an extra reference to the device node,
      which specifically balances the unconditional put in the platform-device
      destructor.
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e75e1d7
  8. 12 6月, 2017 1 次提交
  9. 09 6月, 2017 1 次提交
  10. 07 6月, 2017 1 次提交
  11. 17 3月, 2017 1 次提交
  12. 25 2月, 2017 1 次提交
  13. 25 1月, 2017 1 次提交
  14. 21 1月, 2017 2 次提交
  15. 05 12月, 2016 1 次提交
  16. 30 11月, 2016 1 次提交
  17. 24 11月, 2016 1 次提交
  18. 16 11月, 2016 1 次提交
  19. 01 11月, 2016 2 次提交
    • R
      PM / runtime: Use device links · 21d5c57b
      Rafael J. Wysocki 提交于
      Modify the runtime PM framework to use device links to ensure that
      supplier devices will not be suspended if any of their consumer
      devices are active.
      
      The idea is to reference count suppliers on the consumer's resume
      and drop references to them on its suspend.  The information on
      whether or not the supplier has been reference counted by the
      consumer's (runtime) resume is stored in a new field (rpm_active)
      in the link object for each link.
      
      It may be necessary to clean up those references when the
      supplier is unbinding and that's why the links whose status is
      DEVICE_LINK_SUPPLIER_UNBIND are skipped by the runtime suspend
      and resume code.
      
      The above means that if the consumer device is probed in the
      runtime-active state, the supplier has to be resumed and reference
      counted by device_link_add() so the code works as expected on its
      (runtime) suspend.  There is a new flag, DEVICE_LINK_RPM_ACTIVE,
      to tell device_link_add() about that (in which case the caller
      is responsible for making sure that the consumer really will
      be runtime-active when runtime PM is enabled for it).
      
      The other new link flag, DEVICE_LINK_PM_RUNTIME, tells the core
      whether or not the link should be used for runtime PM at all.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21d5c57b
    • R
      driver core: Functional dependencies tracking support · 9ed98953
      Rafael J. Wysocki 提交于
      Currently, there is a problem with taking functional dependencies
      between devices into account.
      
      What I mean by a "functional dependency" is when the driver of device
      B needs device A to be functional and (generally) its driver to be
      present in order to work properly.  This has certain consequences
      for power management (suspend/resume and runtime PM ordering) and
      shutdown ordering of these devices.  In general, it also implies that
      the driver of A needs to be working for B to be probed successfully
      and it cannot be unbound from the device before the B's driver.
      
      Support for representing those functional dependencies between
      devices is added here to allow the driver core to track them and act
      on them in certain cases where applicable.
      
      The argument for doing that in the driver core is that there are
      quite a few distinct use cases involving device dependencies, they
      are relatively hard to get right in a driver (if one wants to
      address all of them properly) and it only gets worse if multiplied
      by the number of drivers potentially needing to do it.  Morever, at
      least one case (asynchronous system suspend/resume) cannot be handled
      in a single driver at all, because it requires the driver of A to
      wait for B to suspend (during system suspend) and the driver of B to
      wait for A to resume (during system resume).
      
      For this reason, represent dependencies between devices as "links",
      with the help of struct device_link objects each containing pointers
      to the "linked" devices, a list node for each of them, status
      information, flags, and an RCU head for synchronization.
      
      Also add two new list heads, representing the lists of links to the
      devices that depend on the given one (consumers) and to the devices
      depended on by it (suppliers), and a "driver presence status" field
      (needed for figuring out initial states of device links) to struct
      device.
      
      The entire data structure consisting of all of the lists of link
      objects for all devices is protected by a mutex (for link object
      addition/removal and for list walks during device driver probing
      and removal) and by SRCU (for list walking in other case that will
      be introduced by subsequent change sets).  If CONFIG_SRCU is not
      selected, however, an rwsem is used for protecting the entire data
      structure.
      
      In addition, each link object has an internal status field whose
      value reflects whether or not drivers are bound to the devices
      pointed to by the link or probing/removal of their drivers is in
      progress etc.  That field is only modified under the device links
      mutex, but it may be read outside of it in some cases (introduced by
      subsequent change sets), so modifications of it are annotated with
      WRITE_ONCE().
      
      New links are added by calling device_link_add() which takes three
      arguments: pointers to the devices in question and flags.  In
      particular, if DL_FLAG_STATELESS is set in the flags, the link status
      is not to be taken into account for this link and the driver core
      will not manage it.  In turn, if DL_FLAG_AUTOREMOVE is set in the
      flags, the driver core will remove the link automatically when the
      consumer device driver unbinds from it.
      
      One of the actions carried out by device_link_add() is to reorder
      the lists used for device shutdown and system suspend/resume to
      put the consumer device along with all of its children and all of
      its consumers (and so on, recursively) to the ends of those lists
      in order to ensure the right ordering between all of the supplier
      and consumer devices.
      
      For this reason, it is not possible to create a link between two
      devices if the would-be supplier device already depends on the
      would-be consumer device as either a direct descendant of it or a
      consumer of one of its direct descendants or one of its consumers
      and so on.
      
      There are two types of link objects, persistent and non-persistent.
      The persistent ones stay around until one of the target devices is
      deleted, while the non-persistent ones are removed automatically when
      the consumer driver unbinds from its device (ie. they are assumed to
      be valid only as long as the consumer device has a driver bound to
      it).  Persistent links are created by default and non-persistent
      links are created when the DL_FLAG_AUTOREMOVE flag is passed
      to device_link_add().
      
      Both persistent and non-persistent device links can be deleted
      with an explicit call to device_link_del().
      
      Links created without the DL_FLAG_STATELESS flag set are managed
      by the driver core using a simple state machine.  There are 5 states
      each link can be in: DORMANT (unused), AVAILABLE (the supplier driver
      is present and functional), CONSUMER_PROBE (the consumer driver is
      probing), ACTIVE (both supplier and consumer drivers are present and
      functional), and SUPPLIER_UNBIND (the supplier driver is unbinding).
      The driver core updates the link state automatically depending on
      what happens to the linked devices and for each link state specific
      actions are taken in addition to that.
      
      For example, if the supplier driver unbinds from its device, the
      driver core will also unbind the drivers of all of its consumers
      automatically under the assumption that they cannot function
      properly without the supplier.  Analogously, the driver core will
      only allow the consumer driver to bind to its device if the
      supplier driver is present and functional (ie. the link is in
      the AVAILABLE state).  If that's not the case, it will rely on
      the existing deferred probing mechanism to wait for the supplier
      driver to become available.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ed98953
  20. 24 10月, 2016 1 次提交
  21. 16 9月, 2016 1 次提交
    • R
      iommu: Introduce iommu_fwspec · 57f98d2f
      Robin Murphy 提交于
      Introduce a common structure to hold the per-device firmware data that
      most IOMMU drivers need to keep track of. This enables us to configure
      much of that data from common firmware code, and consolidate a lot of
      the equivalent implementations, device look-up tables, etc. which are
      currently strewn across IOMMU drivers.
      
      This will also be enable us to address the outstanding "multiple IOMMUs
      on the platform bus" problem by tweaking IOMMU API calls to prefer
      dev->fwspec->ops before falling back to dev->bus->iommu_ops, and thus
      gracefully handle those troublesome systems which we currently cannot.
      
      As the first user, hook up the OF IOMMU configuration mechanism. The
      driver-defined nature of DT cells means that we still need the drivers
      to translate and add the IDs themselves, but future users such as the
      much less free-form ACPI IORT will be much simpler and self-contained.
      
      CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Suggested-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      57f98d2f
  22. 20 5月, 2016 1 次提交
    • R
      include/linux: apply __malloc attribute · 48a27055
      Rasmus Villemoes 提交于
      Attach the malloc attribute to a few allocation functions.  This helps
      gcc generate better code by telling it that the return value doesn't
      alias any existing pointers (which is even more valuable given the
      pessimizations implied by -fno-strict-aliasing).
      
      A simple example of what this allows gcc to do can be seen by looking at
      the last part of drm_atomic_helper_plane_reset:
      
      	plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL);
      
      	if (plane->state) {
      		plane->state->plane = plane;
      		plane->state->rotation = BIT(DRM_ROTATE_0);
      	}
      
      which compiles to
      
          e8 99 bf d6 ff          callq  ffffffff8116d540 <kmem_cache_alloc_trace>
          48 85 c0                test   %rax,%rax
          48 89 83 40 02 00 00    mov    %rax,0x240(%rbx)
          74 11                   je     ffffffff814015c4 <drm_atomic_helper_plane_reset+0x64>
          48 89 18                mov    %rbx,(%rax)
          48 8b 83 40 02 00 00    mov    0x240(%rbx),%rax [*]
          c7 40 40 01 00 00 00    movl   $0x1,0x40(%rax)
      
      With this patch applied, the instruction at [*] is elided, since the
      store to plane->state->plane is known to not alter the value of
      plane->state.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      48a27055
  23. 02 5月, 2016 1 次提交
    • A
      driver-core: use 'dev' argument in dev_dbg_ratelimited stub · 1f62ff34
      Arnd Bergmann 提交于
      dev_dbg_ratelimited() is a macro that ignores its first argument when DEBUG is
      not set, which can lead to unused variable warnings:
      
      ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_sdq_handle':
      ethernet/mellanox/mlxsw/pci.c:646:18: warning: unused variable 'pdev' [-Wunused-variable]
      ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_rdq_handle':
      ethernet/mellanox/mlxsw/pci.c:671:18: warning: unused variable 'pdev' [-Wunused-variable]
      
      The macro already ensures that all its other arguments are silently
      ignored by the compiler without triggering a warning, through the
      use of the no_printk() macro, but the dev argument is not passed into
      that.
      
      This changes the definition to use the same trick as no_printk() with
      an if(0) that leads the compiler to not evaluate the side-effects but
      still see that 'dev' might not be unused.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Suggested-by: NAndrew Lunn <andrew@lunn.ch>
      Fixes: 6f586e66 ("driver-core: Shut up dev_dbg_reatelimited() without DEBUG")
      Reviewed-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f62ff34
  24. 22 4月, 2016 1 次提交
  25. 17 2月, 2016 1 次提交
  26. 09 2月, 2016 1 次提交
  27. 04 2月, 2016 1 次提交
  28. 08 1月, 2016 1 次提交
  29. 09 12月, 2015 1 次提交
  30. 10 10月, 2015 1 次提交
  31. 06 8月, 2015 1 次提交
  32. 30 7月, 2015 1 次提交
  33. 28 7月, 2015 1 次提交
  34. 23 7月, 2015 1 次提交
  35. 18 7月, 2015 1 次提交
    • N
      include, lib: add __printf attributes to several function prototypes · 8db14860
      Nicolas Iooss 提交于
      Using __printf attributes helps to detect several format string issues
      at compile time (even though -Wformat-security is currently disabled in
      Makefile).  For example it can detect when formatting a pointer as a
      number, like the issue fixed in commit a3fa71c4 ("wl18xx: show
      rx_frames_per_rates as an array as it really is"), or when the arguments
      do not match the format string, c.f.  for example commit 5ce1aca8
      ("reiserfs: fix __RASSERT format string").
      
      To prevent similar bugs in the future, add a __printf attribute to every
      function prototype which needs one in include/linux/ and lib/.  These
      functions were mostly found by using gcc's -Wsuggest-attribute=format
      flag.
      Signed-off-by: NNicolas Iooss <nicolas.iooss_linux@m4x.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Felipe Balbi <balbi@ti.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8db14860
  36. 17 6月, 2015 1 次提交
    • P
      platform_device: better support builtin boilerplate avoidance · f309d444
      Paul Gortmaker 提交于
      We have macros that help reduce the boilerplate for modules
      that register with no extra init/exit complexity other than the
      most standard use case.  However we see an increasing number of
      non-modular drivers using these modular_driver() type register
      functions.
      
      There are several downsides to this:
      1) The code can appear modular to a reader of the code, and they
         won't know if the code really is modular without checking the
         Makefile and Kconfig to see if compilation is governed by a
         bool or tristate.
      2) Coders of drivers may be tempted to code up an __exit function
         that is never used, just in order to satisfy the required three
         args of the modular registration function.
      3) Non-modular code ends up including the <module.h> which increases
         CPP overhead that they don't need.
      4) It hinders us from performing better separation of the module
         init code and the generic init code.
      
      Here we introduce similar macros, with the mapping from module_driver
      to builtin_driver and similar, so that simple changes of:
      
        module_platform_driver()       --->  builtin_platform_driver()
        module_platform_driver_probe() --->  builtin_platform_driver_probe().
      
      can help us avoid #3 above, without having to code up the same
      __init functions and device_initcall() boilerplate.
      
      For non modular code, module_init becomes __initcall.  But direct use
      of __initcall is discouraged, vs. one of the priority categorized
      subgroups.  As __initcall gets mapped onto device_initcall, our
      use of device_initcall directly in this change means that the
      runtime impact is zero -- drivers will remain at level 6 in the
      initcall ordering.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      f309d444