From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Kevin Hilman <khilman@ti.com>
Cc: linux-omap@vger.kernel.org
Subject: Re: context_loss_count error value
Date: Wed, 25 May 2011 09:05:46 +0300 [thread overview]
Message-ID: <1306303546.2062.6.camel@deskari> (raw)
In-Reply-To: <87lixv1x3s.fsf@ti.com>
On Tue, 2011-05-24 at 16:45 -0700, Kevin Hilman wrote:
> Hi Tomi,
>
> Tomi Valkeinen <tomi.valkeinen@ti.com> writes:
>
> > On Wed, 2011-05-18 at 17:41 +0300, Tomi Valkeinen wrote:
> >> On Wed, 2011-05-18 at 16:24 +0200, Kevin Hilman wrote:
> >>
> >> > Looking closer at the code, a zero return happens only when
> >> >
> >> > 1) no hwmod associated to omap_device
> >> > 2) no power domain associated to hwmod
> >> > 3) power domain has not (yet) lost context
> >> >
> >> > None of these are actually error conditions per-se, and in all cases, it
> >> > indidates that context has not been lost (or we can't tell if context
> >> > has been lost.)
> >>
> >> If the pm code cannot tell whether the context has been lost or not, the
> >> driver must assume it has been lost, do you agree? If so, the driver
> >> must handle zero return value differently, and always restore context.
> >>
> >> > So I think the current code is correct.
> >>
> >> How is it correct if it returns an error even if no error has happened
> >> =)? Either the code or the documentation is wrong.
> >>
> >> How about the wrap-around case? Does the loss count go back to zero?
> >
> > Any conclusion on this?
>
> Sorry for the lag... been travelling, and finally back home...
>
> You're right, the code is just wrong here and would lead to strange
> return value checking in the callers to be correct.
>
> I think the best fix for this problem is to use a signed return value
> which can wrap as expected, and then use return negative error codes
> (e.g. -ENODEV).
When I first saw this context_loss_count in Nokia's kernel tree, it was
returning int and was called get_last_off_on_transaction_id. I wonder
why it ended up returning u32 in mainline...
> Care to send a patch? or do you have any other suggestions for a fix?
Sure, I'll cook up a patch.
Looking at other users of get_context_loss_count, I see that omap hsmmc
is also using it. Interestingly hsmmc code uses the value returned from
omap_pm_get_dev_context_loss_count() as int, and checks if the returned
value is < 0.
So changing omap_pm_get_dev_context_loss_count() to return an int would
also "fix" hsmmc code =).
Tomi
next prev parent reply other threads:[~2011-05-25 6:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 7:40 context_loss_count error value Tomi Valkeinen
2011-05-18 10:50 ` Kevin Hilman
2011-05-18 11:33 ` Tomi Valkeinen
2011-05-18 14:24 ` Kevin Hilman
2011-05-18 14:41 ` Tomi Valkeinen
2011-05-24 15:47 ` Tomi Valkeinen
2011-05-24 23:45 ` Kevin Hilman
2011-05-25 6:05 ` Tomi Valkeinen [this message]
2011-05-25 8:31 ` Tomi Valkeinen
2011-05-25 18:34 ` Kevin Hilman
2011-05-25 18:45 ` Tomi Valkeinen
2011-05-25 20:30 ` Kevin Hilman
2011-05-26 5:55 ` Tomi Valkeinen
2011-05-26 15:56 ` Kevin Hilman
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=1306303546.2062.6.camel@deskari \
--to=tomi.valkeinen@ti.com \
--cc=khilman@ti.com \
--cc=linux-omap@vger.kernel.org \
/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.