1. 03 2月, 2015 3 次提交
    • T
      clk: Add rate constraints to clocks · 1c8e6004
      Tomeu Vizoso 提交于
      Adds a way for clock consumers to set maximum and minimum rates. This
      can be used for thermal drivers to set minimum rates, or by misc.
      drivers to set maximum rates to assure a minimum performance level.
      
      Changes the signature of the determine_rate callback by adding the
      parameters min_rate and max_rate.
      Signed-off-by: NTomeu Vizoso <tomeu.vizoso@collabora.com>
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      [sboyd@codeaurora.org: set req_rate in __clk_init]
      Signed-off-by: NMichael Turquette <mturquette@linaro.org>
      [mturquette@linaro.org: min/max rate for sun6i_ahb1_clk_determine_rate
                              migrated clk-private.h changes to clk.c]
      1c8e6004
    • M
      clk: remove clk-private.h · b09d6d99
      Michael Turquette 提交于
      Private clock framework data structures should be private, surprisingly.
      
      Now that all platforms and drivers have been updated to remove static
      initializations of struct clk and struct clk_core objects and all
      references to clk-private.h have been removed we can move the
      definitions of these structures into drivers/clk/clk.c and delete the
      header.
      
      Additionally the ugly DEFINE_CLK macros have been removed. Those were
      used for static definitions of struct clk objects. That practice is no
      longer allowed.
      
      Finally __clk_init is staticized as it is no longer declared in any
      header.
      Reviewed-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMichael Turquette <mturquette@linaro.org>
      b09d6d99
    • T
      clk: Make clk API return per-user struct clk instances · 035a61c3
      Tomeu Vizoso 提交于
      Moves clock state to struct clk_core, but takes care to change as little API as
      possible.
      
      struct clk_hw still has a pointer to a struct clk, which is the
      implementation's per-user clk instance, for backwards compatibility.
      
      The struct clk that clk_get_parent() returns isn't owned by the caller, but by
      the clock implementation, so the former shouldn't call clk_put() on it.
      
      Because some boards in mach-omap2 still register clocks statically, their clock
      registration had to be updated to take into account that the clock information
      is stored in struct clk_core now.
      Signed-off-by: NTomeu Vizoso <tomeu.vizoso@collabora.com>
      Reviewed-by: NStephen Boyd <sboyd@codeaurora.org>
      Tested-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NMichael Turquette <mturquette@linaro.org>
      [mturquette@linaro.org: adapted clk_has_parent to struct clk_core
                              applied OMAP3+ DPLL fix from Tero & Tony]
      035a61c3
  2. 29 1月, 2015 2 次提交
  3. 28 1月, 2015 3 次提交
    • M
      clk: Export phase functions · 9767b04f
      Maxime Ripard 提交于
      The phase setter and getter were not exported until now, which was causing
      build breakages when callers were compiled as module. Export these two
      functions.
      Reported-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NMaxime Ripard <maxime.ripard@free-electrons.com>
      Reviewed-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMichael Turquette <mturquette@linaro.org>
      9767b04f
    • S
      clk: Add __clk_mux_determine_rate_closest · 15a02c1f
      Stephen Boyd 提交于
      Some clock drivers want to find the closest rate on the input of
      a mux instead of a rate that's less than or equal to the desired
      rate. Add a generic mux function to support this.
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Tested-by: NKenneth Westfield <kwestfie@codeaurora.org>
      Signed-off-by: NMichael Turquette <mturquette@linaro.org>
      15a02c1f
    • S
      clk: Fix debugfs clk removal before inited · 52bba980
      Srinivas Kandagatla 提交于
      Some of the clks can be registered & unregistered before the clk related debugfs
      entries are initialized at late_initcall. In the unregister path checking for only
      dentry before clk_debug_init() would lead dangling pointers in the debug clk list,
      because the list is already populated in register path and the clk pointer freed in
      unregister path.
      The side effect of not removing it from the list is either a null pointer
      dereference or if lucky to boot the system, the number of clk entries in
      debugfs disappear.
      
      We could add more checks like if (inited && !clk->dentry) but just removing
      the check for dentry made more sense as debugfs_remove_recursive() seems to be
      safe with null pointers. This will ensure that the unregistering clk would be
      removed from the debug list in all the code paths.
      
      Without this patch kernel would crash with log:
      Unable to handle kernel NULL pointer dereference at virtual address 00000000
      pgd = c0204000
      [00000000] *pgd=00000000
      Internal error: Oops: 5 [#1] SMP ARM
      Modules linked in:
      CPU: 1 PID: 1 Comm: swapper/0 Tainted: G    B          3.19.0-rc3-00007-g412f9ba-dirty #840
      Hardware name: Qualcomm (Flattened Device Tree)
      task: ed948000 ti: ed944000 task.ti: ed944000
      PC is at strlen+0xc/0x40
      LR is at __create_file+0x64/0x1dc
      pc : [<c04ee604>]    lr : [<c049f1c4>]    psr: 60000013
      sp : ed945e40  ip : ed945e50  fp : ed945e4c
      r10: 00000000  r9 : c1006094  r8 : 00000000
      r7 : 000041ed  r6 : 00000000  r5 : ed4af998  r4 : c11b5e28
      r3 : 00000000  r2 : ed945e38  r1 : a0000013  r0 : 00000000
      Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
      Control: 10c5787d  Table: 8020406a  DAC: 00000015
      Process swapper/0 (pid: 1, stack limit = 0xed944248)
      Stack: (0xed945e40 to 0xed946000)
      5e40: ed945e7c ed945e50 c049f1c4 c04ee604 c0fc2fa4 00000000 ecb748c0 c11c2b80
      5e60: c0beec04 0000011c c0fc2fa4 00000000 ed945e94 ed945e80 c049f3e0 c049f16c
      5e80: 00000000 00000000 ed945eac ed945e98 c08cbc50 c049f3c0 ecb748c0 c11c2b80
      5ea0: ed945ed4 ed945eb0 c0fc3080 c08cbc30 c0beec04 c107e1d8 ecdf0600 c107e1d8
      5ec0: c107e1d8 ecdf0600 ed945f54 ed945ed8 c0208ed4 c0fc2fb0 c026a784 c04ee628
      5ee0: ed945f0c ed945ef0 c0f5d600 c04ee604 c0f5d5ec ef7fcc7d c0b40ecc 0000011c
      5f00: ed945f54 ed945f10 c026a994 c0f5d5f8 c04ecc00 00000007 ef7fcc95 00000007
      5f20: c0e90744 c0dd0884 ed945f54 c106cde0 00000007 c117f8c0 0000011c c0f5d5ec
      5f40: c1006094 c100609c ed945f94 ed945f58 c0f5de34 c0208e50 00000007 00000007
      5f60: c0f5d5ec be9b5ae0 00000000 c117f8c0 c0af1680 00000000 00000000 00000000
      5f80: 00000000 00000000 ed945fac ed945f98 c0af169c c0f5dd2c ed944000 00000000
      5fa0: 00000000 ed945fb0 c020f298 c0af168c 00000000 00000000 00000000 00000000
      5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 ebcc6d33 bfffca73
      [<c04ee604>] (strlen) from [<c049f1c4>] (__create_file+0x64/0x1dc)
      [<c049f1c4>] (__create_file) from [<c049f3e0>] (debugfs_create_dir+0x2c/0x34)
      [<c049f3e0>] (debugfs_create_dir) from [<c08cbc50>] (clk_debug_create_one+0x2c/0x16c)
      [<c08cbc50>] (clk_debug_create_one) from [<c0fc3080>] (clk_debug_init+0xdc/0x144)
      [<c0fc3080>] (clk_debug_init) from [<c0208ed4>] (do_one_initcall+0x90/0x1e0)
      [<c0208ed4>] (do_one_initcall) from [<c0f5de34>] (kernel_init_freeable+0x114/0x1e0)
      [<c0f5de34>] (kernel_init_freeable) from [<c0af169c>] (kernel_init+0x1c/0xfc)
      [<c0af169c>] (kernel_init) from [<c020f298>] (ret_from_fork+0x14/0x3c)
      Code: c0b40ecc e1a0c00d e92dd800 e24cb004 (e5d02000)
      ---[ end trace b940e45b5e25c1e7 ]---
      
      Fixes: 6314b679 "clk: Don't hold prepare_lock across debugfs creation"
      Signed-off-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Reviewed-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMichael Turquette <mturquette@linaro.org>
      52bba980
  4. 25 1月, 2015 1 次提交
    • T
      clk: Introduce clk_has_parent() · 4e88f3de
      Thierry Reding 提交于
      This new function is similar to clk_set_parent(), except that it doesn't
      actually change the parent. It merely checks that the given parent clock
      can be a parent for the given clock.
      
      A situation where this is useful is to check that a particular setup is
      valid before switching to it. One specific use-case for this is atomic
      modesetting in the DRM framework where setting a mode is divided into a
      check phase where a given configuration is validated before applying
      changes to the hardware.
      
      Cc: Russell King <linux@arm.linux.org.uk>
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Reviewed-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMichael Turquette <mturquette@linaro.org>
      4e88f3de
  5. 21 1月, 2015 1 次提交
  6. 18 1月, 2015 1 次提交
  7. 16 12月, 2014 1 次提交
  8. 04 12月, 2014 5 次提交
  9. 20 11月, 2014 1 次提交
  10. 27 9月, 2014 2 次提交
  11. 11 9月, 2014 1 次提交
    • S
      clk: Don't hold prepare_lock across debugfs creation · 6314b679
      Stephen Boyd 提交于
      Rob Clark reports a lockdep splat that involves the prepare_lock
      chained with the mmap semaphore.
      
      ======================================================
      [ INFO: possible circular locking dependency detected ]
      3.17.0-rc1-00050-g07a489b #802 Tainted: G        W
      -------------------------------------------------------
      Xorg.bin/5413 is trying to acquire lock:
       (prepare_lock){+.+.+.}, at: [<c0781280>] clk_prepare_lock+0x88/0xfc
      
      but task is already holding lock:
       (qcom_iommu_lock){+.+...}, at: [<c079f664>] qcom_iommu_unmap+0x1c/0x1f0
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #4 (qcom_iommu_lock){+.+...}:
             [<c079f860>] qcom_iommu_map+0x28/0x450
             [<c079eb50>] iommu_map+0xc8/0x12c
             [<c056c1fc>] msm_iommu_map+0xb4/0x130
             [<c05697bc>] msm_gem_get_iova_locked+0x9c/0xe8
             [<c0569854>] msm_gem_get_iova+0x4c/0x64
             [<c0562208>] mdp4_kms_init+0x4c4/0x6c0
             [<c056881c>] msm_load+0x2ac/0x34c
             [<c0545724>] drm_dev_register+0xac/0x108
             [<c0547510>] drm_platform_init+0x50/0xf0
             [<c0578a60>] try_to_bring_up_master.part.3+0xc8/0x108
             [<c0578b48>] component_master_add_with_match+0xa8/0x104
             [<c0568294>] msm_pdev_probe+0x64/0x70
             [<c057e704>] platform_drv_probe+0x2c/0x60
             [<c057cff8>] driver_probe_device+0x108/0x234
             [<c057b65c>] bus_for_each_drv+0x64/0x98
             [<c057cec0>] device_attach+0x78/0x8c
             [<c057c590>] bus_probe_device+0x88/0xac
             [<c057c9b8>] deferred_probe_work_func+0x68/0x9c
             [<c0259db4>] process_one_work+0x1a0/0x40c
             [<c025a710>] worker_thread+0x44/0x4d8
             [<c025ec54>] kthread+0xd8/0xec
             [<c020e9a8>] ret_from_fork+0x14/0x2c
      
      -> #3 (&dev->struct_mutex){+.+.+.}:
             [<c0541188>] drm_gem_mmap+0x38/0xd0
             [<c05695b8>] msm_gem_mmap+0xc/0x5c
             [<c02f0b6c>] mmap_region+0x35c/0x6c8
             [<c02f11ec>] do_mmap_pgoff+0x314/0x398
             [<c02de1e0>] vm_mmap_pgoff+0x84/0xb4
             [<c02ef83c>] SyS_mmap_pgoff+0x94/0xbc
             [<c020e8e0>] ret_fast_syscall+0x0/0x48
      
      -> #2 (&mm->mmap_sem){++++++}:
             [<c0321138>] filldir64+0x68/0x180
             [<c0333fe0>] dcache_readdir+0x188/0x22c
             [<c0320ed0>] iterate_dir+0x9c/0x11c
             [<c03213b0>] SyS_getdents64+0x78/0xe8
             [<c020e8e0>] ret_fast_syscall+0x0/0x48
      
      -> #1 (&sb->s_type->i_mutex_key#3){+.+.+.}:
             [<c03fc544>] __create_file+0x58/0x1dc
             [<c03fc70c>] debugfs_create_dir+0x1c/0x24
             [<c0781c7c>] clk_debug_create_subtree+0x20/0x170
             [<c0be2af8>] clk_debug_init+0xec/0x14c
             [<c0208c70>] do_one_initcall+0x8c/0x1c8
             [<c0b9cce4>] kernel_init_freeable+0x13c/0x1dc
             [<c0877bc4>] kernel_init+0x8/0xe8
             [<c020e9a8>] ret_from_fork+0x14/0x2c
      
      -> #0 (prepare_lock){+.+.+.}:
             [<c087c408>] mutex_lock_nested+0x70/0x3e8
             [<c0781280>] clk_prepare_lock+0x88/0xfc
             [<c0782c50>] clk_prepare+0xc/0x24
             [<c079f474>] __enable_clocks.isra.4+0x18/0xa4
             [<c079f614>] __flush_iotlb_va+0xe0/0x114
             [<c079f6f4>] qcom_iommu_unmap+0xac/0x1f0
             [<c079ea3c>] iommu_unmap+0x9c/0xe8
             [<c056c2fc>] msm_iommu_unmap+0x64/0x84
             [<c0569da4>] msm_gem_free_object+0x11c/0x338
             [<c05413ec>] drm_gem_object_handle_unreference_unlocked+0xfc/0x130
             [<c0541604>] drm_gem_object_release_handle+0x50/0x68
             [<c0447a98>] idr_for_each+0xa8/0xdc
             [<c0541c10>] drm_gem_release+0x1c/0x28
             [<c0540b3c>] drm_release+0x370/0x428
             [<c031105c>] __fput+0x98/0x1e8
             [<c025d73c>] task_work_run+0xb0/0xfc
             [<c02477ec>] do_exit+0x2ec/0x948
             [<c0247ec0>] do_group_exit+0x4c/0xb8
             [<c025180c>] get_signal+0x28c/0x6ac
             [<c0211204>] do_signal+0xc4/0x3e4
             [<c02116cc>] do_work_pending+0xb4/0xc4
             [<c020e938>] work_pending+0xc/0x20
      
      other info that might help us debug this:
      
      Chain exists of:
        prepare_lock --> &dev->struct_mutex --> qcom_iommu_lock
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(qcom_iommu_lock);
                                     lock(&dev->struct_mutex);
                                     lock(qcom_iommu_lock);
        lock(prepare_lock);
      
       *** DEADLOCK ***
      
      3 locks held by Xorg.bin/5413:
       #0:  (drm_global_mutex){+.+.+.}, at: [<c0540800>] drm_release+0x34/0x428
       #1:  (&dev->struct_mutex){+.+.+.}, at: [<c05413bc>] drm_gem_object_handle_unreference_unlocked+0xcc/0x130
       #2:  (qcom_iommu_lock){+.+...}, at: [<c079f664>] qcom_iommu_unmap+0x1c/0x1f0
      
      stack backtrace:
      CPU: 1 PID: 5413 Comm: Xorg.bin Tainted: G        W      3.17.0-rc1-00050-g07a489b #802
      [<c0216290>] (unwind_backtrace) from [<c0211d8c>] (show_stack+0x10/0x14)
      [<c0211d8c>] (show_stack) from [<c087a078>] (dump_stack+0x98/0xb8)
      [<c087a078>] (dump_stack) from [<c027f024>] (print_circular_bug+0x218/0x340)
      [<c027f024>] (print_circular_bug) from [<c0283e08>] (__lock_acquire+0x1d24/0x20b8)
      [<c0283e08>] (__lock_acquire) from [<c0284774>] (lock_acquire+0x9c/0xbc)
      [<c0284774>] (lock_acquire) from [<c087c408>] (mutex_lock_nested+0x70/0x3e8)
      [<c087c408>] (mutex_lock_nested) from [<c0781280>] (clk_prepare_lock+0x88/0xfc)
      [<c0781280>] (clk_prepare_lock) from [<c0782c50>] (clk_prepare+0xc/0x24)
      [<c0782c50>] (clk_prepare) from [<c079f474>] (__enable_clocks.isra.4+0x18/0xa4)
      [<c079f474>] (__enable_clocks.isra.4) from [<c079f614>] (__flush_iotlb_va+0xe0/0x114)
      [<c079f614>] (__flush_iotlb_va) from [<c079f6f4>] (qcom_iommu_unmap+0xac/0x1f0)
      [<c079f6f4>] (qcom_iommu_unmap) from [<c079ea3c>] (iommu_unmap+0x9c/0xe8)
      [<c079ea3c>] (iommu_unmap) from [<c056c2fc>] (msm_iommu_unmap+0x64/0x84)
      [<c056c2fc>] (msm_iommu_unmap) from [<c0569da4>] (msm_gem_free_object+0x11c/0x338)
      [<c0569da4>] (msm_gem_free_object) from [<c05413ec>] (drm_gem_object_handle_unreference_unlocked+0xfc/0x130)
      [<c05413ec>] (drm_gem_object_handle_unreference_unlocked) from [<c0541604>] (drm_gem_object_release_handle+0x50/0x68)
      [<c0541604>] (drm_gem_object_release_handle) from [<c0447a98>] (idr_for_each+0xa8/0xdc)
      [<c0447a98>] (idr_for_each) from [<c0541c10>] (drm_gem_release+0x1c/0x28)
      [<c0541c10>] (drm_gem_release) from [<c0540b3c>] (drm_release+0x370/0x428)
      [<c0540b3c>] (drm_release) from [<c031105c>] (__fput+0x98/0x1e8)
      [<c031105c>] (__fput) from [<c025d73c>] (task_work_run+0xb0/0xfc)
      [<c025d73c>] (task_work_run) from [<c02477ec>] (do_exit+0x2ec/0x948)
      [<c02477ec>] (do_exit) from [<c0247ec0>] (do_group_exit+0x4c/0xb8)
      [<c0247ec0>] (do_group_exit) from [<c025180c>] (get_signal+0x28c/0x6ac)
      [<c025180c>] (get_signal) from [<c0211204>] (do_signal+0xc4/0x3e4)
      [<c0211204>] (do_signal) from [<c02116cc>] (do_work_pending+0xb4/0xc4)
      [<c02116cc>] (do_work_pending) from [<c020e938>] (work_pending+0xc/0x20)
      
      We can break this chain if we don't hold the prepare_lock while
      creating debugfs directories. We only hold the prepare_lock right
      now because we're traversing the clock tree recursively and we
      don't want the hierarchy to change during the traversal.
      Replacing this traversal with a simple linked list walk allows us
      to only grab a list lock instead of the prepare_lock, thus
      breaking the lock chain.
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMike Turquette <mturquette@linaro.org>
      6314b679
  12. 04 9月, 2014 1 次提交
  13. 30 7月, 2014 1 次提交
  14. 26 7月, 2014 1 次提交
  15. 03 7月, 2014 1 次提交
    • P
      clk: define and export clk_debugs_add_file · fb2b3c9f
      Peter De Schrijver 提交于
      Define and export a new function clk_debugs_add_file which adds a file
      to a existing clock's debugfs directory. This can be used by clock
      providers to add debugfs entries which are not related to a specific clock
      type. Examples include the ability to measure the rate of a clock. It can
      also be used by modules to create new debugfs entries. This is useful if you
      want to expose features for testing which can potentially cause system
      instability such as allowing to change a clock's rate from userspace.
      Signed-off-by: NPeter De Schrijver <pdeschrijver@nvidia.com>
      Signed-off-by: NMike Turquette <mturquette@linaro.org>
      fb2b3c9f
  16. 02 7月, 2014 1 次提交
    • S
      clk: Fix build warnings · 6b44c854
      Sachin Kamat 提交于
      ‘all_lists’ and ‘orphan_list’ is accessed only when DEBUG_FS is defined.
      Thus, make their compilation conditional to fix the below warnings introduced
      by commit 27b8d5f7 ("clk: flatten clk tree in debugfs"):
      drivers/clk/clk.c:40:27: warning: ‘all_lists’ defined but not used [-Wunused-variable]
      drivers/clk/clk.c:46:27: warning: ‘orphan_list’ defined but not used [-Wunused-variable]
      Signed-off-by: NSachin Kamat <sachin.kamat@samsung.com>
      Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
      Signed-off-by: NMike Turquette <mturquette@linaro.org>
      6b44c854
  17. 27 6月, 2014 1 次提交
  18. 04 6月, 2014 1 次提交
  19. 24 5月, 2014 1 次提交
    • G
      clk: Neaten clk_summary output · fb8abb7a
      Geert Uytterhoeven 提交于
        - Limit ruler to 80 characters (was: 81),
        - Widen rate column by 1 for nicer spacing,
        - Right-align numbers and their column headers,
        - Move a newline to reduce the number of seq_printf() calls,
        - Use set_puts() for fixed strings.
      
      Before:
      
         clock                        enable_cnt  prepare_cnt  rate        accuracy
      ---------------------------------------------------------------------------------
       extal                          2           2            20000000   0
          thermal                     1           1            20000000   0
          cp                          0           0            10000000   0
             tpu0                     0           0            10000000   0
             tmu0                     0           0            10000000   0
          main                        1           1            20000000   0
             pll3                     0           0            1600000000 0
                ddr                   0           0            200000000  0
                zb3d2                 0           0            200000000  0
                zb3                   0           0            400000000  0
             pll1                     4           4            1560000000 0
                oscclk                0           0            126953     0
                rclk                  1           1            31738      0
                   cmt1               0           0            31738      0
                   cmt0               1           1            31738      0
                imp                   0           0            390000000  0
      
      After:
      
         clock                         enable_cnt  prepare_cnt        rate   accuracy
      --------------------------------------------------------------------------------
       extal                                    2            2    20000000          0
          thermal                               1            1    20000000          0
          cp                                    0            0    10000000          0
             tpu0                               0            0    10000000          0
             tmu0                               0            0    10000000          0
          main                                  1            1    20000000          0
             pll3                               0            0  1600000000          0
                ddr                             0            0   200000000          0
                zb3d2                           0            0   200000000          0
                zb3                             0            0   400000000          0
             pll1                               4            4  1560000000          0
                oscclk                          0            0      126953          0
                rclk                            1            1       31738          0
                   cmt1                         0            0       31738          0
                   cmt0                         1            1       31738          0
                imp                             0            0   390000000          0
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NMike Turquette <mturquette@linaro.org>
      fb8abb7a
  20. 01 5月, 2014 5 次提交
    • S
      clk: Ignore error and NULL pointers passed to clk_{unprepare, disable}() · 63589e92
      Stephen Boyd 提交于
      This simplifies error paths in drivers that use optional clocks
      by allowing the NULL or error pointer to be passed
      unconditionally.
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMike Turquette <mturquette@linaro.org>
      63589e92
    • S
      clk: Consolidate recalc rate logic · 8f2c2db1
      Stephen Boyd 提交于
      The same if-else statement exists four times to recalculate the
      rate of a clock. Consolidate this logic into a single function to
      save some lines.
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMike Turquette <mturquette@linaro.org>
      8f2c2db1
    • S
      clk: Don't check for missing ops in clk_set_parent() · 86a61234
      Stephen Boyd 提交于
      We dereference clk->ops during clock registration so this check
      for NULL ops can't possibly ever be true.
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMike Turquette <mturquette@linaro.org>
      86a61234
    • S
      clk: Fix slab corruption in clk_unregister() · 874f224c
      Stephen Boyd 提交于
      When a clock is unregsitered, we iterate over the list of
      children and reparent them to NULL (i.e. orphan list). While
      iterating the list, we should use the safe iterators because the
      children list for this clock is changing when we reparent the
      children to NULL. Failure to iterate safely can lead to slab
      corruption like this:
      
      =============================================================================
      BUG kmalloc-128 (Not tainted): Poison overwritten
      -----------------------------------------------------------------------------
      
      Disabling lock debugging due to kernel taint
      INFO: 0xed0c4900-0xed0c4903. First byte 0x0 instead of 0x6b
      INFO: Allocated in clk_register+0x20/0x1bc age=297 cpu=2 pid=70
       __slab_alloc.isra.39.constprop.42+0x410/0x454
       kmem_cache_alloc_trace+0x200/0x24c
       clk_register+0x20/0x1bc
       devm_clk_register+0x34/0x68
       0xbf0000f0
       platform_drv_probe+0x18/0x48
       driver_probe_device+0x94/0x360
       __driver_attach+0x94/0x98
       bus_for_each_dev+0x54/0x88
       bus_add_driver+0xe8/0x204
       driver_register+0x78/0xf4
       do_one_initcall+0xc4/0x17c
       load_module+0x19ac/0x2294
       SyS_init_module+0xa4/0x110
       ret_fast_syscall+0x0/0x48
      INFO: Freed in clk_unregister+0xd4/0x140 age=23 cpu=2 pid=73
       __slab_free+0x38/0x41c
       clk_unregister+0xd4/0x140
       release_nodes+0x164/0x1d8
       __device_release_driver+0x60/0xb0
       driver_detach+0xb4/0xb8
       bus_remove_driver+0x5c/0xc4
       SyS_delete_module+0x148/0x1d8
       ret_fast_syscall+0x0/0x48
      INFO: Slab 0xeec50b90 objects=25 used=0 fp=0xed0c5400 flags=0x4080
      INFO: Object 0xed0c48c0 @offset=2240 fp=0xed0c4a00
      
      Bytes b4 ed0c48b0: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a  ZZZZZZZZZZZZZZZZ
      Object ed0c48c0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c48d0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c48e0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c48f0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c4900: 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  ....kkkkkkkkkkkk
      Object ed0c4910: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c4920: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c4930: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5  kkkkkkkkkkkkkkk.
      Redzone ed0c4940: bb bb bb bb                                      ....
      Padding ed0c49e8: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a  ZZZZZZZZZZZZZZZZ
      Padding ed0c49f8: 5a 5a 5a 5a 5a 5a 5a 5a                          ZZZZZZZZ
      CPU: 3 PID: 75 Comm: mdev Tainted: G    B         3.14.0-11033-g2054ba5ca781 #35
      [<c0014be0>] (unwind_backtrace) from [<c0012240>] (show_stack+0x10/0x14)
      [<c0012240>] (show_stack) from [<c04b74a0>] (dump_stack+0x70/0xbc)
      [<c04b74a0>] (dump_stack) from [<c00f7a78>] (check_bytes_and_report+0xbc/0x100)
      [<c00f7a78>] (check_bytes_and_report) from [<c00f7c48>] (check_object+0x18c/0x218)
      [<c00f7c48>] (check_object) from [<c00f7efc>] (__free_slab+0x104/0x144)
      [<c00f7efc>] (__free_slab) from [<c04b6668>] (__slab_free+0x3dc/0x41c)
      [<c04b6668>] (__slab_free) from [<c014c008>] (load_elf_binary+0x88/0x12b4)
      [<c014c008>] (load_elf_binary) from [<c0105a44>] (search_binary_handler+0x78/0x18c)
      [<c0105a44>] (search_binary_handler) from [<c0106fc0>] (do_execve+0x490/0x5dc)
      [<c0106fc0>] (do_execve) from [<c0036b8c>] (____call_usermodehelper+0x134/0x168)
      [<c0036b8c>] (____call_usermodehelper) from [<c000f048>] (ret_from_fork+0x14/0x2c)
      FIX kmalloc-128: Restoring 0xed0c4900-0xed0c4903=0x6b
      
      Fixes: fcb0ee6a (clk: Implement clk_unregister)
      Cc: Jiada Wang <jiada_wang@mentor.com>
      Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
      Cc: Kyungmin Park <kyungmin.park@samsung.com>
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMike Turquette <mturquette@linaro.org>
      Cc: stable@vger.kernel.org
      874f224c
    • S
      clk: Fix double free due to devm_clk_register() · 293ba3b4
      Stephen Boyd 提交于
      Now that clk_unregister() frees the struct clk we're
      unregistering we'll free memory twice: first we'll call kfree()
      in __clk_release() with an address kmalloc doesn't know about and
      second we'll call kfree() in the devres layer. Remove the
      allocation of struct clk in devm_clk_register() and let
      clk_release() handle it. This fixes slab errors like:
      
      =============================================================================
      BUG kmalloc-128 (Not tainted): Invalid object pointer 0xed08e8d0
      -----------------------------------------------------------------------------
      
      Disabling lock debugging due to kernel taint
      INFO: Slab 0xeec503f8 objects=25 used=15 fp=0xed08ea00 flags=0x4081
      CPU: 2 PID: 73 Comm: rmmod Tainted: G    B         3.14.0-11032-g526e9c764381 #34
      [<c0014be0>] (unwind_backtrace) from [<c0012240>] (show_stack+0x10/0x14)
      [<c0012240>] (show_stack) from [<c04b74dc>] (dump_stack+0x70/0xbc)
      [<c04b74dc>] (dump_stack) from [<c00f6778>] (slab_err+0x74/0x84)
      [<c00f6778>] (slab_err) from [<c04b6278>] (free_debug_processing+0x2cc/0x31c)
      [<c04b6278>] (free_debug_processing) from [<c04b6300>] (__slab_free+0x38/0x41c)
      [<c04b6300>] (__slab_free) from [<c03931bc>] (clk_unregister+0xd4/0x140)
      [<c03931bc>] (clk_unregister) from [<c02fb774>] (release_nodes+0x164/0x1d8)
      [<c02fb774>] (release_nodes) from [<c02f8698>] (__device_release_driver+0x60/0xb0)
      [<c02f8698>] (__device_release_driver) from [<c02f9080>] (driver_detach+0xb4/0xb8)
      [<c02f9080>] (driver_detach) from [<c02f8480>] (bus_remove_driver+0x5c/0xc4)
      [<c02f8480>] (bus_remove_driver) from [<c008c9b8>] (SyS_delete_module+0x148/0x1d8)
      [<c008c9b8>] (SyS_delete_module) from [<c000ef80>] (ret_fast_syscall+0x0/0x48)
      FIX kmalloc-128: Object at 0xed08e8d0 not freed
      
      Fixes: fcb0ee6a (clk: Implement clk_unregister)
      Cc: Jiada Wang <jiada_wang@mentor.com>
      Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
      Cc: Kyungmin Park <kyungmin.park@samsung.com>
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMike Turquette <mturquette@linaro.org>
      Cc: stable@vger.kernel.org
      293ba3b4
  21. 28 3月, 2014 2 次提交
  22. 25 3月, 2014 1 次提交
  23. 21 3月, 2014 1 次提交
  24. 20 3月, 2014 1 次提交
  25. 25 2月, 2014 1 次提交