Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4709247rdh; Wed, 29 Nov 2023 08:32:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjYQmTWgSC+fWZCJL3xYZc1atsuSvrWWukcLf1I+/PiBIXkbzrlyHppcsWXCFjbdX/otJQ X-Received: by 2002:a05:6a00:c94:b0:6cc:b448:3654 with SMTP id a20-20020a056a000c9400b006ccb4483654mr15628334pfv.18.1701275564707; Wed, 29 Nov 2023 08:32:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701275564; cv=none; d=google.com; s=arc-20160816; b=gqD8x/agPJdCYone/DhmmZ3wXMWPMX/DMKM3h0D0RRO1/QsCD1vWaWQRXjG7L01hvk ynB/3G8QfuOk4f9AjDlqi6poCeKs12P+EvdAGT9cfKaHdD890REQHYS6iI+3q6gQ8XYe mopD0BUuWezWkx68M0uGPnkjWOIR7+rGB6gyAUSffHpwq8V5TRrfRDNZFknhXUb5OckI WMlX8ZxNUPZ5a3Yiymgmm514uxoelilLxw489M0vX9q8sgtcZ2PD1AVhAp8TWuNv/RPT apJqGrdqkJPpKJMj6tOTN2dS0AxXzMFESt7S9L7EyzzKl1MjLKb/pkg7P/v+8tYpSwTu SijA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:dkim-signature:from; bh=wgM6REurFe0euNPRsJDjg3HXoLEfDSQ4SWRzMt9M5cI=; fh=FpEFgSTsD9KOdZrv5i/8e/czx6Pnhsq5lU2kOotSX/I=; b=tDyqRqoKrPl6aRnkUDpVdMxw7g+9FYve/+mvpYVbbc0kapjyWxyIhnh/VyzXg0quxn sPcPOeP77piAboPBKDX1rQgIhCxhojyvJDiydFz2Qxsi7+bOpb/M/djJK05lVdzbqGZT cCjUh862p3MAs5EPw8uNvrqvEXuLg7YCBwkM/F86WcbzN9TOuPQb+vx5XhjCXAHmQlD9 2sb0O0isD2bWPqKcES3m/50dgmBojoPXGpmwFZD0DoDCi6/CAMG3N0SDRnEthg/tWpDl WfcFQ3GNAl+ydMmdJnlV85MEF2NRB9QO8zkgtaCYDFgxx6Ec9UXwFW0We7ROtoQIncd2 aTrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XpqxKD4q; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=78QriPAc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id h22-20020a056a00219600b006cbb2cd545esi14835138pfi.5.2023.11.29.08.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 08:32:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XpqxKD4q; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=78QriPAc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 78E00804C212; Wed, 29 Nov 2023 08:32:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbjK2QcY (ORCPT + 99 others); Wed, 29 Nov 2023 11:32:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjK2QcX (ORCPT ); Wed, 29 Nov 2023 11:32:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B423BF; Wed, 29 Nov 2023 08:32:30 -0800 (PST) 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 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 08:32:39 -0800 (PST) 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(-) --=20 2.39.2