All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	linux-i2c@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-pm@vger.kernel.org, Peter Rosin <peda@axentia.se>,
	Tony Lindgren <tony@atomide.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mark Brown <broonie@kernel.org>, Tero Kristo <t-kristo@ti.com>,
	Phil Reid <preid@electromag.com.au>
Subject: Re: [RFC] i2c: reject transfers when adapter is suspended
Date: Mon, 1 Oct 2018 23:59:13 +0200	[thread overview]
Message-ID: <20181001215913.GA861@kunai> (raw)
In-Reply-To: <53acc817-b982-6fc5-f5c1-5104968a2b33@redhat.com>

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


> IMHO the is_suspended flag should be set by the adapter driver from its
> own suspend callback (which may be a normal, late or noirq suspend callback),
> as this is the point past which the bus should no longer be used because
> e.g. the suspend callbacks has disabled clocks and/or put the controller
> in reset, etc.

That's what I meant with "not seeing the woods for the trees". Thanks
for clearing my view!

> the i2c-controller device where necessary. But you're hooking into the
> child-device of the actual "hardware" device which represents the i2c_adapter
> bits.

That was intentional because this is the device the I2C core has access
to. Because the callbacks deal only with 'is_suspended' and not with HW,
I thought the logic device could be suitable. I didn't think of
additional relations only affecting its parent.

> on the adapter-device. I believe that instead we should add
> i2c_adapter_mark_suspended and i2c_adapter_mark_resumed helpers and let
> the adapter-driver suspend/resume callbacks call these. This will ensure
> that they get called at the right phase and at the exact moment that
> the adapter is actually suspending.

Agreed. And these helpers are basically this:

> > +	i2c_lock_bus(adap, I2C_LOCK_ROOT_ADAPTER);
> > +	adap->is_suspended = true;
> > +	i2c_unlock_bus(adap, I2C_LOCK_ROOT_ADAPTER);

and this:

> > +	i2c_lock_bus(adap, I2C_LOCK_ROOT_ADAPTER);
> > +	adap->is_suspended = false;
> > +	i2c_unlock_bus(adap, I2C_LOCK_ROOT_ADAPTER);

together with this still in the I2C core:

> > @@ -1867,6 +1904,9 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
> >   	if (WARN_ON(!msgs || num < 1))
> >   		return -EINVAL;
> > +	if (WARN_ON(adap->is_suspended))
> > +		return -ESHUTDOWN;
> > +
> >   	if (adap->quirks && i2c_check_for_quirks(adap, msgs, num))
> >   		return -EOPNOTSUPP;
> > diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> > index 65b4eaed1d96..ee46295a67d4 100644
> > --- a/include/linux/i2c.h
> > +++ b/include/linux/i2c.h
> > @@ -692,6 +692,8 @@ struct i2c_adapter {
> >   	const struct i2c_adapter_quirks *quirks;
> >   	struct irq_domain *host_notify_domain;
> > +
> > +	int is_suspended:1;

Are we aligned?

Thanks,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-10-01 21:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-01 17:44 [RFC] i2c: reject transfers when adapter is suspended Wolfram Sang
2018-10-01 20:40 ` Hans de Goede
2018-10-01 21:59   ` Wolfram Sang [this message]
2018-10-01 22:52     ` Hans de Goede

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=20181001215913.GA861@kunai \
    --to=wsa@the-dreams.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=grygorii.strashko@ti.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=preid@electromag.com.au \
    --cc=t-kristo@ti.com \
    --cc=tony@atomide.com \
    --cc=wsa+renesas@sang-engineering.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.