lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <ZQ0PR01MB1160DC63A1CC70F79036057EEB7BA@ZQ0PR01MB1160.CHNPR01.prod.partner.outlook.cn>
Date: Wed, 24 Jan 2024 04:46:43 +0000
From: JiSheng Teoh <jisheng.teoh@...rfivetech.com>
To: Andi Shyti <andi.shyti@...nel.org>
CC: Michal Simek <michal.simek@....com>, Leyfoon Tan
	<leyfoon.tan@...rfivetech.com>, "linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, "linux-i2c@...r.kernel.org"
	<linux-i2c@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2 RESEND] i2c: cadence: Add system suspend and resume PM
 support

Hi Andi,
> 
> ...
> 
> > > > +static int __maybe_unused cdns_i2c_resume(struct device *dev) {
> > > > +	struct cdns_i2c *xi2c = dev_get_drvdata(dev);
> > > > +	int err;
> > > > +
> > > > +	err = cdns_i2c_runtime_resume(dev);
> > > > +	if (err)
> > > > +		return err;
> > > > +
> > > > +	if (pm_runtime_status_suspended(dev)) {
> > > > +		err = cdns_i2c_runtime_suspend(dev);
> > > > +		if (err)
> > > > +			return err;
> > >
> > > We call the cdns_i2c_resume() functions to come up from a suspended
> > > state. But, if we fail to resume, we call the suspend and return '0' (because this always returns '0').
> > >
> > > In other words, if we take this path, we call resume, but we still end up suspended and return success.
> > >
> > > Andi
> > >
> >
> > My understanding is that during system level resume 'cdns_i2c_resume()', the i2c device itself can still be held in runtime suspend
> regardless of the change in system level PM.
> > Looking back at this, we invoke cdns_i2c_runtime_resume() to enable clock and init the i2c device, the runtime PM state is still
> unchanged and kept suspended.
> > pm_runtime_status_suspended() will be evaluated as true, and runtime suspend 'cdns_i2c_runtime_suspend()' is invoked to
> disable the clock. This balances the clock count enabled earlier.
> 
> If this is your issue, what if we do not enable the clock during resume? and we just mark the device as resumed?
> 
That will work as well. The i2c device will be runtime resumed again during cdns_i2c_master_xfer() anyway, but thought that it
would be a good idea to check if the i2c device is able runtime resume during a system level resume.

> > The runtime PM state is only resumed during cdns_i2c_master_xfer() through pm_runtime_resume_and_get(), and subsequently
> kept suspended through pm_runtime_put_autosuspend().
> > Since the cdns_i2c_runtime_suspend() always return '0', I will simplify them as follow:
> > +if (pm_runtime_status_suspended(dev))
> > +	cdns_i2c_runtime_suspend(dev);
> 
> I'd prefer checking the error value, even though we are sure on the expected return. It's more future proof.
> 
> Andi
> 
Ok, I will keep the original changes.

> > > > +	}
> > > > +
> > > > +	i2c_mark_adapter_resumed(&xi2c->adap);
> > > > +
> > > > +	return 0;
> > > > +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ