Commit 999f1292 authored by Grygorii Strashko's avatar Grygorii Strashko Committed by David S. Miller

net: ethernet: ti: cpts: convert to use ptp auxiliary worker

There could be significant delay in CPTS work schedule under high system
load and on -RT which could cause CPTS misbehavior due to internal counter
overflow. Usage of own kthread_worker allows to avoid such kind of issues
and makes it possible to tune priority of CPTS kthread_worker thread on -RT
(thread name "cpts").

Hence, the CPTS driver is converted to use PTP auxiliary worker as PHC
subsystem implements such functionality in a generic way now.
Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9535cb7
...@@ -224,6 +224,17 @@ static int cpts_ptp_enable(struct ptp_clock_info *ptp, ...@@ -224,6 +224,17 @@ static int cpts_ptp_enable(struct ptp_clock_info *ptp,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static long cpts_overflow_check(struct ptp_clock_info *ptp)
{
struct cpts *cpts = container_of(ptp, struct cpts, info);
unsigned long delay = cpts->ov_check_period;
struct timespec64 ts;
cpts_ptp_gettime(&cpts->info, &ts);
pr_debug("cpts overflow check at %lld.%09lu\n", ts.tv_sec, ts.tv_nsec);
return (long)delay;
}
static struct ptp_clock_info cpts_info = { static struct ptp_clock_info cpts_info = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "CTPS timer", .name = "CTPS timer",
...@@ -236,18 +247,9 @@ static struct ptp_clock_info cpts_info = { ...@@ -236,18 +247,9 @@ static struct ptp_clock_info cpts_info = {
.gettime64 = cpts_ptp_gettime, .gettime64 = cpts_ptp_gettime,
.settime64 = cpts_ptp_settime, .settime64 = cpts_ptp_settime,
.enable = cpts_ptp_enable, .enable = cpts_ptp_enable,
.do_aux_work = cpts_overflow_check,
}; };
static void cpts_overflow_check(struct work_struct *work)
{
struct timespec64 ts;
struct cpts *cpts = container_of(work, struct cpts, overflow_work.work);
cpts_ptp_gettime(&cpts->info, &ts);
pr_debug("cpts overflow check at %lld.%09lu\n", ts.tv_sec, ts.tv_nsec);
schedule_delayed_work(&cpts->overflow_work, cpts->ov_check_period);
}
static int cpts_match(struct sk_buff *skb, unsigned int ptp_class, static int cpts_match(struct sk_buff *skb, unsigned int ptp_class,
u16 ts_seqid, u8 ts_msgtype) u16 ts_seqid, u8 ts_msgtype)
{ {
...@@ -378,7 +380,7 @@ int cpts_register(struct cpts *cpts) ...@@ -378,7 +380,7 @@ int cpts_register(struct cpts *cpts)
} }
cpts->phc_index = ptp_clock_index(cpts->clock); cpts->phc_index = ptp_clock_index(cpts->clock);
schedule_delayed_work(&cpts->overflow_work, cpts->ov_check_period); ptp_schedule_worker(cpts->clock, cpts->ov_check_period);
return 0; return 0;
err_ptp: err_ptp:
...@@ -392,8 +394,6 @@ void cpts_unregister(struct cpts *cpts) ...@@ -392,8 +394,6 @@ void cpts_unregister(struct cpts *cpts)
if (WARN_ON(!cpts->clock)) if (WARN_ON(!cpts->clock))
return; return;
cancel_delayed_work_sync(&cpts->overflow_work);
ptp_clock_unregister(cpts->clock); ptp_clock_unregister(cpts->clock);
cpts->clock = NULL; cpts->clock = NULL;
...@@ -476,7 +476,6 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs, ...@@ -476,7 +476,6 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs,
cpts->dev = dev; cpts->dev = dev;
cpts->reg = (struct cpsw_cpts __iomem *)regs; cpts->reg = (struct cpsw_cpts __iomem *)regs;
spin_lock_init(&cpts->lock); spin_lock_init(&cpts->lock);
INIT_DELAYED_WORK(&cpts->overflow_work, cpts_overflow_check);
ret = cpts_of_parse(cpts, node); ret = cpts_of_parse(cpts, node);
if (ret) if (ret)
......
...@@ -119,7 +119,6 @@ struct cpts { ...@@ -119,7 +119,6 @@ struct cpts {
u32 cc_mult; /* for the nominal frequency */ u32 cc_mult; /* for the nominal frequency */
struct cyclecounter cc; struct cyclecounter cc;
struct timecounter tc; struct timecounter tc;
struct delayed_work overflow_work;
int phc_index; int phc_index;
struct clk *refclk; struct clk *refclk;
struct list_head events; struct list_head events;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment