linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jorge Ramirez-Ortiz, Foundries" <jorge@foundries.io>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "Jorge Ramirez-Ortiz, Foundries" <jorge@foundries.io>,
	Jens Wiklander <jens.wiklander@linaro.org>,
	Tomas Winkler <tomas.winkler@intel.com>,
	Dominique Martinet <asmadeus@codewreck.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Dominique Martinet <dominique.martinet@atmark-techno.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] mmc: part_switch: fixes switch on gp3 partition
Date: Wed, 6 Mar 2024 15:22:20 +0100	[thread overview]
Message-ID: <Zeh8HGDToMoHglD2@trax> (raw)
In-Reply-To: <CACRpkdYZrDgVVCp2bqJqY1BpeHSXDWbRSqk6d=N_QhC4OVv=Ew@mail.gmail.com>

On 06/03/24 14:18:49, Linus Walleij wrote:
> On Wed, Mar 6, 2024 at 10:05 AM Jorge Ramirez-Ortiz, Foundries
> <jorge@foundries.io> wrote:
>
> > That looked strange as there should be support for 4 GP but this code
> > kind of convinced me of the opposite.
> >
> >         if (idata->rpmb) {
> >                 /* Support multiple RPMB partitions */
> >                 target_part = idata->rpmb->part_index;
> >                 target_part |= EXT_CSD_PART_CONFIG_ACC_RPMB;
> >         }
> >
> > So if we apply the fix that you propose, how are multiple RPMB
> > partitions (ie, 4) going to be identified as RPMB? Unless there can't be
> > more than 3?
>
> As far as I can tell there can only be one RPMB partition per device.

that matches everything I have seen in the field too (and we have been
supporting RPMB on many designs lately (# > 30).

>
> The v5.1A spec says (section 6.2.1):
>
> "Two Boot Area Partitions, (...)"
> "One RPMB Partition accessed through a trusted mechanism, (...)"
> "Four General Purpose Area Partitions (...)"
>
> implying there can be only one RPMB.
>
> Also I have never seen more than one in practice.

+1

so I think it is safe to conclude that my commit did indeed cause these
regressions as it ignored the support for multiple GP. Sorry about it!.

I still cant grasp how "target_part = idata->rpmb->part_index" is
helping in the design.

What happens when:
1) EXT_CSD_PART_CONFIG_ACC_MASK > part_index > EXT_CSD_PART_CONFIG_ACC_RPMB
target_part now could be indicating a GP instead of an RPMB leading to failures.

2) part_index <= EXT_CSD_PART_CONFIG_ACC_RPMB
loses the part_index value .

So part_index should be larger than EXT_CSD_PART_CONFIG_ACC_MASK even
though the comment indicates it starts at 0?

/**
 * struct mmc_rpmb_data - special RPMB device type for these areas
 * @dev: the device for the RPMB area
 * @chrdev: character device for the RPMB area
 * @id: unique device ID number
 * @part_index: partition index (0 on first)    <---------------------
 * @md: parent MMC block device
 * @node: list item, so we can put this device on a list
 */
struct mmc_rpmb_data {
	struct device dev;
	struct cdev chrdev;
	int id;

is it just possible that "target_part = idata->rpmb->part_index" just
needs to be shifted to avoid issues?

I think the fix to the regression I introduced could perhaps address
this as well.

  reply	other threads:[~2024-03-06 14:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06  1:44 [PATCH] mmc: part_switch: fixes switch on gp3 partition Dominique Martinet
2024-03-06  8:03 ` Linus Walleij
2024-03-06  8:15   ` Dominique Martinet
2024-03-06  9:05 ` Jorge Ramirez-Ortiz, Foundries
2024-03-06 11:39   ` Dominique Martinet
2024-03-06 13:03   ` Linus Walleij
2024-03-06 13:18   ` Linus Walleij
2024-03-06 14:22     ` Jorge Ramirez-Ortiz, Foundries [this message]
2024-03-06 14:38       ` Linus Walleij
2024-03-06 15:56         ` Ulf Hansson
2024-03-06 19:49           ` Linus Walleij
2024-03-06 22:38             ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zeh8HGDToMoHglD2@trax \
    --to=jorge@foundries.io \
    --cc=asmadeus@codewreck.org \
    --cc=dominique.martinet@atmark-techno.com \
    --cc=jens.wiklander@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tomas.winkler@intel.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).