Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1137051pxj; Fri, 4 Jun 2021 06:59:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgL84w3byfmSSfHTLYDeXTpseTa9naDIr2PPnakHa7BYLTW7Nxw27Ss7aKIbsj/Xzdy01+ X-Received: by 2002:a17:906:c14c:: with SMTP id dp12mr4292273ejc.312.1622815145779; Fri, 04 Jun 2021 06:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622815145; cv=none; d=google.com; s=arc-20160816; b=HgYGV3e70OrbowZusHJ/C8It+4uG9FmJDxaGzqOtPtGtGBSY7UZlwXf3SwEviJ+tD8 ORYZN2gecuSIRCz1XwTMTWmunwTvE5Y8HN0VZ0raXvy+xUp2pIrymdaI8tUup9mM+12C GfN7IgL86+0EqWASIsWizO9zPOLiyOMKAkrxVD9eZFHNPsUSPlZRZ5WjUKxJbViO79WP GTdeX2qWYSTtdHho3p4LV21GlFscTlL22/fKhHCLPfNNaRbpUGbEl9dH/9kJG2wa30uB QG6BYoH3vseUjipr+HHj0J9MNrxsIn8C8KxI92d/AEqLQbW4wX4zsBQx4Sa5l+o/M2y5 fHfQ== 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 :message-id:date:subject:cc:to:from; bh=D4hLYPVoFArku6J57sjNtQzoJ4ejT4ZoKK912uvWR08=; b=o5YQUCLSjPajLAcIaTsSHofLpYcIppm6mbyCl+QxREvRoy/EJuU9eFSCEunoUkUiLe 9gcYCBBy36Lv5J4v+37EhaC0yJERSYGXzI687BTKfo6CU9O1ayakocL8kZ9PUC6cSQb+ j0+Jo1X7wrtDzibMQmafaz7hzFLygazeXScMWf/aVygxfsbAAFhjA+fjJwXOdEjNmgrA HsBg5v3qB9Rk6m1jt8DMgBK1Trr/ccqBRe8FaRMALDP3ab6wFuGM9uJ6FmRSxMyNZah4 VKF61LUw6UJkK9lMk1OoBPLi+4HoMf/b3Y2OdvoIcLbMX21PxggXew1Ke3oWqBxD+RFt dPPA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ec2si4910856ejb.189.2021.06.04.06.58.41; Fri, 04 Jun 2021 06:59:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230450AbhFDN7Y (ORCPT + 99 others); Fri, 4 Jun 2021 09:59:24 -0400 Received: from mx3.molgen.mpg.de ([141.14.17.11]:45049 "EHLO mx1.molgen.mpg.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230124AbhFDN7Y (ORCPT ); Fri, 4 Jun 2021 09:59:24 -0400 Received: from localhost.localdomain (ip5f5ae886.dynamic.kabel-deutschland.de [95.90.232.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id A615361E64762; Fri, 4 Jun 2021 15:57:35 +0200 (CEST) From: Paul Menzel To: Guenter Roeck , Jean Delvare Cc: Madhava Reddy Siddareddygari , Paul Menzel , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hwmon: (pmbus_core) Check adapter PEC support Date: Fri, 4 Jun 2021 15:57:14 +0200 Message-Id: <20210604135714.529042-1-pmenzel@molgen.mpg.de> X-Mailer: git-send-email 2.32.0.rc2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Madhava Reddy Siddareddygari Currently, for Packet Error Checking (PEC) only the controller is checked for support. This causes problems on the cisco-8000 platform where a SMBUS transaction errors are observed. This is because PEC has to be enabled only if both controller and adapter support it. Added code to check PEC capability for adapter and enable it only if both controller and adapter supports PEC. Signed-off-by: Madhava Reddy Siddareddygari [Upstream from SONiC https://github.com/Azure/sonic-linux-kernel/pull/215] Signed-off-by: Paul Menzel --- drivers/hwmon/pmbus/pmbus_core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index bbd745178147..7fbd82b7560d 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2214,11 +2214,13 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, data->has_status_word = true; } - /* Enable PEC if the controller supports it */ - if (!(data->flags & PMBUS_NO_CAPABILITY)) { - ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); - if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK)) + /* Enable PEC if the controller and bus supports it */ + ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); + if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_PEC)) { client->flags |= I2C_CLIENT_PEC; + } } /* -- 2.32.0.rc2