From patchwork Tue Mar 22 16:04:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 8643911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 938079F3D1 for ; Tue, 22 Mar 2016 16:07:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6D6120340 for ; Tue, 22 Mar 2016 16:07:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D6B132025A for ; Tue, 22 Mar 2016 16:07:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aiOoQ-0004qg-Eu; Tue, 22 Mar 2016 16:05:42 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aiOoM-0004mU-KH for linux-arm-kernel@lists.infradead.org; Tue, 22 Mar 2016 16:05:39 +0000 Received: by mail-wm0-x22a.google.com with SMTP id p65so170363599wmp.0 for ; Tue, 22 Mar 2016 09:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=XfGzLyhUvBNpBuq6pav66+zKL/qCNKXh+EYC9hLUTeA=; b=0jmy6um5z0mkJ61gnauyMbt4ZJQ6XVPANzaazMmDgbB4sN7pstnb95PR3jVfOqKXkE lzHTR7oGMlSvsspoOeyy6uTGd1Snh6weV8PyO0fFPYdsu51AeA4I7z7reTrlxJIFFD5y zz256vuKADq0RkOrHZDWTWXH5foZvDz1o6J8iz7C/lZ9LvWHEOrO6O9LTCV3mWn0Ujfs BOJNL6bP58lKBu7DqO4WHsb0fR09mKP+dNhWVwCxTpezPLr5lbKsCvfPDhPVF+78b8y8 pyDI6FEbl3JeNKdQEh5VmZJgg4D23OluSFLvO0nvEUxz2ac03Ejv/l6/Yz8Ff01trZEq tQQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XfGzLyhUvBNpBuq6pav66+zKL/qCNKXh+EYC9hLUTeA=; b=Pxc+rnsOSJg/MQQsnJ8a9sWIOH39prBJrybDgejSzM99Fk9jNmr7zflMZVcepNQ/+6 /DnnZ+cs7Veb9pr+DKPOGx7exNw92Q1ZxXAHam6F4T+R8J0JI7QGI2DFehIS3l3bTvWl 2LuQ7g9H8zmpsgnUCj8xS5SHCsCKBl0qSzBX4SikEcBPnKSW/BbczXlU4Om/tCNgFRZS 26+urnnevGM1O+Pfh8Nz58vq/hBdU9m070srPWvqviBX/TWWZOd5HfHM7QfYUSFbhuLS kCx9etXQQKvicYoCvxLD0QtNeLZLpz6gK4SiQ+wdwXuD01Nv0GiD2sMKdkZPYy+jbob6 Herw== X-Gm-Message-State: AD7BkJJpye3vJVSc3NnH6aRHU8HpxW81SJsplWpdSyPfZ43AyconXH+yqMiTdV9IytBV0w== X-Received: by 10.28.211.130 with SMTP id k124mr21769111wmg.7.1458662716549; Tue, 22 Mar 2016 09:05:16 -0700 (PDT) Received: from Red.local (ANice-651-1-347-184.w86-205.abo.wanadoo.fr. [86.205.131.184]) by smtp.googlemail.com with ESMTPSA id k124sm17941216wmb.11.2016.03.22.09.05.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Mar 2016 09:05:15 -0700 (PDT) From: LABBE Corentin To: herbert@gondor.apana.org.au, davem@davemloft.net, maxime.ripard@free-electrons.com, wens@csie.org Subject: [PATCH] crypto: sun4i-ss: use spin_lock_irq{save|restore} Date: Tue, 22 Mar 2016 17:04:54 +0100 Message-Id: <1458662694-25527-1-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.7.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160322_090538_839312_83F8FD81 X-CRM114-Status: GOOD ( 12.87 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stable , LABBE Corentin , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current sun4i-ss driver is subject to data corruption when ciphering/deciphering. It occurs randomly on end of handled data. No root cause have been found and the only way to remove it is to replace all spin_lock_bh by they irq counterparts. Signed-off-by: LABBE Corentin Cc: stable --- drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c index a19ee12..e72fea73 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c @@ -35,6 +35,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) unsigned int todo; struct sg_mapping_iter mi, mo; unsigned int oi, oo; /* offset for in and out */ + unsigned long flags; if (areq->nbytes == 0) return 0; @@ -49,7 +50,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) return -EINVAL; } - spin_lock_bh(&ss->slock); + spin_lock_irqsave(&ss->slock, flags); for (i = 0; i < op->keylen; i += 4) writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); @@ -117,7 +118,7 @@ release_ss: sg_miter_stop(&mi); sg_miter_stop(&mo); writel(0, ss->base + SS_CTL); - spin_unlock_bh(&ss->slock); + spin_unlock_irqrestore(&ss->slock, flags); return err; } @@ -149,6 +150,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) unsigned int ob = 0; /* offset in buf */ unsigned int obo = 0; /* offset in bufo*/ unsigned int obl = 0; /* length of data in bufo */ + unsigned long flags; if (areq->nbytes == 0) return 0; @@ -181,7 +183,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) if (no_chunk == 1) return sun4i_ss_opti_poll(areq); - spin_lock_bh(&ss->slock); + spin_lock_irqsave(&ss->slock, flags); for (i = 0; i < op->keylen; i += 4) writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); @@ -308,7 +310,7 @@ release_ss: sg_miter_stop(&mi); sg_miter_stop(&mo); writel(0, ss->base + SS_CTL); - spin_unlock_bh(&ss->slock); + spin_unlock_irqrestore(&ss->slock, flags); return err; }