summaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorTero Kristo <t-kristo@ti.com>2018-02-27 15:30:37 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2018-03-09 22:45:38 +0800
commit62f7c708ff2f45ef4e6bffb1ae2e6ee2b0fc09c6 (patch)
treecaba6bb39a674c3bd3cf4dcabd96bed0b5cab836 /drivers/crypto
parentc9af5995d5a84ca191b0ec5514cc385715d89171 (diff)
downloadblackbird-obmc-linux-62f7c708ff2f45ef4e6bffb1ae2e6ee2b0fc09c6.tar.gz
blackbird-obmc-linux-62f7c708ff2f45ef4e6bffb1ae2e6ee2b0fc09c6.zip
crypto: omap-sham - make queue length configurable
Crypto driver queue size can now be configured from userspace. This allows optimizing the queue usage based on use case. Default queue size is still 10 entries. Signed-off-by: Tero Kristo <t-kristo@ti.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/omap-sham.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index 7fb9eef4e724..8e7e1582ef69 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -2051,9 +2051,47 @@ static ssize_t fallback_store(struct device *dev, struct device_attribute *attr,
return size;
}
+static ssize_t queue_len_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct omap_sham_dev *dd = dev_get_drvdata(dev);
+
+ return sprintf(buf, "%d\n", dd->queue.max_qlen);
+}
+
+static ssize_t queue_len_store(struct device *dev,
+ struct device_attribute *attr, const char *buf,
+ size_t size)
+{
+ struct omap_sham_dev *dd = dev_get_drvdata(dev);
+ ssize_t status;
+ long value;
+ unsigned long flags;
+
+ status = kstrtol(buf, 0, &value);
+ if (status)
+ return status;
+
+ if (value < 1)
+ return -EINVAL;
+
+ /*
+ * Changing the queue size in fly is safe, if size becomes smaller
+ * than current size, it will just not accept new entries until
+ * it has shrank enough.
+ */
+ spin_lock_irqsave(&dd->lock, flags);
+ dd->queue.max_qlen = value;
+ spin_unlock_irqrestore(&dd->lock, flags);
+
+ return size;
+}
+
+static DEVICE_ATTR_RW(queue_len);
static DEVICE_ATTR_RW(fallback);
static struct attribute *omap_sham_attrs[] = {
+ &dev_attr_queue_len.attr,
&dev_attr_fallback.attr,
NULL,
};
OpenPOWER on IntegriCloud