1. 28 7月, 2020 1 次提交
  2. 18 6月, 2020 1 次提交
    • S
      of: property: Improve cycle detection when one of the devices is never added · bb278b14
      Saravana Kannan 提交于
      Consider this example where -> means LHS device is a consumer of RHS
      device and indentation represents "child of" of the previous device.
      
      Device A -> Device C
      
      Device B -> Device A
      	Device C
      
      Without this commit:
      1. Device A is added.
      2. Device A is added to waiting for supplier list (Device C)
      3. Device B is added
      4. Device B is linked as a consumer to Device A
      5. Device A doesn't probe because it's waiting for Device C to be added.
      6. Device B doesn't probe because Device A hasn't probed.
      7. Device C will never be added because it's parent hasn't probed.
      
      So, Device A, B and C will be in a probe/add deadlock.
      
      This commit detects this scenario and stops trying to create a device
      link between Device A and Device C since doing so would create the
      following cycle:
      Device A -> Devic C -(parent)-> Device B -> Device A.
      
      With this commit:
      1. Device A is added.
      3. Device B is added
      4. Device B is linked as a consumer to Device A
      5. Device A probes.
      6. Device B probes because Device A has probed.
      7. Device C is added and probed.
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20200610011934.49795-3-saravanak@google.comSigned-off-by: NRob Herring <robh@kernel.org>
      bb278b14
  3. 29 4月, 2020 3 次提交
  4. 15 4月, 2020 1 次提交
  5. 05 3月, 2020 2 次提交
  6. 26 2月, 2020 1 次提交
  7. 22 11月, 2019 1 次提交
  8. 21 11月, 2019 2 次提交
  9. 15 11月, 2019 1 次提交
  10. 07 11月, 2019 3 次提交
  11. 03 11月, 2019 2 次提交
  12. 17 10月, 2019 1 次提交
  13. 11 10月, 2019 2 次提交
  14. 04 10月, 2019 2 次提交
    • S
      of: property: Create device links for all child-supplier depencencies · d4387cd1
      Saravana Kannan 提交于
      A parent device can have child devices that it adds when it probes. But
      this probing of the parent device can happen way after kernel init is done
      -- for example, when the parent device's driver is loaded as a module.
      
      In such cases, if the child devices depend on a supplier in the system, we
      need to make sure the supplier gets the sync_state() callback only after
      these child devices are added and probed.
      
      To achieve this, when creating device links for a device by looking at its
      DT node, don't just look at DT references at the top node level. Look at DT
      references in all the descendant nodes too and create device links from the
      ancestor device to all these supplier devices.
      
      This way, when the parent device probes and adds child devices, the child
      devices can then create their own device links to the suppliers and further
      delay the supplier's sync_state() callback to after the child devices are
      probed.
      
      Example:
      In this illustration, -> denotes DT references and indentation
      represents child status.
      
      Device node A
      	Device node B -> D
      	Device node C -> B, D
      
      Device node D
      
      Assume all these devices have their drivers loaded as modules.
      
      Without this patch, this is the sequence of events:
      1. D is added.
      2. A is added.
      3. Device D probes.
      4. Device D gets its sync_state() callback.
      5. Device B and C might malfunction because their resources got
         altered/turned off before they can make active requests for them.
      
      With this patch, this is the sequence of events:
      1. D is added.
      2. A is added and creates device links to D.
      3. Device link from A to B is not added because A is a parent of B.
      4. Device D probes.
      5. Device D does not get it's sync_state() callback because consumer A
         hasn't probed yet.
      5. Device A probes.
      5. a. Devices B and C are added.
      5. b. Device links from B and C to D are added.
      5. c. Device A's probe completes.
      6. Device D does not get it's sync_state() callback because consumer A
         has probed but consumers B and C haven't probed yet.
      7. Device B and C probe.
      8. Device D gets it's sync_state() callback because all its consumers
         have probed.
      9. None of the devices malfunction.
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190904211126.47518-7-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d4387cd1
    • S
      of: property: Add functional dependency link from DT bindings · a3e1d1a7
      Saravana Kannan 提交于
      Add device links after the devices are created (but before they are
      probed) by looking at common DT bindings like clocks and
      interconnects.
      
      Automatically adding device links for functional dependencies at the
      framework level provides the following benefits:
      
      - Optimizes device probe order and avoids the useless work of
        attempting probes of devices that will not probe successfully
        (because their suppliers aren't present or haven't probed yet).
      
        For example, in a commonly available mobile SoC, registering just
        one consumer device's driver at an initcall level earlier than the
        supplier device's driver causes 11 failed probe attempts before the
        consumer device probes successfully. This was with a kernel with all
        the drivers statically compiled in. This problem gets a lot worse if
        all the drivers are loaded as modules without direct symbol
        dependencies.
      
      - Supplier devices like clock providers, interconnect providers, etc
        need to keep the resources they provide active and at a particular
        state(s) during boot up even if their current set of consumers don't
        request the resource to be active. This is because the rest of the
        consumers might not have probed yet and turning off the resource
        before all the consumers have probed could lead to a hang or
        undesired user experience.
      
        Some frameworks (Eg: regulator) handle this today by turning off
        "unused" resources at late_initcall_sync and hoping all the devices
        have probed by then. This is not a valid assumption for systems with
        loadable modules. Other frameworks (Eg: clock) just don't handle
        this due to the lack of a clear signal for when they can turn off
        resources. This leads to downstream hacks to handle cases like this
        that can easily be solved in the upstream kernel.
      
        By linking devices before they are probed, we give suppliers a clear
        count of the number of dependent consumers. Once all of the
        consumers are active, the suppliers can turn off the unused
        resources without making assumptions about the number of consumers.
      
      By default we just add device-links to track "driver presence" (probe
      succeeded) of the supplier device. If any other functionality provided
      by device-links are needed, it is left to the consumer/supplier
      devices to change the link when they probe.
      
      kbuild test robot reported clang error about missing const
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190904211126.47518-4-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a3e1d1a7
  15. 10 4月, 2019 1 次提交
  16. 17 1月, 2019 1 次提交
  17. 06 12月, 2018 1 次提交
  18. 12 2月, 2018 1 次提交
  19. 08 1月, 2018 1 次提交
  20. 13 12月, 2017 1 次提交
  21. 09 11月, 2017 1 次提交
  22. 13 10月, 2017 1 次提交
  23. 15 8月, 2017 1 次提交
  24. 01 8月, 2017 1 次提交
    • T
      device property: Fix usecount for of_graph_get_port_parent() · c0a480d1
      Tony Lindgren 提交于
      Fix inconsistent use of of_graph_get_port_parent() where
      asoc_simple_card_parse_graph_dai() does of_node_get() before
      calling it while other callers do not. We can fix this by
      not trashing the node passed to of_graph_get_port_parent().
      
      Let's also make sure the callers have correct refcounts and remove
      related incorrect of_node_put() calls for of_for_each_phandle
      as that's done by of_phandle_iterator_next() except when
      we break out of the loop early.
      
      Let's fix both issues with a single patch to avoid kobject
      refcounts getting messed up more if two patches are merged
      separately.
      
      Otherwise strange issues can happen caused by memory corruption
      caused by too many kobject_del() calls such as:
      
      BUG: sleeping function called from invalid context at
      kernel/locking/mutex.c:747
      ...
      (___might_sleep)
      (__mutex_lock)
      (mutex_lock_nested)
      (kernfs_remove)
      (kobject_del)
      (kobject_put)
      (of_get_next_parent)
      (of_graph_get_port_parent)
      (asoc_simple_card_parse_graph_dai [snd_soc_simple_card_utils])
      (asoc_graph_card_probe [snd_soc_audio_graph_card])
      
      Fixes: 0ef472a9 ("of_graph: add of_graph_get_port_parent()")
      Fixes: 2692c1c6 ("ASoC: add audio-graph-card support")
      Fixes: 1689333f ("ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai()")
      Signed-off-by: NTony Lindgren <tony@atomide.com>
      Reviewed-by: NRob Herring <robh@kernel.org>
      Tested-by: NAntonio Borneo <borneo.antonio@gmail.com>
      Tested-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      c0a480d1
  25. 22 7月, 2017 3 次提交
  26. 19 7月, 2017 1 次提交
  27. 22 6月, 2017 3 次提交