Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6275C28CC5 for ; Wed, 5 Jun 2019 19:22:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95481206BB for ; Wed, 5 Jun 2019 19:22:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726280AbfFETWn (ORCPT ); Wed, 5 Jun 2019 15:22:43 -0400 Received: from sed198n136.SEDSystems.ca ([198.169.180.136]:45636 "EHLO sed198n136.sedsystems.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725950AbfFETWm (ORCPT ); Wed, 5 Jun 2019 15:22:42 -0400 Received: from barney.sedsystems.ca (barney [198.169.180.121]) by sed198n136.sedsystems.ca with ESMTP id x55JMLKh017701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 5 Jun 2019 13:22:21 -0600 (CST) Received: from eng1n65.eng.sedsystems.ca (eng1n65.eng.sedsystems.ca [172.21.1.65]) by barney.sedsystems.ca (8.14.7/8.14.4) with ESMTP id x55JMLcI023915 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Wed, 5 Jun 2019 13:22:21 -0600 Subject: Re: [PATCH 1/3] hwmon: (pmbus) Add paged support for VIN, IIN, PIN parameters To: Guenter Roeck Cc: linux-hwmon@vger.kernel.org, jdelvare@suse.com References: <1559751434-19879-1-git-send-email-hancock@sedsystems.ca> <1559751434-19879-2-git-send-email-hancock@sedsystems.ca> <20190605164852.GB32657@roeck-us.net> <20190605182700.GA15733@roeck-us.net> From: Robert Hancock Openpgp: preference=signencrypt Autocrypt: addr=hancock@sedsystems.ca; prefer-encrypt=mutual; keydata= mQINBFfazlkBEADG7wwkexPSLcsG1Rr+tRaqlrITNQiwdXTZG0elskoQeqS0FyOR4BrKTU8c FAX1R512lhHgEZHV02l0uIWRTFBshg/8EK4qwQiS2L7Bp84H1g5c/I8fsT7c5UKBBXgZ0jAL ls4MJiSTubo4dSG+QcjFzNDj6pTqzschZeDZvmCWyC6O1mQ+ySrGj+Fty5dE7YXpHEtrOVkq Y0v3jRm51+7Sufhp7x0rLF7X/OFWcGhPzru3oWxPa4B1QmAWvEMGJRTxdSw4WvUbftJDiz2E VV+1ACsG23c4vlER1muLhvEmx7z3s82lXRaVkEyTXKb8X45tf0NUA9sypDhJ3XU2wmri+4JS JiGVGHCvrPYjjEajlhTAF2yLkWhlxCInLRVgxKBQfTV6WtBuKV/Fxua5DMuS7qUTchz7grJH PQmyylLs44YMH21cG6aujI2FwI90lMdZ6fPYZaaL4X8ZTbY9x53zoMTxS/uI3fUoE0aDW5hU vfzzgSB+JloaRhVtQNTG4BjzNEz9zK6lmrV4o9NdYLSlGScs4AtiKBxQMjIHntArHlArExNr so3c8er4mixubxrIg252dskjtPLNO1/QmdNTvhpGugoE6J4+pVo+fdvu7vwQGMBSwQapzieT mVxuyGKiWOA6hllr5mheej8D1tWzEfsFMkZR2ElkhwlRcEX0ewARAQABtCZSb2JlcnQgSGFu Y29jayA8aGFuY29ja0BzZWRzeXN0ZW1zLmNhPokCNwQTAQIAIQIbAwIeAQIXgAUCV9rOwQUL CQgHAwUVCgkICwUWAgMBAAAKCRCAQSxR8cmd98VTEADFuaeLonfIJiSBY4JQmicwe+O83FSm s72W0tE7k3xIFd7M6NphdbqbPSjXEX6mMjRwzBplTeBvFKu2OJWFOWCETSuQbbnpZwXFAxNJ wTKdoUdNY2fvX33iB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gHFe1DGCayFf8xrFVSPzaxk6CY9f2CuxsZokc7CDAvZrfOqQt8Z4SofSC8z KnJ1I1hBnlcoHDKMi3KabDBi1dHzKm9ifNBkGNP8ux5yAjL/Z6C1yJ+Q28hNiAddX7dArOKd h1L4/QwjER2g3muK6IKfoP7PRjL5S9dbH0q+sbzOJvUQq0HO6apmu78AEQEAAYkCHwQYAQIA CQUCV9rOWQIbDAAKCRCAQSxR8cmd90K9D/4tV1ChjDXWT9XRTqvfNauz7KfsmOFpyN5LtyLH JqtiJeBfIDALF8Wz/xCyJRmYFegRLT6DB6j4BUwAUSTFAqYN+ohFEg8+BdUZbe2LCpV//iym cQW29De9wWpzPyQvM9iEvCG4tc/pnRubk7cal/f3T3oH2RTrpwDdpdi4QACWxqsVeEnd02hf ji6tKFBWVU4k5TQ9I0OFzrkEegQFUE91aY/5AVk5yV8xECzUdjvij2HKdcARbaFfhziwpvL6 uy1RdP+LGeq+lUbkMdQXVf0QArnlHkLVK+j1wPYyjWfk9YGLuznvw8VqHhjA7G7rrgOtAmTS h5V9JDZ9nRbLcak7cndceDAFHwWiwGy9s40cW1DgTWJdxUGAMlHT0/HLGVWmmDCqJFPmJepU brjY1ozW5o1NzTvT7mlVtSyct+2h3hfHH6rhEMcSEm9fhe/+g4GBeHwwlpMtdXLNgKARZmZF W3s/L229E/ooP/4TtgAS6eeA/HU1U9DidN5SlON3E/TTJ0YKnKm3CNddQLYm6gUXMagytE+O oUTM4rxZQ3xuR595XxhIBUW/YzP/yQsL7+67nTDiHq+toRl20ATEtOZQzYLG0/I9TbodwVCu Tf86Ob96JU8nptd2WMUtzV+L+zKnd/MIeaDzISB1xr1TlKjMAc6dj2WvBfHDkqL9tpwGvQ== Organization: SED Systems Message-ID: <612d2dad-59db-0a11-a393-1f3edad772bb@sedsystems.ca> Date: Wed, 5 Jun 2019 13:22:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190605182700.GA15733@roeck-us.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.64 on 198.169.180.136 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org On 2019-06-05 12:27 p.m., Guenter Roeck wrote: >>> To reduce risk due to potentially mis-detecting support on other chips, >>> it may be better to add a separate backend driver for this chip. This >>> would also enable support for the MFR_VOUT_PEAK, MFR_IOUT_PEAK, and >>> MFR_TEMPERATURE_PEAK registers which is otherwise unavailable. >> >> To clarify, you're saying instead of having the auto-detection for those >> in the generic pmbus driver, create a separate irps5401 driver that >> would explicitly add in those parameters? >> > Yes. OK, I can do that. We initially had a separate driver file for this, but ended up changing it to update the generic detection instead. But the separate driver file is likely safer. > >> This particular patch to pmbus_core.c would still be required in order >> for the paged parameters to be displayed properly - it shouldn't break >> anything on chips that don't detect these parameters on multiple pages. >> > > It should still work, though, except that there would be duplicate labels. I don't think it actually does work, at least not in the sensors utility - I haven't diagnosed where it was going wrong, but either not all of the attributes are successfully added at the kernel level, or libsensors filters out the "duplicate" entries and you only see one of them in the output. Actually, it appears there are already drivers in tree that have multiple pages with VIN, PIN and/or IIN values, such as ir35521, which would already have this problem. > > On the downside, with this change, the "vin" etc. label would be "vin1" > for all chips, not just this one. That may break compatibility if there > are users out there looking for specific labels. We may need a better > and more flexible solution to address this problem. For example, the core > could not only look for ".paged", but check if the respective attributes are > present in more than one page, and if so override the "paged" flag. > Something like the following (untested). I think that may be the best solution - though as I mentioned, there are already some drivers whose behavior would be changed by this in that they would end up with vin1 and vin2 instead of vin, etc. In those cases, however, there might be no real alternative - it's not even clear that the current behavior the user would get in that case would even be consistent in terms of which parameter would actually be shown, depending on how that is handled in libsensors. > > static bool pmbus_sensor_is_paged(const struct pmbus_driver_info *info, > const struct pmbus_sensor_attr *attr) > { > int p; > > if (attr->paged) > return true; > > for (p = 1; p < info->pages; p++) { > if (info->func[p] & attr->func) > return true; > } > return false; > } > > ... > > static int pmbus_add_sensor_attrs(...) > { > ... > > bool paged = pmbus_sensor_is_paged(info, attrs); > > pages = paged ? info->pages : 1; > ... > ret = pmbus_add_sensor_attrs_one(client, data, info, name, index, page, attrs, paged) > ^^^ > new parameter > } > > Guenter -- Robert Hancock Senior Software Developer SED Systems, a division of Calian Ltd. Email: hancock@sedsystems.ca