]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ptp: ocp: fix start time alignment in ptp_ocp_signal_set
authorSagi Maimon <maimon.sagi@gmail.com>
Tue, 15 Apr 2025 05:31:31 +0000 (08:31 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:43:51 +0000 (10:43 +0200)
[ Upstream commit 2a5970d5aaff8f3e33ce3bfaa403ae88c40de40d ]

In ptp_ocp_signal_set, the start time for periodic signals is not
aligned to the next period boundary. The current code rounds up the
start time and divides by the period but fails to multiply back by
the period, causing misaligned signal starts. Fix this by multiplying
the rounded-up value by the period to ensure the start time is the
closest next period.

Fixes: 4bd46bb037f8e ("ptp: ocp: Use DIV64_U64_ROUND_UP for rounding.")
Signed-off-by: Sagi Maimon <maimon.sagi@gmail.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20250415053131.129413-1-maimon.sagi@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/ptp/ptp_ocp.c

index 87b960e941bae976b02175fca1ebe6b0ef9a4640..b6f66a9886ce259ff587101cc3dc61cb9c07160a 100644 (file)
@@ -1654,6 +1654,7 @@ ptp_ocp_signal_set(struct ptp_ocp *bp, int gen, struct ptp_ocp_signal *s)
        if (!s->start) {
                /* roundup() does not work on 32-bit systems */
                s->start = DIV64_U64_ROUND_UP(start_ns, s->period);
+               s->start *= s->period;
                s->start = ktime_add(s->start, s->phase);
        }