2019-05-20 09:19:02 +02:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-29 13:06:04 +08:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:57 +02:00
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
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-28 17:30:02 -05:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 17:11:27 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-30 16:11:55 +08:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-24 13:49:46 -05:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-24 13:49:46 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-24 13:49:46 -05:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2024-01-24 13:49:46 -05:00
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2023-11-09 17:48:59 +00:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2023-11-09 17:48:59 +00:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2023-11-09 17:48:59 +00:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-26 12:04:13 -07:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2011-12-05 21:16:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2017-03-26 12:04:13 -07:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2015-03-29 23:11:53 +02:00
|
|
|
|
2022-05-06 22:01:37 +02:00
|
|
|
|
2025-06-13 10:15:46 -07:00
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-28 12:32:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-26 12:04:13 -07:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2017-03-26 12:04:13 -07:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2015-03-29 23:11:53 +02:00
|
|
|
|
|
|
|
|
|
2018-11-09 11:14:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-03-29 23:11:53 +02:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2018-07-02 22:44:21 -07:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-13 20:47:49 +03:00
|
|
|
|
|
|
|
|
|
2022-05-06 22:01:37 +02:00
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-28 12:32:53 +02:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-28 12:32:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-26 12:04:13 -07:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-14 15:24:05 -07:00
|
|
|
|
2014-04-27 15:01:27 +02:00
|
|
|
|
|
|
|
|
|
2022-11-09 15:09:45 -08:00
|
|
|
|
2024-11-25 10:59:54 +00:00
|
|
|
|
|
|
|
|
|
2020-05-01 23:35:36 -04:00
|
|
|
|
2020-05-24 11:27:10 -07:00
|
|
|
|
2023-06-12 14:14:56 -07:00
|
|
|
|
2020-05-24 11:27:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-12 14:14:56 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-05-24 11:27:10 -07:00
|
|
|
|
|
|
|
|
|
2012-09-22 07:02:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:55 +02:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-27 03:26:27 +01:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2019-12-27 03:26:27 +01:00
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2020-01-13 14:00:09 +01:00
|
|
|
|
2021-10-21 17:13:53 +08:00
|
|
|
|
2014-03-20 22:21:52 +01:00
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
2023-11-07 16:00:41 +08:00
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-07 16:00:41 +08:00
|
|
|
|
2023-10-12 00:39:56 +02:00
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
2023-10-12 00:39:57 +02:00
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-06 22:01:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-23 08:22:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-28 17:30:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 11:07:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2012-09-22 07:02:03 +00:00
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
2023-10-18 17:20:11 +03:00
|
|
|
|
2021-06-30 16:11:54 +08:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2025-11-04 14:59:15 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-21 16:37:42 -08:00
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2013-04-12 00:56:15 +00:00
|
|
|
|
|
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
2026-02-21 16:37:42 -08:00
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
2023-11-07 16:00:41 +08:00
|
|
|
|
2023-10-12 00:39:56 +02:00
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:56 +02:00
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
2023-10-12 00:39:56 +02:00
|
|
|
|
2023-10-12 00:39:55 +02:00
|
|
|
|
2014-03-20 22:21:52 +01:00
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2022-05-06 22:01:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-23 08:22:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-28 17:30:02 -05:00
|
|
|
|
|
|
|
|
|
2024-09-27 00:49:07 +02:00
|
|
|
|
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-28 17:30:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
2021-07-05 16:53:06 +08:00
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-30 16:11:54 +08:00
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
|
|
|
|
|
2021-06-30 16:11:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-14 10:23:34 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-12-07 09:00:46 +03:00
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-08 11:04:08 -07:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2019-12-27 03:26:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 17:11:27 -03:00
|
|
|
|
2019-12-27 03:26:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2021-10-27 23:18:02 +00:00
|
|
|
|
|
|
|
|
|
2021-10-20 16:18:34 +08:00
|
|
|
|
|
|
|
|
|
2021-10-27 23:18:02 +00:00
|
|
|
|
2021-10-20 16:18:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2021-10-20 16:18:34 +08:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:57 +02:00
|
|
|
|
2023-10-18 17:20:11 +03:00
|
|
|
|
2023-10-12 00:39:57 +02:00
|
|
|
|
2025-09-05 11:07:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:57 +02:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-14 10:23:34 -08:00
|
|
|
|
|
|
|
|
|
2021-06-30 16:11:54 +08:00
|
|
|
|
|
|
|
|
|
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-28 17:30:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-20 22:21:52 +01:00
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
2023-10-12 00:39:56 +02:00
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
2013-04-12 00:56:15 +00:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-02-02 10:33:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
2022-02-02 10:33:55 +01:00
|
|
|
|
2021-06-30 16:11:53 +08:00
|
|
|
|
|
|
|
|
|
ptp: rework ptp_clock_unregister() to disable events
The ordering of ptp_clock_unregister() is not ideal, as the chardev
remains published while state is being torn down, which means userspace
can race with the kernel teardown. There is also no cleanup of enabled
pin settings nor of the internal PPS event, which means enabled events
can still forward into the core, dereferencing a free'd pointer.
Rework the ordering of cleanup in ptp_clock_unregister() so that we
unpublish the posix clock (and user chardev), disable any pins that
have EXTTS events enabled, disable the PPS event, and then clean up
the aux work and PPS source.
This avoids potential use-after-free and races in PTP clock driver
teardown.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com> # ocelot, sja1105, netdevsim, vclocks
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Link: https://patch.msgid.link/E1uydLH-000000061DM-2gcV@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-09-16 22:36:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ptp: rework ptp_clock_unregister() to disable events
The ordering of ptp_clock_unregister() is not ideal, as the chardev
remains published while state is being torn down, which means userspace
can race with the kernel teardown. There is also no cleanup of enabled
pin settings nor of the internal PPS event, which means enabled events
can still forward into the core, dereferencing a free'd pointer.
Rework the ordering of cleanup in ptp_clock_unregister() so that we
unpublish the posix clock (and user chardev), disable any pins that
have EXTTS events enabled, disable the PPS event, and then clean up
the aux work and PPS source.
This avoids potential use-after-free and races in PTP clock driver
teardown.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com> # ocelot, sja1105, netdevsim, vclocks
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Link: https://patch.msgid.link/E1uydLH-000000061DM-2gcV@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-09-16 22:36:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-28 17:30:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-14 10:23:34 -08:00
|
|
|
|
ptp: rework ptp_clock_unregister() to disable events
The ordering of ptp_clock_unregister() is not ideal, as the chardev
remains published while state is being torn down, which means userspace
can race with the kernel teardown. There is also no cleanup of enabled
pin settings nor of the internal PPS event, which means enabled events
can still forward into the core, dereferencing a free'd pointer.
Rework the ordering of cleanup in ptp_clock_unregister() so that we
unpublish the posix clock (and user chardev), disable any pins that
have EXTTS events enabled, disable the PPS event, and then clean up
the aux work and PPS source.
This avoids potential use-after-free and races in PTP clock driver
teardown.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com> # ocelot, sja1105, netdevsim, vclocks
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Link: https://patch.msgid.link/E1uydLH-000000061DM-2gcV@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-09-16 22:36:03 +01:00
|
|
|
|
|
|
|
|
|
2020-01-13 14:00:09 +01:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2023-11-07 16:00:41 +08:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-24 13:49:46 -05:00
|
|
|
|
2023-10-12 00:39:56 +02:00
|
|
|
|
2023-11-07 16:00:41 +08:00
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
2023-10-12 00:39:56 +02:00
|
|
|
|
|
|
|
|
|
2023-10-12 00:39:54 +02:00
|
|
|
|
2023-11-07 16:00:41 +08:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-03 11:34:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-03 22:59:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-29 13:06:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-20 22:21:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-03-29 07:55:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-28 17:30:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-27 15:02:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 17:11:27 -03:00
|
|
|
|
2013-04-12 00:56:15 +00:00
|
|
|
|
2024-03-11 15:47:29 +01:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 17:11:27 -03:00
|
|
|
|
|
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
2024-03-05 17:11:27 -03:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
2013-04-12 00:56:15 +00:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-05 17:11:27 -03:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-16 22:39:29 +00:00
|
|
|
|
2011-04-22 12:03:08 +02:00
|
|
|
|
|
|
|
|
|