Linux Input Archive mirror
 help / color / mirror / Atom feed
From: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: Re: [PATCH] Input: cyapa - add missing input core locking to suspend/resume functions
Date: Thu, 25 Apr 2024 19:04:30 +0200	[thread overview]
Message-ID: <043e53c5-98a0-4205-8065-cd57dceacd3f@collabora.com> (raw)
In-Reply-To: <5f9052f0-ef5f-4c4f-85f9-f07fffd2b5ef@samsung.com>

Hi Marek,

W dniu 25.04.2024 o 12:02, Marek Szyprowski pisze:
> On 09.10.2023 14:10, Marek Szyprowski wrote:
>> Grab input->mutex during suspend/resume functions like it is done in
>> other input drivers. This fixes the following warning during system
>> suspend/resume cycle on Samsung Exynos5250-based Snow Chromebook:
>>
>> ------------[ cut here ]------------
>> WARNING: CPU: 1 PID: 1680 at drivers/input/input.c:2291 input_device_enabled+0x68/0x6c
>> Modules linked in: ...
>> CPU: 1 PID: 1680 Comm: kworker/u4:12 Tainted: G        W          6.6.0-rc5-next-20231009 #14109
>> Hardware name: Samsung Exynos (Flattened Device Tree)
>> Workqueue: events_unbound async_run_entry_fn
>>    unwind_backtrace from show_stack+0x10/0x14
>>    show_stack from dump_stack_lvl+0x58/0x70
>>    dump_stack_lvl from __warn+0x1a8/0x1cc
>>    __warn from warn_slowpath_fmt+0x18c/0x1b4
>>    warn_slowpath_fmt from input_device_enabled+0x68/0x6c
>>    input_device_enabled from cyapa_gen3_set_power_mode+0x13c/0x1dc
>>    cyapa_gen3_set_power_mode from cyapa_reinitialize+0x10c/0x15c
>>    cyapa_reinitialize from cyapa_resume+0x48/0x98
>>    cyapa_resume from dpm_run_callback+0x90/0x298
>>    dpm_run_callback from device_resume+0xb4/0x258
>>    device_resume from async_resume+0x20/0x64
>>    async_resume from async_run_entry_fn+0x40/0x15c
>>    async_run_entry_fn from process_scheduled_works+0xbc/0x6a8
>>    process_scheduled_works from worker_thread+0x188/0x454
>>    worker_thread from kthread+0x108/0x140
>>    kthread from ret_from_fork+0x14/0x28
>> Exception stack(0xf1625fb0 to 0xf1625ff8)
>> ...
>> ---[ end trace 0000000000000000 ]---
>> ...
>> ------------[ cut here ]------------
>> WARNING: CPU: 1 PID: 1680 at drivers/input/input.c:2291 input_device_enabled+0x68/0x6c
>> Modules linked in: ...
>> CPU: 1 PID: 1680 Comm: kworker/u4:12 Tainted: G        W          6.6.0-rc5-next-20231009 #14109
>> Hardware name: Samsung Exynos (Flattened Device Tree)
>> Workqueue: events_unbound async_run_entry_fn
>>    unwind_backtrace from show_stack+0x10/0x14
>>    show_stack from dump_stack_lvl+0x58/0x70
>>    dump_stack_lvl from __warn+0x1a8/0x1cc
>>    __warn from warn_slowpath_fmt+0x18c/0x1b4
>>    warn_slowpath_fmt from input_device_enabled+0x68/0x6c
>>    input_device_enabled from cyapa_gen3_set_power_mode+0x13c/0x1dc
>>    cyapa_gen3_set_power_mode from cyapa_reinitialize+0x10c/0x15c
>>    cyapa_reinitialize from cyapa_resume+0x48/0x98
>>    cyapa_resume from dpm_run_callback+0x90/0x298
>>    dpm_run_callback from device_resume+0xb4/0x258
>>    device_resume from async_resume+0x20/0x64
>>    async_resume from async_run_entry_fn+0x40/0x15c
>>    async_run_entry_fn from process_scheduled_works+0xbc/0x6a8
>>    process_scheduled_works from worker_thread+0x188/0x454
>>    worker_thread from kthread+0x108/0x140
>>    kthread from ret_from_fork+0x14/0x28
>> Exception stack(0xf1625fb0 to 0xf1625ff8)
>> ...
>> ---[ end trace 0000000000000000 ]---
>>
>> Fixes: d69f0a43c677 ("Input: use input_device_enabled()")
>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> 
> Gentle ping?

Thanks for pinging this gently ;)

Unfortunately I am unable to test it now, but I assume this
fixes the problem for you. If so, you can add my

Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>

> 
>> ---
>>    drivers/input/mouse/cyapa.c | 12 +++++++++++-
>>    1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
>> index a84098448f5b..cf23f95b5f11 100644
>> --- a/drivers/input/mouse/cyapa.c
>> +++ b/drivers/input/mouse/cyapa.c
>> @@ -1347,10 +1347,16 @@ static int cyapa_suspend(struct device *dev)
>>    	u8 power_mode;
>>    	int error;
>>    
>> -	error = mutex_lock_interruptible(&cyapa->state_sync_lock);
>> +	error = mutex_lock_interruptible(&cyapa->input->mutex);
>>    	if (error)
>>    		return error;
>>    
>> +	error = mutex_lock_interruptible(&cyapa->state_sync_lock);
>> +	if (error) {
>> +		mutex_unlock(&cyapa->input->mutex);
>> +		return error;
>> +	}
>> +
>>    	/*
>>    	 * Runtime PM is enable only when device is in operational mode and
>>    	 * users in use, so need check it before disable it to
>> @@ -1385,6 +1391,8 @@ static int cyapa_suspend(struct device *dev)
>>    		cyapa->irq_wake = (enable_irq_wake(client->irq) == 0);
>>    
>>    	mutex_unlock(&cyapa->state_sync_lock);
>> +	mutex_unlock(&cyapa->input->mutex);
>> +
>>    	return 0;
>>    }
>>    
>> @@ -1394,6 +1402,7 @@ static int cyapa_resume(struct device *dev)
>>    	struct cyapa *cyapa = i2c_get_clientdata(client);
>>    	int error;
>>    
>> +	mutex_lock(&cyapa->input->mutex);
>>    	mutex_lock(&cyapa->state_sync_lock);
>>    
>>    	if (device_may_wakeup(dev) && cyapa->irq_wake) {
>> @@ -1412,6 +1421,7 @@ static int cyapa_resume(struct device *dev)
>>    	enable_irq(client->irq);
>>    
>>    	mutex_unlock(&cyapa->state_sync_lock);
>> +	mutex_unlock(&cyapa->input->mutex);
>>    	return 0;
>>    }
>>    
> 
> Best regards


      reply	other threads:[~2024-04-25 17:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20231009121026eucas1p19ed2a6a88fa6b899ef9b915a73ad87b5@eucas1p1.samsung.com>
2023-10-09 12:10 ` [PATCH] Input: cyapa - add missing input core locking to suspend/resume functions Marek Szyprowski
2024-04-25 10:02   ` Marek Szyprowski
2024-04-25 17:04     ` Andrzej Pietrasiewicz [this message]

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=043e53c5-98a0-4205-8065-cd57dceacd3f@collabora.com \
    --to=andrzej.p@collabora.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).