Linux PWM subsystem development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
	"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
	"Linux PWM List" <linux-pwm@vger.kernel.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH 2/3] pwm: renesas-tpu: Fix late Runtime PM enablement
Date: Mon, 16 Mar 2020 18:11:46 +0200	[thread overview]
Message-ID: <20200316161146.GQ4732@pendragon.ideasonboard.com> (raw)
In-Reply-To: <CAMuHMdXP=QpOTpr8Ave0jvJ_KPPK5_R=_2F5JDNR7zvQk3W5PQ@mail.gmail.com>

Hi Geert,

On Mon, Mar 16, 2020 at 05:06:12PM +0100, Geert Uytterhoeven wrote:
> On Mon, Mar 16, 2020 at 5:01 PM Uwe Kleine-König wrote:
> > On Mon, Mar 16, 2020 at 11:32:15AM +0100, Geert Uytterhoeven wrote:
> > > Runtime PM should be enabled before calling pwmchip_add(), as PWM users
> > > can appear immediately after the PWM chip has been added.
> > > Likewise, Runtime PM should always be disabled after the removal of the
> > > PWM chip, even if the latter failed.
> > >
> > > Fixes: 99b82abb0a35b073 ("pwm: Add Renesas TPU PWM driver")
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > >  drivers/pwm/pwm-renesas-tpu.c | 9 ++++-----
> > >  1 file changed, 4 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.c
> > > index 4a855a21b782dea3..8032acc84161a9dd 100644
> > > --- a/drivers/pwm/pwm-renesas-tpu.c
> > > +++ b/drivers/pwm/pwm-renesas-tpu.c
> > > @@ -415,16 +415,17 @@ static int tpu_probe(struct platform_device *pdev)
> > >       tpu->chip.base = -1;
> > >       tpu->chip.npwm = TPU_CHANNEL_MAX;
> > >
> > > +     pm_runtime_enable(&pdev->dev);
> > > +
> > >       ret = pwmchip_add(&tpu->chip);
> > >       if (ret < 0) {
> > >               dev_err(&pdev->dev, "failed to register PWM chip\n");
> > > +             pm_runtime_disable(&pdev->dev);
> > >               return ret;
> > >       }
> > >
> > >       dev_info(&pdev->dev, "TPU PWM %d registered\n", tpu->pdev->id);
> > >
> > > -     pm_runtime_enable(&pdev->dev);
> > > -
> > >       return 0;
> > >  }
> > >
> > > @@ -434,12 +435,10 @@ static int tpu_remove(struct platform_device *pdev)
> > >       int ret;
> > >
> > >       ret = pwmchip_remove(&tpu->chip);
> > > -     if (ret)
> > > -             return ret;
> > >
> > >       pm_runtime_disable(&pdev->dev);
> > >
> > > -     return 0;
> > > +     return ret;
> > >  }
> >
> > Maybe I was a bit quick with my reply to the previous patch. I wonder if
> > it is right to call pm_runtime_disable if pwmchip_remove failed?
> 
> While the pwmchip may still exist, the hardware is unmapped and no
> longer accessible.

Is it the case on module unload, doesn't a .remove() failure prevent the
module from being unloaded, and keeps the device associated with the
driver ? I haven't actually checked myself.

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2020-03-16 16:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-16 10:32 [PATCH 0/3] pwm: Renesas R-Car and TPU fixes Geert Uytterhoeven
2020-03-16 10:32 ` [PATCH 1/3] pwm: rcar: Fix late Runtime PM enablement Geert Uytterhoeven
2020-03-16 15:40   ` Uwe Kleine-König
2020-03-16 15:42     ` Geert Uytterhoeven
2020-03-16 15:57       ` Uwe Kleine-König
2020-03-16 16:02   ` Laurent Pinchart
2020-03-16 10:32 ` [PATCH 2/3] pwm: renesas-tpu: " Geert Uytterhoeven
2020-03-16 16:01   ` Uwe Kleine-König
2020-03-16 16:04     ` Laurent Pinchart
2020-03-16 16:06     ` Geert Uytterhoeven
2020-03-16 16:11       ` Laurent Pinchart [this message]
2020-03-16 10:32 ` [PATCH 3/3] pwm: renesas-tpu: Drop confusing registered message Geert Uytterhoeven
2020-03-16 16:05   ` Laurent Pinchart
2020-03-16 16:27   ` 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=20200316161146.GQ4732@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=yoshihiro.shimoda.uh@renesas.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox