From: Peter Rosin <peda@axentia.se>
To: linux-kernel@vger.kernel.org
Cc: Peter Rosin <peda@axentia.se>, Peter Huewe <peterhuewe@gmx.de>,
Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Brian Norris <computersforpeace@gmail.com>,
Gregory Fong <gregory.0xf0@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
bcm-kernel-feedback-list@broadcom.com,
Sekhar Nori <nsekhar@ti.com>, Kevin Hilman <khilman@kernel.org>,
Haavard Skinnemoen <hskinnemoen@gmail.com>,
Kukjin Kim <kgene@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Orson Zhai <orsonzhai@gmail.com>,
Baolin Wang <baolin.wang@linaro.org>,
Chunyan Zhang <zhang.lyra@gmail.com>,
Wolfram Sang <wsa@the-dreams.de>,
Guenter Roeck <linux@roeck-us.net>Crt Mori <c>
Subject: [PATCH v2 01/10] tpm/tpm_i2c_infineon: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
Date: Wed, 20 Jun 2018 07:17:54 +0200 [thread overview]
Message-ID: <20180620051803.12206-2-peda@axentia.se> (raw)
In-Reply-To: <20180620051803.12206-1-peda@axentia.se>
Locking the root adapter for __i2c_transfer will deadlock if the
device sits behind a mux-locked I2C mux. Switch to the finer-grained
i2c_lock_bus with the I2C_LOCK_SEGMENT flag. If the device does not
sit behind a mux-locked mux, the two locking variants are equivalent.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/char/tpm/tpm_i2c_infineon.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index 6116cd05e228..9086edc9066b 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -117,7 +117,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
/* Lock the adapter for the duration of the whole sequence. */
if (!tpm_dev.client->adapter->algo->master_xfer)
return -EOPNOTSUPP;
- i2c_lock_adapter(tpm_dev.client->adapter);
+ i2c_lock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT);
if (tpm_dev.chip_type == SLB9645) {
/* use a combined read for newer chips
@@ -192,7 +192,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
}
out:
- i2c_unlock_adapter(tpm_dev.client->adapter);
+ i2c_unlock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT);
/* take care of 'guard time' */
usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
@@ -224,7 +224,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
if (!tpm_dev.client->adapter->algo->master_xfer)
return -EOPNOTSUPP;
- i2c_lock_adapter(tpm_dev.client->adapter);
+ i2c_lock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT);
/* prepend the 'register address' to the buffer */
tpm_dev.buf[0] = addr;
@@ -243,7 +243,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
usleep_range(sleep_low, sleep_hi);
}
- i2c_unlock_adapter(tpm_dev.client->adapter);
+ i2c_unlock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT);
/* take care of 'guard time' */
usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
--
2.11.0
next prev parent reply other threads:[~2018-06-20 5:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Peter Rosin [this message]
2018-06-25 10:24 ` [PATCH v2 01/10] tpm/tpm_i2c_infineon: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) 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
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=20180620051803.12206-2-peda@axentia.se \
--to=peda@axentia.se \
--cc=arnd@arndb.de \
--cc=baolin.wang@linaro.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=computersforpeace@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.0xf0@gmail.com \
--cc=hskinnemoen@gmail.com \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=jgg@ziepe.ca \
--cc=kgene@kernel.org \
--cc=khilman@kernel.org \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nsekhar@ti.com \
--cc=orsonzhai@gmail.com \
--cc=peterhuewe@gmx.de \
--cc=wsa@the-dreams.de \
--cc=zhang.lyra@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox