From patchwork Tue Feb 27 13:30:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 129788 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp280456edc; Tue, 27 Feb 2018 05:31:17 -0800 (PST) X-Google-Smtp-Source: AH8x2268Q5K3+lbIxc1+Hz0dWMvuKWtwOQZgs0KEysfsMhfAH7VZ5VZAU0wcVfyPeZ+MsbBjBNLO X-Received: by 2002:a17:902:43e4:: with SMTP id j91-v6mr14031218pld.153.1519738277707; Tue, 27 Feb 2018 05:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519738277; cv=none; d=google.com; s=arc-20160816; b=B/tv334/rM1iBBDkk0PdTfrxTeXnFchUCN8bd5zlpy+yqpdgO95c4TkkywzamjF+rI +/Hu6wt1KiGE8iElE1M0FjbW5FfM/rAUacq/wBPjhJ/sD4MyASn80hcMDl9o+2bko0tP Fu/2xRdskN/ahCb71fhBU/FWDPQZkEyzK8OKtfUb7QQTf/UPHa/H7mvVz6erF0gLCHze nuxSK0SFfQ3G8Mj1DemD9LhVax9ZZGzzQ6A1Jpz5crojL9Gv4BgwaJ30VmXjSmp/7HpI tQAl0snMqOBP7IXETfYjyb9Ual6FSN8FkaHiv97EkqN6glDPUs0DM1CjDre7u5c8Czgi Dybw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=NvhBQ1ketUb/uC2GLPDQzJD94P8oTkYhhWFG0pEAVew=; b=oOm/wqa7p1rBvowrhwBkbMuQrzgfwTqwfgA2rhGXcDzE7pe8VyHloEEOyfRbMdtwlV xDbzl3bIh0iHnO2ZwPSxqB/qXIpRZYcMRTBxlXon6mO3QDcFLWHzvIw01Ee6IGSfOvnk F99wCmneaAoas3eC2+V+y4+MH7tWc6X81/Bh0RxAh5vMw5LajZMZFE+Q0FzHPssFHKpr Iy+d15KT8DK2WSoAfldfVN2E3xFW2W1O1PZn+hrdwA7lFs0Bv2PTQpjAfUAQaa6KL45h i/fWk6ya9cqvJSrrt6w8IUNYolQHog/MuqE2mEDVyzaIFjxChmjMg7afUoH0cggYJntq Qk5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=e7TYEPyU; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o88si8551731pfk.380.2018.02.27.05.31.17; Tue, 27 Feb 2018 05:31:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=e7TYEPyU; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753370AbeB0NbP (ORCPT + 5 others); Tue, 27 Feb 2018 08:31:15 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:14444 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753293AbeB0NbC (ORCPT ); Tue, 27 Feb 2018 08:31:02 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1RDUx1Z019907; Tue, 27 Feb 2018 07:30:59 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519738259; bh=0sGu51nWcs1vQggiDQWPvn0KGu6Vlk8rAOOlRLNrINs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=e7TYEPyUBgL9eK+X4bdz1WDyZxQbcxlxM95nP58EB9oHEd7LzRVa8Q9Ge0VqyKPy/ 47JGciEB5lcVCZqzj3AXnIgrOPQ6hYxX2AwC8C9vHnFY0ffNRgh+fOKg63S9bQoLNB 6NKcy/wEeBkk7+pWPqDjwTJkfTVEXtWdOSqD6COg= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1RDUxwc020250; Tue, 27 Feb 2018 07:30:59 -0600 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Tue, 27 Feb 2018 07:30:58 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Tue, 27 Feb 2018 07:30:58 -0600 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1RDUoJ3022412; Tue, 27 Feb 2018 07:30:57 -0600 From: Tero Kristo To: , , , CC: Subject: [PATCH 3/6] crypto: omap-sham: make fallback size configurable Date: Tue, 27 Feb 2018 15:30:36 +0200 Message-ID: <1519738239-28616-4-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519738239-28616-1-git-send-email-t-kristo@ti.com> References: <1519738239-28616-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Crypto driver fallback size can now be configured from userspace. This allows optimizing the DMA usage based on use case. Default fallback size of 256 is still used. Signed-off-by: Tero Kristo --- drivers/crypto/omap-sham.c | 56 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) -- 1.9.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index ce398b7..7fb9eef 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -229,6 +229,7 @@ struct omap_sham_dev { u8 xmit_buf[BUFLEN] OMAP_ALIGNED; unsigned long flags; + int fallback_sz; struct crypto_queue queue; struct ahash_request *req; @@ -1009,7 +1010,7 @@ static int omap_sham_update_req(struct omap_sham_dev *dd) ctx->total, ctx->digcnt, (ctx->flags & BIT(FLAGS_FINUP)) != 0); if (ctx->total < get_block_size(ctx) || - ctx->total < OMAP_SHA_DMA_THRESHOLD) + ctx->total < dd->fallback_sz) ctx->flags |= BIT(FLAGS_CPU); if (ctx->flags & BIT(FLAGS_CPU)) @@ -1265,11 +1266,11 @@ static int omap_sham_final(struct ahash_request *req) /* * OMAP HW accel works only with buffers >= 9. * HMAC is always >= 9 because ipad == block size. - * If buffersize is less than DMA_THRESHOLD, we use fallback + * If buffersize is less than fallback_sz, we use fallback * SW encoding, as using DMA + HW in this case doesn't provide * any benefit. */ - if (!ctx->digcnt && ctx->bufcnt < OMAP_SHA_DMA_THRESHOLD) + if (!ctx->digcnt && ctx->bufcnt < ctx->dd->fallback_sz) return omap_sham_final_shash(req); else if (ctx->bufcnt) return omap_sham_enqueue(req, OP_FINAL); @@ -2020,6 +2021,47 @@ static int omap_sham_get_res_pdev(struct omap_sham_dev *dd, return err; } +static ssize_t fallback_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->fallback_sz); +} + +static ssize_t fallback_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; + + 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; + } + + dd->fallback_sz = value; + + return size; +} + +static DEVICE_ATTR_RW(fallback); + +static struct attribute *omap_sham_attrs[] = { + &dev_attr_fallback.attr, + NULL, +}; + +static struct attribute_group omap_sham_attr_group = { + .attrs = omap_sham_attrs, +}; + static int omap_sham_probe(struct platform_device *pdev) { struct omap_sham_dev *dd; @@ -2081,6 +2123,8 @@ static int omap_sham_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(dev); pm_runtime_set_autosuspend_delay(dev, DEFAULT_AUTOSUSPEND_DELAY); + dd->fallback_sz = OMAP_SHA_DMA_THRESHOLD; + pm_runtime_enable(dev); pm_runtime_irq_safe(dev); @@ -2118,6 +2162,12 @@ static int omap_sham_probe(struct platform_device *pdev) } } + err = sysfs_create_group(&dev->kobj, &omap_sham_attr_group); + if (err) { + dev_err(dev, "could not create sysfs device attrs\n"); + goto err_algs; + } + return 0; err_algs: