Pull clk fixes from Stephen Boyd: "One core framework fix to walk the orphan list and match up clks to parents when clk providers register the DT provider after registering all their clks (as they should). Then a handful of driver fixes for the qcom, imx, and at91 drivers. The driver fixes are relatively small fixes for incorrect register settings or missing locks causing race conditions" * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: clk: qcom: Avoid SMMU/cx gdsc corner cases clk: qcom: gcc-sc7180: Fix setting flag for votable GDSCs clk: Move clk_core_reparent_orphans() under CONFIG_OF clk: at91: fix possible deadlock clk: walk orphan list on clock provider registration clk: imx: pll14xx: fix clk_pll14xx_wait_lock clk: imx: clk-imx7ulp: Add missing sentinel of ulp_div_table clk: imx: clk-composite-8m: add lock to gate/mux
Unified · Split
| @@ -348,7 +348,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np, · 347 unmodified lines | |||
| 348 | return; | 348 | return; |
| 349 | mainxtal_name = of_clk_get_parent_name(np, i); | 349 | mainxtal_name = of_clk_get_parent_name(np, i); |
| 350 | 350 | ||
| 351 | regmap = syscon_node_to_regmap(np); | 351 | regmap = device_node_to_regmap(np); |
| 352 | if (IS_ERR(regmap)) | 352 | if (IS_ERR(regmap)) |
| 353 | return; | 353 | return; |
| 354 | 354 | ||
| @@ -83,7 +83,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np) · 82 unmodified lines | |||
| 83 | return; | 83 | return; |
| 84 | mainxtal_name = of_clk_get_parent_name(np, i); | 84 | mainxtal_name = of_clk_get_parent_name(np, i); |
| 85 | 85 | ||
| 86 | regmap = syscon_node_to_regmap(np); | 86 | regmap = device_node_to_regmap(np); |
| 87 | if (IS_ERR(regmap)) | 87 | if (IS_ERR(regmap)) |
| 88 | return; | 88 | return; |
| 89 | 89 | ||
| @@ -146,7 +146,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np, · 145 unmodified lines | |||
| 146 | return; | 146 | return; |
| 147 | mainxtal_name = of_clk_get_parent_name(np, i); | 147 | mainxtal_name = of_clk_get_parent_name(np, i); |
| 148 | 148 | ||
| 149 | regmap = syscon_node_to_regmap(np); | 149 | regmap = device_node_to_regmap(np); |
| 150 | if (IS_ERR(regmap)) | 150 | if (IS_ERR(regmap)) |
| 151 | return; | 151 | return; |
| 152 | 152 | ||
| @@ -275,7 +275,7 @@ static int __init pmc_register_ops(void) · 274 unmodified lines | |||
| 275 | 275 | ||
| 276 | np = of_find_matching_node(NULL, sama5d2_pmc_dt_ids); | 276 | np = of_find_matching_node(NULL, sama5d2_pmc_dt_ids); |
| 277 | 277 | ||
| 278 | pmcreg = syscon_node_to_regmap(np); | 278 | pmcreg = device_node_to_regmap(np); |
| 279 | if (IS_ERR(pmcreg)) | 279 | if (IS_ERR(pmcreg)) |
| 280 | return PTR_ERR(pmcreg); | 280 | return PTR_ERR(pmcreg); |
| 281 | 281 | ||
| @@ -162,7 +162,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np) · 161 unmodified lines | |||
| 162 | return; | 162 | return; |
| 163 | mainxtal_name = of_clk_get_parent_name(np, i); | 163 | mainxtal_name = of_clk_get_parent_name(np, i); |
| 164 | 164 | ||
| 165 | regmap = syscon_node_to_regmap(np); | 165 | regmap = device_node_to_regmap(np); |
| 166 | if (IS_ERR(regmap)) | 166 | if (IS_ERR(regmap)) |
| 167 | return; | 167 | return; |
| 168 | 168 | ||
| @@ -136,7 +136,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np) · 135 unmodified lines | |||
| 136 | return; | 136 | return; |
| 137 | mainxtal_name = of_clk_get_parent_name(np, i); | 137 | mainxtal_name = of_clk_get_parent_name(np, i); |
| 138 | 138 | ||
| 139 | regmap = syscon_node_to_regmap(np); | 139 | regmap = device_node_to_regmap(np); |
| 140 | if (IS_ERR(regmap)) | 140 | if (IS_ERR(regmap)) |
| 141 | return; | 141 | return; |
| 142 | 142 | ||
| @@ -3249,6 +3249,34 @@ static inline void clk_debug_unregister(struct clk_core *core) · 3248 unmodified lines | |||
| 3249 | } | 3249 | } |
| 3250 | #endif | 3250 | #endif |
| 3251 | 3251 | ||
| 3252 | static void clk_core_reparent_orphans_nolock(void) | ||
| 3253 | { | ||
| 3254 | struct clk_core *orphan; | ||
| 3255 | struct hlist_node *tmp2; | ||
| 3256 | |||
| 3257 | /* | ||
| 3258 | * walk the list of orphan clocks and reparent any that newly finds a | ||
| 3259 | * parent. | ||
| 3260 | */ | ||
| 3261 | hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) { | ||
| 3262 | struct clk_core *parent = __clk_init_parent(orphan); | ||
| 3263 | |||
| 3264 | /* | ||
| 3265 | * We need to use __clk_set_parent_before() and _after() to | ||
| 3266 | * to properly migrate any prepare/enable count of the orphan | ||
| 3267 | * clock. This is important for CLK_IS_CRITICAL clocks, which | ||
| 3268 | * are enabled during init but might not have a parent yet. | ||
| 3269 | */ | ||
| 3270 | if (parent) { | ||
| 3271 | /* update the clk tree topology */ | ||
| 3272 | __clk_set_parent_before(orphan, parent); | ||
| 3273 | __clk_set_parent_after(orphan, parent, NULL); | ||
| 3274 | __clk_recalc_accuracies(orphan); | ||
| 3275 | __clk_recalc_rates(orphan, 0); | ||
| 3276 | } | ||
| 3277 | } | ||
| 3278 | } | ||
| 3279 | |||
| 3252 | /** | 3280 | /** |
| 3253 | * __clk_core_init - initialize the data structures in a struct clk_core | 3281 | * __clk_core_init - initialize the data structures in a struct clk_core |
| 3254 | * @core: clk_core being initialized | 3282 | * @core: clk_core being initialized |
| @@ -3259,8 +3287,6 @@ static inline void clk_debug_unregister(struct clk_core *core) · 4 unmodified lines | |||
| 3259 | static int __clk_core_init(struct clk_core *core) | 3287 | static int __clk_core_init(struct clk_core *core) |
| 3260 | { | 3288 | { |
| 3261 | int ret; | 3289 | int ret; |
| 3262 | struct clk_core *orphan; | ||
| 3263 | struct hlist_node *tmp2; | ||
| 3264 | unsigned long rate; | 3290 | unsigned long rate; |
| 3265 | 3291 | ||
| 3266 | if (!core) | 3292 | if (!core) |
| @@ -3407,27 +3433,8 @@ static int __clk_core_init(struct clk_core *core) · 140 unmodified lines | |||
| 3407 | clk_enable_unlock(flags); | 3433 | clk_enable_unlock(flags); |
| 3408 | } | 3434 | } |
| 3409 | 3435 | ||
| 3410 | /* | 3436 | clk_core_reparent_orphans_nolock(); |
| 3411 | * walk the list of orphan clocks and reparent any that newly finds a | ||
| 3412 | * parent. | ||
| 3413 | */ | ||
| 3414 | hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) { | ||
| 3415 | struct clk_core *parent = __clk_init_parent(orphan); | ||
| 3416 | 3437 | ||
| 3417 | /* | ||
| 3418 | * We need to use __clk_set_parent_before() and _after() to | ||
| 3419 | * to properly migrate any prepare/enable count of the orphan | ||
| 3420 | * clock. This is important for CLK_IS_CRITICAL clocks, which | ||
| 3421 | * are enabled during init but might not have a parent yet. | ||
| 3422 | */ | ||
| 3423 | if (parent) { | ||
| 3424 | /* update the clk tree topology */ | ||
| 3425 | __clk_set_parent_before(orphan, parent); | ||
| 3426 | __clk_set_parent_after(orphan, parent, NULL); | ||
| 3427 | __clk_recalc_accuracies(orphan); | ||
| 3428 | __clk_recalc_rates(orphan, 0); | ||
| 3429 | } | ||
| 3430 | } | ||
| 3431 | 3438 | ||
| 3432 | kref_init(&core->ref); | 3439 | kref_init(&core->ref); |
| 3433 | out: | 3440 | out: |
| @@ -4179,6 +4186,13 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb) · 745 unmodified lines | |||
| 4179 | EXPORT_SYMBOL_GPL(clk_notifier_unregister); | 4186 | EXPORT_SYMBOL_GPL(clk_notifier_unregister); |
| 4180 | 4187 | ||
| 4181 | #ifdef CONFIG_OF | 4188 | #ifdef CONFIG_OF |
| 4189 | static void clk_core_reparent_orphans(void) | ||
| 4190 | { | ||
| 4191 | clk_prepare_lock(); | ||
| 4192 | clk_core_reparent_orphans_nolock(); | ||
| 4193 | clk_prepare_unlock(); | ||
| 4194 | } | ||
| 4195 | |||
| 4182 | /** | 4196 | /** |
| 4183 | * struct of_clk_provider - Clock provider registration structure | 4197 | * struct of_clk_provider - Clock provider registration structure |
| 4184 | * @link: Entry in global list of clock providers | 4198 | * @link: Entry in global list of clock providers |
| @@ -4274,6 +4288,8 @@ int of_clk_add_provider(struct device_node *np, · 89 unmodified lines | |||
| 4274 | mutex_unlock(&of_clk_mutex); | 4288 | mutex_unlock(&of_clk_mutex); |
| 4275 | pr_debug("Added clock from %pOF\n", np); | 4289 | pr_debug("Added clock from %pOF\n", np); |
| 4276 | 4290 | ||
| 4291 | clk_core_reparent_orphans(); | ||
| 4292 | |||
| 4277 | ret = of_clk_set_defaults(np, true); | 4293 | ret = of_clk_set_defaults(np, true); |
| 4278 | if (ret < 0) | 4294 | if (ret < 0) |
| 4279 | of_clk_del_provider(np); | 4295 | of_clk_del_provider(np); |
| @@ -4309,6 +4325,8 @@ int of_clk_add_hw_provider(struct device_node *np, · 29 unmodified lines | |||
| 4309 | mutex_unlock(&of_clk_mutex); | 4325 | mutex_unlock(&of_clk_mutex); |
| 4310 | pr_debug("Added clk_hw provider from %pOF\n", np); | 4326 | pr_debug("Added clk_hw provider from %pOF\n", np); |
| 4311 | 4327 | ||
| 4328 | clk_core_reparent_orphans(); | ||
| 4329 | |||
| 4312 | ret = of_clk_set_defaults(np, true); | 4330 | ret = of_clk_set_defaults(np, true); |
| 4313 | if (ret < 0) | 4331 | if (ret < 0) |
| 4314 | of_clk_del_provider(np); | 4332 | of_clk_del_provider(np); |
| @@ -142,6 +142,7 @@ struct clk *imx8m_clk_composite_flags(const char *name, · 141 unmodified lines | |||
| 142 | mux->reg = reg; | 142 | mux->reg = reg; |
| 143 | mux->shift = PCG_PCS_SHIFT; | 143 | mux->shift = PCG_PCS_SHIFT; |
| 144 | mux->mask = PCG_PCS_MASK; | 144 | mux->mask = PCG_PCS_MASK; |
| 145 | mux->lock = &imx_ccm_lock; | ||
| 145 | 146 | ||
| 146 | div = kzalloc(sizeof(*div), GFP_KERNEL); | 147 | div = kzalloc(sizeof(*div), GFP_KERNEL); |
| 147 | if (!div) | 148 | if (!div) |
| @@ -161,6 +162,7 @@ struct clk *imx8m_clk_composite_flags(const char *name, · 13 unmodified lines | |||
| 161 | gate_hw = &gate->hw; | 162 | gate_hw = &gate->hw; |
| 162 | gate->reg = reg; | 163 | gate->reg = reg; |
| 163 | gate->bit_idx = PCG_CGC_SHIFT; | 164 | gate->bit_idx = PCG_CGC_SHIFT; |
| 165 | gate->lock = &imx_ccm_lock; | ||
| 164 | 166 | ||
| 165 | hw = clk_hw_register_composite(NULL, name, parent_names, num_parents, | 167 | hw = clk_hw_register_composite(NULL, name, parent_names, num_parents, |
| 166 | mux_hw, &clk_mux_ops, div_hw, | 168 | mux_hw, &clk_mux_ops, div_hw, |
| @@ -40,6 +40,7 @@ static const struct clk_div_table ulp_div_table[] = { · 39 unmodified lines | |||
| 40 | { .val = 5, .div = 16, }, | 40 | { .val = 5, .div = 16, }, |
| 41 | { .val = 6, .div = 32, }, | 41 | { .val = 6, .div = 32, }, |
| 42 | { .val = 7, .div = 64, }, | 42 | { .val = 7, .div = 64, }, |
| 43 | { /* sentinel */ }, | ||
| 43 | }; | 44 | }; |
| 44 | 45 | ||
| 45 | static const int pcc2_uart_clk_ids[] __initconst = { | 46 | static const int pcc2_uart_clk_ids[] __initconst = { |
| @@ -159,7 +159,7 @@ static int clk_pll14xx_wait_lock(struct clk_pll14xx *pll) · 158 unmodified lines | |||
| 159 | { | 159 | { |
| 160 | u32 val; | 160 | u32 val; |
| 161 | 161 | ||
| 162 | return readl_poll_timeout(pll->base, val, val & LOCK_TIMEOUT_US, 0, | 162 | return readl_poll_timeout(pll->base, val, val & LOCK_STATUS, 0, |
| 163 | LOCK_TIMEOUT_US); | 163 | LOCK_TIMEOUT_US); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| @@ -2186,7 +2186,8 @@ static struct gdsc hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc = { · 2185 unmodified lines | |||
| 2186 | .pd = { | 2186 | .pd = { |
| 2187 | .name = "hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc", | 2187 | .name = "hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc", |
| 2188 | }, | 2188 | }, |
| 2189 | .pwrsts = PWRSTS_OFF_ON | VOTABLE, | 2189 | .pwrsts = PWRSTS_OFF_ON, |
| 2190 | .flags = VOTABLE, | ||
| 2190 | }; | 2191 | }; |
| 2191 | 2192 | ||
| 2192 | static struct gdsc hlos1_vote_mmnoc_mmu_tbu_sf_gdsc = { | 2193 | static struct gdsc hlos1_vote_mmnoc_mmu_tbu_sf_gdsc = { |
| @@ -2194,7 +2195,8 @@ static struct gdsc hlos1_vote_mmnoc_mmu_tbu_sf_gdsc = { · 1 unmodified line | |||
| 2194 | .pd = { | 2195 | .pd = { |
| 2195 | .name = "hlos1_vote_mmnoc_mmu_tbu_sf_gdsc", | 2196 | .name = "hlos1_vote_mmnoc_mmu_tbu_sf_gdsc", |
| 2196 | }, | 2197 | }, |
| 2197 | .pwrsts = PWRSTS_OFF_ON | VOTABLE, | 2198 | .pwrsts = PWRSTS_OFF_ON, |
| 2199 | .flags = VOTABLE, | ||
| 2198 | }; | 2200 | }; |
| 2199 | 2201 | ||
| 2200 | static struct gdsc *gcc_sc7180_gdscs[] = { | 2202 | static struct gdsc *gcc_sc7180_gdscs[] = { |
| @@ -242,10 +242,12 @@ static struct clk_branch gfx3d_isense_clk = { · 241 unmodified lines | |||
| 242 | 242 | ||
| 243 | static struct gdsc gpu_cx_gdsc = { | 243 | static struct gdsc gpu_cx_gdsc = { |
| 244 | .gdscr = 0x1004, | 244 | .gdscr = 0x1004, |
| 245 | .gds_hw_ctrl = 0x1008, | ||
| 245 | .pd = { | 246 | .pd = { |
| 246 | .name = "gpu_cx", | 247 | .name = "gpu_cx", |
| 247 | }, | 248 | }, |
| 248 | .pwrsts = PWRSTS_OFF_ON, | 249 | .pwrsts = PWRSTS_OFF_ON, |
| 250 | .flags = VOTABLE, | ||
| 249 | }; | 251 | }; |
| 250 | 252 | ||
| 251 | static struct gdsc gpu_gx_gdsc = { | 253 | static struct gdsc gpu_gx_gdsc = { |