Patch "ptp: ocp: have adjtime handle negative delta_ns correctly" has been added to the 5.17-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ptp: ocp: have adjtime handle negative delta_ns correctly

to the 5.17-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ptp-ocp-have-adjtime-handle-negative-delta_ns-correc.patch
and it can be found in the queue-5.17 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0ec7ee6ee82f9d3aa4c4234283dea94e77df2867
Author: Jonathan Lemon <jonathan.lemon@xxxxxxxxx>
Date:   Fri May 13 15:52:31 2022 -0700

    ptp: ocp: have adjtime handle negative delta_ns correctly
    
    [ Upstream commit da2172a9bfec858ceeb0271b9d444378490398c8 ]
    
    delta_ns is a s64, but it was being passed ptp_ocp_adjtime_coarse
    as an u64.  Also, it turns out that timespec64_add_ns() only handles
    positive values, so perform the math with set_normalized_timespec().
    
    Fixes: 90f8f4c0e3ce ("ptp: ocp: Add ptp_ocp_adjtime_coarse for large adjustments")
    Suggested-by: Vadim Fedorenko <vfedorenko@xxxxxxxx>
    Signed-off-by: Jonathan Lemon <jonathan.lemon@xxxxxxxxx>
    Acked-by: Vadim Fedorenko <vfedorenko@xxxxxxxx>
    Link: https://lore.kernel.org/r/20220513225231.1412-1-jonathan.lemon@xxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 17ad5f0d13b2..6585789ed695 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -625,7 +625,7 @@ __ptp_ocp_adjtime_locked(struct ptp_ocp *bp, u32 adj_val)
 }
 
 static void
-ptp_ocp_adjtime_coarse(struct ptp_ocp *bp, u64 delta_ns)
+ptp_ocp_adjtime_coarse(struct ptp_ocp *bp, s64 delta_ns)
 {
 	struct timespec64 ts;
 	unsigned long flags;
@@ -634,7 +634,8 @@ ptp_ocp_adjtime_coarse(struct ptp_ocp *bp, u64 delta_ns)
 	spin_lock_irqsave(&bp->lock, flags);
 	err = __ptp_ocp_gettime_locked(bp, &ts, NULL);
 	if (likely(!err)) {
-		timespec64_add_ns(&ts, delta_ns);
+		set_normalized_timespec64(&ts, ts.tv_sec,
+					  ts.tv_nsec + delta_ns);
 		__ptp_ocp_settime_locked(bp, &ts);
 	}
 	spin_unlock_irqrestore(&bp->lock, flags);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux