From patchwork Thu Aug 17 09:25:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13356179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB89CC2FC1A for ; Thu, 17 Aug 2023 09:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349529AbjHQJZz (ORCPT ); Thu, 17 Aug 2023 05:25:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349559AbjHQJZg (ORCPT ); Thu, 17 Aug 2023 05:25:36 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F8152D4A for ; Thu, 17 Aug 2023 02:25:33 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fe4cdb72b9so68282875e9.0 for ; Thu, 17 Aug 2023 02:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1692264332; x=1692869132; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qDYTjOqD9a7nigPaAwe0v/hIS9KrkksYARbZO5uDh1M=; b=ghcI2ri+K53r4/l9Yj61XMf1NFBBWoQXz/nXujh3NrmNp3qqpegOPcDYRMQE9JdbJo GNJGQ3EQ0l68OxnVs4BxRPjomKLlnzZpQTy+2UgNVJj43K+Gir77jzVNM+rmlUrSkXBw pSA9hUhCHBZHt6K6KDWJRU6p6C84N5lyajDBUQl1vBnGtzakVccAkMQT/N8nJ2snS5YE jUGxCgL0s/Uv5iiGkvUkyTcAs0MOf8N5h1Sro4fGCSdw8EJZhCwT8GE5Od+wesMiU6AF 8Fg/TfgExbdUiSbv1dl5yc2FbbpQUtPnKfmfqH9d2Biv0EcqX2QfpeA4fqO+eAmeu1qT a3vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692264332; x=1692869132; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qDYTjOqD9a7nigPaAwe0v/hIS9KrkksYARbZO5uDh1M=; b=G5wHlP1FIJGVlLdy5OYxfrFFZM40VDQ3WL7W4SZ7XY5eEQpFW36e7qz7q6kfyvOyGx s5AqiTQCGN89iEYXRsvERiC/eF/ncOaavaBcSsof9Qaaewl7ymVDx4egdjC2utkOuU8l JSDljonFKly4Df3wEz/DwUH/1Iv/dYJAx/HQJ5OiOXRV0unjJ8QUE0U+UQKPh7UWj/bw 43ccZ//6BIIxgsCNWKZPvm0gd6zBE/yI48X334EJt5ZepFegQnm4I4HWIesq7qL1t3Z9 /OJ302ugBlKdQzEoscJD0qUPdJMfEImMsN18845g2NJhnkQC+XHlDJQspNvAQdwEMk9o x4bw== X-Gm-Message-State: AOJu0Yyl+IW0pJKV7wGmwq9ynWBxkGnatlWmxW1J4x6IKtSPakjVxLyi W33FeHJ4ysT1O/wrqlaBckHhRD4ZsTrboRFfB21ZLg== X-Google-Smtp-Source: AGHT+IFmFTcexEqwbWm8wdjByrW9Bzndus23V4XdfarvKrp8GuW1ZndlP+l/yUgoFoMPEpyHyhwMBQ== X-Received: by 2002:a7b:c307:0:b0:3f9:c0f2:e1a4 with SMTP id k7-20020a7bc307000000b003f9c0f2e1a4mr3437772wmj.34.1692264331852; Thu, 17 Aug 2023 02:25:31 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id x10-20020a05600c2a4a00b003fc00892c13sm2227934wme.35.2023.08.17.02.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 02:25:31 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: Guenter Roeck , Jean Delvare Cc: Patrick Rudolph , Naresh Solanki , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] hwmon: pmbus: Reduce clear fault page invocations Date: Thu, 17 Aug 2023 11:25:24 +0200 Message-ID: <20230817092527.808631-1-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Patrick Rudolph Observing I2C traffic revealed consecutive transmission of CLEAR_FAULT commands. While this doesn't cause issues, it extends driver probe time. Avoid invoking pmbus_clear_fault_page for virtual registers, as they're managed by the driver, not the chip. TEST: Verified using an I2C bus analyzer that only one CLEAR_FAULT command is send instead 5 in a row. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- drivers/hwmon/pmbus/pmbus_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) base-commit: fc8df28be7155ddcf8731b4c85fd3372811ba5ac diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 69a4e62b6c8d..cbfabdd69056 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -561,7 +561,8 @@ static bool pmbus_check_register(struct i2c_client *client, rv = pmbus_check_status_cml(client); if (rv < 0 && (data->flags & PMBUS_READ_STATUS_AFTER_FAILED_CHECK)) data->read_status(client, -1); - pmbus_clear_fault_page(client, -1); + if (reg < PMBUS_VIRT_BASE) + pmbus_clear_fault_page(client, -1); return rv >= 0; } From patchwork Thu Aug 17 09:25:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13356178 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B64E8C2FC14 for ; Thu, 17 Aug 2023 09:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349520AbjHQJZy (ORCPT ); Thu, 17 Aug 2023 05:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349562AbjHQJZg (ORCPT ); Thu, 17 Aug 2023 05:25:36 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6694F2D4F for ; Thu, 17 Aug 2023 02:25:34 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fe2048c910so69344645e9.1 for ; Thu, 17 Aug 2023 02:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1692264333; x=1692869133; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4RbSvzpoYud8FXP7GYgLwCUqHVr8YxqyCeoFfLHTQpA=; b=EBKIaD6uHatu3ECpuenVk+PU5q41V6meiTHO+mgqbRsrnABNvtfGilKX888J7xu1Yr a0XBGgyMSJMfTTOhTqKMc/omc46wfDEVjJNi/YHpikEj98gkqAw8VVcFGVaYZbLYYR9U 3GjH38q8/CRv2/sTerTCY7d8ljejaMbTrGxh1MemSSRnQSURQg049ZtXX9VeKaKghhlR GQZcn2NMFkjONuuFGJLnN4yQq5IaKPaX8+v4cbm3d2sytFNDOWsydXY+kM3l2B9GJrjV 33rwXNyEwyT01R2kxiu2n29dKsiwIcX2ixRKj1lPNE3N9QbvWHBAlDId6eIG+MqOJL8Y x7MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692264333; x=1692869133; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4RbSvzpoYud8FXP7GYgLwCUqHVr8YxqyCeoFfLHTQpA=; b=UAT6H3tU9NjtJZw18d+0c1Uo4mzmBlABMC24Gt1jtkAJQNoN0t5zmqbSAmso2mu135 EFNYsGlvTC4G7KTBru1S34gKfFAyb6rbe+bqLMgLIBiM3Y/SZlieklsCm6VIEVC/zyIz H7zauzVuQ4nj60mssx8i8rp7PVrP26Vpnrq8ft+v/Ylsyd+xQllCy7iwTzD/7eup2gsK zXIRtVvN9GODw72JFiTWfkKXXSe1JuFE2g7eZjtRYqZEXxUzmgM5yaqjF5T64+DlRVHB lDa7e+jfy9K0fIyKkhxbTshe6kiy52PvZrl52EqVMpb4xP9W/YnsYIuJ4oh/IlME11uQ tZ0g== X-Gm-Message-State: AOJu0YzCU/HKRF5iVUMW9FFcV5c2Kh617HdTQRiHfblsLtasOLIkAby9 CSuKDQJDL1fDHUfKr0qyPyiP3X/pcHHBvxV6Upn9pA== X-Google-Smtp-Source: AGHT+IGhyCxgx8JdXYe6FXcaqCt52k8fm6b5/iHkfpRZILf7HomCeA965oYnuSpKRjYR0eCUpoMv1Q== X-Received: by 2002:a1c:6a14:0:b0:3fc:27:7e46 with SMTP id f20-20020a1c6a14000000b003fc00277e46mr4682206wmc.3.1692264333007; Thu, 17 Aug 2023 02:25:33 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id x10-20020a05600c2a4a00b003fc00892c13sm2227934wme.35.2023.08.17.02.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 02:25:32 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: Guenter Roeck , Jean Delvare Cc: Patrick Rudolph , Naresh Solanki , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] hwmon: pmbus: Drop unnecessary clear fault page Date: Thu, 17 Aug 2023 11:25:25 +0200 Message-ID: <20230817092527.808631-2-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230817092527.808631-1-Naresh.Solanki@9elements.com> References: <20230817092527.808631-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Patrick Rudolph The pmbus_check_byte_register function already calls clear fault page, so there's no need to do it again in pmbus_identify_common. TEST: Verified using an I2C bus analyser to confirm that only one clear fault page is being send instead of two in a row. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- drivers/hwmon/pmbus/pmbus_core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index cbfabdd69056..1363d9f89181 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2541,7 +2541,6 @@ static int pmbus_identify_common(struct i2c_client *client, } } - pmbus_clear_fault_page(client, page); return 0; } From patchwork Thu Aug 17 09:25:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13356177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BF7DC41513 for ; Thu, 17 Aug 2023 09:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349527AbjHQJZy (ORCPT ); Thu, 17 Aug 2023 05:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349566AbjHQJZh (ORCPT ); Thu, 17 Aug 2023 05:25:37 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC3AF2D63 for ; Thu, 17 Aug 2023 02:25:35 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fe45481edfso75956395e9.1 for ; Thu, 17 Aug 2023 02:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1692264334; x=1692869134; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X3jIyUrd5GzfmWvpSZW4U6VKePA4YO/cn1PhySd1hkU=; b=diCldWqXec2nuRPwhbv8dnOOSVxtSlg1mqcdOIQtloIOxaXTZTDs7QzWXrxm3ahT/J EwbXFkKoREOC9iYAj7p1HumhRuByqiIx++aY0vqwOOLpMUnregLOdlUbm/wb+X9iZgkb Ae2czXdYfpHz2lsTUe7SK7LLElOTK/A+LmjzIOyeONYIaNelle11qLLgw2tR8yTkCZAV pMFKUnkMo7Q2VwpvlVTM0JR12bIZx1AbHKTNXNPrURP4XpZoxmowiKX1yym/72vksaDh V/Uu6dVMTXeWOUc9kUwK7EDoI828pzRb3M4ozw0f2+bI0VkDSe1Wl0ZSmUG9vbpONYz5 tkyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692264334; x=1692869134; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X3jIyUrd5GzfmWvpSZW4U6VKePA4YO/cn1PhySd1hkU=; b=KgXf0u4pzqJVtXs+2GmyJ+o9AeEp9SDfikYETyPPOaGeCNM5zjYOIxu9eiZjMlKbGi EJoLTDe87lgv5JfRE2aJa5Uh4BhlCbapCaq+zalNvhjfSZiPI6jpNGb/8rjMwfzxZgg7 Qj6AptLNQz+Tmkty0CvRmlJhpypC1Vg/eVeWuuJx3DKgIuAOLLt+3hVco084ZAmchOM7 0gqPGGeIE5Uc463huJIOAw0t1gZ5/LKu6OvSSwYYR+XSH3Gxvv1VmOvyi8nP+QL86wOQ Y6m3Wqw2t/+yylMaj49Heeh8M+1BekcfBjT/VGwMmN3ieFgF3jrkYayxacs2Qf9HvuD0 Z+RQ== X-Gm-Message-State: AOJu0Yw6L5/KEXf8ohw/YawpmSbl/698vk9QWxcatOwIY/DsZXnfeW3y jfehRJhdcXCJtfWdF5BJyNNLXQ== X-Google-Smtp-Source: AGHT+IFq50pyoIZbPhhzBj0EePyDPVFwUgBYXowAlhP/0dG8YPEoXUU9dCUuA2LlPbazK2I1HTwJoQ== X-Received: by 2002:a1c:750a:0:b0:3fd:2d35:b96a with SMTP id o10-20020a1c750a000000b003fd2d35b96amr3489743wmc.39.1692264334303; Thu, 17 Aug 2023 02:25:34 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id x10-20020a05600c2a4a00b003fc00892c13sm2227934wme.35.2023.08.17.02.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 02:25:33 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: Guenter Roeck , Jean Delvare Cc: Patrick Rudolph , Naresh Solanki , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] hwmon: pmbus: Fix -EIO seen on pli1209 Date: Thu, 17 Aug 2023 11:25:26 +0200 Message-ID: <20230817092527.808631-3-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230817092527.808631-1-Naresh.Solanki@9elements.com> References: <20230817092527.808631-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Patrick Rudolph After doing performance optimizations the pli1209 driver failed to probe with a probabilty of 2%. It wasn't able to read the PMBUS_OPERATION register due to an -EIO error. An investigation showed that the PLI1209 takes 230 usec to execute the CLEAR_FAULTS command. During that time it's busy and NACKs all requests on the SMBUS interface. It also NACKs reads on PMBUS_STATUS_BYTE making it impossible to poll the BUSY flag. Add a custom write_data function to just wait for not BUSY unconditionally after sending a CLEAR_FAULTS command. TEST: Verified using an I2C bus analyser that no more NACKs are seen after sending a CLEAR_FAULTS command. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- drivers/hwmon/pmbus/pli1209bc.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/hwmon/pmbus/pli1209bc.c b/drivers/hwmon/pmbus/pli1209bc.c index 7d8bd3167b21..c95433790b11 100644 --- a/drivers/hwmon/pmbus/pli1209bc.c +++ b/drivers/hwmon/pmbus/pli1209bc.c @@ -5,6 +5,7 @@ * Copyright (c) 2022 9elements GmbH */ +#include #include #include #include @@ -53,6 +54,30 @@ static int pli1209bc_read_word_data(struct i2c_client *client, int page, } } +static int pli1209bc_write_byte(struct i2c_client *client, int page, u8 reg) +{ + int ret; + + switch (reg) { + case PMBUS_CLEAR_FAULTS: + ret = pmbus_write_byte(client, page, reg); + /* + * PLI1209 takes 230 usec to execute the CLEAR_FAULTS command. + * During that time it's busy and NACKs all requests on the + * SMBUS interface. It also NACKs reads on PMBUS_STATUS_BYTE + * making it impossible to poll the BUSY flag. + * + * Just wait for not BUSY unconditionally. + */ + usleep_range(250, 300); + break; + default: + ret = -ENODATA; + break; + } + return ret; +} + #if IS_ENABLED(CONFIG_SENSORS_PLI1209BC_REGULATOR) static const struct regulator_desc pli1209bc_reg_desc = { .name = "vout2", @@ -102,6 +127,7 @@ static struct pmbus_driver_info pli1209bc_info = { | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT, .read_word_data = pli1209bc_read_word_data, + .write_byte = pli1209bc_write_byte, #if IS_ENABLED(CONFIG_SENSORS_PLI1209BC_REGULATOR) .num_regulators = 1, .reg_desc = &pli1209bc_reg_desc,