From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpcmd03117.aruba.it (smtpcmd03117.aruba.it [62.149.158.117]) (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 3E2344085A for ; Fri, 12 Apr 2024 06:47:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.149.158.117 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712904443; cv=none; b=fe1dJc/q4TSHuoL2psv4wB0d+CIaDqf1lvLKMdrvG983UCviQRscOSZz9s4mHnXGIPu9s84IYjWv5RYFUiVi7/JRF3/qvnDzm1ycZjr5ukbqFdKy3P6Bul8dqeRwinym1+yuFc9HVi6QLHmPQYMVT7sGwE8hjpAPwNbmcl4Ulu0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712904443; c=relaxed/simple; bh=WyC9PNxXS/aVAIKL5oIDw9u87fuWEC6J4MSR68MMGAg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=L69qhSKiFAMdlaEpRzBhR/dTJdvsy0W1tVCJqwbZfIC8m+6gv2aAKjyfq02h/+JiCK2txh8UNLLcX0SpzqqOYjQXR2t68vADnY5TRNbAn7qnmwu+Bz+VAx4CPs7RWiYpOQOzMVdKqMczGjaa5rPnVrSmqE6Awhmg5Wf/fA0Pic8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com; spf=pass smtp.mailfrom=enneenne.com; dkim=pass (2048-bit key) header.d=aruba.it header.i=@aruba.it header.b=QUPni0M9; arc=none smtp.client-ip=62.149.158.117 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enneenne.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=aruba.it header.i=@aruba.it header.b="QUPni0M9" Received: from [192.168.1.57] ([79.0.204.227]) by Aruba Outgoing Smtp with ESMTPSA id vAdsrE8KkQF1DvAdtre770; Fri, 12 Apr 2024 08:44:09 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1712904249; bh=WyC9PNxXS/aVAIKL5oIDw9u87fuWEC6J4MSR68MMGAg=; h=Date:MIME-Version:Subject:To:From:Content-Type; b=QUPni0M9weIIkUhjH94dlpYJX2G5U0niAyW1687kg5ZHZ2sYsqt9o21+502WUgO3F OXZOaihb12N76O9FnYSAXQI9lvs4r7l8xNfB4t9bqaA38anKU8JfIYWqKHkUeaFZqo atQCkeR9/XPcHpF3t7tWGLpSLwo33I1RcOZv/T357tblHHQZnb/IjXdJC/tgzSYu5W 1LL0MjxVLS1gEAitP8Iogfw30/z6YSQ1ImnqQIciovHjNOg3TH7rTWsgzUmDYeus8N Z8mECTFlyHk9QBk8Qqjpp22QVOEq/dbU6goShwcaRfUYqIzB3z/zpJ8aZS47UjQqLa waYypwbIcut2w== Message-ID: <9255124b-958e-4ab4-a812-67ad5d36e16d@enneenne.com> Date: Fri, 12 Apr 2024 08:44:08 +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: Bastien Curutchet 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> <5bda0980-2373-4284-bda4-89f0c6944e76@bootlin.com> <27196117-32bc-4892-b545-d9cf43a89f0a@bootlin.com> <28c5456d-535c-4ed9-b13a-fab7f50412be@bootlin.com> From: Rodolfo Giometti Content-Language: en-US, it, it-IT In-Reply-To: <28c5456d-535c-4ed9-b13a-fab7f50412be@bootlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfKB456YBgpqZ634JB5dUeyybZMVwsuXswVSVYhCb/VUND8r2xEhF5iSPw6RggeNGxEOctbMtAGW9qerebBZB1Afzf05oP6MgLrUj7bQSvPcktEvBrXAA W2nFtMwtaFDJF5Ulzb1sLAmquMPugbcQA7OvwM/7f0H4dvJXWRnXq08fmOC4+fAv0vvyAcNFO/Bdr2ydRZl0dTumjF+f3fUieGKiuStqPKyengfT5hSawCj5 jbQ9IsMZ6POTZPVls34udWv8bTJzac5xEJFsgn0rU0nxVFF3gBxK+NPtdDG0Lh4OWhQDDm0GAdh8GbbyyqlYav3GzLUjrMxiVJgSKPEn+mVvjtfdcnOJPCI0 LymDJgEKOwtX+UoMusQSdwrYGObTvA== On 11/04/24 14:44, Bastien Curutchet wrote: > Hi Rodolfo > >>>> diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c >>>> index 2f4b11b4dfcd..f05fb15ed7f4 100644 >>>> --- a/drivers/pps/clients/pps-gpio.c >>>> +++ b/drivers/pps/clients/pps-gpio.c >>>> @@ -52,7 +52,9 @@ static irqreturn_t pps_gpio_irq_handler(int irq, void *data) >>>> >>>>          info = data; >>>> >>>> -       rising_edge = gpiod_get_value(info->gpio_pin); >>>> +       rising_edge = info->capture_clear ? \ >>>> +                       gpiod_get_value(info->gpio_pin) : \ >>>> +                       !info->assert_falling_edge; >>>>          if ((rising_edge && !info->assert_falling_edge) || >>>>                          (!rising_edge && info->assert_falling_edge)) >>>>                  pps_event(info->pps, &ts, PPS_CAPTUREASSERT, data); >>>> >>>> Please, review and test it before resubmitting. :) >>>> >>> >>> I'll try this and send a V2 after my tests, thank you. >> >> OK, thanks. >> >> However we should think very well about this modification since it could be >> the case where we have a device sending both assert and clear events but we >> wish to catch just the asserts... in this case we will get doubled asserts! >> > > My understanding is that clear events are to be captured only when this > capture_clear boolean is set. If it is not set, the PPS_CAPTURECLEAR > flag is not added to pps_source_info->mode and get_irqf_trigger_flags() > will return only one edge flag (rising or falling depending on > assert-falling-edge DT property). Yes. You are right. > By the way, I see that the capture_clear is never set since the legacy > platform data support has been dropped (commit ee89646619ba). I see, but it can be re-enabled in the future... In this scenario, I think we should add a DT entry to enable this special behavior. Maybe we can also add a warning as below: static irqreturn_t pps_gpio_irq_handler(int irq, void *data) { ... if ((rising_edge && !info->assert_falling_edge) || (!rising_edge && info->assert_falling_edge)) pps_event(info->pps, &ts, PPS_CAPTUREASSERT, data); else if (info->capture_clear && ((rising_edge && info->assert_falling_edge) || (!rising_edge && !info->assert_falling_edge))) pps_event(info->pps, &ts, PPS_CAPTURECLEAR, data); else dev_warn_ratelimited(dev, "no ASSERT or CAPTURE event? " "Maybe you need support-tiny-assert-pulse?"); return IRQ_HANDLED; } Ciao, Rodolfo P.S. I'm sorry, but I'm not good at finding names... ^_^" -- GNU/Linux Solutions e-mail: giometti@enneenne.com Linux Device Driver giometti@linux.it Embedded Systems phone: +39 349 2432127 UNIX programming