From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, linux-mips@linux-mips.org,
Jean Delvare <jdelvare@suse.de>,
Julia Lawall <julia.lawall@lip6.fr>,
Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Subject: Re: [PATCH] i2c: drop ancient protection against sysfs refcounting issues
Date: Tue, 20 Jan 2015 03:01:42 +0800 [thread overview]
Message-ID: <20150119190142.GA9451@kroah.com> (raw)
In-Reply-To: <1421693756-12917-1-git-send-email-wsa@the-dreams.de>
On Mon, Jan 19, 2015 at 07:55:56PM +0100, Wolfram Sang wrote:
> Back in the days, sysfs seemed to have refcounting issues and subsystems
> needed a completion to be safe. This is not the case anymore, so I2C can
> get rid of this code. There is noone else besides I2C doing something
> like this currently (checked with the attached coccinelle script which
> checks if a release function exists and if it contains a completion).
>
> I have been digging through the history of linux.git and
> linux-history.git and found that e.g. w1 used to have such a mechanism
> and also simply removed it later.
>
> Some more info from Greg Kroah-Hartman:
> "Having that call "wait" for the other release call to happen is really
> old, as Jean points out, from 2003. We have "fixed" sysfs since then to
> detach the files from the devices easier, we used to have some nasy
> reference count issues in that area."
>
> And some testing from Jean Delvare which matches my results:
> "However I just tested unloading an i2c bus driver while its adapter's
> new_device attribute was opened and rmmod returned immediately. So it
> doesn't look like accessing sysfs attributes actually takes a reference
> to the underlying i2c_adapter."
>
> Let's get rid of this code before really nobody knows/understands
> anymore what this was for and if it has a subtle use.
>
> Reported-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> ---
>
> Of course, more testing is appreciated. Here is the coccinelle script:
>
> ===
>
> @has_type@
> identifier d_type, rel_f;
> @@
>
> struct device_type d_type = {
> .release = rel_f,
> };
>
> @has_device@
> struct device *d;
> identifier rel_f, p;
> @@
>
> (
> p->dev.release = &rel_f;
> |
> d->release = &rel_f;
> )
>
> @find_type depends on has_type@
> identifier has_type.rel_f, d;
> @@
>
> void rel_f(struct device *d)
> {
> ...
> * complete(...);
> ...
> }
>
> @find_device depends on has_device@
> identifier has_device.rel_f, d;
> @@
>
> void rel_f(struct device *d)
> {
> ...
> * complete(...);
> ...
> }
>
> ===
>
> drivers/i2c/i2c-core.c | 10 +---------
> include/linux/i2c.h | 1 -
> 2 files changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 39d25a8cb1ad..15cc5902cf89 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -41,7 +41,6 @@
> #include <linux/of_device.h>
> #include <linux/of_irq.h>
> #include <linux/clk/clk-conf.h>
> -#include <linux/completion.h>
> #include <linux/hardirq.h>
> #include <linux/irqflags.h>
> #include <linux/rwsem.h>
> @@ -1184,8 +1183,7 @@ EXPORT_SYMBOL_GPL(i2c_new_dummy);
>
> static void i2c_adapter_dev_release(struct device *dev)
> {
> - struct i2c_adapter *adap = to_i2c_adapter(dev);
> - complete(&adap->dev_released);
> + /* empty, but the driver core insists we need a release function */
Yeah, it does, but I hate to see this in "real" code as something is
probably wrong with it if it happens.
Please move the rest of 'i2c_del_adapter' into the release function
(what was after the wait_for_completion() call), and then all should be
fine.
thanks,
greg k-h
WARNING: multiple messages have this Message-ID (diff)
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-mips@linux-mips.org,
Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
linux-kernel@vger.kernel.org, Julia Lawall <julia.lawall@lip6.fr>,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, Jean Delvare <jdelvare@suse.de>
Subject: Re: [PATCH] i2c: drop ancient protection against sysfs refcounting issues
Date: Tue, 20 Jan 2015 03:01:42 +0800 [thread overview]
Message-ID: <20150119190142.GA9451@kroah.com> (raw)
In-Reply-To: <1421693756-12917-1-git-send-email-wsa@the-dreams.de>
On Mon, Jan 19, 2015 at 07:55:56PM +0100, Wolfram Sang wrote:
> Back in the days, sysfs seemed to have refcounting issues and subsystems
> needed a completion to be safe. This is not the case anymore, so I2C can
> get rid of this code. There is noone else besides I2C doing something
> like this currently (checked with the attached coccinelle script which
> checks if a release function exists and if it contains a completion).
>
> I have been digging through the history of linux.git and
> linux-history.git and found that e.g. w1 used to have such a mechanism
> and also simply removed it later.
>
> Some more info from Greg Kroah-Hartman:
> "Having that call "wait" for the other release call to happen is really
> old, as Jean points out, from 2003. We have "fixed" sysfs since then to
> detach the files from the devices easier, we used to have some nasy
> reference count issues in that area."
>
> And some testing from Jean Delvare which matches my results:
> "However I just tested unloading an i2c bus driver while its adapter's
> new_device attribute was opened and rmmod returned immediately. So it
> doesn't look like accessing sysfs attributes actually takes a reference
> to the underlying i2c_adapter."
>
> Let's get rid of this code before really nobody knows/understands
> anymore what this was for and if it has a subtle use.
>
> Reported-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> ---
>
> Of course, more testing is appreciated. Here is the coccinelle script:
>
> ===
>
> @has_type@
> identifier d_type, rel_f;
> @@
>
> struct device_type d_type = {
> .release = rel_f,
> };
>
> @has_device@
> struct device *d;
> identifier rel_f, p;
> @@
>
> (
> p->dev.release = &rel_f;
> |
> d->release = &rel_f;
> )
>
> @find_type depends on has_type@
> identifier has_type.rel_f, d;
> @@
>
> void rel_f(struct device *d)
> {
> ...
> * complete(...);
> ...
> }
>
> @find_device depends on has_device@
> identifier has_device.rel_f, d;
> @@
>
> void rel_f(struct device *d)
> {
> ...
> * complete(...);
> ...
> }
>
> ===
>
> drivers/i2c/i2c-core.c | 10 +---------
> include/linux/i2c.h | 1 -
> 2 files changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 39d25a8cb1ad..15cc5902cf89 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -41,7 +41,6 @@
> #include <linux/of_device.h>
> #include <linux/of_irq.h>
> #include <linux/clk/clk-conf.h>
> -#include <linux/completion.h>
> #include <linux/hardirq.h>
> #include <linux/irqflags.h>
> #include <linux/rwsem.h>
> @@ -1184,8 +1183,7 @@ EXPORT_SYMBOL_GPL(i2c_new_dummy);
>
> static void i2c_adapter_dev_release(struct device *dev)
> {
> - struct i2c_adapter *adap = to_i2c_adapter(dev);
> - complete(&adap->dev_released);
> + /* empty, but the driver core insists we need a release function */
Yeah, it does, but I hate to see this in "real" code as something is
probably wrong with it if it happens.
Please move the rest of 'i2c_del_adapter' into the release function
(what was after the wait_for_completion() call), and then all should be
fine.
thanks,
greg k-h
WARNING: multiple messages have this Message-ID (diff)
From: gregkh@linuxfoundation.org (Greg Kroah-Hartman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] i2c: drop ancient protection against sysfs refcounting issues
Date: Tue, 20 Jan 2015 03:01:42 +0800 [thread overview]
Message-ID: <20150119190142.GA9451@kroah.com> (raw)
In-Reply-To: <1421693756-12917-1-git-send-email-wsa@the-dreams.de>
On Mon, Jan 19, 2015 at 07:55:56PM +0100, Wolfram Sang wrote:
> Back in the days, sysfs seemed to have refcounting issues and subsystems
> needed a completion to be safe. This is not the case anymore, so I2C can
> get rid of this code. There is noone else besides I2C doing something
> like this currently (checked with the attached coccinelle script which
> checks if a release function exists and if it contains a completion).
>
> I have been digging through the history of linux.git and
> linux-history.git and found that e.g. w1 used to have such a mechanism
> and also simply removed it later.
>
> Some more info from Greg Kroah-Hartman:
> "Having that call "wait" for the other release call to happen is really
> old, as Jean points out, from 2003. We have "fixed" sysfs since then to
> detach the files from the devices easier, we used to have some nasy
> reference count issues in that area."
>
> And some testing from Jean Delvare which matches my results:
> "However I just tested unloading an i2c bus driver while its adapter's
> new_device attribute was opened and rmmod returned immediately. So it
> doesn't look like accessing sysfs attributes actually takes a reference
> to the underlying i2c_adapter."
>
> Let's get rid of this code before really nobody knows/understands
> anymore what this was for and if it has a subtle use.
>
> Reported-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> ---
>
> Of course, more testing is appreciated. Here is the coccinelle script:
>
> ===
>
> @has_type@
> identifier d_type, rel_f;
> @@
>
> struct device_type d_type = {
> .release = rel_f,
> };
>
> @has_device@
> struct device *d;
> identifier rel_f, p;
> @@
>
> (
> p->dev.release = &rel_f;
> |
> d->release = &rel_f;
> )
>
> @find_type depends on has_type@
> identifier has_type.rel_f, d;
> @@
>
> void rel_f(struct device *d)
> {
> ...
> * complete(...);
> ...
> }
>
> @find_device depends on has_device@
> identifier has_device.rel_f, d;
> @@
>
> void rel_f(struct device *d)
> {
> ...
> * complete(...);
> ...
> }
>
> ===
>
> drivers/i2c/i2c-core.c | 10 +---------
> include/linux/i2c.h | 1 -
> 2 files changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 39d25a8cb1ad..15cc5902cf89 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -41,7 +41,6 @@
> #include <linux/of_device.h>
> #include <linux/of_irq.h>
> #include <linux/clk/clk-conf.h>
> -#include <linux/completion.h>
> #include <linux/hardirq.h>
> #include <linux/irqflags.h>
> #include <linux/rwsem.h>
> @@ -1184,8 +1183,7 @@ EXPORT_SYMBOL_GPL(i2c_new_dummy);
>
> static void i2c_adapter_dev_release(struct device *dev)
> {
> - struct i2c_adapter *adap = to_i2c_adapter(dev);
> - complete(&adap->dev_released);
> + /* empty, but the driver core insists we need a release function */
Yeah, it does, but I hate to see this in "real" code as something is
probably wrong with it if it happens.
Please move the rest of 'i2c_del_adapter' into the release function
(what was after the wait_for_completion() call), and then all should be
fine.
thanks,
greg k-h
next prev parent reply other threads:[~2015-01-19 21:20 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-19 18:55 [PATCH] i2c: drop ancient protection against sysfs refcounting issues Wolfram Sang
2015-01-19 18:55 ` Wolfram Sang
2015-01-19 18:55 ` Wolfram Sang
2015-01-19 18:59 ` Pantelis Antoniou
2015-01-19 18:59 ` Pantelis Antoniou
2015-01-19 18:59 ` Pantelis Antoniou
2015-01-19 18:59 ` Pantelis Antoniou
2015-01-19 19:01 ` Greg Kroah-Hartman [this message]
2015-01-19 19:01 ` Greg Kroah-Hartman
2015-01-19 19:01 ` Greg Kroah-Hartman
2015-01-19 21:30 ` Wolfram Sang
2015-01-19 21:30 ` Wolfram Sang
2015-01-19 21:30 ` Wolfram Sang
2015-01-19 23:04 ` Russell King - ARM Linux
2015-01-19 23:04 ` Russell King - ARM Linux
2015-01-19 23:04 ` Russell King - ARM Linux
2015-01-20 1:41 ` Greg Kroah-Hartman
2015-01-20 1:41 ` Greg Kroah-Hartman
2015-01-20 1:41 ` Greg Kroah-Hartman
2015-01-20 7:05 ` Lars-Peter Clausen
2015-01-20 7:05 ` Lars-Peter Clausen
2015-01-20 7:05 ` Lars-Peter Clausen
2015-01-20 7:12 ` Greg Kroah-Hartman
2015-01-20 7:12 ` Greg Kroah-Hartman
2015-01-20 7:12 ` Greg Kroah-Hartman
2015-01-20 7:27 ` Lars-Peter Clausen
2015-01-20 7:27 ` Lars-Peter Clausen
2015-01-20 7:27 ` Lars-Peter Clausen
2015-01-20 10:17 ` Russell King - ARM Linux
2015-01-20 10:17 ` Russell King - ARM Linux
2015-01-20 10:17 ` Russell King - ARM Linux
2015-01-20 11:35 ` Wolfram Sang
2015-01-20 11:35 ` Wolfram Sang
2015-01-20 11:35 ` Wolfram Sang
2015-01-19 19:12 ` Russell King - ARM Linux
2015-01-19 19:12 ` Russell King - ARM Linux
2015-01-19 19:12 ` Russell King - ARM Linux
2015-01-19 19:39 ` Wolfram Sang
2015-01-19 19:39 ` Wolfram Sang
2015-01-19 19:39 ` Wolfram Sang
2015-01-19 20:01 ` Lars-Peter Clausen
2015-01-19 20:01 ` Lars-Peter Clausen
2015-01-19 20:01 ` Lars-Peter Clausen
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=20150119190142.GA9451@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=jdelvare@suse.de \
--cc=julia.lawall@lip6.fr \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=pantelis.antoniou@konsulko.com \
--cc=wsa@the-dreams.de \
/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.