From mboxrd@z Thu Jan 1 00:00:00 1970 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 BE206CCFA0D for ; Wed, 5 Nov 2025 22:30:38 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qyyVUWht5f7E4jjs0MMjrNOyfo96HfbxQd47+88oWxw=; b=ip/tVoUisKxJ3+ a0DMltMa0v1KsKYnB+Tzm/cTQGCZCHI+m9CUW+odxJhtP0bIA89k6RkYhqNDa9HxAQZNJb4W2KfH1 hiCgG9BAn38N6rwTYpJhfpsgfym2wiEM0W+mxyoB79muPQ6UAhIkSzFHQZcz9bWmnQto/9FEaPGfu 9g2BsGcDzh/0VoVIes8BZ2DM3sw/1PyXCkIpaA+NLO4Bf8OTozHxTZepFK3Yy2DulZ8zm7naRWMN4 dbGytVQV8bZiku+Ydl9GTI4Xvek0qVfKXxPpgBWxupy1hPcy+yx8mKD/LCHu+czBTL/2r1s2ngjVI YlZNUUJXp6LyqYFSyA8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vGm18-0000000EZmk-2Qji; Wed, 05 Nov 2025 22:30:14 +0000 Received: from hall.aurel32.net ([2001:bc8:30d7:100::1]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vGm15-0000000EZlu-2MhP for linux-riscv@lists.infradead.org; Wed, 05 Nov 2025 22:30:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Content-Transfer-Encoding:From:Reply-To: Subject:Content-ID:Content-Description:X-Debbugs-Cc; bh=1WB5YF5L/yshQ2OgpgkrePCro6RnXwXz3n/xIbIvOQY=; b=OPcHwbqxQ1iw8ViCOSGmOjffci YP2eeZLGx6cZSs8sw7JAHuDe5wiKgcWCxhbfIODy0ThEKlw2loWmouMvUq53+VRy9L+tBISfR/n/B Ip0DZd8V3WIFGFL4ZWNz4WdAmdV796F++EyH+7AwpvssVy/ZadmfxMhmXCdwXIb4WUghzqiHFgven UlX9E9iFTg7sus1a5XimzT+O3h/08xnSOG/uaMfH6l97pvvtSTTCNcWvMzC+1jhkMWdEo94219tQh 7bqaK58K91lOo1Y3yDaVuuHmSeoh7LxG6A7poi6+IiIMkzAYi8wXrafdsXe4Wop5e2pE47lvJugxn DPLD1sjA==; Received: from [2a01:e34:ec5d:a741:1ee1:92ff:feb4:5ec0] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vGm0n-0000000AelV-0U9O; Wed, 05 Nov 2025 23:29:53 +0100 Date: Wed, 5 Nov 2025 23:29:52 +0100 From: Aurelien Jarno To: Troy Mitchell Cc: Andi Shyti , Yixun Lan , Alex Elder , Troy Mitchell , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev Subject: Re: [PATCH v4] i2c: spacemit: introduce pio for k1 Message-ID: Mail-Followup-To: Troy Mitchell , Andi Shyti , Yixun Lan , Alex Elder , Troy Mitchell , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev References: <20251009-k1-i2c-atomic-v4-1-a89367870286@linux.spacemit.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20251009-k1-i2c-atomic-v4-1-a89367870286@linux.spacemit.com> User-Agent: Mutt/2.2.13 (2024-03-09) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251105_143012_086295_DB6C2725 X-CRM114-Status: GOOD ( 21.73 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Hi, On 2025-10-09 17:59, Troy Mitchell wrote: > This patch introduces I2C PIO functionality for the Spacemit K1 SoC, > enabling the use of I2C in atomic context. > > Signed-off-by: Troy Mitchell > --- > Changes in v4: > - refactor for better readability: simplify condition check and moving if/else (timeout/ > wait_xfer_complete) logic into a function > - remove irrelevant changes > - remove the status clear call in spacemit_i2c_xfer_common() > - sort functions to avoid forward declarations, > move unavoidable ones above function definitions > - use udelay() in atomic context to avoid sleeping > - wait for MSD on the last byte in wait_pio_xfer() > - Link to v3: https://lore.kernel.org/r/20250929-k1-i2c-atomic-v3-1-f7e660c138b6@linux.spacemit.com > > Changes in v3: > - drop 1-5 patches (have been merged) > - modify commit message > - use readl_poll_timeout_atomic() in wait_pio_xfer() > - use msecs_to_jiffies() when get PIO mode timeout value > - factor out transfer state handling into spacemit_i2c_handle_state(). > - do not disable/enable the controller IRQ around PIO transfers. > - consolidate spacemit_i2c_init() interrupt setup > - rename is_pio -> use_pio > - rename spacemit_i2c_xfer() -> spacemit_i2c_xfer_common() > - rename spacemit_i2c_int_xfer() -> spacemit_i2c_xfer() > - rename spacemit_i2c_pio_xfer() -> spacemit_i2c_pio_xfer_atomic() > - call spacemit_i2c_err_check() in wait_pio_xfer() when write last byte > - Link to v2: https://lore.kernel.org/r/20250925-k1-i2c-atomic-v2-0-46dc13311cda@linux.spacemit.com > > Changes in v2: > - Patch 1/6: > Patch 3/6: > Patch 4/6: > - nothing > - Patch 2/6: > - remove is_pio judgement in irq_handler() > - Patch 5/6: > - fix wrong comment > - In spacemit_i2c_conditionally_reset_bus(), once the condition is met inside the loop, it should > return directly instead of using break. > - Patch 6/6: > - add is_pio judgement in irq_handler() > - use a fixed timeout value when PIO > - use readl_poll_timeout() in spacemit_i2c_wait_bus_idle() when PIO > > - Link to v1: https://lore.kernel.org/r/20250827-k1-i2c-atomic-v1-0-e59bea02d680@linux.spacemit.com > --- > drivers/i2c/busses/i2c-k1.c | 229 +++++++++++++++++++++++++++++++++++--------- > 1 file changed, 185 insertions(+), 44 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c > index 6b918770e612e098b8ad17418f420d87c94df166..a13284f840ee967466a01375e6603f7568a42f86 100644 > --- a/drivers/i2c/busses/i2c-k1.c > +++ b/drivers/i2c/busses/i2c-k1.c > @@ -97,6 +97,8 @@ > > #define SPACEMIT_BUS_RESET_CLK_CNT_MAX 9 > > +#define SPACEMIT_WAIT_TIMEOUT 1000 /* ms */ > + > enum spacemit_i2c_state { > SPACEMIT_STATE_IDLE, > SPACEMIT_STATE_START, > @@ -125,10 +127,14 @@ struct spacemit_i2c_dev { > > enum spacemit_i2c_state state; > bool read; > + bool use_pio; > struct completion complete; > u32 status; > }; > > +static void spacemit_i2c_err_check(struct spacemit_i2c_dev *i2c); > +static void spacemit_i2c_handle_state(struct spacemit_i2c_dev *i2c); > + At least for spacemit_i2c_err_check, the forward declaration can be avoided by moving code, which is anyway probably better done in a separate patch. Besides this nitpick, this sounds good, so: Tested-by: Aurelien Jarno Reviewed-by: Aurelien Jarno Regards Aurelien -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://aurel32.net _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv