All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fenglin Wu" <fenglin.wu@oss.qualcomm.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH 4/4] leds: rgb: leds-qcom-lpg: Add PWM frequency mode support
Date: Tue, 17 Nov 2026 09:51:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-218537@kernel.org> (raw)
In-Reply-To: <20261117-led-qcom-leds-multiple-fixes-and-pwm-fm-support-v1-4-7a862240683f@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] leds: rgb: leds-qcom-lpg: corrupted get_state() after
  disabling freq mode
--

commit 2a10b372b4d1a0325069cf3509d6445ec569b2c0
Author: Fenglin Wu <fenglin.wu@oss.qualcomm.com>

leds: rgb: leds-qcom-lpg: Add PWM frequency mode support

This commit adds Frequency Mode (FM) support for capable Qualcomm LPG PWM
channels when a 50% duty cycle is requested and Frequency Mode provides
better timing accuracy than standard PWM mode.

> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index 971f929116063..68c73bce103c3 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c

[ ... ]

> @@ -815,11 +1043,50 @@ static void lpg_apply_dtest(struct lpg_channel *chan)
>  		     chan->dtest_value);
>  }
>  
> -static void lpg_apply(struct lpg_channel *chan)
> +static int lpg_apply_freq_mode(struct lpg_channel *chan)
> +{
> +	struct lpg *lpg = chan->lpg;
> +	bool enable_freq_mode = false;
> +
> +	if (!chan->freq_mode_capable)
> +		return 0;
> +
> +	if (chan->enable_freq_mode && chan->enabled)
> +		enable_freq_mode = true;
> +
> +	return regmap_update_bits(lpg->map, chan->base + PWM_FM_MODE_REG,
> +				  PWM_FM_ENABLE,
> +				  enable_freq_mode ? PWM_FM_ENABLE : 0);
> +}

[Severity: Medium]
Does clearing PWM_FM_ENABLE in lpg_apply_freq_mode() when a channel is
disabled cause lpg_pwm_get_state() to report a corrupted period and
duty_cycle?

When lpg_pwm_apply() disables a channel that was running in Frequency
Mode, lpg_apply_freq() and lpg_apply_pwm_value() return early because
!chan->enabled, leaving the Frequency Mode register values in
LPG_SIZE_CLK_REG, LPG_PREDIV_CLK_REG and PWM_VALUE_REG.  However,
lpg_apply_freq_mode() still runs and clears PWM_FM_ENABLE in
PWM_FM_MODE_REG (and lpg_pwm_apply() also resets config.enable_freq_mode
to false before checking state->enabled).

A subsequent lpg_pwm_get_state() call then sees PWM_FM_ENABLE == 0 and
decodes the leftover Frequency Mode register values with the standard PWM
formula, corrupting the initial state read back by pwm_device_request() if
the channel is re-requested or re-exported via sysfs.  Should
lpg_apply_freq_mode() return early when !chan->enabled (matching
lpg_apply_freq() and lpg_apply_pwm_value()), with lpg_pwm_apply()
resetting config.enable_freq_mode only inside the if (state->enabled)
block?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-led-qcom-leds-multiple-fixes-and-pwm-fm-support-v1-0-7a862240683f@oss.qualcomm.com?part=4

      reply	other threads:[~2026-11-17  9:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  9:31 [PATCH 0/4] leds: leds-qcom-lpg: Add several fixes and the PWM frequency mode support Fenglin Wu
2026-11-17  9:31 ` [PATCH 1/4] leds: rgb: leds-qcom-lpg: Fix single-entry LUT leak Fenglin Wu
2026-11-17  9:46   ` sashiko-bot
2026-11-17  9:31 ` [PATCH 2/4] leds: rgb: leds-qcom-lpg: Fix LED color balancing in HW pattern mode Fenglin Wu
2026-11-17  9:50   ` sashiko-bot
2026-11-17  9:31 ` [PATCH 3/4] leds: rgb: leds-qcom-lpg: add mutex lock in lpg_pwm_get_state() Fenglin Wu
2026-11-17  9:40   ` sashiko-bot
2026-11-17  9:31 ` [PATCH 4/4] leds: rgb: leds-qcom-lpg: Add PWM frequency mode support Fenglin Wu
2026-11-17  9:51   ` sashiko-bot [this message]

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=sashiko-outbox-218537@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fenglin.wu@oss.qualcomm.com \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.