From patchwork Wed Nov 29 16:31:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 13473195 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 A8FB3C4167B for ; Wed, 29 Nov 2023 16:33:03 +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=WKl5UUWeDNDkDAxn1ZH8wsF2JnuerSeGFrndO1J0MgA=; b=o1vQbOn/Hij4Qk wKWby621TkOTPs9eRUxQCPdcSfNbZqiHDmmFtzTF85jswQTFawaheFxY6U0tsFY886qZm0E78U2Rj hBROoaHfCBfWlv4gdZ7rj90+dLClBU6Y2Oo/yMVg8GQf0WF56EcJu30W/NS/PpzZbycM5YOsqe2bQ WT0zdCXtUXfypISmur3uLfDZaHZInsf65zOaVcfm1BhXoAv3TxzoQIfeYUFYEikUOAaLEeNpRj4fz kLC0HLKmTUGuZPH8eLntPvKUCUDcbKUN0fhDG7OPquzcO6XJHXNSlAyQqcNHrnfL9x0aAZ6wImWm8 0sglhXhQYTPFj0f7qR/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8NUH-008tlL-1n; Wed, 29 Nov 2023 16:32:33 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8NUE-008tkS-1q for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2023 16:32:31 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701275548; 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=wgM6REurFe0euNPRsJDjg3HXoLEfDSQ4SWRzMt9M5cI=; b=XpqxKD4qG4IArSrfbweYlaVcHx5kpYWy0Fqnhl7xxcyCd+SwoUhjJYaPSRB/Ei/3jhjZkX VH8jZ+40xLF248HPNpe/HZq2ON4qzAZGoKdqcOYOXl2BICeGo1MhLaHbBekMYO7R1OTO1s O6Hcv3rBMJD/hRBVadpfqCJRtm/Ir112/N00belHKO3DfAsEitj8eRYWq1MothKK/wc2lM 5tLecwZJooVolLjDPkFileVyWxLWnjyM5d7Q9OY+QkJ4yEJ11erb+vqdBWF3oacArwmMjA sp/7oDwwpfAfziwJhTHOXsvpAeTQZFjynfy/Y2+ztiJ5jalgUq5Pv+usmzmbMw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701275548; 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=wgM6REurFe0euNPRsJDjg3HXoLEfDSQ4SWRzMt9M5cI=; b=78QriPAcEvZ6gzjZS4NXrw2dqKDfscF3IfvztobeI6yP+Q+8MqK0H+86nx0AgLQqgHAwVR afyoW1AmUv1McxAQ== 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 v2 0/2] spi: spl022: fix sleeping in interrupt context Date: Wed, 29 Nov 2023 17:31:54 +0100 Message-Id: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_083230_789971_CC85552C X-CRM114-Status: GOOD ( 14.47 ) 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 v2: add some documents for the new flag. No functional change. 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 | 12 +- 3 files changed, 77 insertions(+), 310 deletions(-)