All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Ayyathurai, Vijayakannan" <vijayakannan.ayyathurai@intel.com>
Cc: "thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"u.kleine-koenig@pengutronix.de" <u.kleine-koenig@pengutronix.de>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"Wan Mohamad,
	Wan Ahmad Zainie"  <wan.ahmad.zainie.wan.mohamad@intel.com>,
	"mgross@linux.intel.com" <mgross@linux.intel.com>,
	"Raja Subramanian,
	Lakshmi Bai"  <lakshmi.bai.raja.subramanian@intel.com>
Subject: Re: [PATCH v12 1/2] pwm: Add PWM driver for Intel Keem Bay
Date: Fri, 16 Oct 2020 12:21:27 +0300	[thread overview]
Message-ID: <20201016092127.GF4077@smile.fi.intel.com> (raw)
In-Reply-To: <DM6PR11MB425089996A0CC9A43CBC50C5FB030@DM6PR11MB4250.namprd11.prod.outlook.com>

On Fri, Oct 16, 2020 at 03:18:08AM +0000, Ayyathurai, Vijayakannan wrote:
> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 
> Sent: Thursday, 15 October, 2020 4:12 PM
> On Thu, Oct 15, 2020 at 03:36:09AM +0800, vijayakannan.ayyathurai@intel.com wrote:
> > From: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com>

...

> > +	priv->clk = devm_clk_get(dev, NULL);
> > +	if (IS_ERR(priv->clk))
> > +		return dev_err_probe(dev, PTR_ERR(priv->clk), "Failed to get 
> > +clock\n");
> > +
> > +	ret = clk_prepare_enable(priv->clk);
> > +	if (ret)
> > +		return ret;
> > +
> > +	priv->base = devm_platform_ioremap_resource(pdev, 0);
> > +	if (IS_ERR(priv->base)) {
> 
> > +		clk_disable_unprepare(priv->clk);
> 
> See below.
> 
> > +		return PTR_ERR(priv->base);
> > +	}
> > +
> > +	priv->chip.base = -1;
> > +	priv->chip.dev = dev;
> > +	priv->chip.ops = &keembay_pwm_ops;
> > +	priv->chip.npwm = KMB_TOTAL_PWM_CHANNELS;
> > +
> > +	ret = pwmchip_add(&priv->chip);
> > +	if (ret) {
> > +		dev_err(dev, "Failed to add PWM chip: %pe\n", ERR_PTR(ret));
> 
> > +		clk_disable_unprepare(priv->clk);
> 
> This messes up with ordering of things.
> 
> That's why devm golden rule is either all or none. You may fix this by switching to devm_add_action_or_reset().
> 
> One of possible way is like in below drivers:
> 
> 	% git grep -n devm_add_action_or_reset.*disable_unprepare -- drivers/
> 
> But it may be fixed in follow up change. Depends on maintainers' wishes.
> 
> Sure. I shall incorporate and check based on maintainers wish in the next version.
> 
> > +		return ret;
> > +	}
> > +
> > +	platform_set_drvdata(pdev, priv);
> > +
> > +	return 0;
> > +}
> > +
> > +static int keembay_pwm_remove(struct platform_device *pdev) {
> > +	struct keembay_pwm *priv = platform_get_drvdata(pdev);
> > +	int ret;
> > +
> > +	ret = pwmchip_remove(&priv->chip);
> > +	clk_disable_unprepare(priv->clk);
> > +
> > +	return ret;
> 
> ...and this will be simplified to
> 
> 	return pwmchip_remove(&priv->chip);
> 
> Until v10, It is as per your suggestion. But I have changed it in v11 to overcome the issue mentioned by Uwe. I have kept the snip of v10 FYR below.
> 
> //Start snip from v10 review mailing list
> //> +static int keembay_pwm_remove(struct platform_device *pdev) {
> //> +	struct keembay_pwm *priv = platform_get_drvdata(pdev);
> //> +
> //> +	clk_disable_unprepare(priv->clk);
> //> +
> //> +	return pwmchip_remove(&priv->chip);
> //
> //You have to call pwmchip_remove first. Otherwise you're stopping the PWM while the framework still believes everything to be fine.
> //
> //> +}
> //End snip from v10 review mailing review
> 
> > +}

What I said does not contradict with what Uwe said. So, please, fix ordering
either by dropping devm_ in the middle or adding devm_ action.

Now you moved serious ordering issue in ->remove() (which Uwe noted) to less
serious in ->probe(). But issue is still present.

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2020-10-16  9:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14 19:36 [PATCH v12 0/2] Add PWM support for Intel Keem Bay SoC vijayakannan.ayyathurai
2020-10-14 19:36 ` [PATCH v12 1/2] pwm: Add PWM driver for Intel Keem Bay vijayakannan.ayyathurai
2020-10-14 20:04   ` Uwe Kleine-König
2020-10-15 10:42   ` Andy Shevchenko
2020-10-16  3:18     ` Ayyathurai, Vijayakannan
2020-10-16  7:34       ` Uwe Kleine-König
2020-10-16  8:32         ` Ayyathurai, Vijayakannan
2020-10-16  9:25           ` Andy Shevchenko
2020-10-19  5:44         ` Ayyathurai, Vijayakannan
2020-10-19  6:42           ` Uwe Kleine-König
2020-10-16  9:21       ` Andy Shevchenko [this message]
2020-10-19  6:46         ` Uwe Kleine-König
2020-10-16  6:24     ` Uwe Kleine-König
2020-10-16  9:24       ` Andy Shevchenko
2020-10-14 19:36 ` [PATCH v12 2/2] dt-bindings: pwm: keembay: Add bindings for Intel Keem Bay PWM vijayakannan.ayyathurai
2020-10-16 16:04   ` Rob Herring
2020-10-16 19:34     ` Ayyathurai, Vijayakannan

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=20201016092127.GF4077@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=lakshmi.bai.raja.subramanian@intel.com \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mgross@linux.intel.com \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vijayakannan.ayyathurai@intel.com \
    --cc=wan.ahmad.zainie.wan.mohamad@intel.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.