From: Andi Shyti <andi.shyti@gmail.com>
To: Bryan Freed <bfreed@chromium.org>
Cc: Peter Huewe <peter.huewe@infineon.com>,
Rajiv Andrade <srajiv@linux.vnet.ibm.com>,
tpmdd@selhorst.net, tpmdd-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Olof Johansson <olof@lixom.net>,
Luigi Semenzato <semenzato@google.com>
Subject: Re: [PATCH] CHROMIUM: tpm: tpm_tis_i2c: Lock the I2C adapter for a sequence of requests.
Date: Wed, 2 May 2012 22:18:32 +0200 [thread overview]
Message-ID: <20120502201832.GA19349@andi> (raw)
In-Reply-To: <CAEYUcX06hvTb1YP=9vCpK9Z19dtZgNTjUcSRnrUvjc3bu-D--Q@mail.gmail.com>
Hi,
On Wed, May 02, 2012 at 12:06:14PM -0700, Bryan Freed wrote:
> Hi Andi,
>
> On Wed, May 2, 2012 at 11:14 AM, Andi Shyti <andi.shyti@gmail.com> wrote:
> > Hi Bryan,
> >
> >> > try to have a look to the i2c_smbus* function, you could avoid
> >> > lot of code
> > On Wed, May 02, 2012 at 10:25:09AM -0700, Bryan Freed wrote:
> >> (Sorry for resending...)
> >>
> >> Andi, it is not clear what i2c_smbus_* functions in particular will
> >> improve upon this change.
> >>
> >> All i2c_smbus_* functions go through i2c_smbus_xfer() which at some
> >> point will i2c_lock_adapter() for each request.
> >> This is true for adapters that support SMBUS (where the lock occurs
> >> directly in i2c_smbus_xfer()) or just I2C (where the lock occurs in
> >> i2c_transfer() called through i2c_smbus_xfer_emulated()).
> >>
> >> The goal of this change is for the tpm_tis_i2c driver to be able to
> >> lock an adapter over the duration of several I2C requests.
> >> Presumably, that is why i2c_lock_adapter() is exported.
> >
> > the i2c_smbus_* functions will not improve anything to the
> > driver, it will increase the readability and it will allow you to
> > do the same stuff with less code.
>
> I think I see what you are saying.
> We could (in the unmodified version of this driver) replace all the
> iic_tpm_read() calls of one byte (which sends an address byte before
> reading a data byte) with an i2c_smbus_read_byte_command() call which
> does the same thing.
> Switching to the SMBUS calls in this driver will still work on
> adapters that only support I2C because of i2c_smbus_xfer_emulated().
> Right?
> > All the i2c communication implementation you wrote here, is
> > already written in the i2c-core.c file.
>
> Right. Unfortunately, we cannot use any of the i2c_smbus_* functions
> in this driver. The device will fail because the adapter lock is not
> held long enough to prevent I2C traffic going to other devices on the
> same bus. That other traffic to other devices confuses the i2c core
> in this device. Our only driver solution is to lock the adapter for a
> longer duration.
>
> Yes, the code we have here is copied from the i2c-core.c file. In
> fact, we comment this with, "Copy i2c-core:i2c_transfer() as close as
> possible without the adapter locks
> and algorithm check".
>
> And that really is the problem with using the i2c-core.c calls. This
> driver needs to lock the adapter for an extended duration.
mmhhh... you still haven't convinced me. I always thought that
every dublicated code is useless.
You may have good reasons to do that, but I could still try to
find out a way on how to simplify it.
Thanks for the explanation,
Andi
next prev parent reply other threads:[~2012-05-02 20:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-02 14:01 [PATCH] char/tpm: Add new driver for Infineon I2C TIS TPM Peter Huewe
2012-05-02 14:03 ` [PATCH] CHROMIUM: tpm: tpm_tis_i2c: Lock the I2C adapter for a sequence of requests Peter Huewe
2012-05-02 15:17 ` Andi Shyti
2012-05-02 17:25 ` Bryan Freed
2012-05-02 18:14 ` Andi Shyti
2012-05-02 19:06 ` Bryan Freed
2012-05-02 20:18 ` Andi Shyti [this message]
2012-05-02 21:58 ` Bryan Freed
2012-05-02 20:54 ` Peter Hüwe
2012-05-02 15:15 ` [PATCH] char/tpm: Add new driver for Infineon I2C TIS TPM Andi Shyti
2012-05-03 11:18 ` Peter.Huewe
2012-05-10 6:49 ` Andi Shyti
-- strict thread matches above, loose matches on Subject: below --
2011-08-03 21:08 [PATCH] CHROMIUM: tpm: tpm_tis_i2c: Lock the I2C adapter for a sequence of requests Bryan Freed
2011-08-05 7:33 ` Huewe.external
2011-08-05 12:05 ` Huewe.external
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=20120502201832.GA19349@andi \
--to=andi.shyti@gmail.com \
--cc=bfreed@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=peter.huewe@infineon.com \
--cc=semenzato@google.com \
--cc=srajiv@linux.vnet.ibm.com \
--cc=tpmdd-devel@lists.sourceforge.net \
--cc=tpmdd@selhorst.net \
/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