Bugs in MMC [was: [Bug 10030] Suspend doesn't work when SD card is inserted]

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Pierre Ossman <drzeus-mmc@...>, Rafael J. Wysocki <rjw@...>
Cc: pm list <linux-pm@...>, Zdenek Kabelac <zdenek.kabelac@...>, David Brownell <david-b@...>, Kernel development list <linux-kernel@...>
Date: Sunday, February 24, 2008 - 11:33 am

On Sun, 24 Feb 2008, Rafael J. Wysocki wrote:


Well, the patch itself isn't really adequate; it was just a first pass 
intended to illustrate the nature of the problem.

The problems in the MMC subsystem go deeper.

The first is the way it uses flush_workqueue().  This is almost always 
a bad function to call, because it introduces unnecessary dependencies.  
cancel_delayed_work_sync() is much better.

But even changing that won't solve the second issue, which is a genuine
bug.  There is a race between detect events and suspend events.  The
mmc_suspend_host() routine starts out by flushing the kmmcd workqueue
before calling the host's suspend routine.  So what happens if another
detect event occurs in between?

This whole area of synchronization between card insertion, card
removal, suspend, and resume needs to be thought out better.  
Especially keeping in mind that device registration or unregistration
during a system sleep is likely to block until the sleep is over.

Lastly, there are some other questions about confusing aspects of the
subsystem.  What's the story with __mmc_claim_host()?  Is it really
nothing more than an abortable mutex_lock()?  Why does it ever need to
be aborted?  Why is its second argument an atomic_t instead of a normal
int?

Why are mmc_detect() and related routines described in comments as
"Card detection callback from host"?  They don't handle card
_detection_ -- they handle card _removal_.

What's the purpose of the card-counting loop in 
host/omap.c:mmc_omap_switch_handler()?  It looks like dead code.

Alan Stern

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Wed Feb 20, 6:15 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Wed Feb 20, 8:02 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Thu Feb 21, 12:38 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Thu Feb 21, 6:47 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Fri Feb 22, 9:30 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Sat Feb 23, 4:16 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Sat Feb 23, 8:19 pm)
Re: [linux-pm] [Bug 10030] Suspend doesn't work when SD card..., Rafael J. Wysocki, (Sun Feb 24, 10:00 am)
Bugs in MMC [was: [Bug 10030] Suspend doesn't work when SD c..., Alan Stern, (Sun Feb 24, 11:33 am)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Mon Feb 25, 7:40 am)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Sun Feb 24, 6:21 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Mon Feb 25, 7:41 am)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Sun Feb 24, 9:51 am)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Sun Feb 24, 4:09 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Sun Feb 24, 9:33 am)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Sun Feb 24, 4:25 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Sun Feb 24, 4:56 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Sun Feb 24, 6:18 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Wed Feb 20, 6:41 pm)
Re: [Bug 10030] Suspend doesn't work when SD card is inserted, Rafael J. Wysocki, (Wed Feb 20, 4:58 pm)