{"id":2229272,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229272/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260427-i2c-xiic-v1-3-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-3-e6207f9aa5ad@nexthop.ai>","date":"2026-04-28T00:18:08","name":"[3/3] i2c: xiic: don't clobber msg->len to signal block-read completion","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"3e405366f8a9b29e8cc69c594454e77a237e0e37","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-3-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/2229272/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229272/checks/","tags":{},"headers":{"Return-Path":"\n <linux-i2c+bounces-17188-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=oW+MLxvp;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-i2c+bounces-17188-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=\"oW+MLxvp\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4Lcv519Jz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 10:18:23 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 7B9EE3024A0A\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 101FF222590;\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 A4BC117B505;\n\tTue, 28 Apr 2026 00:18:10 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPS id 7C9FDC2BCC4;\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 6EDFAFF8864;\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=L5lHlQ4kzB6MuKYUZu6oOl6w3M8k+aETDbgtHZwvS6c6u5FUkgKX78lTLiMDaAC7HpRTo4R8pNGu+6khvcdo2ytgFkskRF73fak17zCxYU4eOKdxqP3AzNV/Gevabb1CvJ93oe/GnglSrDRLcqLeLgwoIoHGXJ2k+u70joM4cl8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777335490; c=relaxed/simple;\n\tbh=socDHfUvQqpc9gwIt9f18GJimPy7QixuJ0SteirtT0o=;\n\th=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:\n\t In-Reply-To:To:Cc;\n b=iGmR9fHUm16OzjHvgE92STiH87YcnDk19XDGd2TgNU/VqfEF4ahfc98sm9tX8RhIAVsWj7k7O+/y8gj16X9F0tPcUpVFCcilIewkjaFhNTMlDB52WjzYXg8R3NvUC3ERE70P6i+RTzDC01n/KXyQLbzWRnRvtjYP3M/FM9Xi9Yg=","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=oW+MLxvp; 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=socDHfUvQqpc9gwIt9f18GJimPy7QixuJ0SteirtT0o=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From;\n\tb=oW+MLxvpS4tM91Fej4aIsS9mAPEi0PcRTJu5CH+oCKIaAfH9IIFPdT6p6k19DPPgG\n\t B3LLM/5JRKhLaT6XUuicL3Vg/Xl4GAxBYmkSJAKQh4RbXq31FKPU3yl2bVmLujLEu/\n\t i3erW4YmZsTV3pcSz+Z31L7BUAtyvIFSyjbI7aa6rvNsUt32u1WmKeoc4K5qgUdnkJ\n\t /EtAamfuFYMYxZ0IOTALVrxMVV+bP4o8dZC0AdFPlFv7+atxm9LYb2ffw49tj2CF4p\n\t wkER2m0yN+qdHhzD7Hj0j2xM+bM4VwczQcvUafhX5ORVx+evuErR+oVwP4TKgcRuuQ\n\t oPokcYzNBwGvg==","From":"Abdurrahman Hussain via B4 Relay\n <devnull+abdurrahman.nexthop.ai@kernel.org>","Date":"Mon, 27 Apr 2026 17:18:08 -0700","Subject":"[PATCH 3/3] i2c: xiic: don't clobber msg->len to signal block-read\n completion","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-3-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=1863;\n i=abdurrahman@nexthop.ai; h=from:subject:message-id;\n bh=OktgHJV/MKY6BGPhmYAbpjHL8E9xIEfPx0WNo7EeXKg=;\n b=owJ4nJvAy8zAJbYltPXv6rsCXxhPqyUxZL7/c1D+/YWV3ude8c44uo171kVreYnc4A9ndzgYc\n 5v1WZ2R7P3SUcrCIMbFICumyDLnkf+bto62iA0xh+xh5rAygQxh4OIUgImUhDIy/OkTW7nm6/x5\n 1+NvPnzWVc+QrPBm6t+rbz7kn9jLVvuo14uRYXtA04SNf9iNs+V+fn4mfn3LJqP/D0ptNn9M092\n 1Lc5uBxsA3YtVpw==","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\nAt the end of a SMBus block read the BNB handler force-set\ntx_msg->len = 1 to push xiic_tx_space() to zero so the STATE_DONE\nbranch would fire. Two problems:\n\n1. tx_msg and rx_msg alias the same i2c_msg struct during a receive\n   (see xiic_start_recv), so overwriting tx_msg->len also changes\n   rx_msg->len. The i2c core's i2c_smbus_check_pec() then reads the\n   PEC from the wrong offset -- buf[0] instead of buf[rxmsg_len + 1]\n   -- and either mis-validates or returns -EBADMSG.\n\n2. xiic_start_recv sets tx_pos = msg->len (typically 2 when PEC is\n   enabled). xiic_tx_space() is unsigned msg->len - tx_pos, so\n   setting msg->len = 1 with tx_pos = 2 underflows to 0xFFFFFFFF and\n   xiic_tx_space() never compares equal to 0 -- the STATE_DONE check\n   falls through to STATE_ERROR, giving -EIO.\n\nInstead, advance tx_pos up to msg->len. That drives tx_space to 0\nwithout touching msg->len, preserving the buffer length that\nxiic_smbus_block_read_setup() already grew to cover the length byte,\nthe payload and the optional PEC byte.\n\nSigned-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>\n---\n drivers/i2c/busses/i2c-xiic.c | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c\nindex 946e3ed2d760..27715646a9fb 100644\n--- a/drivers/i2c/busses/i2c-xiic.c\n+++ b/drivers/i2c/busses/i2c-xiic.c\n@@ -864,8 +864,11 @@ static irqreturn_t xiic_process(int irq, void *dev_id)\n \n \t\tif (i2c->tx_msg && i2c->smbus_block_read) {\n \t\t\ti2c->smbus_block_read = false;\n-\t\t\t/* Set requested message len=1 to indicate STATE_DONE */\n-\t\t\ti2c->tx_msg->len = 1;\n+\t\t\t/*\n+\t\t\t * Drive xiic_tx_space() to 0 to signal STATE_DONE\n+\t\t\t * without truncating the rx_msg length.\n+\t\t\t */\n+\t\t\ti2c->tx_pos = i2c->tx_msg->len;\n \t\t}\n \n \t\tif (!i2c->tx_msg)\n","prefixes":["3/3"]}