lkml.org 
[lkml]   [2017]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next RFC 2/9] net: dsa: mv88e6xxx: expose switch time as a PTP hardware clock
> +/* The 32-bit timestamp counter overflows every ~34.3 seconds; this task
> + * forces periodic reads so that we don't miss any wraparounds.
> + */
> +#define MV88E6XXX_TAI_OVERFLOW_PERIOD (34 * HZ / 2)
> +static void mv88e6xxx_ptp_overflow_check(struct work_struct *work)
> +{
> + struct delayed_work *dw = to_delayed_work(work);
> + struct mv88e6xxx_chip *chip =
> + container_of(dw, struct mv88e6xxx_chip, overflow_work);
> + bool timeout = time_is_before_jiffies(chip->last_overflow_check +
> + MV88E6XXX_TAI_OVERFLOW_PERIOD);
> +
> + if (timeout) {

Why do you need this timeout? Do you think the kernel will call this
more often than required?

Also, if it did call this function early, you skip the read, and
reschedule. There is then a danger the next read is after the
wraparound.....

> + mutex_lock(&chip->reg_lock);
> + timecounter_read(&chip->tstamp_tc);
> + chip->last_overflow_check = jiffies;
> + mutex_unlock(&chip->reg_lock);
> + }
> +
> + schedule_delayed_work(&chip->overflow_work,
> + MV88E6XXX_TAI_OVERFLOW_PERIOD);
> +}

Thanks
Andrew

\
 
 \ /
  Last update: 2017-09-28 19:03    [W:0.174 / U:1.980 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site