Re: [PATCH v12 2/4] crypto: spacc - Add SPAcc ahash support

From: Herbert Xu

Date: Mon May 04 2026 - 23:32:08 EST


On Thu, Apr 16, 2026 at 12:14:49PM +0530, Pavitrakumar Managutte wrote:
>
> +/*
> + * Allocate a job for spacc module context and initialize
> + * it with an appropriate type.
> + */
> +int spacc_open(struct spacc_device *spacc, int enc, int hash, int ctxid,
> + int secure_mode, spacc_callback cb, void *cbdata)
> +{
> + size_t i;
> + int ret = 0;
> + u32 ctrl = 0;
> + int job_idx = 0;
> + bool ctx_reused = false;
> + struct spacc_job *job = NULL;
> + const struct enc_config *enc_cfg = NULL;
> + const struct hash_config *hash_cfg = NULL;
> + unsigned long flags;
> +
> + /*
> + * Acquire the semaphore. This will decrement the count. If the count
> + * is already zero (meaning all HW contexts are in use), this call
> + * will sleep interruptibly until another thread calls up().
> + */
> + if (down_interruptible(&spacc->ctx_sem)) {
> + dev_dbg(spacc->dptr, "ERR: Interrupted by signal\n");
> + return -ERESTARTSYS; /* Woken by a signal */
> + }

This may sleep. While we used to allow sleeping in setkey, this
is being phased out so new drivers should not do that.

This also raises the question of whether spacc_open should even
be called from setkey. The setkey call could be very far away
from the actual hash processing, so allocating a handle in setkey
seems to be a waste.

As you can allocate handles from do_one_request, why not just do
that always?

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt