Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4199550pxf; Tue, 6 Apr 2021 10:11:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSw4gvgqRCwevZF4Y5GKDOrRO+Hw4BZRWz++4kp+ImuNjTMsSmFTh16vmFjb+bvHE9v8D/ X-Received: by 2002:a92:da88:: with SMTP id u8mr830580iln.241.1617729071597; Tue, 06 Apr 2021 10:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617729071; cv=none; d=google.com; s=arc-20160816; b=XAOakKrBr6ikMtFrv9EYgX6Va24r8n7ezW496cC2+kt0vK605mJZoxcLDx4dsbwYxp vfsvaGRb6oNFKFqP12kKaJpxFLBYIA4JVJObi1XzOjAyrLdC1zLY/7YTV7+noSTyyEJz gA5yRrYisjAbBmmVZqNLOjnwS9vTdTOYC1SY6fFNgnYyV4u9rE1kmdhlLUkKru5ZlbM3 sVUXxeyr81NHIILMvY4rN9lv1toowkGkF6KQKg9UaUMmovJbi/sUVqbHIiMMckCqe8AN l8XvAQ3I6JJ2VpvZqPd02AuBJ9T5logXwgBeUEs+c2lze5KndI9tanyIWs/ONGIVPySs iEtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=eTS7s3Q4PVFVR2xfV4M4LcPu68fXiTC0H2SA49gmnzg=; b=jcXm5d0y84d5wTth8R/NyM+P9G2KWMG4ezXtPnUubAopIfR97jjls5LBAr18dxMJf4 0iasbcOgVJdTlUM5bG+iHCiU9/ZSc7Nkc9cELb9Z1stf7z+BbPwyoS/JQ12k3o96bwtg 7IlYMNt9ZUpgO9mf7Iy5Gd349tTwXQfX6v1GvgXugIBBCzfaX7MyOeqiYQSK9V3VvSYT M8QF0Tsc7TxRVmcLkjtg7jXZkeaSnZ4gvzGova/hRprXQVgy23Pe3IYJPrbUD8z9Sfsc oQqhWYCzo0Tg2XBdcGDi50wq4rzifG+QwkzIl2gHzdXymWiOyYEjFzwel6UiNR/nZcPR OoDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si18900914jav.63.2021.04.06.10.10.59; Tue, 06 Apr 2021 10:11:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244395AbhDFIhY (ORCPT + 99 others); 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)