From patchwork Tue Dec 5 08:31:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13479560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2201EC4167B for ; Tue, 5 Dec 2023 08:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=QvYfaUEQqFkNc5Ac7GE4SwET1U+c9LbaTZ1x3ynvCRI=; b=W6puKNM3uCMU1T 8Jqgu5AvUGNjQDNZv2p7cHUHYxk3sGHRIN2MMLHpvRIvhgIsARsiMwWsE02d/KBLrgVT1UGBv6P3F X+Ela5EEfrKC/dUciTGL+b+t76NxeqQBjT69jbfRj84oZ5MYd3C0u+Tg3UVBQ7zN3v5zsR5qd6Qgi ZjGyXmACM9obgMn2Atq+qcQOUCQJ7uqF/tgmNjiyDnslJp4WmnEBwKigQObvrCD2mktvYGVUsnjgC 32CBqkLtptTEFXutkM1eKGSeZYe4L0bXO+ArRd1qpYbZpkT2YDJ2qXVr4/WZZVOBstVN61dLPp6vT mZJKZnTD4h/PKdN74KyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAQpp-006egy-2n; Tue, 05 Dec 2023 08:31:17 +0000 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rAQpk-006eew-0V for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 08:31:15 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 39A1E6000D; Tue, 5 Dec 2023 08:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701765066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=FYWMV4zrEtZnbrExDx0nqD3HDOe9zXAaFMqIEbZCOCo=; b=QK0mMsEzWUW1JKqu6XipwK9zZcjEkQ0tWwgw5EsAf/Ggs4sBg3pRztf1EuY0+cA62EQmVv ZX+kjNuD7X8WBUOXcfCG3Ovid8QnaCISpkLjkZEHL5FS9Hdb+cZXhchGtR2Nggj/61GaFO ZV682MPmuNjiaE+7hpucQczgX+Ij40u/eqNtal4XAOgy8ouW81tcMLaIN1wRmPAFmcRHQw 12c26I9B8hcV9WoM9wTcnqKYAy2dN3QoXO2t8tsuksl+d2anSkkZSW6rkFGOASn49lF/9Y AVatn5K3Fu9GVdzmKwHhyAZ3SBE6EuPm8hhzA9Q3280bn3vFeHtguQOk9x3Rxg== From: Miquel Raynal To: Mark Brown , Subject: [PATCH] spi: atmel: Prevent spi transfers from being killed Date: Tue, 5 Dec 2023 09:31:02 +0100 Message-Id: <20231205083102.16946-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_003112_488354_086A98BB X-CRM114-Status: GOOD ( 14.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Ryan Wanner , Richard Weinberger , stable@vger.kernel.org, Claudiu Beznea , David Laight , Thomas Petazzoni , Miquel Raynal , Ronald Wahl , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Upstream commit e0205d6203c2 ("spi: atmel: Prevent false timeouts on long transfers") has tried to mitigate the problem of getting spi transfers canceled because they were lasting too long. On slow buses, transfers in the MiB range can take more than one second and thus a calculation was added to progressively increment the timeout value. In order to not be too problematic from a user point of view (waiting dozen of seconds or even minutes), the wait call was turned interruptible. Turning the wait interruptible was a mistake as what we really wanted to do was to be able to kill a transfer. Any signal interrupting our transfer would not be suitable at all so a second attempt was made at turning the wait killable instead. Link: https://lore.kernel.org/linux-spi/20231127095842.389631-1-miquel.raynal@bootlin.com/ All being well, it was reported that JFFS2 was showing a splat when interrupting a transfer. After some more debate about whether JFFS2 should be fixed and how, it was also pointed out that the whole consistency of the filesystem in case of parallel I/O would be compromised. Changing JFFS2 behavior would in theory be possible but nobody has the energy and time and knowledge to do this now, so better prevent spi transfers to be interrupted by the user. Partially revert the blamed commit to no longer use the interruptible nor the killable variant of wait_for_completion(). Fixes: e0205d6203c2 ("spi: atmel: Prevent false timeouts on long transfers") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal Tested-by: Ronald Wahl --- drivers/spi/spi-atmel.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 0197c25f5029..54277de30161 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1333,12 +1333,10 @@ static int atmel_spi_one_transfer(struct spi_controller *host, } dma_timeout = msecs_to_jiffies(spi_controller_xfer_timeout(host, xfer)); - ret_timeout = wait_for_completion_killable_timeout(&as->xfer_completion, - dma_timeout); - if (ret_timeout <= 0) { - dev_err(&spi->dev, "spi transfer %s\n", - !ret_timeout ? "timeout" : "canceled"); - as->done_status = ret_timeout < 0 ? ret_timeout : -EIO; + ret_timeout = wait_for_completion_timeout(&as->xfer_completion, dma_timeout); + if (!ret_timeout) { + dev_err(&spi->dev, "spi transfer timeout\n"); + as->done_status = -EIO; } if (as->done_status)