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 E240C2D541B; Thu, 15 Jan 2026 17:18: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=1768497490; cv=none; b=LqT6jrhaZz71Q89t8jL+4K47PJ1iuJ+4TJAJoPyaoI+JZzzZ6SCeVKgqPH/5oTd93ftvq8mk2PTZfMx1GJnROMM/sJMBBuaidkbr+ifohm74hkamLGtrsXSnCZSGNIU4yoD5CDcj5FS5gY9xLO4q4qgeIGJ9Yw8R19Zkxa5Ui+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768497490; c=relaxed/simple; bh=9EpDDEfIFW7Q7wSQG2tsNFTZ6lrCq/s7XO1WJqizFYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ucpn6xOv0G9OIGL0dmEJGF8ZrBCqEQwgfm2f7w3eeW93ksT4cDTt+dXZwPfphsAuOTkT9ApAtO2rFR0SiLKW9zEaF1WmomJZyTeItAeAjz0GWc1qLapMUlBkI3xN+EAoeU45fEEzbWZRB4vPn7sxHRsz6Zd7dRx0S+UpJ8nsoB4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dPtgQDH4; 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="dPtgQDH4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60CE9C19422; Thu, 15 Jan 2026 17:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768497489; bh=9EpDDEfIFW7Q7wSQG2tsNFTZ6lrCq/s7XO1WJqizFYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dPtgQDH4mpE5GXWCHv/D05+bjZYt5YmEMSpNrFkbwTENjr0qNarWS3EQatWPg/aJ0 NYdzQevVeYV3KS+nZeD9Wl2qoPJTxYBq0tuKLeJ0Tyt0L7aZ4DxRpaalQU1r0P+hg8 ljFhviS56a7+mdX0lN79juW0hrSyLpWy0P5uzUB0= 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 5.15 067/554] i3c: master: svc: Prevent incomplete IBI transaction Date: Thu, 15 Jan 2026 17:42:13 +0100 Message-ID: <20260115164248.668882002@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164246.225995385@linuxfoundation.org> References: <20260115164246.225995385@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 5.15-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 27f55b5e388d9..d12b4ff2a4495 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -297,21 +297,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