All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Garrett <mjg59@srcf.ucam.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] hwmon API update
Date: Mon, 14 Feb 2011 16:23:38 +0000	[thread overview]
Message-ID: <20110214162338.GA10527@srcf.ucam.org> (raw)
In-Reply-To: <4D57CC24.1040306@free.fr>

On Sun, Feb 13, 2011 at 11:08:33PM +0100, Jean Delvare wrote:
> On Sun, 13 Feb 2011 09:16:40 -0800, Guenter Roeck wrote:
> > On Sun, Feb 13, 2011 at 07:18:44AM -0500, Martin Peres wrote:
> > > Hi,
> > > 
> > > I am working on power management on the nouveau driver and I need a way 
> > > to get data out of and send commands to the i2c drivers from the kernel 
> > > space.
> 
> Why? You already have a way to get data out of and send commands to the
> I2C devices themselves (Using the i2c_smbus_* functions). Why do you
> insist on going through the I2C device drivers?

Because implementing support for every sensor chip when there's already 
code in the kernel to deal with them isn't the usual way of handling 
problems.

> > > We can already change the clocks of the card, but we need a way to 
> 
> How is this relevant to the discussion? Are the clock chips connected
> to the I2C bus too?

It's all part of the power management setup.

> > > monitor the temperature and bump the fan speed if needed.
> 
> Hardware is very badly designed if the driver actually has to take care
> of this. Thermal management should be handled by the hardware directly.
> And as a matter of fact, the Analog Devices ADT7473 and the Fintek
> F75375S support this.

It's often the case that fan control on these cards is handled by an 
external hwmon chip, while the thermal diode is integrated into the chip 
core and therefore only readable by the PCI driver. In that case we need 
to be able to access the fan control registers. In other cases, cooling 
is implemented passively by reducing the clock on the card. In those 
cases the PCI driver needs to be able to obtain the temperature from 
off-card chips. Whether you think the hardware approach sucks or not, 
the reality is that we have plenty of devices where maanging the thermal 
state of the hardware requires a single driver to be able to access both 
PCI and i2c devices.

> > > 2.6.38-rc4. This patch only provides the API, no modification to the 
> > > drivers has been completed yet.
> 
> Do you mean that you don't have the code at all yet, or that you did
> not include it in this patch set? Either way, this is wrong. There is
> no point in asking for a review of only half of your solution. We can't
> comment on the relevance of your proposal without seeing how you intend
> to use it.

There's no point in adapting drivers if the API is unacceptable to the 
upstream maintainers. We need a mechanism for in-kernel drivers to read 
and write from hwmon devices. What should the interface to do so look 
like? This is one proposal which would satisfy the current consumers and 
could potentially be used for other devices as well.

> I have no plan to review your patch, sorry. You did not provide a
> proper description of your problem, and you didn't explain why it can't
> be solved with the current kernel infrastructures. Worse, you propose a
> brand new hwmon subsystem, but you don't even provide a description of
> its design, let alone an explanation of why you think this design is
> appropriate. And you don't show us code using it either.

I hope I've provided a bit more context, but to summarise:

Power and thermal management of GPUs requires that the GPU driver be 
able to obtain the GPU temperature and control the GPU fan. On many 
shipping devices, doing so requires the ability for the GPU driver to 
obtain values from devices attached via i2c. The kernel already has 
drivers for these devices and so it makes sense to use them rather than 
duplicating them. Adding a generic hwmon interface for in-kernel use 
would allow these drivers to be used for this purpose.

> All I can say after a quick look at the patch, is that you are
> overengineering a lot. You have enumerated all sensor properties which
> exist, and are trying to handle all sensor types. You have a specific
> need (thermal management of graphics cards), but you are already trying
> to provide a generic access to all hwmon attributes which exist,
> regardless of the needs or relevance. Do you really think you'll need
> information about the case intrusion status in nouveau? Seriously?

If we're adding an in-kernel API then it makes sense for it to be 
generic enoguh that anyone could use it, but there's no real problem in 
just cutting out any functions that wouldn't be used by anyone as yet.

> > This is an extremely complex change just for the benefit of one driver,
> > with a huge potential of misuse. The changes required in each driver
> > to actually implement the API are substantial, and pretty much only add
> > complexity to each hwmon driver with no real benefit.
> 
> I would be very curious to know how comes that the radeon driver
> apparently works just fine without this change, if the nouveau driver
> can't do without it.

It doesn't. Right now the fan control is left up to the card firmware, 
which means that it runs far faster than necessary and also means that 
the card can't drop clock rates in response to reaching temperature 
limits. Radeon will benefit from this just as much as nouveau.

> My main concern is that the code you will have to add to every new
> hwmon driver you will want nouveau to be able to use, is likely to be
> larger than the code needed to access the device registers directly
> from nouveau. Getting a temperature value from a hwmon device is
> typically done with a single call to i2c_smbus_read_byte_data().

Duplicating the functionality directly in novueau (and again in radeon) 
just means that every time we find a bug in an hwmon driver we have to 
fix it in three places. Upstream is typically resistant to this kind of 
thing.

> > The cost gets even larger if one has to consider that some may want or
> > have to to backport drivers to earlier kernel versions. This patchset
> > would result in significant efforts to do such backports.
> 
> This will never be a good reason to reject a change, sorry. Just look
> at the many changes the i2c subsystem went through in the past 2 years.
> They make it difficult to backport i2c device drivers to older kernels,
> but they still happened, because they were needed. When backporting a
> driver, you have to deal with the history of the kernel at large,
> that's life.

(agree)

> > For the API itself, there are lots of functions with similar parameters, 
> > and those parameters are needed in the drivers to determine which attribute
> > is affected. A single function would have accomplished the same, as the drivers
> > will need case statements anyway to identify the actual attribute to be read
> > or written. What we end up here with is a large number of functions to be
> > supported by each driver, all with pretty much the same set of arguments.
> 
> This is the kind of thing which would show up immediately if we could
> see a few actual implementations of the hwmon driver side of the API.
> In general, I would tend to agree with Guenter that exporting a dozen
> functions from the hwmon core driver seems just wrong, especially given
> the specific problem you claim you are trying to solve.

Replacing it with a read/set function with a type enum as the first 
argument would work as well. Would that be more reasonable?

-- 
Matthew Garrett | mjg59@srcf.ucam.org

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2011-02-14 16:23 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-13 12:18 hwmon API update Martin Peres
2011-02-13 12:18 ` [lm-sensors] " Martin Peres
2011-02-13 17:16 ` Guenter Roeck
2011-02-13 17:16   ` [lm-sensors] " Guenter Roeck
2011-02-13 20:00   ` Martin Peres
2011-02-13 20:00     ` [lm-sensors] " Martin Peres
2011-02-13 22:08   ` Jean Delvare
2011-02-13 22:08     ` [lm-sensors] " Jean Delvare
     [not found]     ` <20110213230833.0ee2ff16-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-03-03  9:36       ` Dave Airlie
2011-03-03  9:36         ` [lm-sensors] [Nouveau] " Dave Airlie
     [not found]         ` <AANLkTindG=m4FhNS202MH8YVBUCoDEADTQLxo-Bf_8qx-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-03-03 13:09           ` [lm-sensors] " Martin Peres
2011-03-03 13:09             ` [lm-sensors] [Nouveau] " Martin Peres
2011-03-03 15:22         ` Guenter Roeck
2011-03-03 15:22           ` [lm-sensors] " Guenter Roeck
     [not found]           ` <20110303152216.GA21667-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
2011-03-03 17:29             ` [lm-sensors] " Martin Peres
2011-03-03 17:29               ` [lm-sensors] [Nouveau] " Martin Peres
     [not found]               ` <4D6FCFF2.7040604-GANU6spQydw@public.gmane.org>
2011-03-03 20:48                 ` [lm-sensors] " Lucas Stach
2011-03-03 20:48                   ` [lm-sensors] [Nouveau] " Lucas Stach
2011-03-03 21:19                   ` Guenter Roeck
2011-03-03 21:19                     ` [lm-sensors] " Guenter Roeck
2011-03-03 21:56                     ` [lm-sensors] " Lucas Stach
2011-03-03 21:56                       ` [lm-sensors] [Nouveau] " Lucas Stach
2011-03-03 22:03                       ` [lm-sensors] " Guenter Roeck
2011-03-03 22:03                         ` [lm-sensors] [Nouveau] " Guenter Roeck
2011-03-03 23:53                         ` [lm-sensors] " Martin Peres
2011-03-03 23:53                           ` [lm-sensors] [Nouveau] " Martin Peres
     [not found]                           ` <4D7029E8.4040706-GANU6spQydw@public.gmane.org>
2011-03-04  0:59                             ` [lm-sensors] " Guenter Roeck
2011-03-04  0:59                               ` [lm-sensors] [Nouveau] " Guenter Roeck
     [not found]                               ` <20110304005900.GB31318-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
2011-03-04  8:36                                 ` [lm-sensors] " Martin Peres
2011-03-04  8:36                                   ` [lm-sensors] [Nouveau] " Martin Peres
2011-02-14 16:23 ` Matthew Garrett [this message]
2011-02-14 18:19 ` [lm-sensors] " Guenter Roeck
2011-02-14 18:22 ` Matthew Garrett
2011-02-14 19:01 ` Guenter Roeck
2011-02-14 19:05 ` Matthew Garrett
2011-02-14 19:33 ` Guenter Roeck
2011-02-14 19:40 ` Matthew Garrett
2011-02-14 21:25 ` Guenter Roeck
2011-02-14 21:29 ` Matthew Garrett
2011-02-15 21:50 ` Jean Delvare
2011-02-15 22:07 ` Jean Delvare
2011-02-15 22:23 ` Guenter Roeck
2011-02-28 17:50 ` Lucas Stach
2011-02-28 18:42 ` Guenter Roeck
2011-02-28 23:24 ` Lucas Stach
2011-10-10 22:29 ` Kristen Eisenberg

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=20110214162338.GA10527@srcf.ucam.org \
    --to=mjg59@srcf.ucam.org \
    --cc=lm-sensors@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.