Lines Matching refs:vclock

22 static void ptp_vclock_hash_add(struct ptp_vclock *vclock)  in ptp_vclock_hash_add()  argument
26 hlist_add_head_rcu(&vclock->vclock_hash_node, in ptp_vclock_hash_add()
27 &vclock_hash[vclock->clock->index % HASH_SIZE(vclock_hash)]); in ptp_vclock_hash_add()
32 static void ptp_vclock_hash_del(struct ptp_vclock *vclock) in ptp_vclock_hash_del() argument
36 hlist_del_init_rcu(&vclock->vclock_hash_node); in ptp_vclock_hash_del()
45 struct ptp_vclock *vclock = info_to_vclock(ptp); in ptp_vclock_adjfine() local
52 spin_lock_irqsave(&vclock->lock, flags); in ptp_vclock_adjfine()
53 timecounter_read(&vclock->tc); in ptp_vclock_adjfine()
54 vclock->cc.mult = PTP_VCLOCK_CC_MULT + adj; in ptp_vclock_adjfine()
55 spin_unlock_irqrestore(&vclock->lock, flags); in ptp_vclock_adjfine()
62 struct ptp_vclock *vclock = info_to_vclock(ptp); in ptp_vclock_adjtime() local
65 spin_lock_irqsave(&vclock->lock, flags); in ptp_vclock_adjtime()
66 timecounter_adjtime(&vclock->tc, delta); in ptp_vclock_adjtime()
67 spin_unlock_irqrestore(&vclock->lock, flags); in ptp_vclock_adjtime()
75 struct ptp_vclock *vclock = info_to_vclock(ptp); in ptp_vclock_gettime() local
79 spin_lock_irqsave(&vclock->lock, flags); in ptp_vclock_gettime()
80 ns = timecounter_read(&vclock->tc); in ptp_vclock_gettime()
81 spin_unlock_irqrestore(&vclock->lock, flags); in ptp_vclock_gettime()
91 struct ptp_vclock *vclock = info_to_vclock(ptp); in ptp_vclock_gettimex() local
92 struct ptp_clock *pptp = vclock->pclock; in ptp_vclock_gettimex()
102 spin_lock_irqsave(&vclock->lock, flags); in ptp_vclock_gettimex()
103 ns = timecounter_cyc2time(&vclock->tc, timespec64_to_ns(&pts)); in ptp_vclock_gettimex()
104 spin_unlock_irqrestore(&vclock->lock, flags); in ptp_vclock_gettimex()
114 struct ptp_vclock *vclock = info_to_vclock(ptp); in ptp_vclock_settime() local
118 spin_lock_irqsave(&vclock->lock, flags); in ptp_vclock_settime()
119 timecounter_init(&vclock->tc, &vclock->cc, ns); in ptp_vclock_settime()
120 spin_unlock_irqrestore(&vclock->lock, flags); in ptp_vclock_settime()
128 struct ptp_vclock *vclock = info_to_vclock(ptp); in ptp_vclock_getcrosststamp() local
129 struct ptp_clock *pptp = vclock->pclock; in ptp_vclock_getcrosststamp()
138 spin_lock_irqsave(&vclock->lock, flags); in ptp_vclock_getcrosststamp()
139 ns = timecounter_cyc2time(&vclock->tc, ktime_to_ns(xtstamp->device)); in ptp_vclock_getcrosststamp()
140 spin_unlock_irqrestore(&vclock->lock, flags); in ptp_vclock_getcrosststamp()
149 struct ptp_vclock *vclock = info_to_vclock(ptp); in ptp_vclock_refresh() local
152 ptp_vclock_gettime(&vclock->info, &ts); in ptp_vclock_refresh()
169 struct ptp_vclock *vclock = cc_to_vclock(cc); in ptp_vclock_read() local
170 struct ptp_clock *ptp = vclock->pclock; in ptp_vclock_read()
187 struct ptp_vclock *vclock; in ptp_vclock_register() local
189 vclock = kzalloc(sizeof(*vclock), GFP_KERNEL); in ptp_vclock_register()
190 if (!vclock) in ptp_vclock_register()
193 vclock->pclock = pclock; in ptp_vclock_register()
194 vclock->info = ptp_vclock_info; in ptp_vclock_register()
196 vclock->info.gettimex64 = ptp_vclock_gettimex; in ptp_vclock_register()
198 vclock->info.gettime64 = ptp_vclock_gettime; in ptp_vclock_register()
200 vclock->info.getcrosststamp = ptp_vclock_getcrosststamp; in ptp_vclock_register()
201 vclock->cc = ptp_vclock_cc; in ptp_vclock_register()
203 snprintf(vclock->info.name, PTP_CLOCK_NAME_LEN, "ptp%d_virt", in ptp_vclock_register()
206 INIT_HLIST_NODE(&vclock->vclock_hash_node); in ptp_vclock_register()
208 spin_lock_init(&vclock->lock); in ptp_vclock_register()
210 vclock->clock = ptp_clock_register(&vclock->info, &pclock->dev); in ptp_vclock_register()
211 if (IS_ERR_OR_NULL(vclock->clock)) { in ptp_vclock_register()
212 kfree(vclock); in ptp_vclock_register()
216 timecounter_init(&vclock->tc, &vclock->cc, 0); in ptp_vclock_register()
217 ptp_schedule_worker(vclock->clock, PTP_VCLOCK_REFRESH_INTERVAL); in ptp_vclock_register()
219 ptp_vclock_hash_add(vclock); in ptp_vclock_register()
221 return vclock; in ptp_vclock_register()
224 void ptp_vclock_unregister(struct ptp_vclock *vclock) in ptp_vclock_unregister() argument
226 ptp_vclock_hash_del(vclock); in ptp_vclock_unregister()
228 ptp_clock_unregister(vclock->clock); in ptp_vclock_unregister()
229 kfree(vclock); in ptp_vclock_unregister()
271 struct ptp_vclock *vclock; in ptp_convert_timestamp() local
280 hlist_for_each_entry_rcu(vclock, &vclock_hash[hash], vclock_hash_node) { in ptp_convert_timestamp()
281 if (vclock->clock->index != vclock_index) in ptp_convert_timestamp()
284 spin_lock_irqsave(&vclock->lock, flags); in ptp_convert_timestamp()
285 vclock_ns = timecounter_cyc2time(&vclock->tc, ns); in ptp_convert_timestamp()
286 spin_unlock_irqrestore(&vclock->lock, flags); in ptp_convert_timestamp()