devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Faiz Abbas <faiz_abbas@ti.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-mmc@vger.kernel.org, linux-omap@vger.kernel.org
Cc: ulf.hansson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com,
	kishon@ti.com, zhang.chunyan@linaro.org
Subject: Re: [PATCH v2 1/8] mmc: sdhci: Get rid of finish_tasklet
Date: Fri, 8 Mar 2019 15:36:02 +0200	[thread overview]
Message-ID: <63b6631d-86e7-b8ef-ffaf-40e7d4e96cfb@intel.com> (raw)
In-Reply-To: <8d72ff93-e07f-52b9-da85-acd54f046694@ti.com>

On 6/03/19 12:00 PM, Faiz Abbas wrote:
> Adrian,
> 
> On 25/02/19 1:47 PM, Adrian Hunter wrote:
>> On 15/02/19 9:20 PM, Faiz Abbas wrote:
>>> sdhci.c has two bottom halves implemented. A threaded_irq for handling
>>> card insert/remove operations and a tasklet for finishing mmc requests.
>>> With the addition of external dma support, dmaengine APIs need to
>>> terminate in non-atomic context before unmapping the dma buffers.
>>>
>>> To facilitate this, remove the finish_tasklet and move the call of
>>> sdhci_request_done() to the threaded_irq() callback.
>>
>> The irq thread has a higher latency than the tasklet.  The performance drop
>> is measurable on the system I tried:
>>
>> Before:
>>
>> # dd if=/dev/mmcblk1 of=/dev/null bs=1G count=1 &
>> 1+0 records in
>> 1+0 records out
>> 1073741824 bytes (1.1 GB) copied, 4.44502 s, 242 MB/s
>>
>> After:
>>
>> # dd if=/dev/mmcblk1 of=/dev/null bs=1G count=1 &
>> 1+0 records in
>> 1+0 records out
>> 1073741824 bytes (1.1 GB) copied, 4.50898 s, 238 MB/s
>>
>> So we only want to resort to the thread for the error case.
>>
> 
> Sorry for the late response here, but this is about 1.6% decrease. I
> tried out the same commands on a dra7xx board here (with about 5
> consecutive dd of 1GB) and the average decrease was 0.3%. I believe you
> will also find a lesser percentage change if you average over multiple
> dd commands.
> 
> Is this really so significant that we have to maintain two different
> bottom halves and keep having difficulty with adding APIs that can sleep?

It is a performance drop that can be avoided, so it might as well be.
Splitting the success path from the failure path is common for I/O drivers
for similar reasons as here: the success path can be optimized whereas the
failure path potentially needs to sleep.

> 
> Also I am not sure how to implement only the error handling part in the
> threaded_irq. We need to enter sdhci_request_done() and get the current
> mrq before we can check for error conditions like I've done in patch 2:
> 
> /* Terminate and synchronize dma in case of an error */
> if (data && (mrq->cmd->error || data->error) &&
>     host->use_external_dma) {
> 	struct dma_chan *chan = sdhci_external_dma_channel(host, data);
> 	dmaengine_terminate_sync(chan);
> }
> 
> On a related note, do we really need to protect everything in
> sdhci_request_done() with spinlocks?
>                                      In patch 2 I have only removed lock
> for the terminate_sync() parts that I added but the whole
> dma_unmap/dma_sync parts should be left unprotected IMO.

As it is written, synchronization is needed to stop the same mrq being
finished twice.

I suggest doing the dmaengine_terminate_sync() before calling
sdhci_request_done().  Perhaps you could record the channel that needs to be
sync'd and then do:

	struct dma_chan *chan = READ_ONCE(host->sync_chan);

	if (chan) {
		dmaengine_terminate_sync(chan);
		host->sync_chan = NULL;
	}

  reply	other threads:[~2019-03-08 13:36 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15 19:20 [PATCH v2 0/8] Port am335 and am437 devices to sdhci-omap Faiz Abbas
2019-02-15 19:20 ` [PATCH v2 1/8] mmc: sdhci: Get rid of finish_tasklet Faiz Abbas
2019-02-25  8:17   ` Adrian Hunter
2019-03-06 10:00     ` Faiz Abbas
2019-03-08 13:36       ` Adrian Hunter [this message]
2019-03-12 17:30         ` Rizvi, Mohammad Faiz Abbas
2019-03-14 11:15           ` Grygorii Strashko
2019-03-14 11:41             ` Faiz Abbas
2019-03-14 11:40           ` Arnd Bergmann
2019-03-18  9:33   ` Ulf Hansson
2019-03-26  7:33     ` Adrian Hunter
2019-04-02  7:59       ` Faiz Abbas
2019-04-02 13:12         ` Adrian Hunter
2019-02-15 19:20 ` [PATCH v2 2/8] mmc: sdhci: add support for using external DMA devices Faiz Abbas
2019-02-15 19:20 ` [PATCH v2 3/8] dt-bindings: sdhci-omap: Add properties for using external dma Faiz Abbas
2019-02-15 20:07   ` Tony Lindgren
2019-02-18 13:41     ` Faiz Abbas
2019-02-18 16:20       ` Tony Lindgren
2019-02-18 16:28         ` Tony Lindgren
2019-02-18 20:12       ` Rob Herring
2019-02-19 13:32         ` Faiz Abbas
2019-02-15 19:20 ` [PATCH v2 4/8] mmc: sdhci-omap: Add " Faiz Abbas
2019-02-15 19:20 ` [PATCH v2 5/8] mmc: sdhci: Add quirk for disabling DTO during erase command Faiz Abbas
2019-02-15 19:20 ` [PATCH v2 6/8] mmc: sdhci-omap: Add DISABLE_DTO_FOR_ERASE Quirk Faiz Abbas
2019-02-15 19:20 ` [PATCH v2 7/8] dt-bindings: sdhci-omap: Add am335x and am437x specific bindings Faiz Abbas
2019-02-15 19:20 ` [PATCH v2 8/8] mmc: sdhci-omap: Add am335x and am437x specific compatibles Faiz Abbas
2019-02-15 20:02 ` [PATCH v2 0/8] Port am335 and am437 devices to sdhci-omap Tony Lindgren
2019-02-18 13:49   ` Faiz Abbas
2019-02-18 16:25     ` Tony Lindgren

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=63b6631d-86e7-b8ef-ffaf-40e7d4e96cfb@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=faiz_abbas@ti.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=zhang.chunyan@linaro.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).