--- /dev/null
+From petrm@nvidia.com Mon Jun 22 14:23:50 2026
+From: Petr Machata <petrm@nvidia.com>
+Date: Mon, 22 Jun 2026 13:53:25 +0200
+Subject: Reapply "selftest/ptp: update ptp selftest to exercise the gettimex options"
+To: Greg KH <gregkh@linuxfoundation.org>
+Cc: Petr Machata <petrm@nvidia.com>, <stable@vger.kernel.org>, Sasha Levin <sashal@kernel.org>, Wojtek Wasko <wwasko@nvidia.com>, Mahesh Bandewar <maheshb@google.com>, Shuah Khan <shuah@kernel.org>, Richard Cochran <richardcochran@gmail.com>
+Message-ID: <cb079700e35515f5b7119d0c14933acaf01ada27.1782122983.git.petrm@nvidia.com>
+
+From: Petr Machata <petrm@nvidia.com>
+
+This reverts commit 6b2176a5c99b33f3c4acc04faadaa9c75da7b163, which in turn
+reverts commit fa361565a7275cc43c6ca1abec9ec4fcc9ec51f1, which is commit
+3d07b691ee707c00afaf365440975e81bb96cd9b upstream.
+
+The reason for the original revert was that struct ptp_sys_offset_extended
+does not contain the field clock_id in 6.12.y. However the claim was false:
+6.12.y does in fact contain the field. Reapply therefore the original
+patch.
+
+Signed-off-by: Petr Machata <petrm@nvidia.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/testing/selftests/ptp/testptp.c | 62 +++++++++++++++++++++++++++++++---
+ 1 file changed, 57 insertions(+), 5 deletions(-)
+
+--- a/tools/testing/selftests/ptp/testptp.c
++++ b/tools/testing/selftests/ptp/testptp.c
+@@ -147,6 +147,7 @@ static void usage(char *progname)
+ " -T val set the ptp clock time to 'val' seconds\n"
+ " -x val get an extended ptp clock time with the desired number of samples (up to %d)\n"
+ " -X get a ptp clock cross timestamp\n"
++ " -y val pre/post tstamp timebase to use {realtime|monotonic|monotonic-raw}\n"
+ " -z test combinations of rising/falling external time stamp flags\n",
+ progname, PTP_MAX_SAMPLES);
+ }
+@@ -191,6 +192,7 @@ int main(int argc, char *argv[])
+ int readonly = 0;
+ int settime = 0;
+ int channel = -1;
++ clockid_t ext_clockid = CLOCK_REALTIME;
+
+ int64_t t1, t2, tp;
+ int64_t interval, offset;
+@@ -200,7 +202,7 @@ int main(int argc, char *argv[])
+
+ progname = strrchr(argv[0], '/');
+ progname = progname ? 1+progname : argv[0];
+- while (EOF != (c = getopt(argc, argv, "cd:e:f:F:ghH:i:k:lL:n:o:p:P:rsSt:T:w:x:Xz"))) {
++ while (EOF != (c = getopt(argc, argv, "cd:e:f:F:ghH:i:k:lL:n:o:p:P:rsSt:T:w:x:Xy:z"))) {
+ switch (c) {
+ case 'c':
+ capabilities = 1;
+@@ -283,6 +285,21 @@ int main(int argc, char *argv[])
+ case 'X':
+ getcross = 1;
+ break;
++ case 'y':
++ if (!strcasecmp(optarg, "realtime"))
++ ext_clockid = CLOCK_REALTIME;
++ else if (!strcasecmp(optarg, "monotonic"))
++ ext_clockid = CLOCK_MONOTONIC;
++ else if (!strcasecmp(optarg, "monotonic-raw"))
++ ext_clockid = CLOCK_MONOTONIC_RAW;
++ else {
++ fprintf(stderr,
++ "type needs to be realtime, monotonic or monotonic-raw; was given %s\n",
++ optarg);
++ return -1;
++ }
++ break;
++
+ case 'z':
+ flagtest = 1;
+ break;
+@@ -575,6 +592,7 @@ int main(int argc, char *argv[])
+ }
+
+ soe->n_samples = getextended;
++ soe->clockid = ext_clockid;
+
+ if (ioctl(fd, PTP_SYS_OFFSET_EXTENDED, soe)) {
+ perror("PTP_SYS_OFFSET_EXTENDED");
+@@ -583,12 +601,46 @@ int main(int argc, char *argv[])
+ getextended);
+
+ for (i = 0; i < getextended; i++) {
+- printf("sample #%2d: system time before: %lld.%09u\n",
+- i, soe->ts[i][0].sec, soe->ts[i][0].nsec);
++ switch (ext_clockid) {
++ case CLOCK_REALTIME:
++ printf("sample #%2d: real time before: %lld.%09u\n",
++ i, soe->ts[i][0].sec,
++ soe->ts[i][0].nsec);
++ break;
++ case CLOCK_MONOTONIC:
++ printf("sample #%2d: monotonic time before: %lld.%09u\n",
++ i, soe->ts[i][0].sec,
++ soe->ts[i][0].nsec);
++ break;
++ case CLOCK_MONOTONIC_RAW:
++ printf("sample #%2d: monotonic-raw time before: %lld.%09u\n",
++ i, soe->ts[i][0].sec,
++ soe->ts[i][0].nsec);
++ break;
++ default:
++ break;
++ }
+ printf(" phc time: %lld.%09u\n",
+ soe->ts[i][1].sec, soe->ts[i][1].nsec);
+- printf(" system time after: %lld.%09u\n",
+- soe->ts[i][2].sec, soe->ts[i][2].nsec);
++ switch (ext_clockid) {
++ case CLOCK_REALTIME:
++ printf(" real time after: %lld.%09u\n",
++ soe->ts[i][2].sec,
++ soe->ts[i][2].nsec);
++ break;
++ case CLOCK_MONOTONIC:
++ printf(" monotonic time after: %lld.%09u\n",
++ soe->ts[i][2].sec,
++ soe->ts[i][2].nsec);
++ break;
++ case CLOCK_MONOTONIC_RAW:
++ printf(" monotonic-raw time after: %lld.%09u\n",
++ soe->ts[i][2].sec,
++ soe->ts[i][2].nsec);
++ break;
++ default:
++ break;
++ }
+ }
+ }
+