Skip to content

Commit 31778b1

Browse files
author
CKI KWF Bot
committed
Merge: ptp: stable backport for 9.8 phase 2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7386 JIRA: https://issues.redhat.com/browse/RHEL-115644 * 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:42 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 2ec0613 + 0cc2654 commit 31778b1

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
@@ -107,7 +107,8 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
107107
struct ptp_clock_info *ops;
108108
int err = -EOPNOTSUPP;
109109

110-
if (ptp_clock_freerun(ptp)) {
110+
if (tx->modes & (ADJ_SETOFFSET | ADJ_FREQUENCY | ADJ_OFFSET) &&
111+
ptp_clock_freerun(ptp)) {
111112
pr_err("ptp: physical clock is free running\n");
112113
return -EBUSY;
113114
}

drivers/ptp/ptp_private.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
#define PTP_BUF_TIMESTAMPS 30
2121
#define PTP_DEFAULT_MAX_VCLOCKS 20
2222

23+
enum {
24+
PTP_LOCK_PHYSICAL = 0,
25+
PTP_LOCK_VIRTUAL,
26+
};
27+
2328
struct timestamp_event_queue {
2429
struct ptp_extts_event buf[PTP_MAX_TIMESTAMPS];
2530
int head;
@@ -91,10 +96,20 @@ static inline bool ptp_vclock_in_use(struct ptp_clock *ptp)
9196
{
9297
bool in_use = false;
9398

99+
/* Virtual clocks can't be stacked on top of virtual clocks.
100+
* Avoid acquiring the n_vclocks_mux on virtual clocks, to allow this
101+
* function to be called from code paths where the n_vclocks_mux of the
102+
* parent physical clock is already held. Functionally that's not an
103+
* issue, but lockdep would complain, because they have the same lock
104+
* class.
105+
*/
106+
if (ptp->is_virtual_clock)
107+
return false;
108+
94109
if (mutex_lock_interruptible(&ptp->n_vclocks_mux))
95110
return true;
96111

97-
if (!ptp->is_virtual_clock && ptp->n_vclocks)
112+
if (ptp->n_vclocks)
98113
in_use = true;
99114

100115
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)