Skip to content

Commit 3215b9d

Browse files
committed
Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
Pull clk fixes from Stephen Boyd: "A late collection of fixes for regressions seen this release cycle. Normally I send this earlier than now but real life got in the way. Things are back to normal now. There's the normal set of SoC driver fixes: i.MX boot warning, TI display clks, allwinner clk ops being wrong (fun), driver probe badness on error paths, correctness fix for the new aspeed driver, and even a fix for a race condition in the bcm2835 clk driver. At the core framework level we also got some fixes for the clk phase API caching at the wrong time, better handling of the enabled state of orphan clks, and a fix for a newly introduced bug in how we handle rate calculations for pass-through clks" * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: clk: bcm2835: Protect sections updating shared registers clk: bcm2835: Fix ana->maskX definitions clk: aspeed: Prevent reset if clock is enabled clk: aspeed: Fix is_enabled for certain clocks clk: qcom: msm8916: Fix return value check in qcom_apcs_msm8916_clk_probe() clk: hisilicon: hi3660:Fix potential NULL dereference in hi3660_stub_clk_probe() clk: fix determine rate error with pass-through clock clk: migrate the count of orphaned clocks at init clk: update cached phase to respect the fact when setting phase clk: ti: am43xx: add set-rate-parent support for display clkctrl clock clk: ti: am33xx: add set-rate-parent support for display clkctrl clock clk: ti: clkctrl: add support for CLK_SET_RATE_PARENT flag clk: imx51-imx53: Fix UART4/5 registration on i.MX50 and i.MX53 clk: sunxi-ng: a31: Fix CLK_OUT_* clock ops
2 parents 303851e + 7997f3b commit 3215b9d

File tree

10 files changed

+81
-44
lines changed

10 files changed

+81
-44
lines changed

drivers/clk/bcm/clk-bcm2835.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,17 +449,17 @@ struct bcm2835_pll_ana_bits {
449449
static const struct bcm2835_pll_ana_bits bcm2835_ana_default = {
450450
.mask0 = 0,
451451
.set0 = 0,
452-
.mask1 = (u32)~(A2W_PLL_KI_MASK | A2W_PLL_KP_MASK),
452+
.mask1 = A2W_PLL_KI_MASK | A2W_PLL_KP_MASK,
453453
.set1 = (2 << A2W_PLL_KI_SHIFT) | (8 << A2W_PLL_KP_SHIFT),
454-
.mask3 = (u32)~A2W_PLL_KA_MASK,
454+
.mask3 = A2W_PLL_KA_MASK,
455455
.set3 = (2 << A2W_PLL_KA_SHIFT),
456456
.fb_prediv_mask = BIT(14),
457457
};
458458

459459
static const struct bcm2835_pll_ana_bits bcm2835_ana_pllh = {
460-
.mask0 = (u32)~(A2W_PLLH_KA_MASK | A2W_PLLH_KI_LOW_MASK),
460+
.mask0 = A2W_PLLH_KA_MASK | A2W_PLLH_KI_LOW_MASK,
461461
.set0 = (2 << A2W_PLLH_KA_SHIFT) | (2 << A2W_PLLH_KI_LOW_SHIFT),
462-
.mask1 = (u32)~(A2W_PLLH_KI_HIGH_MASK | A2W_PLLH_KP_MASK),
462+
.mask1 = A2W_PLLH_KI_HIGH_MASK | A2W_PLLH_KP_MASK,
463463
.set1 = (6 << A2W_PLLH_KP_SHIFT),
464464
.mask3 = 0,
465465
.set3 = 0,
@@ -623,8 +623,10 @@ static int bcm2835_pll_on(struct clk_hw *hw)
623623
~A2W_PLL_CTRL_PWRDN);
624624

625625
/* Take the PLL out of reset. */
626+
spin_lock(&cprman->regs_lock);
626627
cprman_write(cprman, data->cm_ctrl_reg,
627628
cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST);
629+
spin_unlock(&cprman->regs_lock);
628630

629631
/* Wait for the PLL to lock. */
630632
timeout = ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS);
@@ -701,9 +703,11 @@ static int bcm2835_pll_set_rate(struct clk_hw *hw,
701703
}
702704

703705
/* Unmask the reference clock from the oscillator. */
706+
spin_lock(&cprman->regs_lock);
704707
cprman_write(cprman, A2W_XOSC_CTRL,
705708
cprman_read(cprman, A2W_XOSC_CTRL) |
706709
data->reference_enable_mask);
710+
spin_unlock(&cprman->regs_lock);
707711

708712
if (do_ana_setup_first)
709713
bcm2835_pll_write_ana(cprman, data->ana_reg_base, ana);

drivers/clk/clk-aspeed.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ static const struct aspeed_clk_soc_data ast2400_data = {
205205
.calc_pll = aspeed_ast2400_calc_pll,
206206
};
207207

208+
static int aspeed_clk_is_enabled(struct clk_hw *hw)
209+
{
210+
struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw);
211+
u32 clk = BIT(gate->clock_idx);
212+
u32 enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? 0 : clk;
213+
u32 reg;
214+
215+
regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, &reg);
216+
217+
return ((reg & clk) == enval) ? 1 : 0;
218+
}
219+
208220
static int aspeed_clk_enable(struct clk_hw *hw)
209221
{
210222
struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw);
@@ -215,6 +227,11 @@ static int aspeed_clk_enable(struct clk_hw *hw)
215227

216228
spin_lock_irqsave(gate->lock, flags);
217229

230+
if (aspeed_clk_is_enabled(hw)) {
231+
spin_unlock_irqrestore(gate->lock, flags);
232+
return 0;
233+
}
234+
218235
if (gate->reset_idx >= 0) {
219236
/* Put IP in reset */
220237
regmap_update_bits(gate->map, ASPEED_RESET_CTRL, rst, rst);
@@ -255,17 +272,6 @@ static void aspeed_clk_disable(struct clk_hw *hw)
255272
spin_unlock_irqrestore(gate->lock, flags);
256273
}
257274

258-
static int aspeed_clk_is_enabled(struct clk_hw *hw)
259-
{
260-
struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw);
261-
u32 clk = BIT(gate->clock_idx);
262-
u32 reg;
263-
264-
regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, &reg);
265-
266-
return (reg & clk) ? 0 : 1;
267-
}
268-
269275
static const struct clk_ops aspeed_clk_gate_ops = {
270276
.enable = aspeed_clk_enable,
271277
.disable = aspeed_clk_disable,

drivers/clk/clk.c

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,10 @@ static int clk_core_round_rate_nolock(struct clk_core *core,
11251125
{
11261126
lockdep_assert_held(&prepare_lock);
11271127

1128-
if (!core)
1128+
if (!core) {
1129+
req->rate = 0;
11291130
return 0;
1131+
}
11301132

11311133
clk_core_init_rate_req(core, req);
11321134

@@ -2309,8 +2311,11 @@ static int clk_core_set_phase_nolock(struct clk_core *core, int degrees)
23092311

23102312
trace_clk_set_phase(core, degrees);
23112313

2312-
if (core->ops->set_phase)
2314+
if (core->ops->set_phase) {
23132315
ret = core->ops->set_phase(core->hw, degrees);
2316+
if (!ret)
2317+
core->phase = degrees;
2318+
}
23142319

23152320
trace_clk_set_phase_complete(core, degrees);
23162321

@@ -2967,23 +2972,38 @@ static int __clk_core_init(struct clk_core *core)
29672972
rate = 0;
29682973
core->rate = core->req_rate = rate;
29692974

2975+
/*
2976+
* Enable CLK_IS_CRITICAL clocks so newly added critical clocks
2977+
* don't get accidentally disabled when walking the orphan tree and
2978+
* reparenting clocks
2979+
*/
2980+
if (core->flags & CLK_IS_CRITICAL) {
2981+
unsigned long flags;
2982+
2983+
clk_core_prepare(core);
2984+
2985+
flags = clk_enable_lock();
2986+
clk_core_enable(core);
2987+
clk_enable_unlock(flags);
2988+
}
2989+
29702990
/*
29712991
* walk the list of orphan clocks and reparent any that newly finds a
29722992
* parent.
29732993
*/
29742994
hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
29752995
struct clk_core *parent = __clk_init_parent(orphan);
2976-
unsigned long flags;
29772996

29782997
/*
2979-
* we could call __clk_set_parent, but that would result in a
2980-
* redundant call to the .set_rate op, if it exists
2998+
* We need to use __clk_set_parent_before() and _after() to
2999+
* to properly migrate any prepare/enable count of the orphan
3000+
* clock. This is important for CLK_IS_CRITICAL clocks, which
3001+
* are enabled during init but might not have a parent yet.
29813002
*/
29823003
if (parent) {
29833004
/* update the clk tree topology */
2984-
flags = clk_enable_lock();
2985-
clk_reparent(orphan, parent);
2986-
clk_enable_unlock(flags);
3005+
__clk_set_parent_before(orphan, parent);
3006+
__clk_set_parent_after(orphan, parent, NULL);
29873007
__clk_recalc_accuracies(orphan);
29883008
__clk_recalc_rates(orphan, 0);
29893009
}
@@ -3000,16 +3020,6 @@ static int __clk_core_init(struct clk_core *core)
30003020
if (core->ops->init)
30013021
core->ops->init(core->hw);
30023022

3003-
if (core->flags & CLK_IS_CRITICAL) {
3004-
unsigned long flags;
3005-
3006-
clk_core_prepare(core);
3007-
3008-
flags = clk_enable_lock();
3009-
clk_core_enable(core);
3010-
clk_enable_unlock(flags);
3011-
}
3012-
30133023
kref_init(&core->ref);
30143024
out:
30153025
clk_pm_runtime_put(core);

drivers/clk/hisilicon/clk-hi3660-stub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ static int hi3660_stub_clk_probe(struct platform_device *pdev)
149149
return PTR_ERR(stub_clk_chan.mbox);
150150

151151
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
152+
if (!res)
153+
return -EINVAL;
152154
freq_reg = devm_ioremap(dev, res->start, resource_size(res));
153155
if (!freq_reg)
154156
return -ENOMEM;

drivers/clk/imx/clk-imx51-imx53.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,17 @@ static const char *ieee1588_sels[] = { "pll3_sw", "pll4_sw", "dummy" /* usbphy2_
131131
static struct clk *clk[IMX5_CLK_END];
132132
static struct clk_onecell_data clk_data;
133133

134-
static struct clk ** const uart_clks[] __initconst = {
134+
static struct clk ** const uart_clks_mx51[] __initconst = {
135+
&clk[IMX5_CLK_UART1_IPG_GATE],
136+
&clk[IMX5_CLK_UART1_PER_GATE],
137+
&clk[IMX5_CLK_UART2_IPG_GATE],
138+
&clk[IMX5_CLK_UART2_PER_GATE],
139+
&clk[IMX5_CLK_UART3_IPG_GATE],
140+
&clk[IMX5_CLK_UART3_PER_GATE],
141+
NULL
142+
};
143+
144+
static struct clk ** const uart_clks_mx50_mx53[] __initconst = {
135145
&clk[IMX5_CLK_UART1_IPG_GATE],
136146
&clk[IMX5_CLK_UART1_PER_GATE],
137147
&clk[IMX5_CLK_UART2_IPG_GATE],
@@ -321,8 +331,6 @@ static void __init mx5_clocks_common_init(void __iomem *ccm_base)
321331
clk_prepare_enable(clk[IMX5_CLK_TMAX1]);
322332
clk_prepare_enable(clk[IMX5_CLK_TMAX2]); /* esdhc2, fec */
323333
clk_prepare_enable(clk[IMX5_CLK_TMAX3]); /* esdhc1, esdhc4 */
324-
325-
imx_register_uart_clocks(uart_clks);
326334
}
327335

328336
static void __init mx50_clocks_init(struct device_node *np)
@@ -388,6 +396,8 @@ static void __init mx50_clocks_init(struct device_node *np)
388396

389397
r = clk_round_rate(clk[IMX5_CLK_USBOH3_PER_GATE], 54000000);
390398
clk_set_rate(clk[IMX5_CLK_USBOH3_PER_GATE], r);
399+
400+
imx_register_uart_clocks(uart_clks_mx50_mx53);
391401
}
392402
CLK_OF_DECLARE(imx50_ccm, "fsl,imx50-ccm", mx50_clocks_init);
393403

@@ -477,6 +487,8 @@ static void __init mx51_clocks_init(struct device_node *np)
477487
val = readl(MXC_CCM_CLPCR);
478488
val |= 1 << 23;
479489
writel(val, MXC_CCM_CLPCR);
490+
491+
imx_register_uart_clocks(uart_clks_mx51);
480492
}
481493
CLK_OF_DECLARE(imx51_ccm, "fsl,imx51-ccm", mx51_clocks_init);
482494

@@ -606,5 +618,7 @@ static void __init mx53_clocks_init(struct device_node *np)
606618

607619
r = clk_round_rate(clk[IMX5_CLK_USBOH3_PER_GATE], 54000000);
608620
clk_set_rate(clk[IMX5_CLK_USBOH3_PER_GATE], r);
621+
622+
imx_register_uart_clocks(uart_clks_mx50_mx53);
609623
}
610624
CLK_OF_DECLARE(imx53_ccm, "fsl,imx53-ccm", mx53_clocks_init);

drivers/clk/qcom/apcs-msm8916.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev)
4949
struct clk_regmap_mux_div *a53cc;
5050
struct regmap *regmap;
5151
struct clk_init_data init = { };
52-
int ret;
52+
int ret = -ENODEV;
5353

5454
regmap = dev_get_regmap(parent, NULL);
55-
if (IS_ERR(regmap)) {
56-
ret = PTR_ERR(regmap);
55+
if (!regmap) {
5756
dev_err(dev, "failed to get regmap: %d\n", ret);
5857
return ret;
5958
}

drivers/clk/sunxi-ng/ccu-sun6i-a31.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ static struct ccu_mp out_a_clk = {
762762
.features = CCU_FEATURE_FIXED_PREDIV,
763763
.hw.init = CLK_HW_INIT_PARENTS("out-a",
764764
clk_out_parents,
765-
&ccu_div_ops,
765+
&ccu_mp_ops,
766766
0),
767767
},
768768
};
@@ -783,7 +783,7 @@ static struct ccu_mp out_b_clk = {
783783
.features = CCU_FEATURE_FIXED_PREDIV,
784784
.hw.init = CLK_HW_INIT_PARENTS("out-b",
785785
clk_out_parents,
786-
&ccu_div_ops,
786+
&ccu_mp_ops,
787787
0),
788788
},
789789
};
@@ -804,7 +804,7 @@ static struct ccu_mp out_c_clk = {
804804
.features = CCU_FEATURE_FIXED_PREDIV,
805805
.hw.init = CLK_HW_INIT_PARENTS("out-c",
806806
clk_out_parents,
807-
&ccu_div_ops,
807+
&ccu_mp_ops,
808808
0),
809809
},
810810
};

drivers/clk/ti/clk-33xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static const struct omap_clkctrl_bit_data am3_gpio4_bit_data[] __initconst = {
4545

4646
static const struct omap_clkctrl_reg_data am3_l4_per_clkctrl_regs[] __initconst = {
4747
{ AM3_CPGMAC0_CLKCTRL, NULL, CLKF_SW_SUP, "cpsw_125mhz_gclk", "cpsw_125mhz_clkdm" },
48-
{ AM3_LCDC_CLKCTRL, NULL, CLKF_SW_SUP, "lcd_gclk", "lcdc_clkdm" },
48+
{ AM3_LCDC_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_SET_RATE_PARENT, "lcd_gclk", "lcdc_clkdm" },
4949
{ AM3_USB_OTG_HS_CLKCTRL, NULL, CLKF_SW_SUP, "usbotg_fck", "l3s_clkdm" },
5050
{ AM3_TPTC0_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk", "l3_clkdm" },
5151
{ AM3_EMIF_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_ddr_m2_div2_ck", "l3_clkdm" },

drivers/clk/ti/clk-43xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static const struct omap_clkctrl_reg_data am4_l4_per_clkctrl_regs[] __initconst
187187
{ AM4_OCP2SCP0_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
188188
{ AM4_OCP2SCP1_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
189189
{ AM4_EMIF_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_ddr_m2_ck", "emif_clkdm" },
190-
{ AM4_DSS_CORE_CLKCTRL, NULL, CLKF_SW_SUP, "disp_clk", "dss_clkdm" },
190+
{ AM4_DSS_CORE_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_SET_RATE_PARENT, "disp_clk", "dss_clkdm" },
191191
{ AM4_CPGMAC0_CLKCTRL, NULL, CLKF_SW_SUP, "cpsw_125mhz_gclk", "cpsw_125mhz_clkdm" },
192192
{ 0 },
193193
};

drivers/clk/ti/clkctrl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
537537
init.parent_names = &reg_data->parent;
538538
init.num_parents = 1;
539539
init.flags = 0;
540+
if (reg_data->flags & CLKF_SET_RATE_PARENT)
541+
init.flags |= CLK_SET_RATE_PARENT;
540542
init.name = kasprintf(GFP_KERNEL, "%s:%s:%04x:%d",
541543
node->parent->name, node->name,
542544
reg_data->offset, 0);

0 commit comments

Comments
 (0)