linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] base: fix a missing check of clk_prepare
@ 2018-12-26  2:47 Kangjie Lu
  2018-12-26  9:37 ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Kangjie Lu @ 2018-12-26  2:47 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Rafael J. Wysocki, Pavel Machek, Len Brown,
	Greg Kroah-Hartman, linux-pm, linux-kernel

clk_prepare() could fail, so let's check its status, and if it fails,
issue an error message.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/base/power/clock_ops.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
index 5a42ae4078c2..cb6144fb24e2 100644
--- a/drivers/base/power/clock_ops.c
+++ b/drivers/base/power/clock_ops.c
@@ -65,7 +65,9 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
 	if (IS_ERR(ce->clk)) {
 		ce->status = PCE_STATUS_ERROR;
 	} else {
-		clk_prepare(ce->clk);
+		if (clk_prepare(ce->clk))
+			dev_err(dev, "clk_prepare failed.\n");
+
 		ce->status = PCE_STATUS_ACQUIRED;
 		dev_dbg(dev, "Clock %pC con_id %s managed by runtime PM.\n",
 			ce->clk, ce->con_id);
-- 
2.17.2 (Apple Git-113)


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] base: fix a missing check of clk_prepare
  2018-12-26  2:47 [PATCH] base: fix a missing check of clk_prepare Kangjie Lu
@ 2018-12-26  9:37 ` Rafael J. Wysocki
  2018-12-31 17:25   ` Pavel Machek
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2018-12-26  9:37 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Rafael J. Wysocki, Pavel Machek, Len Brown,
	Greg Kroah-Hartman, Linux PM, Linux Kernel Mailing List

On Wed, Dec 26, 2018 at 3:47 AM Kangjie Lu <kjlu@umn.edu> wrote:
>
> clk_prepare() could fail, so let's check its status, and if it fails,
> issue an error message.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/base/power/clock_ops.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> index 5a42ae4078c2..cb6144fb24e2 100644
> --- a/drivers/base/power/clock_ops.c
> +++ b/drivers/base/power/clock_ops.c
> @@ -65,7 +65,9 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
>         if (IS_ERR(ce->clk)) {
>                 ce->status = PCE_STATUS_ERROR;
>         } else {
> -               clk_prepare(ce->clk);
> +               if (clk_prepare(ce->clk))
> +                       dev_err(dev, "clk_prepare failed.\n");

I'm not sure that this is useful.  The code continues regardless of
the error anyway and it should at least set ce->status to
PCE_STATUS_ERROR in the failing case.

Have you seen a failure in this particular spot in practice?

> +
>                 ce->status = PCE_STATUS_ACQUIRED;
>                 dev_dbg(dev, "Clock %pC con_id %s managed by runtime PM.\n",
>                         ce->clk, ce->con_id);
> --
> 2.17.2 (Apple Git-113)
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] base: fix a missing check of clk_prepare
  2018-12-26  9:37 ` Rafael J. Wysocki
@ 2018-12-31 17:25   ` Pavel Machek
  2019-01-01 20:13     ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Machek @ 2018-12-31 17:25 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: kjlu, pakki001, Rafael J. Wysocki, Len Brown, Greg Kroah-Hartman,
	Linux PM, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]

On Wed 2018-12-26 10:37:54, Rafael J. Wysocki wrote:
> On Wed, Dec 26, 2018 at 3:47 AM Kangjie Lu <kjlu@umn.edu> wrote:
> >
> > clk_prepare() could fail, so let's check its status, and if it fails,
> > issue an error message.
> >
> > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > ---
> >  drivers/base/power/clock_ops.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> > index 5a42ae4078c2..cb6144fb24e2 100644
> > --- a/drivers/base/power/clock_ops.c
> > +++ b/drivers/base/power/clock_ops.c
> > @@ -65,7 +65,9 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
> >         if (IS_ERR(ce->clk)) {
> >                 ce->status = PCE_STATUS_ERROR;
> >         } else {
> > -               clk_prepare(ce->clk);
> > +               if (clk_prepare(ce->clk))
> > +                       dev_err(dev, "clk_prepare failed.\n");
> 
> I'm not sure that this is useful.  The code continues regardless of
> the error anyway and it should at least set ce->status to
> PCE_STATUS_ERROR in the failing case.

Maybe this is not complete fix, but dev_err() is preferable to silent
failure.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] base: fix a missing check of clk_prepare
  2018-12-31 17:25   ` Pavel Machek
@ 2019-01-01 20:13     ` Rafael J. Wysocki
  2019-01-01 20:21       ` Pavel Machek
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2019-01-01 20:13 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Rafael J. Wysocki, kjlu, pakki001, Rafael J. Wysocki, Len Brown,
	Greg Kroah-Hartman, Linux PM, Linux Kernel Mailing List

On Mon, Dec 31, 2018 at 6:25 PM Pavel Machek <pavel@ucw.cz> wrote:
>
> On Wed 2018-12-26 10:37:54, Rafael J. Wysocki wrote:
> > On Wed, Dec 26, 2018 at 3:47 AM Kangjie Lu <kjlu@umn.edu> wrote:
> > >
> > > clk_prepare() could fail, so let's check its status, and if it fails,
> > > issue an error message.
> > >
> > > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > > ---
> > >  drivers/base/power/clock_ops.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> > > index 5a42ae4078c2..cb6144fb24e2 100644
> > > --- a/drivers/base/power/clock_ops.c
> > > +++ b/drivers/base/power/clock_ops.c
> > > @@ -65,7 +65,9 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
> > >         if (IS_ERR(ce->clk)) {
> > >                 ce->status = PCE_STATUS_ERROR;
> > >         } else {
> > > -               clk_prepare(ce->clk);
> > > +               if (clk_prepare(ce->clk))
> > > +                       dev_err(dev, "clk_prepare failed.\n");
> >
> > I'm not sure that this is useful.  The code continues regardless of
> > the error anyway and it should at least set ce->status to
> > PCE_STATUS_ERROR in the failing case.
>
> Maybe this is not complete fix, but dev_err() is preferable to silent
> failure.

Preferable to you I suppose?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] base: fix a missing check of clk_prepare
  2019-01-01 20:13     ` Rafael J. Wysocki
@ 2019-01-01 20:21       ` Pavel Machek
  2019-01-01 21:05         ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Machek @ 2019-01-01 20:21 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: kjlu, pakki001, Rafael J. Wysocki, Len Brown, Greg Kroah-Hartman,
	Linux PM, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1751 bytes --]

On Tue 2019-01-01 21:13:01, Rafael J. Wysocki wrote:
> On Mon, Dec 31, 2018 at 6:25 PM Pavel Machek <pavel@ucw.cz> wrote:
> >
> > On Wed 2018-12-26 10:37:54, Rafael J. Wysocki wrote:
> > > On Wed, Dec 26, 2018 at 3:47 AM Kangjie Lu <kjlu@umn.edu> wrote:
> > > >
> > > > clk_prepare() could fail, so let's check its status, and if it fails,
> > > > issue an error message.
> > > >
> > > > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > > > ---
> > > >  drivers/base/power/clock_ops.c | 4 +++-
> > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> > > > index 5a42ae4078c2..cb6144fb24e2 100644
> > > > --- a/drivers/base/power/clock_ops.c
> > > > +++ b/drivers/base/power/clock_ops.c
> > > > @@ -65,7 +65,9 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
> > > >         if (IS_ERR(ce->clk)) {
> > > >                 ce->status = PCE_STATUS_ERROR;
> > > >         } else {
> > > > -               clk_prepare(ce->clk);
> > > > +               if (clk_prepare(ce->clk))
> > > > +                       dev_err(dev, "clk_prepare failed.\n");
> > >
> > > I'm not sure that this is useful.  The code continues regardless of
> > > the error anyway and it should at least set ce->status to
> > > PCE_STATUS_ERROR in the failing case.
> >
> > Maybe this is not complete fix, but dev_err() is preferable to silent
> > failure.
> 
> Preferable to you I suppose?

Preferable to the poor person trying to figure out why his machine
does not work?
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] base: fix a missing check of clk_prepare
  2019-01-01 20:21       ` Pavel Machek
@ 2019-01-01 21:05         ` Rafael J. Wysocki
  2019-02-11 13:24           ` Pavel Machek
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2019-01-01 21:05 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Rafael J. Wysocki, kjlu, pakki001, Rafael J. Wysocki, Len Brown,
	Greg Kroah-Hartman, Linux PM, Linux Kernel Mailing List

On Tue, Jan 1, 2019 at 9:21 PM Pavel Machek <pavel@ucw.cz> wrote:
>
> On Tue 2019-01-01 21:13:01, Rafael J. Wysocki wrote:
> > On Mon, Dec 31, 2018 at 6:25 PM Pavel Machek <pavel@ucw.cz> wrote:
> > >
> > > On Wed 2018-12-26 10:37:54, Rafael J. Wysocki wrote:
> > > > On Wed, Dec 26, 2018 at 3:47 AM Kangjie Lu <kjlu@umn.edu> wrote:
> > > > >
> > > > > clk_prepare() could fail, so let's check its status, and if it fails,
> > > > > issue an error message.
> > > > >
> > > > > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > > > > ---
> > > > >  drivers/base/power/clock_ops.c | 4 +++-
> > > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> > > > > index 5a42ae4078c2..cb6144fb24e2 100644
> > > > > --- a/drivers/base/power/clock_ops.c
> > > > > +++ b/drivers/base/power/clock_ops.c
> > > > > @@ -65,7 +65,9 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
> > > > >         if (IS_ERR(ce->clk)) {
> > > > >                 ce->status = PCE_STATUS_ERROR;
> > > > >         } else {
> > > > > -               clk_prepare(ce->clk);
> > > > > +               if (clk_prepare(ce->clk))
> > > > > +                       dev_err(dev, "clk_prepare failed.\n");
> > > >
> > > > I'm not sure that this is useful.  The code continues regardless of
> > > > the error anyway and it should at least set ce->status to
> > > > PCE_STATUS_ERROR in the failing case.
> > >
> > > Maybe this is not complete fix, but dev_err() is preferable to silent
> > > failure.
> >
> > Preferable to you I suppose?
>
> Preferable to the poor person trying to figure out why his machine
> does not work?

Not really, unless that person knows what the message means.

Honestly, what would you do if you saw that message?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] base: fix a missing check of clk_prepare
  2019-01-01 21:05         ` Rafael J. Wysocki
@ 2019-02-11 13:24           ` Pavel Machek
  0 siblings, 0 replies; 7+ messages in thread
From: Pavel Machek @ 2019-02-11 13:24 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: kjlu, pakki001, Rafael J. Wysocki, Len Brown, Greg Kroah-Hartman,
	Linux PM, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 2281 bytes --]

On Tue 2019-01-01 22:05:39, Rafael J. Wysocki wrote:
> On Tue, Jan 1, 2019 at 9:21 PM Pavel Machek <pavel@ucw.cz> wrote:
> >
> > On Tue 2019-01-01 21:13:01, Rafael J. Wysocki wrote:
> > > On Mon, Dec 31, 2018 at 6:25 PM Pavel Machek <pavel@ucw.cz> wrote:
> > > >
> > > > On Wed 2018-12-26 10:37:54, Rafael J. Wysocki wrote:
> > > > > On Wed, Dec 26, 2018 at 3:47 AM Kangjie Lu <kjlu@umn.edu> wrote:
> > > > > >
> > > > > > clk_prepare() could fail, so let's check its status, and if it fails,
> > > > > > issue an error message.
> > > > > >
> > > > > > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > > > > > ---
> > > > > >  drivers/base/power/clock_ops.c | 4 +++-
> > > > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> > > > > > index 5a42ae4078c2..cb6144fb24e2 100644
> > > > > > --- a/drivers/base/power/clock_ops.c
> > > > > > +++ b/drivers/base/power/clock_ops.c
> > > > > > @@ -65,7 +65,9 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
> > > > > >         if (IS_ERR(ce->clk)) {
> > > > > >                 ce->status = PCE_STATUS_ERROR;
> > > > > >         } else {
> > > > > > -               clk_prepare(ce->clk);
> > > > > > +               if (clk_prepare(ce->clk))
> > > > > > +                       dev_err(dev, "clk_prepare failed.\n");
> > > > >
> > > > > I'm not sure that this is useful.  The code continues regardless of
> > > > > the error anyway and it should at least set ce->status to
> > > > > PCE_STATUS_ERROR in the failing case.
> > > >
> > > > Maybe this is not complete fix, but dev_err() is preferable to silent
> > > > failure.
> > >
> > > Preferable to you I suppose?
> >
> > Preferable to the poor person trying to figure out why his machine
> > does not work?
> 
> Not really, unless that person knows what the message means.
> 
> Honestly, what would you do if you saw that message?

Grep it in the kernel sources. Having something to grep for
(vs. machine that fails to work properly) is quite important.
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-02-11 13:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-26  2:47 [PATCH] base: fix a missing check of clk_prepare Kangjie Lu
2018-12-26  9:37 ` Rafael J. Wysocki
2018-12-31 17:25   ` Pavel Machek
2019-01-01 20:13     ` Rafael J. Wysocki
2019-01-01 20:21       ` Pavel Machek
2019-01-01 21:05         ` Rafael J. Wysocki
2019-02-11 13:24           ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).