Netdev List
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Vadim Pasternak <vadimp@mellanox.com>,
	Andrew Lunn <andrew@lunn.ch>, Ido Schimmel <idosch@mellanox.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	Jiri Pirko <jiri@mellanox.com>, mlxsw <mlxsw@mellanox.com>
Subject: Re: [PATCH net-next 09/12] mlxsw: core: Extend hwmon interface with fan fault attribute
Date: Thu, 14 Feb 2019 06:29:03 -0800	[thread overview]
Message-ID: <add494aa-1963-7258-58af-61d6085a88f8@roeck-us.net> (raw)
In-Reply-To: <AM6PR05MB5224D8338CD23225746CBA72A2670@AM6PR05MB5224.eurprd05.prod.outlook.com>

On 2/13/19 11:06 PM, Vadim Pasternak wrote:
> 
> 
>> -----Original Message-----
>> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
>> Sent: Wednesday, February 13, 2019 5:03 PM
>> To: Andrew Lunn <andrew@lunn.ch>; Ido Schimmel <idosch@mellanox.com>
>> Cc: netdev@vger.kernel.org; davem@davemloft.net; Jiri Pirko
>> <jiri@mellanox.com>; mlxsw <mlxsw@mellanox.com>; Vadim Pasternak
>> <vadimp@mellanox.com>
>> Subject: Re: [PATCH net-next 09/12] mlxsw: core: Extend hwmon interface with
>> fan fault attribute
>>
>> On 2/13/19 5:53 AM, Andrew Lunn wrote:
>>> On Wed, Feb 13, 2019 at 11:28:53AM +0000, Ido Schimmel wrote:
>>>> From: Vadim Pasternak <vadimp@mellanox.com>
>>>>
>>>> Add new fan hwmon attribute for exposing fan faults (fault indication
>>>> is read from Fan Out of Range Event Register).
>>>>
>>>> Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
>>>> Reviewed-by: Jiri Pirko <jiri@mellanox.com>
>>>> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
>>>
>>> Hi Ido
>>>
>>> You should include the HWMON maintainer in the Cc: list.
>>>
>>> I would not be too surprised if he says to use
>>> hwmon_device_register_with_info().
>>>
>>
>> I would ask to do that for new drivers, but this is is not a new driver.
>> On top of that, I wasn't included in its initial review. Since I wasn't involved, I
>> have no idea what shape the driver is in, and for sure won't review it now (to
>> retain my sanity).
>>
>> Only comment I have is that using the _with_info API and using devm_ functions
>> might simplify the driver a lot. I'll be happy to do a review if/when that is done.
>>
>> Guenter
> 
> Hi Guenter,
> 
> Thank you for your comments.
> 
> But, this patch adds one new FAN attribute to the existing infrastructure.
> At the time mlxsw core_hwmon module has been submitted, the API
> hwmon_device_register_with_info() was not available yet.
> Of course in a new modules we are using this API, like in
> our mlxreg-fan for example.
> 
> The same is relevant for the patch 10/12 from this series – it also extends
> the existing infrastructure.
> But there, even in case of a new code the config structure for
> hwmon_device_register_with_info()  would be look like:
> {
> 	/* 3 entries like below - for chip ambient temperatures (could be from 1 to 3. */
> 	HWMON_F_INPUT | HWMON_T_HIGHEST | HWMON_T_RESET_HISTORY,
> 	...
> 	/* 128 entries like below - for modules temperatures (could be from 16 to 128. */
> 	HWMON_F_INPUT | HWMON_T_CRIT | HWMON_T_EMERGENCY, HWMON_T_FAULT | HWMON_T_LABEL,
> 	...
> 	/* 64 entries like below - for interconnects temperatures (could be from 0 to 64). */
> 	HWMON_F_INPUT | HWMON_T_HIGHEST | HWMON_T_RESET_HISTORY | HWMON_T_LABEL,
> 	0
> };
> 
I would probably have created the above dynamically, just like the current code does,
except it now generates all the attributes. AFAICS the current code doesn't leave holes
in attribute numbering, so allocating everything statically doesn't really make much
sense. Note that you would need separate arrays, one per sensor type (temperature, fan,
pwm).

> Means we'll have 195 lines for configuration description and in case future systems will
> be equipped with the bigger number of port slots and/or with the bigger number of
> interconnects devices, the below structure will require modification.
> Modification will be not necessary, in case we'll keep configuration like it is now.
> 
> Regarding devm_ API - it has been used initially in core_hwmon module, but the in
> commit (9b3bc7db759e) it has been removed. And it was a good reason for that.
> Chip can be re-programmed after initialization in case driver determines it needs to
> flash a new firmware version. In such case after re-programming driver will make
> registration again and among the other stuff it will make new registration with
> hwmon subsystem. And in case it 's registered with
> hwmon subsystem using devm_hwmon_device_register_with_groups(), the old
> hwmon device (registered before the flashing) was never unregistered and was
> referencing stale data, resulting in a use-after free.
> 
Well, devm_ obviously doesn't work if the object lifetime doesn't match device
lifetime.

Guenter

  reply	other threads:[~2019-02-14 14:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13 11:28 [PATCH net-next 00/12] mlxsw: hwmon and thermal extensions Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 01/12] mlxsw: spectrum: Move QSFP EEPROM definitions to common location Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 02/12] mlxsw: reg: Add Management Temperature Bulk Register Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 03/12] mlxsw: reg: Add Fan Out of Range Event Register Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 04/12] mlxsw: core: Add API for QSFP module temperature thresholds reading Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 05/12] mlxsw: core: Set different thermal polling time based on bus frequency capability Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 06/12] mlxsw: core: Modify thermal zone definition Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 07/12] mlxsw: core: Replace thermal temperature trips with defines Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 08/12] mlxsw: core: Rename cooling device Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 09/12] mlxsw: core: Extend hwmon interface with fan fault attribute Ido Schimmel
2019-02-13 13:53   ` Andrew Lunn
2019-02-13 15:02     ` Guenter Roeck
2019-02-14  7:06       ` Vadim Pasternak
2019-02-14 14:29         ` Guenter Roeck [this message]
2019-02-13 11:28 ` [PATCH net-next 10/12] mlxsw: core: Extend hwmon interface with QSFP module temperature attributes Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 11/12] mlxsw: core: Add QSFP module temperature label attribute to hwmon Ido Schimmel
2019-02-13 11:28 ` [PATCH net-next 12/12] mlxsw: core: Allow thermal zone binding to an external cooling device Ido Schimmel
2019-02-14  6:33 ` [PATCH net-next 00/12] mlxsw: hwmon and thermal extensions David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=add494aa-1963-7258-58af-61d6085a88f8@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=vadimp@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox