From patchwork Wed Mar 23 15:11:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 8650871 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 25188C0553 for ; Wed, 23 Mar 2016 15:13:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 126FD2026D for ; Wed, 23 Mar 2016 15:13:40 +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 3D8D72025A for ; Wed, 23 Mar 2016 15:13:38 +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 1aikSC-00012C-QX; Wed, 23 Mar 2016 15:12:12 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aikS9-0000wi-QS for linux-arm-kernel@lists.infradead.org; Wed, 23 Mar 2016 15:12:10 +0000 Received: by mail-wm0-x244.google.com with SMTP id u125so5140268wmg.0 for ; Wed, 23 Mar 2016 08:11:49 -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=FXZ6b3mutyJcT+9MvA0ad2IFC/sERzZNv3mW4UGPL6c=; b=NvsrlnvNesjb7iXEJ88ejAOs45dBNQCeRmrr3qWuoxpX+FgF5+NGA2k7YnGXvoQC+H ZeFIA0ZREcyeWrMWGTZv4QLcQaF3YjYha2L9CpFUUUhOgOZY09AtawA+UBkaSkv7Ljvl ZpQ0gRzMuP26BUse+K6Kz3ZCOyXvvKncoNE/2OKUTT6nLV7Fgye0jtFmfYMKj60YgIWi aPeIkezSIcAHmBwIHi8pq5w0CO8VVle5AfdRbxEcYk/rJpOQ/vZDNFNLqbGitoE56bT0 KtcA0QcddvlimNH3cJdfT0t9TLxy+Naqcfaktqn6M//c3hGoHDAbJbQFthejCBJZFU4I wodA== 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=FXZ6b3mutyJcT+9MvA0ad2IFC/sERzZNv3mW4UGPL6c=; b=OzCx9Nmagl1jgU6yJBtXGwYLTs9JhPCDRUqLS+V6rxVHm0TSwwdItPY6tmQPucFc3f m2tWAi3dL50fF0Poohwf6pElkaH5F52wfiJI99F9NrrwII7RdIrxS3VOW8jJlcRil1JL DucTiZ04+z3Upo+ZQ+6gGKQt/OjWMyjHG1bnh9y//L7EQKiHFZprWMOaAk4ifjRAU18k MU8OfnR5I8kChPR0x/uTz2fEErQi4nsIxdoTzDRM+y1pekhbVpcHI6WZRiAYGZ4QYxxt znuJH3quC5b3Trywo+jU0TC7XDAclTg/J0EW39eSGmzqLMVnEkA/xSItWbjX3TFMwpU0 //9A== X-Gm-Message-State: AD7BkJI5H06MCnEuk3Gk+D6sVp26M7/Jbk18tEvELfuS5b6GtP89PTARhu+ge5PyiGLpMw== X-Received: by 10.28.224.212 with SMTP id x203mr27908043wmg.75.1458745908249; Wed, 23 Mar 2016 08:11:48 -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 82sm22629126wmd.4.2016.03.23.08.11.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Mar 2016 08:11:47 -0700 (PDT) From: LABBE Corentin To: herbert@gondor.apana.org.au, davem@davemloft.net, maxime.ripard@free-electrons.com, wens@csie.org Subject: [PATCH RESEND] crypto: sun4i-ss: Replace spinlock_bh by spin_lock_irq{save|restore} Date: Wed, 23 Mar 2016 16:11:24 +0100 Message-Id: <1458745884-27798-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-20160323_081210_011100_0F649D16 X-CRM114-Status: GOOD ( 12.59 ) 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 could generate 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 their irq counterparts. Fixes: 6298e948215f ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator") 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 7be3fbc..3830d7c 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); @@ -307,7 +309,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; }