{"id":2229271,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229271/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260427-i2c-xiic-v1-1-e6207f9aa5ad@nexthop.ai/","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/1.1/projects/35/?format=json","name":"Linux I2C development","link_name":"linux-i2c","list_id":"linux-i2c.vger.kernel.org","list_email":"linux-i2c@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260427-i2c-xiic-v1-1-e6207f9aa5ad@nexthop.ai>","date":"2026-04-28T00:18:06","name":"[1/3] i2c: xiic: preserve PEC byte length in SMBus block read setup","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"748b0bd904bc32f660048f518445ef8315b22973","submitter":{"id":92480,"url":"http://patchwork.ozlabs.org/api/1.1/people/92480/?format=json","name":"Abdurrahman Hussain via B4 Relay","email":"devnull+abdurrahman.nexthop.ai@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260427-i2c-xiic-v1-1-e6207f9aa5ad@nexthop.ai/mbox/","series":[{"id":501748,"url":"http://patchwork.ozlabs.org/api/1.1/series/501748/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/list/?series=501748","date":"2026-04-28T00:18:06","name":"i2c: xiic: fix SMBus block read and PEC support","version":1,"mbox":"http://patchwork.ozlabs.org/series/501748/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229271/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229271/checks/","tags":{},"headers":{"Return-Path":"\n <linux-i2c+bounces-17187-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-i2c@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=FTZO1ACo;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-i2c+bounces-17187-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"FTZO1ACo\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4Lcs4Z96z1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 10:18:21 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 8912B300CA3F\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 00:18:17 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 0DF7722173D;\n\tTue, 28 Apr 2026 00:18:11 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A4C1E1E1C11;\n\tTue, 28 Apr 2026 00:18:10 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPS id 64E53C2BCB7;\n\tTue, 28 Apr 2026 00:18:10 +0000 (UTC)","from aws-us-west-2-korg-lkml-1.web.codeaurora.org\n (localhost.localdomain [127.0.0.1])\n\tby smtp.lore.kernel.org (Postfix) with ESMTP id 524F9FF8867;\n\tTue, 28 Apr 2026 00:18:10 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777335490; cv=none;\n b=NEGgLpY0gBehVJI088iCvUwqXj4Gp+Wql7LzuKZ5WbKnaeYrXf0sFp3TzvX1oaM5oXTOaB1wc5EvC+nGfDmBvf8dMc+5lKHCErciZzBvZz4CibWL6MsHdXo+TcPyg2IT0F+Dum7APF7PPxj4I3QAp+lqXC4yotA752Ikh2r/FHk=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777335490; c=relaxed/simple;\n\tbh=pX6+8HgPg+/75SzAsHB9znme86Aih5ZL9FPNk75ERIc=;\n\th=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:\n\t In-Reply-To:To:Cc;\n b=aB2nkYX50YLbBY+0CGXU25GiugLUjCFUE2BqYKY2MKtoPLDx1g7/vv+Dok2RRDCR20tLxHaVf3BpzfRRYge/uluaks5KF6iyD3HeepcyHo/551h6jiup7OrgJf0QomYLebDJrkhYhlHDh+b378w+1GtlXMmwIl6uyLGfxfrwQ2o=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=FTZO1ACo; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777335490;\n\tbh=pX6+8HgPg+/75SzAsHB9znme86Aih5ZL9FPNk75ERIc=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From;\n\tb=FTZO1ACond1QyuWms2yeUh6w2WvZrK/37C6xfPBDNsQn/yZ915BFqTI8hSl3MyPGq\n\t 7UX62Cia71C7Hk91H6CuY0lNqX1S03nNgzqrDhRmTD7DsbAHuzpBreCfS5DkivpPhA\n\t y3OARf6rlex1UMgYomJpBEHx3TkleSjfc8GIledGH+uw5M/SQZJxAbKs/ljFKtG0qk\n\t UoYiS0Xww6ECLlYUY3XvIm6h3j5mgL9Nl3VZL1AykUCKyWJfVFT9UDXHXKZSFpABXC\n\t 1QtFsceu0F9Bd6Ok2uP0Zh+wgeECWmay9hU6lc6NtVaWqTLhno4vMzNTrVOd10sLut\n\t umrHOd78wosHw==","From":"Abdurrahman Hussain via B4 Relay\n <devnull+abdurrahman.nexthop.ai@kernel.org>","Date":"Mon, 27 Apr 2026 17:18:06 -0700","Subject":"[PATCH 1/3] i2c: xiic: preserve PEC byte length in SMBus block\n read setup","Precedence":"bulk","X-Mailing-List":"linux-i2c@vger.kernel.org","List-Id":"<linux-i2c.vger.kernel.org>","List-Subscribe":"<mailto:linux-i2c+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-i2c+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20260427-i2c-xiic-v1-1-e6207f9aa5ad@nexthop.ai>","References":"<20260427-i2c-xiic-v1-0-e6207f9aa5ad@nexthop.ai>","In-Reply-To":"<20260427-i2c-xiic-v1-0-e6207f9aa5ad@nexthop.ai>","To":"Michal Simek <michal.simek@amd.com>, Andi Shyti <andi.shyti@kernel.org>","Cc":"linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,\n linux-kernel@vger.kernel.org, Abdurrahman Hussain <abdurrahman@nexthop.ai>","X-Mailer":"b4 0.15.1","X-Developer-Signature":"v=1; a=openpgp-sha256; l=2279;\n i=abdurrahman@nexthop.ai; h=from:subject:message-id;\n bh=WbRNSgR6fF75ujIFRpZT+WIk0CWNPjAlMacuue3U6KE=;\n b=owJ4nJvAy8zAJbYltPXv6rsCXxhPqyUxZL7/c3B1ziaWhgZtFrFK/7l1X/ruSL6cYMDSVjL1j\n c2+ms//ngV2lLIwiHExyIopssx55P+mraMtYkPMIXuYOaxMIEMYuDgFYCJT7jAydHBtfsJ7Ujyo\n QjBN2L0pu0lRwTj1x/cph3/Ku6i+WVcWz/BPQZ3xXJja3qblId0ujyKkJq17U3jguKjB1QquM6I\n zzQ/zAgDNJ07Z","X-Developer-Key":"i=abdurrahman@nexthop.ai; a=openpgp;\n fpr=9CE24FEC86888658B05CC23FB45585FDABDD10F4","X-Endpoint-Received":"by B4 Relay for abdurrahman@nexthop.ai/default with\n auth_id=756","X-Original-From":"Abdurrahman Hussain <abdurrahman@nexthop.ai>","Reply-To":"abdurrahman@nexthop.ai"},"content":"From: Abdurrahman Hussain <abdurrahman@nexthop.ai>\n\nxiic_smbus_block_read_setup() overwrites rx_msg->len based on the\nannounced block length byte, but the i2c core appends an extra byte to\nmsg->len when PEC is enabled on the client (see\n__i2c_smbus_xfer_emulated in i2c-core-smbus.c). Before this handler\nruns, rx_msg->len is therefore 1 + pec_len, where pec_len is 0 or 1.\n\nOverwriting rx_msg->len to rxmsg_len + 1 drops that PEC byte from the\ncaller's buffer: the PEC byte is never drained from the FIFO and the\ncore's i2c_smbus_check_pec() reads the last payload byte instead of\nthe actual PEC, returning -EBADMSG even on clean transfers. Capture\npec_len before the overwrite and add it back when recomputing\nrx_msg->len.\n\nThis is a pure bug fix; non-PEC behaviour is unchanged (pec_len == 0).\nTested on a Xilinx AXI IIC FPGA block driving an adm1266 PMBus\nblackbox read -- with PEC enabled the full 64-byte record transfers\ncleanly after this change.\n\nSigned-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>\n---\n drivers/i2c/busses/i2c-xiic.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c\nindex 3e7735e1dae0..959a47b645a5 100644\n--- a/drivers/i2c/busses/i2c-xiic.c\n+++ b/drivers/i2c/busses/i2c-xiic.c\n@@ -539,6 +539,8 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c *i2c)\n \n \t/* Check if received length is valid */\n \tif (rxmsg_len <= I2C_SMBUS_BLOCK_MAX) {\n+\t\tunsigned int pec_len = i2c->rx_msg->len - 1;\n+\n \t\t/* Set Receive fifo depth */\n \t\tif (rxmsg_len > IIC_RX_FIFO_DEPTH) {\n \t\t\t/*\n@@ -546,7 +548,7 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c *i2c)\n \t\t\t * Receive fifo depth should set to Rx fifo capacity minus 1\n \t\t\t */\n \t\t\trfd_set = IIC_RX_FIFO_DEPTH - 1;\n-\t\t\ti2c->rx_msg->len = rxmsg_len + 1;\n+\t\t\ti2c->rx_msg->len = rxmsg_len + 1 + pec_len;\n \t\t} else if ((rxmsg_len == 1) ||\n \t\t\t(rxmsg_len == 0)) {\n \t\t\t/*\n@@ -562,7 +564,7 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c *i2c)\n \t\t\t * Receive fifo depth should set to Rx msg len minus 2\n \t\t\t */\n \t\t\trfd_set = rxmsg_len - 2;\n-\t\t\ti2c->rx_msg->len = rxmsg_len + 1;\n+\t\t\ti2c->rx_msg->len = rxmsg_len + 1 + pec_len;\n \t\t}\n \t\txiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set);\n \n","prefixes":["1/3"]}