2019-05-20 10:19:02 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-04-22 14:03:08 +04:00
|
|
|
/*
|
|
|
|
* PTP 1588 clock support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 OMICRON electronics GmbH
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _PTP_CLOCK_KERNEL_H_
|
|
|
|
#define _PTP_CLOCK_KERNEL_H_
|
|
|
|
|
2012-09-22 11:02:03 +04:00
|
|
|
#include <linux/device.h>
|
2012-09-03 14:34:58 +04:00
|
|
|
#include <linux/pps_kernel.h>
|
2011-04-22 14:03:08 +04:00
|
|
|
#include <linux/ptp_clock.h>
|
|
|
|
|
|
|
|
|
|
|
|
struct ptp_clock_request {
|
|
|
|
enum {
|
|
|
|
PTP_CLK_REQ_EXTTS,
|
|
|
|
PTP_CLK_REQ_PEROUT,
|
|
|
|
PTP_CLK_REQ_PPS,
|
|
|
|
} type;
|
|
|
|
union {
|
|
|
|
struct ptp_extts_request extts;
|
|
|
|
struct ptp_perout_request perout;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-02-22 14:15:25 +03:00
|
|
|
struct system_device_crosststamp;
|
2018-11-09 13:14:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct ptp_system_timestamp - system time corresponding to a PHC timestamp
|
|
|
|
*/
|
|
|
|
struct ptp_system_timestamp {
|
|
|
|
struct timespec64 pre_ts;
|
|
|
|
struct timespec64 post_ts;
|
|
|
|
};
|
|
|
|
|
2011-04-22 14:03:08 +04:00
|
|
|
/**
|
2020-05-02 06:35:36 +03:00
|
|
|
* struct ptp_clock_info - describes a PTP hardware clock
|
2011-04-22 14:03:08 +04:00
|
|
|
*
|
|
|
|
* @owner: The clock driver should set to THIS_MODULE.
|
2012-09-22 11:02:04 +04:00
|
|
|
* @name: A short "friendly name" to identify the clock and to
|
|
|
|
* help distinguish PHY based devices from MAC based ones.
|
|
|
|
* The string is not meant to be a unique id.
|
2011-04-22 14:03:08 +04:00
|
|
|
* @max_adj: The maximum possible frequency adjustment, in parts per billon.
|
|
|
|
* @n_alarm: The number of programmable alarms.
|
|
|
|
* @n_ext_ts: The number of external time stamp channels.
|
|
|
|
* @n_per_out: The number of programmable periodic signals.
|
2014-03-21 01:21:52 +04:00
|
|
|
* @n_pins: The number of programmable pins.
|
2011-04-22 14:03:08 +04:00
|
|
|
* @pps: Indicates whether the clock supports a PPS callback.
|
2014-03-21 01:21:52 +04:00
|
|
|
* @pin_config: Array of length 'n_pins'. If the number of
|
|
|
|
* programmable pins is nonzero, then drivers must
|
|
|
|
* allocate and initialize this array.
|
2011-04-22 14:03:08 +04:00
|
|
|
*
|
|
|
|
* clock operations
|
|
|
|
*
|
2016-11-09 00:49:16 +03:00
|
|
|
* @adjfine: Adjusts the frequency of the hardware clock.
|
|
|
|
* parameter scaled_ppm: Desired frequency offset from
|
|
|
|
* nominal frequency in parts per million, but with a
|
|
|
|
* 16 bit binary fractional field.
|
|
|
|
*
|
2011-04-22 14:03:08 +04:00
|
|
|
* @adjfreq: Adjusts the frequency of the hardware clock.
|
2016-11-09 00:49:16 +03:00
|
|
|
* This method is deprecated. New drivers should implement
|
|
|
|
* the @adjfine method instead.
|
2012-11-01 16:30:16 +04:00
|
|
|
* parameter delta: Desired frequency offset from nominal frequency
|
|
|
|
* in parts per billion
|
2011-04-22 14:03:08 +04:00
|
|
|
*
|
2020-05-02 06:35:36 +03:00
|
|
|
* @adjphase: Adjusts the phase offset of the hardware clock.
|
|
|
|
* parameter delta: Desired change in nanoseconds.
|
|
|
|
*
|
2011-04-22 14:03:08 +04:00
|
|
|
* @adjtime: Shifts the time of the hardware clock.
|
|
|
|
* parameter delta: Desired change in nanoseconds.
|
|
|
|
*
|
2015-03-30 00:11:51 +03:00
|
|
|
* @gettime64: Reads the current time from the hardware clock.
|
2018-11-09 13:14:45 +03:00
|
|
|
* This method is deprecated. New drivers should implement
|
|
|
|
* the @gettimex64 method instead.
|
2015-03-30 00:11:51 +03:00
|
|
|
* parameter ts: Holds the result.
|
|
|
|
*
|
2018-11-09 13:14:44 +03:00
|
|
|
* @gettimex64: Reads the current time from the hardware clock and optionally
|
|
|
|
* also the system clock.
|
|
|
|
* parameter ts: Holds the PHC timestamp.
|
|
|
|
* parameter sts: If not NULL, it holds a pair of timestamps from
|
|
|
|
* the system clock. The first reading is made right before
|
|
|
|
* reading the lowest bits of the PHC timestamp and the second
|
|
|
|
* reading immediately follows that.
|
|
|
|
*
|
2016-02-22 14:15:25 +03:00
|
|
|
* @getcrosststamp: Reads the current time from the hardware clock and
|
|
|
|
* system clock simultaneously.
|
|
|
|
* parameter cts: Contains timestamp (device,system) pair,
|
|
|
|
* where system time is realtime and monotonic.
|
|
|
|
*
|
2015-03-30 00:11:51 +03:00
|
|
|
* @settime64: Set the current time on the hardware clock.
|
|
|
|
* parameter ts: Time value to set.
|
|
|
|
*
|
2011-04-22 14:03:08 +04:00
|
|
|
* @enable: Request driver to enable or disable an ancillary feature.
|
|
|
|
* parameter request: Desired resource to enable or disable.
|
|
|
|
* parameter on: Caller passes one to enable or zero to disable.
|
|
|
|
*
|
2014-03-21 01:21:52 +04:00
|
|
|
* @verify: Confirm that a pin can perform a given function. The PTP
|
|
|
|
* Hardware Clock subsystem maintains the 'pin_config'
|
|
|
|
* array on behalf of the drivers, but the PHC subsystem
|
|
|
|
* assumes that every pin can perform every function. This
|
|
|
|
* hook gives drivers a way of telling the core about
|
|
|
|
* limitations on specific pins. This function must return
|
|
|
|
* zero if the function can be assigned to this pin, and
|
|
|
|
* nonzero otherwise.
|
|
|
|
* parameter pin: index of the pin in question.
|
|
|
|
* parameter func: the desired function to use.
|
|
|
|
* parameter chan: the function channel index to use.
|
|
|
|
*
|
2020-05-12 00:02:15 +03:00
|
|
|
* @do_aux_work: Request driver to perform auxiliary (periodic) operations
|
|
|
|
* Driver should return delay of the next auxiliary work
|
|
|
|
* scheduling time (>=0) or negative value in case further
|
|
|
|
* scheduling is not required.
|
ptp: introduce ptp auxiliary worker
Many PTP drivers required to perform some asynchronous or periodic work,
like periodically handling PHC counter overflow or handle delayed timestamp
for RX/TX network packets. In most of the cases, such work is implemented
using workqueues. Unfortunately, Kernel workqueues might introduce
significant delay in work scheduling under high system load and on -RT,
which could cause misbehavior of PTP drivers due to internal counter
overflow, for example, and there is no way to tune its execution policy and
priority manuallly.
Hence, The kthread_worker can be used insted of workqueues, as it create
separte named kthread for each worker and its its execution policy and
priority can be configured using chrt tool.
This prblem was reported for two drivers TI CPSW CPTS and dp83640, so
instead of modifying each of these driver it was proposed to add PTP
auxiliary worker to the PHC subsystem.
The patch adds PTP auxiliary worker in PHC subsystem using kthread_worker
and kthread_delayed_work and introduces two new PHC subsystem APIs:
- long (*do_aux_work)(struct ptp_clock_info *ptp) callback in
ptp_clock_info structure, which driver should assign if it require to
perform asynchronous or periodic work. Driver should return the delay of
the PTP next auxiliary work scheduling time (>=0) or negative value in case
further scheduling is not required.
- int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay) which
allows schedule PTP auxiliary work.
The name of kthread_worker thread corresponds PTP PHC device name "ptp%d".
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-07-29 01:30:02 +03:00
|
|
|
*
|
2011-04-22 14:03:08 +04:00
|
|
|
* Drivers should embed their ptp_clock_info within a private
|
|
|
|
* structure, obtaining a reference to it using container_of().
|
|
|
|
*
|
|
|
|
* The callbacks must all return zero on success, non-zero otherwise.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ptp_clock_info {
|
|
|
|
struct module *owner;
|
|
|
|
char name[16];
|
|
|
|
s32 max_adj;
|
|
|
|
int n_alarm;
|
|
|
|
int n_ext_ts;
|
|
|
|
int n_per_out;
|
2014-03-21 01:21:52 +04:00
|
|
|
int n_pins;
|
2011-04-22 14:03:08 +04:00
|
|
|
int pps;
|
2014-03-21 01:21:52 +04:00
|
|
|
struct ptp_pin_desc *pin_config;
|
2016-11-09 00:49:16 +03:00
|
|
|
int (*adjfine)(struct ptp_clock_info *ptp, long scaled_ppm);
|
2011-04-22 14:03:08 +04:00
|
|
|
int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta);
|
2020-05-02 06:35:36 +03:00
|
|
|
int (*adjphase)(struct ptp_clock_info *ptp, s32 phase);
|
2011-04-22 14:03:08 +04:00
|
|
|
int (*adjtime)(struct ptp_clock_info *ptp, s64 delta);
|
2015-03-30 00:11:51 +03:00
|
|
|
int (*gettime64)(struct ptp_clock_info *ptp, struct timespec64 *ts);
|
2018-11-09 13:14:44 +03:00
|
|
|
int (*gettimex64)(struct ptp_clock_info *ptp, struct timespec64 *ts,
|
|
|
|
struct ptp_system_timestamp *sts);
|
2016-02-22 14:15:25 +03:00
|
|
|
int (*getcrosststamp)(struct ptp_clock_info *ptp,
|
|
|
|
struct system_device_crosststamp *cts);
|
2015-03-30 00:11:51 +03:00
|
|
|
int (*settime64)(struct ptp_clock_info *p, const struct timespec64 *ts);
|
2011-04-22 14:03:08 +04:00
|
|
|
int (*enable)(struct ptp_clock_info *ptp,
|
|
|
|
struct ptp_clock_request *request, int on);
|
2014-03-21 01:21:52 +04:00
|
|
|
int (*verify)(struct ptp_clock_info *ptp, unsigned int pin,
|
|
|
|
enum ptp_pin_function func, unsigned int chan);
|
ptp: introduce ptp auxiliary worker
Many PTP drivers required to perform some asynchronous or periodic work,
like periodically handling PHC counter overflow or handle delayed timestamp
for RX/TX network packets. In most of the cases, such work is implemented
using workqueues. Unfortunately, Kernel workqueues might introduce
significant delay in work scheduling under high system load and on -RT,
which could cause misbehavior of PTP drivers due to internal counter
overflow, for example, and there is no way to tune its execution policy and
priority manuallly.
Hence, The kthread_worker can be used insted of workqueues, as it create
separte named kthread for each worker and its its execution policy and
priority can be configured using chrt tool.
This prblem was reported for two drivers TI CPSW CPTS and dp83640, so
instead of modifying each of these driver it was proposed to add PTP
auxiliary worker to the PHC subsystem.
The patch adds PTP auxiliary worker in PHC subsystem using kthread_worker
and kthread_delayed_work and introduces two new PHC subsystem APIs:
- long (*do_aux_work)(struct ptp_clock_info *ptp) callback in
ptp_clock_info structure, which driver should assign if it require to
perform asynchronous or periodic work. Driver should return the delay of
the PTP next auxiliary work scheduling time (>=0) or negative value in case
further scheduling is not required.
- int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay) which
allows schedule PTP auxiliary work.
The name of kthread_worker thread corresponds PTP PHC device name "ptp%d".
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-07-29 01:30:02 +03:00
|
|
|
long (*do_aux_work)(struct ptp_clock_info *ptp);
|
2011-04-22 14:03:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ptp_clock;
|
|
|
|
|
|
|
|
enum ptp_clock_events {
|
|
|
|
PTP_CLOCK_ALARM,
|
|
|
|
PTP_CLOCK_EXTTS,
|
|
|
|
PTP_CLOCK_PPS,
|
2012-09-03 14:34:58 +04:00
|
|
|
PTP_CLOCK_PPSUSR,
|
2011-04-22 14:03:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct ptp_clock_event - decribes a PTP hardware clock event
|
|
|
|
*
|
|
|
|
* @type: One of the ptp_clock_events enumeration values.
|
|
|
|
* @index: Identifies the source of the event.
|
2012-09-03 14:34:58 +04:00
|
|
|
* @timestamp: When the event occurred (%PTP_CLOCK_EXTTS only).
|
|
|
|
* @pps_times: When the event occurred (%PTP_CLOCK_PPSUSR only).
|
2011-04-22 14:03:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct ptp_clock_event {
|
|
|
|
int type;
|
|
|
|
int index;
|
2012-09-03 14:34:58 +04:00
|
|
|
union {
|
|
|
|
u64 timestamp;
|
|
|
|
struct pps_event_time pps_times;
|
|
|
|
};
|
2011-04-22 14:03:08 +04:00
|
|
|
};
|
|
|
|
|
2016-11-11 08:10:07 +03:00
|
|
|
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ptp_clock_register() - register a PTP hardware clock driver
|
|
|
|
*
|
|
|
|
* @info: Structure describing the new clock.
|
|
|
|
* @parent: Pointer to the parent device of the new clock.
|
|
|
|
*
|
|
|
|
* Returns a valid pointer on success or PTR_ERR on failure. If PHC
|
|
|
|
* support is missing at the configuration level, this function
|
|
|
|
* returns NULL, and drivers are expected to gracefully handle that
|
|
|
|
* case separately.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
|
|
|
|
struct device *parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ptp_clock_unregister() - unregister a PTP hardware clock driver
|
|
|
|
*
|
|
|
|
* @ptp: The clock to remove from service.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern int ptp_clock_unregister(struct ptp_clock *ptp);
|
|
|
|
|
2011-04-22 14:03:08 +04:00
|
|
|
/**
|
|
|
|
* ptp_clock_event() - notify the PTP layer about an event
|
|
|
|
*
|
|
|
|
* @ptp: The clock obtained from ptp_clock_register().
|
|
|
|
* @event: Message structure describing the event.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern void ptp_clock_event(struct ptp_clock *ptp,
|
|
|
|
struct ptp_clock_event *event);
|
|
|
|
|
2012-04-04 02:59:16 +04:00
|
|
|
/**
|
|
|
|
* ptp_clock_index() - obtain the device index of a PTP clock
|
|
|
|
*
|
|
|
|
* @ptp: The clock obtained from ptp_clock_register().
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern int ptp_clock_index(struct ptp_clock *ptp);
|
|
|
|
|
2019-06-11 18:45:09 +03:00
|
|
|
/**
|
|
|
|
* scaled_ppm_to_ppb() - convert scaled ppm to ppb
|
|
|
|
*
|
|
|
|
* @ppm: Parts per million, but with a 16 bit binary fractional field
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern s32 scaled_ppm_to_ppb(long ppm);
|
|
|
|
|
2014-03-21 01:21:52 +04:00
|
|
|
/**
|
|
|
|
* ptp_find_pin() - obtain the pin index of a given auxiliary function
|
|
|
|
*
|
2020-03-29 17:55:10 +03:00
|
|
|
* The caller must hold ptp_clock::pincfg_mux. Drivers do not have
|
|
|
|
* access to that mutex as ptp_clock is an opaque type. However, the
|
|
|
|
* core code acquires the mutex before invoking the driver's
|
|
|
|
* ptp_clock_info::enable() callback, and so drivers may call this
|
|
|
|
* function from that context.
|
|
|
|
*
|
2014-03-21 01:21:52 +04:00
|
|
|
* @ptp: The clock obtained from ptp_clock_register().
|
|
|
|
* @func: One of the ptp_pin_function enumerated values.
|
|
|
|
* @chan: The particular functional channel to find.
|
|
|
|
* Return: Pin index in the range of zero to ptp_clock_caps.n_pins - 1,
|
|
|
|
* or -1 if the auxiliary function cannot be found.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ptp_find_pin(struct ptp_clock *ptp,
|
|
|
|
enum ptp_pin_function func, unsigned int chan);
|
|
|
|
|
2020-03-29 17:55:10 +03:00
|
|
|
/**
|
|
|
|
* ptp_find_pin_unlocked() - wrapper for ptp_find_pin()
|
|
|
|
*
|
|
|
|
* This function acquires the ptp_clock::pincfg_mux mutex before
|
|
|
|
* invoking ptp_find_pin(). Instead of using this function, drivers
|
|
|
|
* should most likely call ptp_find_pin() directly from their
|
|
|
|
* ptp_clock_info::enable() method.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ptp_find_pin_unlocked(struct ptp_clock *ptp,
|
|
|
|
enum ptp_pin_function func, unsigned int chan);
|
|
|
|
|
ptp: introduce ptp auxiliary worker
Many PTP drivers required to perform some asynchronous or periodic work,
like periodically handling PHC counter overflow or handle delayed timestamp
for RX/TX network packets. In most of the cases, such work is implemented
using workqueues. Unfortunately, Kernel workqueues might introduce
significant delay in work scheduling under high system load and on -RT,
which could cause misbehavior of PTP drivers due to internal counter
overflow, for example, and there is no way to tune its execution policy and
priority manuallly.
Hence, The kthread_worker can be used insted of workqueues, as it create
separte named kthread for each worker and its its execution policy and
priority can be configured using chrt tool.
This prblem was reported for two drivers TI CPSW CPTS and dp83640, so
instead of modifying each of these driver it was proposed to add PTP
auxiliary worker to the PHC subsystem.
The patch adds PTP auxiliary worker in PHC subsystem using kthread_worker
and kthread_delayed_work and introduces two new PHC subsystem APIs:
- long (*do_aux_work)(struct ptp_clock_info *ptp) callback in
ptp_clock_info structure, which driver should assign if it require to
perform asynchronous or periodic work. Driver should return the delay of
the PTP next auxiliary work scheduling time (>=0) or negative value in case
further scheduling is not required.
- int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay) which
allows schedule PTP auxiliary work.
The name of kthread_worker thread corresponds PTP PHC device name "ptp%d".
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-07-29 01:30:02 +03:00
|
|
|
/**
|
|
|
|
* ptp_schedule_worker() - schedule ptp auxiliary work
|
|
|
|
*
|
|
|
|
* @ptp: The clock obtained from ptp_clock_register().
|
|
|
|
* @delay: number of jiffies to wait before queuing
|
|
|
|
* See kthread_queue_delayed_work() for more info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay);
|
|
|
|
|
2019-12-27 16:02:28 +03:00
|
|
|
/**
|
|
|
|
* ptp_cancel_worker_sync() - cancel ptp auxiliary clock
|
|
|
|
*
|
|
|
|
* @ptp: The clock obtained from ptp_clock_register().
|
|
|
|
*/
|
|
|
|
void ptp_cancel_worker_sync(struct ptp_clock *ptp);
|
|
|
|
|
2016-11-11 08:10:07 +03:00
|
|
|
#else
|
|
|
|
static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
|
|
|
|
struct device *parent)
|
|
|
|
{ return NULL; }
|
|
|
|
static inline int ptp_clock_unregister(struct ptp_clock *ptp)
|
|
|
|
{ return 0; }
|
|
|
|
static inline void ptp_clock_event(struct ptp_clock *ptp,
|
|
|
|
struct ptp_clock_event *event)
|
|
|
|
{ }
|
|
|
|
static inline int ptp_clock_index(struct ptp_clock *ptp)
|
|
|
|
{ return -1; }
|
|
|
|
static inline int ptp_find_pin(struct ptp_clock *ptp,
|
|
|
|
enum ptp_pin_function func, unsigned int chan)
|
|
|
|
{ return -1; }
|
ptp: introduce ptp auxiliary worker
Many PTP drivers required to perform some asynchronous or periodic work,
like periodically handling PHC counter overflow or handle delayed timestamp
for RX/TX network packets. In most of the cases, such work is implemented
using workqueues. Unfortunately, Kernel workqueues might introduce
significant delay in work scheduling under high system load and on -RT,
which could cause misbehavior of PTP drivers due to internal counter
overflow, for example, and there is no way to tune its execution policy and
priority manuallly.
Hence, The kthread_worker can be used insted of workqueues, as it create
separte named kthread for each worker and its its execution policy and
priority can be configured using chrt tool.
This prblem was reported for two drivers TI CPSW CPTS and dp83640, so
instead of modifying each of these driver it was proposed to add PTP
auxiliary worker to the PHC subsystem.
The patch adds PTP auxiliary worker in PHC subsystem using kthread_worker
and kthread_delayed_work and introduces two new PHC subsystem APIs:
- long (*do_aux_work)(struct ptp_clock_info *ptp) callback in
ptp_clock_info structure, which driver should assign if it require to
perform asynchronous or periodic work. Driver should return the delay of
the PTP next auxiliary work scheduling time (>=0) or negative value in case
further scheduling is not required.
- int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay) which
allows schedule PTP auxiliary work.
The name of kthread_worker thread corresponds PTP PHC device name "ptp%d".
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-07-29 01:30:02 +03:00
|
|
|
static inline int ptp_schedule_worker(struct ptp_clock *ptp,
|
|
|
|
unsigned long delay)
|
|
|
|
{ return -EOPNOTSUPP; }
|
2019-12-27 16:02:28 +03:00
|
|
|
static inline void ptp_cancel_worker_sync(struct ptp_clock *ptp)
|
|
|
|
{ }
|
ptp: introduce ptp auxiliary worker
Many PTP drivers required to perform some asynchronous or periodic work,
like periodically handling PHC counter overflow or handle delayed timestamp
for RX/TX network packets. In most of the cases, such work is implemented
using workqueues. Unfortunately, Kernel workqueues might introduce
significant delay in work scheduling under high system load and on -RT,
which could cause misbehavior of PTP drivers due to internal counter
overflow, for example, and there is no way to tune its execution policy and
priority manuallly.
Hence, The kthread_worker can be used insted of workqueues, as it create
separte named kthread for each worker and its its execution policy and
priority can be configured using chrt tool.
This prblem was reported for two drivers TI CPSW CPTS and dp83640, so
instead of modifying each of these driver it was proposed to add PTP
auxiliary worker to the PHC subsystem.
The patch adds PTP auxiliary worker in PHC subsystem using kthread_worker
and kthread_delayed_work and introduces two new PHC subsystem APIs:
- long (*do_aux_work)(struct ptp_clock_info *ptp) callback in
ptp_clock_info structure, which driver should assign if it require to
perform asynchronous or periodic work. Driver should return the delay of
the PTP next auxiliary work scheduling time (>=0) or negative value in case
further scheduling is not required.
- int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay) which
allows schedule PTP auxiliary work.
The name of kthread_worker thread corresponds PTP PHC device name "ptp%d".
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-07-29 01:30:02 +03:00
|
|
|
|
2016-11-11 08:10:07 +03:00
|
|
|
#endif
|
|
|
|
|
2018-11-09 13:14:44 +03:00
|
|
|
static inline void ptp_read_system_prets(struct ptp_system_timestamp *sts)
|
|
|
|
{
|
|
|
|
if (sts)
|
|
|
|
ktime_get_real_ts64(&sts->pre_ts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ptp_read_system_postts(struct ptp_system_timestamp *sts)
|
|
|
|
{
|
|
|
|
if (sts)
|
|
|
|
ktime_get_real_ts64(&sts->post_ts);
|
|
|
|
}
|
|
|
|
|
2011-04-22 14:03:08 +04:00
|
|
|
#endif
|