linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Gilad Ben-Yossef <gilad@benyossef.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S . Miller" <davem@davemloft.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	linux-crypto@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH v2 20/34] crypto: ccree - remove struct buff_mgr_handle
Date: Tue, 11 Feb 2020 19:19:14 +0100	[thread overview]
Message-ID: <20200211181928.15178-21-geert+renesas@glider.be> (raw)
In-Reply-To: <20200211181928.15178-1-geert+renesas@glider.be>

The buff_mgr_handle structure contains only a single member, and only
one instance exists.  Simplify the code and reduce memory consumption by
moving this member to struct cc_drvdata.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_buffer_mgr.c | 41 ++++++----------------------
 drivers/crypto/ccree/cc_driver.h     |  2 +-
 2 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c
index abf08369f030faa8..f2e782d2be155ee4 100644
--- a/drivers/crypto/ccree/cc_buffer_mgr.c
+++ b/drivers/crypto/ccree/cc_buffer_mgr.c
@@ -19,10 +19,6 @@ enum dma_buffer_type {
 	DMA_BUFF_TYPE = 2,
 };
 
-struct buff_mgr_handle {
-	struct dma_pool *mlli_buffs_pool;
-};
-
 union buffer_array_entry {
 	struct scatterlist *sgl;
 	dma_addr_t buffer_dma;
@@ -402,7 +398,6 @@ int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx,
 {
 	struct cipher_req_ctx *req_ctx = (struct cipher_req_ctx *)ctx;
 	struct mlli_params *mlli_params = &req_ctx->mlli_params;
-	struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
 	struct device *dev = drvdata_to_dev(drvdata);
 	struct buffer_array sg_data;
 	u32 dummy = 0;
@@ -466,7 +461,7 @@ int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx,
 	}
 
 	if (req_ctx->dma_buf_type == CC_DMA_BUF_MLLI) {
-		mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
+		mlli_params->curr_pool = drvdata->mlli_buffs_pool;
 		rc = cc_generate_mlli(dev, &sg_data, mlli_params, flags);
 		if (rc)
 			goto cipher_exit;
@@ -1007,7 +1002,6 @@ int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req)
 	struct device *dev = drvdata_to_dev(drvdata);
 	struct buffer_array sg_data;
 	unsigned int authsize = areq_ctx->req_authsize;
-	struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
 	int rc = 0;
 	struct crypto_aead *tfm = crypto_aead_reqtfm(req);
 	bool is_gcm4543 = areq_ctx->is_gcm4543;
@@ -1180,7 +1174,7 @@ int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req)
 	 */
 	if (areq_ctx->assoc_buff_type == CC_DMA_BUF_MLLI ||
 	    areq_ctx->data_buff_type == CC_DMA_BUF_MLLI) {
-		mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
+		mlli_params->curr_pool = drvdata->mlli_buffs_pool;
 		rc = cc_generate_mlli(dev, &sg_data, mlli_params, flags);
 		if (rc)
 			goto aead_map_failure;
@@ -1208,7 +1202,6 @@ int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx,
 	u32 *curr_buff_cnt = cc_hash_buf_cnt(areq_ctx);
 	struct mlli_params *mlli_params = &areq_ctx->mlli_params;
 	struct buffer_array sg_data;
-	struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
 	int rc = 0;
 	u32 dummy = 0;
 	u32 mapped_nents = 0;
@@ -1255,7 +1248,7 @@ int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx,
 
 	/*build mlli */
 	if (areq_ctx->data_dma_buf_type == CC_DMA_BUF_MLLI) {
-		mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
+		mlli_params->curr_pool = drvdata->mlli_buffs_pool;
 		/* add the src data to the sg_data */
 		cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, nbytes,
 				0, true, &areq_ctx->mlli_nents);
@@ -1293,7 +1286,6 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx,
 	unsigned int update_data_len;
 	u32 total_in_len = nbytes + *curr_buff_cnt;
 	struct buffer_array sg_data;
-	struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
 	unsigned int swap_index = 0;
 	int rc = 0;
 	u32 dummy = 0;
@@ -1368,7 +1360,7 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx,
 	}
 
 	if (areq_ctx->data_dma_buf_type == CC_DMA_BUF_MLLI) {
-		mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
+		mlli_params->curr_pool = drvdata->mlli_buffs_pool;
 		/* add the src data to the sg_data */
 		cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src,
 				(update_data_len - *curr_buff_cnt), 0, true,
@@ -1435,39 +1427,22 @@ void cc_unmap_hash_request(struct device *dev, void *ctx,
 
 int cc_buffer_mgr_init(struct cc_drvdata *drvdata)
 {
-	struct buff_mgr_handle *buff_mgr_handle;
 	struct device *dev = drvdata_to_dev(drvdata);
 
-	buff_mgr_handle = kmalloc(sizeof(*buff_mgr_handle), GFP_KERNEL);
-	if (!buff_mgr_handle)
-		return -ENOMEM;
-
-	drvdata->buff_mgr_handle = buff_mgr_handle;
-
-	buff_mgr_handle->mlli_buffs_pool =
+	drvdata->mlli_buffs_pool =
 		dma_pool_create("dx_single_mlli_tables", dev,
 				MAX_NUM_OF_TOTAL_MLLI_ENTRIES *
 				LLI_ENTRY_BYTE_SIZE,
 				MLLI_TABLE_MIN_ALIGNMENT, 0);
 
-	if (!buff_mgr_handle->mlli_buffs_pool)
-		goto error;
+	if (!drvdata->mlli_buffs_pool)
+		return -ENOMEM;
 
 	return 0;
-
-error:
-	cc_buffer_mgr_fini(drvdata);
-	return -ENOMEM;
 }
 
 int cc_buffer_mgr_fini(struct cc_drvdata *drvdata)
 {
-	struct buff_mgr_handle *buff_mgr_handle = drvdata->buff_mgr_handle;
-
-	if (buff_mgr_handle) {
-		dma_pool_destroy(buff_mgr_handle->mlli_buffs_pool);
-		kfree(drvdata->buff_mgr_handle);
-		drvdata->buff_mgr_handle = NULL;
-	}
+	dma_pool_destroy(drvdata->mlli_buffs_pool);
 	return 0;
 }
diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h
index 7360b403655c96f7..4895f124d2b83fb1 100644
--- a/drivers/crypto/ccree/cc_driver.h
+++ b/drivers/crypto/ccree/cc_driver.h
@@ -140,7 +140,7 @@ struct cc_drvdata {
 	struct completion hw_queue_avail; /* wait for HW queue availability */
 	struct platform_device *plat_dev;
 	u32 mlli_sram_addr;
-	void *buff_mgr_handle;
+	struct dma_pool *mlli_buffs_pool;
 	void *cipher_handle;
 	void *hash_handle;
 	void *aead_handle;
-- 
2.17.1


  parent reply	other threads:[~2020-02-11 18:20 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 01/34] debugfs: regset32: Add Runtime PM support Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 02/34] crypto: ccree - fix debugfs register access while suspended Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 03/34] crypto: ccree - fix retry handling in cc_send_sync_request() Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 04/34] crypto: ccree - remove unneeded casts Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 05/34] crypto: ccree - swap SHA384 and SHA512 larval hashes at build time Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 06/34] crypto: ccree - drop duplicated error message on SRAM exhaustion Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 07/34] crypto: ccree - remove empty cc_sram_mgr_fini() Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 08/34] crypto: ccree - clean up clock handling Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 09/34] crypto: ccree - make mlli_params.mlli_virt_addr void * Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 10/34] crypto: ccree - use existing helpers to split 64-bit addresses Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 11/34] crypto: ccree - defer larval_digest_addr init until needed Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 12/34] crypto: ccree - remove bogus paragraph about freeing SRAM Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 13/34] crypto: ccree - use u32 for SRAM addresses Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 14/34] crypto: ccree - simplify Runtime PM handling Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 15/34] crypto: ccree - use of_device_get_match_data() Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 16/34] crypto: ccree - remove cc_pm_is_dev_suspended() wrapper Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 17/34] crypto: ccree - make cc_pm_{suspend,resume}() static Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 18/34] crypto: ccree - remove struct cc_sram_ctx Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 19/34] crypto: ccree - remove struct cc_debugfs_ctx Geert Uytterhoeven
2020-02-11 18:19 ` Geert Uytterhoeven [this message]
2020-02-11 18:19 ` [PATCH v2 21/34] crypto: ccree - remove struct cc_cipher_handle Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 22/34] crypto: ccree - extract cc_init_copy_sram() Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 23/34] crypto: ccree - remove bogus kerneldoc markers Geert Uytterhoeven
2020-02-11 18:44   ` Sergei Shtylyov
2020-02-11 18:19 ` [PATCH v2 24/34] crypto: ccree - improve kerneldoc in cc_hw_queue_defs.h Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 25/34] crypto: ccree - improve kerneldoc in cc_buffer_mgr.c Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 26/34] crypto: ccree - improve kerneldoc in cc_hash.[ch] Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 27/34] crypto: ccree - improve kerneldoc in cc_request_mgr.[ch] Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 28/34] crypto: ccree - improve kerneldoc in cc_sram_mgr.[ch] Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 29/34] crypto: ccree - spelling s/Crytpcell/Cryptocell/ Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 30/34] crypto: ccree - grammar s/not room/no room/ Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 31/34] crypto: ccree - use existing dev helper in init_cc_resources() Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 32/34] crypto: ccree - use devm_k[mz]alloc() for AEAD data Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 33/34] crypto: ccree - use devm_k[mz]alloc() for cipher data Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 34/34] crypto: ccree - use devm_kzalloc() for hash data Geert Uytterhoeven
     [not found] ` <CAOtvUMfs84VXAecVNShoEg-CU6APjyiVTUBkogpFq_c3fbaX+Q@mail.gmail.com>
2020-02-13  7:47   ` [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
2020-02-19 15:41     ` Gilad Ben-Yossef
2020-02-20 12:29 ` Gilad Ben-Yossef
2020-02-22  1:42 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200211181928.15178-21-geert+renesas@glider.be \
    --to=geert+renesas@glider.be \
    --cc=davem@davemloft.net \
    --cc=gilad@benyossef.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).