diff options
| author | Ingo Molnar <mingo@kernel.org> | 2024-03-25 13:32:29 +0300 | 
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2024-03-25 13:32:29 +0300 | 
| commit | f4566a1e73957800df75a3dd2dccee8a4697f327 (patch) | |
| tree | b043b875228c0b25988af66c680d60cae69d761d /drivers/crypto/intel/iaa/iaa_crypto_main.c | |
| parent | b9e6e28663928cab836a19abbdec3d036a07db3b (diff) | |
| parent | 4cece764965020c22cff7665b18a012006359095 (diff) | |
| download | linux-f4566a1e73957800df75a3dd2dccee8a4697f327.tar.xz | |
Merge tag 'v6.9-rc1' into sched/core, to pick up fixes and to refresh the branch
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/crypto/intel/iaa/iaa_crypto_main.c')
| -rw-r--r-- | drivers/crypto/intel/iaa/iaa_crypto_main.c | 122 | 
1 files changed, 15 insertions, 107 deletions
diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c index dfd3baf0a8d8..1cd304de5388 100644 --- a/drivers/crypto/intel/iaa/iaa_crypto_main.c +++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c @@ -258,16 +258,14 @@ static void free_iaa_compression_mode(struct iaa_compression_mode *mode)  	kfree(mode->name);  	kfree(mode->ll_table);  	kfree(mode->d_table); -	kfree(mode->header_table);  	kfree(mode);  }  /* - * IAA Compression modes are defined by an ll_table, a d_table, and an - * optional header_table.  These tables are typically generated and - * captured using statistics collected from running actual - * compress/decompress workloads. + * IAA Compression modes are defined by an ll_table and a d_table. + * These tables are typically generated and captured using statistics + * collected from running actual compress/decompress workloads.   *   * A module or other kernel code can add and remove compression modes   * with a given name using the exported @add_iaa_compression_mode() @@ -315,9 +313,6 @@ EXPORT_SYMBOL_GPL(remove_iaa_compression_mode);   * @ll_table_size: The ll table size in bytes   * @d_table: The d table   * @d_table_size: The d table size in bytes - * @header_table: Optional header table - * @header_table_size: Optional header table size in bytes - * @gen_decomp_table_flags: Otional flags used to generate the decomp table   * @init: Optional callback function to init the compression mode data   * @free: Optional callback function to free the compression mode data   * @@ -330,9 +325,6 @@ int add_iaa_compression_mode(const char *name,  			     int ll_table_size,  			     const u32 *d_table,  			     int d_table_size, -			     const u8 *header_table, -			     int header_table_size, -			     u16 gen_decomp_table_flags,  			     iaa_dev_comp_init_fn_t init,  			     iaa_dev_comp_free_fn_t free)  { @@ -370,16 +362,6 @@ int add_iaa_compression_mode(const char *name,  		mode->d_table_size = d_table_size;  	} -	if (header_table) { -		mode->header_table = kzalloc(header_table_size, GFP_KERNEL); -		if (!mode->header_table) -			goto free; -		memcpy(mode->header_table, header_table, header_table_size); -		mode->header_table_size = header_table_size; -	} - -	mode->gen_decomp_table_flags = gen_decomp_table_flags; -  	mode->init = init;  	mode->free = free; @@ -420,10 +402,6 @@ static void free_device_compression_mode(struct iaa_device *iaa_device,  	if (device_mode->aecs_comp_table)  		dma_free_coherent(dev, size, device_mode->aecs_comp_table,  				  device_mode->aecs_comp_table_dma_addr); -	if (device_mode->aecs_decomp_table) -		dma_free_coherent(dev, size, device_mode->aecs_decomp_table, -				  device_mode->aecs_decomp_table_dma_addr); -  	kfree(device_mode);  } @@ -440,73 +418,6 @@ static int check_completion(struct device *dev,  			    bool compress,  			    bool only_once); -static int decompress_header(struct iaa_device_compression_mode *device_mode, -			     struct iaa_compression_mode *mode, -			     struct idxd_wq *wq) -{ -	dma_addr_t src_addr, src2_addr; -	struct idxd_desc *idxd_desc; -	struct iax_hw_desc *desc; -	struct device *dev; -	int ret = 0; - -	idxd_desc = idxd_alloc_desc(wq, IDXD_OP_BLOCK); -	if (IS_ERR(idxd_desc)) -		return PTR_ERR(idxd_desc); - -	desc = idxd_desc->iax_hw; - -	dev = &wq->idxd->pdev->dev; - -	src_addr = dma_map_single(dev, (void *)mode->header_table, -				  mode->header_table_size, DMA_TO_DEVICE); -	dev_dbg(dev, "%s: mode->name %s, src_addr %llx, dev %p, src %p, slen %d\n", -		__func__, mode->name, src_addr,	dev, -		mode->header_table, mode->header_table_size); -	if (unlikely(dma_mapping_error(dev, src_addr))) { -		dev_dbg(dev, "dma_map_single err, exiting\n"); -		ret = -ENOMEM; -		return ret; -	} - -	desc->flags = IAX_AECS_GEN_FLAG; -	desc->opcode = IAX_OPCODE_DECOMPRESS; - -	desc->src1_addr = (u64)src_addr; -	desc->src1_size = mode->header_table_size; - -	src2_addr = device_mode->aecs_decomp_table_dma_addr; -	desc->src2_addr = (u64)src2_addr; -	desc->src2_size = 1088; -	dev_dbg(dev, "%s: mode->name %s, src2_addr %llx, dev %p, src2_size %d\n", -		__func__, mode->name, desc->src2_addr, dev, desc->src2_size); -	desc->max_dst_size = 0; // suppressed output - -	desc->decompr_flags = mode->gen_decomp_table_flags; - -	desc->priv = 0; - -	desc->completion_addr = idxd_desc->compl_dma; - -	ret = idxd_submit_desc(wq, idxd_desc); -	if (ret) { -		pr_err("%s: submit_desc failed ret=0x%x\n", __func__, ret); -		goto out; -	} - -	ret = check_completion(dev, idxd_desc->iax_completion, false, false); -	if (ret) -		dev_dbg(dev, "%s: mode->name %s check_completion failed ret=%d\n", -			__func__, mode->name, ret); -	else -		dev_dbg(dev, "%s: mode->name %s succeeded\n", __func__, -			mode->name); -out: -	dma_unmap_single(dev, src_addr, 1088, DMA_TO_DEVICE); - -	return ret; -} -  static int init_device_compression_mode(struct iaa_device *iaa_device,  					struct iaa_compression_mode *mode,  					int idx, struct idxd_wq *wq) @@ -529,24 +440,11 @@ static int init_device_compression_mode(struct iaa_device *iaa_device,  	if (!device_mode->aecs_comp_table)  		goto free; -	device_mode->aecs_decomp_table = dma_alloc_coherent(dev, size, -							    &device_mode->aecs_decomp_table_dma_addr, GFP_KERNEL); -	if (!device_mode->aecs_decomp_table) -		goto free; -  	/* Add Huffman table to aecs */  	memset(device_mode->aecs_comp_table, 0, sizeof(*device_mode->aecs_comp_table));  	memcpy(device_mode->aecs_comp_table->ll_sym, mode->ll_table, mode->ll_table_size);  	memcpy(device_mode->aecs_comp_table->d_sym, mode->d_table, mode->d_table_size); -	if (mode->header_table) { -		ret = decompress_header(device_mode, mode, wq); -		if (ret) { -			pr_debug("iaa header decompression failed: ret=%d\n", ret); -			goto free; -		} -	} -  	if (mode->init) {  		ret = mode->init(device_mode);  		if (ret) @@ -1324,7 +1222,7 @@ static int iaa_compress(struct crypto_tfm *tfm,	struct acomp_req *req,  	*compression_crc = idxd_desc->iax_completion->crc; -	if (!ctx->async_mode) +	if (!ctx->async_mode || disable_async)  		idxd_free_desc(wq, idxd_desc);  out:  	return ret; @@ -1570,7 +1468,7 @@ static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,  	*dlen = req->dlen; -	if (!ctx->async_mode) +	if (!ctx->async_mode || disable_async)  		idxd_free_desc(wq, idxd_desc);  	/* Update stats */ @@ -1596,6 +1494,7 @@ static int iaa_comp_acompress(struct acomp_req *req)  	u32 compression_crc;  	struct idxd_wq *wq;  	struct device *dev; +	u64 start_time_ns;  	int order = -1;  	compression_ctx = crypto_tfm_ctx(tfm); @@ -1669,8 +1568,10 @@ static int iaa_comp_acompress(struct acomp_req *req)  		" req->dlen %d, sg_dma_len(sg) %d\n", dst_addr, nr_sgs,  		req->dst, req->dlen, sg_dma_len(req->dst)); +	start_time_ns = iaa_get_ts();  	ret = iaa_compress(tfm, req, wq, src_addr, req->slen, dst_addr,  			   &req->dlen, &compression_crc, disable_async); +	update_max_comp_delay_ns(start_time_ns);  	if (ret == -EINPROGRESS)  		return ret; @@ -1717,6 +1618,7 @@ static int iaa_comp_adecompress_alloc_dest(struct acomp_req *req)  	struct iaa_wq *iaa_wq;  	struct device *dev;  	struct idxd_wq *wq; +	u64 start_time_ns;  	int order = -1;  	cpu = get_cpu(); @@ -1773,8 +1675,10 @@ alloc_dest:  	dev_dbg(dev, "dma_map_sg, dst_addr %llx, nr_sgs %d, req->dst %p,"  		" req->dlen %d, sg_dma_len(sg) %d\n", dst_addr, nr_sgs,  		req->dst, req->dlen, sg_dma_len(req->dst)); +	start_time_ns = iaa_get_ts();  	ret = iaa_decompress(tfm, req, wq, src_addr, req->slen,  			     dst_addr, &req->dlen, true); +	update_max_decomp_delay_ns(start_time_ns);  	if (ret == -EOVERFLOW) {  		dma_unmap_sg(dev, req->dst, sg_nents(req->dst), DMA_FROM_DEVICE);  		req->dlen *= 2; @@ -1805,6 +1709,7 @@ static int iaa_comp_adecompress(struct acomp_req *req)  	int nr_sgs, cpu, ret = 0;  	struct iaa_wq *iaa_wq;  	struct device *dev; +	u64 start_time_ns;  	struct idxd_wq *wq;  	if (!iaa_crypto_enabled) { @@ -1864,8 +1769,10 @@ static int iaa_comp_adecompress(struct acomp_req *req)  		" req->dlen %d, sg_dma_len(sg) %d\n", dst_addr, nr_sgs,  		req->dst, req->dlen, sg_dma_len(req->dst)); +	start_time_ns = iaa_get_ts();  	ret = iaa_decompress(tfm, req, wq, src_addr, req->slen,  			     dst_addr, &req->dlen, false); +	update_max_decomp_delay_ns(start_time_ns);  	if (ret == -EINPROGRESS)  		return ret; @@ -1916,6 +1823,7 @@ static struct acomp_alg iaa_acomp_fixed_deflate = {  	.base			= {  		.cra_name		= "deflate",  		.cra_driver_name	= "deflate-iaa", +		.cra_flags		= CRYPTO_ALG_ASYNC,  		.cra_ctxsize		= sizeof(struct iaa_compression_ctx),  		.cra_module		= THIS_MODULE,  		.cra_priority		= IAA_ALG_PRIORITY,  | 
