All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Jassi Brar <jaswinder.singh@linaro.org>
Cc: mythripk@ti.com, linux-omap@vger.kernel.org,
	linux-fbdev@vger.kernel.org, andy.green@linaro.org,
	n-dechesne@ti.com
Subject: Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
Date: Wed, 27 Jun 2012 08:13:41 +0000	[thread overview]
Message-ID: <1340784821.2649.17.camel@deskari> (raw)
In-Reply-To: <CAJe_Zhdz5mAZbyer8fL4YfvcQ8xMF31cPG2zr3AbBNWv8nctnw@mail.gmail.com>

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

On Wed, 2012-06-27 at 13:11 +0530, Jassi Brar wrote:
> On 27 June 2012 11:28, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> >
> > It doesn't matter how omapdss is organized, -EACCES _is_ an error. It
> > tells us that something unexpected happened, and we should react to it
> > somehow.
> >
>   $ git show 5025ce070
> Exactly how omapdss is organised is the reason -EBUSY isn't an error there :)
> Otherwise, omapdss should panic that somehow 'imbalance' has been
> introduced in rpm.

There's no imbalance there, as each get() is still matched by a put(),
and the use count is correct. Your patch may cause either get or put to
be skipped.

In 5025ce070 the function in question is dss_runtime_put(), and -EBUSY
_is_ an error there. Normally if you call pm_runtime_put_sync() and the
use count drops to zero, the device should be suspended. In this case,
however, it won't be suspended as a child device is still enabled. Thus,
the framework informs about this with -EBUSY.

It's ok to ignore -EBUSY, because we're not really interested about if
the device is actually suspended or not.

However, dispc_runtime_get() is a different matter, because there we
_are_ interested about the state of the HW. If we skip
dispc_runtime_get() because runtime PM is disabled, we don't know
whether the HW is enabled or not.

And even if your patch was modified to check the HW status after
pm_runtime_enabled(), and return 0 is HW is enabled and an error if HW
is disabled, it'd be wrong, because you skip the pm_runtime_get() call.
This means that the use count is not increased, and there's no guarantee
that the HW would be functional after dispc_runtime_get() returns.

> > Sure, in the current omapdss neither is a breaking problem, because 1)
> > the matching dispc_runtime_put() is called also with runtime PM
> > disabled, and thus we don't decrease the use count, and 2) the HW
> > happens to be already enabled. But that's just by "luck", and tomorrow
> > omapdss could be different.
> >
> It's no 'luck', but it's because today omapdss takes proper care of PM
> enable/disable and get/put.
> Rather, if tomorrow that stops working, it would hint that we managed
> to screw up the balance.
> Because if omapdss suspended and disabled PM on DISPC, and still HDMI
> attempted to access dss regs, that clearly means HDMI hasn't been duly
> made aware of the DISPC status.

There are two different things here. First one is how
dispc_runtime_get/put & co. should work. The second is how they are
used.

As I see, you are arguing that it's ok to have dispc_runtime_get/put
broken, as long as they are used in a way that causes no problems.

> Just as preemption and suspend/resume don't introduce any race in
> locking, RPM won't introduce new imbalance in get/put of omapdss.
> 
> I am afraid, we won't reach any eureka moment on this, so I would
> leave us to our conditions. This patch and discussion made me look
> deep into rpm, I thank you for that and for your patience.

Yes, same here. I think this discussion and related code digging has
really improved my understanding of runtime PM =). Perhaps I'll get it
correct this time with this new information.

There's still the system suspend, which I think is quite broken. The
patch I gave fixes it for the time being, but I see it as a temporary
solution.

I don't like it at all that omapdss disables and enables the panels in
omapdss's suspend/resume hooks. But I'm not sure how this should work...
Should panel drivers each have their own suspend/resume hooks, and
handle it themselves? Or should the call to suspend/resume come from
upper layers, like omapfb or omapdrm.

I made a prototype patch a few weeks ago to move the suspend to omapfb,
and it feels better than the current one, but I'm still not sure...

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Jassi Brar <jaswinder.singh@linaro.org>
Cc: mythripk@ti.com, linux-omap@vger.kernel.org,
	linux-fbdev@vger.kernel.org, andy.green@linaro.org,
	n-dechesne@ti.com
Subject: Re: [PATCH] OMAPDSS: Check if RPM enabled before trying to change state
Date: Wed, 27 Jun 2012 11:13:41 +0300	[thread overview]
Message-ID: <1340784821.2649.17.camel@deskari> (raw)
In-Reply-To: <CAJe_Zhdz5mAZbyer8fL4YfvcQ8xMF31cPG2zr3AbBNWv8nctnw@mail.gmail.com>

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

On Wed, 2012-06-27 at 13:11 +0530, Jassi Brar wrote:
> On 27 June 2012 11:28, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> >
> > It doesn't matter how omapdss is organized, -EACCES _is_ an error. It
> > tells us that something unexpected happened, and we should react to it
> > somehow.
> >
>   $ git show 5025ce070
> Exactly how omapdss is organised is the reason -EBUSY isn't an error there :)
> Otherwise, omapdss should panic that somehow 'imbalance' has been
> introduced in rpm.

There's no imbalance there, as each get() is still matched by a put(),
and the use count is correct. Your patch may cause either get or put to
be skipped.

In 5025ce070 the function in question is dss_runtime_put(), and -EBUSY
_is_ an error there. Normally if you call pm_runtime_put_sync() and the
use count drops to zero, the device should be suspended. In this case,
however, it won't be suspended as a child device is still enabled. Thus,
the framework informs about this with -EBUSY.

It's ok to ignore -EBUSY, because we're not really interested about if
the device is actually suspended or not.

However, dispc_runtime_get() is a different matter, because there we
_are_ interested about the state of the HW. If we skip
dispc_runtime_get() because runtime PM is disabled, we don't know
whether the HW is enabled or not.

And even if your patch was modified to check the HW status after
pm_runtime_enabled(), and return 0 is HW is enabled and an error if HW
is disabled, it'd be wrong, because you skip the pm_runtime_get() call.
This means that the use count is not increased, and there's no guarantee
that the HW would be functional after dispc_runtime_get() returns.

> > Sure, in the current omapdss neither is a breaking problem, because 1)
> > the matching dispc_runtime_put() is called also with runtime PM
> > disabled, and thus we don't decrease the use count, and 2) the HW
> > happens to be already enabled. But that's just by "luck", and tomorrow
> > omapdss could be different.
> >
> It's no 'luck', but it's because today omapdss takes proper care of PM
> enable/disable and get/put.
> Rather, if tomorrow that stops working, it would hint that we managed
> to screw up the balance.
> Because if omapdss suspended and disabled PM on DISPC, and still HDMI
> attempted to access dss regs, that clearly means HDMI hasn't been duly
> made aware of the DISPC status.

There are two different things here. First one is how
dispc_runtime_get/put & co. should work. The second is how they are
used.

As I see, you are arguing that it's ok to have dispc_runtime_get/put
broken, as long as they are used in a way that causes no problems.

> Just as preemption and suspend/resume don't introduce any race in
> locking, RPM won't introduce new imbalance in get/put of omapdss.
> 
> I am afraid, we won't reach any eureka moment on this, so I would
> leave us to our conditions. This patch and discussion made me look
> deep into rpm, I thank you for that and for your patience.

Yes, same here. I think this discussion and related code digging has
really improved my understanding of runtime PM =). Perhaps I'll get it
correct this time with this new information.

There's still the system suspend, which I think is quite broken. The
patch I gave fixes it for the time being, but I see it as a temporary
solution.

I don't like it at all that omapdss disables and enables the panels in
omapdss's suspend/resume hooks. But I'm not sure how this should work...
Should panel drivers each have their own suspend/resume hooks, and
handle it themselves? Or should the call to suspend/resume come from
upper layers, like omapfb or omapdrm.

I made a prototype patch a few weeks ago to move the suspend to omapfb,
and it feels better than the current one, but I'm still not sure...

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2012-06-27  8:13 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-23  8:06 [PATCH] OMAPDSS: Check if RPM enabled before trying to change state jaswinder.singh
2012-06-23  8:18 ` jaswinder.singh
2012-06-25  6:20 ` Tomi Valkeinen
2012-06-25  6:20   ` Tomi Valkeinen
2012-06-25  8:49   ` Jassi Brar
2012-06-25  8:53     ` Jassi Brar
2012-06-25  9:30     ` Tomi Valkeinen
2012-06-25  9:30       ` Tomi Valkeinen
2012-06-25 12:27       ` Jassi Brar
2012-06-25 12:39         ` Jassi Brar
2012-06-25 12:41         ` Tomi Valkeinen
2012-06-25 12:41           ` Tomi Valkeinen
2012-06-25 13:31           ` Jassi Brar
2012-06-25 13:43             ` Jassi Brar
2012-06-25 13:49             ` Tomi Valkeinen
2012-06-25 13:49               ` Tomi Valkeinen
2012-06-25 17:06               ` Jassi Brar
2012-06-25 17:18                 ` Jassi Brar
2012-06-26  7:19                 ` Tomi Valkeinen
2012-06-26  7:19                   ` Tomi Valkeinen
2012-06-26  8:32                   ` Jassi Brar
2012-06-26  8:44                     ` Jassi Brar
2012-06-26  8:40                     ` Andy Green
2012-06-26  8:40                       ` Andy Green
2012-06-26  9:07                     ` Tomi Valkeinen
2012-06-26  9:07                       ` Tomi Valkeinen
2012-06-26  9:57                       ` Jassi Brar
2012-06-26 10:09                         ` Jassi Brar
2012-06-26 12:03                         ` Tomi Valkeinen
2012-06-26 12:03                           ` Tomi Valkeinen
2012-06-26 14:49                           ` Jassi Brar
2012-06-26 14:52                             ` Jassi Brar
2012-06-26 15:08                             ` Tomi Valkeinen
2012-06-26 15:08                               ` Tomi Valkeinen
2012-06-26 15:09                               ` Jassi Brar
2012-06-26 15:21                                 ` Jassi Brar
2012-06-26 15:11                                 ` Tomi Valkeinen
2012-06-26 15:11                                   ` Tomi Valkeinen
2012-06-26 17:01                                   ` Jassi Brar
2012-06-26 17:13                                     ` Jassi Brar
2012-06-26 18:44                                     ` Tomi Valkeinen
2012-06-26 18:44                                       ` Tomi Valkeinen
2012-06-27  4:42                                       ` Jassi Brar
2012-06-27  4:54                                         ` Jassi Brar
2012-06-27  5:58                                         ` Tomi Valkeinen
2012-06-27  5:58                                           ` Tomi Valkeinen
2012-06-27  7:41                                           ` Jassi Brar
2012-06-27  7:53                                             ` Jassi Brar
2012-06-27  8:13                                             ` Tomi Valkeinen [this message]
2012-06-27  8:13                                               ` Tomi Valkeinen
2012-06-27 14:53                                               ` Jassi Brar
2012-06-27 14:56                                                 ` Jassi Brar
2012-06-28  6:41                                                 ` Tomi Valkeinen
2012-06-28  6:41                                                   ` Tomi Valkeinen
2012-06-28  7:46                                                   ` Jassi Brar
2012-06-28  7:58                                                     ` Jassi Brar
2012-06-28  7:58                                                     ` Tomi Valkeinen
2012-06-28  7:58                                                       ` Tomi Valkeinen
2012-06-25 12:05   ` Grazvydas Ignotas
2012-06-25 12:05     ` Grazvydas Ignotas
2012-06-25 12:30     ` Tomi Valkeinen
2012-06-25 12:30       ` Tomi Valkeinen
2012-06-25 12:42       ` Rajendra Nayak
2012-06-25 12:54         ` Rajendra Nayak
2012-06-25 12:50         ` Tomi Valkeinen
2012-06-25 12:50           ` Tomi Valkeinen
2012-06-26  4:51           ` Rajendra Nayak
2012-06-26  4:55             ` Rajendra Nayak
2012-06-26 13:02             ` Grazvydas Ignotas
2012-06-26 13:02               ` Grazvydas Ignotas
2012-06-26 14:34               ` Alan Stern
2012-06-26 14:34                 ` Alan Stern
2012-06-26 15:01                 ` Tomi Valkeinen
2012-06-26 15:01                   ` Tomi Valkeinen
2012-06-26 15:11                   ` Alan Stern
2012-06-26 15:11                     ` Alan Stern
2012-06-25 12:33     ` Jassi Brar
2012-06-25 12:45       ` Jassi Brar

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=1340784821.2649.17.camel@deskari \
    --to=tomi.valkeinen@ti.com \
    --cc=andy.green@linaro.org \
    --cc=jaswinder.singh@linaro.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mythripk@ti.com \
    --cc=n-dechesne@ti.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.