Re: [PATCH v5 23/23] Documentation: EM: Update with runtime modification design

Lukasz Luba
2023-12-19T08:46:04Z

On 12/19/23 04:42, Xuewen Yan wrote:
> On Wed, Nov 29, 2023 at 7:11 PM Lukasz Luba <lukasz.luba@arm.com> wrote:

[snip]

>> +
>> + -> drivers/soc/example/example_em_mod.c
>> +
>> + 01 static void foo_get_new_em(struct device *dev)
>> + 02 {
>> + 03 struct em_perf_table __rcu *runtime_table;
>> + 04 struct em_perf_state *table, *new_table;
>> + 05 struct em_perf_domain *pd;
>> + 06 unsigned long freq;
>> + 07 int i, ret;
>> + 08
>> + 09 pd = em_pd_get(dev);
>> + 10 if (!pd)
>> + 11 return;
>> + 12
>> + 13 runtime_table = em_allocate_table(pd);
>> + 14 if (!runtime_table)
>> + 15 return;
>> + 16
>> + 17 new_table = runtime_table->state;
>> + 18
>> + 19 table = em_get_table(pd);
>> + 20 for (i = 0; i < pd->nr_perf_states; i++) {
>> + 21 freq = table[i].frequency;
>> + 22 foo_get_power_perf_values(dev, freq, &new_table[i]);
>> + 23 }
>> + 24 em_put_table();
>> + 25
>> + 26 /* Calculate 'cost' values for EAS */
>> + 27 ret = em_dev_compute_costs(dev, table, pd->nr_perf_states);
>> + 28 if (ret) {
>> + 29 dev_warn(dev, "EM: compute costs failed %d\n", ret);
>> + 30 em_free_table(runtime_table);
>> + 31 return;
>> + 32 }
>> + 33
>> + 34 ret = em_dev_update_perf_domain(dev, runtime_table);
>> + 35 if (ret) {
>> + 36 dev_warn(dev, "EM: update failed %d\n", ret);
>> + 37 em_free_table(runtime_table);
>> + 38 return;
>> + 39 }
>> + 40
>> + 41 ctx->runtime_table = runtime_table;
>
> Because here is ctx, maybe the foo_get_new_em(struct device *dev)
> shoule be foo_get_new_em(struct foo_context *ctx)?

Make sense, I will change that bit. Thanks!