Skip to contentSkip to conversation

mmc: block: ioctl: define rpmb reliable flag

PATCH Superseded Christian Löhle 3 participants 3 messages Apr 5, 2023 – May 15, 2023 MMC, SD and SDIO

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mmc: block: ioctl: define rpmb reliable flag

Give a proper name to BIT 31 which is used as reliable write for RPMB.

---
 drivers/mmc/core/block.c       | 5 ++++-
 include/uapi/linux/mmc/ioctl.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/mmc/core/block.c +4 -1
index 672ab90c4b2d..16e262ddc954 100644
@@ -49,6 +49,8 @@
 
 #include <linux/uaccess.h>
 
+#include <uapi/linux/mmc/ioctl.h>
+
 #include "queue.h"
 #include "block.h"
 #include "core.h"
@@ -538,7 +540,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
 		 * may be increased by a future standard. We just copy the
 		 * 'Reliable Write' bit here.
 		 */
-		sbc.arg = data.blocks | (idata->ic.write_flag & BIT(31));
+		sbc.arg = data.blocks |
+			(idata->ic.write_flag & MMC_RPMB_RELIABLE_WRITE);
 		sbc.flags = MMC_RSP_R1 | MMC_CMD_AC;
 		mrq.sbc = &sbc;
 	}
include/uapi/linux/mmc/ioctl.h +1 -0
index e7401ade6822..b2ff7f5be87b 100644
@@ -11,6 +11,7 @@ struct mmc_ioc_cmd {
 	 * Bit 31 selects 'Reliable Write' for RPMB.
 	 */
 	int write_flag;
+#define MMC_RPMB_RELIABLE_WRITE (1 << 31)
 
 	/* Application-specific command.  true = precede with CMD55 */
 	int is_acmd;
Signature · 6 lines
2.37.3


Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782
Reviewed-by on v1 1/3
#1 lore raw
Quoted 5 lines

Give a proper name to BIT 31 which is used as reliable write for RPMB.

Thanks (see nit below),
Avri

Quoted 34 lines
---
 drivers/mmc/core/block.c       | 5 ++++-
 include/uapi/linux/mmc/ioctl.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/mmc/core/block.c +4 -1
index 672ab90c4b2d..16e262ddc954 100644
@@ -49,6 +49,8 @@
 
 #include <linux/uaccess.h>
 
+#include <uapi/linux/mmc/ioctl.h>
+
 #include "queue.h"
 #include "block.h"
 #include "core.h"
@@ -538,7 +540,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card
 *card, struct mmc_blk_data *md,
                 * may be increased by a future standard. We just copy the
                 * 'Reliable Write' bit here.
                 */
-               sbc.arg = data.blocks | (idata->ic.write_flag & BIT(31));
+               sbc.arg = data.blocks |
+                       (idata->ic.write_flag & MMC_RPMB_RELIABLE_WRITE);
                sbc.flags = MMC_RSP_R1 | MMC_CMD_AC;
                mrq.sbc = &sbc;
        }
include/uapi/linux/mmc/ioctl.h +0 -0
index e7401ade6822..b2ff7f5be87b 100644

include/uapi/linux/mmc/ioctl.h struct mmc_ioc_cmd { · line 11

Quoted 1 line
include/uapi/linux/mmc/ioctl.h +0 -0
@@ -11,6 +11,7 @@ struct mmc_ioc_cmd {
         * Bit 31 selects 'Reliable Write' for RPMB.

No longer needed.

Thanks,
Avri

Quoted 13 lines
include/uapi/linux/mmc/ioctl.h +1 -1
         */
        int write_flag;
+#define MMC_RPMB_RELIABLE_WRITE (1 << 31)
 
        /* Application-specific command.  true = precede with CMD55 */
        int is_acmd;
--

2.37.3

Hyperstone GmbH | Reichenaustr. 39a | 78467 Konstanz Managing Director: Dr. Jan Peter Berns. Commercial register of local courts: Freiburg HRB381782

#2 lore raw
In reply to Christian Löhle
Quoted 38 lines · Christian Löhle

Give a proper name to BIT 31 which is used as reliable write for RPMB.

---
 drivers/mmc/core/block.c       | 5 ++++-
 include/uapi/linux/mmc/ioctl.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/mmc/core/block.c +4 -1
index 672ab90c4b2d..16e262ddc954 100644
@@ -49,6 +49,8 @@
 
 #include <linux/uaccess.h>
 
+#include <uapi/linux/mmc/ioctl.h>
+
 #include "queue.h"
 #include "block.h"
 #include "core.h"
@@ -538,7 +540,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
                 * may be increased by a future standard. We just copy the
                 * 'Reliable Write' bit here.
                 */
-               sbc.arg = data.blocks | (idata->ic.write_flag & BIT(31));
+               sbc.arg = data.blocks |
+                       (idata->ic.write_flag & MMC_RPMB_RELIABLE_WRITE);
                sbc.flags = MMC_RSP_R1 | MMC_CMD_AC;
                mrq.sbc = &sbc;
        }
include/uapi/linux/mmc/ioctl.h +0 -0
index e7401ade6822..b2ff7f5be87b 100644

include/uapi/linux/mmc/ioctl.h struct mmc_ioc_cmd { · line 14

Quoted 4 lines
include/uapi/linux/mmc/ioctl.h +1 -0
@@ -11,6 +11,7 @@ struct mmc_ioc_cmd {
         * Bit 31 selects 'Reliable Write' for RPMB.
         */
        int write_flag;
+#define MMC_RPMB_RELIABLE_WRITE (1 << 31)

I am not sure this is really worth it. Keeping kernel headers for user space in sync is a bit messy.

The define as such seems reasonable, but isn't it better to have the define at two places then? One that's part of the MMC subsystem in the kernel and another that's specific to the mmc-utils userspace tool?

[...]

Kind regards
Uffe