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 8CB457C6C0; Wed, 21 Feb 2024 14:27:30 +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=1708525650; cv=none; b=u8Z38c8SwMIDxf86Zx4YoAPbj0J0CWBSVg3reXoIT8apmFUfVzIm54ZarQwkBXQq0VFoHL00gez9gfg+2cfsdXY5nye/Moj8ZosySvpKM7zZB1ii7FGJ6l6roumg3QeOgfhAmWpwReD/pcBp03n1H2mCMmzCnwPfeCC191bmM34= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708525650; c=relaxed/simple; bh=HfAclfuxQiBVXPLqMFycxGI6JFBndzpSgTLcNKCcHpk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WeVUPOxoX16k85kDziiShpmD2nboiKZRvyHlnfJ08Mz3hX0qRaPxBjBc8vFdJDENNxvq+jI0ANkL8Rh3Ho+TXpLaZFYJTzG0M+YsGdPhuimN+di6OMSdln2Dq7GNF0PmX8cuUhNmSZm9IZJfn316tarFuTSTUM6hdNcb5x+98XY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HrBw1TRr; 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="HrBw1TRr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08039C433C7; Wed, 21 Feb 2024 14:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708525650; bh=HfAclfuxQiBVXPLqMFycxGI6JFBndzpSgTLcNKCcHpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrBw1TRrHfm9ANdrrxzIce/dOAX4Rgr3lArIiO+g7MoV3ofwXvUZQ1DjVYWTbCmUw hwR9yp+4gcS+hcFsHqsU/ptewn91kHewDNPiaZO5idMbAMqtxM4DH0/kD595wALvhp cs9pqVs8LMyzWnYxTUda9UejhTOOzgA8bsUPrR0I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jean Delvare , Piotr Zakowski , Alexander Sverdlin , Andi Shyti , Sasha Levin Subject: [PATCH 5.4 220/267] i2c: i801: Fix block process call transactions Date: Wed, 21 Feb 2024 14:09:21 +0100 Message-ID: <20240221125947.124511800@linuxfoundation.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221125940.058369148@linuxfoundation.org> References: <20240221125940.058369148@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jean Delvare [ Upstream commit c1c9d0f6f7f1dbf29db996bd8e166242843a5f21 ] According to the Intel datasheets, software must reset the block buffer index twice for block process call transactions: once before writing the outgoing data to the buffer, and once again before reading the incoming data from the buffer. The driver is currently missing the second reset, causing the wrong portion of the block buffer to be read. Signed-off-by: Jean Delvare Reported-by: Piotr Zakowski Closes: https://lore.kernel.org/linux-i2c/20240213120553.7b0ab120@endymion.delvare/ Fixes: 315cd67c9453 ("i2c: i801: Add Block Write-Block Read Process Call support") Reviewed-by: Alexander Sverdlin Signed-off-by: Andi Shyti Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-i801.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 21ed6d98c048..18489940a947 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -531,11 +531,10 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, /* Set block buffer mode */ outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); - inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ - if (read_write == I2C_SMBUS_WRITE) { len = data->block[0]; outb_p(len, SMBHSTDAT0(priv)); + inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ for (i = 0; i < len; i++) outb_p(data->block[i+1], SMBBLKDAT(priv)); } @@ -551,6 +550,7 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, return -EPROTO; data->block[0] = len; + inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ for (i = 0; i < len; i++) data->block[i + 1] = inb_p(SMBBLKDAT(priv)); } -- 2.43.0