All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bo Shen <voice.shen@atmel.com>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	devicetree@vger.kernel.org, linux-pwm@vger.kernel.org,
	nicolas.ferre@atmel.com, linux-kernel@vger.kernel.org,
	plagnioj@jcrosoft.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4] PWM: atmel-pwm: add PWM controller driver
Date: Sun, 29 Sep 2013 18:02:37 +0800	[thread overview]
Message-ID: <5247FABD.9070405@atmel.com> (raw)
In-Reply-To: <5245B7D7.2040405@free-electrons.com>

Hi Alexandre,

On 9/28/2013 00:52, Alexandre Belloni wrote:
[snip]

>> +static int atmel_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
>> +{
>> +	struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
>> +	int ret;
>> +
>> +	ret = clk_enable(atmel_pwm->clk);
>> +	if (ret) {
>> +		pr_err("failed to enable pwm clock\n");
>> +		return ret;
>> +	}
>> +
>
> This will increment clk->enable_count each time it is called.

Yes, that's true.

>> +	atmel_pwm_writel(atmel_pwm, PWM_ENA, 1 << pwm->hwpwm);
>> +
>> +	return 0;
>> +}
>> +
>> +static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
>> +{
>> +	struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
>> +	u32 val;
>> +
>> +	atmel_pwm_writel(atmel_pwm, PWM_DIS, 1 << pwm->hwpwm);
>> +
>> +	val = atmel_pwm_readl(atmel_pwm, PWM_SR);
>> +	if ((val & PWM_SR_ALL_CH_ON) == 0)
>> +		clk_disable(atmel_pwm->clk);
>> +}
>
> This will decrement clk->enable_count only once there are no pwm enabled
> anymore.  So in you enable more than one channel, you will never disable
> the clock. The simple fix is to always call clk_diasble, regardless of
> the state of the other channels.

Thank for point out this.

I see you have sent out a patch to fix it (however the other contents of 
your patch doesn't work). So, do you prefer I send out v5 patch to fix 
this? or you fix your patch at same time fix this issue?

Best Regards,
Bo Shen

WARNING: multiple messages have this Message-ID (diff)
From: voice.shen@atmel.com (Bo Shen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4] PWM: atmel-pwm: add PWM controller driver
Date: Sun, 29 Sep 2013 18:02:37 +0800	[thread overview]
Message-ID: <5247FABD.9070405@atmel.com> (raw)
In-Reply-To: <5245B7D7.2040405@free-electrons.com>

Hi Alexandre,

On 9/28/2013 00:52, Alexandre Belloni wrote:
[snip]

>> +static int atmel_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
>> +{
>> +	struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
>> +	int ret;
>> +
>> +	ret = clk_enable(atmel_pwm->clk);
>> +	if (ret) {
>> +		pr_err("failed to enable pwm clock\n");
>> +		return ret;
>> +	}
>> +
>
> This will increment clk->enable_count each time it is called.

Yes, that's true.

>> +	atmel_pwm_writel(atmel_pwm, PWM_ENA, 1 << pwm->hwpwm);
>> +
>> +	return 0;
>> +}
>> +
>> +static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
>> +{
>> +	struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
>> +	u32 val;
>> +
>> +	atmel_pwm_writel(atmel_pwm, PWM_DIS, 1 << pwm->hwpwm);
>> +
>> +	val = atmel_pwm_readl(atmel_pwm, PWM_SR);
>> +	if ((val & PWM_SR_ALL_CH_ON) == 0)
>> +		clk_disable(atmel_pwm->clk);
>> +}
>
> This will decrement clk->enable_count only once there are no pwm enabled
> anymore.  So in you enable more than one channel, you will never disable
> the clock. The simple fix is to always call clk_diasble, regardless of
> the state of the other channels.

Thank for point out this.

I see you have sent out a patch to fix it (however the other contents of 
your patch doesn't work). So, do you prefer I send out v5 patch to fix 
this? or you fix your patch at same time fix this issue?

Best Regards,
Bo Shen

WARNING: multiple messages have this Message-ID (diff)
From: Bo Shen <voice.shen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
To: Alexandre Belloni
	<alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Thierry Reding
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH v4] PWM: atmel-pwm: add PWM controller driver
Date: Sun, 29 Sep 2013 18:02:37 +0800	[thread overview]
Message-ID: <5247FABD.9070405@atmel.com> (raw)
In-Reply-To: <5245B7D7.2040405-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Hi Alexandre,

On 9/28/2013 00:52, Alexandre Belloni wrote:
[snip]

>> +static int atmel_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
>> +{
>> +	struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
>> +	int ret;
>> +
>> +	ret = clk_enable(atmel_pwm->clk);
>> +	if (ret) {
>> +		pr_err("failed to enable pwm clock\n");
>> +		return ret;
>> +	}
>> +
>
> This will increment clk->enable_count each time it is called.

Yes, that's true.

>> +	atmel_pwm_writel(atmel_pwm, PWM_ENA, 1 << pwm->hwpwm);
>> +
>> +	return 0;
>> +}
>> +
>> +static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
>> +{
>> +	struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
>> +	u32 val;
>> +
>> +	atmel_pwm_writel(atmel_pwm, PWM_DIS, 1 << pwm->hwpwm);
>> +
>> +	val = atmel_pwm_readl(atmel_pwm, PWM_SR);
>> +	if ((val & PWM_SR_ALL_CH_ON) == 0)
>> +		clk_disable(atmel_pwm->clk);
>> +}
>
> This will decrement clk->enable_count only once there are no pwm enabled
> anymore.  So in you enable more than one channel, you will never disable
> the clock. The simple fix is to always call clk_diasble, regardless of
> the state of the other channels.

Thank for point out this.

I see you have sent out a patch to fix it (however the other contents of 
your patch doesn't work). So, do you prefer I send out v5 patch to fix 
this? or you fix your patch at same time fix this issue?

Best Regards,
Bo Shen
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Bo Shen <voice.shen@atmel.com>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	<devicetree@vger.kernel.org>, <linux-pwm@vger.kernel.org>,
	<nicolas.ferre@atmel.com>, <linux-kernel@vger.kernel.org>,
	<plagnioj@jcrosoft.com>, <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v4] PWM: atmel-pwm: add PWM controller driver
Date: Sun, 29 Sep 2013 18:02:37 +0800	[thread overview]
Message-ID: <5247FABD.9070405@atmel.com> (raw)
In-Reply-To: <5245B7D7.2040405@free-electrons.com>

Hi Alexandre,

On 9/28/2013 00:52, Alexandre Belloni wrote:
[snip]

>> +static int atmel_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
>> +{
>> +	struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
>> +	int ret;
>> +
>> +	ret = clk_enable(atmel_pwm->clk);
>> +	if (ret) {
>> +		pr_err("failed to enable pwm clock\n");
>> +		return ret;
>> +	}
>> +
>
> This will increment clk->enable_count each time it is called.

Yes, that's true.

>> +	atmel_pwm_writel(atmel_pwm, PWM_ENA, 1 << pwm->hwpwm);
>> +
>> +	return 0;
>> +}
>> +
>> +static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
>> +{
>> +	struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
>> +	u32 val;
>> +
>> +	atmel_pwm_writel(atmel_pwm, PWM_DIS, 1 << pwm->hwpwm);
>> +
>> +	val = atmel_pwm_readl(atmel_pwm, PWM_SR);
>> +	if ((val & PWM_SR_ALL_CH_ON) == 0)
>> +		clk_disable(atmel_pwm->clk);
>> +}
>
> This will decrement clk->enable_count only once there are no pwm enabled
> anymore.  So in you enable more than one channel, you will never disable
> the clock. The simple fix is to always call clk_diasble, regardless of
> the state of the other channels.

Thank for point out this.

I see you have sent out a patch to fix it (however the other contents of 
your patch doesn't work). So, do you prefer I send out v5 patch to fix 
this? or you fix your patch at same time fix this issue?

Best Regards,
Bo Shen

  reply	other threads:[~2013-09-29 10:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-25  3:27 [PATCH v4] PWM: atmel-pwm: add PWM controller driver Bo Shen
2013-09-25  3:27 ` Bo Shen
2013-09-25  3:27 ` Bo Shen
2013-09-25  7:29 ` Nicolas Ferre
2013-09-25  7:29   ` Nicolas Ferre
2013-09-25  7:29   ` Nicolas Ferre
2013-09-25 13:15   ` Alexandre Belloni
2013-09-25 13:15     ` Alexandre Belloni
2013-09-27 16:52 ` Alexandre Belloni
2013-09-27 16:52   ` Alexandre Belloni
2013-09-27 16:52   ` Alexandre Belloni
2013-09-29 10:02   ` Bo Shen [this message]
2013-09-29 10:02     ` Bo Shen
2013-09-29 10:02     ` Bo Shen
2013-09-29 10:02     ` Bo Shen
2013-09-29 15:56     ` Alexandre Belloni
2013-09-29 15:56       ` Alexandre Belloni
2013-09-29 15:56       ` Alexandre Belloni

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=5247FABD.9070405@atmel.com \
    --to=voice.shen@atmel.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=thierry.reding@gmail.com \
    /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.