1. 21 5月, 2020 1 次提交
  2. 15 5月, 2020 3 次提交
  3. 05 5月, 2020 1 次提交
  4. 28 4月, 2020 1 次提交
  5. 27 3月, 2020 1 次提交
    • G
      Revert "driver core: Set fw_devlink to "permissive" behavior by default" · 18555cb6
      Greg Kroah-Hartman 提交于
      This reverts commit c442a0d1 as it
      breaks some of the Raspberry Pi devices.  Marek writes:
      	This patch has just landed in linux-next 20200326. Sadly it
      	breaks booting of the Raspberry Pi3b and Pi4 boards, either in
      	32bit or 64bit mode. There is no warning nor panic message, just
      	a silent freeze. The last message shown on the earlycon is:
      
      	[    0.893217] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
      
      so revert it for now and let's try again and add it to linux-next after
      5.7-rc1 is out so that we can try to get more debugging/testing
      happening.
      Reported-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: Saravana Kannan <saravanak@google.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      18555cb6
  6. 24 3月, 2020 1 次提交
  7. 21 3月, 2020 1 次提交
    • S
      driver core: Add device links from fwnode only for the primary device · 4dbe191c
      Saravana Kannan 提交于
      Sometimes, more than one (generally two) device can point to the same
      fwnode.  However, only one device is set as the fwnode's device
      (fwnode->dev) and can be looked up from the fwnode.
      
      Typically, only one of these devices actually have a driver and actually
      probe. If we create device links for all these devices, then the
      suppliers' of these devices (with the same fwnode) will never get a
      sync_state() call because one of their consumer devices will never probe
      (because they don't have a driver).
      
      So, create device links only for the device that is considered as the
      fwnode's device.
      
      One such example of this is the PCI bridge platform_device and the
      corresponding pci_bus device. Both these devices will have the same
      fwnode. It's the platform_device that is registered first and is set as
      the fwnode's device. Also the platform_device is the one that actually
      probes. Without this patch none of the suppliers of a PCI bridge
      platform_device would get a sync_state() callback.
      
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: linux-pci@vger.kernel.org
      Reviewed-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20200321045448.15192-1-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4dbe191c
  8. 05 3月, 2020 5 次提交
  9. 04 3月, 2020 2 次提交
  10. 27 2月, 2020 2 次提交
  11. 15 11月, 2019 1 次提交
  12. 03 11月, 2019 3 次提交
  13. 10 10月, 2019 1 次提交
    • R
      cpufreq: Avoid cpufreq_suspend() deadlock on system shutdown · 65650b35
      Rafael J. Wysocki 提交于
      It is incorrect to set the cpufreq syscore shutdown callback pointer
      to cpufreq_suspend(), because that function cannot be run in the
      syscore stage of system shutdown for two reasons: (a) it may attempt
      to carry out actions depending on devices that have already been shut
      down at that point and (b) the RCU synchronization carried out by it
      may not be able to make progress then.
      
      The latter issue has been present since commit 45975c7d ("rcu:
      Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds"),
      but the former one has been there since commit 90de2a4a ("cpufreq:
      suspend cpufreq governors on shutdown") regardless.
      
      Fix that by dropping cpufreq_syscore_ops altogether and making
      device_shutdown() call cpufreq_suspend() directly before shutting
      down devices, which is along the lines of what system-wide power
      management does.
      
      Fixes: 45975c7d ("rcu: Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds")
      Fixes: 90de2a4a ("cpufreq: suspend cpufreq governors on shutdown")
      Reported-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Tested-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: 4.0+ <stable@vger.kernel.org> # 4.0+
      65650b35
  14. 04 10月, 2019 3 次提交
    • S
      driver core: Add sync_state driver/bus callback · fc5a251d
      Saravana Kannan 提交于
      This sync_state driver/bus callback is called once all the consumers
      of a supplier have probed successfully.
      
      This allows the supplier device's driver/bus to sync the supplier
      device's state to the software state with the guarantee that all the
      consumers are actively managing the resources provided by the supplier
      device.
      
      To maintain backwards compatibility and ease transition from existing
      frameworks and resource cleanup schemes, late_initcall_sync is the
      earliest when the sync_state callback might be called.
      
      There is no upper bound on the time by which the sync_state callback
      has to be called. This is because if a consumer device never probes,
      the supplier has to maintain its resources in the state left by the
      bootloader. For example, if the bootloader leaves the display
      backlight at a fixed voltage and the backlight driver is never probed,
      you don't want the backlight to ever be turned off after boot up.
      
      Also, when multiple devices are added after kernel init, some
      suppliers could be added before their consumer devices get added. In
      these instances, the supplier devices could get their sync_state
      callback called right after they probe because the consumers devices
      haven't had a chance to create device links to the suppliers.
      
      To handle this correctly, this change also provides APIs to
      pause/resume sync state callbacks so that when multiple devices are
      added, their sync_state callback evaluation can be postponed to happen
      after all of them are added.
      
      kbuild test robot reported missing documentation for device.state_synced
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190904211126.47518-5-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fc5a251d
    • S
      driver core: Add support for linking devices during device addition · e2ae9bcc
      Saravana Kannan 提交于
      The firmware corresponding to a device (dev.fwnode) might be able to
      provide functional dependency information between a device and its
      supplier and consumer devices.  Tracking this functional dependency
      allows optimizing device probe order and informing a supplier when all
      its consumers have probed (and thereby actively managing their
      resources).
      
      The existing device links feature allows tracking and using
      supplier-consumer relationships. So, this patch adds the add_links()
      fwnode callback to allow firmware to create device links for each
      device as the device is added.
      
      However, when consumer devices are added, they might not have a supplier
      device to link to despite needing mandatory resources/functionality from
      one or more suppliers. A waiting_for_suppliers list is created to track
      such consumers and retry linking them when new devices get added.
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190904211126.47518-3-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2ae9bcc
    • S
      driver core: Add fwnode_to_dev() to look up device from fwnode · 372a67c0
      Saravana Kannan 提交于
      It's often useful to look up a device that corresponds to a fwnode. So
      add an API to do that irrespective of the bus on which the device has
      been added to.
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190904211126.47518-2-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      372a67c0
  15. 28 8月, 2019 3 次提交
  16. 14 8月, 2019 1 次提交
  17. 01 8月, 2019 3 次提交
    • S
      driver core: Add sync_state driver/bus callback · 8f8184d6
      Saravana Kannan 提交于
      This sync_state driver/bus callback is called once all the consumers
      of a supplier have probed successfully.
      
      This allows the supplier device's driver/bus to sync the supplier
      device's state to the software state with the guarantee that all the
      consumers are actively managing the resources provided by the supplier
      device.
      
      To maintain backwards compatibility and ease transition from existing
      frameworks and resource cleanup schemes, late_initcall_sync is the
      earliest when the sync_state callback might be called.
      
      There is no upper bound on the time by which the sync_state callback
      has to be called. This is because if a consumer device never probes,
      the supplier has to maintain its resources in the state left by the
      bootloader. For example, if the bootloader leaves the display
      backlight at a fixed voltage and the backlight driver is never probed,
      you don't want the backlight to ever be turned off after boot up.
      
      Also, when multiple devices are added after kernel init, some
      suppliers could be added before their consumer devices get added. In
      these instances, the supplier devices could get their sync_state
      callback called right after they probe because the consumers devices
      haven't had a chance to create device links to the suppliers.
      
      To handle this correctly, this change also provides APIs to
      pause/resume sync state callbacks so that when multiple devices are
      added, their sync_state callback evaluation can be postponed to happen
      after all of them are added.
      
      kbuild test robot reported missing documentation for device.state_synced
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190731221721.187713-5-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8f8184d6
    • S
      driver core: Add edit_links() callback for drivers · 134b23ee
      Saravana Kannan 提交于
      The driver core/bus adding supplier-consumer dependencies by default
      enables functional dependencies to be tracked correctly even when the
      consumer devices haven't had their drivers registered or loaded (if they
      are modules).
      
      However, when the bus incorrectly adds dependencies that it shouldn't
      have added, the devices might never probe.
      
      For example, if device-C is a consumer of device-S and they have
      phandles to each other in DT, the following could happen:
      
      1.  Device-S get added first.
      2.  The bus add_links() callback will (incorrectly) try to link it as
          a consumer of device-C.
      3.  Since device-C isn't present, device-S will be put in
          "waiting-for-supplier" list.
      4.  Device-C gets added next.
      5.  All devices in "waiting-for-supplier" list are retried for linking.
      6.  Device-S gets linked as consumer to Device-C.
      7.  The bus add_links() callback will (correctly) try to link it as
          a consumer of device-S.
      8.  This isn't allowed because it would create a cyclic device links.
      
      Neither devices will get probed since the supplier is marked as
      dependent on the consumer. And the consumer will never probe because the
      consumer can't get resources from the supplier.
      
      Without this patch, things stay in this broken state. However, with this
      patch, the execution will continue like this:
      
      9.  Device-C's driver is loaded.
      10. Device-C's driver removes Device-S as a consumer of Device-C.
      11. Device-C's driver adds Device-C as a consumer of Device-S.
      12. Device-S probes.
      14. Device-C probes.
      
      kbuild test robot reported missing documentation for device.has_edit_links
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190731221721.187713-3-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      134b23ee
    • S
      driver core: Add support for linking devices during device addition · 5302dd7d
      Saravana Kannan 提交于
      When devices are added, the bus might want to create device links to track
      functional dependencies between supplier and consumer devices. This
      tracking of supplier-consumer relationship allows optimizing device probe
      order and tracking whether all consumers of a supplier are active. The
      add_links bus callback is added to support this.
      
      However, when consumer devices are added, they might not have a supplier
      device to link to despite needing mandatory resources/functionality from
      one or more suppliers. A waiting_for_suppliers list is created to track
      such consumers and retry linking them when new devices get added.
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190731221721.187713-2-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5302dd7d
  18. 31 7月, 2019 1 次提交
    • M
      driver core: Fix use-after-free and double free on glue directory · ac43432c
      Muchun Song 提交于
      There is a race condition between removing glue directory and adding a new
      device under the glue dir. It can be reproduced in following test:
      
      CPU1:                                         CPU2:
      
      device_add()
        get_device_parent()
          class_dir_create_and_add()
            kobject_add_internal()
              create_dir()    // create glue_dir
      
                                                    device_add()
                                                      get_device_parent()
                                                        kobject_get() // get glue_dir
      
      device_del()
        cleanup_glue_dir()
          kobject_del(glue_dir)
      
                                                      kobject_add()
                                                        kobject_add_internal()
                                                          create_dir() // in glue_dir
                                                            sysfs_create_dir_ns()
                                                              kernfs_create_dir_ns(sd)
      
            sysfs_remove_dir() // glue_dir->sd=NULL
            sysfs_put()        // free glue_dir->sd
      
                                                                // sd is freed
                                                                kernfs_new_node(sd)
                                                                  kernfs_get(glue_dir)
                                                                  kernfs_add_one()
                                                                  kernfs_put()
      
      Before CPU1 remove last child device under glue dir, if CPU2 add a new
      device under glue dir, the glue_dir kobject reference count will be
      increase to 2 via kobject_get() in get_device_parent(). And CPU2 has
      been called kernfs_create_dir_ns(), but not call kernfs_new_node().
      Meanwhile, CPU1 call sysfs_remove_dir() and sysfs_put(). This result in
      glue_dir->sd is freed and it's reference count will be 0. Then CPU2 call
      kernfs_get(glue_dir) will trigger a warning in kernfs_get() and increase
      it's reference count to 1. Because glue_dir->sd is freed by CPU1, the next
      call kernfs_add_one() by CPU2 will fail(This is also use-after-free)
      and call kernfs_put() to decrease reference count. Because the reference
      count is decremented to 0, it will also call kmem_cache_free() to free
      the glue_dir->sd again. This will result in double free.
      
      In order to avoid this happening, we also should make sure that kernfs_node
      for glue_dir is released in CPU1 only when refcount for glue_dir kobj is
      1 to fix this race.
      
      The following calltrace is captured in kernel 4.14 with the following patch
      applied:
      
      commit 726e4109 ("drivers: core: Remove glue dirs from sysfs earlier")
      
      --------------------------------------------------------------------------
      [    3.633703] WARNING: CPU: 4 PID: 513 at .../fs/kernfs/dir.c:494
                      Here is WARN_ON(!atomic_read(&kn->count) in kernfs_get().
      ....
      [    3.633986] Call trace:
      [    3.633991]  kernfs_create_dir_ns+0xa8/0xb0
      [    3.633994]  sysfs_create_dir_ns+0x54/0xe8
      [    3.634001]  kobject_add_internal+0x22c/0x3f0
      [    3.634005]  kobject_add+0xe4/0x118
      [    3.634011]  device_add+0x200/0x870
      [    3.634017]  _request_firmware+0x958/0xc38
      [    3.634020]  request_firmware_into_buf+0x4c/0x70
      ....
      [    3.634064] kernel BUG at .../mm/slub.c:294!
                      Here is BUG_ON(object == fp) in set_freepointer().
      ....
      [    3.634346] Call trace:
      [    3.634351]  kmem_cache_free+0x504/0x6b8
      [    3.634355]  kernfs_put+0x14c/0x1d8
      [    3.634359]  kernfs_create_dir_ns+0x88/0xb0
      [    3.634362]  sysfs_create_dir_ns+0x54/0xe8
      [    3.634366]  kobject_add_internal+0x22c/0x3f0
      [    3.634370]  kobject_add+0xe4/0x118
      [    3.634374]  device_add+0x200/0x870
      [    3.634378]  _request_firmware+0x958/0xc38
      [    3.634381]  request_firmware_into_buf+0x4c/0x70
      --------------------------------------------------------------------------
      
      Fixes: 726e4109 ("drivers: core: Remove glue dirs from sysfs earlier")
      Signed-off-by: NMuchun Song <smuchun@gmail.com>
      Reviewed-by: NMukesh Ojha <mojha@codeaurora.org>
      Signed-off-by: NPrateek Sood <prsood@codeaurora.org>
      Link: https://lore.kernel.org/r/20190727032122.24639-1-smuchun@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac43432c
  19. 30 7月, 2019 6 次提交