All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc <linux-mmc@vger.kernel.org>,
	linux-block <linux-block@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Bough Chen <haibo.chen@nxp.com>,
	Alex Lemberg <alex.lemberg@sandisk.com>,
	Mateusz Nowak <mateusz.nowak@intel.com>,
	Yuliy Izrailov <Yuliy.Izrailov@sandisk.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Dong Aisheng <dongas86@gmail.com>,
	Das Asutosh <asutoshd@codeaurora.org>,
	Zhangfei Gao <zhangfei.gao@gmail.com>,
	Sahitya Tummala <stummala@codeaurora.org>,
	Harjani Ritesh <riteshh@codeaurora.org>,
	Venu Byravarasu <vbyravarasu@nvidia.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Shawn Lin <shawn.lin@rock-chips.com>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH V8 00/14] mmc: Add Command Queue support
Date: Fri, 13 Oct 2017 14:58:11 +0300	[thread overview]
Message-ID: <008d5504-d5ae-06fc-5c3f-c39e14d49d50@intel.com> (raw)
In-Reply-To: <CAPDyKFqoMVemtCSHBzfK5YTqLsGEr_v_z7o=HOKCwEdVz0tH_w@mail.gmail.com>

On 11/10/17 16:58, Ulf Hansson wrote:
> On 11 October 2017 at 14:58, Adrian Hunter <adrian.hunter@intel.com> wrote:
>> On 11/10/17 15:13, Ulf Hansson wrote:
>>> On 10 October 2017 at 15:31, Adrian Hunter <adrian.hunter@intel.com> wrote:
>>>> On 10/10/17 16:08, Ulf Hansson wrote:
>>>>> [...]
>>>>>
>>>>>>>>>
>>>>>>>>> I have also run some test on my ux500 board and enabling the blkmq
>>>>>>>>> path via the new MMC Kconfig option. My idea was to run some iozone
>>>>>>>>> comparisons between the legacy path and the new blkmq path, but I just
>>>>>>>>> couldn't get to that point because of the following errors.
>>>>>>>>>
>>>>>>>>> I am using a Kingston 4GB SDHC card, which is detected and mounted
>>>>>>>>> nicely. However, when I decide to do some writes to the card I get the
>>>>>>>>> following errors.
>>>>>>>>>
>>>>>>>>> root@ME:/mnt/sdcard dd if=/dev/zero of=testfile bs=8192 count=5000 conv=fsync
>>>>>>>>> [  463.714294] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  464.722656] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  466.081481] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  467.111236] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  468.669647] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  469.685699] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  471.043334] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  472.052337] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  473.342651] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  474.323760] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  475.544769] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  476.539031] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  477.748474] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>> [  478.724182] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>>>>
>>>>>>>>> I haven't yet got the point of investigating this any further, and
>>>>>>>>> unfortunate I have a busy schedule with traveling next week. I will do
>>>>>>>>> my best to look into this as soon as I can.
>>>>>>>>>
>>>>>>>>> Perhaps you have some ideas?
>>>>>>>>
>>>>>>>> The behaviour depends on whether you have MMC_CAP_WAIT_WHILE_BUSY. Try
>>>>>>>> changing that and see if it makes a difference.
>>>>>>>
>>>>>>> Yes, it does! I disabled MMC_CAP_WAIT_WHILE_BUSY (and its
>>>>>>> corresponding code in mmci.c) and the errors goes away.
>>>>>>>
>>>>>>> When I use MMC_CAP_WAIT_WHILE_BUSY I get these problems:
>>>>>>>
>>>>>>> [  223.820983] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>> [  224.815795] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>> [  226.034881] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>> [  227.112884] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>> [  227.220275] mmc0: Card stuck in wrong state! mmcblk0 mmc_blk_card_stuck
>>>>>>> [  228.686798] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>> [  229.892150] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>> [  231.031890] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>> [  232.239013] mmci-pl18x 80126000.sdi0_per1: error during DMA transfer!
>>>>>>> 5000+0 records in
>>>>>>> 5000+0 records out
>>>>>>> root@ME:/mnt/sdcard
>>>>>>>
>>>>>>> I looked at the new blkmq code from patch v10 13/15. It seems like the
>>>>>>> MMC_CAP_WAIT_WHILE_BUSY is used to determine whether the async request
>>>>>>> mechanism should be used or not. Perhaps I didn't looked close enough,
>>>>>>> but maybe you could elaborate on why this seems to be the case!?
>>>>>>
>>>>>> MMC_CAP_WAIT_WHILE_BUSY is necessary because it means that a data transfer
>>>>>> request has finished when the host controller calls mmc_request_done(). i.e.
>>>>>> polling the card is not necessary.
>>>>>
>>>>> Well, that is a rather big change on its own. Earlier we polled with
>>>>> CMD13 to verify that the card has moved back to the transfer state, in
>>>>> case it was a write. And that was no matter of MMC_CAP_WAIT_WHILE_BUSY
>>>>> was set or not. Right!?
>>>>
>>>> Yes
>>>>
>>>>>
>>>>> I am not sure it's a good idea to bypass that validation, it seems
>>>>> fragile to rely only on the busy detection on DAT line for writes.
>>>>
>>>> Can you cite something from the specifications that backs that up, because I
>>>> couldn't find anything to suggest that CMD13 polling was expected.
>>>
>>> No I can't, but I don't see why that matters.
>>>
>>> My point is, if we want to go down that road by avoiding the CMD13
>>> polling, that needs to be a separate change, which we can test and
>>> confirm on its own.
>>>
>>>>
>>>>>
>>>>>>
>>>>>> Have you tried V9 or V10.  There was a fix in V9 related to calling
>>>>>> ->post_req() which could mess up DMA.
>>>>>
>>>>> I have used V10.
>>>>>
>>>>>>
>>>>>> The other thing that could go wrong with DMA is if it cannot accept
>>>>>> ->post_req() being called from mmc_request_done().
>>>>>
>>>>> I don't think mmci has a problem with that, however why do you want to
>>>>> do this? Wouldn't that defeat some of the benefits with the async
>>>>> request mechanism?
>>>>
>>>> Perhaps - but it would need to be tested.  If there are more requests
>>>> waiting, one optimization could be to defer ->post_req() until after the
>>>> next request is started.
>>>
>>> This is already proven, because this how the existing mmc async
>>> request mechanism works.
>>>
>>> In ->post_req() callbacks, host drivers may do dma_unmap_sg(), which
>>> is something that could be costly and therefore it's better to start a
>>> new request before, such these things can go on in parallel.
>>
>> OK I will make a patch that takes care of both issues.  That will also mean
>> the request is not completed in the ->done() callback because ->post_req()
>> must precede block layer completion.
> 
> Right.
> 
> Actually completing the request in the ->done callback, may still be
> possible, because in principle it only needs to inform the other
> prepared request that it may start, before it continues to post
> process/completes the current one.

It already does that.

> 
> However, by looking at for example how mmci.c works, it actually holds
> its spinlock while it calls mmc_request_done(). The same spinlock is
> taken in the ->request() function, but not in the ->post_req()
> function. In other words, completing the request in the ->done()
> callback, would make mmci to keep the spinlock held throughout the
> post processing cycle, which then prevents the next request from being
> started.

It is in interrupt context also. So if the block layer work is on the same
CPU it will anyway wait.

> 
> So my conclusion is, let's start a as you suggested, by not completing
> the request in ->done() as to maintain existing behavior. Then we can
> address optimizations on top, which very likely will involve doing
> changes to host drivers as well.

Ideally it should be possible to start the next already prepared request
from the ->done() callback of the current request.  Perhaps add a new host API.

  parent reply	other threads:[~2017-10-13 12:05 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-13 11:40 [PATCH V8 00/14] mmc: Add Command Queue support Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 01/14] mmc: core: Introduce host claiming by context Adrian Hunter
2017-09-20  9:00   ` Ulf Hansson
2017-09-22 11:23   ` Linus Walleij
2017-09-13 11:40 ` [PATCH V8 02/14] mmc: core: Add support for handling CQE requests Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 03/14] mmc: mmc: Enable Command Queuing Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 04/14] mmc: mmc: Enable CQE's Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 05/14] mmc: block: Use local variables in mmc_blk_data_prep() Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 06/14] mmc: block: Prepare CQE data Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 07/14] mmc: block: Factor out mmc_setup_queue() Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 08/14] mmc: core: Add parameter use_blk_mq Adrian Hunter
2017-09-21  9:47   ` Ulf Hansson
2017-09-22 13:30     ` Adrian Hunter
2017-09-22 14:01       ` Linus Walleij
2017-09-13 11:40 ` [PATCH V8 09/14] mmc: core: Remove unnecessary host claim Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 10/14] mmc: core: Export mmc_start_bkops() Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 11/14] mmc: core: Export mmc_start_request() Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 12/14] mmc: block: Add CQE and blk-mq support Adrian Hunter
2017-09-21  9:59   ` Ulf Hansson
2017-09-21 11:17     ` Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 13/14] mmc: cqhci: support for command queue enabled host Adrian Hunter
2017-09-13 11:40 ` [PATCH V8 14/14] mmc: sdhci-pci: Add CQHCI support for Intel GLK Adrian Hunter
2017-09-18 12:19   ` [PATCH V9 " Adrian Hunter
2017-09-21  9:01 ` [PATCH V8 00/14] mmc: Add Command Queue support Ulf Hansson
2017-09-21  9:44   ` Adrian Hunter
2017-10-10 12:12     ` Ulf Hansson
2017-10-10 12:24       ` Adrian Hunter
2017-10-10 13:08         ` Ulf Hansson
2017-10-10 13:31           ` Adrian Hunter
2017-10-11 12:13             ` Ulf Hansson
2017-10-11 12:58               ` Adrian Hunter
2017-10-11 13:58                 ` Ulf Hansson
2017-10-12  8:08                   ` Linus Walleij
2017-10-12  8:28                     ` Ulf Hansson
2017-10-13 11:58                   ` Adrian Hunter [this message]
2017-10-18  6:16                   ` Adrian Hunter
2017-10-19 11:44                     ` Adrian Hunter
2017-10-20 12:30                       ` Adrian Hunter
2017-10-23 13:06                         ` Adrian Hunter
2017-10-24  5:37                           ` Ulf Hansson
2017-10-24  6:42                             ` Adrian Hunter
2017-10-24  7:39                               ` Ulf Hansson
2017-10-24  9:11                                 ` Adrian Hunter
2017-09-21 14:07 ` Christoph Hellwig

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=008d5504-d5ae-06fc-5c3f-c39e14d49d50@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=Yuliy.Izrailov@sandisk.com \
    --cc=alex.lemberg@sandisk.com \
    --cc=asutoshd@codeaurora.org \
    --cc=dongas86@gmail.com \
    --cc=haibo.chen@nxp.com \
    --cc=hch@lst.de \
    --cc=jh80.chung@samsung.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=mateusz.nowak@intel.com \
    --cc=riteshh@codeaurora.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=stummala@codeaurora.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vbyravarasu@nvidia.com \
    --cc=zhangfei.gao@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.