lkml.org 
[lkml]   [2021]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/7] net: dsa: b53: Add PHC clock support
On Thu, Nov 04, 2021 at 02:31:58PM +0100, Martin Kaistra wrote:

> +static void b53_ptp_overflow_check(struct work_struct *work)
> +{
> + struct delayed_work *dw = to_delayed_work(work);
> + struct b53_device *dev =
> + container_of(dw, struct b53_device, overflow_work);
> +
> + mutex_lock(&dev->ptp_mutex);
> + timecounter_read(&dev->tc);
> + mutex_unlock(&dev->ptp_mutex);
> +
> + schedule_delayed_work(&dev->overflow_work, B53_PTP_OVERFLOW_PERIOD);
> +}
> +
> +int b53_ptp_init(struct b53_device *dev)
> +{
> + mutex_init(&dev->ptp_mutex);
> +
> + INIT_DELAYED_WORK(&dev->overflow_work, b53_ptp_overflow_check);

...

> @@ -97,4 +101,14 @@ struct b53_device {
> bool vlan_enabled;
> unsigned int num_ports;
> struct b53_port *ports;
> +
> + /* PTP */
> + bool broadsync_hd;
> + struct ptp_clock *ptp_clock;
> + struct ptp_clock_info ptp_clock_info;
> + struct cyclecounter cc;
> + struct timecounter tc;
> + struct mutex ptp_mutex;
> +#define B53_PTP_OVERFLOW_PERIOD (HZ / 2)
> + struct delayed_work overflow_work;

Instead of generic work, consider implementing
ptp_clock_info::do_aux_work instead.

The advantage is that you get a named kernel thread that can be given
scheduling priority administratively.

Thanks,
Richard

\
 
 \ /
  Last update: 2021-11-04 18:30    [W:0.162 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site