Patch "pwm: xilinx: Fix u32 overflow issue in 32-bit width PWM mode." has been added to the 6.6-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

    pwm: xilinx: Fix u32 overflow issue in 32-bit width PWM mode.

to the 6.6-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:
     pwm-xilinx-fix-u32-overflow-issue-in-32-bit-width-pw.patch
and it can be found in the queue-6.6 subdirectory.

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



commit abda204368c4c9e7d53bcbd114707719bb476e12
Author: Ken Sloat <ksloat@xxxxxxxxxxxxxxxx>
Date:   Thu Dec 15 16:07:15 2022 +0000

    pwm: xilinx: Fix u32 overflow issue in 32-bit width PWM mode.
    
    [ Upstream commit 56f45266df67aa0f5b2a6881c8c4d16dbfff6b7d ]
    
    This timer HW supports 8, 16 and 32-bit timer widths. This
    driver currently uses a u32 to store the max possible value
    of the timer. However, statements perform addition of 2 in
    xilinx_pwm_apply() when calculating the period_cycles and
    duty_cycles values. Since priv->max is a u32, this will
    result in an overflow to 1 which will not only be incorrect
    but fail on range comparison. This results in making it
    impossible to set the PWM in this timer mode.
    
    There are two obvious solutions to the current problem:
    1. Cast each instance where overflow occurs to u64.
    2. Change priv->max from a u32 to a u64.
    
    Solution #1 requires more code modifications, and leaves
    opportunity to introduce similar overflows if other math
    statements are added in the future. These may also go
    undetected if running in non 32-bit timer modes.
    
    Solution #2 is the much smaller and cleaner approach and
    thus the chosen method in this patch.
    
    This was tested on a Zynq UltraScale+ with multiple
    instances of the PWM IP.
    
    Signed-off-by: Ken Sloat <ksloat@xxxxxxxxxxxxxxxx>
    Reviewed-by: Michal Simek <michal.simek@xxxxxxx>
    Reviewed-by: Sean Anderson <sean.anderson@xxxxxxxx>
    Link: https://lore.kernel.org/r/SJ0P222MB0107490C5371B848EF04351CA1E19@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Michal Simek <michal.simek@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/clocksource/timer-xilinx.h b/include/clocksource/timer-xilinx.h
index c0f56fe6d22a..d116f18de899 100644
--- a/include/clocksource/timer-xilinx.h
+++ b/include/clocksource/timer-xilinx.h
@@ -41,7 +41,7 @@ struct regmap;
 struct xilinx_timer_priv {
 	struct regmap *map;
 	struct clk *clk;
-	u32 max;
+	u64 max;
 };
 
 /**




[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