crypto: omap-aes - make fallback size configurable

Crypto driver fallback size can now be configured from userspace. This
allows optimizing the DMA usage based on use case. Detault fallback
size of 200 is still used.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Tero Kristo 2018-02-27 15:30:38 +02:00 committed by Herbert Xu
parent 62f7c708ff
commit 537c62ca12

View File

@ -47,6 +47,8 @@
static LIST_HEAD(dev_list);
static DEFINE_SPINLOCK(list_lock);
static int aes_fallback_sz = 200;
#ifdef DEBUG
#define omap_aes_read(dd, offset) \
({ \
@ -519,7 +521,7 @@ static int omap_aes_crypt(struct ablkcipher_request *req, unsigned long mode)
!!(mode & FLAGS_ENCRYPT),
!!(mode & FLAGS_CBC));
if (req->nbytes < 200) {
if (req->nbytes < aes_fallback_sz) {
SKCIPHER_REQUEST_ON_STACK(subreq, ctx->fallback);
skcipher_request_set_tfm(subreq, ctx->fallback);
@ -1040,6 +1042,44 @@ err:
return err;
}
static ssize_t fallback_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
return sprintf(buf, "%d\n", aes_fallback_sz);
}
static ssize_t fallback_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{
ssize_t status;
long value;
status = kstrtol(buf, 0, &value);
if (status)
return status;
/* HW accelerator only works with buffers > 9 */
if (value < 9) {
dev_err(dev, "minimum fallback size 9\n");
return -EINVAL;
}
aes_fallback_sz = value;
return size;
}
static DEVICE_ATTR_RW(fallback);
static struct attribute *omap_aes_attrs[] = {
&dev_attr_fallback.attr,
NULL,
};
static struct attribute_group omap_aes_attr_group = {
.attrs = omap_aes_attrs,
};
static int omap_aes_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@ -1168,6 +1208,12 @@ static int omap_aes_probe(struct platform_device *pdev)
}
}
err = sysfs_create_group(&dev->kobj, &omap_aes_attr_group);
if (err) {
dev_err(dev, "could not create sysfs device attrs\n");
goto err_aead_algs;
}
return 0;
err_aead_algs:
for (i = dd->pdata->aead_algs_info->registered - 1; i >= 0; i--) {