mmc: core_sdhci: emmc mutex support for medfield
authorChuanxiao Dong <chuanxiao.dong@intel.com>
Mon, 24 Oct 2011 08:19:19 +0000 (16:19 +0800)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 21:21:06 +0000 (13:21 -0800)
commit307de6cae738d992ff899ae9858845c682ac91a3
tree96767719fd9fd49c50605557b442f416a3671e1e
parenteaa7fddf9db5609f7fd1ff57b91da8470a493359
mmc: core_sdhci: emmc mutex support for medfield

One of the Medfield eMMC controller (PCI device id 0x0823, SDIO3)
is a shared resource used by the SCU and the IA processors.
SCU primarily uses the eMMC host controller to access the eMMC device's
Boot Partition, while the IA CPU uses the eMMC host controller to
access the eMMC device's User Partition.

After the SCU hands off the system to the IA processor, the IA processor
assumes ownership to the eMMC host controller. Due to absence of any
arbitration at the eMMC host controller, this could result in concurrent
eMMC host accesses resulting in bus contention and garbage data ending up
in either of the partitions.

To circumvent this from happening, eMMC host controller locking mechanism
is employed, where at any one given time, only one agent, SCU or IA,
may be allowed to access the host. This is achieved by implementing
Dekker's Algorithm (http://en.wikipedia.org/wiki/Dekker's_algorithm)
between the two processors.

Before handing off the system to the IA processor, SCU must set up three
housekeeping mutex variables allocated in the shared SRAM as follows:

eMMC_Owner = IA (SCU and IA processors - RW, 32bit)
IA_Req = FALSE (IA -RW, SCU - RO, 32bit)
SCU_Req = FALSE (IA - RO, SCU - R/W, 32bit)

There is no hardware based access control to these variables and so code
executing on SCU and IA processors must follow access rules of
Dekker's algorithm. Detail info about this algorithm can be found in
comments and code of this patch.

Change-Id: I303c18cbab815ce1d71aae8160c3fd595b0a516c
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
Reviewed-on: http://android.intel.com:8080/23130
Reviewed-by: Gross, Mark <mark.gross@intel.com>
Tested-by: Gross, Mark <mark.gross@intel.com>
drivers/mmc/host/sdhci-pci.c
drivers/mmc/host/sdhci.c
include/linux/mmc/sdhci.h