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 6BC60EFCE37 for ; Wed, 4 Mar 2026 18:17: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:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=SFcOhY5xKXNxtQJNP869O3hZ0440orV55V9obU/tYro=; b=bXqeTI1POLzw3h 2BGuSX9Ll+9b5NyULlceeWSCv6bg1hDh1gNA5WQ1p+BmX+tgxlSCxwUSFYJDxYanfW+yi5gp7y+tM LalIQAUGU+MNLmRhTG7KaGx3oM+7EJlR1lL5mdRj4Qe9skVeSCWZC7p87S9ozuDZ25CVzLmHSTnwH kJxfd4gIsEtG1wxjaUXHlplhlp6rPv5czJCvQpFVOUMRgDK/XEUCuC4Ufwr1huPshWqcH5hp35Lbg xpeNO9I62qX5VYWdj0MHKQP34Z1i9KkTaZS83qEmEtq0NxqpPUf+mEtV8957AmIQmeuJci3Xo8LrX BprH/CdNI9sLMuehjT4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxqmv-00000000K9O-2yfp; Wed, 04 Mar 2026 18:17:37 +0000 Received: from mgamail.intel.com ([192.198.163.19]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxqmt-00000000K1V-1YZ5 for linux-i3c@lists.infradead.org; Wed, 04 Mar 2026 18:17:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1772648256; x=1804184256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wcdp6EMUqEBKkfw95WRgZ70Pbgb75gQd39eoVDYkDY8=; b=OdrXj3FwodeHo5aq1CAeVElRqFzw3M5B699R9BY4YFiGr5Jn5QwJPm8U IZQvybY7jx3g0pX8/j/7RDWSCoSF/n3lYxGKpUaD56dAjKFUVeL6kMeFl psgrO22PtpW+2S8oY1hlgzfHabgxm9XGvxfvUh1pregDXvFBluOGXpk2c NxlKxyALBzf1LyGQ4rmRrKCIpJs3CtEkAi62cRlJZwLxhWOlexWIInF1G LYFRfxAWBGKrOYD2tRfTEFOs4A8DxQEpBkNEq/7Aw92FcPFHAmw5/Te2v R2ZTLhTwf1zTBGYZwF3uD8bF1MU+2F9GAZXJkspPYy0MRCAY8fjFd3oTN A==; X-CSE-ConnectionGUID: sCkVLxRKT6yoqzvTO48VXA== X-CSE-MsgGUID: q9c83eH2RbmwYybfofaf0Q== X-IronPort-AV: E=McAfee;i="6800,10657,11719"; a="72745920" X-IronPort-AV: E=Sophos;i="6.21,324,1763452800"; d="scan'208";a="72745920" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2026 10:17:35 -0800 X-CSE-ConnectionGUID: pZ8yZL6qTmifS8fpXE35Tw== X-CSE-MsgGUID: 5yx0Ev/EQ6WmVYnp0f7stA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,324,1763452800"; d="scan'208";a="217656768" Received: from dalessan-mobl3.ger.corp.intel.com (HELO ahunter6-desk) ([10.245.245.133]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2026 10:17:34 -0800 From: Adrian Hunter To: alexandre.belloni@bootlin.com Cc: Frank.Li@nxp.com, linux-i3c@lists.infradead.org Subject: [PATCH V2 08/14] i3c: mipi-i3c-hci: Correct RING_CTRL_ABORT handling in DMA dequeue Date: Wed, 4 Mar 2026 20:16:59 +0200 Message-ID: <20260304181706.143841-9-adrian.hunter@intel.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260304181706.143841-1-adrian.hunter@intel.com> References: <20260304181706.143841-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260304_101735_430545_2247FB60 X-CRM114-Status: GOOD ( 13.48 ) X-BeenThere: linux-i3c@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-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org The logic used to abort the DMA ring contains several flaws: 1. The driver unconditionally issues a ring abort even when the ring has already stopped. 2. The completion used to wait for abort completion is never re-initialized, resulting in incorrect wait behavior. 3. The abort sequence unintentionally clears RING_CTRL_ENABLE, which resets hardware ring pointers and disrupts the controller state. 4. If the ring is already stopped, the abort operation should be considered successful without attempting further action. Fix the abort handling by checking whether the ring is running before issuing an abort, re-initializing the completion when needed, ensuring that RING_CTRL_ENABLE remains asserted during abort, and treating an already stopped ring as a successful condition. Fixes: 9ad9a52cce282 ("i3c/master: introduce the mipi-i3c-hci driver") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Reviewed-by: Frank Li --- Changes in V2: Add Frank's Rev'd-by Mutex is now defined in struct i3c_hci drivers/i3c/master/mipi-i3c-hci/dma.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c index d7840ff69e59..a3e8e01a35c9 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dma.c +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c @@ -546,18 +546,25 @@ static bool hci_dma_dequeue_xfer(struct i3c_hci *hci, struct hci_rh_data *rh = &rings->headers[xfer_list[0].ring_number]; unsigned int i; bool did_unqueue = false; + u32 ring_status; guard(mutex)(&hci->control_mutex); - /* stop the ring */ - rh_reg_write(RING_CONTROL, RING_CTRL_ABORT); - if (wait_for_completion_timeout(&rh->op_done, HZ) == 0) { - /* - * We're deep in it if ever this condition is ever met. - * Hardware might still be writing to memory, etc. - */ - dev_crit(&hci->master.dev, "unable to abort the ring\n"); - WARN_ON(1); + ring_status = rh_reg_read(RING_STATUS); + if (ring_status & RING_STATUS_RUNNING) { + /* stop the ring */ + reinit_completion(&rh->op_done); + rh_reg_write(RING_CONTROL, RING_CTRL_ENABLE | RING_CTRL_ABORT); + wait_for_completion_timeout(&rh->op_done, HZ); + ring_status = rh_reg_read(RING_STATUS); + if (ring_status & RING_STATUS_RUNNING) { + /* + * We're deep in it if ever this condition is ever met. + * Hardware might still be writing to memory, etc. + */ + dev_crit(&hci->master.dev, "unable to abort the ring\n"); + WARN_ON(1); + } } spin_lock_irq(&hci->lock); -- 2.51.0 -- linux-i3c mailing list linux-i3c@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-i3c