History

gpiolib: cdev: allow edge event timestamps to be configured as REALTIME

Using CLOCK_REALTIME as the source for event timestamps is crucial for some specific applications, particularly those requiring timetamps relative to a PTP clock, so provide an option to switch the event timestamp source from the default CLOCK_MONOTONIC to CLOCK_REALTIME. Note that CLOCK_REALTIME was the default source clock for GPIO until Linux 5.7 when it was changed to CLOCK_MONOTONIC due to issues with the shifting of the realtime clock. Providing this option maintains the CLOCK_MONOTONIC as the default, while also providing a path forward for those dependent on the pre-5.7 behaviour.

Kent Gibson committed 6 years ago

Commit 26d060e1 parent 93224ed3 files · +28 −6Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/gpio.h+9−3
@@ -65,6 +65,7 @@ struct gpiochip_info { · 64 unmodified lines
6565 * @GPIO_V2_LINE_FLAG_BIAS_PULL_UP: line has pull-up bias enabled
6666 * @GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN: line has pull-down bias enabled
6767 * @GPIO_V2_LINE_FLAG_BIAS_DISABLED: line has bias disabled
68+ * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME: line events contain REALTIME timestamps
6869 */
6970 enum gpio_v2_line_flag {
7071 GPIO_V2_LINE_FLAG_USED = _BITULL(0),
@@ -78,6 +79,7 @@ enum gpio_v2_line_flag { · 7 unmodified lines
7879 GPIO_V2_LINE_FLAG_BIAS_PULL_UP = _BITULL(8),
7980 GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = _BITULL(9),
8081 GPIO_V2_LINE_FLAG_BIAS_DISABLED = _BITULL(10),
82+ GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME = _BITULL(11),
8183 };
8284
8385 /**
@@ -270,9 +272,6 @@ enum gpio_v2_line_event_id { · 186 unmodified lines
270272 /**
271273 * struct gpio_v2_line_event - The actual event being pushed to userspace
272274 * @timestamp_ns: best estimate of time of event occurrence, in nanoseconds.
273− * The @timestamp_ns is read from %CLOCK_MONOTONIC and is intended to allow
274− * the accurate measurement of the time between events. It does not provide
275− * the wall-clock time.
276275 * @id: event identifier with value from &enum gpio_v2_line_event_id
277276 * @offset: the offset of the line that triggered the event
278277 * @seqno: the sequence number for this event in the sequence of events for
@@ -280,6 +279,13 @@ enum gpio_v2_line_event_id { · 1 unmodified line
280279 * @line_seqno: the sequence number for this event in the sequence of
281280 * events on this particular line
282281 * @padding: reserved for future use
282+ *
283+ * By default the @timestamp_ns is read from %CLOCK_MONOTONIC and is
284+ * intended to allow the accurate measurement of the time between events.
285+ * It does not provide the wall-clock time.
286+ *
287+ * If the %GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME flag is set then the
288+ * @timestamp_ns is read from %CLOCK_REALTIME.
283289 */
284290 struct gpio_v2_line_event {
285291 __aligned_u64 timestamp_ns;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t