From patchwork Tue Feb 27 13:30:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 129783 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp280242edc; Tue, 27 Feb 2018 05:31:06 -0800 (PST) X-Google-Smtp-Source: AH8x227BaVJ4FdLTUd6s+EWFICV14+Z0crC9qfdszS+RB8u7jWVzgIFn+fMkz70JSHF/1qSPXodb X-Received: by 2002:a17:902:4d:: with SMTP id 71-v6mr14316580pla.341.1519738266658; Tue, 27 Feb 2018 05:31:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519738266; cv=none; d=google.com; s=arc-20160816; b=H6NB5XhnOfEFD/B0rlffazTvftoVOuNhiLPyB4fkIYGtS6xzkjFG5GAV2Bxii/qqBZ LhuSPZ7tL6a1pDD9V7SdPV/BlikrQmrFc5GOjI9EA6QXW3NFzYrm7HRn3RwoArIdlZ3S J+qF2BLo+qSjZ+CmCJaS+VKOwM9J34IMMieShBHU3kGPvpu2FSvmQwpM5KlmprRYA/zR qPfj6eRPhH11kfQjMapvdxFDa6WnLUIZgH6SAu47gGlV341pek4lUXK/tuV1x5ddK990 qheT5L4o0jhSGr42rBK6ThIrMrZK6H4DhwCybsAPJBUpb6ylVkQNY7eOI0+LO4Tr2GQM tNaw== 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=5mJb3Dn5Fwe3nXWLdsI7sR2om/QuzeaIpmSVTJovV5c=; b=GDgg6gDWe7Mj3/txvkx9ZVB/68/BVlYLLGgTmiBg3HlaN0kCyQ8FKaESrJ3+58j9RM EKondYGlyRTziiNwsFY9o41sWS3SP5BUhC+UMTm23/C6hE8D263R9YUt5innaP2cf0zP 3/o13/SJ6ZHU2S57gDvAm8uIPeCUE45tNtGlp1LkZrf1/4JE0TLNTDgfgL64ggxOKGis hF2ZhJRe5IpxHjclo6rDp+HuuBKt55n/sfa0uK9+XfVG3Uca3wYDaVvAhhfghIf6e680 hWhlY8kUQ0MxkZbb8Llpe7v1Vzw08bMZ2bMF/2MlyNT4GI3Na/np+w9uQRToiv5+IAcS 3Ufg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Wi57y/Q4; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (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 33-v6si5585201plf.98.2018.02.27.05.31.06; Tue, 27 Feb 2018 05:31:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Wi57y/Q4; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753362AbeB0NbE (ORCPT + 1 other); Tue, 27 Feb 2018 08:31:04 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:14437 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753297AbeB0NbB (ORCPT ); Tue, 27 Feb 2018 08:31:01 -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 w1RDUtFW019887; Tue, 27 Feb 2018 07:30:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519738255; bh=ic4QSj95eDhraZMnE3xmEb/IdzPN90VvXvw8nOG9fHI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Wi57y/Q4UZHUznf/C1ozwCMAVrtz2dSEtVvTUMhqY68+tPeMfEgzYvBC4ljn4X5mF +EtWPOZ7+Cl2Mt6Ridrb9oO6+jWEsN8ArCK+bKoHYXkR96tNI6L7ga6aCsVZCB72gk XQFTlFHeG+UdszsxdDm3X6rgxHJMPBwGsBotpKmI= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1RDUtEA020174; Tue, 27 Feb 2018 07:30:55 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE102.ent.ti.com (157.170.170.32) 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:54 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE100.ent.ti.com (157.170.170.30) 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:54 -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 w1RDUoJ1022412; Tue, 27 Feb 2018 07:30:53 -0600 From: Tero Kristo To: , , , CC: Subject: [PATCH 1/6] crypto: omap-sham: Verify page zone of scatterlists before starting DMA Date: Tue, 27 Feb 2018 15:30:34 +0200 Message-ID: <1519738239-28616-2-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-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org In certain platforms like DRA7xx having memory > 2GB with LPAE enabled has a constraint that DMA can be done with the initial 2GB and marks it as ZONE_DMA. But openssl when used with cryptodev does not make sure that input buffer is DMA capable. So, adding a check to verify if the input buffer is capable of DMA. Signed-off-by: Tero Kristo Reported-by: Aparna Balasubramanian Reviewed-by: Lokesh Vutla --- drivers/crypto/omap-sham.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 1.9.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index 86b89ac..ce398b7 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -759,6 +759,13 @@ static int omap_sham_align_sgs(struct scatterlist *sg, while (nbytes > 0 && sg_tmp) { n++; +#ifdef CONFIG_ZONE_DMA + if (page_zonenum(sg_page(sg_tmp)) != ZONE_DMA) { + aligned = false; + break; + } +#endif + if (offset < sg_tmp->length) { if (!IS_ALIGNED(offset + sg_tmp->offset, 4)) { aligned = false; From patchwork Tue Feb 27 13:30:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 129784 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp280284edc; Tue, 27 Feb 2018 05:31:09 -0800 (PST) X-Google-Smtp-Source: AH8x225Mkmg6Z8xJ/IvuEucT0mQhVx+oytfTnQIBfLzTu+c8uK/Nvg50vdREXUZSZk6dhShesENp X-Received: by 10.98.156.16 with SMTP id f16mr14245569pfe.180.1519738268991; Tue, 27 Feb 2018 05:31:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519738268; cv=none; d=google.com; s=arc-20160816; b=pPCGnW+AnhoEr0SVJk1/EqhrIQcbimd7QkRng8yB1KbjWuVa9NXl08REKvDy/IoKRR BAiPFrdd4fiyze1g7oKbtsjys9skp7aZOKTV1ybR1cxnm9GP/2rxwGERWUhd/zwcPrjS jCB8YbT1gKck4TPWgQQ83CqxpS6U/0dSrWsW5Q2Zvmie2LMQaQA0vycylOCCUO0dq5uK K5xWAR31FEi8eO06jAicu4IuYEpHP6aCvOcPSWudMjo0XI8sJjNmcKWjRfjnjI2vyB27 2gs7gbPYCe/BjyVeNHhqjmwUpI35WEP6OZtbj90rSNR8/qQomOU3bK2KhOKm42eBJYha BXqQ== 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=N4FUIsejYUZ19DudHxF+cGAWolsoI6jj5zVIdeD5MXk=; b=EQhczYMVrRDZt2La+/La8bwtxHBIkhABVzAw3UJcU9CTHGpClKe8qeTjc+kIECqO08 4ZMO07kkdp2SUZj8oP/khZSFvELFZxEHIh/HHj1qxGuK7fnoChEeC2yWHUtuk4rGRQC3 1lt+93QJA72iKrm9oAd+iomCqfMJzuHLILPb87FvJdPiOgYLKBoRX8dkROtxtnx6cZDM csTXJqZ4o484doVCTzX5vYK7y+U3po57bE2vStkyBIuhZh/JQjDXWZ+0DfQGJYfjlRO8 EsVL0EGFytIseSxkSxw+dfjG+x1QHfpf7zifv0NbMLLFUGAF/ULpbI6Ad9evPwMiTj79 hMfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=cniAPeGW; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (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 33-v6si5585201plf.98.2018.02.27.05.31.08; Tue, 27 Feb 2018 05:31:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=cniAPeGW; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753361AbeB0NbD (ORCPT + 1 other); Tue, 27 Feb 2018 08:31:03 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:27555 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753210AbeB0NbB (ORCPT ); Tue, 27 Feb 2018 08:31:01 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1RDUv1i019514; Tue, 27 Feb 2018 07:30:57 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519738257; bh=J4egHFPx0FjrmR8RHYH9JqjdgwqKrh0DCn6cEhJ9DhI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=cniAPeGWNnSTAkYLLOunhvb7o7AyWPH2x5eqi6tvhiNb9TJ4ceO2BdauhfOsLfMaU dNyTWjxW+Py/u96qQZ+Npa2EqiCquHUbxL0Q/LXNOdLq3bNUW2po0cH/0oRjhjQZ6j bapVGMu2yTIPXJBUjs9YUmf3UR69qdpj89OAdmpg= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1RDUvp9020181; Tue, 27 Feb 2018 07:30:57 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE104.ent.ti.com (10.64.6.25) 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:56 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE107.ent.ti.com (10.64.6.28) 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:56 -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 w1RDUoJ2022412; Tue, 27 Feb 2018 07:30:55 -0600 From: Tero Kristo To: , , , CC: Subject: [PATCH 2/6] crypto: omap-crypto: Verify page zone scatterlists before starting DMA Date: Tue, 27 Feb 2018 15:30:35 +0200 Message-ID: <1519738239-28616-3-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-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org In certain platforms like DRA7xx having memory > 2GB with LPAE enabled has a constraint that DMA can be done with the initial 2GB and marks it as ZONE_DMA. But openssl when used with cryptodev does not make sure that input buffer is DMA capable. So, adding a check to verify if the input buffer is capable of DMA. Signed-off-by: Tero Kristo --- drivers/crypto/omap-crypto.c | 4 ++++ 1 file changed, 4 insertions(+) -- 1.9.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-crypto.c b/drivers/crypto/omap-crypto.c index 23e3777..2c42e4b 100644 --- a/drivers/crypto/omap-crypto.c +++ b/drivers/crypto/omap-crypto.c @@ -104,6 +104,10 @@ static int omap_crypto_check_sg(struct scatterlist *sg, int total, int bs, return OMAP_CRYPTO_NOT_ALIGNED; if (!IS_ALIGNED(sg->length, bs)) return OMAP_CRYPTO_NOT_ALIGNED; +#ifdef CONFIG_ZONE_DMA + if (page_zonenum(sg_page(sg)) != ZONE_DMA) + return OMAP_CRYPTO_NOT_ALIGNED; +#endif len += sg->length; sg = sg_next(sg); From patchwork Tue Feb 27 13:30:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 129785 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp280318edc; Tue, 27 Feb 2018 05:31:10 -0800 (PST) X-Google-Smtp-Source: AH8x224Dv1XdAManA6Ku9iar8vmh1Q1wBqzxsZlF61HwgBhLv3/s9nxI3uanidmY1AlbDC8Eg3Xs X-Received: by 2002:a17:902:7445:: with SMTP id e5-v6mr14192192plt.204.1519738270492; Tue, 27 Feb 2018 05:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519738270; cv=none; d=google.com; s=arc-20160816; b=bdeBJOk1lg1vdCfbYnvngFT98o79SECGqryTrzJwebRCdYrYwqHWzadiwCmV6QpacA cMktPVNOKO4xGUDRIdKFLLkdLMl8ZrjFa1I2q92j5pfqRBRrkrgQZo/KLUEPH9N+IYBL sRQXbWJ5m698H14eAtIbi8p+xSbK44RdC+VIoZGpudtxUr7i5IHKM8GyyNFJIbvcnIWI joLicJu4v0M9ov8hWyLaNyanEYfqJyHVpPvtCtM7iAlfZWHwp9xAs94t2o6+KAP/YI4/ Ogm+uX4FHLTMhdcALTUZq9r/ZGZwR35O/PhWoOXL1ttIymBnAXpZAaufNMWwT+D9yeKb +auQ== 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=13Dkw47pnay4gK0u8RulYWQpcPDzI1++eAaQBDtRx3I=; b=P3OZNq6uHL4o36YiEHvijqeOSzOc4jgRsUdWO6epr52uIa4thCe2qHzxbA2EBLPpEx CcyYIl5jhqDsMJZj3jF6zohyIXUpW8KDN755XaLq36wdjxuogmS9+eDHGxPFX+Ef6YOi fwcro8M3i662laOVp9AlpzzQ9v5HYaS6fZIGXny7hvQBQbEfXWNy0Izj1mhx1tpDKW9w yi6D51ndiswDGUhhNFSdZ1ODM7I/KtsXCJ3Kwmhu10i8tpHU3cOC7kf/6hQ/eFUpIGPB 8OvjL+RBViJW2GYS1Yqg+T1m/in+SZHVqwLGhB9Vn80KnbxnzWzr2WmaZNJKO5jIqNSo 0gNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ukevOUWb; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (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 33-v6si5585201plf.98.2018.02.27.05.31.10; Tue, 27 Feb 2018 05:31:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ukevOUWb; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753363AbeB0NbG (ORCPT + 1 other); Tue, 27 Feb 2018 08:31:06 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:27561 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753297AbeB0NbF (ORCPT ); Tue, 27 Feb 2018 08:31:05 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1RDV1SP019519; Tue, 27 Feb 2018 07:31:01 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519738261; bh=pbC7r204R1vpPUs7FAX4eBcpd6pY6HJVD1j6vv+buwg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ukevOUWbZnozRozWEb9zi2lZBbtMLCEWdTOUsOidCu0jy9qPUbk91gwV5anK1xyIL D80hjJE8c31GVxaeSHZXNPF+nDuy2Ct9LtAOOTEUNfIwA1wUYVZ0BpKuObe2uZDoQ8 +xD1xKplTSDaGHl7saCwtdQg23O8VcosE17XRml0= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1RDV1HR026355; Tue, 27 Feb 2018 07:31:01 -0600 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE103.ent.ti.com (10.64.6.24) 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:31:00 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE101.ent.ti.com (10.64.6.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:31:00 -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 w1RDUoJ4022412; Tue, 27 Feb 2018 07:30:59 -0600 From: Tero Kristo To: , , , CC: Subject: [PATCH 4/6] crypto: omap-sham: make queue length configurable Date: Tue, 27 Feb 2018 15:30:37 +0200 Message-ID: <1519738239-28616-5-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-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 --- drivers/crypto/omap-sham.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) -- 1.9.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index 7fb9eef..8e7e1582 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, }; From patchwork Tue Feb 27 13:30:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 129786 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp280322edc; Tue, 27 Feb 2018 05:31:10 -0800 (PST) X-Google-Smtp-Source: AH8x2266bd4ZbPH+RsGy1wlrJTVn+8jU3s6m2hkwtbkzQPA4AdWuCSWyT6qzPQTW83vaZPcS2bvv X-Received: by 2002:a17:902:8ec6:: with SMTP id x6-v6mr14519190plo.402.1519738270782; Tue, 27 Feb 2018 05:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519738270; cv=none; d=google.com; s=arc-20160816; b=TssjNAw4zcmnQOVuP1jytN1MmqobeEQqa/7DI1PpekCWPdy8y42K3MiImRCUWW2wGw 0iCWhmu/NNsgA+cpEBXxZXF4gskWxrS5EnQzzTtSaFAHmO8WEM+pbE8hrXq6NOF/7Umu qTwZRIMVO0Z4PocqP8AU0hVm5/I9+xNCbNYI2lEj267kxgTJiyyna+B7M2x8H7aXzWML SYfR+Thq58DqXCYKadw/9mVnrXQzjMEusP8T5Fft8pQ49azmH9EQ8cTN+cHSWdB5fb9y mSP/Rvvefqt1v8ftpnURdKUjzAsLcF1OfStmFwngB6Qu5LYp83nwNj3zaMDVX/b69DU7 Dv7g== 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=vWL4arwpUQ0qqVd+7n7mMCq2ctopnMk1s8k5sxeVpTo=; b=EZERKtaOFHGSmW2a3wlBllyY4sHR9k8S3+P9djM7FMyL0hr5p5oY1bzq6+RJFWQtuq VxomJ6AaW7kcUppKFOhtOg+Q2348mYrDxRVCzoBJcfnXwD+hKYfqGsGhRrjNkccuwUUe pXoPLAb4bM/gyycju050EQhvgeb5JE+6QEpd+PozHGtPn/T40aybCJmsK5HT079Tv/xk CGB7v1FZGujXWvdTQvwU2A0h6o9tGYEyfQKp8wCsoE8HqA8Iin66d4h1EQgwHs+fiiEv +kHCfBefexBpco1ZzmtToJdDD2hlfhCoALJkfRIyCDnxQJmU609kO9PgNPjUgkcTovTN hfDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=B0GsKrea; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (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 33-v6si5585201plf.98.2018.02.27.05.31.10; Tue, 27 Feb 2018 05:31:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=B0GsKrea; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753366AbeB0NbI (ORCPT + 1 other); Tue, 27 Feb 2018 08:31:08 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:16969 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753297AbeB0NbH (ORCPT ); Tue, 27 Feb 2018 08:31:07 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1RDV3Rd031785; Tue, 27 Feb 2018 07:31:03 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519738263; bh=qBlkH/9ukU40bcks/NSbj7UbJt7SueLCDaUIem7kcTI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=B0GsKreaIvhguEHzgq9MrdStFsy7fqZrW2StgMAr3D+u77ueHdKdFMT5YGdzuwO2x bM+OSJeEN25N8p1BI7u825+9BoSjdS9xN0w8kGvTwO5oMzbq7uNzQLGPj7hUhaGGX+ Tdvl4EzPCRPnIxrc6WKw5d4NBJFeB1vuyD/meqWg= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1RDV3b0026604; Tue, 27 Feb 2018 07:31:03 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE102.ent.ti.com (10.64.6.23) 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:31:02 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE107.ent.ti.com (10.64.6.28) 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:31:03 -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 w1RDUoJ5022412; Tue, 27 Feb 2018 07:31:01 -0600 From: Tero Kristo To: , , , CC: Subject: [PATCH 5/6] crypto: omap-aes: make fallback size configurable Date: Tue, 27 Feb 2018 15:30:38 +0200 Message-ID: <1519738239-28616-6-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-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 --- drivers/crypto/omap-aes.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) -- 1.9.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index fbec0a2..76bc94f 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -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) \ ({ \ @@ -517,7 +519,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); @@ -1029,6 +1031,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; @@ -1159,6 +1199,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--) { From patchwork Tue Feb 27 13:30:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 129787 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp280342edc; Tue, 27 Feb 2018 05:31:12 -0800 (PST) X-Google-Smtp-Source: AH8x224ImO1UtS1J+2NKUCp1AG8yssrLrsLJo6IkwhaYPacJV9SFxuQnUGqAYcySvrHkdP5XhGNk X-Received: by 10.98.228.3 with SMTP id r3mr12625863pfh.77.1519738272082; Tue, 27 Feb 2018 05:31:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519738272; cv=none; d=google.com; s=arc-20160816; b=VJ+NlzuBVpqAOMZkL5gXDci/MpEXsfZ0q4Cc7NpJpa79pAmWcDiQyk/Wc4FGq4CDVa BAZL6dXyNi4a5CBTw6aTWvBtq5ndr4/9ibrN8xqbuyI5rgzuLQJa/nXVdyKc+rJIHwuB YE0Qukd0maJ3xEDBmrfS2DnHOppgJ1ySZnFI9g6P1FAtgqQ3C/isLreQZHe1b+4WzJEZ sKfUQXERANK3K9bxmnposgg+qlP1GMyfjBsBtgeT92KWcgYeIV4Ka7t2Ph+J53+YMKnh 5wvq9rBjFYsas0zz5CVoK4LRrBujGZHkUTCrgqNYEEIGdb1i/w5lJy8dVjPVTYrxp4S7 87Bg== 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=uxEOvc3HZpS0pgozYbWosqjDOTX5mzvHeJKW6NKG3yg=; b=eBZi12TlxKVeJ6XbVMs/f0KMMDEH+F7N24cUcHQ1IC9fEmcDlz0JnENj58ngHcQQzn cfs6V/Qp81WaukJft4g4CgaMMmHDhrPEJ2LBHYIdf86LeY+OrwkUZlIIPk3OxRRisXG+ c93K8dtHCg/X8A27ene0nMqbIHhqH3/7WRhrisPMtfGyzQokUOCl3R8fhKYVl2/wCc8e W93ObKUhGlhPmEn+QtmjdbZGyKApFhRDcgi/qvXeWbAB7rw/4YTQwVmzoWvMgjaSPmRj 96pyDe7m0824qlNe3FNP9Facu7cqzcutpdDTvHSfaClCtMST7myzWzRN8r6FurCidU2S OLrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GsCQKNlf; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (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 33-v6si5585201plf.98.2018.02.27.05.31.11; Tue, 27 Feb 2018 05:31:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GsCQKNlf; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753297AbeB0NbJ (ORCPT + 1 other); Tue, 27 Feb 2018 08:31:09 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:27567 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753364AbeB0NbI (ORCPT ); Tue, 27 Feb 2018 08:31:08 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1RDV57I019543; Tue, 27 Feb 2018 07:31:05 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519738265; bh=fHuq5/YDgYAUvqieBaNrampkvMBm5cACmHWqHdt/YHE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=GsCQKNlfM81IuOPxQGuJMXknN1zVbFrT+gvW3ZLVFul3b+EL8WdK9s6fphiixYmA8 UbgQb8NI2jsgxzJ4FdDI18WZR1B3YfDBqnfmv5lg8HYk1K9xFeJdGysmJiiZoQJfFf E2g/girunkvTeGrGsop2LsTVDSJUTdDug7NOrVuA= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1RDV5ri026749; Tue, 27 Feb 2018 07:31:05 -0600 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE100.ent.ti.com (10.64.6.21) 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:31:05 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE113.ent.ti.com (10.64.6.34) 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:31:05 -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 w1RDUoJ6022412; Tue, 27 Feb 2018 07:31:03 -0600 From: Tero Kristo To: , , , CC: Subject: [PATCH 6/6] crypto: omap-aes: make queue length configurable Date: Tue, 27 Feb 2018 15:30:39 +0200 Message-ID: <1519738239-28616-7-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-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 --- drivers/crypto/omap-aes.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 1.9.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index 76bc94f..250880a 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -1058,9 +1058,52 @@ 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_aes_dev *dd = dev_get_drvdata(dev); + + return sprintf(buf, "%d\n", dd->engine->queue.max_qlen); +} + +static ssize_t queue_len_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t size) +{ + struct omap_aes_dev *dd; + 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_bh(&list_lock); + list_for_each_entry(dd, &dev_list, list) { + spin_lock_irqsave(&dd->lock, flags); + dd->engine->queue.max_qlen = value; + dd->aead_queue.base.max_qlen = value; + spin_unlock_irqrestore(&dd->lock, flags); + } + spin_unlock_bh(&list_lock); + + return size; +} + +static DEVICE_ATTR_RW(queue_len); static DEVICE_ATTR_RW(fallback); static struct attribute *omap_aes_attrs[] = { + &dev_attr_queue_len.attr, &dev_attr_fallback.attr, NULL, };