All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaehoon Chung <jh80.chung@samsung.com>
To: u-boot@lists.denx.de
Subject: [PATCH 3/4] cmd: mmc: display write protect state of boot partition
Date: Wed, 1 Apr 2020 15:56:21 +0900	[thread overview]
Message-ID: <9fef4a3d-46a3-6e18-a5f9-b125c41b849c@samsung.com> (raw)
In-Reply-To: <a422626b-ff5f-68ba-1489-c6bda1ab586b@gmx.de>

On 4/1/20 3:05 PM, Heinrich Schuchardt wrote:
> On 4/1/20 5:04 AM, Jaehoon Chung wrote:
>> Hi,
>>
>> On 3/30/20 2:24 PM, Heinrich Schuchardt wrote:
>>> Boot partitions of eMMC devices can be power on or permanently write
>>> protected. Let the 'mmc info' command display the protection state.
>>>
>>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>> ---
>>>  cmd/mmc.c | 24 ++++++++++++++++++++++++
>>>  1 file changed, 24 insertions(+)
>>>
>>> diff --git a/cmd/mmc.c b/cmd/mmc.c
>>> index 6f3cb85cc0..d62c85e439 100644
>>> --- a/cmd/mmc.c
>>> +++ b/cmd/mmc.c
>>> @@ -54,6 +54,8 @@ static void print_mmcinfo(struct mmc *mmc)
>>>  	if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {
>>>  		bool has_enh = (mmc->part_support & ENHNCD_SUPPORT) != 0;
>>>  		bool usr_enh = has_enh && (mmc->part_attr & EXT_CSD_ENH_USR);
>>> +		u8 wp, ext_csd[MMC_MAX_BLOCK_LEN];
>>> +		int ret;
>>>
>>>  #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
>>>  		puts("HC WP Group Size: ");
>>> @@ -90,6 +92,28 @@ static void print_mmcinfo(struct mmc *mmc)
>>>  					putc('\n');
>>>  			}
>>>  		}
>>> +		ret = mmc_send_ext_csd(mmc, ext_csd);
>>> +		if (ret)
>>> +			return;
>>
>> Is it really needed to call mmc_send_ext_csd() at here.
>> ext_csd register value was already read somewhere.
> 
> struct mmc does not contain the extended CSD. Performancewise it does
> not make sense to carry a copy which would have to be updated after each
> command that could potentially update it like SWITCH.

Why doesn't make sense to carry a copy? Its value can be updated whenever it's changed.
If someone want to set "write protect", then it has to follow sequence.
read ext_csd -> check value -> send_switch command 
Then it's possible to keep its value..

And some values are one-time programmable. it's not efficient about sending command to read again.

Best Regards,
Jaehoon Chung

> 
> The call to mmc_send_ext_csd() does not lead to any visible performance
> issue here.
> 
> Best regards
> 
> Heinrich
> 
>>
>> Best Regards,
>> Jaehoon Chung
>>
>>> +		wp = ext_csd[EXT_CSD_BOOT_WP_STATUS];
>>> +		for (i = 0; i < 2; ++i) {
>>> +			printf("Boot area %d is ", i);
>>> +			switch (wp & 3) {
>>> +			case 0:
>>> +				printf("not write protected\n");
>>> +				break;
>>> +			case 1:
>>> +				printf("power on protected\n");
>>> +				break;
>>> +			case 2:
>>> +				printf("permanently protected\n");
>>> +				break;
>>> +			default:
>>> +				printf("in reserved protection state\n");
>>> +				break;
>>> +			}
>>> +			wp >>= 2;
>>> +		}
>>>  	}
>>>  }
>>>  static struct mmc *init_mmc_device(int dev, bool force_init)
>>> --
>>> 2.25.1
>>>
>>>
>>>
>>
> 
> 
> 

  reply	other threads:[~2020-04-01  6:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30  5:24 [PATCH 0/4] mmc: manage boot area protection Heinrich Schuchardt
2020-03-30  5:24 ` [PATCH 1/4] mmc: EXT_CSD registers for write protection Heinrich Schuchardt
2020-03-30  5:24 ` [PATCH 2/4] mmc: export mmc_send_ext_csd() Heinrich Schuchardt
2020-03-30  5:24 ` [PATCH 3/4] cmd: mmc: display write protect state of boot partition Heinrich Schuchardt
2020-04-01  3:04   ` Jaehoon Chung
2020-04-01  6:05     ` Heinrich Schuchardt
2020-04-01  6:56       ` Jaehoon Chung [this message]
2020-03-30  5:24 ` [PATCH 4/4] cmd: mmc: provide boot area protection command Heinrich Schuchardt

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=9fef4a3d-46a3-6e18-a5f9-b125c41b849c@samsung.com \
    --to=jh80.chung@samsung.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.