linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC : mmc : Use wait_for_completion_timeout() instead of wait_for_completion in case of multiple write blocks.
@ 2011-08-25  4:44 NamJae Jeon
  2011-08-30  7:15 ` Linus Walleij
  0 siblings, 1 reply; 6+ messages in thread
From: NamJae Jeon @ 2011-08-25  4:44 UTC (permalink / raw)
  To: linux-mmc, linux-kernel; +Cc: Chris Ball, linus.walleij, Kyungmin Park

Hi.

If card is infinitely holding pull down busy line(data 0) while
writing multiple blocks, write will be blocked in
mmc_wait_for_req_done().
I suggest to use wait_for_completion_timeout instread of
wait_for_completion like the below code.

How do you think about my suggestion ?

Thanks.

------------------------------------------------------------------------------------------------------------------
static void mmc_wait_for_req_done(struct mmc_host *host, struct
mmc_request *mrq)
{
        unsigned int write_timeout = 0;
	
        if(mrq->data != NULL && (mrq->data->flags & MMC_DATA_WRITE) &&
(mrq->cmd->opcode & MMC_WRITE_MULTIPLE_BLOCK)) {
                write_timeout =
usecs_to_jiffies(mrq->data->timeout_ns/1000) * mrq->data->blocks;
                wait_for_completion_timeout(&mrq->completion, write_timeout);
        }
        else wait_for_completion(&mrq->completion);
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC : mmc : Use wait_for_completion_timeout() instead of wait_for_completion in case of multiple write blocks.
  2011-08-25  4:44 RFC : mmc : Use wait_for_completion_timeout() instead of wait_for_completion in case of multiple write blocks NamJae Jeon
@ 2011-08-30  7:15 ` Linus Walleij
  2011-09-02  5:58   ` NamJae Jeon
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2011-08-30  7:15 UTC (permalink / raw)
  To: NamJae Jeon
  Cc: linux-mmc, linux-kernel, Chris Ball, Kyungmin Park,
	Sebastian Rasmussen, Ulf Hansson

On Thu, Aug 25, 2011 at 6:44 AM, NamJae Jeon <linkinjeon@gmail.com> wrote:

> If card is infinitely holding pull down busy line(data 0) while
> writing multiple blocks, write will be blocked in
> mmc_wait_for_req_done().
> I suggest to use wait_for_completion_timeout instread of
> wait_for_completion like the below code.
>
> How do you think about my suggestion ?

Since this is a hardware lock-up it is up to the host driver to
timeout and return an error to the framework.

For example only the host driver have information on the
clock speed on the host controller and other information such
as request size that can be used to set a suitable timeout waiting
for the request to complete.

If you just grep for timeout_ns in drivers/mmc/host you can
see several drivers using the card-supplied timeout_ns for
handing the timeout properly given local clocking
constraints etc.

Often host controllers can take the number
of clock cycles until timeout as a parameter, and only
the host controller can calculate this number.
See for example in mmci_start_data()
in mmci.c.

So I seriously think you need to look closer at the problematic
host driver if this is a problem to you, e.g. rewrite it to use
wait_for_completion_timeout() there.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC : mmc : Use wait_for_completion_timeout() instead of wait_for_completion in case of multiple write blocks.
  2011-08-30  7:15 ` Linus Walleij
@ 2011-09-02  5:58   ` NamJae Jeon
  2011-09-03 20:08     ` Linus Walleij
  0 siblings, 1 reply; 6+ messages in thread
From: NamJae Jeon @ 2011-09-02  5:58 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-mmc, linux-kernel, Chris Ball, Kyungmin Park,
	Sebastian Rasmussen, Ulf Hansson

2011/8/30 Linus Walleij <linus.walleij@linaro.org>:
> On Thu, Aug 25, 2011 at 6:44 AM, NamJae Jeon <linkinjeon@gmail.com> wrote:
>
>> If card is infinitely holding pull down busy line(data 0) while
>> writing multiple blocks, write will be blocked in
>> mmc_wait_for_req_done().
>> I suggest to use wait_for_completion_timeout instread of
>> wait_for_completion like the below code.
>>
>> How do you think about my suggestion ?
>
> Since this is a hardware lock-up it is up to the host driver to
> timeout and return an error to the framework.
>
> For example only the host driver have information on the
> clock speed on the host controller and other information such
> as request size that can be used to set a suitable timeout waiting
> for the request to complete.
>
> If you just grep for timeout_ns in drivers/mmc/host you can
> see several drivers using the card-supplied timeout_ns for
> handing the timeout properly given local clocking
> constraints etc.
>
> Often host controllers can take the number
> of clock cycles until timeout as a parameter, and only
> the host controller can calculate this number.
> See for example in mmci_start_data()
> in mmci.c.
>
> So I seriously think you need to look closer at the problematic
> host driver if this is a problem to you, e.g. rewrite it to use
> wait_for_completion_timeout() there.
>
> Yours,
> Linus Walleij
>

We should consider DMA situation. As I know, host controller can not
rise timeout interrupt in write not read in DMA status. host
controller can just know whether card is finish to program to use busy
line. If unstable card is holding busy line while writing using DMA,
hang problem will happen by wait_for_completion.
so I think that mmc driver need some exception to avoid this problem.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC : mmc : Use wait_for_completion_timeout() instead of wait_for_completion in case of multiple write blocks.
  2011-09-02  5:58   ` NamJae Jeon
@ 2011-09-03 20:08     ` Linus Walleij
  2011-09-05  0:30       ` NamJae Jeon
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2011-09-03 20:08 UTC (permalink / raw)
  To: NamJae Jeon
  Cc: linux-mmc, linux-kernel, Chris Ball, Kyungmin Park,
	Sebastian Rasmussen, Ulf Hansson

2011/9/2 NamJae Jeon <linkinjeon@gmail.com>:

> We should consider DMA situation. As I know, host controller can not
> rise timeout interrupt in write not read in DMA status.

Which host controller are you talking about?

> host
> controller can just know whether card is finish to program to use busy
> line. If unstable card is holding busy line while writing using DMA,
> hang problem will happen by wait_for_completion.
> so I think that mmc driver need some exception to avoid this problem.

Yes you can add a timeout in the driver itself. Just set up
a common timer, no big deal.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC : mmc : Use wait_for_completion_timeout() instead of wait_for_completion in case of multiple write blocks.
  2011-09-03 20:08     ` Linus Walleij
@ 2011-09-05  0:30       ` NamJae Jeon
  2011-09-05 13:11         ` Linus Walleij
  0 siblings, 1 reply; 6+ messages in thread
From: NamJae Jeon @ 2011-09-05  0:30 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-mmc, linux-kernel, Chris Ball, Kyungmin Park,
	Sebastian Rasmussen, Ulf Hansson

2011/9/4 Linus Walleij <linus.walleij@linaro.org>:
> 2011/9/2 NamJae Jeon <linkinjeon@gmail.com>:
>
>> We should consider DMA situation. As I know, host controller can not
>> rise timeout interrupt in write not read in DMA status.
>
> Which host controller are you talking about?
As I know, this controller is using on many ARM core. I can not
disclose the information in my situation.

>
>> host
>> controller can just know whether card is finish to program to use busy
>> line. If unstable card is holding busy line while writing using DMA,
>> hang problem will happen by wait_for_completion.
>> so I think that mmc driver need some exception to avoid this problem.
>
> Yes you can add a timeout in the driver itself. Just set up
> a common timer, no big deal.
>
> Yours,
> Linus Walleij
>

I didn't decide, how much timeout should I add ? first, I think that I
try to add timeout_ns * the number of blocks. but If timeout_ns is 1.6
sec and the number of blocks is 512, the timeout will be very long. or
If I just add 10*HZ(10 sec), Is it proper ?
Would you advise more for me ?

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC : mmc : Use wait_for_completion_timeout() instead of wait_for_completion in case of multiple write blocks.
  2011-09-05  0:30       ` NamJae Jeon
@ 2011-09-05 13:11         ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2011-09-05 13:11 UTC (permalink / raw)
  To: NamJae Jeon
  Cc: linux-mmc, linux-kernel, Chris Ball, Kyungmin Park,
	Sebastian Rasmussen, Ulf Hansson

On Mon, Sep 5, 2011 at 2:30 AM, NamJae Jeon <linkinjeon@gmail.com> wrote:

>>> host
>>> controller can just know whether card is finish to program to use busy
>>> line. If unstable card is holding busy line while writing using DMA,
>>> hang problem will happen by wait_for_completion.
>>> so I think that mmc driver need some exception to avoid this problem.
>>
>> Yes you can add a timeout in the driver itself. Just set up
>> a common timer, no big deal.
>
> I didn't decide, how much timeout should I add ? first, I think that I
> try to add timeout_ns * the number of blocks. but If timeout_ns is 1.6
> sec and the number of blocks is 512, the timeout will be very long. or
> If I just add 10*HZ(10 sec), Is it proper ?

The timeout_ns comes from the card CSD bits 112 thru 119.
"Data read access-time 1".

According to the spec this "Defines the asynchronous part of the data
access time."

I don't know how to interpret this, but it says nothing about the
number of blocks involved and nor does the drivers we have
interpret it that way.

This time AFAICT is for the entire transaction, not per-block.

In the mmci driver we calculate the clock cycles required for
timeout_ns and the number of clock cycles in
timeout_clks and that's it. That's the timeout for the
entire operation. This is how all drivers work I think.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-05 13:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-25  4:44 RFC : mmc : Use wait_for_completion_timeout() instead of wait_for_completion in case of multiple write blocks NamJae Jeon
2011-08-30  7:15 ` Linus Walleij
2011-09-02  5:58   ` NamJae Jeon
2011-09-03 20:08     ` Linus Walleij
2011-09-05  0:30       ` NamJae Jeon
2011-09-05 13:11         ` Linus Walleij

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