crypto: rockchip: core: modify buffer addr_vir size to 8 PAGES

Increase the buffer size from 1 to 8 pages. Data can be copied to
 the buffer for hardware crypto calculation when the scatter list
 does not meet the alignment requirement and data length less than
 8 pages.

Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com>
Change-Id: Id5e36f4fa7fc042ea4d117071ae9fee16ebb3494
This commit is contained in:
Lin Jinhan
2021-11-09 11:00:47 +08:00
parent a548b4bb5b
commit b9eca4f12e
2 changed files with 11 additions and 4 deletions

View File

@@ -169,8 +169,8 @@ static int rk_load_data(struct rk_crypto_dev *rk_dev,
alg_ctx->addr_out = sg_dma_address(sg_dst);
}
} else {
count = (alg_ctx->left_bytes > PAGE_SIZE) ?
PAGE_SIZE : alg_ctx->left_bytes;
count = (alg_ctx->left_bytes > rk_dev->vir_max) ?
rk_dev->vir_max : alg_ctx->left_bytes;
if (!sg_pcopy_to_buffer(alg_ctx->req_src, alg_ctx->src_nents,
rk_dev->addr_vir, count,
@@ -674,13 +674,15 @@ static int rk_crypto_probe(struct platform_device *pdev)
goto err_crypto;
}
rk_dev->addr_vir = (char *)__get_free_page(GFP_KERNEL);
rk_dev->addr_vir = (void *)__get_free_pages(GFP_KERNEL, RK_BUFFER_ORDER);
if (!rk_dev->addr_vir) {
err = -ENOMEM;
dev_err(dev, "__get_free_page failed.\n");
goto err_crypto;
}
rk_dev->vir_max = RK_BUFFER_SIZE;
platform_set_drvdata(pdev, rk_dev);
tasklet_init(&rk_dev->queue_task,
@@ -724,7 +726,7 @@ static int rk_crypto_remove(struct platform_device *pdev)
tasklet_kill(&rk_dev->queue_task);
if (rk_dev->addr_vir)
free_page((unsigned long)rk_dev->addr_vir);
free_pages((unsigned long)rk_dev->addr_vir, RK_BUFFER_ORDER);
rk_dev->soc_data->hw_deinit(&pdev->dev, rk_dev->hw_info);

View File

@@ -35,6 +35,10 @@
#define RK_CRYPTO_PRIORITY 300
/* Increase the addr_vir buffer size from 1 to 8 pages */
#define RK_BUFFER_ORDER 3
#define RK_BUFFER_SIZE (PAGE_SIZE << RK_BUFFER_ORDER)
struct rk_crypto_soc_data {
char **valid_algs_name;
int valid_algs_num;
@@ -71,6 +75,7 @@ struct rk_crypto_dev {
/* the public variable */
struct crypto_async_request *async_req;
void *addr_vir;
u32 vir_max;
bool busy;
void (*request_crypto)(struct rk_crypto_dev *rk_dev, const char *name);