Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [PATCHv4] mmc: rpmb: fixes pause retune on all RPMB partitions.
@ 2023-12-01 15:31 Jorge Ramirez-Ortiz
  2023-12-07 14:01 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Jorge Ramirez-Ortiz @ 2023-12-01 15:31 UTC (permalink / raw)
  To: jorge, ulf.hansson, linus.walleij, adrian.hunter
  Cc: linux-mmc, linux-kernel, stable

When RPMB was converted to a character device, it added support for
multiple RPMB partitions (Commit 97548575bef3 ("mmc: block: Convert RPMB
to a character device").

One of the changes in this commit was transforming the variable
target_part defined in __mmc_blk_ioctl_cmd into a bitmask.

This inadvertedly regressed the validation check done in
mmc_blk_part_switch_pre() and mmc_blk_part_switch_post().

This commit fixes that regression.

Fixes: 97548575bef3 ("mmc: block: Convert RPMB to a character device")
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: <stable@vger.kernel.org> # v4.14+
---

  v2:
     fixes parenthesis around condition
  v3:
     adds stable to commit header
  v4:
     fixes the stable version to v4.14
     adds Reviewed-by

 drivers/mmc/core/block.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 152dfe593c43..13093d26bf81 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -851,9 +851,10 @@ static const struct block_device_operations mmc_bdops = {
 static int mmc_blk_part_switch_pre(struct mmc_card *card,
 				   unsigned int part_type)
 {
+	const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_RPMB;
 	int ret = 0;

-	if (part_type == EXT_CSD_PART_CONFIG_ACC_RPMB) {
+	if ((part_type & mask) == mask) {
 		if (card->ext_csd.cmdq_en) {
 			ret = mmc_cmdq_disable(card);
 			if (ret)
@@ -868,9 +869,10 @@ static int mmc_blk_part_switch_pre(struct mmc_card *card,
 static int mmc_blk_part_switch_post(struct mmc_card *card,
 				    unsigned int part_type)
 {
+	const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_RPMB;
 	int ret = 0;

-	if (part_type == EXT_CSD_PART_CONFIG_ACC_RPMB) {
+	if ((part_type & mask) == mask) {
 		mmc_retune_unpause(card->host);
 		if (card->reenable_cmdq && !card->ext_csd.cmdq_en)
 			ret = mmc_cmdq_enable(card);
@@ -3143,4 +3145,3 @@ module_exit(mmc_blk_exit);

 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Multimedia Card (MMC) block device driver");
-
--
2.34.1

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

* Re: [PATCHv4] mmc: rpmb: fixes pause retune on all RPMB partitions.
  2023-12-01 15:31 [PATCHv4] mmc: rpmb: fixes pause retune on all RPMB partitions Jorge Ramirez-Ortiz
@ 2023-12-07 14:01 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2023-12-07 14:01 UTC (permalink / raw)
  To: Jorge Ramirez-Ortiz
  Cc: linus.walleij, adrian.hunter, linux-mmc, linux-kernel, stable

On Fri, 1 Dec 2023 at 16:31, Jorge Ramirez-Ortiz <jorge@foundries.io> wrote:
>
> When RPMB was converted to a character device, it added support for
> multiple RPMB partitions (Commit 97548575bef3 ("mmc: block: Convert RPMB
> to a character device").
>
> One of the changes in this commit was transforming the variable
> target_part defined in __mmc_blk_ioctl_cmd into a bitmask.
>
> This inadvertedly regressed the validation check done in
> mmc_blk_part_switch_pre() and mmc_blk_part_switch_post().
>
> This commit fixes that regression.
>
> Fixes: 97548575bef3 ("mmc: block: Convert RPMB to a character device")
> Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Cc: <stable@vger.kernel.org> # v4.14+

Applied for fixes, thanks!

Kind regards
Uffe


> ---
>
>   v2:
>      fixes parenthesis around condition
>   v3:
>      adds stable to commit header
>   v4:
>      fixes the stable version to v4.14
>      adds Reviewed-by
>
>  drivers/mmc/core/block.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 152dfe593c43..13093d26bf81 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -851,9 +851,10 @@ static const struct block_device_operations mmc_bdops = {
>  static int mmc_blk_part_switch_pre(struct mmc_card *card,
>                                    unsigned int part_type)
>  {
> +       const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_RPMB;
>         int ret = 0;
>
> -       if (part_type == EXT_CSD_PART_CONFIG_ACC_RPMB) {
> +       if ((part_type & mask) == mask) {
>                 if (card->ext_csd.cmdq_en) {
>                         ret = mmc_cmdq_disable(card);
>                         if (ret)
> @@ -868,9 +869,10 @@ static int mmc_blk_part_switch_pre(struct mmc_card *card,
>  static int mmc_blk_part_switch_post(struct mmc_card *card,
>                                     unsigned int part_type)
>  {
> +       const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_RPMB;
>         int ret = 0;
>
> -       if (part_type == EXT_CSD_PART_CONFIG_ACC_RPMB) {
> +       if ((part_type & mask) == mask) {
>                 mmc_retune_unpause(card->host);
>                 if (card->reenable_cmdq && !card->ext_csd.cmdq_en)
>                         ret = mmc_cmdq_enable(card);
> @@ -3143,4 +3145,3 @@ module_exit(mmc_blk_exit);
>
>  MODULE_LICENSE("GPL");
>  MODULE_DESCRIPTION("Multimedia Card (MMC) block device driver");
> -
> --
> 2.34.1

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

end of thread, other threads:[~2023-12-07 14:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-01 15:31 [PATCHv4] mmc: rpmb: fixes pause retune on all RPMB partitions Jorge Ramirez-Ortiz
2023-12-07 14:01 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox