linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/10] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
@ 2018-06-20  5:17 Peter Rosin
  2018-06-20  5:17 ` [PATCH v2 01/10] tpm/tpm_i2c_infineon: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) Peter Rosin
                   ` (11 more replies)
  0 siblings, 12 replies; 23+ messages in thread
From: Peter Rosin @ 2018-06-20  5:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Wolfram Sang, Guenter Roeck, Crt Mori, Jonathan Cameron,
	Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Dmitry Torokhov, Antti Palosaari, Mauro Carvalho Chehab,
	Michael Krufky, Lee Jones, linux-integrity, linux-i2c,
	linux-arm-kernel, linux-samsung-soc, linux-iio, linux-input,
	linux-media

Hi!

With the introduction of mux-locked I2C muxes, the concept of
locking only a segment of the I2C adapter tree was added. At the
time, I did not want to cause a lot of extra churn, so left most
users of i2c_lock_adapter alone and apparently didn't think enough
about it; they simply continued to lock the whole adapter tree.
However, i2c_lock_adapter is in fact wrong for almost every caller
(there is naturally an exception) that is itself not a driver for
a root adapter. What normal drivers generally want is to only
lock the segment of the adapter tree that their device sits on.

In fact, if a device sits behind a mux-locked I2C mux, and its
driver calls i2c_lock_adapter followed by an unlocked I2C transfer,
things will deadlock (since even a mux-locked I2C adapter will lock
its parent at some point). If the device is not sitting behind a
mux-locked I2C mux (i.e. either directly on the root adapter or
behind a (chain of) parent-locked I2C muxes) the root/segment
distinction is of no consequence; the root adapter is locked either
way.

Mux-locked I2C muxes are probably not that common, and putting any
of the affected devices behind one is probably even rarer, which
is why we have not seen any deadlocks. At least not that I know
of...

Since silently changing the semantics of i2c_lock_adapter might
be quite a surprise, especially for out-of-tree users, this series
instead removes the function and forces all users to explicitly
name I2C_LOCK_SEGMENT or I2C_LOCK_ROOT_ADAPTER in a call to
i2c_lock_bus, as suggested by Wolfram. Yes, users will be a teensy
bit more wordy, but open-coding I2C locking from random drivers
should be avoided, so it's perhaps a good thing if it doesn't look
too neat?

I suggest that Wolfram takes this series through the I2C tree and
creates an immutable branch for the other subsystems. The series
is based on v4.18-r1.

I do not have *any* of the affected devices, and have thus only
done build tests.

Cheers,
Peter

PS. for more background on mux-locked vs. parent-locked etc, see
Documentation/i2c/i2c-topology

Changes since v1:
- rebased to v4.18-rc1, thus removing the i2c-tegra hunk from
  the last patch
- Not adding i2c_lock_segment (et al) and remove i2c_lock_adapter
  instead of renaming it to i2c_lock_root, since having 8 closely
  related inline locking functions in include/linux/i2c.h was
  a few too many. I.e., instead going from 5 to 8, we are now
  going from 5 to 3.

Peter Rosin (10):
  tpm/tpm_i2c_infineon: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
  i2c: mux: pca9541: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
  input: rohm_bu21023: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
  media: af9013: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
  media: drxk_hard: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
  media: rtl2830: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
  media: tda1004x: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
  media: tda18271: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
  mfd: 88pm860x-i2c: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
  i2c: remove i2c_lock_adapter and use i2c_lock_bus directly

 drivers/char/tpm/tpm_i2c_infineon.c      |  8 +++----
 drivers/i2c/busses/i2c-brcmstb.c         |  8 +++----
 drivers/i2c/busses/i2c-davinci.c         |  4 ++--
 drivers/i2c/busses/i2c-gpio.c            | 40 ++++++++++++++++----------------
 drivers/i2c/busses/i2c-s3c2410.c         |  4 ++--
 drivers/i2c/busses/i2c-sprd.c            |  8 +++----
 drivers/i2c/i2c-core-slave.c             |  8 +++----
 drivers/i2c/muxes/i2c-mux-pca9541.c      |  6 ++---
 drivers/iio/temperature/mlx90614.c       |  4 ++--
 drivers/input/touchscreen/rohm_bu21023.c |  4 ++--
 drivers/media/dvb-frontends/af9013.c     |  8 +++----
 drivers/media/dvb-frontends/drxk_hard.c  |  4 ++--
 drivers/media/dvb-frontends/rtl2830.c    | 12 +++++-----
 drivers/media/dvb-frontends/tda1004x.c   |  6 ++---
 drivers/media/tuners/tda18271-common.c   |  8 +++----
 drivers/mfd/88pm860x-i2c.c               |  8 +++----
 include/linux/i2c.h                      | 12 ----------
 17 files changed, 70 insertions(+), 82 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2018-07-12 22:11 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-20  5:17 [PATCH v2 00/10] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment Peter Rosin
2018-06-20  5:17 ` [PATCH v2 01/10] tpm/tpm_i2c_infineon: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) Peter Rosin
2018-06-25 10:24   ` Jarkko Sakkinen
2018-06-26 10:07     ` Alexander Steffen
2018-06-26 12:05       ` Jarkko Sakkinen
2018-06-26 12:07         ` Jarkko Sakkinen
2018-06-20  5:17 ` [PATCH v2 02/10] i2c: mux: pca9541: " Peter Rosin
2018-06-20  5:17 ` [PATCH v2 03/10] input: rohm_bu21023: " Peter Rosin
2018-06-20 20:28   ` Dmitry Torokhov
2018-06-20  5:17 ` [PATCH v2 04/10] media: af9013: " Peter Rosin
2018-06-20  5:17 ` [PATCH v2 05/10] media: drxk_hard: " Peter Rosin
2018-06-20  5:17 ` [PATCH v2 06/10] media: rtl2830: " Peter Rosin
2018-06-20  5:18 ` [PATCH v2 07/10] media: tda1004x: " Peter Rosin
2018-06-20  5:18 ` [PATCH v2 08/10] media: tda18271: " Peter Rosin
2018-06-20  5:18 ` [PATCH v2 09/10] mfd: 88pm860x-i2c: " Peter Rosin
2018-07-04  7:04   ` Lee Jones
2018-06-20  5:18 ` [PATCH v2 10/10] i2c: remove i2c_lock_adapter and use i2c_lock_bus directly Peter Rosin
2018-06-26  8:28   ` Jonathan Cameron
2018-06-26 14:09   ` Sekhar Nori
2018-06-26  2:37 ` [PATCH v2 00/10] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment Wolfram Sang
2018-07-12 21:28   ` Wolfram Sang
2018-07-12 21:59     ` Mauro Carvalho Chehab
2018-07-12 22:11 ` Wolfram Sang

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).