Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp196724lqj; Wed, 10 Apr 2024 08:01:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUMvRYvuqwHjMqX4fTQrhx5KzQpe9kIAab534+UOber0kyVZ8cfKDiLunjaUhJqtYA0Vrv1De1xEUgKW9IUaFMa/nbmW3rEZg0nhvKM5w== X-Google-Smtp-Source: AGHT+IEDsif4pqKTX+/AzNwwvKPh7uun7tYrdIs+8AHBCk1+0r34lDXP8RSTUiUMFKzNPlqA5m8r X-Received: by 2002:a05:6512:558:b0:516:c1bf:8ddb with SMTP id h24-20020a056512055800b00516c1bf8ddbmr1814089lfl.66.1712761284418; Wed, 10 Apr 2024 08:01:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712761284; cv=pass; d=google.com; s=arc-20160816; b=SWvrbfh3Io36UpuG2sXH6ou63UlnB/ORO2EIXG6iyy/XibY34Hqk2Hw0V8aHz8oxNE c5m2KqNlFP9L7wC16ATFCqSTCBawE7x2AeIYqPDnVHhs+dYcLX2IPQujPv9FidTxy35q T5PtSc7B+tkY9UJUsfG3GU4z62QnbgxqZjmINT7gp6QvTa89Nhrfu9WAOwlLxETTZlpD FzbbqM6uNMkblcnu+3Hkg/CWWGKNphpyCUBgXUlme9DEDRHdS8Sy4otv7/YcgqeMDZZu sPcR7d9O+2JYNkBg01Lw/94F60tNHrsj8uAx/yh6g6J+ILTgfzVRnBrdXVCcvmBaRPEc /g5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=j65IjvQWYnnx1L9dvrx1w/98kN+MLSREHb32zvuuNKg=; fh=tfFaZzpi9p9fRg2PuA3g6757Ibpmo+WpSVLzgfvL2VA=; b=IZmt8Q3iLWnrmMbm/ZCKAX55uiSi5SJm9e+zXzGhSAZbZBPsTNjLefS0NAXVZXJ3FN u/U2phQpAft6kQfe6a3VD0Vj584Fjt6P6lZwlIyLpNRw9qpca9dNduTLcjihIcfvGrXg nBUq4KZltQopjeI1vu0xJRjUqC6iA29QlJVBf/sTSLEDseeQeyoPWZsry4NYfq5z8UPt 4W+Zj4COD9mXP9I+KWeIHLv4bT5N2OvcwJQAWCE4bBaFru/EYNKcN23NYRgv1QRuqrL3 SmhWLeqX05l/sa+VRFdA1o71teKNWGjAny6xQjVDqbnc2gT+kqhoA0q2g5W/a5wU69v0 9qaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dWURWtYX; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-138804-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138804-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g22-20020a0564021ed600b0056e51b954desi4084337edg.542.2024.04.10.08.01.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 08:01:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138804-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dWURWtYX; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-138804-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138804-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C63DD1F305DF for ; Wed, 10 Apr 2024 14:52:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B0F917554C; Wed, 10 Apr 2024 14:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dWURWtYX" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7089916C85A for ; Wed, 10 Apr 2024 14:46:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712760386; cv=none; b=c61NRS90be7KcDw5GfL0EWByfk+QVk57VBVHgpOhs2ItE/+elZcNC2T6MFLuVG9/u2Z4o1X3MPShEy1oFot1m+tDF9TODmgZDtn+V0A47in/s0Cq1Xm21CC5apz+QzX7FkSJ63i4CyvHEJLz2R0A9Q040G8Ddz/epuA4Hpqmnq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712760386; c=relaxed/simple; bh=7V6t7G9R/j8SfQ17SSxxvRlFWUnNIt2VQiFHcCwuQlk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=V2JxU1YT/sP+UT/jdwVrxeK08LnAKzJhLvXACS2vIWK/smtMc0A8BjabNv2tcxd9sSE1Tia9WZ6QA22/4kphkFvVhaCKcHfTqUdw5tz8LFBEBWbeTyODbAHSQF5yeSCjOo7l31Xf4yclHYobXsQKHtGMFeFKQAz/kNj+FLFhsGs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dWURWtYX; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 0311B1BF20A; Wed, 10 Apr 2024 14:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712760376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j65IjvQWYnnx1L9dvrx1w/98kN+MLSREHb32zvuuNKg=; b=dWURWtYX8/wsDFDFtmJkcNR7t7zwKiKybpsZHUrUN8gTZzaiupwJBL/GU0OL5WxFp2uJpJ QDd/NKp/FS2qtTMIKSezO3WFWzjOT89GxNdgCG670xnKmn/MAB4Nek/tn3y0DkuEn6bhIS C3VVmS6YJ6iQAK5GE5KV4PVbS72DO/M2SSoOp/Wselq6QVqPya7JDnUM7qgWuO9GclX5QQ H4D1lHaPQpF1bP6e7qV4xsf0atNsCKQDQzFQf5Q0y7BvhvbQu23KlsVKsydxnqJb4Yi2ah JKU76pu5wpg/iz28FOvFEXz6WIaXKCamXfMtu8R7vimcx9GwTcwlfrUeCApgZQ== Message-ID: <5bda0980-2373-4284-bda4-89f0c6944e76@bootlin.com> Date: Wed, 10 Apr 2024 16:46:15 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] pps: clients: gpio: Bypass edge's direction check when not needed To: Rodolfo Giometti Cc: linux-kernel@vger.kernel.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca References: <20240410113502.73038-1-bastien.curutchet@bootlin.com> <1f7f5b2f-54d4-4dc1-90ff-b896c930faed@enneenne.com> Content-Language: en-US From: Bastien Curutchet In-Reply-To: <1f7f5b2f-54d4-4dc1-90ff-b896c930faed@enneenne.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Sasl: bastien.curutchet@bootlin.com Hi Rodolfo, On 4/10/24 16:23, Rodolfo Giometti wrote: > On 10/04/24 13:35, Bastien Curutchet wrote: >> In the IRQ handler, the GPIO's state is read to verify the direction of >> the edge that triggered the interruption before generating the PPS event. >> If a pulse is too short, the GPIO line can reach back its original state >> before this verification and the PPS event is lost. >> >> This check is needed when info->capture_clear is set because it needs >> interruptions on both rising and falling edges. When info->capture_clear >> is not set, interruption is triggered by one edge only so this check can >> be omitted. >> >> Bypass the edge's direction verification when info->capture_clear is not >> set. >> >> Signed-off-by: Bastien Curutchet >> --- >>   drivers/pps/clients/pps-gpio.c | 9 +++++++++ >>   1 file changed, 9 insertions(+) >> >> diff --git a/drivers/pps/clients/pps-gpio.c >> b/drivers/pps/clients/pps-gpio.c >> index 2f4b11b4dfcd..c2a96e3e3836 100644 >> --- a/drivers/pps/clients/pps-gpio.c >> +++ b/drivers/pps/clients/pps-gpio.c >> @@ -52,6 +52,15 @@ static irqreturn_t pps_gpio_irq_handler(int irq, >> void *data) >>       info = data; >> +    if (!info->capture_clear) { >> +        /* >> +         * If capture_clear is unset, IRQ is triggered by one edge only. >> +         * So the check on edge direction is not needed here >> +         */ >> +        pps_event(info->pps, &ts, PPS_CAPTUREASSERT, data); >> +        return IRQ_HANDLED; >> +    } >> + >>       rising_edge = gpiod_get_value(info->gpio_pin); >>       if ((rising_edge && !info->assert_falling_edge) || >>               (!rising_edge && info->assert_falling_edge)) > > Apart the code duplication, which are the real benefits of doing so? > It prevents from losing a PPS event when the pulse is so short (or the kernel so busy) that the trailing edge of the pulse occurs before the interrupt handler can read the state of the GPIO pin. Best regards, Bastien