From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E83152F12D4; Fri, 9 Jan 2026 11:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767959710; cv=none; b=CiIBQVAGJaY2rBUsEcIQZXgROKjlxFa7pPQkTuxittSDxzxcvnNWo8R2MyvY7zmANkO1sje9iYxp1aIfNzEPBd+fY7keMLb4iyn+V/EA+n82VC5h5emuYTcGBzRmCZ+RYl4uusCxmyx2rCZSs6d+RDjUTqIFsRwjezxqsUh9+8Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767959710; c=relaxed/simple; bh=g3CCNelzcpfKP+AtJuhETzE7T4n7GSfFdb36DY94W+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e40vD7JOqmLU1kYH4c88zbBwpx+YG8lWIS+rwilohphMONJLTA0Laj/SlFSNCqLjcwBrAuEKlcu8nTlKwPCk10S29eWf6XhkU6KIyAMZ0z1x2S+/uCDUGp2v6Aq8kBeErbHpmWiJs73ow4Jda711qrpNdmCA8pKh3u/lmDhZaag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0zqhhW23; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0zqhhW23" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7196DC4CEF1; Fri, 9 Jan 2026 11:55:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767959709; bh=g3CCNelzcpfKP+AtJuhETzE7T4n7GSfFdb36DY94W+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0zqhhW23somqUxO3t+/eOGkva63X2NTZ5UKoDeneJuPtqrFFhJh3Ov6DGJWG1exu5 CXEBC0LxO0CX2q9vFyG/oBmRsSsnyZWRgy1L6j7SCIYCD9qA82X2mYmn75YUz+e1R3 CM+tTuX+tZgDCipkHOGazeT0azNimF0OAjRYU0qg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stanley Chu , Frank Li , Miquel Raynal , Alexandre Belloni , Sasha Levin Subject: [PATCH 6.6 105/737] i3c: master: svc: Prevent incomplete IBI transaction Date: Fri, 9 Jan 2026 12:34:04 +0100 Message-ID: <20260109112137.951913443@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112133.973195406@linuxfoundation.org> References: <20260109112133.973195406@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stanley Chu [ Upstream commit 3a36273e5a07dda0ccec193800f3b78c3c0380af ] If no free IBI slot is available, svc_i3c_master_handle_ibi returns immediately. This causes the STOP condition to be missed because the EmitStop request is sent when the transfer is not complete. To resolve this, svc_i3c_master_handle_ibi must wait for the transfer to complete before returning. Fixes: dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver") Signed-off-by: Stanley Chu Reviewed-by: Frank Li Reviewed-by: Miquel Raynal Link: https://patch.msgid.link/20251027034715.708243-1-yschu@nuvoton.com Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/i3c/master/svc-i3c-master.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 277884b5e1ca4..3222b8f56a926 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -358,21 +358,27 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master, int ret, val; u8 *buf; - slot = i3c_generic_ibi_get_free_slot(data->ibi_pool); - if (!slot) - return -ENOSPC; - - slot->len = 0; - buf = slot->data; - + /* + * Wait for transfer to complete before returning. Otherwise, the EmitStop + * request might be sent when the transfer is not complete. + */ ret = readl_relaxed_poll_timeout(master->regs + SVC_I3C_MSTATUS, val, SVC_I3C_MSTATUS_COMPLETE(val), 0, 1000); if (ret) { dev_err(master->dev, "Timeout when polling for COMPLETE\n"); - i3c_generic_ibi_recycle_slot(data->ibi_pool, slot); return ret; } + slot = i3c_generic_ibi_get_free_slot(data->ibi_pool); + if (!slot) { + dev_dbg(master->dev, "No free ibi slot, drop the data\n"); + writel(SVC_I3C_MDATACTRL_FLUSHRB, master->regs + SVC_I3C_MDATACTRL); + return -ENOSPC; + } + + slot->len = 0; + buf = slot->data; + while (SVC_I3C_MSTATUS_RXPEND(readl(master->regs + SVC_I3C_MSTATUS)) && slot->len < SVC_I3C_FIFO_SIZE) { mdatactrl = readl(master->regs + SVC_I3C_MDATACTRL); -- 2.51.0