kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Primoz Beltram <primoz.beltram@kate.si>
To: kernelnewbies@kernelnewbies.org
Subject: I2C bus driver TIMEDOUT because of PM autosuspend
Date: Wed, 27 Nov 2019 15:49:10 +0100	[thread overview]
Message-ID: <50980a4b-21a1-d051-7e51-5c61dc503db8@kate.si> (raw)

I am analysing a problem with I2C bus driver where the problem shows up 
as I2C bus completely blocked. The LX driver in question is 
/drivers/i2c/busses/i2c-xiic.c. This driver is for FPGA based I2C 
controller.
Problem is difficult to reproduce, it happens very rarely. So far I saw 
that the main precondition is to have very heavy I2C traffic on bus.
In my case this is achieved/reproduced via netdev driving SFP LEDs via 
/sys/class/leds/ (via gpio-pca953x). I generate traffic with iperf3. 
Network traffic is on 10Gbps EMAC. LX kernel is 4.14.0, ARM64, dual core 
CPU, 2Gbyte mem.
What I saw from debugging this problem, is that I2C bus gets in this 
blocked state when wait_event_timeout() completes because of timeout. 
The timeout error handling in this driver is probably not robust enough 
(bus should not remain blocked because of error), but at this moment 
this are just my speculations (don't know enough details).

Looking the data on oscilloscope, I saw that SCL in single I2C data 
transfer (several messages) sequence can be interrupted for very long 
delays, e.g up to hundredths of usec (SCL is 100kHz). There are only two 
delays in driver code, first in wait_event_timeout and second in set 
autosuspend delay. I started to suspect that PM autosuspend delay could 
play some role here. Case is a bit strange because in very busy I2C 
traffic, PM autosuspend should not be triggered at all. Additionally, if 
I lower PM timeout, e.g. from 1000 (default) to 100, I hit the problem 
sooner (waits for problem hit are in order of n*10minutes).

It looks like PM autosupend is playing some role here.

Power management options in my Linux kernel build .config:
# CONFIG_SUSPEND is not set
# CONFIG_PM is not set
CONFIG_ARCH_SUSPEND_POSSIBLE=y

It is not logical (PM is not configured, PM runtime calls are void/empty 
calls), but this case is repeatedly reproduced on my test setup:

XIIC_PM_TIMEOUT=1000 (or less) -> I2C timeout error, bus blocked

XIIC_PM_TIMEOUT=10000 -> No I2C timeout error

I tried also to build i2c-xiic driver with kernel build defaults and 
without optimizations (ccflags-y +=  -O0 -g) and also as in-kernel and 
as loadable module.

Always the same test results.

The workaround that works at the moment is to change PM delay from 1000 
(default) to 10000.

Doing so I don't reproduce the problem (24h runs ok), but honestly I 
don't believe this is fix. More likely the problem is some coincidence 
timing issue, somewhere.

I intentionally did not put all detail descriptions of embedded system 
and test setup here (long list), because the main reason of this post is:

I would like to expose/discuss this issue (maintainer of the code, or 
others).
The reason/source of the problem can be much more complex and in some 
other place.

So my question is who should I contact, is this the M: in the 
MAINTAINERS list, the MODULE_AUTHOR, ...?
How to proceed.

WBR Primoz


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

             reply	other threads:[~2019-11-27 14:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27 14:49 Primoz Beltram [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-11-21 16:59 I2C bus driver TIMEDOUT because of PM autosuspend Primoz Beltram
2019-12-03  1:30 ` anish singh
2019-12-03  9:26   ` Primoz Beltram

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=50980a4b-21a1-d051-7e51-5c61dc503db8@kate.si \
    --to=primoz.beltram@kate.si \
    --cc=kernelnewbies@kernelnewbies.org \
    /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;
as well as URLs for NNTP newsgroup(s).