Re: [PATCH RFC] crypto: caam - never share the gcm and skcipher descriptors serially

From: Sahil Malhotra

Date: Thu Nov 12 2026 - 05:47:06 EST


On Mon, Nov 09, 2026 at 12:42:54AM +0100, Vincent Jardin wrote:
> The gcm and skcipher shared descriptors were built with HDR_SHARE_SERIAL,
> so the SEC runs the jobs of one key one after the other:
> it leads to about 4 Gbps per key on LX2160A, whatever the number of
> CPUs or queues. No hardware reason for this code has been found.
>
> From benchmarks, when built with HDR_SHARE_NEVER, the performance
> is much better and scales: for instance with one CPU, AES-128-GCM,
> the gains are:
> - 325 -> 592 MB/s at 1420 B
> - 498 -> 6283 MB/s at 16 KiB

Hi Vincent,

Thanks for the patch and the numbers. They are LX2160A only, but this
change affects every CAAM user, and most CAAM instances look very
different from LX2160A.

Some CAAM-based SoCs have a single DECO, and others only 2-3.
On a single-DECO CAAM, SERIAL sharing is the best case: consecutive
same-key jobs self-share in the one DECO and keep the class 1/2 keys
(and context, with SC). NEVER cannot add any parallelism
there. It only adds a shared descriptor refetch, a key reload, and the
AES decrypt-key derivation again. So I would expect a small regression on
those parts, worst for small packets.

So this needs to be tested on other platforms before it can go in.
If you have numbers on other SoCs with fewer DECOs, that would be
helpful. We can also run it on i.MX boards on our side, if you don't
have access to other boards.

If the regression shows up, one option is to pick the share mode at
probe time from CHA_NUM_MS[DECO_NUM]: NEVER only when there is more than
one DECO, SERIAL otherwise.

On the commit message: "No hardware reason for this code has been
found" is not quite right. SERIAL is a deliberate key-reuse trade-off
that suits few-DECO parts. Please reword the log so it describes a
trade-off.

> - init_sh_desc(desc, HDR_SHARE_SERIAL);
> + init_sh_desc(desc, HDR_SHARE_NEVER);

Do you have similar numbers for authenc and xts, since they use the
same kind of descriptors?

> - init_sh_desc(desc, HDR_SHARE_SERIAL | HDR_SAVECTX);
> + init_sh_desc(desc, HDR_SHARE_NEVER | HDR_SAVECTX);
> /* Skip if already shared */
> key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
> JUMP_COND_SHRD);

With NEVER, the JUMP_COND_SHRD key-skip and HDR_SAVECTX become dead
code (as the bot noted).

Thanks,
Sahil