From patchwork Mon Apr 30 19:56:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10372567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6E2B26032A for ; Mon, 30 Apr 2018 19:57:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D95B2897E for ; Mon, 30 Apr 2018 19:57:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FDE628AA7; Mon, 30 Apr 2018 19:57:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A2C382897E for ; Mon, 30 Apr 2018 19:57:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 02AFC6E383; Mon, 30 Apr 2018 19:57:00 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 807256E383 for ; Mon, 30 Apr 2018 19:56:58 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id t11so15125229wmt.0 for ; Mon, 30 Apr 2018 12:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id; bh=c/V0ugpHOnLMEBkwKKro0X+RYMyqc5vLmhsK4jlX1UA=; b=Kao0G5wgITSXiFejFZPEAo7YltynRu4mjp3P4USdE37Bv1iV4v+Kqezb2tEi18vCcu r1ffQNvy+YhF0XCGRf2+UzqT+z2hm8Bu19UB5XL6uPbCLUERbUVJ4JDdh/Kiz4KMPbE3 VG606eneGJoIBf/ChgCdcmty+E8kw89+dgzHg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c/V0ugpHOnLMEBkwKKro0X+RYMyqc5vLmhsK4jlX1UA=; b=WyoDTHDBDviIUZhiUaOuRpFy/Fhzx/PIj+IiKoOPiC6j3yWe/FQqaSj0ql2SQNuIl0 dx0hTWdwCpg17duxB3aErYRS/b79Ehi5pyblTfcXSf/LnY0EN6MFPOzndeY5pa8Br8pf l6qUU7m7IQReIvmgYIYPY5cCh9l2uz9RvuQ6jQ7/LX4KngGDoOPQkAlReM8vWa2QDJGy K2wRZ7+97bvZtvpNSzeTvWHxwt2WW3uyxwBwOKnmJKPIKOdtCzJ+4/s0+GLUikm9WopV 5fdnbexNw9l7LPO1GVI4UndSr3ODx7rfKtlspYijAM/VLG/TxsukVR7bNbPbq9bpJ47x G/gg== X-Gm-Message-State: ALQs6tAKSXTg1iumynAsqEj/t3F+Nk8Dkkj2OzNKvkaHRpeNtnpLZJ9+ ooURS0CekUty+LKT0ZgeGRjC0UJW X-Google-Smtp-Source: AB8JxZpnJOFT+DrZhjMI5c0gQl9LIxnrjaKXtjT079HyTAKcwPXUyLJQB7SyKSz8jiffFtCL8EWM5g== X-Received: by 2002:a50:d2d7:: with SMTP id q23-v6mr18398846edg.12.1525118216897; Mon, 30 Apr 2018 12:56:56 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5635:0:39d2:f87e:2033:9f6]) by smtp.gmail.com with ESMTPSA id n8-v6sm4808307edb.5.2018.04.30.12.56.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Apr 2018 12:56:55 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Mon, 30 Apr 2018 21:56:49 +0200 Message-Id: <20180430195649.17445-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.17.0 Subject: [Intel-gfx] [PATCH] input/psmouse: Don't hold the mutex while calling ->disconnect X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-input@vger.kernel.org, Stephen Lyons , Daniel Vetter , Dmitry Torokhov , LKML , Benjamin Tissoires , Daniel Vetter , Arvind Yadav MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP At least trackpoint_disconnect wants to remove some sysfs files, and we can't remove sysfs files while holding psmouse_mutex: ====================================================== WARNING: possible circular locking dependency detected 4.16.0-rc5-g613eb885b69e-drmtip_1+ #1 Tainted: G U ------------------------------------------------------ kworker/0:3/102 is trying to acquire lock: (kn->count#130){++++}, at: [<000000009679748b>] kernfs_remove_by_name_ns+0x3b/0x80 but task is already holding lock: (psmouse_mutex){+.+.}, at: [<0000000014f44bcc>] psmouse_disconnect+0x62/0x160 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (psmouse_mutex){+.+.}: psmouse_attr_set_helper+0x28/0x140 kernfs_fop_write+0xfe/0x180 __vfs_write+0x1e/0x130 vfs_write+0xbd/0x1b0 SyS_write+0x40/0xa0 do_syscall_64+0x65/0x1a0 entry_SYSCALL_64_after_hwframe+0x42/0xb7 -> #0 (kn->count#130){++++}: __kernfs_remove+0x243/0x2b0 kernfs_remove_by_name_ns+0x3b/0x80 remove_files.isra.0+0x2b/0x60 sysfs_remove_group+0x38/0x80 sysfs_remove_groups+0x24/0x40 trackpoint_disconnect+0x2c/0x50 psmouse_disconnect+0x8f/0x160 serio_disconnect_driver+0x28/0x40 serio_driver_remove+0xc/0x10 device_release_driver_internal+0x15b/0x230 serio_handle_event+0x1c8/0x260 process_one_work+0x215/0x620 worker_thread+0x48/0x3a0 kthread+0xfb/0x130 ret_from_fork+0x3a/0x50 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(psmouse_mutex); lock(kn->count#130); lock(psmouse_mutex); lock(kn->count#130); *** DEADLOCK *** 6 locks held by kworker/0:3/102: #0: ((wq_completion)"events_long"){+.+.}, at: [<000000002e408bfa>] process_one_work+0x191/0x620 #1: (serio_event_work){+.+.}, at: [<000000002e408bfa>] process_one_work+0x191/0x620 #2: (serio_mutex){+.+.}, at: [<00000000c8a49847>] serio_handle_event+0x23/0x260 #3: (&dev->mutex){....}, at: [<00000000b55eee75>] device_release_driver_internal+0x2f/0x230 #4: (&serio->drv_mutex){+.+.}, at: [<000000009719f997>] serio_disconnect_driver+0x16/0x40 #5: (psmouse_mutex){+.+.}, at: [<0000000014f44bcc>] psmouse_disconnect+0x62/0x160 stack backtrace: CPU: 0 PID: 102 Comm: kworker/0:3 Tainted: G U 4.16.0-rc5-g613eb885b69e-drmtip_1+ #1 Hardware name: LENOVO 74591P0/74591P0, BIOS 6DET28WW (1.05 ) 07/30/2008 Workqueue: events_long serio_handle_event Call Trace: dump_stack+0x5f/0x86 print_circular_bug.isra.18+0x1d0/0x2c0 __lock_acquire+0x14ae/0x1b60 ? kernfs_remove_by_name_ns+0x20/0x80 ? lock_acquire+0xaf/0x200 lock_acquire+0xaf/0x200 ? kernfs_remove_by_name_ns+0x3b/0x80 __kernfs_remove+0x243/0x2b0 ? kernfs_remove_by_name_ns+0x3b/0x80 ? kernfs_name_hash+0xd/0x70 ? kernfs_find_ns+0x7e/0x100 kernfs_remove_by_name_ns+0x3b/0x80 remove_files.isra.0+0x2b/0x60 sysfs_remove_group+0x38/0x80 sysfs_remove_groups+0x24/0x40 trackpoint_disconnect+0x2c/0x50 psmouse_disconnect+0x8f/0x160 serio_disconnect_driver+0x28/0x40 serio_driver_remove+0xc/0x10 device_release_driver_internal+0x15b/0x230 serio_handle_event+0x1c8/0x260 process_one_work+0x215/0x620 worker_thread+0x48/0x3a0 ? _raw_spin_unlock_irqrestore+0x4c/0x60 kthread+0xfb/0x130 ? process_one_work+0x620/0x620 ? _kthread_create_on_node+0x30/0x30 ret_from_fork+0x3a/0x50 Signed-off-by: Daniel Vetter Cc: Dmitry Torokhov Cc: Benjamin Tissoires Cc: Daniel Vetter Cc: Arvind Yadav Cc: Stephen Lyons Cc: linux-input@vger.kernel.org --- drivers/input/mouse/psmouse-base.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 8900c3166ebf..06ccd8e22f3c 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -1484,8 +1484,10 @@ static void psmouse_disconnect(struct serio *serio) psmouse_deactivate(parent); } + mutex_unlock(&psmouse_mutex); if (psmouse->disconnect) psmouse->disconnect(psmouse); + mutex_lock(&psmouse_mutex); if (parent && parent->pt_deactivate) parent->pt_deactivate(parent);