From patchwork Mon Oct 9 12:10:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 731227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B906E95A96 for ; Mon, 9 Oct 2023 12:10:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346308AbjJIMKf (ORCPT ); Mon, 9 Oct 2023 08:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346444AbjJIMKe (ORCPT ); Mon, 9 Oct 2023 08:10:34 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54AA9A6 for ; Mon, 9 Oct 2023 05:10:30 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231009121026euoutp02a5e7d51acf322b8e5e508a511a4737bc~MbzOTJ7jT0678106781euoutp02H for ; Mon, 9 Oct 2023 12:10:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231009121026euoutp02a5e7d51acf322b8e5e508a511a4737bc~MbzOTJ7jT0678106781euoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1696853426; bh=+oeF9tduJROpDtEILgnH87XCwSDj3+xudliDOb9i4c0=; h=From:To:Cc:Subject:Date:References:From; b=JpYvnAD49jvrdbgZD5e7a6H8MuDp/a0YCS84UmjwewbqYI8jIGJuBo3sG0w5T7Wcf 8M2cFksRLgj2usgPEy48M46SKMj+BTcBSogjDv1+5QKgMMbJTNX4otaNxvXQXgHsWh I/jP84wFGbE1ypNi8tMEs03fq26ha4jOGZWjpwWM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20231009121026eucas1p1adad209218fa1a3c4958ca50071ebcad~MbzOFgJgu0583105831eucas1p1W; Mon, 9 Oct 2023 12:10:26 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id BC.2B.11320.2BDE3256; Mon, 9 Oct 2023 13:10:26 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231009121026eucas1p19ed2a6a88fa6b899ef9b915a73ad87b5~MbzNqHT6W1046310463eucas1p1H; Mon, 9 Oct 2023 12:10:26 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231009121026eusmtrp2daf61cd3394bda244624e4b47fc2aa5f~MbzNpQuTW0414604146eusmtrp2e; Mon, 9 Oct 2023 12:10:26 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-1f-6523edb292fb Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 33.91.10549.2BDE3256; Mon, 9 Oct 2023 13:10:26 +0100 (BST) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231009121025eusmtip124de06fbf785870495bda711da01db0c~MbzNS2WFR1780317803eusmtip1P; Mon, 9 Oct 2023 12:10:25 +0000 (GMT) From: Marek Szyprowski To: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Dmitry Torokhov , Andrzej Pietrasiewicz Subject: [PATCH] Input: cyapa - add missing input core locking to suspend/resume functions Date: Mon, 9 Oct 2023 14:10:18 +0200 Message-Id: <20231009121018.1075318-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42LZduzned1Nb5VTDeb9VbFY9vgei8XhRS8Y LW5++sZqcXnXHDaLtUfusjuweuy4u4TRY+esu+wefVtWMXp83iQXwBLFZZOSmpNZllqkb5fA lfHufD9jwXfFinUd7WwNjF2yXYycHBICJhInN6xg6mLk4hASWMEocevXZHYI5wujxO6+hywQ zmdGiSeT+plhWma33GOGSCxnlPjc8ZsVruXytEssIFVsAoYSXW+72EBsEQFbiR0rpoMtYRbo Z5RYu2wvO0hCWCBGouXGdyYQm0VAVeLhopdgNq+AvcTp+59YINbJS+w/eJYZIi4ocXLmE7A4 M1C8eetssDMkBDo5JF7uOMoG0eAi8X/GJShbWOLV8S3sELaMxP+d85kgGtoZJRb8vg/lTGCU aHh+ixGiylrizrlfQN0cQCs0Jdbv0ocIO0q0/NrLBBKWEOCTuPFWEOIIPolJ26YzQ4R5JTra hCCq1SRmHV8Ht/bghUtQJR4SDW3pIGEhgViJySvnMk1gVJiF5LNZSD6bhXDCAkbmVYziqaXF uempxUZ5qeV6xYm5xaV56XrJ+bmbGIEJ5fS/4192MC5/9VHvECMTB+MhRgkOZiURXt1ShVQh 3pTEyqrUovz4otKc1OJDjNIcLErivKop8qlCAumJJanZqakFqUUwWSYOTqkGJjNZOZ3z9Uf6 tXcorzha/2b+/73NfUoPtS/oaxmuNauJLri5KdtmxWc7f2sJVs9NT+SrOCY0NyamJs1x3GIr e6iD9VlWwK/4y7LZ8V9Mtfktp9ztCj3Mr/u+dE3A2RXHfLnXzXwid/+x8tfX2w4pZDJf6zgk yfZap79tUp3b25cveT8+Ee5b+3Zb3Ix0/11GhYuUr31ZqBU91dNvaRd/h8Qfrhy19YV/Zdeo 3ni2vZzN5v8jqUCnkne5Z1/bPF17wVH37+ysMoXatFyx3++LN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= X-CMS-MailID: 20231009121026eucas1p19ed2a6a88fa6b899ef9b915a73ad87b5 X-Msg-Generator: CA X-RootMTR: 20231009121026eucas1p19ed2a6a88fa6b899ef9b915a73ad87b5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231009121026eucas1p19ed2a6a88fa6b899ef9b915a73ad87b5 References: Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 Reviewed-by: Andrzej Pietrasiewicz --- 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; }