Re: [PATCH] crypto: caam/qi - simplify CGR allocation, freeing

From: Sebastian Andrzej Siewior
Date: Tue Oct 09 2018 - 13:11:21 EST


On 2018-10-08 14:09:37 [+0300], Horia GeantÄ wrote:
> CGRs (Congestion Groups) have to be freed by the same CPU that
> initialized them.
> This is why currently the driver takes special measures; however, using
> set_cpus_allowed_ptr() is incorrect - as reported by Sebastian.
>
> Instead of the generic solution of replacing set_cpus_allowed_ptr() with
> work_on_cpu_safe(), we use the qman_delete_cgr_safe() QBMan API instead
> of qman_delete_cgr() - which internally takes care of proper CGR
> deletion.
>
> Link: https://lkml.kernel.org/r/20181005125443.dfhd2asqktm22ney@xxxxxxxxxxxxx
> Reported-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> Signed-off-by: Horia GeantÄ <horia.geanta@xxxxxxx>

Oh. No more usage of set_cpus_allowed_ptr(). Wonderful. Thank you.
Acked-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
for that.

Now that you shifted my attention to qman_delete_cgr_safe().
Could you please use work_on_cpu_safe() here instead
smp_call_function_single() with preempt_disable() around it?

Now, what is the problem with the CPU limitation? Is this a HW
limitation that you can access the registers from a certain CPU?

This still fails (silently) if the CPU is missing, right? If you can't
get around it, you could block the CPU from going offline. You could
register a HP notifier
cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, â

and the function would return -EINVAL if this is the special CPU. The
other thing would be forbid rmmod. This *could* work but if I remember
correctly, an explicit unbind can't be stopped.

Sebastian