Patch "pwm: rockchip: Eliminate potential race condition when probing" has been added to the 5.10-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: rockchip: Eliminate potential race condition when probing

to the 5.10-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-rockchip-eliminate-potential-race-condition-when.patch
and it can be found in the queue-5.10 subdirectory.

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



commit 18898df13e0c27d3505828c89754f07f0e1fc469
Author: Simon South <simon@xxxxxxxxxxxxxx>
Date:   Tue Jan 19 11:12:08 2021 -0500

    pwm: rockchip: Eliminate potential race condition when probing
    
    [ Upstream commit d21ba5d6217bd5a6a696678385906ed1994b380b ]
    
    Commit 48cf973cae33 ("pwm: rockchip: Avoid glitches on already running
    PWMs") introduced a potential race condition in rockchip_pwm_probe(): A
    consumer could enable an inactive PWM, or disable a running one, between
    rockchip_pwm_probe() registering the device via pwmchip_add() and checking
    whether it is enabled (to determine whether it was started by a
    bootloader). This could result in a device's PWM clock being either enabled
    once more than necessary, potentially causing it to continue running when
    no longer needed, or disabled once more than necessary, producing a warning
    from the kernel.
    
    Eliminate these possibilities by modifying rockchip_pwm_probe() so it
    checks whether a device is enabled before registering it rather than after.
    
    Fixes: 48cf973cae33 ("pwm: rockchip: Avoid glitches on already running PWMs")
    Reported-by: Trent Piepho <tpiepho@xxxxxxxxx>
    Signed-off-by: Simon South <simon@xxxxxxxxxxxxxx>
    Signed-off-by: Thierry Reding <thierry.reding@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c
index ede027fbf2bb4..3b8da7b0091b1 100644
--- a/drivers/pwm/pwm-rockchip.c
+++ b/drivers/pwm/pwm-rockchip.c
@@ -289,6 +289,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
 	struct rockchip_pwm_chip *pc;
 	struct resource *r;
 	u32 enable_conf, ctrl;
+	bool enabled;
 	int ret, count;
 
 	id = of_match_device(rockchip_pwm_dt_ids, &pdev->dev);
@@ -351,6 +352,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
 		pc->chip.of_pwm_n_cells = 3;
 	}
 
+	enable_conf = pc->data->enable_conf;
+	ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl);
+	enabled = (ctrl & enable_conf) == enable_conf;
+
 	ret = pwmchip_add(&pc->chip);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
@@ -358,9 +363,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
 	}
 
 	/* Keep the PWM clk enabled if the PWM appears to be up and running. */
-	enable_conf = pc->data->enable_conf;
-	ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl);
-	if ((ctrl & enable_conf) != enable_conf)
+	if (!enabled)
 		clk_disable(pc->clk);
 
 	clk_disable(pc->pclk);



[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