Update source to Armbian-dev-202610.A311Y3
This commit is contained in:
@@ -156,23 +156,24 @@ int aml_sha_init(struct ahash_request *req)
|
||||
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
|
||||
struct aml_sha_ctx *tctx = crypto_ahash_ctx(tfm);
|
||||
struct aml_sha_reqctx *ctx = ahash_request_ctx(req);
|
||||
struct aml_sha_dev *dd = NULL;
|
||||
struct aml_sha_dev *tmp;
|
||||
|
||||
spin_lock_bh(&aml_sha.lock);
|
||||
if (!tctx->dd) {
|
||||
list_for_each_entry(tmp, &aml_sha.dev_list, list) {
|
||||
dd = tmp;
|
||||
break;
|
||||
if (aml_sha.dev_list.next && !list_empty(&aml_sha.dev_list)) {
|
||||
/* coverity[unreachable : SUPPRESS] */
|
||||
list_for_each_entry(tmp, &aml_sha.dev_list, list) {
|
||||
tctx->dd = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tctx->dd = dd;
|
||||
} else {
|
||||
dd = tctx->dd;
|
||||
}
|
||||
|
||||
spin_unlock_bh(&aml_sha.lock);
|
||||
|
||||
ctx->dd = dd;
|
||||
if (!tctx->dd)
|
||||
return -ENODEV;
|
||||
|
||||
ctx->dd = tctx->dd;
|
||||
|
||||
ctx->flags = 0;
|
||||
|
||||
@@ -196,7 +197,7 @@ int aml_sha_init(struct ahash_request *req)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx->hw_ctx = kzalloc(dd->hw_ctx_sz, GFP_ATOMIC | GFP_DMA);
|
||||
ctx->hw_ctx = kzalloc(ctx->dd->hw_ctx_sz, GFP_ATOMIC | GFP_DMA);
|
||||
if (!ctx->hw_ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -555,6 +556,9 @@ static void aml_sha_copy_ready_hash(struct ahash_request *req)
|
||||
if (!req->result)
|
||||
return;
|
||||
|
||||
if (!ctx || !ctx->hw_ctx)
|
||||
return;
|
||||
|
||||
if (ctx->flags & SHA_FLAGS_SHA1)
|
||||
memcpy(req->result, ctx->hw_ctx, SHA1_DIGEST_SIZE);
|
||||
else if (ctx->flags & SHA_FLAGS_SHA224)
|
||||
@@ -578,6 +582,9 @@ static int aml_sha_finish_hmac(struct ahash_request *req)
|
||||
u32 status = 0;
|
||||
int err = 0;
|
||||
|
||||
if (!ctx->hw_ctx || !dd->descriptor)
|
||||
return -EINVAL;
|
||||
|
||||
hw_ctx = dmam_alloc_coherent(dd->parent, dd->hw_ctx_sz,
|
||||
&hmac_hw_ctx, GFP_ATOMIC | GFP_DMA);
|
||||
if (!hw_ctx)
|
||||
@@ -586,16 +593,18 @@ static int aml_sha_finish_hmac(struct ahash_request *req)
|
||||
memcpy(hw_ctx, ctx->hw_ctx, dd->hw_ctx_sz);
|
||||
|
||||
key = kzalloc(tctx->keylen, GFP_ATOMIC | GFP_DMA);
|
||||
if (!key)
|
||||
if (!key) {
|
||||
dmam_free_coherent(dd->parent, dd->hw_ctx_sz, hw_ctx, hmac_hw_ctx);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(key, tctx->key, tctx->keylen);
|
||||
dma_key = dma_map_single(dd->parent, key,
|
||||
tctx->keylen, DMA_TO_DEVICE);
|
||||
if (dma_mapping_error(dd->parent, dma_key)) {
|
||||
dev_err(dd->dev, "mapping key addr failed: %d\n", tctx->keylen);
|
||||
dmam_free_coherent(dd->parent, dd->hw_ctx_sz,
|
||||
hw_ctx, hmac_hw_ctx);
|
||||
kfree(key);
|
||||
dmam_free_coherent(dd->parent, dd->hw_ctx_sz, hw_ctx, hmac_hw_ctx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -649,9 +658,11 @@ static int aml_sha_finish_hmac(struct ahash_request *req)
|
||||
err = -EINVAL;
|
||||
}
|
||||
aml_dma_debug(dd->descriptor, 2, "end hmac", dd->thread, dd->status, dd->dma);
|
||||
memcpy(ctx->hw_ctx, hw_ctx, dd->hw_ctx_sz);
|
||||
|
||||
dma_unmap_single(dd->parent, dma_key,
|
||||
tctx->keylen, DMA_TO_DEVICE);
|
||||
memcpy(ctx->hw_ctx, hw_ctx, dd->hw_ctx_sz);
|
||||
kfree(key);
|
||||
dmam_free_coherent(dd->parent, dd->hw_ctx_sz, hw_ctx, hmac_hw_ctx);
|
||||
|
||||
return err;
|
||||
@@ -668,6 +679,9 @@ static void aml_sha_clean_key(struct ahash_request *req)
|
||||
u8 *key = 0;
|
||||
size_t dsc_sz = 0;
|
||||
|
||||
if (!dd)
|
||||
return;
|
||||
|
||||
dsc_sz = aml_dma_get_dsc_sz(0, dd->dma);
|
||||
descriptor = dmam_alloc_coherent(dd->parent, dsc_sz,
|
||||
&dma_descript_tab, GFP_ATOMIC | GFP_DMA);
|
||||
@@ -1004,8 +1018,11 @@ static int aml_sha_enqueue(struct ahash_request *req, unsigned int op)
|
||||
|
||||
ctx = ahash_request_ctx(req);
|
||||
tctx = crypto_tfm_ctx(req->base.tfm);
|
||||
dd = tctx->dd;
|
||||
|
||||
if (!tctx->dd)
|
||||
return -ENODEV;
|
||||
|
||||
dd = tctx->dd;
|
||||
ctx->op = op;
|
||||
|
||||
if (pm_runtime_suspended(dd->parent)) {
|
||||
@@ -1023,9 +1040,11 @@ static int aml_sha_enqueue(struct ahash_request *req, unsigned int op)
|
||||
int aml_sha_process(struct ahash_request *req)
|
||||
{
|
||||
struct aml_sha_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
|
||||
struct aml_sha_dev *dd = tctx->dd;
|
||||
|
||||
return aml_sha_handle_queue(dd, req);
|
||||
if (!tctx->dd)
|
||||
return -ENODEV;
|
||||
|
||||
return aml_sha_handle_queue(tctx->dd, req);
|
||||
}
|
||||
|
||||
static int _aml_sha_update(struct ahash_request *req)
|
||||
@@ -1162,23 +1181,35 @@ int aml_sha_setkey(struct crypto_ahash *tfm, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct aml_sha_ctx *tctx = crypto_ahash_ctx(tfm);
|
||||
int bs = crypto_shash_blocksize(tctx->shash);
|
||||
int ds = crypto_shash_digestsize(tctx->shash);
|
||||
struct aml_sha_dev *dd = NULL, *tmp;
|
||||
int bs, ds;
|
||||
struct aml_sha_dev *tmp;
|
||||
int err = 0;
|
||||
|
||||
if (!tctx)
|
||||
return -EINVAL;
|
||||
|
||||
if (tctx->shash) {
|
||||
bs = crypto_shash_blocksize(tctx->shash);
|
||||
ds = crypto_shash_digestsize(tctx->shash);
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
spin_lock_bh(&aml_sha.lock);
|
||||
if (!tctx->dd) {
|
||||
list_for_each_entry(tmp, &aml_sha.dev_list, list) {
|
||||
dd = tmp;
|
||||
break;
|
||||
if (aml_sha.dev_list.next && !list_empty(&aml_sha.dev_list)) {
|
||||
/* coverity[unreachable : SUPPRESS] */
|
||||
list_for_each_entry(tmp, &aml_sha.dev_list, list) {
|
||||
tctx->dd = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tctx->dd = dd;
|
||||
} else {
|
||||
dd = tctx->dd;
|
||||
}
|
||||
spin_unlock_bh(&aml_sha.lock);
|
||||
|
||||
if (!tctx->dd)
|
||||
return -EINVAL;
|
||||
|
||||
tctx->kte = -1;
|
||||
if (keylen > bs) {
|
||||
err = aml_shash_digest(tctx->shash,
|
||||
@@ -1199,21 +1230,24 @@ int aml_sha_kl_setkey(struct crypto_ahash *tfm, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct aml_sha_ctx *tctx = crypto_ahash_ctx(tfm);
|
||||
struct aml_sha_dev *dd = NULL, *tmp;
|
||||
struct aml_sha_dev *tmp;
|
||||
int err = 0;
|
||||
|
||||
spin_lock_bh(&aml_sha.lock);
|
||||
if (!tctx->dd) {
|
||||
list_for_each_entry(tmp, &aml_sha.dev_list, list) {
|
||||
dd = tmp;
|
||||
break;
|
||||
if (aml_sha.dev_list.next && !list_empty(&aml_sha.dev_list)) {
|
||||
/* coverity[unreachable : SUPPRESS] */
|
||||
list_for_each_entry(tmp, &aml_sha.dev_list, list) {
|
||||
tctx->dd = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tctx->dd = dd;
|
||||
} else {
|
||||
dd = tctx->dd;
|
||||
}
|
||||
spin_unlock_bh(&aml_sha.lock);
|
||||
|
||||
if (!tctx->dd)
|
||||
return -ENODEV;
|
||||
|
||||
/* key[0:3] = kte */
|
||||
tctx->kte = *(uint32_t *)&key[0];
|
||||
WARN_ON(!(keylen == 16 || keylen == 32));
|
||||
@@ -1575,7 +1609,7 @@ static int aml_sha_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct aml_sha_dev *sha_dd;
|
||||
struct device *dev = &pdev->dev;
|
||||
int err = -EPERM;
|
||||
int err;
|
||||
/* default is 48 for most chips.
|
||||
* For S7D, it is 40 and specified in dts
|
||||
*/
|
||||
@@ -1586,6 +1620,11 @@ static int aml_sha_probe(struct platform_device *pdev)
|
||||
*/
|
||||
u32 support_sha1_zero_len = 1;
|
||||
|
||||
if (!dev->parent) {
|
||||
err = -ENODEV;
|
||||
goto sha_dd_err;
|
||||
}
|
||||
|
||||
sha_dd = devm_kzalloc(dev, sizeof(struct aml_sha_dev), GFP_KERNEL);
|
||||
if (!sha_dd) {
|
||||
err = -ENOMEM;
|
||||
|
||||
Reference in New Issue
Block a user