[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231210115412.hztjrubacnmenbvz@zenone.zhora.eu>
Date: Sun, 10 Dec 2023 12:54:12 +0100
From: Andi Shyti <andi.shyti@...nel.org>
To: Ji Sheng Teoh <jisheng.teoh@...rfivetech.com>
Cc: leyfoon.tan@...rfivetech.com, linux-arm-kernel@...ts.infradead.org,
linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
michal.simek@....com
Subject: Re: [PATCH v2] i2c: cadence: Add system suspend and resume PM support
Hi Ji Sheng,
[...]
> > > +static int __maybe_unused cdns_i2c_resume(struct device *dev)
> > > +{
> >
> > I am not really understanding what you are trying to do here:
> >
> > > + struct cdns_i2c *xi2c = dev_get_drvdata(dev);
> > > + int err;
> > > +
> > > + err = cdns_i2c_runtime_resume(dev);
> >
> > First you try to resume...
> >
> > > + if (err)
> > > + return err;
> > > +
> > > + if (pm_runtime_status_suspended(dev)) {
> >
> > ... then you check if you are suspended ...
>
> This serves as a check and balance to ensure that when the system
> resumes with device in runtime suspend state, we disable the clock
> enabled in earlier cdns_i2c_runtime_resume() to ensure a balanced clock
> reference count for subsequent runtime resume transition.
> Similar implementation can be found in this commit:
> https://github.com/torvalds/linux/commit/44c99904cf61f945d02ac9976ab10dd5ccaea393
OK, this is done purely for clock balancing, but then, I still
don't understand the case. I expect the clock counter to be
unbalanced when you suspend (because is moving towards '0').
While, if you check if the clock is unbalanced when resuming, it
means that the clock had a negative counter (which is impossible
because the clock counter is unsigned).
If there is any unbalancing at this stage, then I recommend you
to check what has happened previously.
... Or is there anything I am missing?
Thanks,
Andi
> > > + err = cdns_i2c_runtime_suspend(dev);
> >
> > ... and suspend again? Shouldn't this be _resume()?
> >
> > Thanks,
> .[O> Andi
> >
> > > + if (err)
> > > + return err;
> > > + }
> > > +
> > > + i2c_mark_adapter_resumed(&xi2c->adap);
> > > +
> > > + return 0;
> > > +}
Powered by blists - more mailing lists