Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6243232iob; Tue, 10 May 2022 13:46:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMJnuPO/7yxdRUbdOMqhN+PYYd8321kBtM6/nK8ulk2pKFoZ8MmVB2M8l5eSwx0qU8vFQk X-Received: by 2002:a17:907:7da6:b0:6f4:dc6f:1e32 with SMTP id oz38-20020a1709077da600b006f4dc6f1e32mr21079995ejc.614.1652215613845; Tue, 10 May 2022 13:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652215613; cv=none; d=google.com; s=arc-20160816; b=FgJSygcnUnv3fTyE60EcAk9t7butnIFisNogR1zD42AySoKZzSUSaRc7azEXLPksIH cDrQHFIY4tZYZDpj3plt9bop4LKHdixniB9uVqBbnd+TiVc9S6+RG80m8tLaLhqE8Vf9 BJmKGhvgumBOTaGgoFhz4iERNHJptyX+DcQef0SIvBlvhtXDhKHsEwvl8o9Wzd+qjJ5e RGhT/P1O+NP5GIarpeXQa3mkmNVjoqyAj2PJqDFRaiNuhflS9D1YBYqtV/LHAxCeylzL JnOSjW7/tV/oqACRDw2WcXNEYfX2yX44EO5dys7XoCgcYdbO8TysuDHJtiz3zbWBUUqL cvYg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ouz40ScP+HV6bCX2owxJJQYX69C9xk7K2TAVYgTnXhQ=; b=K3Z3/H90YjitcbRZdfC8yN25AlZJsDUuQ1cuyvg34yrYjhADbia5wzs8JNEyCIyWfK Yf13DJ93EXngL3DL8ggCE3ttqavXXu1F+OHnkFi+i2P7pge/GIj0t05RSiGP5bahV924 TwW2eTcWvt39ENgx2eK1sA9h2sxnuLHnO1/MUf6yXr1ERz63knSvaS59woRn9PgXhGdE 1lYiLGEaPpd8IvwZlqJD6tcCknpKKOF0UV8NA5EyJLbcmrIC+aKzZS8Zicd9vkruDbUz F3zIWhxPc5YYZ8sRoDpwUpV+CFASOfcy/FOsgbHj3L1heqkvb0lINPnSeFZiHYXc+VWE oakw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=axOW4MCf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o17-20020a1709064f9100b006f395c76f21si306268eju.891.2022.05.10.13.46.30; Tue, 10 May 2022 13:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=axOW4MCf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344130AbiEJOZm (ORCPT + 99 others); Tue, 10 May 2022 10:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244205AbiEJNwx (ORCPT ); Tue, 10 May 2022 09:52:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 002736C0DD; Tue, 10 May 2022 06:38:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E1239B81DB3; Tue, 10 May 2022 13:37:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4825CC385C6; Tue, 10 May 2022 13:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652189870; bh=zlEMjjuzr3mcxVhnutTM6/09TaldW+hL/6Nh9t7O0Zk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=axOW4MCfOow57M4lgEo+SwzK19qsF/43NZd8x1sB82LLQGf8ViKwvIQVtSvlv4APt aEBHIXsbTDC/UKJSS72BrKtgNvLVDaVw/sfpuINiENbWae6Q+/2sxbm9bsLzV5vEIT O4unf5XyaKHC9FqkW5uqs6sCJy2gz/unVfCG92xY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adam Wujek , Guenter Roeck Subject: [PATCH 5.17 056/140] hwmon: (pmbus) disable PEC if not enabled Date: Tue, 10 May 2022 15:07:26 +0200 Message-Id: <20220510130743.221225564@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130741.600270947@linuxfoundation.org> References: <20220510130741.600270947@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adam Wujek commit 75d2b2b06bd8407d03a3f126bc8b95eb356906c7 upstream. Explicitly disable PEC when the client does not support it. The problematic scenario is the following. A device with enabled PEC support is up and running and a kernel driver is loaded. Then the driver is unloaded (or device unbound), the HW device is reconfigured externally (e.g. by i2cset) to advertise itself as not supporting PEC. Without a new code, at the second load of the driver (or bind) the "flags" variable is not updated to avoid PEC usage. As a consequence the further communication with the device is done with the PEC enabled, which is wrong and may fail. The implementation first disable the I2C_CLIENT_PEC flag, then the old code enable it if needed. Fixes: 4e5418f787ec ("hwmon: (pmbus_core) Check adapter PEC support") Signed-off-by: Adam Wujek Link: https://lore.kernel.org/r/20220420145059.431061-1-dev_public@wujek.eu Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/pmbus/pmbus_core.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2326,6 +2326,9 @@ static int pmbus_init_common(struct i2c_ data->has_status_word = true; } + /* Make sure PEC is disabled, will be enabled later if needed */ + client->flags &= ~I2C_CLIENT_PEC; + /* Enable PEC if the controller and bus supports it */ if (!(data->flags & PMBUS_NO_CAPABILITY)) { ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);