* [PATCH v2] PM / devfreq: Don't delete sysfs group twice
[not found] ` <f4620f8efbf247119640470ec12810fe@AM4PR0802MB2210.eurprd08.prod.outlook.com>
@ 2016-12-16 19:09 ` Chris Diamand
0 siblings, 0 replies; 5+ messages in thread
From: Chris Diamand @ 2016-12-16 19:09 UTC (permalink / raw)
To: Chanwoo Choi, linux-pm@vger.kernel.org
Cc: Sudeep Holla, MyungJoo Ham, Kyungmin Park, Nishanth Menon,
Cai Zhiyong, cpgs (cpgs@samsung.com)
The 'userspace' governor adds a sysfs entry, which is removed when
the governor is changed, or the devfreq device is released. However,
when the latter occurs via device_unregister(), device_del() is
called first, which removes the sysfs entries recursively and deletes
the kobject.
This means we get an Oops when the governor calls
sysfs_remove_group() on the deleted kobject. Fix this by only doing
the call when kobj *hasn't* been kobject_del()'d.
Note that we can't just remove the call to sysfs_remove_group()
entirely - it's needed for when the governor is changed to one which
doesn't need a sysfs entry.
Signed-off-by: Chris Diamand <chris.diamand@arm.com>
---
This takes a different approach to v1, and fixes the issue in the governor
instead. This means reference counting should still work as usual, so anything
which doesn't call devfreq_remove_device() should still work.
drivers/devfreq/governor_userspace.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c
index 35de6e8..9db4d6f 100644
--- a/drivers/devfreq/governor_userspace.c
+++ b/drivers/devfreq/governor_userspace.c
@@ -112,7 +112,13 @@ static int userspace_init(struct devfreq *devfreq)
static void userspace_exit(struct devfreq *devfreq)
{
- sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group);
+ /*
+ * Remove the sysfs entry, unless this is being called after
+ * device_del(), which should have done this already via kobject_del().
+ */
+ if (devfreq->dev.kobj.sd)
+ sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group);
+
kfree(devfreq->data);
devfreq->data = NULL;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2] PM / devfreq: Don't delete sysfs group twice
@ 2017-01-12 14:57 ` chris.diamand
2017-01-13 0:18 ` Chanwoo Choi
0 siblings, 1 reply; 5+ messages in thread
From: chris.diamand @ 2017-01-12 14:57 UTC (permalink / raw)
To: Chanwoo Choi, linux-pm
Cc: Sudeep Holla, MyungJoo Ham, Kyungmin Park, Nishanth Menon,
Cai Zhiyong, cpgs (cpgs@samsung.com), Chris Diamand
From: Chris Diamand <chris.diamand@arm.com>
The 'userspace' governor adds a sysfs entry, which is removed when
the governor is changed, or the devfreq device is released. However,
when the latter occurs via device_unregister(), device_del() is
called first, which removes the sysfs entries recursively and deletes
the kobject.
This means we get an Oops when the governor calls
sysfs_remove_group() on the deleted kobject. Fix this by only doing
the call when kobj *hasn't* been kobject_del()'d.
Note that we can't just remove the call to sysfs_remove_group()
entirely - it's needed for when the governor is changed to one which
doesn't need a sysfs entry.
Signed-off-by: Chris Diamand <chris.diamand@arm.com>
---
Hi all - this is a resend of my updated devfreq removal fix.
This takes a different approach to v1, and fixes the issue in the governor
instead. This means reference counting should still work as usual, so anything
which doesn't call devfreq_remove_device() should still work.
Cheers!
Chris
drivers/devfreq/governor_userspace.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c
index 35de6e8..9db4d6f 100644
--- a/drivers/devfreq/governor_userspace.c
+++ b/drivers/devfreq/governor_userspace.c
@@ -112,7 +112,13 @@ static int userspace_init(struct devfreq *devfreq)
static void userspace_exit(struct devfreq *devfreq)
{
- sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group);
+ /*
+ * Remove the sysfs entry, unless this is being called after
+ * device_del(), which should have done this already via kobject_del().
+ */
+ if (devfreq->dev.kobj.sd)
+ sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group);
+
kfree(devfreq->data);
devfreq->data = NULL;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PM / devfreq: Don't delete sysfs group twice
2017-01-12 14:57 ` [PATCH v2] PM / devfreq: Don't delete sysfs group twice chris.diamand
@ 2017-01-13 0:18 ` Chanwoo Choi
0 siblings, 0 replies; 5+ messages in thread
From: Chanwoo Choi @ 2017-01-13 0:18 UTC (permalink / raw)
To: chris.diamand, linux-pm
Cc: Sudeep Holla, MyungJoo Ham, Kyungmin Park, Nishanth Menon,
Cai Zhiyong, cpgs (cpgs@samsung.com)
Hi Chris,
Looks good to me.
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
On 2017년 01월 12일 23:57, chris.diamand@arm.com wrote:
> From: Chris Diamand <chris.diamand@arm.com>
>
> The 'userspace' governor adds a sysfs entry, which is removed when
> the governor is changed, or the devfreq device is released. However,
> when the latter occurs via device_unregister(), device_del() is
> called first, which removes the sysfs entries recursively and deletes
> the kobject.
>
> This means we get an Oops when the governor calls
> sysfs_remove_group() on the deleted kobject. Fix this by only doing
> the call when kobj *hasn't* been kobject_del()'d.
>
> Note that we can't just remove the call to sysfs_remove_group()
> entirely - it's needed for when the governor is changed to one which
> doesn't need a sysfs entry.
>
> Signed-off-by: Chris Diamand <chris.diamand@arm.com>
> ---
> Hi all - this is a resend of my updated devfreq removal fix.
>
> This takes a different approach to v1, and fixes the issue in the governor
> instead. This means reference counting should still work as usual, so anything
> which doesn't call devfreq_remove_device() should still work.
>
> Cheers!
> Chris
>
> drivers/devfreq/governor_userspace.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c
> index 35de6e8..9db4d6f 100644
> --- a/drivers/devfreq/governor_userspace.c
> +++ b/drivers/devfreq/governor_userspace.c
> @@ -112,7 +112,13 @@ static int userspace_init(struct devfreq *devfreq)
>
> static void userspace_exit(struct devfreq *devfreq)
> {
> - sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group);
> + /*
> + * Remove the sysfs entry, unless this is being called after
> + * device_del(), which should have done this already via kobject_del().
> + */
> + if (devfreq->dev.kobj.sd)
> + sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group);
> +
> kfree(devfreq->data);
> devfreq->data = NULL;
> }
>
--
Best Regards,
Chanwoo Choi
S/W Center, Samsung Electronics
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v2] PM / devfreq: Don't delete sysfs group twice
[not found] <CGME20170112145811epcas2p1e8c07796d9c4630e25484b72ca1e94c0@epcas2p1.samsung.com>
@ 2017-01-13 1:15 ` MyungJoo Ham
[not found] ` <0dbe1e6db0f14888ae545aa7c9d780af@AM4PR0802MB2210.eurprd08.prod.outlook.com>
1 sibling, 0 replies; 5+ messages in thread
From: MyungJoo Ham @ 2017-01-13 1:15 UTC (permalink / raw)
To: chris.diamand@arm.com, Chanwoo Choi, linux-pm@vger.kernel.org
Cc: Sudeep Holla, Kyungmin Park, Nishanth Menon, Cai Zhiyong, cpgs .
[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]
> From: Chris Diamand <chris.diamand@arm.com>
>
> The 'userspace' governor adds a sysfs entry, which is removed when
> the governor is changed, or the devfreq device is released. However,
> when the latter occurs via device_unregister(), device_del() is
> called first, which removes the sysfs entries recursively and deletes
> the kobject.
>
> This means we get an Oops when the governor calls
> sysfs_remove_group() on the deleted kobject. Fix this by only doing
> the call when kobj *hasn't* been kobject_del()'d.
>
> Note that we can't just remove the call to sysfs_remove_group()
> entirely - it's needed for when the governor is changed to one which
> doesn't need a sysfs entry.
>
> Signed-off-by: Chris Diamand <chris.diamand@arm.com>
> ---
> Hi all - this is a resend of my updated devfreq removal fix.
>
> This takes a different approach to v1, and fixes the issue in the governor
> instead. This means reference counting should still work as usual, so anything
> which doesn't call devfreq_remove_device() should still work.
>
> Cheers!
> Chris
Ok, I'll update
https://git.kernel.org/cgit/linux/kernel/git/mzx/devfreq.git/commit/?h=for-4.10-rc&id=1eb32280a81463b6e1e38e2d261710e0d7fd5dcf
with this one.
Cheers,
MyungJoo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PM / devfreq: Don't delete sysfs group twice
[not found] ` <0dbe1e6db0f14888ae545aa7c9d780af@AM4PR0802MB2210.eurprd08.prod.outlook.com>
@ 2017-01-13 14:16 ` Chris Diamand
0 siblings, 0 replies; 5+ messages in thread
From: Chris Diamand @ 2017-01-13 14:16 UTC (permalink / raw)
To: MyungJoo Ham, Chanwoo Choi
Cc: linux-pm@vger.kernel.org, Sudeep Holla, Kyungmin Park,
Nishanth Menon, Cai Zhiyong, cpgs .
On Fri, Jan 13, 2017 at 12:18:39AM +0000, Chanwoo Choi wrote:
> Hi Chris,
>
> Looks good to me.
>
> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
On Fri, Jan 13, 2017 at 01:15:06AM +0000, MyungJoo Ham wrote:
> Ok, I'll update
> https://git.kernel.org/cgit/linux/kernel/git/mzx/devfreq.git/commit/?h=for-4.10-rc&id=1eb32280a81463b6e1e38e2d261710e0d7fd5dcf
> with this one.
Thanks both!
Cheers,
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-13 14:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20170112145810epcas2p359a78f92ce8bd256a8f09c6e9c211cf1@epcas2p3.samsung.com>
2017-01-12 14:57 ` [PATCH v2] PM / devfreq: Don't delete sysfs group twice chris.diamand
2017-01-13 0:18 ` Chanwoo Choi
[not found] <CGME20170112145811epcas2p1e8c07796d9c4630e25484b72ca1e94c0@epcas2p1.samsung.com>
2017-01-13 1:15 ` MyungJoo Ham
[not found] ` <0dbe1e6db0f14888ae545aa7c9d780af@AM4PR0802MB2210.eurprd08.prod.outlook.com>
2017-01-13 14:16 ` Chris Diamand
[not found] <CGME20161213171211epcas3p3ed8807883967daca28b7abe211446739@epcas3p3.samsung.com>
2016-12-13 17:09 ` [PATCH] " Chris Diamand
2016-12-14 1:38 ` Chanwoo Choi
2016-12-14 2:48 ` Chanwoo Choi
2016-12-14 9:29 ` Sudeep Holla
[not found] ` <172e4f85358b4f4e9206c4a54b5db056@AM4PR0802MB2210.eurprd08.prod.outlook.com>
2016-12-14 11:32 ` Chris Diamand
[not found] ` <7a342ead78be4f32a4a37b541fde412b@AM4PR0802MB2210.eurprd08.prod.outlook.com>
2016-12-15 10:41 ` Chris Diamand
[not found] ` <f4620f8efbf247119640470ec12810fe@AM4PR0802MB2210.eurprd08.prod.outlook.com>
2016-12-16 19:09 ` [PATCH v2] " Chris Diamand
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).