Commit 537c62ca authored by Tero Kristo's avatar Tero Kristo Committed by Herbert Xu

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: default avatarTero Kristo <t-kristo@ti.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 62f7c708
......@@ -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 @@ static int omap_aes_get_res_pdev(struct omap_aes_dev *dd,
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--) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment