From nobody Sat Jun 13 03:33:18 2026 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (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 273FD3A5E64 for ; Mon, 11 May 2026 07:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778485602; cv=none; b=m5u8D+DlF53RfVHvfpPg7YdzHU1Jbz6qxDs9YqaVjnWYajh90Tu6MQoAHU++YYIrEvBkFos8tuFT8Vmi32rddv4S7AeKk3Dn4ybP23tDMziQe0wRrHEfdOQ0rTwz7QnGFssVEv0EQ+fUdDogGn2Qx7rdwElzrJ7yHSaTuqZJIVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778485602; c=relaxed/simple; bh=WbRNSgR6fF75ujIFRpZT+WIk0CWNPjAlMacuue3U6KE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fBnGpx26sVs2CgV5SbGD9PSgqwt0qCmtD7BL2BJNrjsc+2bQPItBpUu5x/dyM5Yt460s4NsYeT8zwDM1JWsqYS1HhBa2fxnU7lKOocRV2Zx6TTj0tS+UX4QiddBd9bGrNEy2iSqVAWzrovOdk4nsdumATpOfqwRgDwnCnFOSjcg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai; spf=pass smtp.mailfrom=nexthop.ai; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b=I6kyPiil; arc=none smtp.client-ip=74.125.82.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b="I6kyPiil" Received: by mail-dy1-f182.google.com with SMTP id 5a478bee46e88-2f0d3e07e30so10097683eec.0 for ; Mon, 11 May 2026 00:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1778485585; x=1779090385; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wErO40OAlXA0m7VCC6f5qpf//Pf9vFknfGugsyxSfv4=; b=I6kyPiil6x4HbUnOn6duJGGHVv/TK4DuJf/IFFx1P97/p/i0IKH0gsmex1CPhUXGMa Zz2FwxnOQBGWeT27B7LpJapqdcct3VKXFVaRka1I1i+PaYZcQZAUwkTKZcKdfgn8C237 K3/BBl0U+GOxCIUMcO0DfVL4OXuh4Rf7suiKyg11StKxnRF6IESpQngVhLfi9pfbC4L9 Uzioa5C8eF6BX0NV/BLLkrn4l8pxmFw/F7dugqeFd39DFd2EYCf4gqKcb2l3Z0U1JRWG XEaJIXJZmgduhAbeN3OLNzfFCqF2wuLIEka1Jc8SZNbOq14IYvX+OPQ73i5yazl9tg3V a3dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778485585; x=1779090385; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=wErO40OAlXA0m7VCC6f5qpf//Pf9vFknfGugsyxSfv4=; b=jYLttMb7j2CVF9YIUZBk37YckQXNAo9W60Tybf5+MRf73q71Tybjr0RMhVGcdGfQjJ /ToKuqJU1AJ6ZbXLWnNkz0FOGx4VzkyLeT7HDKo9C1M6jCMSWGwSNArV+HKu0T0IFZ8z wxkK4ELS9EBmsrjFLgGq9Fc1rXZXwKozRu+SxJNrxs2MnchuaCoTuA6GeL2Ou4X45MxJ OmooHxEzE6Ptkty+c2+lbFMrrMNwg3MVtaUGmkxJNQyEHXrgKeerxGZHVa4pJhbRoSfv ogo2eXVuELRJIwaj5DaZrBE5NdyCOCbmHhwKZnDQ4kt5diarjYuMelTmFgMelzc2noky Fj1Q== X-Forwarded-Encrypted: i=1; AFNElJ8c12dFFY2IIRybnlrMsnAcDvBOqV2z3uZIdzO2HSEklXJpp8FyCk7dbLU8KlShlHPtF1tqT1oSjNosiIY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8ZMd0DTggzj20m2v7lWHpBIL7hqKCiSx2kyuWwFRdrzCJ8Fc9 w/ocISInuXr9q6LlSqRhEgPBSuutBu6q6zBQXaqmvwPadWftJWqqQwtMAtubZv1kX3pNwacUNK7 TXy1gJMU= X-Gm-Gg: Acq92OEMoD0kZmNhOFP6ThyheBqyPRnuvKxFwfZZPxoGux5i+q2uwTrwlqrzCBpJz20 SSFR9z0INYOHVQ02zsAU1JMHM2Wfi3xeYxLyPItLIpLUgu23AtfbgybTaaI6NoYSoh4vrbNQd5c fcfMbrW8czUNOMIT88Twywr9OsVjUd0KuGvtuy0SLnajBrDEruNP3dm3uYF7M8Ptq9B6f5td7th 8qFHvzQyiRfhM9T46RANSMC2mlteYRn8D/Kigg3gNuj7+Ty5KcvZMUi3Gewftf0lBhWhQPbAVjA rEAYdce6SKTOgCt162Ppo6AJt2iNp9ARCOFNcKIsUxyYDn4Mtf2hrs6y0dByCNg8jE7C57X00CA uu43obnoQ1Ls+fh+JKA+i0AN5rtGDGE2Jo4H9Lw72SZZuDRhAG/0DGmdxpYRwP/qjKqey28SihY LYzDhgEudtuB6BznMqbFRKm+BhZQ== X-Received: by 2002:a05:7301:578b:b0:2df:7fe3:96a with SMTP id 5a478bee46e88-2f545c976a8mr11709144eec.0.1778485584615; Mon, 11 May 2026 00:46:24 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2f888e381c9sm12205702eec.26.2026.05.11.00.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 00:46:24 -0700 (PDT) From: Abdurrahman Hussain Date: Mon, 11 May 2026 00:46:12 -0700 Subject: [PATCH v2 1/3] i2c: xiic: preserve PEC byte length in SMBus block read setup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260511-i2c-xiic-v2-1-c16380cb1594@nexthop.ai> References: <20260511-i2c-xiic-v2-0-c16380cb1594@nexthop.ai> In-Reply-To: <20260511-i2c-xiic-v2-0-c16380cb1594@nexthop.ai> To: Michal Simek , Andi Shyti Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778485583; l=2279; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=WbRNSgR6fF75ujIFRpZT+WIk0CWNPjAlMacuue3U6KE=; b=bHXgIxBPq/DfWG3LxVv/I1TZyOj4J79btpDvtIwXuTBO0Ws8u8ehEVZEILe7jCdUbb1OnVDKz n2XCDgSp0gzAUAwLKPexATrF9DHZFFJLSA2gM4gzPlMhOQiiItOoVOy X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= xiic_smbus_block_read_setup() overwrites rx_msg->len based on the announced block length byte, but the i2c core appends an extra byte to msg->len when PEC is enabled on the client (see __i2c_smbus_xfer_emulated in i2c-core-smbus.c). Before this handler runs, rx_msg->len is therefore 1 + pec_len, where pec_len is 0 or 1. Overwriting rx_msg->len to rxmsg_len + 1 drops that PEC byte from the caller's buffer: the PEC byte is never drained from the FIFO and the core's i2c_smbus_check_pec() reads the last payload byte instead of the actual PEC, returning -EBADMSG even on clean transfers. Capture pec_len before the overwrite and add it back when recomputing rx_msg->len. This is a pure bug fix; non-PEC behaviour is unchanged (pec_len =3D=3D 0). Tested on a Xilinx AXI IIC FPGA block driving an adm1266 PMBus blackbox read -- with PEC enabled the full 64-byte record transfers cleanly after this change. Signed-off-by: Abdurrahman Hussain --- drivers/i2c/busses/i2c-xiic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 3e7735e1dae0..959a47b645a5 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -539,6 +539,8 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c= *i2c) =20 /* Check if received length is valid */ if (rxmsg_len <=3D I2C_SMBUS_BLOCK_MAX) { + unsigned int pec_len =3D i2c->rx_msg->len - 1; + /* Set Receive fifo depth */ if (rxmsg_len > IIC_RX_FIFO_DEPTH) { /* @@ -546,7 +548,7 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c= *i2c) * Receive fifo depth should set to Rx fifo capacity minus 1 */ rfd_set =3D IIC_RX_FIFO_DEPTH - 1; - i2c->rx_msg->len =3D rxmsg_len + 1; + i2c->rx_msg->len =3D rxmsg_len + 1 + pec_len; } else if ((rxmsg_len =3D=3D 1) || (rxmsg_len =3D=3D 0)) { /* @@ -562,7 +564,7 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c= *i2c) * Receive fifo depth should set to Rx msg len minus 2 */ rfd_set =3D rxmsg_len - 2; - i2c->rx_msg->len =3D rxmsg_len + 1; + i2c->rx_msg->len =3D rxmsg_len + 1 + pec_len; } xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set); =20 --=20 2.53.0 From nobody Sat Jun 13 03:33:18 2026 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (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 4604339EF2F for ; Mon, 11 May 2026 07:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778485603; cv=none; b=qzS4dark3+si6QiuWxwXRobOzaC2PgWYygksr5QI9DsYHq/ReSKkealgG2M79NnRUg+Tbshgw9iEBl96exiGovCH+HqOmR/DeEXHoHKSrbq2pNz6p5CpTiSPV8AFHhXmZkmUF7I9rOGhYmZrUAW7DpeLcxFbplixA3egEatU3gE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778485603; c=relaxed/simple; bh=YQInRzCWVXJBbGUOGvO2DPhTx2lGcEJzvpRvFC2WTNM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PEy0ixAf1If27J3i2qMV09IO+ebi5es4nMmFvdBvA2lxPAy5+ezjgsFJeSmAaHyw0WluEPUd4bYEcv7sztjBNz5utbrb7HRqFDMB58ZpM1By/YfP8PLnuRZ1HhifZh4tfyM4UA8FsJzitc8lRT1Q6qX1qdTLylgyNZFTzn/SrHE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai; spf=pass smtp.mailfrom=nexthop.ai; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b=DJHWEjJV; arc=none smtp.client-ip=74.125.82.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b="DJHWEjJV" Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-2b4520f6b32so6881723eec.0 for ; Mon, 11 May 2026 00:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1778485586; x=1779090386; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eIDyOEViNLE4KPweGmgFctKJ5qfBRnVS9bTwCoRCqcc=; b=DJHWEjJV3Ghze8x0et2yYrWYbK2uk6xC8U12RP6x0s1JeQXPPuQATlUulTYDjlmG/S LAQk7vATvB8rm9pG/qu7VKX6B8OgBgFLHF09qdI6aSYU/iLE2NsOLOs39tE+HCYHax5u aDgvxmANKiZjEb6YKmQwvub5sWkDgQme4jROq/ptg/8tDDfJuB+pk4hhE/iZHJ+kdE5t Pnq7hgBaKJQlkc0aiENhVbyfiZ/TugicI56gjF0j5D00bbPUa6Fps7TeFXdU1d3TYggZ X8hCmBGma2VeBAJepChhvxFcDA9knkvYJf7aE6zGlss9SbOjdVlXazFlo8AfeSuoEWLn mSHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778485586; x=1779090386; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=eIDyOEViNLE4KPweGmgFctKJ5qfBRnVS9bTwCoRCqcc=; b=gELeVcd4U9kEJX8+Um+oO28TxsmKgTE/XV7mTae1jSQkrS0vJo6srrAnmRANAZsBrH cipFnCTrZB5Pm/Nhq4JvD959aSNPePR9E9c/k4FGZym+NKJ30Jl2kr/lrX3ZWoUn1mM0 IHH25/Uk0mKjg/wxUQAQFhByaiLgeyTYrJ92mg7wDwRhNiCcTYhimFcIMrZ8obsZMWMZ tz4PcrgyM2hJaR/o6XaNG2BHe5FjTtClzHRV0Obaa1aa8oZUpR7IoGCzs+eKakNeP4zg gKcBhLeEcL6/ct1HcKvWKH4r7cxVqDD0wKBDu3JtLmxM+aNFdMIfotg4USdLdi2jqPeY d/cg== X-Forwarded-Encrypted: i=1; AFNElJ/4Z4/S3r60BcCU+apuEQ2qLiIWJ2Ip7K7My3t1m0wW7aMvdlIgYi+K3jCwRcQtUa5j6HENxqrCi3AwZeA=@vger.kernel.org X-Gm-Message-State: AOJu0YxpCdfYBcVLdEFg7djoykt0cTtDlDwpBLHkDdPmGlwz+wsp2wMb 82qaYPfCa5QezN8OwsSQYy1VZPwqH8/QipPq+BqIeNSSlEhcrQ6nUKXH+8C+5Qhl7IRl4+czY0c +YTbyw7w= X-Gm-Gg: Acq92OGazHD24zmMK2jkyNBt3fOKrYYeH9Igk14W1+XuQiXo2sqijGh8qZMr8zetj6c boqBE39Fp68Ml6Pm2nm9K1s2GYrt9AWur6mz4x3z2+ulk3di6rXD2s3PL25q/CJ6Na2wlP+LzgG hAwO3ZLaH4Uv5mq++YCJUJSbfge7JBRFrpqNsJ1t471yEj2H9wS4u/5rJDGwfdnJiwzOl2i5ASo 13BohQet+yX7KH/zPjJ5/tw/z0HWNahS2maEgz+0hCPNoYGi3ob7PkKz1Khkv9buMS0TGl8hPnl Donm7eOmjp4jvF38e1zVQNgMD3AbmN0pC62kYEhlTIcgW39LEvyPIgI7pJ5eMR1aFIIkj7mUKD7 k4akWHmS02edVpzV21bqBoxlVNfPnYYdnR2z9sm9ge5Jbr5/h7pKcAppvUA7S+loQH8EfA5/UkB DGcq+g2ZBno+FBUj6yeWNjgpPWZg== X-Received: by 2002:a05:693c:2c01:b0:2de:c5ca:c1e8 with SMTP id 5a478bee46e88-2f54d696d50mr10433842eec.4.1778485585334; Mon, 11 May 2026 00:46:25 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2f888e381c9sm12205702eec.26.2026.05.11.00.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 00:46:25 -0700 (PDT) From: Abdurrahman Hussain Date: Mon, 11 May 2026 00:46:13 -0700 Subject: [PATCH v2 2/3] i2c: xiic: defer RX_FULL until all trailing bytes are in FIFO Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260511-i2c-xiic-v2-2-c16380cb1594@nexthop.ai> References: <20260511-i2c-xiic-v2-0-c16380cb1594@nexthop.ai> In-Reply-To: <20260511-i2c-xiic-v2-0-c16380cb1594@nexthop.ai> To: Michal Simek , Andi Shyti Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778485583; l=2814; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=YQInRzCWVXJBbGUOGvO2DPhTx2lGcEJzvpRvFC2WTNM=; b=dHsiGR14XxL9FvZ3NefbWYmUQ8oOcT+goVAwocjGBRlTlbew/67kGcPRS7gfnnbVhFNbdSGXD 3xPF0HIIm95AWgaRGjDwtxs57YOhEBTVb42qu8U6FH7RXHBH/uRdLSE X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= For the normal path of xiic_smbus_block_read_setup() (rxmsg_len less than IIC_RX_FIFO_DEPTH), RFD was programmed to rxmsg_len - 2, which fires the RX_FULL interrupt while the last payload byte is still in flight. xiic_read_rx()'s bytes_rem =3D=3D 1 branch then sets NACK on that byte still on the wire, truncating the read in the PEC-enabled case. Raise the threshold so RX_FULL fires only once every remaining byte (payload plus optional PEC) is already buffered in the FIFO. That routes the drain through xiic_read_rx()'s bytes_rem =3D=3D 0 path, which reads everything out and emits the stop cleanly. For the non-PEC path the full payload is still read out through the same bytes_rem =3D=3D 0 branch; the only user-visible change is that the controller waits one extra byte-time before servicing the interrupt. The deferred-fire formula is rxmsg_len + pec_len - 1, and the RFD register at XIIC_RFD_REG_OFFSET is a 4-bit field. Widen the chunk-vs-defer guard to (rxmsg_len + pec_len > IIC_RX_FIFO_DEPTH) so the boundary case rxmsg_len =3D=3D IIC_RX_FIFO_DEPTH with PEC enabled cannot write 16 into that 4-bit register; it routes through the chunked drain instead, which already caps RFD at IIC_RX_FIFO_DEPTH - 1. Signed-off-by: Abdurrahman Hussain --- drivers/i2c/busses/i2c-xiic.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 959a47b645a5..a9452eca26df 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -542,10 +542,11 @@ static void xiic_smbus_block_read_setup(struct xiic_i= 2c *i2c) unsigned int pec_len =3D i2c->rx_msg->len - 1; =20 /* Set Receive fifo depth */ - if (rxmsg_len > IIC_RX_FIFO_DEPTH) { + if (rxmsg_len + pec_len > IIC_RX_FIFO_DEPTH) { /* - * When Rx msg len greater than or equal to Rx fifo capacity - * Receive fifo depth should set to Rx fifo capacity minus 1 + * Trailing payload (data + optional PEC) exceeds Rx FIFO + * capacity; drain in chunks. Fire RX_FULL when the FIFO is + * full and let the ISR re-arm for the remainder. */ rfd_set =3D IIC_RX_FIFO_DEPTH - 1; i2c->rx_msg->len =3D rxmsg_len + 1 + pec_len; @@ -559,11 +560,8 @@ static void xiic_smbus_block_read_setup(struct xiic_i2= c *i2c) rfd_set =3D 0; i2c->rx_msg->len =3D SMBUS_BLOCK_READ_MIN_LEN; } else { - /* - * When Rx msg len less than Rx fifo capacity - * Receive fifo depth should set to Rx msg len minus 2 - */ - rfd_set =3D rxmsg_len - 2; + /* Defer RX_FULL until all trailing bytes are in FIFO. */ + rfd_set =3D rxmsg_len + pec_len - 1; i2c->rx_msg->len =3D rxmsg_len + 1 + pec_len; } xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set); --=20 2.53.0 From nobody Sat Jun 13 03:33:18 2026 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (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 284B239F172 for ; Mon, 11 May 2026 07:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778485601; cv=none; b=h/4omOdz7mvh+ZkPipBZN80bt66fasAfoSIaBW54asq9RGwgZcyHJkAY9wCDawz6mXfZKMUkt6YDqsahzitfMUBY2y9UBQ8LtVyMJezhd4vKJ+i8v21tHczHoHW0i8CxHOBdkEpM6BksiiLEMdFSobET2yzTog7HtiKvHoMxSpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778485601; c=relaxed/simple; bh=tjDfjq5O5p81+MNuIlyxeuaZBrECDSK/ynhLod78ZDU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d9w4Uzdv6ZrY2/hmQxsRr2pRBHoUytRNscIuZ6n72C/5f/UHzF+258D2h9qtdK/JG/rQ2IGhG5yU/5YJbKYEr2T2LAkHyuO+rD8P9Y+2YiUqjgLeyDY+ofhTQcjtm352JtUDN+JMWb67cdHn5Y+HZsr06HIGitdcsxLGmiY0Src= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai; spf=pass smtp.mailfrom=nexthop.ai; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b=JN46uooX; arc=none smtp.client-ip=74.125.82.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b="JN46uooX" Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-2f7020a928eso5323723eec.1 for ; Mon, 11 May 2026 00:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1778485586; x=1779090386; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=d4Dha3V3dyDcgOa6Jz5YYLbPJnxJR4aqvkeRMGSz7IM=; b=JN46uooXf5K2XbnJJb5r7O22CMd6ZG6gIdr14gKhrZqFo12cWj0JgR1uK5dlU7+Ut7 xx0Y7m00vZfES8X7eSWWx6i45KleHKclco8fWZKmFUcDtjbqO6GG0BkzW5Xp1wttvS4X Pg7/rGsBg86IKCqpJw0UK1m3m7bFIYzOTcXhedUqPXlVFO5YY7TYi016D7sD668E2i8p 2yJlZKG7jY28d2qD/eWjYD+7XTnnj6Ey6v6JspH23b0mKwfFDl4MFrNrbJ17X1UmfaCn 45Qn1WioTAjiOE4oYSzwAfpsvG936ufSwThYYlICzuc59qTYePFleFkvofqw8ML7MuAD 2Baw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778485586; x=1779090386; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=d4Dha3V3dyDcgOa6Jz5YYLbPJnxJR4aqvkeRMGSz7IM=; b=AKKM3i2dBcEQPRzGZC68cqlil7GlJRx0eE8ZyF7twmHvuDfnVudAPTceXiz231nIC4 UN6iUmNXyE1wUjRDSUSl0DNWDI+wuDqa+9/ZkuHuhWtO9sl7H3++ZlaZ6xgFEPGUd+2d jV4uNoBcTlSsdiqEyAyjIpBfUpFHzc7LYjZQg9qRvSf0WmzUogSPgbEr6eKMDcFrwrOI /YjfxBJ/63YKX6Z4sVLcsnZBS8iJn506+qQTKQ9k6c9UadanNTXsfy0l1SYX9KTfzmEH BhCJYpcdBUHRffdijYu3r94vrObuuF2P/SWLdVOPaVo7tu0W2P3NKkqhLY/sSI109c7B cqcw== X-Forwarded-Encrypted: i=1; AFNElJ/4/eZsH0wq9da4w13Ax6UDh7rrdDPIe9HaTNUWhU8LIju8hiOOY/aQDXuVfUnFSwt92SF8WEGDcofmj8o=@vger.kernel.org X-Gm-Message-State: AOJu0YyDVwSSMEvw2SqSzPmjrcl5HYAQqEXojAStBKlfChzQzBqoWXpr l8uSwML8RMAu92Ec6DVy0BJwyHL+h7rBZqISSGql7qbpexXTWMIl9EfxEZmOWlY8qosAIV566Tw 1B/MsvHs= X-Gm-Gg: Acq92OFuJP2msjM6YEWb5Zbg8pXKcssbx07+G7A36OLa/3WviNtb2oFaPvanEWYH1ZE cSWSUDX0/079kBn9+FZfgx+pKlYwa8XSss748XItxhEXwg/acLjprx3Bu0cFPGUXxqrx9jZwmHW glc7m5SnbJstewddn4DTTac4Nee5nsDAW25OErwpH0VCIGtcHJywqlrcHxe5yG+8lL2N10xT5PH PLKkOu5p/ksJxeSMxGCVBkOe7wbpftZ4W0SnDvYylthpEJYxkqqt7G91WqEkZWn5BoqPuSZ9/Ul FV5YYQ2wZ3+YoGRO/lhQCnh4hCvbgci7pJCzQoo5TmMrmSz2dPEVlJpsImQzBjsdPTuNreRdodu U47ulJ62egAqqZHck8IGsLgMbvFgpAd8OmbVJ2ZnEu4rTkPByjLsUZVmmdGY2U/v4KowaPz9vVd OY3h+7dzgTpNao4LeENUNhsZuR4g== X-Received: by 2002:a05:7301:7c12:b0:2ed:e14:7f5c with SMTP id 5a478bee46e88-2f54b89204emr11224440eec.32.1778485586024; Mon, 11 May 2026 00:46:26 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2f888e381c9sm12205702eec.26.2026.05.11.00.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 00:46:25 -0700 (PDT) From: Abdurrahman Hussain Date: Mon, 11 May 2026 00:46:14 -0700 Subject: [PATCH v2 3/3] i2c: xiic: don't clobber msg->len to signal block-read completion Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260511-i2c-xiic-v2-3-c16380cb1594@nexthop.ai> References: <20260511-i2c-xiic-v2-0-c16380cb1594@nexthop.ai> In-Reply-To: <20260511-i2c-xiic-v2-0-c16380cb1594@nexthop.ai> To: Michal Simek , Andi Shyti Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778485583; l=1863; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=tjDfjq5O5p81+MNuIlyxeuaZBrECDSK/ynhLod78ZDU=; b=gw6nqk9h7ji67ko8VcuiZnbtsh798I4nAiW0eLEU4honRN1DaqpqzEms07K7iy0hP7h8OdbMo ofqTUL9Hms6DQLDAvItHCCZB8xleHHnL0lXGtsTNLop4I4Aoo64vfcL X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= At the end of a SMBus block read the BNB handler force-set tx_msg->len =3D 1 to push xiic_tx_space() to zero so the STATE_DONE branch would fire. Two problems: 1. tx_msg and rx_msg alias the same i2c_msg struct during a receive (see xiic_start_recv), so overwriting tx_msg->len also changes rx_msg->len. The i2c core's i2c_smbus_check_pec() then reads the PEC from the wrong offset -- buf[0] instead of buf[rxmsg_len + 1] -- and either mis-validates or returns -EBADMSG. 2. xiic_start_recv sets tx_pos =3D msg->len (typically 2 when PEC is enabled). xiic_tx_space() is unsigned msg->len - tx_pos, so setting msg->len =3D 1 with tx_pos =3D 2 underflows to 0xFFFFFFFF and xiic_tx_space() never compares equal to 0 -- the STATE_DONE check falls through to STATE_ERROR, giving -EIO. Instead, advance tx_pos up to msg->len. That drives tx_space to 0 without touching msg->len, preserving the buffer length that xiic_smbus_block_read_setup() already grew to cover the length byte, the payload and the optional PEC byte. Signed-off-by: Abdurrahman Hussain --- drivers/i2c/busses/i2c-xiic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index a9452eca26df..24183483f1b3 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -865,8 +865,11 @@ static irqreturn_t xiic_process(int irq, void *dev_id) =20 if (i2c->tx_msg && i2c->smbus_block_read) { i2c->smbus_block_read =3D false; - /* Set requested message len=3D1 to indicate STATE_DONE */ - i2c->tx_msg->len =3D 1; + /* + * Drive xiic_tx_space() to 0 to signal STATE_DONE + * without truncating the rx_msg length. + */ + i2c->tx_pos =3D i2c->tx_msg->len; } =20 if (!i2c->tx_msg) --=20 2.53.0