From nobody Mon Jun 8 19:56:25 2026 Received: from smtp134-31.sina.com.cn (smtp134-31.sina.com.cn [180.149.134.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB69931355C for ; Wed, 27 May 2026 06:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=180.149.134.31 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863119; cv=none; b=l4lZ65TCdKI89Uzh3HOjQySl59Lffm9Qyysuo5fvWNCxaI5fRohSnoujyU+IYoWCDLbUrjYyqsssnUG/sC5P2pRVr5g0xZF1k+eM+3Y/3VSOOJUnWHXWXzP/EbrLLml5M1EfnjvUiooiOj8tWMKgulYvdBKhU+PIcHJ8ogS/E20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863119; c=relaxed/simple; bh=v3FvirLMTzIowH+sk9YeMlRZ6Xk1NGaiUV8kiiXj6ck=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=V/6ptFjR5YdeQoTqOfAyE8OwPzlnqgCA69HSGi7XgxDVwNQMkkuvMp6W7Zp5rxNuzCacqadwJE3HBjKalMnw9mQkrrSmWUG4oE0TWQlEcO9KRKufqYrgXih4OH9I9ek/EunAOdUT7/z0oRXM38dfZ1eGXjlGDF4mLZTt2rffCAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.cn; spf=pass smtp.mailfrom=sina.cn; dkim=pass (1024-bit key) header.d=sina.cn header.i=@sina.cn header.b=Hhpprlta; arc=none smtp.client-ip=180.149.134.31 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.cn header.i=@sina.cn header.b="Hhpprlta" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.cn; s=201208; t=1779863110; bh=12PR9PWOizZM4zDXqd1Sv3pdVkgOOhc9DR371nViGmU=; h=From:Subject:Date:Message-Id; b=HhpprltayBKOG6Dla4pYwKXC42RRonI0ItVHrelDCBeSn8uzGy4wz9ms4rqiEnQpC hH/WUimyniAUmzIj5h+z5MSY+uvMYTaysw0dZdL9kNM0DFVyHcp1XoFy7DeNvsH+bA 3Qm+zWYr0JihRQuZwIiFje5iFjWTGigNx+YCwDEg= X-SMAIL-HELO: NTT-kernel-dev Received: from unknown (HELO NTT-kernel-dev)([60.247.85.88]) by sina.cn (10.185.250.21) with ESMTP id 6A168CF6000035DD; Wed, 27 May 2026 14:19:39 +0800 (CST) X-Sender: jianqkang@sina.cn X-Auth-ID: jianqkang@sina.cn Authentication-Results: sina.cn; spf=none smtp.mailfrom=jianqkang@sina.cn; dkim=none header.i=none; dmarc=none action=none header.from=jianqkang@sina.cn X-SMAIL-MID: 6041043408497 X-SMAIL-UIID: 90C1CF8D460341559EDBB1606F92CBDC-20260527-141939-1 From: Jianqiang kang To: gregkh@linuxfoundation.org, stable@vger.kernel.org, adrian.hunter@intel.com Cc: patches@lists.linux.dev, linux-kernel@vger.kernel.org, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, sashal@kernel.org, billy_tsai@aspeedtech.com, npitre@baylibre.com, boris.brezillon@collabora.com, linux-i3c@lists.infradead.org Subject: [PATCH 6.12.y] i3c: mipi-i3c-hci: Correct RING_CTRL_ABORT handling in DMA dequeue Date: Wed, 27 May 2026 14:19:33 +0800 Message-Id: <20260527061933.3612126-1-jianqkang@sina.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Adrian Hunter [ Upstream commit b795e68bf3073d67bebbb5a44d93f49efc5b8cc7 ] 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 Link: https://patch.msgid.link/20260306072451.11131-9-adrian.hunter@intel.c= om Signed-off-by: Alexandre Belloni Signed-off-by: Jianqiang kang --- drivers/i3c/master/mipi-i3c-hci/dma.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mip= i-i3c-hci/dma.c index b9496e8c4784..44461f13b54c 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dma.c +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c @@ -457,16 +457,23 @@ static bool hci_dma_dequeue_xfer(struct i3c_hci *hci, struct hci_rh_data *rh =3D &rings->headers[xfer_list[0].ring_number]; unsigned int i; bool did_unqueue =3D false; - - /* stop the ring */ - rh_reg_write(RING_CONTROL, RING_CTRL_ABORT); - if (wait_for_completion_timeout(&rh->op_done, HZ) =3D=3D 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); + u32 ring_status; + + ring_status =3D 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 =3D 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); + } } =20 for (i =3D 0; i < n; i++) { --=20 2.34.1