From: Sagar Dharia <sdharia@codeaurora.org>
To: Doug Anderson <dianders@chromium.org>
Cc: Jonathan Corbet <corbet@lwn.net>,
Andy Gross <andy.gross@linaro.org>,
David Brown <david.brown@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Wolfram Sang <wsa@the-dreams.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Karthikeyan Ramasubramanian <kramasub@codeaurora.org>,
linux-doc@vger.kernel.org, linux-arm-msm@vger.kernel.org,
devicetree@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-serial@vger.kernel.org, Jiri Slaby <jslaby@suse.com>,
evgreen@chromium.org, acourbot@chromium.org,
Girish Mahadevan <girishm@codeaurora.org>,
swboyd@chromium.org, harryy@codeaurora.org,
adharmap@codeaurora.org
Subject: Re: [v3, 3/4] i2c: i2c-qcom-geni: Add bus driver for the Qualcomm GENI I2C controller
Date: Thu, 8 Mar 2018 18:27:56 -0700 [thread overview]
Message-ID: <014494b3-0b4a-d82f-0b93-53464e281cb4@codeaurora.org> (raw)
In-Reply-To: <CAD=FV=UXK_wYky83nmQdk4dQtVSCV9=o3i2590ZyUMcq4rrdKQ@mail.gmail.com>
Hi Doug,
On 3/7/2018 10:19 PM, Doug Anderson wrote:
> Hi,
>
> On Wed, Mar 7, 2018 at 6:42 PM, Sagar Dharia <sdharia@codeaurora.org> wrote:
>> Hi Doug,
>> Thank you for reviewing the patch. I will take a stab at a few comments
>> below. We will address most of the other comments in next version of I2C
>> patch.
>>>
>>>> +
>>>> +static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = {
>>>> + {KHz(100), 7, 10, 11, 26},
>>>> + {KHz(400), 2, 5, 12, 24},
>>>> + {KHz(1000), 1, 3, 9, 18},
>>>
>>>
>>> So I guess this is all relying on an input serial clock of 19.2MHz?
>>> Maybe document that?
>>>
>>> Assuming I'm understanding the math here, is it really OK for your
>>> 100kHz and 1MHz mode to be running slightly fast?
>>>
>>> 19200. / 2 / 24
>>>>>>
>>>>>> 400.0
>>>
>>>
>>> 19200. / 7 / 26
>>>>>>
>>>>>> 105.49450549450549
>>>
>>>
>>> 19200. / 1 / 18
>>>>>>
>>>>>> 1066.6666666666667
>>>
>>>
>>> It seems like you'd want the fastest clock that you can make that's
>>> _less than_ the spec.
>>>
>>>
>>> It would also be interesting to know if it's expected that boards
>>> might need to tweak the t_high / t_low depending on their electrical
>>> characteristics. In the past I've had lots of requests from board
>>> makers to tweak things because they've got a long trace, or a stronger
>>> or weaker pull, or ... If so we might later need to add some dts
>>> properties like "i2c-scl-rising-time-ns" and make the math more
>>> dynamic here, unless your hardware somehow automatically adjusts for
>>> this type of thing...
>>> These values are derived by our HW team to comply with the t-high and
>>
>> t-low specs of I2C. We have confirmed on scope that the frequency of SCL is
>> indeed less than/equal to the spec. We have not come across slaves who have
>> needed to tweak these things. We are open to adding these properties in dts
>> if you have any such slaves not conforming due to board-layout of other
>> reasons.
>
> OK, I'm fine with leaving something like this till later if/when it
> comes up. Documenting a little bit more about how these timings work
> seems like it would be nice, though, at least mentioning what the
> source clock is...
>
Yes, we will document how t-high and t-low is derived from source.
>>> Wow, that's a cluster of arcane calls to handle a call that probably
>>> will never fail (it just enables clocks and sets pinctrl). Sigh.
>>> ...but as far as I can tell the whole sequence is right. You
>>> definitely need a "put" after a failed get and it looks like
>>> pm_runtime_set_suspended() has a special exception where it can be
>>> called if you got a runtime error...
>>
>> We didn't have this in before either. But this condition is somewhat
>> frequent if I2C transactions are called on cusp of exiting system suspend.
>> (e.g. PMIC slave getting a wakeup-IRQ and trying to read from PMIC through
>> I2C to read its status as to what caused that wake-up. At that time,
>> get_sync doesn't really enable resources (kernel 4.9) since the runtime-pm
>> ref-count isn't decremented. We run the risk of unclocked access if these
>> arcane calls aren't present. You can go through runtime-pm documentation
>> chapter 6 for more details.
>
> Yeah, I certainly agree that the calls are needed if
> pm_runtime_get_sync() and I'm not suggesting removing them. Hence the
> "as far as I can tell the whole sequence is right".
>
> ...but I'm actually kinda worried if you're saying that you actually
> ran into this case. Hopefully that got fixed and code no longer tries
> to read from the PMIC at a bad time anymore? That code should be
> fixed not to be running so late in suspend.
>
I have added Harry Y and Abhijeet D (developers for PMIC I2C client
team). They can comment if there is still a usecase of very late
transaction during suspend and/or very early transaction during resume.
>
>>>>
>>>> + /* Make sure no transactions are pending */
>>>> + ret = i2c_trylock_bus(&gi2c->adap, I2C_LOCK_SEGMENT);
>>>> + if (!ret) {
>>>> + dev_err(gi2c->se.dev, "late I2C transaction request\n");
>>>> + return -EBUSY;
>>>> + }
>>>
>>>
>>> Does this happen? How?
>>>
>>> Nothing about this code looks special for your hardware. If this is
>>> really needed, why is it not part of the i2c core since there's
>>> nothing specific about your driver here?
>>>
>> There have been some clients that don't implement sys-suspend/resume
>> callbacks (so i2c adapter has no clue they are done with their transactions)
>> and this allows us to be flexible when they call I2C transactions extremely
>> late.
>
> Still feels like this belongs in the i2c core, not your driver. Maybe
> you should send a patch for the core and remove it from here?
>
> ...and also, it seems like any i2c clients that don't implement the
> suspend/resume callbacks and try to do i2c transactions late in the
> game need to be fixed. It should be documented that this isn't a
> valid thing for a driver to do and if we end up in this error case
> then it's not an i2c issue but it's a bad driver somewhere.
>
You are right: this check is special for our HW due to usecases
mentioned above.
This check can go in i2c-core, but then it will not be necessary if
all adapters and clients that we work with are upstreamed (and all
implement system suspend/resume).
We will remove this in next version of geni i2c-adapter driver.
Thanks
Sagar
--
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2018-03-09 1:27 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 1:38 [PATCH v3 0/4] Introduce GENI SE Controller Driver Karthikeyan Ramasubramanian
2018-02-28 1:38 ` [PATCH v3 1/4] dt-bindings: soc: qcom: Add device tree binding for GENI SE Karthikeyan Ramasubramanian
2018-03-05 23:58 ` Rob Herring
2018-03-06 0:55 ` Karthik Ramasubramanian
2018-03-06 13:22 ` Rob Herring
2018-03-06 17:13 ` Karthik Ramasubramanian
2018-02-28 1:38 ` [PATCH v3 2/4] soc: qcom: Add GENI based QUP Wrapper driver Karthikeyan Ramasubramanian
2018-03-02 20:41 ` Stephen Boyd
2018-03-02 20:58 ` Evan Green
2018-03-03 0:58 ` Karthik Ramasubramanian
2018-03-06 21:56 ` Stephen Boyd
[not found] ` <152037339742.218381.11498404122038956963-n1Xw8LXHxjTHt/MElyovVYaSKrA+ACpX0E9HWUfgJXw@public.gmane.org>
2018-03-08 6:46 ` Karthik Ramasubramanian
[not found] ` <945b6c00-dde6-6ec7-4577-4cc0d034796b-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-03-08 13:24 ` Robin Murphy
[not found] ` <8567be1b-1431-4f1d-cb41-6a7eaa434438-5wv7dgnIgG8@public.gmane.org>
2018-03-08 14:41 ` Christoph Hellwig
2018-03-08 18:18 ` Karthik Ramasubramanian
2018-03-09 18:18 ` Karthik Ramasubramanian
2018-02-28 1:38 ` [PATCH v3 3/4] i2c: i2c-qcom-geni: Add bus driver for the Qualcomm GENI I2C controller Karthikeyan Ramasubramanian
2018-03-07 21:16 ` [v3, " Doug Anderson
2018-03-08 2:42 ` Sagar Dharia
2018-03-08 5:19 ` Doug Anderson
2018-03-08 21:12 ` Doug Anderson
2018-03-09 1:06 ` Sagar Dharia
2018-03-09 5:02 ` Doug Anderson
2018-03-09 1:27 ` Sagar Dharia [this message]
2018-03-09 6:43 ` Karthik Ramasubramanian
2018-02-28 1:38 ` [PATCH v3 4/4] tty: serial: msm_geni_serial: Add serial driver support for GENI based QUP Karthikeyan Ramasubramanian
2018-03-02 22:11 ` Stephen Boyd
2018-03-06 0:51 ` Karthik Ramasubramanian
2018-03-06 21:45 ` Stephen Boyd
2018-03-08 6:06 ` Karthik Ramasubramanian
2018-03-08 22:32 ` Stephen Boyd
2018-03-09 4:57 ` Karthik Ramasubramanian
2018-03-03 0:11 ` Evan Green
2018-03-13 20:16 ` Karthik Ramasubramanian
2018-03-16 18:39 ` Evan Green
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=014494b3-0b4a-d82f-0b93-53464e281cb4@codeaurora.org \
--to=sdharia@codeaurora.org \
--cc=acourbot@chromium.org \
--cc=adharmap@codeaurora.org \
--cc=andy.gross@linaro.org \
--cc=corbet@lwn.net \
--cc=david.brown@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=evgreen@chromium.org \
--cc=girishm@codeaurora.org \
--cc=gregkh@linuxfoundation.org \
--cc=harryy@codeaurora.org \
--cc=jslaby@suse.com \
--cc=kramasub@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=swboyd@chromium.org \
--cc=wsa@the-dreams.de \
/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).