linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Dorfman <kdorfman@codeaurora.org>
To: "Per Förlin" <per.forlin@stericsson.com>
Cc: Per Forlin <per.lkml@gmail.com>,
	Venkatraman S <svenkatr@gmail.com>,
	"cjb@laptop.org" <cjb@laptop.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>
Subject: Re: [PATCH v1] mmc: fix async request mechanism for sequential read scenarios
Date: Tue, 20 Nov 2012 18:26:13 +0200	[thread overview]
Message-ID: <50ABAF25.7010708@codeaurora.org> (raw)
In-Reply-To: <50AAA5F2.6000200@stericsson.com>

Hello,

On 11/19/2012 11:34 PM, Per Förlin wrote:

>>>>>>        if (host->areq) {
>>>>>> +             if (!areq)
>>>>>> +                     mmc_prefetch_init(host->areq,
>>>>>> +                                       &host->areq->mrq->completion);
>>>>>>                mmc_wait_for_req_done(host, host->areq->mrq);
>>>>>> +             if (!areq) {
>>>>>> +                     mmc_prefetch_start(host->areq, false);
>>>>>> +                     if (mmc_prefetch_pending(host->areq))
>>>>>> +                             return NULL;
>>> In this case, mmc thread may be unblocked because done() arrived for
>>> current request and not because new request notification. In such a case
>>> we would like the done request to be handled before fetching the new
>>> request.
>> I agree. We wake up and there is no pending new request execution should proceed normally by handling the completed request.
>>
>>> In my code is_done_rcv flag used along with is_new_req flag in
>>> order to differentiate the reason for mmc thread awake.
>> In my patch the return value of "mmc_prefetch_pending()" specifies if thee is a pending request.what should happen.
>> If both current request is done and mmc_prefetch_pending is done at the same time I see there is a problem with my patch. There needs to be a flag to indicate if current request is done.
There is race between done() and NEW_REQUEST events, also when we got 
both of them, the order is to complete current and then to fetch new.


>>>>> I understand your motivation and idea for re-structure the patch. It is
>>>>> still not clear for me how exactly mmc thread will be awaken on new
>>>>> request notification in your version, but I have another problem:
>>>>>
>>>> mmc_request_fn() is called and it calls complete(mq->prefetch_completion) which wakes up the current thread.
>>>> My patch is just an example. The intention is to make the patch cleaner. But I may have missed some of the HPI aspects.
>>>
>>> Is it the lack of functions wrappers that you are using in your example?
>> It's fine to skip the functions wrappers if it makes no sense.
>> What I want to avoid is to create new functions for data_req_start and data_req_wait.
>> I would rather add this to the existing functions in core.c and keep changes in block.c and the flow minimal.
>>
>>> As I understand your example, you mean to implement generic logic on
>>> core/core.c level by using wrapper functions and leave final
>>> implementation for MMC to card/queue.c and for SDIO layer to
>>> card/..sdio.. (I'm not too familiar with sdio protocol implementation).
>>> Well, it is make a lot of sense.
>>>
>> I still have "plans" to add pre/post/async support in the SDIO framework too but I have not got to it.
>> I would be nice to add your NEW_REQ feature along with the other mmc-async features, to make it usable from SDIO.
>>
>>
>>> But the devil is in details - there is a lot of work in
>>> mmc_wait_for_data_req_done(), done() callback and also error handling
>>> changes for card/block.c
>> Things in core.c could be re-used in the SDIO case. In block.c there are only FS specific implementation not relevant for SDIO.
>>
>>>
>>> Do you think, that wait_event() API used not suits the same semantic as
>>> completion API?
>> The waiting mechanims may be wait_event or completion.
>> I'm not in favor of using both. Better to replace completion with wait_event if you prefer.
>>
> I'm fine with wait_event() (block request transfers) combined with completion (for other transfer), as long as the core.c API is intact. I don't see a reason for a new start_data_req()
>
> mmc_start_req() is only used by the mmc block transfers.
The main idea is to change start_req() waiting point 
(mmc_wait_for_data_req_done() function) in such way that external events 
(in the MMC case it is coming from block layer) may awake MMC context 
from waiting for current request. This is done by change the original 
mmc_start_req() function and not changing its signature of mmc_start_req().

May I ask you to see [PATCH v2] patch? I think that is is no change in 
core.c API (by core.c API you mean all functions from core.h?).

Also to use new request feature of core.c one need to implement 
notification similar to mmc_request_fn() and I do not see difficulties 
to do it from SDIO.


> Making a test case in mmc_test.c is a good way to stress test the feature (e.g. random timing of incoming new requests) and it will show how the API works too.
>
> BR
> Per
>
>> My main concern is to avoid adding new API to core.c in order to add the NEW_REQ feature. My patch is an example of changes to be done in core.c without adding new functions.
>>
>>>
>>> We would like to have a generic capability to handle additional events,
>>> such as HPI/stop flow, in addition to the NEW_REQUEST notification.
>>> Therefore, an event mechanism seems to be a better design than completion.
>>>
>>> I've looked at SDIO code and from what I can understand, right now SDIO
>>> is not using async request mechanism and works from 'wait_for_cmd()`
>>> level. This means that such work as exposing MMC core API's is major
>>> change and definitely should be separate design and implementation
>>> effort, while my current patch right now will fix mmc thread behavior
>>> and give better performance for upper layers.
>> You are right. There is no support in the SDIO implementation for pre/post/async feature. Still I had it in mind design the "struct mmc_async". It's possible to re-use the mmc core parts in order to utilize this support in the SDIO case. I'm not saying we should design for SDIO but at least keep the API in a way that it's potential usable from SDIO too. The API of core.c (start/wait of requests) should make sense without the existence of MMC block driver (block/queue).
>>
>> One way to test the design is to add a test in mmc_test.c for penging NEW_REQ. In mmc_test.c there is not block.c or queue.c.
>> If the test case if simple to write in mmc_test.c it's means that the API is on a good level.
I have plans to implement new test in mmc_test.c, but current patch was 
tested using special test I/O scheduler, that is used instead of cfq I/O 
scheduler: "[PATCH v5 1/3] block: Add test-iosched scheduler"

This gives us great power to create any ut scenarios.

-- 
Konstantin Dorfman,
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center,
Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

  reply	other threads:[~2012-11-20 16:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24  9:41 [PATCH v1] mmc: fix async request mechanism for sequential read scenarios Konstantin Dorfman
2012-10-24 17:07 ` Per Förlin
2012-10-25 13:28   ` Konstantin Dorfman
2012-10-25 15:02     ` Per Förlin
2012-10-26 12:07       ` Venkatraman S
2012-10-28 13:12         ` Konstantin Dorfman
2012-10-29 21:40           ` Per Forlin
2012-10-30  7:45             ` Per Forlin
2012-10-30 12:23               ` Konstantin Dorfman
2012-10-30 12:19             ` Konstantin Dorfman
2012-10-30 19:57               ` Per Forlin
2012-11-13 21:10               ` Per Forlin
2012-11-14 15:15                 ` Konstantin Dorfman
2012-11-15 16:38                   ` Per Förlin
2012-11-19  9:48                     ` Konstantin Dorfman
2012-11-19 14:32                       ` Per Förlin
2012-11-19 21:34                         ` Per Förlin
2012-11-20 16:26                           ` Konstantin Dorfman [this message]
2012-11-20 18:57                             ` Konstantin Dorfman
2012-11-26 15:28                           ` Konstantin Dorfman
2012-10-28 12:43       ` Konstantin Dorfman
2012-10-26 11:55     ` Venkatraman S
2012-10-28 12:52       ` Konstantin Dorfman
  -- strict thread matches above, loose matches on Subject: below --
2012-10-15 15:36 Konstantin Dorfman
2012-10-21 23:02 ` Per Forlin

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=50ABAF25.7010708@codeaurora.org \
    --to=kdorfman@codeaurora.org \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=per.forlin@stericsson.com \
    --cc=per.lkml@gmail.com \
    --cc=svenkatr@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 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).