[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <38a23afc-57da-a01f-286c-15f8b3d61705@broadcom.com>
Date: Tue, 10 Nov 2020 11:24:36 -0800
From: Ray Jui <ray.jui@...adcom.com>
To: Rayagonda Kokatanur <rayagonda.kokatanur@...adcom.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
BCM Kernel Feedback <bcm-kernel-feedback-list@...adcom.com>,
Brendan Higgins <brendanhiggins@...gle.com>,
Dhananjay Phadke <dphadke@...ux.microsoft.com>,
Florian Fainelli <f.fainelli@...il.com>,
linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
linux-i2c <linux-i2c@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Lori Hikichi <lori.hikichi@...adcom.com>,
Ray Jui <rjui@...adcom.com>,
Scott Branden <sbranden@...adcom.com>,
Wolfram Sang <wsa@...nel.org>
Subject: Re: [PATCH v3 5/6] i2c: iproc: handle master read request
On 11/9/2020 8:23 PM, Rayagonda Kokatanur wrote:
> Hi Ray,
>
> Could you please check Dhananjay comments and update your thoughts.
>
> On Fri, Nov 6, 2020 at 11:11 PM Dhananjay Phadke
> <dphadke@...ux.microsoft.com> wrote:
>>
>> On Thu, 5 Nov 2020 15:13:04 +0530, Rayagonda Kokatanur wrote:
>>>> So the suggestion was to set HW threshold for rx fifo interrupt, not
>>>> really a SW property. By setting it in DT, makes it easier to
>>>> customize for target system, module param needs or ioctl makes it
>>>> dependent on userpsace to configure it.
>>>>
>>>> The need for tasklet seems to arise from the fact that many bytes are
>>>> left in the fifo. If there's a common problem here, such tasklet would be
>>>> needed in i2c subsys rather than controller specific tweak, akin to
>>>> how networking uses NAPI or adding block transactions to the interface?
>>>>
>>>> For master write-read event, it seems both IS_S_RD_EVENT_SHIFT and
>>>> IS_S_RX_EVENT_SHIFT are detected, which implies that core is late to
>>>> drain rx fifo i.e. write is complete and the read has started on the bus?
>>>
>>> Yes it's true that for master write-read events both
>>> IS_S_RD_EVENT_SHIFT and IS_S_RX_EVENT_SHIFT are coming together.
>>> So before the slave starts transmitting data to the master, it should
>>> first read all data from rx-fifo i.e. complete master write and then
>>> process master read.
>>>
>>> To minimise interrupt overhead, we are batching 64bytes.
>>> To keep isr running for less time, we are using a tasklet.
>>> Again to keep the tasklet not running for more than 20u, we have set
>>> max of 10 bytes data read from rx-fifo per tasklet run.
>>>
>>> If we start processing everything in isr and using rx threshold
>>> interrupt, then isr will run for a longer time and this may hog the
>>> system.
>>> For example, to process 10 bytes it takes 20us, to process 30 bytes it
>>> takes 60us and so on.
>>> So is it okay to run isr for so long ?
>>>
>>> Keeping all this in mind we thought a tasklet would be a good option
>>> and kept max of 10 bytes read per tasklet.
>>>
>>> Please let me know if you still feel we should not use a tasklet and
>>> don't batch 64 bytes.
>>
>> Deferring to tasklet is OK, could use a kernel thread (i.e. threaded_irq)
>> as i2c rate is quite low.
>>
kernel thread was proposed in the internal review. I don't see much
benefit of using tasklet. If a thread is blocked from running for more
than several tenth of ms, that's really a system-level issue than an
issue with this driver.
IMO, it's an overkill to use tasklet here but we can probably leave it
as it is since it does not have a adverse effect and the code ran in
tasklet is short.
>> But do enable rx_threshold and read out early. This will avoid fifo full
>> or master write-read situation where lot of bytes must be drained from rx
>> fifo before serving tx fifo (avoid tx underrun).
>>
>> Best would have been setting up DMA into mem (some controllers seem capable).
>> In absence of that, it's a trade off: if rx intr threshold is low,
>> there will be more interrupts, but less time spent in each. Default could
>> still be 64B or no-thresh (allow override in dtb).
How much time is expected to read 64 bytes from an RX FIFO? Even with
APB bus each register read is expected to be in the tenth or hundreds of
nanosecond range. Reading the entire FIFO of 64 bytes should take less
than 10 us. The interrupt context switch overhead is probably longer
than that. It's much more effective to read all of them in a single
batch than breaking them into multiple batches.
Like Florian already suggested, DT property is meant to describe
variants in HW, it should not be used for this purpose. DT maintainer
Rob also mentioned this multiple times in other reviews.
>>
>> Few other comments -
>>
>>> + /* schedule tasklet to read data later */
>>> + tasklet_schedule(&iproc_i2c->slave_rx_tasklet);
>>> +
>>> + /* clear only IS_S_RX_EVENT_SHIFT interrupt */
>>> + iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET,
>>> + BIT(IS_S_RX_EVENT_SHIFT));
>>> + }
>>
>> Why clearing one rx interrupt bit here after scheduling tasklet? Should all that
>> be done by tasklet? Also should just return after scheduling tasklet?
>>
>> Thanks,
>> Dhananjay
Download attachment "smime.p7s" of type "application/pkcs7-signature" (4151 bytes)
Powered by blists - more mailing lists