From patchwork Thu Oct 17 12:25:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 176573 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp847802ill; Thu, 17 Oct 2019 05:26:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8q0lhNIvPVPbJ8goFGk1anhYgR/xmbTSC60iyzEUvHUrnYS+89AmOH5NB19WFhKyJnzoo X-Received: by 2002:a17:906:3593:: with SMTP id o19mr3145261ejb.61.1571315185068; Thu, 17 Oct 2019 05:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571315185; cv=none; d=google.com; s=arc-20160816; b=qhCbxBP15BQGFHLGRiy+QqBtYeRwlxZkhowTHOF+86toUBJ2800C8RCdwaGkFgLnnk rCvDcuJ6cAbjZ1LoTNHiDsBhbwjJVIAbsMkCIF0WT3oiO2C6bnzuZYi/uNKMV+HRyKYT maFDAAav6MGj8wIgrMgIgc5ZRsbROTT0iV2TUAF4GBLqPtet7VWKVCxKTIhWmCovyPuE gTXqqUPV4MGJObUlN5BPnEjkwsotP5QRB0GDe8tCI0/x59mFCcJiZBugvYzfEgjXjui0 mS2HcjldEFmlJ2G/xhGiwQK8oX2rc7HTgaqJixCiD5gqigxtM5/dEA70iq+sUWiYPrUc pp5w== 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; bh=gf7Wxfh77f7HHA3L8Iq0WB8JJs92egQOvoT79mDTzZI=; b=bx3nmCmwdxUrxHFFFAMnYpdfoiVlGvd8oNKd2UYjySXLY7nz04sd06aEhVi3jsFlhA bFOgeZt31buAbf9Lb0ekxd1go9FWF3vW8wHaSbL65Y48MSrvvCZ+MbEErCZMyg/XCKQ3 v6klOF8hESTEDsPfxHwyDiwOWojWG5QRS/WUv9APk1WjA/kkHbxjt67CkYNz48sa/RdV MIAd4S1k4ObO1fryQqrDfV2+O4wsFY/E4hTH7T62crHhvdLIrVyPjXiRdy+MxrD7gT3R h75zYVTYe/fMEX+F3+uH9eZ2VhnGQ/Stfq2JpDW7QKeb3p2IModbk8V5K90rIPLs6Bwa L47A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=rUqYVpjO; 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 ot22si1288436ejb.153.2019.10.17.05.26.24; Thu, 17 Oct 2019 05:26:25 -0700 (PDT) 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=rUqYVpjO; 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 S2502304AbfJQM0X (ORCPT + 3 others); Thu, 17 Oct 2019 08:26:23 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:54478 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728554AbfJQM0X (ORCPT ); Thu, 17 Oct 2019 08:26:23 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9HCQDsH086521; Thu, 17 Oct 2019 07:26:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1571315173; bh=gf7Wxfh77f7HHA3L8Iq0WB8JJs92egQOvoT79mDTzZI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=rUqYVpjOwrHoanumGzo0DLMjJiI9R8hQuBSBtl5TmV4TMbNmFzW0qQL+eqe0diDLm 2xYJOSj/HqJa0r+voyBgxVZkLINCxfakIq1rbNlk/SYiy6uir2MfDHSKl0gPfeSoT0 TPS2NuTtUAq7ywW/SYt/MWiVbsVZn3lWDS12M1Z0= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9HCQDLM016505 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 17 Oct 2019 07:26:13 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 17 Oct 2019 07:26:04 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 17 Oct 2019 07:26:12 -0500 Received: from sokoban.bb.dnainternet.fi (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9HCPxNb073246; Thu, 17 Oct 2019 07:26:10 -0500 From: Tero Kristo To: , , , CC: , Subject: [PATCH 06/10] crypto: omap-sham: fix buffer handling for split test cases Date: Thu, 17 Oct 2019 15:25:45 +0300 Message-ID: <20191017122549.4634-7-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191017122549.4634-1-t-kristo@ti.com> References: <20191017122549.4634-1-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 Current buffer handling logic fails in a case where the buffer contains existing data from previous update which is divisible by block size. This results in a block size of data to be left missing from the sg list going out to the hw accelerator, ending up in stalling the crypto accelerator driver (the last request never completes fully due to missing data.) Fix this by passing the total size of the data instead of the data size of current request, and also parsing the buffer contents within the prepare request handling. Signed-off-by: Tero Kristo --- drivers/crypto/omap-sham.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.17.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 0bf07a7c060b..e71cd977b621 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -740,11 +740,12 @@ static int omap_sham_align_sgs(struct scatterlist *sg, struct scatterlist *sg_tmp = sg; int new_len; int offset = rctx->offset; + int bufcnt = rctx->bufcnt; if (!sg || !sg->length || !nbytes) return 0; - new_len = nbytes - offset; + new_len = nbytes; if (offset) list_ok = false; @@ -763,6 +764,16 @@ static int omap_sham_align_sgs(struct scatterlist *sg, while (nbytes > 0 && sg_tmp) { n++; + if (bufcnt) { + if (!IS_ALIGNED(bufcnt, bs)) { + aligned = false; + break; + } + nbytes -= bufcnt; + bufcnt = 0; + continue; + } + #ifdef CONFIG_ZONE_DMA if (page_zonenum(sg_page(sg_tmp)) != ZONE_DMA) { aligned = false; @@ -859,7 +870,7 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update) if (rctx->bufcnt) memcpy(rctx->dd->xmit_buf, rctx->buffer, rctx->bufcnt); - ret = omap_sham_align_sgs(req->src, nbytes, bs, final, rctx); + ret = omap_sham_align_sgs(req->src, rctx->total, bs, final, rctx); if (ret) return ret;