From patchwork Wed Nov 29 13:32:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 13472865 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 D465AC10DAA for ; Wed, 29 Nov 2023 13:32:55 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=aLsrpRtr5ETAr4C90rUK+RLWF0HucIctWW8Nxos1xPw=; b=TZSGKqFbpYAmN2 8PkEMMHSznhXEmZFZzJWnTTqAgZZa8F22a87zFAigJXuP8iMRDPfchq4d/QxlMpmFX84CCweNdMGS BLg2pGSMKrK3zFxQUJOQspkzgH6MT7AHB9TKyP4zlVsl6sLSJu+lMqTLxtrBZ7V1/w+b3ah4d6evI jFfBEKw2TkYm1vp37v2meF0ESsoVU+dShNz5V41wBv7F0bLTU+n75yLKLg/o5G9UeG1gXWmUUdfLM R+FOw5JSAEli+2LvsgAd902av3DnwydTAp01huGrplO8t4+4TkMPIGlhy6IR1zoU6RVhu0dPHl2S3 Lq5gU/TTJSrHaKNrkORw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Kg4-008TSQ-2i; Wed, 29 Nov 2023 13:32:32 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8Kg2-008TRG-0B for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2023 13:32:31 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701264744; 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=4kppMjNPf1GKwvIU18Ptl9YLUNAOWni/rWCQpmP6c8g=; b=PvEEKZi+brEqPQ8OQRPOWt0chNcNLzDHQoN0j2L2GW4V/8SPzJDhHYDof4k2PAkPf9B2jq 9aMgfMdBtj09ljuQpoC/9h2WAKQy9JhSPz8Wa6eV5Vu2mGvTO9zzc28HG3g+ppLUt0Oz86 B160SzuFerkL4ToSRxko96gJm6IrAvosekVRMR7aldlKEq9a3/QpTmxsjkFTEGah4dJpvM nGCZgwrRrHY5rflUNEMvGjpDVifP8mi6SmhQaa0O78YLuoD86Zpao7mPh+9cqa0O66kkAO nR9Ut5FCnp5TXiRpqihMg7OCe+p0DEon+u7V49OcX4yqBpMOseE4V1ONlVt4xA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701264744; 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=4kppMjNPf1GKwvIU18Ptl9YLUNAOWni/rWCQpmP6c8g=; b=cZCeWPixlXbm9/0ZN/s6Zf16kJHyUsdaXP+dwG+0mQ6kkKXSexhziIrvU57eBq/zAHiKPa PSo4cRDO9Ch7hMCg== To: linus.walleij@linaro.org, broonie@kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 0/2] spi: spl022: fix sleeping in interrupt context Date: Wed, 29 Nov 2023 14:32:17 +0100 Message-Id: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_053230_233411_0DEA9482 X-CRM114-Status: GOOD ( 13.70 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, While running the spl022, I got the following warning: BUG: sleeping function called from invalid context at drivers/spi/spi.c:1428 This is because between spi transfers, spi_transfer_delay_exec() (who may sleep if the delay is >10us) is called in interrupt context. This is a problem for anyone who runs this driver and need more than 10us delay. Patch 1 adds an error reporting mechanism, needed by patch 2 who switch to use the default spi_transfer_one_message(), which fix the problem. The series is tested with polling transfer mode and interrupt transfer mode. I can't test the DMA mode, so some help testing here is very appreciated. One question: This series is quite big for stable trees, so how can we backport this fix? We can: - Let it be released, and get tested for some time. After a while without any reported problem, backport it. - Have a small patch which fixes this problem. One idea I have is to switch the current interrupt handler to threaded interrupt handler, and switch from existing use of tasklet to workqueue. So that the driver can safely sleep if needed. And then add this series on top of that. - other options that I miss? Best regards, Nam Nam Cao (2): spi: introduce SPI_TRANS_FAIL_IO for error reporting spi: spl022: switch to use default spi_transfer_one_message() drivers/spi/spi-pl022.c | 372 +++++++--------------------------------- drivers/spi/spi.c | 3 + include/linux/spi/spi.h | 1 + 3 files changed, 70 insertions(+), 306 deletions(-)