All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: Sudeep Holla <sudeep.holla@arm.com>,
	Chris Diamand <chris.diamand@arm.com>,
	linux-pm@vger.kernel.org, MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>,
	Nishanth Menon <nm@ti.com>, Cai Zhiyong <caizhiyong@huawei.com>,
	"cpgs (cpgs@samsung.com)" <cpgs@samsung.com>
Subject: Re: [PATCH] PM / devfreq: Don't delete sysfs group twice
Date: Wed, 14 Dec 2016 19:10:55 +0900	[thread overview]
Message-ID: <58511AAF.7010705@samsung.com> (raw)
In-Reply-To: <420ba56f-70be-0735-ad99-d90dd04113c5@arm.com>

Hi Sudeep,

On 2016년 12월 14일 18:29, Sudeep Holla wrote:
> 
> 
> On 14/12/16 02:48, Chanwoo Choi wrote:
>> Hi Chris,
>>
>> On 2016년 12월 14일 10:38, Chanwoo Choi wrote:
>>> Hi Chris,
>>>
>>> On 2016년 12월 14일 02:09, Chris Diamand wrote:
>>>> 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 explicitly
>>>> stopping the governor in devfreq_remove_device(), *before* the
>>>> devfreq entry is removed.
>>>>
>>>> Note that we can't just remove the call to sysfs_remove_group() in
>>>> the userspace governor, as it's needed for when the governor is
>>>> changed to one without a sysfs entry.
>>>>
>>>> Signed-off-by: Chris Diamand <chris.diamand@arm.com>
>>>> ---
>>>>  drivers/devfreq/devfreq.c | 6 ++++++
>>>>  1 file changed, 6 insertions(+)
>>>>
>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>>> index 478006b..d8a817c 100644
>>>> --- a/drivers/devfreq/devfreq.c
>>>> +++ b/drivers/devfreq/devfreq.c
>>>> @@ -622,6 +622,12 @@ int devfreq_remove_device(struct devfreq *devfreq)
>>>>  	if (!devfreq)
>>>>  		return -EINVAL;
>>>>  
>>>> +	if (devfreq->governor) {
>>>> +		devfreq->governor->event_handler(devfreq,
>>>> +						 DEVFREQ_GOV_STOP, NULL);
>>>> +		devfreq->governor = NULL;
>>>> +	}
>>>> +
>>>>
>>> The devfreq_remove_device has following description:
>>> - "* The oppsite of devfreq_add_device()"
>>>
>>> I think that we should call the '_remove_devfreq()' function in the devfreq_remove_device()
>>> because '_remove_devfreq()' is in charge of releasing the devfreq instance.
>>>
>>> The '_remove_devfreq() ' function includes the code to stop the governor and following works:
>>> - remove the devfreq instance from devfreq list
>>> - call the profile->exit function
>>> - destroy the muxte of devfreq instance
>>> - Free the devfreq memory.
>>
>> How about following patch?
>> I think that this patch covers the all of case when removing the devfreq device.
>>
>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>> index 8a456dd55a8d..eea406df0037 100644
>> --- a/drivers/devfreq/devfreq.c
>> +++ b/drivers/devfreq/devfreq.c
>> @@ -496,6 +496,7 @@ static void _remove_devfreq(struct devfreq *devfreq)
>>                 devfreq->profile->exit(devfreq->dev.parent);
>>  
>>         mutex_destroy(&devfreq->lock);
>> +       device_unregister(&devfreq->dev);
>>         kfree(devfreq);
>>  }
>>  
> 
> Won't this result in device_unregister->put_device->kobject_put->kref_put->
> kobject_release->kobject_cleanup->release->device_unregister
> 
> Is that fine ?
> 

My suggestion is incorrect. The original suggestion is right
with removing the code related to DEVFREQ_GOV_STOP from _remove_devfreq().
I'm sorry for confusion.

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 8a456dd55a8d..3e9eb7fa9e72 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -488,10 +488,6 @@ static void _remove_devfreq(struct devfreq *devfreq)
        list_del(&devfreq->node);
        mutex_unlock(&devfreq_list_lock);
 
-       if (devfreq->governor)
-               devfreq->governor->event_handler(devfreq,
-                                                DEVFREQ_GOV_STOP, NULL);
-
        if (devfreq->profile->exit)
                devfreq->profile->exit(devfreq->dev.parent);
 
@@ -634,6 +630,10 @@ int devfreq_remove_device(struct devfreq *devfreq)
        if (!devfreq)
                return -EINVAL;
 
+       if (devfreq->governor)
+               devfreq->governor->event_handler(devfreq,
+                                        DEVFREQ_GOV_STOP, NULL);
+
        device_unregister(&devfreq->dev);
 
        return 0;


-- 
Regards,
Chanwoo Choi

  reply	other threads:[~2016-12-14 10:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161213171211epcas3p3ed8807883967daca28b7abe211446739@epcas3p3.samsung.com>
2016-12-13 17:09 ` [PATCH] PM / devfreq: Don't delete sysfs group twice Chris Diamand
2016-12-14  1:37   ` Chanwoo Choi
2016-12-14  1:38   ` Chanwoo Choi
2016-12-14  2:48     ` Chanwoo Choi
2016-12-14  9:29       ` Sudeep Holla
2016-12-14 10:10         ` Chanwoo Choi [this message]
     [not found]         ` <172e4f85358b4f4e9206c4a54b5db056@AM4PR0802MB2210.eurprd08.prod.outlook.com>
2016-12-14 11:32           ` Chris Diamand
2016-12-14 13:48             ` Chanwoo Choi
     [not found]             ` <7a342ead78be4f32a4a37b541fde412b@AM4PR0802MB2210.eurprd08.prod.outlook.com>
2016-12-15 10:41               ` Chris Diamand
2016-12-16  6:48                 ` Chanwoo Choi
     [not found]                 ` <f4620f8efbf247119640470ec12810fe@AM4PR0802MB2210.eurprd08.prod.outlook.com>
2016-12-16 19:09                   ` [PATCH v2] " Chris Diamand
2016-12-16  2:17               ` Re: [PATCH] " MyungJoo Ham
     [not found] <CGME20161213170941epcas2p1267d3da4c7034777c8de117ed3c0f9fe@epcas2p1.samsung.com>
2016-12-14  0:45 ` MyungJoo Ham

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=58511AAF.7010705@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=caizhiyong@huawei.com \
    --cc=chris.diamand@arm.com \
    --cc=cpgs@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=nm@ti.com \
    --cc=sudeep.holla@arm.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 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.