RPMB eMMC errors under Linux

Newer eMMC flash devices have a small partition (several megabytes) that is used to store OEM security keys (for things like DRM or encrypting private app data under something like Android). Linux implements support for the Replay Protected Memory Block partition in the form of ioctls. It's a pretty raw access layer, most of the implementation on these devices rightfully lives in userland instead of the kernel.

If you have one of these devices in some configurations you will get errors like this.

[   11.361670] mmc0: Got data interrupt 0x00000002 even though no data operation was in progress.
[   11.363818] mmcblk0rpmb: error -110 transferring data, sector 8064, nr 8, cmd response 0x900, card status 0xb00
[   11.363932] mmcblk0rpmb: retrying using single block read
[   11.365980] mmcblk0rpmb: timed out sending r/w cmd command, card status 0x400900
[   11.368122] mmcblk0rpmb: timed out sending r/w cmd command, card status 0x400900
[   11.370246] mmcblk0rpmb: timed out sending r/w cmd command, card status 0x400900
[   11.372380] mmcblk0rpmb: timed out sending r/w cmd command, card status 0x400900
[   11.374503] mmcblk0rpmb: timed out sending r/w cmd command, card status 0x400900
[   11.376637] mmcblk0rpmb: timed out sending r/w cmd command, card status 0x400900
[   11.376723] end_request: I/O error, dev mmcblk0rpmb, sector 8064
[   11.376793] Buffer I/O error on device mmcblk0rpmb, logical block 1008

On the Asus T100 tablet I was testing with, during boot Ubuntu would hang while this happened for 5-10 seconds each time and it would happen 3 or 4 times before the boot would finish. Some disk operations later would try to check that partition and cause the same sort of I/O hangs. I went looking for a udev rule to fix it but it kept happening despite removing the MMC setup rules. To finally fix it, I ended up writing this small kernel patch.

From 0f5081c323c52ac842b01fd79df3b3c251f7aca9 Mon Sep 17 00:00:00 2001
From: Nell Hardcastle <nell@dev-nell.com>
Date: Thu, 29 May 2014 22:06:50 -0700
Subject: [PATCH] eMMC: Don't initialize partitions on RPMB flagged areas.

Prevents a lot of pointless hanging at boot on some devices.
---
 drivers/mmc/card/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 452782b..dd85dcf 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -2255,7 +2255,7 @@ static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md)
       return 0;

    for (idx = 0; idx < card->nr_parts; idx++) {
-       if (card->part[idx].size) {
+       if (card->part[idx].size && !(card->part[idx].area_type & MMC_BLK_DATA_AREA_RPMB)) {
                    ret = mmc_blk_alloc_part(card, md,
                                       card->part[idx].part_cfg,
                                            card->part[idx].size >> 9,
-- 
1.9.1

This isn't suitable for contributing to the kernel, if you actually do need to use the RPMB partition for something you might need the partition setup, but for anyone else having this problem this might be useful. The right way to do this is probably deeper in the initialization so that it doesn't entirely disable the device.

Comments