forked from clearlinux-pkgs/linux-iot-lts2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0017-rpmb-enable-emmc-specific-read-data-fixup.patch
78 lines (72 loc) · 2.27 KB
/
0017-rpmb-enable-emmc-specific-read-data-fixup.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From 67c80ae4077e82a8311573a223bed1f9544a7fb9 Mon Sep 17 00:00:00 2001
From: Tomas Winkler <[email protected]>
Date: Sun, 7 Aug 2016 11:27:08 +0300
Subject: [PATCH 02/22] rpmb: enable emmc specific read data fixup
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
V8: Resend.
V9: Scan all the frames in the sequence.
Change-Id: I34a4aeccbd0294b2c7c83837faa4ba5a54b9be48
Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Alexander Usyskin <[email protected]>
Tested-by: Avri Altman <[email protected]>
---
drivers/char/rpmb/core.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/char/rpmb/core.c b/drivers/char/rpmb/core.c
index 69a590106ae1..3bf3f0db54fb 100644
--- a/drivers/char/rpmb/core.c
+++ b/drivers/char/rpmb/core.c
@@ -36,6 +36,38 @@ void rpmb_dev_put(struct rpmb_dev *rdev)
}
EXPORT_SYMBOL_GPL(rpmb_dev_put);
+/**
+ * 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 (RPMB_TYPE_HW(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++) {
+ struct rpmb_frame_jdec *frame = cmds[i].frames;
+
+ if (frame->req_resp == cpu_to_be16(RPMB_READ_DATA)) {
+ dev_dbg(&rdev->dev, "Fixing up READ_DATA frame to block_count=0\n");
+ frame->block_count = 0;
+ }
+ }
+}
+
/**
* rpmb_cmd_seq - send RPMB command sequence
*
@@ -58,6 +90,7 @@ int rpmb_cmd_seq(struct rpmb_dev *rdev, struct rpmb_cmd *cmds, u32 ncmds)
mutex_lock(&rdev->lock);
err = -EOPNOTSUPP;
if (rdev->ops && rdev->ops->cmd_seq) {
+ rpmb_cmd_fixup(rdev, cmds, ncmds);
err = rdev->ops->cmd_seq(rdev->dev.parent, rdev->target,
cmds, ncmds);
}
--
2.19.1