All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/5] mmc: Add access to RPMB partition
@ 2012-07-06  8:43 Loic Pallardy
  2012-07-06  8:44 ` [PATCH v1 1/5] mmc: core: Expose " Loic Pallardy
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Loic Pallardy @ 2012-07-06  8:43 UTC (permalink / raw)
  To: linux-mmc, Chris Ball
  Cc: Linus Walleij, STEricsson_nomadik_linux, Ulf Hansson, Loic Pallardy

The goal of this patchserie is to offer access to MMC RPMB 
(Replay Protected Memory Block) partition.
The RPMB partition is used in general to store some secure data.
It is accessible through a trusted mechanism described in 
JEDEC standard JESD84-A441.

This patchserie proposes following modifications:
- detect RPMB capability and create RPMB block device if supported
- extend MMC sysfs to provide access to RPMB partition size and 
  reliable write sector count (information needed by user space to 
  acces RPMB partition)
- update IOCTL to support RPMB access. This includes automatic partition
  switch and sending of Set Block Count (CMD23) message.

RPMB partition becomes accessible using standard IOCTL interface.
Patches don't include trusted mechanism or any verification. 
It is user space or secure application responsability to provide the right 
command and the entire data frame as defined by JEDEC standard.

Loic Pallardy (5):
  mmc: core: Add mmc_set_blockcount feature
  mmc: core: Expose access to RPMB partition
  mmc: card: Do not scan RPMB partitions
  mmc: core: Extend sysfs to ext_csd parameters for RPMB support
  mmc: card: Add RPMB support in IOCTL interface

 Documentation/mmc/mmc-dev-attrs.txt |  7 ++++
 drivers/mmc/card/block.c            | 67 +++++++++++++++++++++++++++++++++++++
 drivers/mmc/core/core.c             | 14 ++++++++
 drivers/mmc/core/mmc.c              | 15 +++++++++
 include/linux/mmc/card.h            |  2 ++
 include/linux/mmc/core.h            |  2 ++
 include/linux/mmc/mmc.h             |  2 ++
 7 files changed, 109 insertions(+)

-- 
1.7.11.1


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

* [PATCH v1 1/5] mmc: core: Expose access to RPMB partition
  2012-07-06  8:43 [PATCH v1 0/5] mmc: Add access to RPMB partition Loic Pallardy
@ 2012-07-06  8:44 ` Loic Pallardy
  2012-07-08 19:17   ` Linus Walleij
  2012-07-06  8:44 ` [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions Loic Pallardy
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: Loic Pallardy @ 2012-07-06  8:44 UTC (permalink / raw)
  To: linux-mmc, Chris Ball
  Cc: Linus Walleij, STEricsson_nomadik_linux, Ulf Hansson,
	Loic Pallardy, Alex Macro

Following JEDEC standard, if the mmc support RPMB partition,
a new interface is created and exposed via /dev/block.
Users will be able to access RPMB partition using standard
mmc IOCTL command.

Signed-off-by: Alex Macro <alex.macro@stericsson.com>
Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
---
 drivers/mmc/core/mmc.c   | 11 +++++++++++
 include/linux/mmc/card.h |  2 ++
 include/linux/mmc/mmc.h  |  2 ++
 3 files changed, 15 insertions(+)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 258b203..8a459cb 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -480,6 +480,17 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
 
 		card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM];
 		card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION];
+
+		/*
+		 * RPMB regions are defined in multiples of 128K.
+		 */
+		card->ext_csd.raw_rpmb_size_mult = ext_csd[EXT_CSD_RPMB_MULT];
+		if (ext_csd[EXT_CSD_RPMB_MULT]) {
+			mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17,
+				EXT_CSD_PART_CONFIG_ACC_RPMB,
+				"rpmb", 0, false,
+				MMC_BLK_DATA_AREA_RPMB);
+		}
 	}
 
 	card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT];
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index d76513b..46a5502 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -81,6 +81,7 @@ struct mmc_ext_csd {
 	unsigned int		boot_ro_lock;		/* ro lock support */
 	bool			boot_ro_lockable;
 	u8			raw_partition_support;	/* 160 */
+	u8			raw_rpmb_size_mult;	/* 168 */
 	u8			raw_erased_mem_count;	/* 181 */
 	u8			raw_ext_csd_structure;	/* 194 */
 	u8			raw_card_type;		/* 196 */
@@ -200,6 +201,7 @@ struct mmc_part {
 #define MMC_BLK_DATA_AREA_MAIN	(1<<0)
 #define MMC_BLK_DATA_AREA_BOOT	(1<<1)
 #define MMC_BLK_DATA_AREA_GP	(1<<2)
+#define MMC_BLK_DATA_AREA_RPMB	(1<<3)
 };
 
 /*
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index d425cab..e73136a 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -282,6 +282,7 @@ struct _mmc_csd {
 #define EXT_CSD_RST_N_FUNCTION		162	/* R/W */
 #define EXT_CSD_SANITIZE_START		165     /* W */
 #define EXT_CSD_WR_REL_PARAM		166	/* RO */
+#define EXT_CSD_RPMB_MULT		168	/* RO */
 #define EXT_CSD_BOOT_WP			173	/* R/W */
 #define EXT_CSD_ERASE_GROUP_DEF		175	/* R/W */
 #define EXT_CSD_PART_CONFIG		179	/* R/W */
@@ -333,6 +334,7 @@ struct _mmc_csd {
 
 #define EXT_CSD_PART_CONFIG_ACC_MASK	(0x7)
 #define EXT_CSD_PART_CONFIG_ACC_BOOT0	(0x1)
+#define EXT_CSD_PART_CONFIG_ACC_RPMB	(0x3)
 #define EXT_CSD_PART_CONFIG_ACC_GP0	(0x4)
 
 #define EXT_CSD_PART_SUPPORT_PART_EN	(0x1)
-- 
1.7.11.1


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

* [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions
  2012-07-06  8:43 [PATCH v1 0/5] mmc: Add access to RPMB partition Loic Pallardy
  2012-07-06  8:44 ` [PATCH v1 1/5] mmc: core: Expose " Loic Pallardy
@ 2012-07-06  8:44 ` Loic Pallardy
  2012-07-08 19:18   ` Linus Walleij
  2012-07-11  0:35   ` Namjae Jeon
  2012-07-06  8:44 ` [PATCH v1 3/5] mmc: core: Extend sysfs to ext_csd parameters for RPMB support Loic Pallardy
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 20+ messages in thread
From: Loic Pallardy @ 2012-07-06  8:44 UTC (permalink / raw)
  To: linux-mmc, Chris Ball
  Cc: Linus Walleij, STEricsson_nomadik_linux, Ulf Hansson,
	Loic Pallardy, Johan Rudholm

Do not scan rpmb partitions for "soft" partitions, since the rpmb
partition contains protected data. Silences the following
message during boot:

 mmcblkXRPMB: unknown partition table

Signed-off-by: Johan Rudholm <johan.rudholm@stericsson.com>
---
 drivers/mmc/card/block.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 276d21c..1b202fe 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1521,6 +1521,9 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
 	md->disk->queue = md->queue.queue;
 	md->disk->driverfs_dev = parent;
 	set_disk_ro(md->disk, md->read_only || default_ro);
+	md->disk->flags = GENHD_FL_EXT_DEVT;
+	if (area_type & MMC_BLK_DATA_AREA_RPMB)
+		md->disk->flags |= GENHD_FL_NO_PART_SCAN;
 
 	/*
 	 * As discussed on lkml, GENHD_FL_REMOVABLE should:
-- 
1.7.11.1


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

* [PATCH v1 3/5] mmc: core: Extend sysfs to ext_csd parameters for RPMB support
  2012-07-06  8:43 [PATCH v1 0/5] mmc: Add access to RPMB partition Loic Pallardy
  2012-07-06  8:44 ` [PATCH v1 1/5] mmc: core: Expose " Loic Pallardy
  2012-07-06  8:44 ` [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions Loic Pallardy
@ 2012-07-06  8:44 ` Loic Pallardy
  2012-07-08 19:19   ` Linus Walleij
  2012-07-06  8:44 ` [PATCH v1 4/5] mmc: core: Add mmc_set_blockcount feature Loic Pallardy
  2012-07-06  8:44 ` [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface Loic Pallardy
  4 siblings, 1 reply; 20+ messages in thread
From: Loic Pallardy @ 2012-07-06  8:44 UTC (permalink / raw)
  To: linux-mmc, Chris Ball
  Cc: Linus Walleij, STEricsson_nomadik_linux, Ulf Hansson, Loic Pallardy

Extend current sysfs access to ext_csd rpmb
parameters (RPMB partition size) and rel_sector
information.

Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
---
 Documentation/mmc/mmc-dev-attrs.txt | 7 +++++++
 drivers/mmc/core/mmc.c              | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/Documentation/mmc/mmc-dev-attrs.txt b/Documentation/mmc/mmc-dev-attrs.txt
index 22ae844..0d98fac 100644
--- a/Documentation/mmc/mmc-dev-attrs.txt
+++ b/Documentation/mmc/mmc-dev-attrs.txt
@@ -25,6 +25,8 @@ All attributes are read-only.
 	serial			Product Serial Number (from CID Register)
 	erase_size		Erase group size
 	preferred_erase_size	Preferred erase size
+	raw_rpmb_size_mult	RPMB partition size
+	rel_sectors		Reliable write sector count
 
 Note on Erase Size and Preferred Erase Size:
 
@@ -65,6 +67,11 @@ Note on Erase Size and Preferred Erase Size:
 
 	"preferred_erase_size" is in bytes.
 
+Note on raw_rpmb_size_mult:
+	"raw_rpmb_size_mult" is a mutliple of 128kB block.
+	RPMB size in byte is calculated by using the following equation:
+	RPMB partition size = 128kB x raw_rpmb_size_mult
+
 SD/MMC/SDIO Clock Gating Attribute
 ==================================
 
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 8a459cb..0f2449c 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -615,6 +615,8 @@ MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
 MMC_DEV_ATTR(enhanced_area_offset, "%llu\n",
 		card->ext_csd.enhanced_area_offset);
 MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
+MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult);
+MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors);
 
 static struct attribute *mmc_std_attrs[] = {
 	&dev_attr_cid.attr,
@@ -630,6 +632,8 @@ static struct attribute *mmc_std_attrs[] = {
 	&dev_attr_serial.attr,
 	&dev_attr_enhanced_area_offset.attr,
 	&dev_attr_enhanced_area_size.attr,
+	&dev_attr_raw_rpmb_size_mult.attr,
+	&dev_attr_rel_sectors.attr,
 	NULL,
 };
 
-- 
1.7.11.1


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

* [PATCH v1 4/5] mmc: core: Add mmc_set_blockcount feature
  2012-07-06  8:43 [PATCH v1 0/5] mmc: Add access to RPMB partition Loic Pallardy
                   ` (2 preceding siblings ...)
  2012-07-06  8:44 ` [PATCH v1 3/5] mmc: core: Extend sysfs to ext_csd parameters for RPMB support Loic Pallardy
@ 2012-07-06  8:44 ` Loic Pallardy
  2012-07-08 19:20   ` Linus Walleij
  2012-07-06  8:44 ` [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface Loic Pallardy
  4 siblings, 1 reply; 20+ messages in thread
From: Loic Pallardy @ 2012-07-06  8:44 UTC (permalink / raw)
  To: linux-mmc, Chris Ball
  Cc: Linus Walleij, STEricsson_nomadik_linux, Ulf Hansson,
	Loic Pallardy, Alex Macro

Provide support for automatically sending Set Block Count
(CMD23) messages. Used at least for RPMB support.

Signed-off-by: Alex Macro <alex.macro@stericsson.com>
Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
---
 drivers/mmc/core/core.c  | 14 ++++++++++++++
 include/linux/mmc/core.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 0b6141d..7990e2c 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1827,6 +1827,20 @@ int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen)
 }
 EXPORT_SYMBOL(mmc_set_blocklen);
 
+int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount,
+			bool is_rel_write)
+{
+	struct mmc_command cmd = {0};
+
+	cmd.opcode = MMC_SET_BLOCK_COUNT;
+	cmd.arg = blockcount & 0x0000FFFF;
+	if (is_rel_write)
+		cmd.arg |= 1 << 31;
+	cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
+	return mmc_wait_for_cmd(card->host, &cmd, 5);
+}
+EXPORT_SYMBOL(mmc_set_blockcount);
+
 static void mmc_hw_reset_for_init(struct mmc_host *host)
 {
 	if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index 1b431c7..098b7dd 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -166,6 +166,8 @@ extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
 extern unsigned int mmc_calc_max_discard(struct mmc_card *card);
 
 extern int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen);
+extern int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount,
+			      bool is_rel_write);
 extern int mmc_hw_reset(struct mmc_host *host);
 extern int mmc_hw_reset_check(struct mmc_host *host);
 extern int mmc_can_reset(struct mmc_card *card);
-- 
1.7.11.1


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

* [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface
  2012-07-06  8:43 [PATCH v1 0/5] mmc: Add access to RPMB partition Loic Pallardy
                   ` (3 preceding siblings ...)
  2012-07-06  8:44 ` [PATCH v1 4/5] mmc: core: Add mmc_set_blockcount feature Loic Pallardy
@ 2012-07-06  8:44 ` Loic Pallardy
  2012-07-08 19:22   ` Linus Walleij
  2012-07-10  0:37   ` Namjae Jeon
  4 siblings, 2 replies; 20+ messages in thread
From: Loic Pallardy @ 2012-07-06  8:44 UTC (permalink / raw)
  To: linux-mmc, Chris Ball
  Cc: Linus Walleij, STEricsson_nomadik_linux, Ulf Hansson,
	Loic Pallardy, Alex Macro

RPMB partition is accessing though /dev/block/mmcXrpmb device
User callers can read and write entire data frame(s) as defined
by JEDEC Standard JESD84-A441, using standard IOCTL interface.

Signed-off-by: Alex Macro <alex.macro@stericsson.com>
Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
---
 drivers/mmc/card/block.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1b202fe..a9956cf 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -126,6 +126,10 @@ enum mmc_blk_status {
 module_param(perdev_minors, int, 0444);
 MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device");
 
+static inline int mmc_blk_part_switch(struct mmc_card *card,
+				      struct mmc_blk_data *md);
+static int get_card_status(struct mmc_card *card, u32 *status, int retries);
+
 static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
 {
 	struct mmc_blk_data *md;
@@ -357,6 +361,38 @@ out:
 	return ERR_PTR(err);
 }
 
+static int ioctl_rpmb_card_status_poll(struct mmc_card *card, u32 *status,
+				       u32 retries_max)
+{
+	int err;
+	u32 retry_count = 0;
+
+	if (!status || !retries_max)
+		return -EINVAL;
+
+	do {
+		err = get_card_status(card, status, 5);
+		if (err)
+			break;
+
+		if (!R1_STATUS(*status) &&
+				(R1_CURRENT_STATE(*status) != R1_STATE_PRG))
+			break; /* RPMB programming operation complete */
+
+		/*
+		 * Rechedule to give the MMC device a chance to continue
+		 * processing the previous command without being polled too
+		 * frequently.
+		 */
+		usleep_range(1000, 5000);
+	} while (++retry_count < retries_max);
+
+	if (retry_count == retries_max)
+		err = -EPERM;
+
+	return err;
+}
+
 static int mmc_blk_ioctl_cmd(struct block_device *bdev,
 	struct mmc_ioc_cmd __user *ic_ptr)
 {
@@ -368,6 +404,8 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
 	struct mmc_request mrq = {NULL};
 	struct scatterlist sg;
 	int err;
+	int is_rpmb = false;
+	u32 status = 0;
 
 	/*
 	 * The caller must have CAP_SYS_RAWIO, and must be calling this on the
@@ -387,6 +425,9 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
 		goto cmd_err;
 	}
 
+	if (md->area_type & MMC_BLK_DATA_AREA_RPMB)
+		is_rpmb = true;
+
 	card = md->queue.card;
 	if (IS_ERR(card)) {
 		err = PTR_ERR(card);
@@ -437,12 +478,23 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
 
 	mmc_claim_host(card->host);
 
+	err = mmc_blk_part_switch(card, md);
+	if (err)
+		goto cmd_rel_host;
+
 	if (idata->ic.is_acmd) {
 		err = mmc_app_cmd(card->host, card);
 		if (err)
 			goto cmd_rel_host;
 	}
 
+	if (is_rpmb) {
+		err = mmc_set_blockcount(card, data.blocks,
+			idata->ic.write_flag & (1 << 31));
+		if (err)
+			goto cmd_rel_host;
+	}
+
 	mmc_wait_for_req(card->host, &mrq);
 
 	if (cmd.error) {
@@ -478,6 +530,18 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
 		}
 	}
 
+	if (is_rpmb) {
+		/*
+		 * Ensure RPMB command has completed by polling CMD13
+		 * "Send Status".
+		 */
+		err = ioctl_rpmb_card_status_poll(card, &status, 5);
+		if (err)
+			dev_err(mmc_dev(card->host),
+					"%s: Card Status=0x%08X, error %d\n",
+					__func__, status, err);
+	}
+
 cmd_rel_host:
 	mmc_release_host(card->host);
 
-- 
1.7.11.1


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

* Re: [PATCH v1 1/5] mmc: core: Expose access to RPMB partition
  2012-07-06  8:44 ` [PATCH v1 1/5] mmc: core: Expose " Loic Pallardy
@ 2012-07-08 19:17   ` Linus Walleij
  2012-07-09 17:42     ` Johan Rudholm
  0 siblings, 1 reply; 20+ messages in thread
From: Linus Walleij @ 2012-07-08 19:17 UTC (permalink / raw)
  To: Loic Pallardy
  Cc: linux-mmc, Chris Ball, STEricsson_nomadik_linux, Ulf Hansson, Alex Macro

On Fri, Jul 6, 2012 at 10:44 AM, Loic Pallardy
<loic.pallardy@stericsson.com> wrote:

> Following JEDEC standard, if the mmc support RPMB partition,
> a new interface is created and exposed via /dev/block.
> Users will be able to access RPMB partition using standard
> mmc IOCTL command.
>
> Signed-off-by: Alex Macro <alex.macro@stericsson.com>
> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions
  2012-07-06  8:44 ` [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions Loic Pallardy
@ 2012-07-08 19:18   ` Linus Walleij
  2012-07-11  0:35   ` Namjae Jeon
  1 sibling, 0 replies; 20+ messages in thread
From: Linus Walleij @ 2012-07-08 19:18 UTC (permalink / raw)
  To: Loic Pallardy
  Cc: linux-mmc, Chris Ball, STEricsson_nomadik_linux, Ulf Hansson,
	Johan Rudholm

On Fri, Jul 6, 2012 at 10:44 AM, Loic Pallardy
<loic.pallardy@stericsson.com> wrote:

> Do not scan rpmb partitions for "soft" partitions, since the rpmb
> partition contains protected data. Silences the following
> message during boot:
>
>  mmcblkXRPMB: unknown partition table
>
> Signed-off-by: Johan Rudholm <johan.rudholm@stericsson.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v1 3/5] mmc: core: Extend sysfs to ext_csd parameters for RPMB support
  2012-07-06  8:44 ` [PATCH v1 3/5] mmc: core: Extend sysfs to ext_csd parameters for RPMB support Loic Pallardy
@ 2012-07-08 19:19   ` Linus Walleij
  2012-07-09 17:45     ` Johan Rudholm
  0 siblings, 1 reply; 20+ messages in thread
From: Linus Walleij @ 2012-07-08 19:19 UTC (permalink / raw)
  To: Loic Pallardy
  Cc: linux-mmc, Chris Ball, STEricsson_nomadik_linux, Ulf Hansson

On Fri, Jul 6, 2012 at 10:44 AM, Loic Pallardy
<loic.pallardy@stericsson.com> wrote:

> Extend current sysfs access to ext_csd rpmb
> parameters (RPMB partition size) and rel_sector
> information.
>
> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v1 4/5] mmc: core: Add mmc_set_blockcount feature
  2012-07-06  8:44 ` [PATCH v1 4/5] mmc: core: Add mmc_set_blockcount feature Loic Pallardy
@ 2012-07-08 19:20   ` Linus Walleij
  2012-07-09 17:48     ` Johan Rudholm
  0 siblings, 1 reply; 20+ messages in thread
From: Linus Walleij @ 2012-07-08 19:20 UTC (permalink / raw)
  To: Loic Pallardy
  Cc: linux-mmc, Chris Ball, STEricsson_nomadik_linux, Ulf Hansson, Alex Macro

On Fri, Jul 6, 2012 at 10:44 AM, Loic Pallardy
<loic.pallardy@stericsson.com> wrote:

> Provide support for automatically sending Set Block Count
> (CMD23) messages. Used at least for RPMB support.
>
> Signed-off-by: Alex Macro <alex.macro@stericsson.com>
> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface
  2012-07-06  8:44 ` [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface Loic Pallardy
@ 2012-07-08 19:22   ` Linus Walleij
  2012-07-09 17:54     ` Johan Rudholm
  2012-07-10  0:37   ` Namjae Jeon
  1 sibling, 1 reply; 20+ messages in thread
From: Linus Walleij @ 2012-07-08 19:22 UTC (permalink / raw)
  To: Loic Pallardy
  Cc: linux-mmc, Chris Ball, STEricsson_nomadik_linux, Ulf Hansson, Alex Macro

On Fri, Jul 6, 2012 at 10:44 AM, Loic Pallardy
<loic.pallardy@stericsson.com> wrote:

> RPMB partition is accessing though /dev/block/mmcXrpmb device
> User callers can read and write entire data frame(s) as defined
> by JEDEC Standard JESD84-A441, using standard IOCTL interface.
>
> Signed-off-by: Alex Macro <alex.macro@stericsson.com>
> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v1 1/5] mmc: core: Expose access to RPMB partition
  2012-07-08 19:17   ` Linus Walleij
@ 2012-07-09 17:42     ` Johan Rudholm
  0 siblings, 0 replies; 20+ messages in thread
From: Johan Rudholm @ 2012-07-09 17:42 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Loic Pallardy, linux-mmc, Chris Ball, STEricsson_nomadik_linux,
	Ulf Hansson, Alex Macro

2012/7/8 Linus Walleij <linus.walleij@linaro.org>:
> On Fri, Jul 6, 2012 at 10:44 AM, Loic Pallardy
> <loic.pallardy@stericsson.com> wrote:
>
>> Following JEDEC standard, if the mmc support RPMB partition,
>> a new interface is created and exposed via /dev/block.
>> Users will be able to access RPMB partition using standard
>> mmc IOCTL command.
>>
>> Signed-off-by: Alex Macro <alex.macro@stericsson.com>
>> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

Acked-by: Johan Rudholm <johan.rudholm@stericsson.com>

//Johan

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

* Re: [PATCH v1 3/5] mmc: core: Extend sysfs to ext_csd parameters for RPMB support
  2012-07-08 19:19   ` Linus Walleij
@ 2012-07-09 17:45     ` Johan Rudholm
  0 siblings, 0 replies; 20+ messages in thread
From: Johan Rudholm @ 2012-07-09 17:45 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Loic Pallardy, linux-mmc, Chris Ball, STEricsson_nomadik_linux,
	Ulf Hansson

2012/7/8 Linus Walleij <linus.walleij@linaro.org>:
> On Fri, Jul 6, 2012 at 10:44 AM, Loic Pallardy
> <loic.pallardy@stericsson.com> wrote:
>
>> Extend current sysfs access to ext_csd rpmb
>> parameters (RPMB partition size) and rel_sector
>> information.
>>
>> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

Acked-by: Johan Rudholm <johan.rudholm@stericsson.com>

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

* Re: [PATCH v1 4/5] mmc: core: Add mmc_set_blockcount feature
  2012-07-08 19:20   ` Linus Walleij
@ 2012-07-09 17:48     ` Johan Rudholm
  0 siblings, 0 replies; 20+ messages in thread
From: Johan Rudholm @ 2012-07-09 17:48 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Loic Pallardy, linux-mmc, Chris Ball, STEricsson_nomadik_linux,
	Ulf Hansson, Alex Macro

2012/7/8 Linus Walleij <linus.walleij@linaro.org>:
> On Fri, Jul 6, 2012 at 10:44 AM, Loic Pallardy
> <loic.pallardy@stericsson.com> wrote:
>
>> Provide support for automatically sending Set Block Count
>> (CMD23) messages. Used at least for RPMB support.
>>
>> Signed-off-by: Alex Macro <alex.macro@stericsson.com>
>> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

Acked-by: Johan Rudholm <johan.rudholm@stericsson.com>

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

* Re: [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface
  2012-07-08 19:22   ` Linus Walleij
@ 2012-07-09 17:54     ` Johan Rudholm
  0 siblings, 0 replies; 20+ messages in thread
From: Johan Rudholm @ 2012-07-09 17:54 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Loic Pallardy, linux-mmc, Chris Ball, STEricsson_nomadik_linux,
	Ulf Hansson, Alex Macro

2012/7/8 Linus Walleij <linus.walleij@linaro.org>:
> On Fri, Jul 6, 2012 at 10:44 AM, Loic Pallardy
> <loic.pallardy@stericsson.com> wrote:
>
>> RPMB partition is accessing though /dev/block/mmcXrpmb device
>> User callers can read and write entire data frame(s) as defined
>> by JEDEC Standard JESD84-A441, using standard IOCTL interface.
>>
>> Signed-off-by: Alex Macro <alex.macro@stericsson.com>
>> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

Acked-by: Johan Rudholm <johan.rudholm@stericsson.com>

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

* Re: [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface
  2012-07-06  8:44 ` [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface Loic Pallardy
  2012-07-08 19:22   ` Linus Walleij
@ 2012-07-10  0:37   ` Namjae Jeon
  2012-07-10 12:28     ` Loic pallardy
  1 sibling, 1 reply; 20+ messages in thread
From: Namjae Jeon @ 2012-07-10  0:37 UTC (permalink / raw)
  To: Loic Pallardy
  Cc: linux-mmc, Chris Ball, Linus Walleij, STEricsson_nomadik_linux,
	Ulf Hansson, Alex Macro

>
> +	err = mmc_blk_part_switch(card, md);
> +	if (err)
> +		goto cmd_rel_host;
> +
Should it wrapped by if (is_rpbm) condition ? It can be called in other ioctl.

>  	if (idata->ic.is_acmd) {
>  		err = mmc_app_cmd(card->host, card);
>  		if (err)
>  			goto cmd_rel_host;
>  	}

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

* Re: [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface
  2012-07-10  0:37   ` Namjae Jeon
@ 2012-07-10 12:28     ` Loic pallardy
  2012-07-11  0:12       ` Namjae Jeon
  0 siblings, 1 reply; 20+ messages in thread
From: Loic pallardy @ 2012-07-10 12:28 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: Loic Pallardy, linux-mmc, Chris Ball, Linus Walleij,
	STEricsson_nomadik_linux, Ulf Hansson, Alex Macro

Repost in text format

2012/7/10 Namjae Jeon <linkinjeon@gmail.com>
>
> >
> > +     err = mmc_blk_part_switch(card, md);
> > +     if (err)
> > +             goto cmd_rel_host;
> > +
> Should it wrapped by if (is_rpbm) condition ? It can be called in other
> ioctl.
It was my first implementation, but in that case you have to manage a
session, switching on RPMB partition at the begining of the IOCTL and
restore previous partition at the end. (because RPMB partition doesn't
support all commands).

Having a look to how mmc driver manages partition selection, I saw
that mmc_blk_issue_rq for instance calls mmc_blk_part_switch in the
beginning to be sure it's on the right partition, but never restores

The proposal is to use same way and to make it compliant with Boot and
GP partitions if there are any special commands supported by them.
>
> >       if (idata->ic.is_acmd) {
> >               err = mmc_app_cmd(card->host, card);
> >               if (err)
> >                       goto cmd_rel_host;
> >       }
> --
> 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

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

* Re: [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface
  2012-07-10 12:28     ` Loic pallardy
@ 2012-07-11  0:12       ` Namjae Jeon
  0 siblings, 0 replies; 20+ messages in thread
From: Namjae Jeon @ 2012-07-11  0:12 UTC (permalink / raw)
  To: Loic pallardy
  Cc: Loic Pallardy, linux-mmc, Chris Ball, Linus Walleij,
	STEricsson_nomadik_linux, Ulf Hansson, Alex Macro

2012/7/10, Loic pallardy <loic.pallardy@gmail.com>:
> Repost in text format
>
> 2012/7/10 Namjae Jeon <linkinjeon@gmail.com>
>>
>> >
>> > +     err = mmc_blk_part_switch(card, md);
>> > +     if (err)
>> > +             goto cmd_rel_host;
>> > +
>> Should it wrapped by if (is_rpbm) condition ? It can be called in other
>> ioctl.
> It was my first implementation, but in that case you have to manage a
> session, switching on RPMB partition at the begining of the IOCTL and
> restore previous partition at the end. (because RPMB partition doesn't
> support all commands).
>
> Having a look to how mmc driver manages partition selection, I saw
> that mmc_blk_issue_rq for instance calls mmc_blk_part_switch in the
> beginning to be sure it's on the right partition, but never restores
>
> The proposal is to use same way and to make it compliant with Boot and
> GP partitions if there are any special commands supported by them.
Okay, I understood what you mean.
we should change partition switching in other ioctl again after ioctl
about rpmb is called.

Reviewed-by: Namjae Jeon <linkinjeon@gmail.com>
>>
>> >       if (idata->ic.is_acmd) {
>> >               err = mmc_app_cmd(card->host, card);
>> >               if (err)
>> >                       goto cmd_rel_host;
>> >       }
>> --
>> 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
>

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

* Re: [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions
  2012-07-06  8:44 ` [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions Loic Pallardy
  2012-07-08 19:18   ` Linus Walleij
@ 2012-07-11  0:35   ` Namjae Jeon
  2012-07-11 12:36     ` Loic pallardy
  1 sibling, 1 reply; 20+ messages in thread
From: Namjae Jeon @ 2012-07-11  0:35 UTC (permalink / raw)
  To: Loic Pallardy
  Cc: linux-mmc, Chris Ball, Linus Walleij, STEricsson_nomadik_linux,
	Ulf Hansson, Johan Rudholm

>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 276d21c..1b202fe 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1521,6 +1521,9 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct
> mmc_card *card,
>  	md->disk->queue = md->queue.queue;
>  	md->disk->driverfs_dev = parent;
>  	set_disk_ro(md->disk, md->read_only || default_ro);
> +	md->disk->flags = GENHD_FL_EXT_DEVT;
Currrenlty mmc have been setting minors to CONFIG_MMC_BLOCK_MINORS.
Why did you add GENHD_FL_EXT_DEVT ?

Thanks.

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

* Re: [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions
  2012-07-11  0:35   ` Namjae Jeon
@ 2012-07-11 12:36     ` Loic pallardy
  0 siblings, 0 replies; 20+ messages in thread
From: Loic pallardy @ 2012-07-11 12:36 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: Loic Pallardy, linux-mmc, Chris Ball, Linus Walleij,
	STEricsson_nomadik_linux, Ulf Hansson, Johan Rudholm

>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index 276d21c..1b202fe 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -1521,6 +1521,9 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct
>> mmc_card *card,
>>       md->disk->queue = md->queue.queue;
>>       md->disk->driverfs_dev = parent;
>>       set_disk_ro(md->disk, md->read_only || default_ro);
>> +     md->disk->flags = GENHD_FL_EXT_DEVT;
> Currrenlty mmc have been setting minors to CONFIG_MMC_BLOCK_MINORS.
> Why did you add GENHD_FL_EXT_DEVT ?
>
> Thanks.
Yes, my mistake, indeed not related to this patch.
Thanks.

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

end of thread, other threads:[~2012-07-11 12:36 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-06  8:43 [PATCH v1 0/5] mmc: Add access to RPMB partition Loic Pallardy
2012-07-06  8:44 ` [PATCH v1 1/5] mmc: core: Expose " Loic Pallardy
2012-07-08 19:17   ` Linus Walleij
2012-07-09 17:42     ` Johan Rudholm
2012-07-06  8:44 ` [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions Loic Pallardy
2012-07-08 19:18   ` Linus Walleij
2012-07-11  0:35   ` Namjae Jeon
2012-07-11 12:36     ` Loic pallardy
2012-07-06  8:44 ` [PATCH v1 3/5] mmc: core: Extend sysfs to ext_csd parameters for RPMB support Loic Pallardy
2012-07-08 19:19   ` Linus Walleij
2012-07-09 17:45     ` Johan Rudholm
2012-07-06  8:44 ` [PATCH v1 4/5] mmc: core: Add mmc_set_blockcount feature Loic Pallardy
2012-07-08 19:20   ` Linus Walleij
2012-07-09 17:48     ` Johan Rudholm
2012-07-06  8:44 ` [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface Loic Pallardy
2012-07-08 19:22   ` Linus Walleij
2012-07-09 17:54     ` Johan Rudholm
2012-07-10  0:37   ` Namjae Jeon
2012-07-10 12:28     ` Loic pallardy
2012-07-11  0:12       ` Namjae Jeon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.