diff mbox

mmc: core: fix the aysync mechanism when card removed

Message ID 50FE838C.5010709@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jaehoon Chung Jan. 22, 2013, 12:18 p.m. UTC
When card removed, then didn't complete the previously data.
(It didn't wakeup any interrupt.)
If card is removed, then we can assume to complete the previously data.
And wakeup the interrupt for wait_event of data.

This problem is produced when sd-card is removed.(Sd-card is running some operation)

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Kyungmin Park <Kyungmin.park@samsung.com>
---
 drivers/mmc/core/core.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

Comments

Jaehoon Chung Jan. 31, 2013, 7:06 a.m. UTC | #1
Have any other opinion?

On 01/22/2013 09:18 PM, Jaehoon Chung wrote:
> When card removed, then didn't complete the previously data.
> (It didn't wakeup any interrupt.)
> If card is removed, then we can assume to complete the previously data.
> And wakeup the interrupt for wait_event of data.
> 
> This problem is produced when sd-card is removed.(Sd-card is running some operation)
> 
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> Signed-off-by: Kyungmin Park <Kyungmin.park@samsung.com>
> ---
>  drivers/mmc/core/core.c |   31 ++++++++++++++++++++-----------
>  1 files changed, 20 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 8b3a122..bc1d627 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -515,17 +515,26 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
>  		mmc_pre_req(host, areq->mrq, !host->areq);
>  
>  	if (host->areq) {
> -			err = mmc_wait_for_data_req_done(host, host->areq->mrq,
> -					areq);
> -			if (err == MMC_BLK_NEW_REQUEST) {
> -				if (error)
> -					*error = err;
> -				/*
> -				 * The previous request was not completed,
> -				 * nothing to return
> -				 */
> -				return NULL;
> -			}
> +		err = mmc_wait_for_data_req_done(host, host->areq->mrq,
> +				areq);
> +		if (err == MMC_BLK_NEW_REQUEST) {
> +			if (error)
> +				*error = err;
> +			/*
> +			 * The previous request was not completed,
> +			 * nothing to return
> +			 */
> +			return NULL;
> +		} else if (err == MMC_BLK_NOMEDIUM && areq) {
> +			struct mmc_context_info *ctnx = &host->context_info;
> +			/*
> +			 * If crad is removed,
> +			 * then we didn't wait for data completed.
> +			 * Assume that data-recieve done.
> +			 */
> +			ctnx->is_done_rcv = true;
> +			wake_up_interruptible(&ctnx->wait);
> +		}
>  		/*
>  		 * Check BKOPS urgency for each R1 response
>  		 */
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
subhashj@codeaurora.org Jan. 31, 2013, 8:42 a.m. UTC | #2
On 1/22/2013 5:48 PM, Jaehoon Chung wrote:
> When card removed, then didn't complete the previously data.
> (It didn't wakeup any interrupt.)
> If card is removed, then we can assume to complete the previously data.
> And wakeup the interrupt for wait_event of data.
>
> This problem is produced when sd-card is removed.(Sd-card is running some operation)
>
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> Signed-off-by: Kyungmin Park <Kyungmin.park@samsung.com>
> ---
>   drivers/mmc/core/core.c |   31 ++++++++++++++++++++-----------
>   1 files changed, 20 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 8b3a122..bc1d627 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -515,17 +515,26 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
>   		mmc_pre_req(host, areq->mrq, !host->areq);
>   
>   	if (host->areq) {
> -			err = mmc_wait_for_data_req_done(host, host->areq->mrq,
> -					areq);
> -			if (err == MMC_BLK_NEW_REQUEST) {
> -				if (error)
> -					*error = err;
> -				/*
> -				 * The previous request was not completed,
> -				 * nothing to return
> -				 */
> -				return NULL;
> -			}
> +		err = mmc_wait_for_data_req_done(host, host->areq->mrq,
> +				areq);
> +		if (err == MMC_BLK_NEW_REQUEST) {
> +			if (error)
> +				*error = err;
> +			/*
> +			 * The previous request was not completed,
> +			 * nothing to return
> +			 */
> +			return NULL;
> +		} else if (err == MMC_BLK_NOMEDIUM && areq) {
> +			struct mmc_context_info *ctnx = &host->context_info;
> +			/*
> +			 * If crad is removed,
> +			 * then we didn't wait for data completed.
> +			 * Assume that data-recieve done.
> +			 */
> +			ctnx->is_done_rcv = true;
> +			wake_up_interruptible(&ctnx->wait);

Can you please explain more on what exactly we are trying to do here 
(may be you can list down the call flow)? I am not sure if i understood 
this correctly. But why would you need to wakeup the thread here? We are 
here because thread is already woken up. mmc_wait_for_data_req_done() 
would return only if either the new request is received or the currently 
running request on controller is completed.

Regards,
Subhash

> +		}
>   		/*
>   		 * Check BKOPS urgency for each R1 response
>   		 */

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jaehoon Chung Jan. 31, 2013, 9:46 a.m. UTC | #3
On 01/31/2013 05:42 PM, Subhash Jadavani wrote:
> On 1/22/2013 5:48 PM, Jaehoon Chung wrote:
>> When card removed, then didn't complete the previously data.
>> (It didn't wakeup any interrupt.)
>> If card is removed, then we can assume to complete the previously data.
>> And wakeup the interrupt for wait_event of data.
>>
>> This problem is produced when sd-card is removed.(Sd-card is running some operation)
>>
>> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
>> Signed-off-by: Kyungmin Park <Kyungmin.park@samsung.com>
>> ---
>>   drivers/mmc/core/core.c |   31 ++++++++++++++++++++-----------
>>   1 files changed, 20 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>> index 8b3a122..bc1d627 100644
>> --- a/drivers/mmc/core/core.c
>> +++ b/drivers/mmc/core/core.c
>> @@ -515,17 +515,26 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
>>           mmc_pre_req(host, areq->mrq, !host->areq);
>>         if (host->areq) {
>> -            err = mmc_wait_for_data_req_done(host, host->areq->mrq,
>> -                    areq);
>> -            if (err == MMC_BLK_NEW_REQUEST) {
>> -                if (error)
>> -                    *error = err;
>> -                /*
>> -                 * The previous request was not completed,
>> -                 * nothing to return
>> -                 */
>> -                return NULL;
>> -            }
>> +        err = mmc_wait_for_data_req_done(host, host->areq->mrq,
>> +                areq);
>> +        if (err == MMC_BLK_NEW_REQUEST) {
>> +            if (error)
>> +                *error = err;
>> +            /*
>> +             * The previous request was not completed,
>> +             * nothing to return
>> +             */
>> +            return NULL;
>> +        } else if (err == MMC_BLK_NOMEDIUM && areq) {
>> +            struct mmc_context_info *ctnx = &host->context_info;
>> +            /*
>> +             * If crad is removed,
>> +             * then we didn't wait for data completed.
>> +             * Assume that data-recieve done.
>> +             */
>> +            ctnx->is_done_rcv = true;
>> +            wake_up_interruptible(&ctnx->wait);
> 
> Can you please explain more on what exactly we are trying to do here (may be you can list down the call flow)? I am not sure if i understood this correctly. But why would you need to wakeup the thread here? We are here because thread is already woken up. mmc_wait_for_data_req_done() would return only if either the new request is received or the currently running request on controller is completed.
This problem is produced when card is removed and running some operation.
If card is removed, mmc_wait_for_data_req_done() is returned error, right?
But if there was async request and running async operation, then maybe run mmc_start_request() with areq.
controller is waiting "_for_req_data_done_" for areq.

If request is host->areq.process is running at this time.
But if request is areq(prepared request), then mmc_wait_for_data_req_done should be pending.
and system is dead-lock.

Best Regards,
Jaehoon Chung

> 
> Regards,
> Subhash
> 
>> +        }
>>           /*
>>            * Check BKOPS urgency for each R1 response
>>            */
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Seungwon Jeon Jan. 31, 2013, 10:48 a.m. UTC | #4
On Thursday, January 31, 2013, Jaehoon Chung wrote:
> On 01/31/2013 05:42 PM, Subhash Jadavani wrote:
> > On 1/22/2013 5:48 PM, Jaehoon Chung wrote:
> >> When card removed, then didn't complete the previously data.
> >> (It didn't wakeup any interrupt.)
> >> If card is removed, then we can assume to complete the previously data.
> >> And wakeup the interrupt for wait_event of data.
> >>
> >> This problem is produced when sd-card is removed.(Sd-card is running some operation)
> >>
> >> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> >> Signed-off-by: Kyungmin Park <Kyungmin.park@samsung.com>
> >> ---
> >>   drivers/mmc/core/core.c |   31 ++++++++++++++++++++-----------
> >>   1 files changed, 20 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> >> index 8b3a122..bc1d627 100644
> >> --- a/drivers/mmc/core/core.c
> >> +++ b/drivers/mmc/core/core.c
> >> @@ -515,17 +515,26 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
> >>           mmc_pre_req(host, areq->mrq, !host->areq);
> >>         if (host->areq) {
> >> -            err = mmc_wait_for_data_req_done(host, host->areq->mrq,
> >> -                    areq);
> >> -            if (err == MMC_BLK_NEW_REQUEST) {
> >> -                if (error)
> >> -                    *error = err;
> >> -                /*
> >> -                 * The previous request was not completed,
> >> -                 * nothing to return
> >> -                 */
> >> -                return NULL;
> >> -            }
> >> +        err = mmc_wait_for_data_req_done(host, host->areq->mrq,
> >> +                areq);
> >> +        if (err == MMC_BLK_NEW_REQUEST) {
> >> +            if (error)
> >> +                *error = err;
> >> +            /*
> >> +             * The previous request was not completed,
> >> +             * nothing to return
> >> +             */
> >> +            return NULL;
> >> +        } else if (err == MMC_BLK_NOMEDIUM && areq) {
> >> +            struct mmc_context_info *ctnx = &host->context_info;
> >> +            /*
> >> +             * If crad is removed,
> >> +             * then we didn't wait for data completed.
> >> +             * Assume that data-recieve done.
> >> +             */
> >> +            ctnx->is_done_rcv = true;
> >> +            wake_up_interruptible(&ctnx->wait);
> >
> > Can you please explain more on what exactly we are trying to do here (may be you can list down the
> call flow)? I am not sure if i understood this correctly. But why would you need to wakeup the thread
> here? We are here because thread is already woken up. mmc_wait_for_data_req_done() would return only
> if either the new request is received or the currently running request on controller is completed.
> This problem is produced when card is removed and running some operation.
> If card is removed, mmc_wait_for_data_req_done() is returned error, right?
> But if there was async request and running async operation, then maybe run mmc_start_request() with
> areq.
> controller is waiting "_for_req_data_done_" for areq.
> 
> If request is host->areq.process is running at this time.
> But if request is areq(prepared request), then mmc_wait_for_data_req_done should be pending.
> and system is dead-lock.
I also found this problem with sdcard.
I think it can be solved easily. Did you see the following patch?
[PATCH 1/2] mmc: core: fix permanent sleep of mmcqd during card removal
We may just get the hint from __mmc_start_req function.

Thanks,
Seungwon Jeon
> 
> Best Regards,
> Jaehoon Chung
> 
> >
> > Regards,
> > Subhash
> >
> >> +        }
> >>           /*
> >>            * Check BKOPS urgency for each R1 response
> >>            */
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jaehoon Chung Jan. 31, 2013, 11:03 a.m. UTC | #5
Hi Seungwon,

I didn't see your patch "[PATCH 1/2] mmc: core: fix permanent sleep of mmcqd during card removal".
But i found the patch. right..i think it's also same problem.

Your patch is more generic..great.
I will reply to your patch with my acked.

Best Regards,
Jaehoon Chung

On 01/31/2013 07:48 PM, Seungwon Jeon wrote:
> On Thursday, January 31, 2013, Jaehoon Chung wrote:
>> On 01/31/2013 05:42 PM, Subhash Jadavani wrote:
>>> On 1/22/2013 5:48 PM, Jaehoon Chung wrote:
>>>> When card removed, then didn't complete the previously data.
>>>> (It didn't wakeup any interrupt.)
>>>> If card is removed, then we can assume to complete the previously data.
>>>> And wakeup the interrupt for wait_event of data.
>>>>
>>>> This problem is produced when sd-card is removed.(Sd-card is running some operation)
>>>>
>>>> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
>>>> Signed-off-by: Kyungmin Park <Kyungmin.park@samsung.com>
>>>> ---
>>>>   drivers/mmc/core/core.c |   31 ++++++++++++++++++++-----------
>>>>   1 files changed, 20 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>>>> index 8b3a122..bc1d627 100644
>>>> --- a/drivers/mmc/core/core.c
>>>> +++ b/drivers/mmc/core/core.c
>>>> @@ -515,17 +515,26 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
>>>>           mmc_pre_req(host, areq->mrq, !host->areq);
>>>>         if (host->areq) {
>>>> -            err = mmc_wait_for_data_req_done(host, host->areq->mrq,
>>>> -                    areq);
>>>> -            if (err == MMC_BLK_NEW_REQUEST) {
>>>> -                if (error)
>>>> -                    *error = err;
>>>> -                /*
>>>> -                 * The previous request was not completed,
>>>> -                 * nothing to return
>>>> -                 */
>>>> -                return NULL;
>>>> -            }
>>>> +        err = mmc_wait_for_data_req_done(host, host->areq->mrq,
>>>> +                areq);
>>>> +        if (err == MMC_BLK_NEW_REQUEST) {
>>>> +            if (error)
>>>> +                *error = err;
>>>> +            /*
>>>> +             * The previous request was not completed,
>>>> +             * nothing to return
>>>> +             */
>>>> +            return NULL;
>>>> +        } else if (err == MMC_BLK_NOMEDIUM && areq) {
>>>> +            struct mmc_context_info *ctnx = &host->context_info;
>>>> +            /*
>>>> +             * If crad is removed,
>>>> +             * then we didn't wait for data completed.
>>>> +             * Assume that data-recieve done.
>>>> +             */
>>>> +            ctnx->is_done_rcv = true;
>>>> +            wake_up_interruptible(&ctnx->wait);
>>>
>>> Can you please explain more on what exactly we are trying to do here (may be you can list down the
>> call flow)? I am not sure if i understood this correctly. But why would you need to wakeup the thread
>> here? We are here because thread is already woken up. mmc_wait_for_data_req_done() would return only
>> if either the new request is received or the currently running request on controller is completed.
>> This problem is produced when card is removed and running some operation.
>> If card is removed, mmc_wait_for_data_req_done() is returned error, right?
>> But if there was async request and running async operation, then maybe run mmc_start_request() with
>> areq.
>> controller is waiting "_for_req_data_done_" for areq.
>>
>> If request is host->areq.process is running at this time.
>> But if request is areq(prepared request), then mmc_wait_for_data_req_done should be pending.
>> and system is dead-lock.
> I also found this problem with sdcard.
> I think it can be solved easily. Did you see the following patch?
> [PATCH 1/2] mmc: core: fix permanent sleep of mmcqd during card removal
> We may just get the hint from __mmc_start_req function.
> 
> Thanks,
> Seungwon Jeon
>>
>> Best Regards,
>> Jaehoon Chung
>>
>>>
>>> Regards,
>>> Subhash
>>>
>>>> +        }
>>>>           /*
>>>>            * Check BKOPS urgency for each R1 response
>>>>            */
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 8b3a122..bc1d627 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -515,17 +515,26 @@  struct mmc_async_req *mmc_start_req(struct mmc_host *host,
 		mmc_pre_req(host, areq->mrq, !host->areq);
 
 	if (host->areq) {
-			err = mmc_wait_for_data_req_done(host, host->areq->mrq,
-					areq);
-			if (err == MMC_BLK_NEW_REQUEST) {
-				if (error)
-					*error = err;
-				/*
-				 * The previous request was not completed,
-				 * nothing to return
-				 */
-				return NULL;
-			}
+		err = mmc_wait_for_data_req_done(host, host->areq->mrq,
+				areq);
+		if (err == MMC_BLK_NEW_REQUEST) {
+			if (error)
+				*error = err;
+			/*
+			 * The previous request was not completed,
+			 * nothing to return
+			 */
+			return NULL;
+		} else if (err == MMC_BLK_NOMEDIUM && areq) {
+			struct mmc_context_info *ctnx = &host->context_info;
+			/*
+			 * If crad is removed,
+			 * then we didn't wait for data completed.
+			 * Assume that data-recieve done.
+			 */
+			ctnx->is_done_rcv = true;
+			wake_up_interruptible(&ctnx->wait);
+		}
 		/*
 		 * Check BKOPS urgency for each R1 response
 		 */