Re: [PATCH v5 9/9] crypto: caam - add crypto_engine support for HASH algorithms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/30/2020 2:49 AM, Iuliana Prodan wrote:
> @@ -123,6 +128,9 @@ struct caam_export_state {
>  	int (*update)(struct ahash_request *req);
>  	int (*final)(struct ahash_request *req);
>  	int (*finup)(struct ahash_request *req);
> +	struct ahash_edesc *edesc;
> +	void (*ahash_op_done)(struct device *jrdev, u32 *desc, u32 err,
> +			      void *context);
These members are used internally by the driver,
during ahash request processing.
They are recomputed each time a new request is received.

This means .import/.export callbacks don't have to deal with them.

>  /* submit ahash update if it the first job descriptor after update */
> @@ -1209,9 +1280,8 @@ static int ahash_update_no_ctx(struct ahash_request *req)
>  				     DUMP_PREFIX_ADDRESS, 16, 4, desc,
>  				     desc_bytes(desc), 1);
>  
> -		ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_dst, req);
> -		if (ret != -EINPROGRESS)
> -			goto unmap_ctx;
> +		ret = ahash_enqueue_req(jrdev, ahash_done_ctx_dst, req,
> +					ctx->ctx_len, DMA_TO_DEVICE);
In case ahash_enqueue_req() fails, driver's callbacks state machine
changes since the code falls through.

>  
>  		state->update = ahash_update_ctx;
>  		state->finup = ahash_finup_ctx;

> @@ -1394,9 +1459,8 @@ static int ahash_update_first(struct ahash_request *req)
>  				     DUMP_PREFIX_ADDRESS, 16, 4, desc,
>  				     desc_bytes(desc), 1);
>  
> -		ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_dst, req);
> -		if (ret != -EINPROGRESS)
> -			goto unmap_ctx;
> +		ret = ahash_enqueue_req(jrdev, ahash_done_ctx_dst, req,
> +					ctx->ctx_len, DMA_TO_DEVICE);
Same here.

>  
>  		state->update = ahash_update_ctx;
>  		state->finup = ahash_finup_ctx;

> @@ -1752,7 +1820,9 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
>  	}
>  
>  	dma_addr = dma_map_single_attrs(ctx->jrdev, ctx->sh_desc_update,
> -					offsetof(struct caam_hash_ctx, key),
> +					offsetof(struct caam_hash_ctx, key) -
> +					offsetof(struct caam_hash_ctx,
> +						 sh_desc_update),
>  					ctx->dir, DMA_ATTR_SKIP_CPU_SYNC);
>  	if (dma_mapping_error(ctx->jrdev, dma_addr)) {
>  		dev_err(ctx->jrdev, "unable to map shared descriptors\n");
> @@ -1770,11 +1840,19 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
>  	ctx->sh_desc_update_dma = dma_addr;
>  	ctx->sh_desc_update_first_dma = dma_addr +
>  					offsetof(struct caam_hash_ctx,
> -						 sh_desc_update_first);
> +						 sh_desc_update_first) -
> +					offsetof(struct caam_hash_ctx,
> +						 sh_desc_update);
>  	ctx->sh_desc_fin_dma = dma_addr + offsetof(struct caam_hash_ctx,
> -						   sh_desc_fin);
> +						   sh_desc_fin) -
> +					  offsetof(struct caam_hash_ctx,
> +						   sh_desc_update);
>  	ctx->sh_desc_digest_dma = dma_addr + offsetof(struct caam_hash_ctx,
> -						      sh_desc_digest);
> +						      sh_desc_digest) -
> +					     offsetof(struct caam_hash_ctx,
> +						      sh_desc_update);
offsetof(struct caam_hash_ctx, sh_desc_update) is used several times,
it deserves a local variable.

Horia




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux