From: "Ondřej Jirman" <x@xff.cz>
To: Samuel Holland <samuel@sholland.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Rob Herring <robh+dt@kernel.org>,
devicetree@vger.kernel.org, linux-i2c@vger.kernel.org,
Wolfram Sang <wsa@kernel.org>
Subject: Re: [PATCH 4/5] Input: pinephone-keyboard - Support the proxied I2C bus
Date: Sun, 30 Jan 2022 04:00:31 +0100 [thread overview]
Message-ID: <20220130030031.v2jbebaz7rs2d6vm@core.my.home> (raw)
In-Reply-To: <4d642ba4-bd34-814d-8ae1-c90c87fa4bc4@sholland.org>
On Sat, Jan 29, 2022 at 08:43:30PM -0600, Samuel Holland wrote:
> On 1/29/22 8:05 PM, Ondřej Jirman wrote:
> >
> > Please use a single read transfer to get both command result and data.
> > There will be less risk that some userspace app will issue another command
> > in between command status being read as 0 and data byte being read.
> >
> > Otherwise if you use this in some read/modify/write operation, you
> > may write unexpected value to PMIC. I2C register layout is designed
> > to make this as optimal as possible in a single I2C transaction, so
> > you only need 3 bytes to start command and 2 bytes to read the result
> > and data, both in a single xfer. There's very high likelihood the command
> > will complete in those 300 - 500 us anyway, because the timing is
> > predictable. If this delay is set right, it's almost guaranteed,
> > only two xfers will be necessary to run the command and get the result+
> > status.
>
> I did this originally, but it causes a different race condition: since the data
> is read first, the command can complete between when the data is read and when
> the result is read. If this happens, the command will be seen as complete, but
> the data will be garbage.
>
> This caused occasional read errors for the charger's power supply properties,
> because I2C reads sometimes returned nonsensical values for those bytes.
Oh, well. :) I guess the firmware would need to wait for any ongoing I2C
tranfer to finish before setting the command status to 0, for this to work.
Another lesson learned. :(
> > And if possible, it would be best if the bus was somehow made busy for
> > other users, until the whole comand/result sequence completes, to eliminate
> > the possibility of another command being issued by other bus users
> > around [1].
>
> Yes, I can add a call to i2c_lock_bus() here.
Perfect.
thank you,
o.
> Regards,
> Samuel
next prev parent reply other threads:[~2022-01-30 3:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-29 23:00 [PATCH 0/5] Pine64 PinePhone keyboard support Samuel Holland
2022-01-29 23:00 ` [PATCH 1/5] dt-bindings: input: Add the PinePhone keyboard binding Samuel Holland
2022-02-11 13:23 ` Rob Herring
2022-02-14 4:41 ` Samuel Holland
2022-01-29 23:00 ` [PATCH 2/5] Input: pinephone-keyboard - Add PinePhone keyboard driver Samuel Holland
2022-02-02 8:07 ` Ondřej Jirman
2022-02-02 11:48 ` Ondřej Jirman
2022-01-29 23:00 ` [PATCH 3/5] Input: pinephone-keyboard - Build in the default keymap Samuel Holland
2022-01-31 19:45 ` Dmitry Torokhov
2022-02-02 4:58 ` Samuel Holland
2022-05-30 7:05 ` Pavel Machek
2022-04-12 10:20 ` Jarrah
2022-04-12 11:34 ` Ondřej Jirman
2022-01-29 23:00 ` [PATCH 4/5] Input: pinephone-keyboard - Support the proxied I2C bus Samuel Holland
2022-01-30 2:05 ` Ondřej Jirman
2022-01-30 2:43 ` Samuel Holland
2022-01-30 3:00 ` Ondřej Jirman [this message]
2022-01-29 23:00 ` [PATCH 5/5] [DO NOT MERGE] arm64: dts: allwinner: pinephone: Add keyboard Samuel Holland
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=20220130030031.v2jbebaz7rs2d6vm@core.my.home \
--to=x@xff.cz \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=samuel@sholland.org \
--cc=wsa@kernel.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).