From nobody Fri Oct 3 14:29:29 2025 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EF471F2BB5 for ; Fri, 29 Aug 2025 01:31:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756431065; cv=none; b=ZRcaoUBjM3YUz05s8WFaRhne713L7DpF3gVosIL/GLh/Z0An/8ePueweyEUKOWzEvtQCchED3qoCBvDQUiCO65GFMQy2QU41FYvkI/PVRhdoX/r3BZl+VlMLRAGMozwvPUibafYreUYPK5GxsZNyaz+61k9UAmjtKahH8AmgukE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756431065; c=relaxed/simple; bh=Qbqep2hzcqNwSJ0FdtBOdWhD7FOE+5zl9NAF74yt6Bw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=INlc7O7NkAsRpFAnCJ+KwhqF/yMGO95zc2fA0xa/gVYUuFQtuMNhfw30c+mdf3nuzBtJlRpyEcNZ+SW4HkhVHzuNL7nC7KjF8Feb/hHkRy72F+MVoAr+vNBv8T5F/rUm2NFStXS09PTmzug7auZlej4QHfWyuLzUc3paMjBc4nQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=R23EBhK3; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R23EBhK3" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-323267bc2eeso1209362a91.1 for ; Thu, 28 Aug 2025 18:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756431061; x=1757035861; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JCc+9KPYWnXlW7uF+KcOgI9YRTfMpRpG2O6mgKyAsFA=; b=R23EBhK3b3oEIEQTOCQnJ+oesTjr7+J9qwspbskDprPGSXHWcKERpwE9A3zE0KUFxa 8LvNAG0cGBDDLvpOvqCtCLN1RBrPC8TjSvdw27VFUDZrMAhUyppQQD17/wooipidb8l8 qXW4FhPvz9OiPQ4jBSwIIQjy9y5AULXk9019vSaS7ntm8iewbnwPCTeXkC/f8PCLtsJu 7b83S3pj0bbwIYbqAraqW5ZYXdCVPJuSMFylekcQ5wwAIOfCxbEwqwmaXhhpZjkiblZf NKBsoBczvcstH07Dp5J36ROvWf5dc9JkviPH6uy0bOUfjaBlz4ozcFUTrc6f17voOnZG QqoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756431061; x=1757035861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JCc+9KPYWnXlW7uF+KcOgI9YRTfMpRpG2O6mgKyAsFA=; b=TnmluB0TtqJrBezbIyIrS7IU31tU0Spvh2DCue0KoWbY7wgtxFKCASjTbGoWIqOW0E gg/wDV3xq6kM50Q/So3q/6pbzWJSQZFAgvj802cRjexP1Mr8Y/+PmVXWLQaz1/uhECSM 26tXO1VWCYD1xQ84eCN7mJiMVoc7Of1pCbhG36fEP+4WHHavNKEvt6Gnp8RDOSZQzrNo pP87twDb20nNp8K+k+lnXuCG7Rx6V7yhZvzG1Wg3ECNRKzNYvIN9wx0Qjd1wqwA/ogB0 7k85GAXw0JCKgC/Mn3hF4+XPq7NPUiFFwELkIVOMSzxs0d9KFs3RremnrCLK0tO3ExU7 50yg== X-Gm-Message-State: AOJu0YytWxuFJvDNkE+uU9LQVn4wnPJGRvWfrkfJg42dsLZd0sT4LQdV ji/CaefLIr92yfD00Nt2vR4ISf4+dL8Mz7R6fAB3KAUI1pCbrWWHFJXQeCKO7A== X-Gm-Gg: ASbGnctGry5kD8vdmuiRm0HBawcLh9DbKB1lH7VrDoGRCkf5ZJlgYYraMsc7FQapbPH gGmgwbBgLva2rRpCpqagE9NDLsvrBblakcROdTpR/hdSgFFaTiNsSPWL6IoIKEUI25qZ14xIyPO +tN5ZJVCy7ImdTgOfhQHw378jvluSyyHO2KmQzPS/75aXBSTJ9Hr23VaQ4hVhuhPvUuC9ixfKMf bouK++zYTt3b/CwgStK/ov6/wGzmM6wsxMEwQEA4HwIlstDizaMgcf4S6NXpOXS2ohLCHQD5ax/ jPPrldkCvIrjqeOa1uVjQ+806vv8oJ6S+LjklmmeYXsxgVCfobGzf0KkcjXCrvmBcVG/nMhdw0W /vKN3fOtQs3W3GOmreDe4tnpaGjG++wJPWBy8TYMDXgI= X-Google-Smtp-Source: AGHT+IGzfeCPaZZjJB+gqeKg99B8LCs/ZeRT0KWO62kRVGoGTA+idY+/TD5Dbn/d3RbdoRGPeyQ98w== X-Received: by 2002:a17:90b:5644:b0:327:70b9:9d68 with SMTP id 98e67ed59e1d1-32770b99e1bmr10491075a91.16.1756431061407; Thu, 28 Aug 2025 18:31:01 -0700 (PDT) Received: from cs20-buildserver.lan ([2402:7500:500:7a9f:2e0:4cff:fe68:863]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-327daeec552sm959977a91.27.2025.08.28.18.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 18:31:01 -0700 (PDT) From: Stanley Chu X-Google-Original-From: Stanley Chu To: frank.li@nxp.com, miquel.raynal@bootlin.com, alexandre.belloni@bootlin.com, linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, tomer.maimon@nuvoton.com, kwliu@nuvoton.com, yschu@nuvoton.com Subject: [RESEND PATCH v2 1/2] i3c: master: svc: Use manual response for IBI events Date: Fri, 29 Aug 2025 09:30:52 +0800 Message-Id: <20250829013053.3562853-2-yschu@nuvoton.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250829013053.3562853-1-yschu@nuvoton.com> References: <20250829013053.3562853-1-yschu@nuvoton.com> 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: Stanley Chu Driver wants to nack the IBI request when the target is not in the known address list. In below code, svc_i3c_master_nack_ibi() will cause undefined behavior when using AUTOIBI with auto response rule, because hw always auto ack the IBI request. switch (ibitype) { case SVC_I3C_MSTATUS_IBITYPE_IBI: dev =3D svc_i3c_master_dev_from_addr(master, ibiaddr); if (!dev || !is_events_enabled(master, SVC_I3C_EVENT_IBI)) svc_i3c_master_nack_ibi(master); ... break; AutoIBI has another issue that the controller doesn't quit AutoIBI state after IBIWON polling timeout when there is a SDA glitch(high->low->high). 1. SDA high->low: raising an interrupt to execute IBI ISR 2. SDA low->high 3. Driver writes an AutoIBI request 4. AutoIBI process does not start because SDA is not low 5. IBIWON polling times out 6. Controller reamins in AutoIBI state and doesn't accept EmitStop request Emitting broadcast address with IBIRESP_MANUAL avoids both issues. Fixes: dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver") Signed-off-by: Stanley Chu --- Changes since v1: * Specify full fileds in the MCTRL register * Add Fixes tag --- drivers/i3c/master/svc-i3c-master.c | 30 ++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i= 3c-master.c index 701ae165b25b..8e7b4ab919e3 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -517,9 +517,24 @@ static void svc_i3c_master_ibi_isr(struct svc_i3c_mast= er *master) */ writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); =20 - /* Acknowledge the incoming interrupt with the AUTOIBI mechanism */ - writel(SVC_I3C_MCTRL_REQUEST_AUTO_IBI | - SVC_I3C_MCTRL_IBIRESP_AUTO, + /* + * Write REQUEST_START_ADDR request to emit broadcast address for arbitra= tion, + * instend of using AUTO_IBI. + * + * Using AutoIBI request may cause controller to remain in AutoIBI state = when + * there is a glitch on SDA line (high->low->high). + * 1. SDA high->low, raising an interrupt to execute IBI isr. + * 2. SDA low->high. + * 3. IBI isr writes an AutoIBI request. + * 4. The controller will not start AutoIBI process because SDA is not lo= w. + * 5. IBIWON polling times out. + * 6. Controller reamins in AutoIBI state and doesn't accept EmitStop req= uest. + */ + writel(SVC_I3C_MCTRL_REQUEST_START_ADDR | + SVC_I3C_MCTRL_TYPE_I3C | + SVC_I3C_MCTRL_IBIRESP_MANUAL | + SVC_I3C_MCTRL_DIR(SVC_I3C_MCTRL_DIR_WRITE) | + SVC_I3C_MCTRL_ADDR(I3C_BROADCAST_ADDR), master->regs + SVC_I3C_MCTRL); =20 /* Wait for IBIWON, should take approximately 100us */ @@ -539,10 +554,15 @@ static void svc_i3c_master_ibi_isr(struct svc_i3c_mas= ter *master) switch (ibitype) { case SVC_I3C_MSTATUS_IBITYPE_IBI: dev =3D svc_i3c_master_dev_from_addr(master, ibiaddr); - if (!dev || !is_events_enabled(master, SVC_I3C_EVENT_IBI)) + if (!dev || !is_events_enabled(master, SVC_I3C_EVENT_IBI)) { svc_i3c_master_nack_ibi(master); - else + } else { + if (dev->info.bcr & I3C_BCR_IBI_PAYLOAD) + svc_i3c_master_ack_ibi(master, true); + else + svc_i3c_master_ack_ibi(master, false); svc_i3c_master_handle_ibi(master, dev); + } break; case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN: if (is_events_enabled(master, SVC_I3C_EVENT_HOTJOIN)) --=20 2.34.1 From nobody Fri Oct 3 14:29:29 2025 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FB081FBE80 for ; Fri, 29 Aug 2025 01:31:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756431066; cv=none; b=rjCNu+Io8UzPAaMU2E/gFWdcz1EbaebSng29/S+Oce7CAJZf9eC4HnzZiEzCHPQNspTkhPNxzovQmOzc13+d2ygOPvj0JdmeXSU9IKKwKmGgG7AGeVuyAzqVsuGmK2BSM6H5cE/zOPD4ig1pTPLfnDfXbJc9unSg4mN8YYVekzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756431066; c=relaxed/simple; bh=pKt+r5DpAI7p4BPFjwN9v/Y+1a84jf9NTgvzR3HT8YY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MfRg3s2uQ3ioA9ZYjXqUo94zUkBEyDmp5uGWUaoQ8JCe4NAn6BARDJcR+NzaxI9nL+mSw9wkFcdeezo3dENJ9IluADcDSoM6ieSKAqyNfIGxHTrIAPLzOMKF/bm78n74AHmR+/qTfArn0oVZRuZp2P6kNPe6aUu1ZRt6iBdz1Ss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=m5MOuRSx; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m5MOuRSx" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-327aa47c928so1241178a91.3 for ; Thu, 28 Aug 2025 18:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756431064; x=1757035864; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z/9pMLAzp+OJLv9QfGuHa4wnCkokVIs0cn0/wGFQPEU=; b=m5MOuRSxM0h7p2QEQamgwRq+Gfc8WHk6jtliXaKoE+76/hKtTms/dLbs+Y2JniAA/C xXncz98ekD/nlRmhwXrSflwGehsP+TQGRNC2ANK22ON7jms0dlfmk0p+wdFDbVRYMN21 3u3uogvAzTkSfveh8Foj0Jwbo+rWnR4pFt7UMfN03Gb/dSXw5+2zGz21kmORPJgK7sKh EGZ0lZHkcMFbm7e2qMmfw1Mv5IO4XuR2colFkQSIQI9EqUyk4rFNUenh09ugYEhRnqu5 hlTo0cyiPC/jN3zTWC/wQPaBlIssODjQPx87TI0DTps9P0biQgfl+7oYXvnJLDhiuU5F dzFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756431064; x=1757035864; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z/9pMLAzp+OJLv9QfGuHa4wnCkokVIs0cn0/wGFQPEU=; b=JT5BAhLARgDLtsh2Q7K4ONuvqGwo0QVgM3P2TXu6XdUlWwOWseo93aDwdDqxDf76X3 h9Una2VcKK9Wjh2sVBcdfKM5M5/7y8PJyNMzHHkg2/y5768nUjlWiS6DgAhzcO2tRaof XBHY3K54U9ZvvOJdpMbrXzzeur1X220geBy3/Trwskdeheub4QGAYHqfbdMWzE6HaAQC xNmpdV0hIoxjlRKI2dQsU0CqhSM2wIsex7BTqe8+H21iFJLkCrEmbia3xBgpv+iORvAu 6lUk6YT/yrchZ4UV+QLbpmaauLkwoTrl551P1tKQezT6t8jIE61gufUy5UTtWSItNiJs MsnQ== X-Gm-Message-State: AOJu0Yz3SZ6cqghcmYABUSlvlCS7VPpuEmqJVwZQtLyyEzMfJRpMl0Tw 6laSvErY2EvBoHviexOeX5Yh0DFwTKIR1+ybL/FIEpiGdQI+/J+IY+DiLfvHuw== X-Gm-Gg: ASbGncsAW/lprphcOLeBkC9lHb6Jw/e3su4R2Z0lTmUkDXen9C3HAj9J0Ry7gmIrW8A 5QY5r1ljDYeWtjQp1i1Vfl+wVfOz5cut/JOelKYJmu9SRjug/STotDuZN7GGyeXSo9Yr4VTfTp7 viVtIhrOIzbMwaXIPaPxlCAOsd3vPlPRdn/vGx3zyT6IP3VAvahUfVaop7h3anDlIo/8WgxpTyr kdSgaP38kK2C+bFCZ3vmDMqxC9Ueuj2dYPYlf66MRw7ygjyhpWwimExes/Jccj4/9NMvYaMTvWq l27RjQ0dyq/U+U6kalm20JYJDxxQzVm5XH6oWtt3GrnYQcS1kJ0YACmP+mmG8jRM+Lz2MLkcG2Y WtHf2YJrcO4GOnYQH9ShhvfUZ3OwSIB5X X-Google-Smtp-Source: AGHT+IFjrfeM+QC3JsYvq0XJQwzI7oSGwDWr+9yk1UjNgku6/8Ns5b588Q9STD2zyT0UUigxpZD7TQ== X-Received: by 2002:a17:90b:3f87:b0:327:e781:3d2e with SMTP id 98e67ed59e1d1-327e7813ef0mr507446a91.33.1756431063645; Thu, 28 Aug 2025 18:31:03 -0700 (PDT) Received: from cs20-buildserver.lan ([2402:7500:500:7a9f:2e0:4cff:fe68:863]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-327daeec552sm959977a91.27.2025.08.28.18.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 18:31:03 -0700 (PDT) From: Stanley Chu X-Google-Original-From: Stanley Chu To: frank.li@nxp.com, miquel.raynal@bootlin.com, alexandre.belloni@bootlin.com, linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, tomer.maimon@nuvoton.com, kwliu@nuvoton.com, yschu@nuvoton.com Subject: [RESEND PATCH v2 2/2] i3c: master: svc: Recycle unused IBI slot Date: Fri, 29 Aug 2025 09:30:53 +0800 Message-Id: <20250829013053.3562853-3-yschu@nuvoton.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250829013053.3562853-1-yschu@nuvoton.com> References: <20250829013053.3562853-1-yschu@nuvoton.com> 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: Stanley Chu In svc_i3c_master_handle_ibi(), an IBI slot is fetched from the pool to store the IBI payload. However, when an error condition is encountered, the function returns without recycling the IBI slot, resulting in an IBI slot leak. Fixes: c85e209b799f ("i3c: master: svc: fix ibi may not return mandatory da= ta byte") Signed-off-by: Stanley Chu --- Changes since v1: * Add Fixes tag --- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i= 3c-master.c index 8e7b4ab919e3..9641e66a4e5f 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -417,6 +417,7 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_mas= ter *master, 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; } =20 --=20 2.34.1