Skip to content

Commit 69c3581

Browse files
author
CKI KWF Bot
committed
Merge: ptp: stable backport for 10.2 phase 1
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1485 JIRA: https://issues.redhat.com/browse/RHEL-115596 * 87f7ce2 ptp: remove ptp->n_vclocks check logic in ptp_vclock_in_use() * 5ab73b0 ptp: fix breakage after ptp_vclock_in_use() rework * aa112cb ptp: allow reading of currently dialed frequency to succeed on free-running clocks * 2efe412 ptp: prevent possible ABBA deadlock in ptp_clock_freerun() Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> --- <small>Created 2025-09-23 02:49 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12334433&issuetype=1&priority=4&summary=backporter+webhook+issue&components=kernel-workflow+/+backporter)</small> Approved-by: Jiri Benc <jbenc@redhat.com> Approved-by: Hangbin Liu <haliu@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents cb489e8 + c95bee1 commit 69c3581

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

drivers/ptp/ptp_clock.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
121121
struct ptp_clock_info *ops;
122122
int err = -EOPNOTSUPP;
123123

124-
if (ptp_clock_freerun(ptp)) {
124+
if (tx->modes & (ADJ_SETOFFSET | ADJ_FREQUENCY | ADJ_OFFSET) &&
125+
ptp_clock_freerun(ptp)) {
125126
pr_err("ptp: physical clock is free running\n");
126127
return -EBUSY;
127128
}

drivers/ptp/ptp_private.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
#define PTP_DEFAULT_MAX_VCLOCKS 20
2525
#define PTP_MAX_CHANNELS 2048
2626

27+
enum {
28+
PTP_LOCK_PHYSICAL = 0,
29+
PTP_LOCK_VIRTUAL,
30+
};
31+
2732
struct timestamp_event_queue {
2833
struct ptp_extts_event buf[PTP_MAX_TIMESTAMPS];
2934
int head;
@@ -100,10 +105,20 @@ static inline bool ptp_vclock_in_use(struct ptp_clock *ptp)
100105
{
101106
bool in_use = false;
102107

108+
/* Virtual clocks can't be stacked on top of virtual clocks.
109+
* Avoid acquiring the n_vclocks_mux on virtual clocks, to allow this
110+
* function to be called from code paths where the n_vclocks_mux of the
111+
* parent physical clock is already held. Functionally that's not an
112+
* issue, but lockdep would complain, because they have the same lock
113+
* class.
114+
*/
115+
if (ptp->is_virtual_clock)
116+
return false;
117+
103118
if (mutex_lock_interruptible(&ptp->n_vclocks_mux))
104119
return true;
105120

106-
if (!ptp->is_virtual_clock && ptp->n_vclocks)
121+
if (ptp->n_vclocks)
107122
in_use = true;
108123

109124
mutex_unlock(&ptp->n_vclocks_mux);

drivers/ptp/ptp_vclock.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ static long ptp_vclock_refresh(struct ptp_clock_info *ptp)
154154
return PTP_VCLOCK_REFRESH_INTERVAL;
155155
}
156156

157+
static void ptp_vclock_set_subclass(struct ptp_clock *ptp)
158+
{
159+
lockdep_set_subclass(&ptp->clock.rwsem, PTP_LOCK_VIRTUAL);
160+
}
161+
157162
static const struct ptp_clock_info ptp_vclock_info = {
158163
.owner = THIS_MODULE,
159164
.name = "ptp virtual clock",
@@ -213,6 +218,8 @@ struct ptp_vclock *ptp_vclock_register(struct ptp_clock *pclock)
213218
return NULL;
214219
}
215220

221+
ptp_vclock_set_subclass(vclock->clock);
222+
216223
timecounter_init(&vclock->tc, &vclock->cc, 0);
217224
ptp_schedule_worker(vclock->clock, PTP_VCLOCK_REFRESH_INTERVAL);
218225

0 commit comments

Comments
 (0)