From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: "xinhui.pan" <xinhuix.pan@intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>,
linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
andriy.shevchenko@linux.intel.com, yanmin_zhang@linux.intel.com,
bo.he@intel.com
Subject: Re: [PATCH] i2c-designware-pcidrv: fix the incorrect return of idle callback
Date: Wed, 29 Jan 2014 12:38:13 +0200 [thread overview]
Message-ID: <20140129103813.GN18029@intel.com> (raw)
In-Reply-To: <52E8D13A.1060100@intel.com>
On Wed, Jan 29, 2014 at 06:00:26PM +0800, xinhui.pan wrote:
>
>
> 于 2014年01月29日 16:35, Mika Westerberg 写道:
> > On Tue, Jan 28, 2014 at 07:30:35PM +0100, Wolfram Sang wrote:
> >> On Tue, Jan 28, 2014 at 01:48:28PM +0800, xinhui.pan wrote:
> >>> From: "xinhui.pan" <xinhuix.pan@intel.com>
> >>>
> >>> i2c_dw_pci_runtime_idle should return -EBUSY rather than zero if it do success.
> >>
> >> I don't understand...
> >>
> >>> Otherwise rpm_idle will call pm_suspend again and that may cause pm_schedule_suspend delay invalidate.
> >>>
> >>> Signed-off-by: bo.he <bo.he@intel.com>
> >>> Signed-off-by: xinhui.pan <xinhuix.pan@intel.com>
> >>> ---
> >>> drivers/i2c/busses/i2c-designware-pcidrv.c | 4 ++--
> >>> 1 file changed, 2 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
> >>> index f6ed06c..96e81f6 100644
> >>> --- a/drivers/i2c/busses/i2c-designware-pcidrv.c
> >>> +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
> >>> @@ -190,8 +190,8 @@ static int i2c_dw_pci_runtime_idle(struct device *dev)
> >>> int err = pm_schedule_suspend(dev, 500);
> >>> dev_dbg(dev, "runtime_idle called\n");
> >>>
> >>> - if (err != 0)
> >>> - return 0;
> >>> + if (err)
> >>> + return err;
> >>> return -EBUSY;
> >>
> >> ... it does return EBUSY when pm_schedule_suspend() succeeds? It only
> >> returns 0 if it does not succeed (for which I don't know if this is an
> >> apropriate behaviour). Mika?
> >
> > If I understand correctly, pm_schedule_suspend(dev, 500) is there because
> > we want to runtime suspend in 500 ms. It then returns -EBUSY to prevent PM
> > runtime from carrying on suspend on it's own. However, I have no idea where
> > this magical 500 ms requirement comes from.
> >
> > If we fail to schedule suspend we let the PM core to do whatever it thinks
> > suitable (in this case I suppose it suspends the device).
> >
>
> Hi ,Mika
> If the callback returns 0,it means pm_schedule_suspend fails,
> also means rpm_check_suspend_allowed(pm_schedule_suspend calls it)
> returns nonzero value.As a result,rpm_suspend will be called by rpm_idle.
> However in rpm_idle, rpm_check_suspend_allowed is called at first,too.
> and the return value is treated as it is.But rpm_idle just returns
> without doing anything(rpm_suspend is not called).
> in both case above,why goes in different ways? I am confused.
To be honest, I don't know ;-)
> > I think the whole idle dance could be replaced with a use of runtime PM
> > autosuspend, just like we do in the platform version of the driver.
> >
> > Xinghui,
> >
> > Is this a real problem that you are trying to solve?
> >
>
> To be honest,we got many panic when testing.
> But is not caused by this driver I think.
> while checking problems,we found these confusing codes by accident.
OK, so if this is not a problem, I would suggest keeping the code as is for
now as someone who introduced the pm_schedule_suspend() thing probably
tested it and it worked then.
In fact, I think that the PCI part of that driver needs an audit since it
does some PCI power management magic itself which drivers aren't supposed
to do anymore.
prev parent reply other threads:[~2014-01-29 10:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-28 5:48 [PATCH] i2c-designware-pcidrv: fix the incorrect return of idle callback xinhui.pan
2014-01-28 18:30 ` Wolfram Sang
2014-01-29 2:03 ` xinhui.pan
2014-01-29 7:35 ` xinhui.pan
2014-01-29 8:35 ` Mika Westerberg
2014-01-29 10:00 ` xinhui.pan
2014-01-29 10:38 ` Mika Westerberg [this message]
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=20140129103813.GN18029@intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bo.he@intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@the-dreams.de \
--cc=xinhuix.pan@intel.com \
--cc=yanmin_zhang@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox