From patchwork Thu Aug 27 13:30:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1352558 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BckPX5Lzpz9sSP for ; Thu, 27 Aug 2020 23:40:16 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=J5zABpw+; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=L+cuOAUx; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BckPW29X9zDqjY for ; Thu, 27 Aug 2020 23:40:15 +1000 (AEST) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=66.111.4.28; helo=out4-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=J5zABpw+; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=L+cuOAUx; dkim-atps=neutral Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BckKF0tZGzDqgq for ; Thu, 27 Aug 2020 23:36:32 +1000 (AEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id D46165C0077; Thu, 27 Aug 2020 09:30:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 27 Aug 2020 09:30:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=6EIf2LGImcTk3 KN8YEp7FE9CDzy1PxgLn7xD/VwiMqY=; b=J5zABpw+y1iUXC0GfMtmCgmB9N1V2 ZMyn7+Z5euptMG99D3a9OFtrerzxt5eyw+EAulZPlBYnHKSKwwMc3NssUw1ysmmo Kn37t+MbUpupY2kzz2fTJqSHZXrJuwa/L846K9q1ZCVXx0DobMeSngkEkyXuA0km EjKfENbvHHBXR0LGGnOvqOQpC7z3cffPzC0bDFiyp/xd7HHOZmWKwn3wcvo2zTWS tf31lk+SqPV0wAHImaqurAGuhKXUpk1Osti15h5WGL0BkhW0ix1Ci6CXk4uYo6BR i4jJXyhy/e7Iu7JoUYJZU2NiGimRNAI7JTBzJfS2K7F8ry7PFvQujSzog== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=6EIf2LGImcTk3KN8YEp7FE9CDzy1PxgLn7xD/VwiMqY=; b=L+cuOAUx nF2y6/cH3DMGSqcW1oWm5S76JCMmOlbevVRyMYriv1L814R/K5O0msci5L35H5Mb n5Ptu4crO6TLETrNr92eVMOtLpjJpuXQkcv5fcRurXlpOh/axVVv7AfZrL7L9H+G CslrkakisnDFadSGD+b348cUjEy83dQNMfo1UmfWaKPyELi9k+31Iea8RXFMrXkm 1w+XGanFRkWQg2QRh+BxHzd6B3HUBST+Q2mNJMVQdauf75ggHYfL6XuqVrdIQVVh nH0yfa8tmibRiBT3NVsO0KgfIrXU0MjW8d1oS/OJa0bVzfGjK9W058KS1YJYbx14 0G56EmBbJLszEA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddvgedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhepjefgvdevheetkeevgeegleelgfelte etjeffleffvdduudevieffgeetleevhfetnecukfhppedugedrvddrudduiedruddtnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvg ifsegrjhdrihgurdgruh X-ME-Proxy: Received: from localhost.localdomain (ppp14-2-116-10.adl-apt-pir-bras32.tpg.internode.on.net [14.2.116.10]) by mail.messagingengine.com (Postfix) with ESMTPA id A34CC3280059; Thu, 27 Aug 2020 09:30:42 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.8 1/3] pmbus: (max31785) Retry enabling fans after writing MFR_FAN_CONFIG Date: Thu, 27 Aug 2020 23:00:00 +0930 Message-Id: <20200827133002.369439-2-andrew@aj.id.au> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200827133002.369439-1-andrew@aj.id.au> References: <20200827133002.369439-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" It has been observed across large fleets of systems that a small subset of those systems occasionally loose control of some number of fans across a BMC reboot (their hwmon fan attributes are missing from sysfs). From extensive testing and tracing it was discovered that writes enabling a fan in FAN_CONFIG_1_2 failed to stick on the system under test with a frequency of about 1 in 1000 re-binds of the driver. The MAX31785 datasheet recommends in the documentation for MFR_FAN_CONFIG that the asssociated fan(s) be disabled before updating the register. The sequence in question implements this suggestion, and the observed loss-of-fans symptom occurs when the write to re-enable the fan in FAN_CONFIG_1_2 fails to stick. The trace data suggests a one-shot retry is enough to successfully update FAN_CONFIG_1_2. With the workaround, no loss of fans was observed in over 20,000 consecutive rebinds of the driver. Signed-off-by: Andrew Jeffery --- drivers/hwmon/pmbus/max31785.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/pmbus/max31785.c b/drivers/hwmon/pmbus/max31785.c index cbcd0b2301f4..88b7156d777e 100644 --- a/drivers/hwmon/pmbus/max31785.c +++ b/drivers/hwmon/pmbus/max31785.c @@ -376,6 +376,7 @@ static int max31785_of_fan_config(struct i2c_client *client, u32 page; u32 uval; int ret; + int i; if (!of_device_is_compatible(child, "pmbus-fan")) return 0; @@ -552,10 +553,24 @@ static int max31785_of_fan_config(struct i2c_client *client, if (ret < 0) return ret; - ret = max31785_i2c_smbus_write_byte_data(client, PMBUS_FAN_CONFIG_12, - pb_cfg); - if (ret < 0) - return ret; + for (i = 0; i < 2; i++) { + ret = max31785_i2c_smbus_write_byte_data(client, + PMBUS_FAN_CONFIG_12, + pb_cfg); + if (ret < 0) + continue; + + ret = max31785_i2c_smbus_read_byte_data(client, + PMBUS_FAN_CONFIG_12); + if (ret < 0) + continue; + + if (ret == pb_cfg) + break; + } + + if (i == 2) + return -EIO; /* * Fans are on pages 0 - 5. If the page property of a fan node is From patchwork Thu Aug 27 13:30:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1352573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BckWN1r0Zz9sRK for ; Thu, 27 Aug 2020 23:45:20 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=Cf4BwQ2T; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=VM8C4fHm; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BckWN011kzDqYn for ; Thu, 27 Aug 2020 23:45:20 +1000 (AEST) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=66.111.4.28; helo=out4-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=Cf4BwQ2T; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=VM8C4fHm; dkim-atps=neutral Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BckKF0QgCzDqM3 for ; Thu, 27 Aug 2020 23:36:32 +1000 (AEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 6B63A5C0316; Thu, 27 Aug 2020 09:30:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 27 Aug 2020 09:30:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=sw3c6eWGVj7V0 vWAk3un+/GnrJLprKEwMeWYTD+JiqY=; b=Cf4BwQ2Tp3mX+0YPVVMk98aItHsNu 5zBfgi0m+c+aKXf5W1cckDHUpyqmQzn0JHQk9RxJKLKmgKPHOMsfndWsM73OSma8 Jj5cjDxBvwJwUz1d2YHa7iWQkirLC/pY2X6tq7u3YicPCPiqlyEv1mSao+G8F0Jx WXtXoDp1nERFgCPWR1dV6DNr11ZDksBMx45Q9hrK5omlrho89hjtunS8TnOdvADb auvZtmJYCYwz5M4OirYmEcVg8HJbyc9Z7S7xqTypcA8DinqSA+UoEynpPOWo7XHP 78z9jhh02xHbF+ARNwg7WW4VDkoXZLCl4DJVXAmwmkJ2Ligz1ZSmuW30A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=sw3c6eWGVj7V0vWAk3un+/GnrJLprKEwMeWYTD+JiqY=; b=VM8C4fHm ZtAN3dOjSnAjN2Z8dcE/KMWOBA2XnvxXA8RihDZ14lTuCDIF/28PCVQJ0bp0oYGK PvB1tdZuXZA7H5ZOm/RZwbyC2IB1wQhhksSt8kze2ukYXs5Jc2KiZ08G1oR1iDyz O56Zt5W/Khbzel8RwzibmyAXCt3OWNAxfXNf7ADxRh+S6yjMnDxuQJTR6TfVFKIo Cgl2PlPM9sjnhsSCU2xHmJ00g98l+8PyErHVlEqUlr/OjsaDjDwzq+WgHvoeh4/w kRsaXW3b2g/6pjoSjPgeBcTMOmXgjMf/fG20+TKYJQ1IiDwQs5VLdsLGHj20798D tqp4g1P81iGX2w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddvgedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhepjefgvdevheetkeevgeegleelgfelte etjeffleffvdduudevieffgeetleevhfetnecukfhppedugedrvddrudduiedruddtnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvg ifsegrjhdrihgurdgruh X-ME-Proxy: Received: from localhost.localdomain (ppp14-2-116-10.adl-apt-pir-bras32.tpg.internode.on.net [14.2.116.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 2CAFC3280059; Thu, 27 Aug 2020 09:30:43 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.8 2/3] pmbus: (max31785) Add a local pmbus_set_page() implementation Date: Thu, 27 Aug 2020 23:00:01 +0930 Message-Id: <20200827133002.369439-3-andrew@aj.id.au> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200827133002.369439-1-andrew@aj.id.au> References: <20200827133002.369439-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" Extensive testing and tracing has shown that the MAX31785 is unreliable in the face of PAGE write commands, ACK'ing the PAGE request but reporting a value of 0 on some subsequent PAGE reads. The trace data suggests that a one-shot retry of the PAGE write is enough to get the requested value to stick. As we configure the device before registering with the PMBus core, centralise PAGE handling inside the driver and implement the one-shot retry semantics there. Signed-off-by: Andrew Jeffery --- drivers/hwmon/pmbus/max31785.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/pmbus/max31785.c b/drivers/hwmon/pmbus/max31785.c index 88b7156d777e..a392c0efe0a6 100644 --- a/drivers/hwmon/pmbus/max31785.c +++ b/drivers/hwmon/pmbus/max31785.c @@ -361,6 +361,27 @@ static int max31785_write_word_data(struct i2c_client *client, int page, return -ENXIO; } +static int max31785_pmbus_set_page(struct i2c_client *client, int page) +{ + int ret; + int i; + + for (i = 0; i < 2; i++) { + ret = max31785_i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); + if (ret < 0) + return ret; + + ret = max31785_i2c_smbus_read_byte_data(client, PMBUS_PAGE); + if (ret < 0) + return ret; + + if (ret == page) + return 0; + } + + return -EIO; +} + /* * Returns negative error codes if an unrecoverable problem is detected, 0 if a * recoverable problem is detected, or a positive value on success. @@ -392,7 +413,7 @@ static int max31785_of_fan_config(struct i2c_client *client, return -ENXIO; } - ret = max31785_i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); + ret = max31785_pmbus_set_page(client, page); if (ret < 0) return ret; @@ -613,7 +634,7 @@ static int max31785_of_tmp_config(struct i2c_client *client, return -ENXIO; } - ret = max31785_i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); + ret = max31785_pmbus_set_page(client, page); if (ret < 0) return ret; @@ -714,7 +735,7 @@ static int max31785_configure_dual_tach(struct i2c_client *client, int i; for (i = 0; i < MAX31785_NR_FAN_PAGES; i++) { - ret = max31785_i2c_smbus_write_byte_data(client, PMBUS_PAGE, i); + ret = max31785_pmbus_set_page(client, i); if (ret < 0) return ret; @@ -756,7 +777,7 @@ static int max31785_probe(struct i2c_client *client, *info = max31785_info; - ret = max31785_i2c_smbus_write_byte_data(client, PMBUS_PAGE, 255); + ret = max31785_pmbus_set_page(client, 255); if (ret < 0) return ret; @@ -798,8 +819,7 @@ static int max31785_probe(struct i2c_client *client, if (!have_fan || fan_configured) continue; - ret = max31785_i2c_smbus_write_byte_data(client, PMBUS_PAGE, - i); + ret = max31785_pmbus_set_page(client, i); if (ret < 0) return ret; From patchwork Thu Aug 27 13:30:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 1352567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BckTK6zTlz9sT6 for ; Thu, 27 Aug 2020 23:43:33 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=Bt3k5Xtb; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=MOk+P2BH; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BckTK64bBzDqf3 for ; Thu, 27 Aug 2020 23:43:33 +1000 (AEST) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aj.id.au (client-ip=66.111.4.28; helo=out4-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.a=rsa-sha256 header.s=fm3 header.b=Bt3k5Xtb; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=MOk+P2BH; dkim-atps=neutral Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BckKF0gC9zDqSh for ; Thu, 27 Aug 2020 23:36:32 +1000 (AEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id E676F5C031A; Thu, 27 Aug 2020 09:30:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 27 Aug 2020 09:30:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=Kkcc9vN9QXP25 +selb3Q6qwT+96BRSbB1PImG5HrLwU=; b=Bt3k5XtblL3weuNT55h+XW1wK0kkl khJ8VtPutL/m/b37CLq2xX5qt2rt7Cz97jgrNZdXqVikvH/H58IUWylue0pbMtH8 BgdLKrOL0fsiO+MzaIzkzCtrNoumJaYPUBB2EKxhh5RTBP/iOr2tNO4lqCeXeHHY KFrW2JCfbiEejLnDq/a/7e5dg50FS5krd3geGPZTKP83BXD/hDNNywvHwnFpNqIk djNd8pXOWF2j8YeJIE+1ASa4oVlNGOc/GmaKaiEgY194kpfnVzfR/8kFFvPTMrK/ uikwIyGEtk17i7ho2wRL4/F1cb2Zi8Dw9kFmmEAVkMYZtMDhpjsg2yDsQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=Kkcc9vN9QXP25+selb3Q6qwT+96BRSbB1PImG5HrLwU=; b=MOk+P2BH PuHwxkpvWBYx7jrUr0j4CPK3kDKXnI383+QOH08jZ7Pyf9s8DqEeglzWb7iuoWaY IPHeUlolREc9LqYZfh5HKiG1UCBQ1fbFrqNOvcuOwSd3PbP8/VnxxY5GHVx2lmBH gAKB8oGwuBJ2dk5NJmrKLX5mj9br73T6MU5gycQCqT1IIm9eetZW4NN8FbXY9UuX lEj33//xBhZay/QflTquF+09ivYq9NESMflmrbyjx3//dENPfZey7mYWl/YkhVLx TgxZnmdYSY+dkGxnMF2TAodxm47Rxsepoiu7Lt/yx72OXEdJSAwSLYJ6A+/5t3Oa fqP/OG2TI1Ewwg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddvgedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegr jhdrihgurdgruheqnecuggftrfgrthhtvghrnhepjefgvdevheetkeevgeegleelgfelte etjeffleffvdduudevieffgeetleevhfetnecukfhppedugedrvddrudduiedruddtnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvg ifsegrjhdrihgurdgruh X-ME-Proxy: Received: from localhost.localdomain (ppp14-2-116-10.adl-apt-pir-bras32.tpg.internode.on.net [14.2.116.10]) by mail.messagingengine.com (Postfix) with ESMTPA id B5B243280059; Thu, 27 Aug 2020 09:30:45 -0400 (EDT) From: Andrew Jeffery To: joel@jms.id.au Subject: [PATCH linux dev-5.8 3/3] pmbus: (core) Add a one-shot retry in pmbus_set_page() Date: Thu, 27 Aug 2020 23:00:02 +0930 Message-Id: <20200827133002.369439-4-andrew@aj.id.au> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200827133002.369439-1-andrew@aj.id.au> References: <20200827133002.369439-1-andrew@aj.id.au> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openbmc@lists.ozlabs.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" From extensive testing and tracing it was discovered that the MAX31785 occasionally fails to switch pages despite ACK'ing the PAGE PMBus data write. I suspect this behaviour had been seen on other devices as well, as pmbus_set_page() already read-back the freshly set value and errored out if it wasn't what we requested. In the case of the MAX31785 it was shown that a one-shot retry was enough to get the PAGE write to stick if the inital command failed. To improve robustness, only error out if the one-shot retry also fails to stick. Signed-off-by: Andrew Jeffery --- drivers/hwmon/pmbus/pmbus_core.c | 33 ++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 702c25010369..7d0aac59af31 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -158,25 +158,34 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase) if (!(data->info->func[page] & PMBUS_PAGE_VIRTUAL) && data->info->pages > 1 && page != data->currpage) { + int i; + dev_dbg(&client->dev, "Want page %u, %u cached\n", page, data->currpage); - rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); - if (rv < 0) { + for (i = 0; i < 2; i++) { rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); - dev_dbg(&client->dev, - "Failed to set page %u, performed one-shot retry %s: %d\n", - page, rv ? "and failed" : "with success", rv); + + if (rv) + continue; + + rv = i2c_smbus_read_byte_data(client, PMBUS_PAGE); if (rv < 0) - return rv; + continue; + + /* Success, exit loop */ + if (rv == page) + break; + + rv = i2c_smbus_read_byte_data(client, PMBUS_STATUS_CML); + if (rv < 0) + continue; + + if (rv & PB_CML_FAULT_INVALID_DATA) + return -EIO; } - - rv = i2c_smbus_read_byte_data(client, PMBUS_PAGE); - if (rv < 0) - return rv; - - if (rv != page) + if (i == 2) return -EIO; } data->currpage = page;