All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon South <simon@simonsouth.net>
To: tpiepho@gmail.com, thierry.reding@gmail.com,
	u.kleine-koenig@pengutronix.de, robin.murphy@arm.com,
	lee.jones@linaro.org, heiko@sntech.de, bbrezillon@kernel.org,
	david.wu@rock-chips.com, steven.liu@rock-chips.com,
	linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Cc: simon@simonsouth.net
Subject: [PATCH v4 0/5] pwm: rockchip: Eliminate potential race condition when probing
Date: Tue, 19 Jan 2021 11:12:04 -0500	[thread overview]
Message-ID: <cover.1610976129.git.simon@simonsouth.net> (raw)

This patch series eliminates the race condition Trent Piepho
identified[0] in the Rockchip PWM driver's rockchip_pwm_probe()
function, by moving code that checks whether a device is enabled ahead
of the code that registers it via pwmchip_add().

It includes several other small fixes and improvements to the driver
as well: It also

- Fixes a potential kernel hang introduced by my earlier commit
  457f74abbed0 ("pwm: rockchip: Keep enabled PWMs running while
  probing") by ensuring a device's APB clock is enabled before its
  registers are accessed;

- Removes a superfluous call to clk_unprepare() that could produce
  warnings from the kernel;

- Clarifies error messages from the driver by replacing "bus clk" with
  "PWM clk"; and

- Ensures the driver enables a clock before querying its rate with
  clk_get_rate(), as stated as a requirement in that function's
  documentation.

This version of the series incorporates Uwe Kleine-König's feedback on
v3 and includes these changes:

- Patch 1's commit message has been edited slightly to improve
  readability, and the error message updated by the patch now reads
  "prepare enable" rather than just "enable" for consistency with the
  error message above it in the code.

- Patch 3's commit message now mentions consistency with the device
  tree.

- Patch 4 has been simplified and now just moves the device-enabled
  check ahead of the call to pwmchip_add(). It no longers changes any
  error-handling behaviour, and an extraneous pair of parentheses has
  been removed.

Patches 2 and 5 are unchanged from v3, while the remaining 2 patches
present in v3 (which removed goto targets from and reordered some
operations in rockchip_pwm_probe()) have been dropped.

I've tested these changes on my Pinebook Pro (RK3399 with a PWM-driven
backlight enabled by U-Boot) and ROCK64 (RK3328) and they appear to
work fine.

[0] https://www.spinics.net/lists/linux-pwm/msg14611.html

--
Simon South
simon@simonsouth.net


Simon South (5):
  pwm: rockchip: Enable APB clock during register access while probing
  pwm: rockchip: rockchip_pwm_probe(): Remove superfluous
    clk_unprepare()
  pwm: rockchip: Replace "bus clk" with "PWM clk"
  pwm: rockchip: Eliminate potential race condition when probing
  pwm: rockchip: Enable clock before calling clk_get_rate()

 drivers/pwm/pwm-rockchip.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

-- 
2.30.0


WARNING: multiple messages have this Message-ID (diff)
From: Simon South <simon@simonsouth.net>
To: tpiepho@gmail.com, thierry.reding@gmail.com,
	u.kleine-koenig@pengutronix.de, robin.murphy@arm.com,
	lee.jones@linaro.org, heiko@sntech.de, bbrezillon@kernel.org,
	david.wu@rock-chips.com, steven.liu@rock-chips.com,
	linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Cc: simon@simonsouth.net
Subject: [PATCH v4 0/5] pwm: rockchip: Eliminate potential race condition when probing
Date: Tue, 19 Jan 2021 11:12:04 -0500	[thread overview]
Message-ID: <cover.1610976129.git.simon@simonsouth.net> (raw)

This patch series eliminates the race condition Trent Piepho
identified[0] in the Rockchip PWM driver's rockchip_pwm_probe()
function, by moving code that checks whether a device is enabled ahead
of the code that registers it via pwmchip_add().

It includes several other small fixes and improvements to the driver
as well: It also

- Fixes a potential kernel hang introduced by my earlier commit
  457f74abbed0 ("pwm: rockchip: Keep enabled PWMs running while
  probing") by ensuring a device's APB clock is enabled before its
  registers are accessed;

- Removes a superfluous call to clk_unprepare() that could produce
  warnings from the kernel;

- Clarifies error messages from the driver by replacing "bus clk" with
  "PWM clk"; and

- Ensures the driver enables a clock before querying its rate with
  clk_get_rate(), as stated as a requirement in that function's
  documentation.

This version of the series incorporates Uwe Kleine-König's feedback on
v3 and includes these changes:

- Patch 1's commit message has been edited slightly to improve
  readability, and the error message updated by the patch now reads
  "prepare enable" rather than just "enable" for consistency with the
  error message above it in the code.

- Patch 3's commit message now mentions consistency with the device
  tree.

- Patch 4 has been simplified and now just moves the device-enabled
  check ahead of the call to pwmchip_add(). It no longers changes any
  error-handling behaviour, and an extraneous pair of parentheses has
  been removed.

Patches 2 and 5 are unchanged from v3, while the remaining 2 patches
present in v3 (which removed goto targets from and reordered some
operations in rockchip_pwm_probe()) have been dropped.

I've tested these changes on my Pinebook Pro (RK3399 with a PWM-driven
backlight enabled by U-Boot) and ROCK64 (RK3328) and they appear to
work fine.

[0] https://www.spinics.net/lists/linux-pwm/msg14611.html

--
Simon South
simon@simonsouth.net


Simon South (5):
  pwm: rockchip: Enable APB clock during register access while probing
  pwm: rockchip: rockchip_pwm_probe(): Remove superfluous
    clk_unprepare()
  pwm: rockchip: Replace "bus clk" with "PWM clk"
  pwm: rockchip: Eliminate potential race condition when probing
  pwm: rockchip: Enable clock before calling clk_get_rate()

 drivers/pwm/pwm-rockchip.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

-- 
2.30.0


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Simon South <simon@simonsouth.net>
To: tpiepho@gmail.com, thierry.reding@gmail.com,
	u.kleine-koenig@pengutronix.de, robin.murphy@arm.com,
	lee.jones@linaro.org, heiko@sntech.de, bbrezillon@kernel.org,
	david.wu@rock-chips.com, steven.liu@rock-chips.com,
	linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Cc: simon@simonsouth.net
Subject: [PATCH v4 0/5] pwm: rockchip: Eliminate potential race condition when probing
Date: Tue, 19 Jan 2021 11:12:04 -0500	[thread overview]
Message-ID: <cover.1610976129.git.simon@simonsouth.net> (raw)

This patch series eliminates the race condition Trent Piepho
identified[0] in the Rockchip PWM driver's rockchip_pwm_probe()
function, by moving code that checks whether a device is enabled ahead
of the code that registers it via pwmchip_add().

It includes several other small fixes and improvements to the driver
as well: It also

- Fixes a potential kernel hang introduced by my earlier commit
  457f74abbed0 ("pwm: rockchip: Keep enabled PWMs running while
  probing") by ensuring a device's APB clock is enabled before its
  registers are accessed;

- Removes a superfluous call to clk_unprepare() that could produce
  warnings from the kernel;

- Clarifies error messages from the driver by replacing "bus clk" with
  "PWM clk"; and

- Ensures the driver enables a clock before querying its rate with
  clk_get_rate(), as stated as a requirement in that function's
  documentation.

This version of the series incorporates Uwe Kleine-König's feedback on
v3 and includes these changes:

- Patch 1's commit message has been edited slightly to improve
  readability, and the error message updated by the patch now reads
  "prepare enable" rather than just "enable" for consistency with the
  error message above it in the code.

- Patch 3's commit message now mentions consistency with the device
  tree.

- Patch 4 has been simplified and now just moves the device-enabled
  check ahead of the call to pwmchip_add(). It no longers changes any
  error-handling behaviour, and an extraneous pair of parentheses has
  been removed.

Patches 2 and 5 are unchanged from v3, while the remaining 2 patches
present in v3 (which removed goto targets from and reordered some
operations in rockchip_pwm_probe()) have been dropped.

I've tested these changes on my Pinebook Pro (RK3399 with a PWM-driven
backlight enabled by U-Boot) and ROCK64 (RK3328) and they appear to
work fine.

[0] https://www.spinics.net/lists/linux-pwm/msg14611.html

--
Simon South
simon@simonsouth.net


Simon South (5):
  pwm: rockchip: Enable APB clock during register access while probing
  pwm: rockchip: rockchip_pwm_probe(): Remove superfluous
    clk_unprepare()
  pwm: rockchip: Replace "bus clk" with "PWM clk"
  pwm: rockchip: Eliminate potential race condition when probing
  pwm: rockchip: Enable clock before calling clk_get_rate()

 drivers/pwm/pwm-rockchip.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

-- 
2.30.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2021-01-19 18:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 16:12 Simon South [this message]
2021-01-19 16:12 ` [PATCH v4 0/5] pwm: rockchip: Eliminate potential race condition when probing Simon South
2021-01-19 16:12 ` Simon South
2021-01-19 16:12 ` [PATCH v4 1/5] pwm: rockchip: Enable APB clock during register access while probing Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 16:12 ` [PATCH v4 2/5] pwm: rockchip: rockchip_pwm_probe(): Remove superfluous clk_unprepare() Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 16:12 ` [PATCH v4 3/5] pwm: rockchip: Replace "bus clk" with "PWM clk" Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 16:12 ` [PATCH v4 4/5] pwm: rockchip: Eliminate potential race condition when probing Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 16:12 ` [PATCH v4 5/5] pwm: rockchip: Enable clock before calling clk_get_rate() Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 16:12   ` Simon South
2021-01-19 19:22   ` Uwe Kleine-König
2021-01-19 19:22     ` Uwe Kleine-König
2021-01-19 19:22     ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1610976129.git.simon@simonsouth.net \
    --to=simon@simonsouth.net \
    --cc=bbrezillon@kernel.org \
    --cc=david.wu@rock-chips.com \
    --cc=heiko@sntech.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=robin.murphy@arm.com \
    --cc=steven.liu@rock-chips.com \
    --cc=thierry.reding@gmail.com \
    --cc=tpiepho@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.