From: Kent Gibson <warthog618@gmail.com>
To: Dipen Patel <dipenp@nvidia.com>
Cc: thierry.reding@gmail.com, jonathanh@nvidia.com,
linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-gpio@vger.kernel.org, linus.walleij@linaro.org,
brgl@bgdev.pl, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, robh+dt@kernel.org
Subject: Re: [RFC v3 09/12] gpiolib: cdev: Add hardware timestamp clock type
Date: Thu, 9 Dec 2021 06:28:43 +0800 [thread overview]
Message-ID: <20211208222843.GA5029@sol> (raw)
In-Reply-To: <395ba111-d620-f302-d0e7-8f20f39e6485@nvidia.com>
On Tue, Dec 07, 2021 at 05:42:35PM -0800, Dipen Patel wrote:
>
> On 12/1/21 4:53 PM, Kent Gibson wrote:
> > On Wed, Dec 01, 2021 at 10:01:46AM -0800, Dipen Patel wrote:
> >> Hi,
> >>
> >>
> >> On 12/1/21 9:16 AM, Kent Gibson wrote:
> >>> On Tue, Nov 30, 2021 at 07:29:20PM -0800, Dipen Patel wrote:
> >>>> Hi,
> >>>>
> >>>> On 11/25/21 5:31 PM, Kent Gibson wrote:
> >>>>> On Tue, Nov 23, 2021 at 11:30:36AM -0800, Dipen Patel wrote:
> >>>>>> This patch adds new clock type for the GPIO controller which can
> >>>>>> timestamp gpio lines in realtime using hardware means. To expose such
> >>>>>> functionalities to the userspace, code has been added in this patch
> >>>>>> where during line create call, it checks for new clock type and if
> >>>>>> requested, calls hardware timestamp related API from gpiolib.c.
> >>>>>> During line change event, the HTE subsystem pushes timestamp data
> >>>>>> through callbacks.
> >>>>>>
> >>>>>> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
> >>>>>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> >>>>>> ---
> >>>>>> Changes in v2:
> >>>>>> - Added hte_dir and static structure hte_ts_desc.
> >>>>>> - Added callbacks which get invoked by HTE when new data is available.
> >>>>>> - Better use of hte_dir and seq from hte_ts_desc.
> >>>>>> - Modified sw debounce function to accommodate hardware timestamping.
> >>>>>>
> >>>>>> drivers/gpio/gpiolib-cdev.c | 161 ++++++++++++++++++++++++++++++++++--
> >>>>>> include/uapi/linux/gpio.h | 1 +
> >>>>>> 2 files changed, 153 insertions(+), 9 deletions(-)
> >>>>>>
> >>>>>> diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> >>>>>> index c7b5446d01fd..1736ad54e3ec 100644
> >>>>>> --- a/drivers/gpio/gpiolib-cdev.c
> >>>>>> +++ b/drivers/gpio/gpiolib-cdev.c
> >>>>>> @@ -464,6 +464,12 @@ struct line {
> >>>>>> * stale value.
> >>>>>> */
> >>>>>> unsigned int level;
> >>>>>> + /*
> >>>>>> + * dir will be touched in HTE callbacks hte_ts_cb_t and
> >>>>>> + * hte_ts_threaded_cb_t and they are mutually exclusive. This will be
> >>>>>> + * unused when HTE is not supported/disabled.
> >>>>>> + */
> >>>>>> + enum hte_dir dir;
> >>>>>> };
> >>>>>>
> >>>>> Documentation should be in present tense, so
> >>>>>
> >>>>> s/will be/is/g
> >>>>>
> >>>>> Same applies to other patches.
> >>>>>
> >>>>> Also
> >>>>>
> >>>>> s/touched/accessed/
> >>>>>
> >>>>> dir is a poor name for the field. It is the hte edge direction and
> >>>>> effectively the line level, so call it hte_edge_dirn or
> >>>>> hte_edge_direction or hte_level.
> >>>>>
> >>>>> And it is placed in a section of the struct documented as "debouncer specific
> >>>>> fields", but it is not specfic to the debouncer. Add a "hte specific
> >>>>> fields" section if nothing else is suitable.
> >>>>>
> >>>>>> /**
> >>>>>> @@ -518,6 +524,7 @@ struct linereq {
> >>>>>> GPIO_V2_LINE_DRIVE_FLAGS | \
> >>>>>> GPIO_V2_LINE_EDGE_FLAGS | \
> >>>>>> GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME | \
> >>>>>> + GPIO_V2_LINE_FLAG_EVENT_CLOCK_HARDWARE | \
> >>>>>> GPIO_V2_LINE_BIAS_FLAGS)
> >>>>>>
> >>>>>> static void linereq_put_event(struct linereq *lr,
> >>>>>> @@ -546,6 +553,94 @@ static u64 line_event_timestamp(struct line *line)
> >>>>>> return ktime_get_ns();
> >>>>>> }
> >>>>>>
> >>>>>> +static hte_return_t process_hw_ts_thread(void *p)
> >>>>>> +{
> >>>>>> + struct line *line = p;
> >>>>>> + struct linereq *lr = line->req;
> >>>>>> + struct gpio_v2_line_event le;
> >>>>>> + u64 eflags;
> >>>>>> +
> >>>>>> + memset(&le, 0, sizeof(le));
> >>>>>> +
> >>>>>> + le.timestamp_ns = line->timestamp_ns;
> >>>>>> + line->timestamp_ns = 0;
> >>>>>> +
> >>>>> What is the purpose of this zeroing?
> >>>>>
> >>>>>> + if (line->dir >= HTE_DIR_NOSUPP) {
> >>>>>> + eflags = READ_ONCE(line->eflags);
> >>>>>> + if (eflags == GPIO_V2_LINE_FLAG_EDGE_BOTH) {
> >>>>>> + int level = gpiod_get_value_cansleep(line->desc);
> >>>>>> +
> >>>>>> + if (level)
> >>>>>> + /* Emit low-to-high event */
> >>>>>> + le.id = GPIO_V2_LINE_EVENT_RISING_EDGE;
> >>>>>> + else
> >>>>>> + /* Emit high-to-low event */
> >>>>>> + le.id = GPIO_V2_LINE_EVENT_FALLING_EDGE;
> >>>>>> + } else if (eflags == GPIO_V2_LINE_FLAG_EDGE_RISING) {
> >>>>>> + /* Emit low-to-high event */
> >>>>>> + le.id = GPIO_V2_LINE_EVENT_RISING_EDGE;
> >>>>>> + } else if (eflags == GPIO_V2_LINE_FLAG_EDGE_FALLING) {
> >>>>>> + /* Emit high-to-low event */
> >>>>>> + le.id = GPIO_V2_LINE_EVENT_FALLING_EDGE;
> >>>>>> + } else {
> >>>>>> + return HTE_CB_ERROR;
> >>>>>> + }
> >>>>>> + } else {
> >>>>>> + if (line->dir == HTE_RISING_EDGE_TS)
> >>>>>> + le.id = GPIO_V2_LINE_EVENT_RISING_EDGE;
> >>>>>> + else
> >>>>>> + le.id = GPIO_V2_LINE_EVENT_FALLING_EDGE;
> >>>>>> + }
> >>>>> The mapping from line->dir to le.id needs to take into account the active
> >>>>> low setting for the line.
> >>>>>
> >>>>> And it might be simpler if the hte_ts_data provided the level, equivalent
> >>>>> to gpiod_get_raw_value_cansleep(), rather than an edge direction, so you
> >>>>> can provide a common helper to determine the edge given the raw level.
> >>>> (So from the level determine the edge?) that sound right specially when
> >>>>
> >>>> HTE provider has capability to record the edge in that case why bother
> >>>>
> >>>> getting the level and determine edge?
> >>>>
> >>>> Calculating the edge from the level makes sense when hte provider does not
> >>>>
> >>>> have that feature and that is what if (line->dir >= HTE_DIR_NOSUPP) does.
> >>>>
> >>> As asked in the review of patch 02, do you have an example of hardware that
> >>> reports an edge direction rather than NOSUPP?
> >> No...
> > So you are adding an interface that nothing will currently use.
> > Are there plans for hardware that will report the edge, and you are
> > laying the groundwork here?
>
> Adding here for the general case should there be provider
>
> available with such feature.
>
Then you are adding dead code, and you should remove that aspect of your
interface until you have hardware that does support it.
Cheers,
Kent.
next prev parent reply other threads:[~2021-12-08 22:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-23 19:30 [RFC v3 00/12] Intro to Hardware timestamping engine Dipen Patel
2021-11-23 19:30 ` [RFC v3 01/12] Documentation: Add HTE subsystem guide Dipen Patel
2021-11-23 19:30 ` [RFC v3 02/12] drivers: Add hardware timestamp engine (HTE) Dipen Patel
2021-11-26 1:30 ` Kent Gibson
2021-12-08 0:36 ` Dipen Patel
2021-12-08 1:21 ` Kent Gibson
2021-12-08 1:59 ` Dipen Patel
2021-11-23 19:30 ` [RFC v3 03/12] hte: Add tegra194 HTE kernel provider Dipen Patel
2021-11-24 0:45 ` Randy Dunlap
2021-11-23 19:30 ` [RFC v3 04/12] dt-bindings: Add HTE bindings Dipen Patel
2021-11-24 2:59 ` Rob Herring
2021-11-23 19:30 ` [RFC v3 05/12] hte: Add Tegra194 IRQ HTE test driver Dipen Patel
2021-11-23 19:30 ` [RFC v3 06/12] gpiolib: Add HTE support Dipen Patel
2021-11-26 1:31 ` Kent Gibson
2021-11-23 19:30 ` [RFC v3 07/12] dt-bindings: gpio: Add hardware-timestamp-engine property Dipen Patel
2021-11-30 22:32 ` Rob Herring
2021-11-23 19:30 ` [RFC v3 08/12] gpio: tegra186: Add HTE in gpio-tegra186 driver Dipen Patel
2021-11-23 19:30 ` [RFC v3 09/12] gpiolib: cdev: Add hardware timestamp clock type Dipen Patel
2021-11-26 1:31 ` Kent Gibson
2021-12-01 3:29 ` Dipen Patel
2021-12-01 17:16 ` Kent Gibson
2021-12-01 18:01 ` Dipen Patel
2021-12-02 0:53 ` Kent Gibson
2021-12-03 23:24 ` Dipen Patel
2021-12-08 1:42 ` Dipen Patel
2021-12-08 20:14 ` Dipen Patel
2021-12-08 22:24 ` Kent Gibson
2021-12-08 22:28 ` Kent Gibson [this message]
2022-01-05 23:00 ` Dipen Patel
2021-12-01 17:18 ` Dipen Patel
2021-11-23 19:30 ` [RFC v3 10/12] tools: gpio: Add new hardware " Dipen Patel
2021-11-23 19:30 ` [RFC v3 11/12] hte: Add tegra GPIO HTE test driver Dipen Patel
2021-11-23 19:30 ` [RFC v3 12/12] MAINTAINERS: Added HTE Subsystem Dipen Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211208222843.GA5029@sol \
--to=warthog618@gmail.com \
--cc=brgl@bgdev.pl \
--cc=devicetree@vger.kernel.org \
--cc=dipenp@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).