linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dhananjay Phadke <dphadke@linux.microsoft.com>
To: rayagonda.kokatanur@broadcom.com
Cc: andriy.shevchenko@linux.intel.com,
	bcm-kernel-feedback-list@broadcom.com, brendanhiggins@google.com,
	dphadke@linux.microsoft.com, f.fainelli@gmail.com,
	linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org, lori.hikichi@broadcom.com,
	ray.jui@broadcom.com, rjui@broadcom.com, sbranden@broadcom.com,
	wsa@kernel.org
Subject: Re: [PATCH v3 5/6] i2c: iproc: handle master read request
Date: Fri,  6 Nov 2020 09:41:26 -0800	[thread overview]
Message-ID: <1604684486-16272-1-git-send-email-dphadke@linux.microsoft.com> (raw)
In-Reply-To: <CAHO=5PGAMvRAyrBF3_ubbgciqHV3hAbmt4B7Rb3hdibMbgs6ZQ@mail.gmail.com>

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.

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).

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

  reply	other threads:[~2020-11-06 17:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02  3:54 [PATCH v3 0/6] fix iproc driver to handle master read request Rayagonda Kokatanur
2020-11-02  3:54 ` [PATCH v3 1/6] i2c: iproc: handle Master aborted error Rayagonda Kokatanur
2020-11-02  3:54 ` [PATCH v3 2/6] i2c: iproc: handle only slave interrupts which are enabled Rayagonda Kokatanur
2020-11-02  3:54 ` [PATCH v3 3/6] i2c: iproc: update slave isr mask (ISR_MASK_SLAVE) Rayagonda Kokatanur
2020-11-02  3:54 ` [PATCH v3 4/6] i2c: iproc: fix typo in slave_isr function Rayagonda Kokatanur
2020-11-02  3:54 ` [PATCH v3 5/6] i2c: iproc: handle master read request Rayagonda Kokatanur
2020-11-03  6:19   ` Dhananjay Phadke
2020-11-04  3:35   ` Florian Fainelli
2020-11-04  3:57     ` Rayagonda Kokatanur
2020-11-04 18:01       ` Ray Jui
2020-11-05  7:46         ` Dhananjay Phadke
2020-11-05  9:43           ` Rayagonda Kokatanur
2020-11-06 17:41             ` Dhananjay Phadke [this message]
2020-11-10  4:23               ` Rayagonda Kokatanur
2020-11-10 19:24                 ` Ray Jui
2020-11-14  1:17                   ` Dhananjay Phadke
     [not found]                     ` <CAHO=5PFzd9KTR93ntUvAX5dqzxqJQpVXEirs5uoXdvcnZ7hL4g@mail.gmail.com>
2020-12-02 14:35                       ` Wolfram Sang
2020-12-02 17:44                         ` Ray Jui
2020-12-17  4:08                           ` Rayagonda Kokatanur
2020-12-17 19:11                             ` Ray Jui
2020-12-20  7:13                               ` Rayagonda Kokatanur
2021-01-05 16:21                                 ` Wolfram Sang
2021-01-05 17:46                                   ` Florian Fainelli
2021-01-05 20:50                                     ` Wolfram Sang
2020-12-02 17:43                       ` Ray Jui
2020-11-02  3:54 ` [PATCH v3 6/6] i2c: iproc: handle rx fifo full interrupt Rayagonda Kokatanur

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=1604684486-16272-1-git-send-email-dphadke@linux.microsoft.com \
    --to=dphadke@linux.microsoft.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=brendanhiggins@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lori.hikichi@broadcom.com \
    --cc=ray.jui@broadcom.com \
    --cc=rayagonda.kokatanur@broadcom.com \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --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).