1. 05 7月, 2019 1 次提交
  2. 14 6月, 2019 1 次提交
    • D
      drivers/base/devres: introduce devm_release_action() · 2374b682
      Dan Williams 提交于
      Patch series "mm/devm_memremap_pages: Fix page release race", v2.
      
      Logan audited the devm_memremap_pages() shutdown path and noticed that
      it was possible to proceed to arch_remove_memory() before all potential
      page references have been reaped.
      
      Introduce a new ->cleanup() callback to do the work of waiting for any
      straggling page references and then perform the percpu_ref_exit() in
      devm_memremap_pages_release() context.
      
      For p2pdma this involves some deeper reworks to reference count
      resources on a per-instance basis rather than a per pci-device basis.  A
      modified genalloc api is introduced to convey a driver-private pointer
      through gen_pool_{alloc,free}() interfaces.  Also, a
      devm_memunmap_pages() api is introduced since p2pdma does not
      auto-release resources on a setup failure.
      
      The dax and pmem changes pass the nvdimm unit tests, and the p2pdma
      changes should now pass testing with the pci_p2pdma_release() fix.
      Jrme, how does this look for HMM?
      
      This patch (of 6):
      
      The devm_add_action() facility allows a resource allocation routine to
      add custom devm semantics.  One such user is devm_memremap_pages().
      
      There is now a need to manually trigger
      devm_memremap_pages_release().  Introduce devm_release_action() so the
      release action can be triggered via a new devm_memunmap_pages() api in a
      follow-on change.
      
      Link: http://lkml.kernel.org/r/155727336530.292046.2926860263201336366.stgit@dwillia2-desk3.amr.corp.intel.comSigned-off-by: NDan Williams <dan.j.williams@intel.com>
      Reviewed-by: NIra Weiny <ira.weiny@intel.com>
      Reviewed-by: NLogan Gunthorpe <logang@deltatee.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: "Jérôme Glisse" <jglisse@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2374b682
  3. 20 4月, 2019 1 次提交
  4. 01 4月, 2019 1 次提交
    • G
      device.h: reorganize struct device · 159ef31e
      Greg Kroah-Hartman 提交于
      struct device is big, around 760 bytes on x86_64.  It's not a critical
      structure, but it is embedded everywhere, so making it smaller is always
      a good thing.
      
      With a recent patch that moved a field from struct device to the private
      structure, some benchmarks showed a very odd regression, despite this
      structure having nothing to do with those benchmarks.  That caused me to
      look into the layout of the structure.  Using 'pahole', it showed a
      number of holes and ways that the structure could be reordered in order
      to align some cachelines better, as well as reduce the size of the
      overall structure.
      
      Move 'struct kobj' to the start of the structure, to keep that access
      in the first cacheline, and try to organize things a bit more compactly
      where possible
      
      By doing these few moves, the result removes at least 8 bytes from
      'struct device' on a 64bit system.  Given we know there are systems with
      at least 30k devices in memory at once, every little byte counts, and
      this change could be a savings of 240k of kernel memory for them.  On
      "normal" systems the overall memory savings would be much less.
      
      Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
      Cc: Johan Hovold <johan@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      159ef31e
  5. 18 3月, 2019 1 次提交
  6. 08 3月, 2019 1 次提交
    • R
      linux/device.h: use DYNAMIC_DEBUG_BRANCH in dev_dbg_ratelimited · e0b73d7b
      Rasmus Villemoes 提交于
      Patch series "various dynamic_debug patches", v4.
      
      This started as an experiment to see how hard it would be to change the
      four pointers in struct _ddebug into relative offsets, a la
      CONFIG_GENERIC_BUG_RELATIVE_POINTERS, thus saving 16 bytes per pr_debug
      site (and thus exactly making up for the extra space used by the
      introduction of jump labels in 9049fc74).  I stumbled on a few things
      that are probably worth fixing regardless of whether that goal is deemed
      worthwhile.
      
      Back at v3 (in November), I redid the implementation on top of the fancy
      new asm-macros stuff.  Luckily enough, v3 didn't get picked up, since
      the asm-macros were backed out again.  I still want to do the
      relative-pointers thing eventually, but we're close to the merge window
      opening, so here's just most of the "incidental" patches, some of which
      also serve as preparation for the relative pointers.
      
      This patch (of 4):
      
      dev_dbg_ratelimited tests the dynamic debug descriptor the old-fashioned
      way, and doesn't utilize the static key/jump label implementation when
      CONFIG_JUMP_LABEL is set.  Use the DYNAMIC_DEBUG_BRANCH which is defined
      appropriately.
      
      Link: http://lkml.kernel.org/r/20190212214150.4807-2-linux@rasmusvillemoes.dkSigned-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NJason Baron <jbaron@akamai.com>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e0b73d7b
  7. 06 3月, 2019 1 次提交
    • A
      mm: replace all open encodings for NUMA_NO_NODE · 98fa15f3
      Anshuman Khandual 提交于
      Patch series "Replace all open encodings for NUMA_NO_NODE", v3.
      
      All these places for replacement were found by running the following
      grep patterns on the entire kernel code.  Please let me know if this
      might have missed some instances.  This might also have replaced some
      false positives.  I will appreciate suggestions, inputs and review.
      
      1. git grep "nid == -1"
      2. git grep "node == -1"
      3. git grep "nid = -1"
      4. git grep "node = -1"
      
      This patch (of 2):
      
      At present there are multiple places where invalid node number is
      encoded as -1.  Even though implicitly understood it is always better to
      have macros in there.  Replace these open encodings for an invalid node
      number with the global macro NUMA_NO_NODE.  This helps remove NUMA
      related assumptions like 'invalid node' from various places redirecting
      them to a common definition.
      
      Link: http://lkml.kernel.org/r/1545127933-10711-2-git-send-email-anshuman.khandual@arm.comSigned-off-by: NAnshuman Khandual <anshuman.khandual@arm.com>
      Reviewed-by: NDavid Hildenbrand <david@redhat.com>
      Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>	[ixgbe]
      Acked-by: Jens Axboe <axboe@kernel.dk>			[mtip32xx]
      Acked-by: Vinod Koul <vkoul@kernel.org>			[dmaengine.c]
      Acked-by: Michael Ellerman <mpe@ellerman.id.au>		[powerpc]
      Acked-by: Doug Ledford <dledford@redhat.com>		[drivers/infiniband]
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Hans Verkuil <hverkuil@xs4all.nl>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      98fa15f3
  8. 21 2月, 2019 1 次提交
  9. 20 2月, 2019 2 次提交
  10. 19 2月, 2019 1 次提交
    • S
      PM / core: Add support to skip power management in device/driver model · 85945c28
      Sudeep Holla 提交于
      All device objects in the driver model contain fields that control the
      handling of various power management activities. However, it's not
      always useful. There are few instances where pseudo devices are added
      to the model just to take advantage of many other features like
      kobjects, udev events, and so on. One such example is cpu devices and
      their caches.
      
      The sysfs for the cpu caches are managed by adding devices with cpu
      as the parent in cpu_device_create() when secondary cpu is brought
      online. Generally when the secondary CPUs are hotplugged back in as part
      of resume from suspend-to-ram, we call cpu_device_create() from the cpu
      hotplug state machine while the cpu device associated with that CPU is
      not yet ready to be resumed as the device_resume() call happens bit
      later. It's not really needed to set the flag is_prepared for cpu
      devices as they are mostly pseudo device and hotplug framework deals
      with state machine and not managed through the cpu device.
      
      This often results in annoying warning when resuming:
      Enabling non-boot CPUs ...
      CPU1: Booted secondary processor
       cache: parent cpu1 should not be sleeping
      CPU1 is up
      CPU2: Booted secondary processor
       cache: parent cpu2 should not be sleeping
      CPU2 is up
      .... and so on.
      
      So in order to fix these kind of errors, we could just completely avoid
      doing any power management related initialisations and operations if
      they are not used by these devices.
      
      Add no_pm flags to indicate that the device doesn't require any sort of
      PM activities and all of them can be completely skipped. We can use the
      same flag to also avoid adding not used *power* sysfs entries for these
      devices. For now, lets use this for cpu cache devices.
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NSudeep Holla <sudeep.holla@arm.com>
      Tested-by: NEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      85945c28
  11. 14 2月, 2019 2 次提交
  12. 08 2月, 2019 1 次提交
  13. 03 2月, 2019 1 次提交
  14. 01 2月, 2019 2 次提交
    • R
      driver core: Add device link flag DL_FLAG_AUTOPROBE_CONSUMER · e7dd4010
      Rafael J. Wysocki 提交于
      Add a new device link flag, DL_FLAG_AUTOPROBE_CONSUMER, to request the
      driver core to probe for a consumer driver automatically after binding
      a driver to the supplier device on a persistent managed device link.
      
      As unbinding the supplier driver on a managed device link causes the
      consumer driver to be detached from its device automatically, this
      flag provides a complementary mechanism which is needed to address
      some "composite device" use cases.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e7dd4010
    • R
      driver core: Fix handling of runtime PM flags in device_link_add() · e2f3cd83
      Rafael J. Wysocki 提交于
      After commit ead18c23 ("driver core: Introduce device links
      reference counting"), if there is a link between the given supplier
      and the given consumer already, device_link_add() will refcount it
      and return it unconditionally without updating its flags.  It is
      possible, however, that the second (or any subsequent) caller of
      device_link_add() for the same consumer-supplier pair will pass
      DL_FLAG_PM_RUNTIME, possibly along with DL_FLAG_RPM_ACTIVE, in flags
      to it and the existing link may not behave as expected then.
      
      First, if DL_FLAG_PM_RUNTIME is not set in the existing link's flags
      at all, it needs to be set like during the original initialization of
      the link.
      
      Second, if DL_FLAG_RPM_ACTIVE is passed to device_link_add() in flags
      (in addition to DL_FLAG_PM_RUNTIME), the existing link should to be
      updated to reflect the "active" runtime PM configuration of the
      consumer-supplier pair and extra care must be taken here to avoid
      possible destructive races with runtime PM of the consumer.
      
      To that end, redefine the rpm_active field in struct device_link
      as a refcount, initialize it to 1 and make rpm_resume() (for the
      consumer) and device_link_add() increment it whenever they acquire
      a runtime PM reference on the supplier device.  Accordingly, make
      rpm_suspend() (for the consumer) and pm_runtime_clean_up_links()
      decrement it and drop runtime PM references to the supplier
      device in a loop until rpm_active becones 1 again.
      
      Fixes: ead18c23 ("driver core: Introduce device links reference counting")
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2f3cd83
  15. 18 1月, 2019 1 次提交
  16. 17 12月, 2018 1 次提交
  17. 16 10月, 2018 3 次提交
  18. 20 9月, 2018 2 次提交
  19. 28 7月, 2018 1 次提交
    • R
      dma-mapping: Generalise dma_32bit_limit flag · f07d141f
      Robin Murphy 提交于
      Whilst the notion of an upstream DMA restriction is most commonly seen
      in PCI host bridges saddled with a 32-bit native interface, a more
      general version of the same issue can exist on complex SoCs where a bus
      or point-to-point interconnect link from a device's DMA master interface
      to another component along the path to memory (often an IOMMU) may carry
      fewer address bits than the interfaces at both ends nominally support.
      In order to properly deal with this, the first step is to expand the
      dma_32bit_limit flag into an arbitrary mask.
      
      To minimise the impact on existing code, we'll make sure to only
      consider this new mask valid if set. That makes sense anyway, since a
      mask of zero would represent DMA not being wired up at all, and that
      would be better handled by not providing valid ops in the first place.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      f07d141f
  20. 23 7月, 2018 1 次提交
  21. 21 7月, 2018 1 次提交
  22. 10 7月, 2018 1 次提交
    • R
      driver core: allow stopping deferred probe after init · 25b4e70d
      Rob Herring 提交于
      Deferred probe will currently wait forever on dependent devices to probe,
      but sometimes a driver will never exist. It's also not always critical for
      a driver to exist. Platforms can rely on default configuration from the
      bootloader or reset defaults for things such as pinctrl and power domains.
      This is often the case with initial platform support until various drivers
      get enabled. There's at least 2 scenarios where deferred probe can render
      a platform broken. Both involve using a DT which has more devices and
      dependencies than the kernel supports. The 1st case is a driver may be
      disabled in the kernel config. The 2nd case is the kernel version may
      simply not have the dependent driver. This can happen if using a newer DT
      (provided by firmware perhaps) with a stable kernel version. Deferred
      probe issues can be difficult to debug especially if the console has
      dependencies or userspace fails to boot to a shell.
      
      There are also cases like IOMMUs where only built-in drivers are
      supported, so deferring probe after initcalls is not needed. The IOMMU
      subsystem implemented its own mechanism to handle this using OF_DECLARE
      linker sections.
      
      This commit adds makes ending deferred probe conditional on initcalls
      being completed or a debug timeout. Subsystems or drivers may opt-in by
      calling driver_deferred_probe_check_init_done() instead of
      unconditionally returning -EPROBE_DEFER. They may use additional
      information from DT or kernel's config to decide whether to continue to
      defer probe or not.
      
      The timeout mechanism is intended for debug purposes and WARNs loudly.
      The remaining deferred probe pending list will also be dumped after the
      timeout. Not that this timeout won't work for the console which needs
      to be enabled before userspace starts. However, if the console's
      dependencies are resolved, then the kernel log will be printed (as
      opposed to no output).
      
      Cc: Alexander Graf <agraf@suse.de>
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25b4e70d
  23. 09 7月, 2018 2 次提交
  24. 07 7月, 2018 1 次提交
  25. 06 7月, 2018 2 次提交
  26. 06 6月, 2018 1 次提交
  27. 31 5月, 2018 1 次提交
    • M
      driver core: hold dev's parent lock when needed · 8c97a46a
      Martin Liu 提交于
      SoC have internal I/O buses that can't be proved for devices. The
      devices on the buses can be accessed directly without additinal
      configuration required. This type of bus is represented as
      "simple-bus". In some platforms, we name "soc" with "simple-bus"
      attribute and many devices are hooked under it described in DT
      (device tree).
      
      In commit bf74ad5b ("Hold the device's parent's lock during
      probe and remove") to solve USB subsystem lock sequence since
      USB device's characteristic. Thus "soc" needs to be locked
      whenever a device and driver's probing happen under "soc" bus.
      During this period, an async driver tries to probe a device which
      is under the "soc" bus would be blocked until previous driver
      finish the probing and release "soc" lock. And the next probing
      under the "soc" bus need to wait for async finish. Because of
      that, driver's async probe for init time improvement will be
      shadowed.
      
      Since many devices don't have USB devices' characteristic, they
      actually don't need parent's lock. Thus, we introduce a lock flag
      in bus_type struct and driver core would lock the parent lock base
      on the flag. For USB, we set this flag in usb_bus_type to keep
      original lock behavior in driver core.
      
      Async probe could have more benefit after this patch.
      Signed-off-by: NMartin Liu <liumartin@google.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c97a46a
  28. 28 5月, 2018 1 次提交
  29. 03 5月, 2018 2 次提交
  30. 19 4月, 2018 1 次提交
  31. 22 3月, 2018 1 次提交