linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Question about windfarm drivers
@ 2009-04-16  8:52 Jean Delvare
  2009-04-17  7:28 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 2+ messages in thread
From: Jean Delvare @ 2009-04-16  8:52 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras; +Cc: linuxppc-dev

Hi Ben, hi Paul,

As I am converting the windfarm drivers to the new i2c device binding
model, I need to understand how these drivers work currently. There's
one thing I do not understand so I'd appreciate if you could explain it
to me.

I am looking at function wf_lm75_detach() in windfarm_lm75_sensor.c.
This function is called by i2c-core if either i2c-powermac or
windfarm_lm75_sensor is unloaded. It sets lm->i2c.adapter to NULL and
then calls wf_unregister_sensor(), which in turn calls wf_put_sensor(),
which calls wf_sensor_release() is the reference count drops to 0,
which in turns call the driver's .release() method, that is,
wf_lm75_release() in our case.

In wf_lm75_release(), i2c_detach_client() is called if and only if
lm->i2c.adapter is set, which is not the case, and then the data
structure, including the i2c client, is freed from memory. This means
that the freed i2c client is still registered with i2c-core, this looks
wrong.

Am I missing something? Or is this clean-up path broken and nobody ever
noticed?

I am also curious why wf_unregister_sensor() calls wf_put_sensor()
while wf_register_sensor() doesn't call wf_get_sensor().

Thanks,
-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question about windfarm drivers
  2009-04-16  8:52 Question about windfarm drivers Jean Delvare
@ 2009-04-17  7:28 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2009-04-17  7:28 UTC (permalink / raw)
  To: Jean Delvare; +Cc: linuxppc-dev, Paul Mackerras

On Thu, 2009-04-16 at 10:52 +0200, Jean Delvare wrote:

> In wf_lm75_release(), i2c_detach_client() is called if and only if
> lm->i2c.adapter is set, which is not the case, and then the data
> structure, including the i2c client, is freed from memory. This means
> that the freed i2c client is still registered with i2c-core, this looks
> wrong.
> 
> Am I missing something? Or is this clean-up path broken and nobody ever
> noticed?

Probably the later :-)

> I am also curious why wf_unregister_sensor() calls wf_put_sensor()
> while wf_register_sensor() doesn't call wf_get_sensor().

It's quite possible that those code path are a bit buggy and not well
exercised. I don't think people ever unload those modules and we tend to
have that stuff built-in ourselves.

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-17  7:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-16  8:52 Question about windfarm drivers Jean Delvare
2009-04-17  7:28 ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).