We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dc1c5b4 commit aca1a19Copy full SHA for aca1a19
3 files changed
bsp/rockchip/dm/clk/clk-rk-gate.h
@@ -27,6 +27,20 @@
27
.gate_flags = gf, \
28
}
29
30
+#define GATE_NO_SET_RATE(_id, cname, pname, f, o, b, gf) \
31
+(void *)&(struct rockchip_clk_cell) \
32
+{ \
33
+ .cell.name = cname, \
34
+ .cell.ops = &rockchip_gate_clk_ops, \
35
+ .cell.parent_name = pname, \
36
+ .cell.parents_nr = 1, \
37
+ .cell.flags = f | RT_CLK_F_SET_RATE_PARENT, \
38
+ .id = _id, \
39
+ .gate_offset = o, \
40
+ .gate_shift = b, \
41
+ .gate_flags = gf, \
42
+}
43
+
44
extern const struct rt_clk_ops rockchip_gate_clk_ops;
45
46
#endif /* __CLK_RK_GATE_H__ */
bsp/rockchip/dm/clk/clk-rk-half-divider.h
@@ -63,7 +63,7 @@ struct rockchip_half_divider_clk_cell
63
.rk_cell.init = rockchip_half_divider_clk_cell_init,\
64
65
66
-#define COMPOSITE_NOGATE_HALFDIV(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw, df) \
+#define COMPOSITE_NOGATE_HALFDIV(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw, df) \
67
(void *)&(struct rockchip_half_divider_clk_cell) \
68
{ \
69
.rk_cell.cell.name = cname, \
@@ -82,7 +82,8 @@ struct rockchip_half_divider_clk_cell
82
83
84
85
-#define COMPOSITE_NOMUX_HALFDIV(_id, cname, pname, f, mo, ds, dw, df, go, gs, gf) \
+#define COMPOSITE_NOMUX_HALFDIV(_id, cname, pname, f, mo, ds, dw, df, go, gs, gf) \
86
+(void *)&(struct rockchip_half_divider_clk_cell) \
87
88
89
.rk_cell.cell.parent_name = pname, \
components/drivers/clk/clk-scmi.c
@@ -230,7 +230,7 @@ static rt_err_t scmi_clk_probe(struct rt_scmi_device *sdev)
230
for (int id = 0; id < cell_count; ++id)
231
{
232
const char *clk_name;
233
- rt_uint32_t flags, rates_nr, rate_discrete;
+ rt_uint32_t flags, rate_discrete;
234
235
in.id = rt_cpu_to_le32(id);
236
in.rate_index = rt_cpu_to_le32(0);
@@ -242,7 +242,6 @@ static rt_err_t scmi_clk_probe(struct rt_scmi_device *sdev)
242
243
244
flags = rt_le32_to_cpu(out->num_rates_flags);
245
- rates_nr = SCMI_NUM_REMAINING(flags);
246
rate_discrete = SCMI_RATE_DISCRETE(flags);
247
248
if (rate_discrete)
@@ -263,12 +262,40 @@ static rt_err_t scmi_clk_probe(struct rt_scmi_device *sdev)
263
262
264
265
266
- for (int i = 0; i < rates_nr; ++i)
+ /*
+ * SCMI: [11:0] = rates in this message, [31:16] = remaining to query.
267
+ * Using REMAINING as the copy count overflows rates[] and corrupts heap.
268
+ */
269
+ int idx = 0;
270
271
+ for (;;)
272
- clk_data->info.list.rates[i] = SCMI_RATE_TO_U64(out->rate[i]);
273
+ rt_uint32_t nr = SCMI_NUM_RETURNED(flags);
274
+ rt_uint32_t remaining = SCMI_NUM_REMAINING(flags);
275
276
+ for (rt_uint32_t i = 0; i < nr && idx < SCMI_MAX_NUM_RATES; ++i, ++idx)
277
+ {
278
+ clk_data->info.list.rates[idx] = SCMI_RATE_TO_U64(out->rate[i]);
279
+ }
280
281
+ if (remaining == 0 || idx >= SCMI_MAX_NUM_RATES)
282
283
+ break;
284
285
286
+ in.rate_index = rt_cpu_to_le32(idx);
287
+ msg = RT_SCMI_MSG_RAW(SCMI_CLOCK_DESCRIBE_RATES, &in, sizeof(in), out, out_size);
288
289
+ if ((err = rt_scmi_process_msg(sclk->sdev, &msg)))
290
291
+ rt_free(clk_data);
292
+ goto _fail;
293
294
295
+ flags = rt_le32_to_cpu(out->num_rates_flags);
296
297
- clk_data->info.list.rates_nr = rates_nr;
298
+ clk_data->info.list.rates_nr = idx;
299
300
else
301
0 commit comments