public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org, Mikko Perttunen <cyndis@kapsi.fi>
Subject: Re: [PATCH v1 3/3] i2c: tegra: Fix suspending in active runtime PM state
Date: Fri, 13 Dec 2019 17:55:11 +0300	[thread overview]
Message-ID: <ec7e11f6-2695-29c8-c9ed-98dc229b8aac@gmail.com> (raw)
In-Reply-To: <ae96db3a-0854-6e80-0469-e5fa6fd7bb8e@gmail.com>

13.12.2019 17:29, Dmitry Osipenko пишет:
> 13.12.2019 02:34, Dmitry Osipenko пишет:
>> I noticed that sometime I2C clock is kept enabled during suspend-resume.
>> This happens because runtime PM defers dynamic suspension and thus it may
>> happen that runtime PM is in active state when system enters into suspend.
>> In particular I2C controller that is used for CPU's DVFS is often kept ON
>> during suspend because CPU's voltage scaling happens quite often.
>>
>> Note: we marked runtime PM as IRQ-safe during the driver's probe in the
>> "Support atomic transfers" patch, thus it's okay to enforce runtime PM
>> suspend/resume in the NOIRQ phase which is used for the system-level
>> suspend/resume of the driver.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/i2c/busses/i2c-tegra.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
>> index b3ecdd87e91f..d309a314f4d6 100644
>> --- a/drivers/i2c/busses/i2c-tegra.c
>> +++ b/drivers/i2c/busses/i2c-tegra.c
>> @@ -1790,9 +1790,14 @@ static int tegra_i2c_remove(struct platform_device *pdev)
>>  static int __maybe_unused tegra_i2c_suspend(struct device *dev)
>>  {
>>  	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
>> +	int err;
>>  
>>  	i2c_mark_adapter_suspended(&i2c_dev->adapter);
> 
> I'm now in a doubt that it is correct to use NOIRQ level at all for the
> suspend because i2c_mark_adapter_suspended() uses mutex, thus I'm
> wondering what will happen if there is an asynchronous transfer
> happening during suspend..
> 
> The i2c_mark_adapter_suspended() will try to block and will never return?

Moreover, the I2C interrupt should be disabled during the NOIRQ phase.
So, yes.. looks like making use of NOIRQ level wasn't a correct
decision. On the other hand, I don't think that any I2C client driver
used by Tegra SoCs in the upstream kernel could cause the problem at the
moment, so it shouldn't be critical.

BTW: Jon, please CC me next time ;) [I'll try to find a better solution
for the PCIE problem]

>> +	err = pm_runtime_force_suspend(dev);
>> +	if (err < 0)
>> +		return err;
>> +
>>  	return 0;
>>  }
>>  
>> @@ -1813,6 +1818,10 @@ static int __maybe_unused tegra_i2c_resume(struct device *dev)
>>  	if (err)
>>  		return err;
>>  
>> +	err = pm_runtime_force_resume(dev);
>> +	if (err < 0)
>> +		return err;
>> +
>>  	i2c_mark_adapter_resumed(&i2c_dev->adapter);
>>  
>>  	return 0;
>>
> 


  reply	other threads:[~2019-12-13 20:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12 23:34 [PATCH v1 0/3] Tegra I2C: Support atomic transfers and correct suspend/resume Dmitry Osipenko
2019-12-12 23:34 ` [PATCH v1 1/3] i2c: tegra: Support atomic transfers Dmitry Osipenko
2019-12-13 14:36   ` Dmitry Osipenko
2019-12-13 15:12   ` Thierry Reding
2019-12-13 15:15     ` Dmitry Osipenko
2019-12-13 15:20       ` Thierry Reding
2019-12-13 15:25         ` Dmitry Osipenko
2019-12-12 23:34 ` [PATCH v1 2/3] i2c: tegra: Rename I2C_PIO_MODE_MAX_LEN to I2C_PIO_MODE_PREFERRED_LEN Dmitry Osipenko
2019-12-13 15:12   ` Thierry Reding
2019-12-12 23:34 ` [PATCH v1 3/3] i2c: tegra: Fix suspending in active runtime PM state Dmitry Osipenko
2019-12-12 23:43   ` Dmitry Osipenko
2019-12-13 13:47   ` Thierry Reding
2019-12-13 14:04     ` Dmitry Osipenko
2019-12-13 18:01       ` Dmitry Osipenko
2019-12-19 22:58         ` Dmitry Osipenko
2019-12-27 13:47           ` Dmitry Osipenko
2019-12-13 14:29   ` Dmitry Osipenko
2019-12-13 14:55     ` Dmitry Osipenko [this message]
2019-12-27 13:55       ` Dmitry Osipenko

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=ec7e11f6-2695-29c8-c9ed-98dc229b8aac@gmail.com \
    --to=digetx@gmail.com \
    --cc=cyndis@kapsi.fi \
    --cc=jonathanh@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=wsa@the-dreams.de \
    /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