Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1151908ybs; Mon, 25 May 2020 08:20:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW9Q3hDSPNU4R96g9jNXEXGgNWjWoZRLjEPzygoHGIkau9IdIDauTUjFi8W29RMCq3MhYP X-Received: by 2002:a17:906:944e:: with SMTP id z14mr18594687ejx.86.1590420007801; Mon, 25 May 2020 08:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590420007; cv=none; d=google.com; s=arc-20160816; b=AsvCJzNUBNJkhvg/JqARslevbmmgFKqsg3cKRvpuulwYfcFYjeURegXcw32ZwnRUA1 YT39h3KyW4yr3r4PrdIDnIF/EwUZsp44/4etWkL4w972qSy86okeLUJvSL5VSUipNHGm g2HyZmmcmEyFmiZR+z2Ef5U2b4M0nEa29tXx63lkeYl4FGrY0cZjQlz2lOMzz1g/Rgo2 d6XsUtG52WU1FoSZBYwk9xTNcxy3Pza7fCVWtnBxClNdmElhNjYh8C3f1e7pGHkMgfvE 0L32GLnDe+Pztr79p8CFgKnC6EVSnvhW6MAY6lt50nVswvMAlLQCxAikM3yU4cgeVys7 Ubdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JgdxX2C74TdDmjeVY9HQN2a/yq7wOSbOdwxkkYCYXyQ=; b=ykbSrHS4kPaCaZNei3oQpAPSXo2KvF/+MZ6wyMDx8Qp71FjhcPU7wutkGjU1N6hckA EbRhf8pyPIFzH6Jm2XEpIT5l3tyfczLNTgN34Y2pUVxeAzcItK21NIsVv/FYcV3vV9MS ZBxcGWdWsdHcuTAC8l2CEgZA8wh/wcenjE69igvcuIfzw41h5bus2UNp9fJM6nE2dNbR HSzwkZdTMJkotxdjGk81o8QTHoeOBPZQSQh/DX5s2R4OkGfmB7rmkgnEaEXBaV/n3IvA Ykmw538JL1NEl/6kf55Iv3hO7a/kNG55unV1+RgQiN/iXGpEIFBlB5vS5CeJXRxdHynf ccTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N9adz5zO; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q25si8991901edw.313.2020.05.25.08.19.43; Mon, 25 May 2020 08:20:07 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N9adz5zO; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403996AbgEYPRn (ORCPT + 99 others); Mon, 25 May 2020 11:17:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390998AbgEYPRn (ORCPT ); Mon, 25 May 2020 11:17:43 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45459C061A0E; Mon, 25 May 2020 08:17:43 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id 131so561044pfv.13; Mon, 25 May 2020 08:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JgdxX2C74TdDmjeVY9HQN2a/yq7wOSbOdwxkkYCYXyQ=; b=N9adz5zOwkTSECpw8gScK2pWCHzS2JXKrK0SWR5uk5+0ARWhw5rdzsPascizMaKx5J Mi5jklMWhTLlXpSZWJPhU8KLwex4X+dJUT8dpDlpb5vwIcWUPbBNi3uz38tNQZKXPSX5 SLdsG+G5/FitBcp28xwyWZXm+CnuzG/428JvNVcXov2lVq3dd9vNC6mx7j1tgByf2SYl Op8bvijIDGefF5eWmo4yx5mh8TbKlHwdmi96W5eqaF3eZm/Wge/ZCZxL8nPIvXaNI19h iZMjs0rjfgJ+26iiQK02Hzvvxz9FcTe3qgtqTIkHEchq6EXIVJdjg6xv+6qe3WG/qfVl 7REg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=JgdxX2C74TdDmjeVY9HQN2a/yq7wOSbOdwxkkYCYXyQ=; b=b67OcIOQKKuPYSF99W6jaYxI8/D/XsC9D7komow8yw+8w4QUEursWOKJHA/Haz8yIY OOgKGknbvKsgeao86SQ5xVkVQfpFCjvZ8/+naknou0PZ91c7UOy2ryL3En2vcVowT8/o jVh+V2yz7VaJgDjDMvSXfzSSWrX+M+TdoRib9PHKdDEskj95PUDVFibm5MMGTsezyV4r 8b33dJM/lTWz0AIrXkm+kcJFMJRj/J++x/8jtPcUEz21D2ASlSHsdh/PH0JKTM7eFkS9 1sv8HoRKsDdnijPzWIcSpJlENfOaCxxyzlTG0xJjBfd31RD3JuJSQX3sS4uBpdRmzSMY /+kA== X-Gm-Message-State: AOAM5324RIA6JBslBR7EWctrWYHPOHvla2VdVLPOHoJlDBmetoMJqXY+ 2zk18GI8qEwMd2wQoNFCeLYh41CDbWA= X-Received: by 2002:aa7:9aa8:: with SMTP id x8mr16954629pfi.182.1590419862613; Mon, 25 May 2020 08:17:42 -0700 (PDT) Received: from sol (220-235-68-201.dyn.iinet.net.au. [220.235.68.201]) by smtp.gmail.com with ESMTPSA id k4sm5288767pfp.173.2020.05.25.08.17.39 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 May 2020 08:17:41 -0700 (PDT) Date: Mon, 25 May 2020 23:17:36 +0800 From: Kent Gibson To: Linus Walleij Cc: Bartosz Golaszewski , Hector Bujanda , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List Subject: Re: [PATCH] gpiolib: add GPIO_SET_DEBOUNCE_IOCTL Message-ID: <20200525151736.GA32461@sol> References: <20200419001858.105281-1-hector.bujanda@digi.com> <20200525022252.GA22956@sol> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 25, 2020 at 02:17:41PM +0200, Linus Walleij wrote: > On Mon, May 25, 2020 at 4:22 AM Kent Gibson wrote: > > > You mention timers for the gpio pins that cannot provide debounce, > > so I'm confused. Could you clarify which strategy you have in mind? > > My idea is that the callback gpiod_set_debounce() for in-kernel consumers > should more or less always return success. Either the hardware does > the debounce, or gpiolib sets up a timer. > > > I've also had a quick look at the possibility of providing the software > > debounce for in-kernel consumers. > > That is where I think it should start. > > > Are you anticipating new API for > > that? e.g. allowing consumers to request gpio events? Cos, gpio_keys > > grabs the irq itself - and that would bypass the software debouncer, > > or even conflict with it. > > It may be hard or impossible. > > I suppose gpiolib would have to steal or intercept the interrupt > by using e.g. IRQF_SHARED and then just return IRQ_HANDLED > on the first IRQ so the underlying irq handler does not get called. > And how would gpiolib ensure that it was first in the chain? > After the timer times out it needs to retrigger the IRQ. > > So the consuming driver would se a "debounced and ready" > IRQ so when it gets this IRQ it knows for sure there is > no bounciness on it because gpiolib already took care > of that. > > The above is in no way trivial, but it follows the design pattern > of "narrow and deep" APIs. > Totally agree with the concept - just trying to work out how to implement it seemlessly given the existing API and usage, and given my limited knowledge of the kernel internals. > Failure is an option! Sorry if I push too complex ideas. > I'm not as concerned about complexity as I am about fragility. I don't see any problem adding debounce for gpiolib-cdev. Adding a more complete solution to gpiolib itself is certainly non-trivial, if it is possible at all. The path I'll probably be taking is adding a debouncer to gpiolib-cdev, so at least we have a solution for userspace, then take a longer look at the more general solution. Cheers, Kent.