1. 05 1月, 2020 1 次提交
  2. 24 12月, 2019 3 次提交
  3. 20 11月, 2019 2 次提交
  4. 11 11月, 2019 1 次提交
  5. 20 9月, 2019 1 次提交
  6. 18 9月, 2019 1 次提交
    • S
      clk: Evict unregistered clks from parent caches · bdcf1dc2
      Stephen Boyd 提交于
      We leave a dangling pointer in each clk_core::parents array that has an
      unregistered clk as a potential parent when that clk_core pointer is
      freed by clk{_hw}_unregister(). It is impossible for the true parent of
      a clk to be set with clk_set_parent() once the dangling pointer is left
      in the cache because we compare parent pointers in
      clk_fetch_parent_index() instead of checking for a matching clk name or
      clk_hw pointer.
      
      Before commit ede77858 ("clk: Remove global clk traversal on fetch
      parent index"), we would check clk_hw pointers, which has a higher
      chance of being the same between registration and unregistration, but it
      can still be allocated and freed by the clk provider. In fact, this has
      been a long standing problem since commit da0f0b2c ("clk: Correct
      lookup logic in clk_fetch_parent_index()") where we stopped trying to
      compare clk names and skipped over entries in the cache that weren't
      NULL.
      
      There are good (performance) reasons to not do the global tree lookup in
      cases where the cache holds dangling pointers to parents that have been
      unregistered. Let's take the performance hit on the uncommon
      registration path instead. Loop through all the clk_core::parents arrays
      when a clk is unregistered and set the entry to NULL when the parent
      cache entry and clk being unregistered are the same pointer. This will
      fix this problem and avoid the overhead for the "normal" case.
      
      Based on a patch by Bjorn Andersson.
      
      Fixes: da0f0b2c ("clk: Correct lookup logic in clk_fetch_parent_index()")
      Reviewed-by: NBjorn Andersson <bjorn.andersson@linaro.org>
      Tested-by: NSai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      Link: https://lkml.kernel.org/r/20190828181959.204401-1-sboyd@kernel.org
      bdcf1dc2
  7. 06 9月, 2019 1 次提交
  8. 18 8月, 2019 1 次提交
  9. 17 8月, 2019 3 次提交
    • M
      clk: Fix potential NULL dereference in clk_fetch_parent_index() · 24876f09
      Martin Blumenstingl 提交于
      Don't compare the parent clock name with a NULL name in the
      clk_parent_map. This prevents a kernel crash when passing NULL
      core->parents[i].name to strcmp().
      
      An example which triggered this is a mux clock with four parents when
      each of them is referenced in the clock driver using
      clk_parent_data.fw_name and then calling clk_set_parent(clk, 3rd_parent)
      on this mux.
      In this case the first parent is also the HW default so
      core->parents[i].hw is populated when the clock is registered. Calling
      clk_set_parent(clk, 3rd_parent) will then go through all parents and
      skip the first parent because it's hw pointer doesn't match. For the
      second parent no hw pointer is cached yet and clk_core_get(core, 1)
      returns a non-matching pointer (which is correct because we are comparing
      the second with the third parent). Comparing the result of
      clk_core_get(core, 2) with the requested parent gives a match. However
      we don't reach this point because right after the clk_core_get(core, 1)
      mismatch the old code tried to !strcmp(parent->name, NULL) (where the
      second argument is actually core->parents[i].name, but that was never
      populated by the clock driver).
      Signed-off-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Link: https://lkml.kernel.org/r/20190815223155.21384-1-martin.blumenstingl@googlemail.com
      Fixes: fc0c209c ("clk: Allow parents to be specified without string names")
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      24876f09
    • S
      clk: Fix falling back to legacy parent string matching · 4f8c6aba
      Stephen Boyd 提交于
      Calls to clk_core_get() will return ERR_PTR(-EINVAL) if we've started
      migrating a clk driver to use the DT based style of specifying parents
      but we haven't made any DT updates yet. This happens when we pass a
      non-NULL value as the 'name' argument of of_parse_clkspec(). That
      function returns -EINVAL in such a situation, instead of -ENOENT like we
      expected. The return value comes back up to clk_core_fill_parent_index()
      which proceeds to skip calling clk_core_lookup() because the error
      pointer isn't equal to -ENOENT, it's -EINVAL.
      
      Furthermore, we blindly overwrite the error pointer returned by
      clk_core_get() with NULL when there isn't a legacy .name member
      specified in the parent map. This isn't too bad right now because we
      don't really care to differentiate NULL from an error, but in the future
      we should only try to do a legacy lookup if we know we might find
      something. This way DT lookups that fail don't try to lookup based on
      strings when there isn't any string to match, hiding the error from DT
      parsing.
      
      Fix both these problems so that clk provider drivers can use the new
      style of parent mapping without having to also update their DT at the
      same time. This patch is based on an earlier patch from Taniya Das which
      checked for -EINVAL in addition to -ENOENT return values from
      clk_core_get().
      
      Fixes: 601b6e93 ("clk: Allow parents to be specified via clkspec index")
      Cc: Taniya Das <tdas@codeaurora.org>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Reported-by: NTaniya Das <tdas@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      Link: https://lkml.kernel.org/r/20190813214147.34394-1-sboyd@kernel.orgTested-by: NTaniya Das <tdas@codeaurora.org>
      4f8c6aba
    • S
      clk: Overwrite clk_hw::init with NULL during clk_register() · 0214f33c
      Stephen Boyd 提交于
      We don't want clk provider drivers to use the init structure after clk
      registration time, but we leave a dangling reference to it by means of
      clk_hw::init. Let's overwrite the member with NULL during clk_register()
      so that this can't be used anymore after registration time.
      
      Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
      Cc: Doug Anderson <dianders@chromium.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      Link: https://lkml.kernel.org/r/20190731193517.237136-10-sboyd@kernel.orgReviewed-by: NSylwester Nawrocki <s.nawrocki@samsung.com>
      0214f33c
  10. 09 8月, 2019 1 次提交
  11. 08 8月, 2019 3 次提交
  12. 26 6月, 2019 4 次提交
  13. 18 6月, 2019 1 次提交
    • C
      clk: Fix debugfs clk_possible_parents for clks without parent string names · 2d156b78
      Chen-Yu Tsai 提交于
      Following the commit fc0c209c ("clk: Allow parents to be specified
      without string names"), the parent name string is not always populated.
      
      Instead, fetch the parents clk_core struct using the appropriate helper,
      and read its name directly. If that fails, go through the possible
      sources of parent names. The order in which they are used is different
      from how parents are looked up, with the global name having precedence
      over local fw_name and indices. This makes more sense as a) the
      parent_maps structure does not differentiate between legacy global names
      and fallback global names, and b) global names likely provide more
      information than local fw_names.
      
      Fixes: fc0c209c ("clk: Allow parents to be specified without string names")
      Signed-off-by: NChen-Yu Tsai <wens@csie.org>
      2d156b78
  14. 17 6月, 2019 1 次提交
  15. 24 5月, 2019 1 次提交
    • S
      clk: Unexport __clk_of_table · 30d5a945
      Stephen Boyd 提交于
      This symbol doesn't need to be exported to clk providers anymore.
      Originally, it was hidden inside clk.c, but then OMAP needed to get
      access to it in commit 819b4861 ("CLK: ti: add init support for
      clock IP blocks"), but eventually that code also changed in commit
      c08ee14c ("clk: ti: change clock init to use generic of_clk_init")
      and we were left with this exported. Move this back into clk.c so that
      it isn't exposed anymore.
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      30d5a945
  16. 04 5月, 2019 1 次提交
    • S
      clk: Cache core in clk_fetch_parent_index() without names · 1a079560
      Stephen Boyd 提交于
      If a clk has specified parents via clk_hw pointers it won't specify the
      globally unique names for the parents. Without the unique names, we
      can't fallback to comparing them against the name of the 'parent'
      pointer here. Therefore, do a pointer comparison against the clk_hw
      pointers too and cache the clk_core structure if they match. This fixes
      parent lookup code for clks that only specify clk_hw pointers and
      nothing else, like muxes that are purely inside a clk controller.
      
      Similarly, if the parent pointer isn't cached after trying to match
      clk_core or clk_hw pointers, lookup the pointer from DT or via clkdev
      lookups instead of relying purely on the globally unique clk name match.
      This should allow us to move away from having to specify global names
      for clk parents entirely.
      
      While we're in the area, add some comments so it's clearer what's going
      on. The if statements don't lend themselves to much clarity in their raw
      form.
      
      Fixes: fc0c209c ("clk: Allow parents to be specified without string names")
      Reported-by: NCharles Keepax <ckeepax@opensource.cirrus.com>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      1a079560
  17. 27 4月, 2019 1 次提交
    • S
      clk: Remove CLK_IS_BASIC clk flag · 90b6c5c7
      Stephen Boyd 提交于
      This flag was historically used to indicate that a clk is a "basic" type
      of clk like a mux, divider, gate, etc. This never turned out to be very
      useful though because it was hard to cleanly split "basic" clks from
      other clks in a system. This one flag was a way for type introspection
      and it just didn't scale. If anything, it was used by the TI clk driver
      to indicate that a clk_hw wasn't contained in the SoC specific clk
      structure. We can get rid of this define now that TI is finding those
      clks a different way.
      
      Cc: Tero Kristo <t-kristo@ti.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: <linux-mips@vger.kernel.org>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Kevin Hilman <khilman@baylibre.com>
      Cc: <linux-pwm@vger.kernel.org>
      Cc: <linux-amlogic@lists.infradead.org>
      Acked-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      90b6c5c7
  18. 20 4月, 2019 5 次提交
    • S
      clk: Allow parents to be specified via clkspec index · 601b6e93
      Stephen Boyd 提交于
      Some clk providers are simple DT nodes that only have a 'clocks'
      property without having an associated 'clock-names' property. In these
      cases, we want to let these clk providers point to their parent clks
      without having to dereference the 'clocks' property at probe time to
      figure out the parent's globally unique clk name. Let's add an 'index'
      property to the parent_data structure so that clk providers can indicate
      that their parent is a particular index in the 'clocks' DT property.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Tested-by: NJeffrey Hugo <jhugo@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      601b6e93
    • S
      clk: Look for parents with clkdev based clk_lookups · dde4eff4
      Stephen Boyd 提交于
      In addition to looking for DT based parents, support clkdev based
      clk_lookups. This should allow non-DT based clk drivers to participate
      in the parent lookup process.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Tested-by: NJeffrey Hugo <jhugo@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      dde4eff4
    • S
      clk: Allow parents to be specified without string names · fc0c209c
      Stephen Boyd 提交于
      The common clk framework is lacking in ability to describe the clk
      topology without specifying strings for every possible parent-child
      link. There are a few drawbacks to the current approach:
      
       1) String comparisons are used for everything, including describing
       topologies that are 'local' to a single clock controller.
      
       2) clk providers (e.g. i2c clk drivers) need to create globally unique
       clk names to avoid collisions in the clk namespace, leading to awkward
       name generation code in various clk drivers.
      
       3) DT bindings may not fully describe the clk topology and linkages
       between clk controllers because drivers can easily rely on globally unique
       strings to describe connections between clks.
      
      This leads to confusing DT bindings, complicated clk name generation
      code, and inefficient string comparisons during clk registration just so
      that the clk framework can detect the topology of the clk tree.
      Furthermore, some drivers call clk_get() and then __clk_get_name() to
      extract the globally unique clk name just so they can specify the parent
      of the clk they're registering. We have of_clk_parent_fill() but that
      mostly only works for single clks registered from a DT node, which isn't
      the norm. Let's simplify this all by introducing two new ways of
      specifying clk parents.
      
      The first method is an array of pointers to clk_hw structures
      corresponding to the parents at that index. This works for clks that are
      registered when we have access to all the clk_hw pointers for the
      parents.
      
      The second method is a mix of clk_hw pointers and strings of local and
      global parent clk names. If the .fw_name member of the map is set we'll
      look for that clk by performing a DT based lookup of the device the clk
      is registered with and the .name specified in the map. If that fails,
      we'll fallback to the .name member and perform a global clk name lookup
      like we've always done before.
      
      Using either one of these new methods is entirely optional. Existing
      drivers will continue to work, and they can migrate to this new approach
      as they see fit. Eventually, we'll want to get rid of the 'parent_names'
      array in struct clk_init_data and use one of these new methods instead.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Cc: Rob Herring <robh@kernel.org>
      Tested-by: NJeffrey Hugo <jhugo@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      fc0c209c
    • S
      clk: Add of_clk_hw_register() API for early clk drivers · 89a5ddcc
      Stephen Boyd 提交于
      In some circumstances drivers register clks early and don't have access
      to a struct device because the device model isn't initialized yet. Add
      an API to let drivers register clks associated with a struct device_node
      so that these drivers can participate in getting parent clks through DT.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Cc: Rob Herring <robh@kernel.org>
      Tested-by: NJeffrey Hugo <jhugo@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      89a5ddcc
    • S
      clk: Prepare for clk registration API that uses DT nodes · fceaa7d8
      Stephen Boyd 提交于
      Split out the body of the clk_register() function so it can be shared
      between the different types of registration APIs (DT, device).
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Cc: Rob Herring <robh@kernel.org>
      Tested-by: NJeffrey Hugo <jhugo@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      fceaa7d8
  19. 09 3月, 2019 1 次提交
  20. 02 3月, 2019 5 次提交
    • S
      clk: Move of_clk_*() APIs into clk.c from clkdev.c · cf13f289
      Stephen Boyd 提交于
      The API between clk.c and clkdev.c is purely getting the clk_hw
      structure (or the struct clk if it's not CCF) and then turning that
      struct clk_hw pointer into a struct clk pointer via clk_hw_create_clk().
      There's no need to complicate clkdev.c with these DT parsing details
      that are only relevant to the common clk framework. Move the DT parsing
      logic into the core framework and just expose the APIs to get a clk_hw
      pointer and convert it.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      cf13f289
    • S
      clk: Inform the core about consumer devices · efa85048
      Stephen Boyd 提交于
      We'd like to have a pointer to the device that's consuming a particular
      clk in the clk framework so we can link the consumer to the clk provider
      with a PM device link. Add a device argument to clk_hw_create_clk() for
      this so it can be used in subsequent patches to add and remove the link.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      efa85048
    • S
      clk: Introduce of_clk_get_hw_from_clkspec() · 4472287a
      Stephen Boyd 提交于
      We want to get struct clk_hw pointers from a DT clk specifier (i.e. a
      clocks property) so that we can find parent clks without searching for
      globally unique clk names. This should save time by avoiding the global
      string search for clks that are external to the clock controller
      providing the clk and let us move away from string comparisons in
      general.
      
      Introduce of_clk_get_hw_from_clkspec() which is largely the DT parsing
      part of finding clks implemented in clkdev.c and have that return a
      clk_hw pointer instead of converting that into a clk pointer. This lets
      us push up the clk pointer creation to the caller in clk_get() and
      avoids the need to push the dev_id and con_id throughout the DT parsing
      code.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      4472287a
    • M
      clk: core: clarify the check for runtime PM · 24478839
      Miquel Raynal 提交于
      Currently, the core->dev entry is populated only if runtime PM is
      enabled. Doing so prevents accessing the device structure in any
      case.
      
      Keep the same logic but instead of using the presence of core->dev as
      the only condition, also check the status of
      pm_runtime_enabled(). Then, we can set the core->dev pointer at any
      time as long as a device structure is available.
      
      This change will help supporting device links in the clock subsystem.
      Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      [sboyd@kernel.org: Change to a boolean flag]
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      24478839
    • S
      clk: Combine __clk_get() and __clk_create_clk() · 1df4046a
      Stephen Boyd 提交于
      The __clk_get() function is practically a private clk implementation
      detail now. No architecture defines it, and given that new code should
      be using the common clk framework there isn't a need for it to keep
      existing just to serve clkdev purposes. Let's fold it into the
      __clk_create_clk() function and make that a little more generic by
      renaming it to clk_hw_create_clk(). This will allow the framework to
      create a struct clk handle to a particular clk_hw pointer and link it up
      as a consumer wherever that's needed.
      
      Doing this also lets us get rid of the __clk_free_clk() API that had to
      be kept in sync with __clk_put(). Splitting that API up into the "link
      and unlink from consumer list" phase and "free the clk pointer" phase
      allows us to reuse that logic in a couple places, simplifying the code.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      1df4046a
  21. 03 2月, 2019 1 次提交
  22. 02 2月, 2019 1 次提交