From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00B6FC433ED for ; Tue, 6 Apr 2021 08:37:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2E54613C3 for ; Tue, 6 Apr 2021 08:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244399AbhDFIhY (ORCPT ); Tue, 6 Apr 2021 04:37:24 -0400 Received: from muru.com ([72.249.23.125]:51394 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234953AbhDFIhY (ORCPT ); Tue, 6 Apr 2021 04:37:24 -0400 Received: from atomide.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 23EF180A4; Tue, 6 Apr 2021 08:38:23 +0000 (UTC) Date: Tue, 6 Apr 2021 11:37:07 +0300 From: Tony Lindgren To: Dmitry Torokhov Cc: Paul Cercueil , od@zcrc.me, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] input: gpio-keys: Use hrtimer for software debounce, if possible Message-ID: References: <20210307222240.380583-1-paul@crapouillou.net> <20210307222240.380583-3-paul@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, * Dmitry Torokhov [700101 02:00]: > On Sun, Mar 07, 2021 at 10:22:40PM +0000, Paul Cercueil wrote: > > We want to be able to report the input event as soon as the debounce > > delay elapsed. However, the current code does not really ensure that, > > as it uses the jiffies-based schedule_delayed_work() API. With a small > > enough HZ value (HZ <= 100), this results in some input events being > > lost, when a key is quickly pressed then released (on a human's time > > scale). > > > > Switching to hrtimers fixes this issue, and will work even on extremely > > low HZ values (tested at HZ=24). This is however only possible if > > reading the GPIO is possible without sleeping. If this condition is not > > met, the previous approach of using a jiffies-based timer is taken. > > > > Signed-off-by: Paul Cercueil > > Applied with minor edits to make more use of debounce_use_hrtimer flag. While testing Linux next I noticed that this patch causes a null pointer dereference at least when unbinding a gpio-keys instance, see below. Regards, Tony 8< ----------------- Unable to handle kernel NULL pointer dereference at virtual address 0000000c ... PC is at hrtimer_active+0xc/0x98 LR is at hrtimer_try_to_cancel+0x24/0x140 ... [] (hrtimer_active) from [] (hrtimer_try_to_cancel+0x24/0x140) [] (hrtimer_try_to_cancel) from [] (hrtimer_cancel+0x14/0x4c) [] (hrtimer_cancel) from [] (gpio_keys_attr_store_helper+0x1b8/0x1d8 [gpio_keys]) [] (gpio_keys_attr_store_helper [gpio_keys]) from [] (gpio_keys_store_disabled_keys+0x18/0x24 [gpio_keys]) [] (gpio_keys_store_disabled_keys [gpio_keys]) from [] (kernfs_fop_write_iter+0x10c/0x1cc) [] (kernfs_fop_write_iter) from [] (vfs_write+0x2ac/0x404) [] (vfs_write) from [] (ksys_write+0x64/0xdc) [] (ksys_write) from [] (ret_fast_syscall+0x0/0x58)