All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@siemens.com>, xenomai@xenomai.org
Subject: Re: [PATCH 02/12] drivers/gpio: provide optional timestamped readouts
Date: Fri, 25 Jan 2019 10:38:29 +0100	[thread overview]
Message-ID: <1215ea5d-5ba7-348e-20b9-7d46cc77c183@xenomai.org> (raw)
In-Reply-To: <214e962e-f725-f056-7153-7225b21a4112@siemens.com>

On 1/25/19 10:33 AM, Jan Kiszka wrote:
> On 25.01.19 10:31, Philippe Gerum wrote:
>> On 1/25/19 10:23 AM, Jan Kiszka wrote:
>>> On 25.01.19 10:15, Philippe Gerum wrote:
>>>> On 1/24/19 7:17 PM, Jan Kiszka wrote:
>>>>> On 24.01.19 16:34, Philippe Gerum wrote:
>>>>>> In timestamping mode, read() returns the timestamp of the latest
>>>>>> event
>>>>>> receipt on the pin based on CLOCK_MONOTONIC, along with the pin
>>>>>> state. This is an optional pin readout mode controlled by the
>>>>>> GPIO_RTIOC_TS request, e.g.:
>>>>>>
>>>>>> struct rtdm_gpio_readout rdo;
>>>>>> int ret, on, val;
>>>>>>
>>>>>> on = 1;
>>>>>> ret = ioctl(pinfd, GPIO_RTIOC_TS, &on);
>>>>>> ret = read(pinfd, &rdo, sizeof(rdo));
>>>>>> /* pin state changed to rdo.value at time rdo.timestamp */
>>>>>>
>>>>>> on = 0;
>>>>>> ret = ioctl(pinfd, GPIO_RTIOC_TS, &on);
>>>>>> ret = read(pinfd, &val, sizeof(val));
>>>>>> /* pin state changed to value (time of change unspecified) */
>>>>>>
>>>>>> By default, timestamping mode is disabled, which corresponds to the
>>>>>> original behavior.
>>>>>>
>>>>>> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
>>>>>> ---
>>>>>>     include/cobalt/kernel/rtdm/gpio.h |  1 +
>>>>>>     include/rtdm/uapi/gpio.h          | 18 +++++++----
>>>>>>     kernel/drivers/gpio/gpio-core.c   | 54
>>>>>> +++++++++++++++++++++++--------
>>>>>>     3 files changed, 54 insertions(+), 19 deletions(-)
>>>>>>
>>>>>> diff --git a/include/cobalt/kernel/rtdm/gpio.h
>>>>>> b/include/cobalt/kernel/rtdm/gpio.h
>>>>>> index cdb472f8a..00055ec0a 100644
>>>>>> --- a/include/cobalt/kernel/rtdm/gpio.h
>>>>>> +++ b/include/cobalt/kernel/rtdm/gpio.h
>>>>>> @@ -33,6 +33,7 @@ struct rtdm_gpio_pin {
>>>>>>         rtdm_event_t event;
>>>>>>         char *name;
>>>>>>         struct gpio_desc *desc;
>>>>>> +    nanosecs_abs_t timestamp;
>>>>>>     };
>>>>>>       struct rtdm_gpio_chip {
>>>>>> diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h
>>>>>> index b745f156c..ac14be66c 100644
>>>>>> --- a/include/rtdm/uapi/gpio.h
>>>>>> +++ b/include/rtdm/uapi/gpio.h
>>>>>> @@ -18,12 +18,18 @@
>>>>>>     #ifndef _RTDM_UAPI_GPIO_H
>>>>>>     #define _RTDM_UAPI_GPIO_H
>>>>>>     -#define GPIO_RTIOC_DIR_OUT        _IOW(RTDM_CLASS_GPIO, 0, int)
>>>>>> -#define GPIO_RTIOC_DIR_IN        _IO(RTDM_CLASS_GPIO, 1)
>>>>>> -#define GPIO_RTIOC_IRQEN        _IOW(RTDM_CLASS_GPIO, 2, int) /*
>>>>>> GPIO
>>>>>> trigger */
>>>>>> -#define GPIO_RTIOC_IRQDIS        _IO(RTDM_CLASS_GPIO, 3)
>>>>>> -#define GPIO_RTIOC_REQS                _IO(RTDM_CLASS_GPIO, 4)
>>>>>> -#define GPIO_RTIOC_RELS                _IO(RTDM_CLASS_GPIO, 5)
>>>>>> +struct rtdm_gpio_readout {
>>>>>> +    __u64 timestamp;
>>>>>
>>>>> nanosecs_abs_t - we use this type also in to userspace interface.
>>>>>
>>>>
>>>> Nope. This is ABI stuff, nanosecs_abs_t is not guaranteed to have the
>>>> same size regardless of the ABI models, which is unsafe in mixed 32/64
>>>> model configurations. OTOH, __u64 is safe.
>>>
>>> If nanosecs_abs_t is alread an ABI, and it is used as such for a long
>>> time (see include/rtdm/uapi/serial.h). If you see a bug in its
>>> definition, that needs to be fixed. We should not resolve that by
>>> choosing open-coded local workarounds.
>>>
>>
>> nanosecs_t is not defined in the Xenomai ABI, never has been. Using
>> nanosecs_t in structs actually abuses such ABI. So we may either keep
>> adding even more nanosecs, or fix the spots where it should be replaced
>> with __u64.
> 
> Xenomai ABI includes the driver ABI - so your assumption might have been
> it's not while it was de facto.
> 
> Again, let's address the issue, not work around it.
> 

__u64 is the fix, using nanosecs*_t in uapi/ is wrong. So please merge
this fix, and we'll see how we can progress fixing other abuses.

-- 
Philippe.


  reply	other threads:[~2019-01-25  9:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-24 15:34 [PATCH 00/12] Assorted updates: RTnet, GPIO, smokey tests Philippe Gerum
2019-01-24 15:34 ` [PATCH 01/12] testsuite/smokey: posix_clock: prevent false positive in time-dependent test Philippe Gerum
2019-01-24 15:34 ` [PATCH 02/12] drivers/gpio: provide optional timestamped readouts Philippe Gerum
2019-01-24 18:17   ` Jan Kiszka
2019-01-25  9:15     ` Philippe Gerum
2019-01-25  9:23       ` Jan Kiszka
2019-01-25  9:31         ` Philippe Gerum
2019-01-25  9:33           ` Jan Kiszka
2019-01-25  9:38             ` Philippe Gerum [this message]
2019-01-25  9:48               ` Jan Kiszka
2019-01-25 10:11                 ` Philippe Gerum
2019-01-25 11:32                   ` Jan Kiszka
2019-01-25 11:42                     ` Philippe Gerum
2019-01-25 13:46                       ` Jan Kiszka
2019-01-24 15:34 ` [PATCH 03/12] testsuite/gpiotest: enable timestamping on 'timestamp' argument Philippe Gerum
2019-01-24 15:34 ` [PATCH 04/12] net/stack: allow initializing pre-allocated device structs Philippe Gerum
2019-01-24 15:34 ` [PATCH 05/12] net/stack: fresh rtskb should have ip_summed set to CHECKSUM_NONE Philippe Gerum
2019-01-24 18:21   ` Jan Kiszka
2019-01-25  9:26     ` Philippe Gerum
2019-01-24 15:34 ` [PATCH 06/12] net/rtdev: ensure per-device skbs get mapped at registration Philippe Gerum
2019-01-24 18:24   ` Jan Kiszka
2019-02-06  9:02     ` Philippe Gerum
2019-02-06  9:08       ` Jan Kiszka
2019-02-06  9:47         ` Philippe Gerum
2019-01-24 15:34 ` [PATCH 07/12] net/udp: getfrag: fix frag preparation status Philippe Gerum
2019-01-24 15:34 ` [PATCH 08/12] net/udp: getfrag: remove direct reference to user memory Philippe Gerum
2019-01-24 15:34 ` [PATCH 09/12] testsuite/smokey: net: do not unload pre-loaded modules Philippe Gerum
2019-01-24 15:34 ` [PATCH 10/12] testsuite/smokey: net: do not down a previously running test interface Philippe Gerum
2019-01-24 15:34 ` [PATCH 11/12] net/stack: rtskb: do not run nop locking calls Philippe Gerum
2019-01-24 15:34 ` [PATCH 12/12] testsuite/smokey: net_client: improve stats readability Philippe Gerum
2019-01-24 18:10 ` [PATCH 00/12] Assorted updates: RTnet, GPIO, smokey tests Jan Kiszka
2019-01-25  9:12   ` Philippe Gerum
2019-01-25  9:20     ` Jan Kiszka

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=1215ea5d-5ba7-348e-20b9-7d46cc77c183@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=jan.kiszka@siemens.com \
    --cc=xenomai@xenomai.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.