Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp502628pxb; Thu, 9 Sep 2021 06:01:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVjGUF2c/P04+GBF756tvfrc5jvykwvfQWzveZZdHVNd1bdqAL24R29paIYNwG2hiSzY5y X-Received: by 2002:a05:6512:ad3:: with SMTP id n19mr2261429lfu.297.1631192494850; Thu, 09 Sep 2021 06:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631192494; cv=none; d=google.com; s=arc-20160816; b=JYHqL6/J5Tj1714xI2NCk5mHHETJS0efKZ9Bo59Tbp2nyJN+LtDb6Lf98MZOwe7DPn hlxJczO47Url3X5PhCEuKGDPVaqLEfQlXoqNPmRI916OO+1VFohUp2+uJuqn+dHyD+1A 80iW+mraQ3Kf3yWBe/9KdopraBDkyYm+uT5qOzKmMvrNPZYF6fUSZldybavtaABpoC4F CWh9l2VAa9nGBy6uucXs1R9K029CwbDeJ9YV5f9/L6jAzcd2FTY1bpXSexkRgGBNkr/i R5URUh3+sk7lp+dis4vAJOnY8n1rINQajKe2OiRkDLkZ/p4JKQP2Ms3PxTklgyJdmp6u WMMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nIyuIbteo9ie7jeD8Tj/y0ZACk8DXLEOta3xZfmDglI=; b=agF5jr2x5S7Ws/dkSJOsIpD0gypF9/bK3VoJv/k6U6VtMT7fGqxf7G8rt7NjCoeOfD OxlVQs/75WY9+fHJYOO3HkSJoM34T1SGCxs+SlHcJmLs0pVB05VI+8jpRSloe+g6OiEX GhJRFNPoQaLChigTMxKC9wIyBy9fmf46Yd0Rh1vkWDFFlnnoB3NHr9F5SxZSHKXmLgDd LE2EP9SbZgRSJW9Up6xBzCJO2m343zWgzVPjHPij7eJJKHDr4Kr/DozgCn3OPW5etNBR Gsapk+G9wUk4xC3PetF7JxKYFQWNi7fkCTibm/IkrgZrbdvC9yGf+x1SJO7ZPQw37TYc s2UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f4U5ovBg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si1854783edc.166.2021.09.09.06.01.00; Thu, 09 Sep 2021 06:01:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f4U5ovBg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347732AbhIIM4u (ORCPT + 99 others); Thu, 9 Sep 2021 08:56:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:55860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355288AbhIIMpF (ORCPT ); Thu, 9 Sep 2021 08:45:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 989A4630EF; Thu, 9 Sep 2021 11:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188560; bh=EQDvWcBd9tVsriQeK+dTVMgqWTuR1Gn/6oSqmXHsnH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4U5ovBgYS95QthoZBsmTer8TsV3+59hPC7xFv1db0da9xlRCAZMYoOXJGWX1bWIP 4C1x9s0GRj+BUOFTmwnXhDCIbEcl59BLvrMpcxP5WfR6TC+NP9bK/Vl3lJ90sKUngY TzwlAs6jLbk9rvgk2S/hw8NJEqvnxs3UxGmKma8uob6CZKlWO/zj0NpdNm8zFb9V0M k4AtB1oOPHM0Ge6S3nH//ATI0yg0JhomHtm1+SetcPTBLQ1Kh9bktmEuWqtkU8qrpq QE3V6QR5l1WsRSabQXsUVmvOZA6FPhmbU6FIsFbwKitZ2x76rFkVFqoZJWdpMsBFro 0jrbzINyJKzuw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Heiner Kallweit , Jean Delvare , Wolfram Sang , Sasha Levin , linux-i2c@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 042/109] i2c: i801: Fix handling SMBHSTCNT_PEC_EN Date: Thu, 9 Sep 2021 07:53:59 -0400 Message-Id: <20210909115507.147917-42-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heiner Kallweit [ Upstream commit a6b8bb6a813a6621c75ceacd1fa604c0229e9624 ] Bit SMBHSTCNT_PEC_EN is used only if software calculates the CRC and uses register SMBPEC. This is not supported by the driver, it supports hw-calculation of CRC only (using bit SMBAUXSTS_CRCE). The chip spec states the following, therefore never set bit SMBHSTCNT_PEC_EN. Chapter SMBus CRC Generation and Checking If the AAC bit is set in the Auxiliary Control register, the PCH automatically calculates and drives CRC at the end of the transmitted packet for write cycles, and will check the CRC for read cycles. It will not transmit the contents of the PEC register for CRC. The PEC bit must not be set in the Host Control register. If this bit is set, unspecified behavior will result. This patch is based solely on the specification and compile-tested only, because I have no PEC-capable devices. Signed-off-by: Heiner Kallweit Tested-by: Jean Delvare Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-i801.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index a959062ded4f..4da3b58aa505 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -510,19 +510,16 @@ static int i801_transaction(struct i801_priv *priv, int xact) static int i801_block_transaction_by_block(struct i801_priv *priv, union i2c_smbus_data *data, - char read_write, int command, - int hwpec) + char read_write, int command) { - int i, len; - int status; - int xact = hwpec ? SMBHSTCNT_PEC_EN : 0; + int i, len, status, xact; switch (command) { case I2C_SMBUS_BLOCK_PROC_CALL: - xact |= I801_BLOCK_PROC_CALL; + xact = I801_BLOCK_PROC_CALL; break; case I2C_SMBUS_BLOCK_DATA: - xact |= I801_BLOCK_DATA; + xact = I801_BLOCK_DATA; break; default: return -EOPNOTSUPP; @@ -672,8 +669,7 @@ static irqreturn_t i801_isr(int irq, void *dev_id) */ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, union i2c_smbus_data *data, - char read_write, int command, - int hwpec) + char read_write, int command) { int i, len; int smbcmd; @@ -778,9 +774,8 @@ static int i801_set_block_buffer_mode(struct i801_priv *priv) } /* Block transaction function */ -static int i801_block_transaction(struct i801_priv *priv, - union i2c_smbus_data *data, char read_write, - int command, int hwpec) +static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data *data, + char read_write, int command) { int result = 0; unsigned char hostc; @@ -816,11 +811,11 @@ static int i801_block_transaction(struct i801_priv *priv, && i801_set_block_buffer_mode(priv) == 0) result = i801_block_transaction_by_block(priv, data, read_write, - command, hwpec); + command); else result = i801_block_transaction_byte_by_byte(priv, data, read_write, - command, hwpec); + command); if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_WRITE) { @@ -931,8 +926,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, SMBAUXCTL(priv)); if (block) - ret = i801_block_transaction(priv, data, read_write, size, - hwpec); + ret = i801_block_transaction(priv, data, read_write, size); else ret = i801_transaction(priv, xact); @@ -1691,6 +1685,7 @@ static unsigned char i801_setup_hstcfg(struct i801_priv *priv) unsigned char hstcfg = priv->original_hstcfg; hstcfg &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */ + hstcfg &= ~SMBHSTCNT_PEC_EN; /* Disable software PEC */ hstcfg |= SMBHSTCFG_HST_EN; pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hstcfg); return hstcfg; -- 2.30.2