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: 17269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp338652vqn; Wed, 29 Nov 2023 05:32:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNBkPB7s79rJohREQAcXCJCcT5H1IWkLA7JDLcBtJ3A+WgNisPNXr9ETLHbd12f/fhH+6p X-Received: by 2002:a17:902:d2c6:b0:1cf:cf34:d4fa with SMTP id n6-20020a170902d2c600b001cfcf34d4famr12117847plc.28.1701264754990; Wed, 29 Nov 2023 05:32:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701264754; cv=none; d=google.com; s=arc-20160816; b=IgUJc9H6Cuabxh+MhpBaXTHmzCJdG0U/zyZWSrHRgCr12YpL36WnAaw9D9tf0trqBd gfAwrZxUTWIZGk2uroL1gKRhmPEMT1V/rVNcCR/rxlV0lgMhvIQk9ywfNIPshhCGOK95 Irpjr6EoQylDgppVV0gvCioG9gtnw1/dnF9f17duUlJssFByepxXXgUpq763luHN2fhx Oz44Au9UPe///o526BY3NtoguWXrAi9kIMJjcCTwJEYXss1ET0Gt7fBclk5Tf7pLziSD EFs4AUFknTKpXRT7reE+uucsZ2jDTthFPwBWQ/FolhRUuE8o9Zk8EHrTnKf2D3D28ROC /n5A== 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=4kppMjNPf1GKwvIU18Ptl9YLUNAOWni/rWCQpmP6c8g=; fh=FpEFgSTsD9KOdZrv5i/8e/czx6Pnhsq5lU2kOotSX/I=; b=dluInPU3+/JujeqrdlxXe4aPkp1Bq3+r8+ZHRcnSsVTXijHBUTPDz0KL/7RP2uz4Hu ioQs2+E3+lNjCZBCuxb9W5aNFfkSizLxYvqh0TgliXq41akINRNlnXDeAV4oGfquOAxK fDVq15SSWAcTwHykC/YNbrmC4VpBAwja5xI3VrgqSCAF8FEPxcGXWSPo3QPlSapy5JcH WWvsmkQhENWcYaOoD7KpQranAZhJ2p7Bl9+yco3kTqrR700tCAVxPNxlVm2WnltuYUFq eeCM/bcjbIKR2GgJ8K5oKC+RP3iz8jDeairjlnnx3j8v0rdCvgD6gF3qrC7rCMQFc0Ym eQVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PvEEKZi+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=cZCeWPix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id z8-20020a170903018800b001cfd754d789si6161051plg.137.2023.11.29.05.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:32:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PvEEKZi+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=cZCeWPix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 91CCD82217B3; Wed, 29 Nov 2023 05:32:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232882AbjK2NcU (ORCPT + 99 others); Wed, 29 Nov 2023 08:32:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbjK2NcT (ORCPT ); Wed, 29 Nov 2023 08:32:19 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0944E9D; Wed, 29 Nov 2023 05:32:26 -0800 (PST) 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-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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 29 Nov 2023 05:32:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783905391850067118 X-GMAIL-MSGID: 1783905391850067118 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(-)