lkml.org 
[lkml]   [2016]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v7 02/11] rpmb: enable emmc specific read data fixup
Date
For eMMC the block count of the RPMB read operation is not indicated in
the original RPMB Data Read Request packet.
This might be different then the implementation of other protocol
standards.
This patch implements a fixup for this behavior.

V6: new in the series
V7: resend

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/char/rpmb/core.c | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/char/rpmb/core.c b/drivers/char/rpmb/core.c
index ff10cbb7b644..8cfbbb721538 100644
--- a/drivers/char/rpmb/core.c
+++ b/drivers/char/rpmb/core.c
@@ -117,6 +117,35 @@ static int rpmb_request_verify(struct rpmb_dev *rdev, struct rpmb_data *rpmbd)
}

/**
+ * rpmb_cmd_fixup - fixup rpmb command
+ *
+ * @rdev: rpmb device
+ * @cmds: rpmb command list
+ * @ncmds: number of commands
+ *
+ */
+static void rpmb_cmd_fixup(struct rpmb_dev *rdev,
+ struct rpmb_cmd *cmds, u32 ncmds)
+{
+ int i;
+
+ if (rdev->ops->type != RPMB_TYPE_EMMC)
+ return;
+
+ /* Fixup RPMB_READ_DATA specific to eMMC
+ * The block count of the RPMB read operation is not indicated
+ * in the original RPMB Data Read Request packet.
+ * This is different then implementation for other protocol
+ * standards.
+ */
+ for (i = 0; i < ncmds; i++)
+ if (cmds->frames->req_resp == cpu_to_be16(RPMB_READ_DATA)) {
+ dev_dbg(&rdev->dev, "Fixing up READ_DATA frame to block_count=0\n");
+ cmds->frames->block_count = 0;
+ }
+}
+
+/**
* rpmb_cmd_seq - send RPMB command sequence
*
* @rdev: rpmb device
@@ -136,10 +165,11 @@ int rpmb_cmd_seq(struct rpmb_dev *rdev, struct rpmb_cmd *cmds, u32 ncmds)
return -EINVAL;

mutex_lock(&rdev->lock);
- if (rdev->ops && rdev->ops->cmd_seq)
+ err = -EOPNOTSUPP;
+ if (rdev->ops && rdev->ops->cmd_seq) {
+ rpmb_cmd_fixup(rdev, cmds, ncmds);
err = rdev->ops->cmd_seq(rdev->dev.parent, cmds, ncmds);
- else
- err = -EOPNOTSUPP;
+ }
mutex_unlock(&rdev->lock);
return err;
}
--
2.7.4
\
 
 \ /
  Last update: 2016-11-07 20:01    [W:0.078 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site