fix(ufs): move nutrs assignment to ufs_init

nutrs is set in ufs_enum (used by get_empty_slot), this will not
be assigned if UFS_FLAGS_SKIPINIT is set in flags during init and
might end up crashing read/write commands

Change-Id: I1517b69c56741fd5bf4ef0ebc1fc8738746233d7
Signed-off-by: anans <anans@google.com>
This commit is contained in:
anans 2022-03-15 13:37:37 +05:30
parent 6e16f7f09c
commit 0956319b58
1 changed files with 7 additions and 5 deletions

View File

@ -739,11 +739,6 @@ static void ufs_enum(void)
unsigned int blk_num, blk_size;
int i;
/* 0 means 1 slot */
nutrs = (mmio_read_32(ufs_params.reg_base + CAP) & CAP_NUTRS_MASK) + 1;
if (nutrs > (ufs_params.desc_size / UFS_DESC_SIZE))
nutrs = ufs_params.desc_size / UFS_DESC_SIZE;
ufs_verify_init();
ufs_verify_ready();
@ -788,6 +783,13 @@ int ufs_init(const ufs_ops_t *ops, ufs_params_t *params)
memcpy(&ufs_params, params, sizeof(ufs_params_t));
/* 0 means 1 slot */
nutrs = (mmio_read_32(ufs_params.reg_base + CAP) & CAP_NUTRS_MASK) + 1;
if (nutrs > (ufs_params.desc_size / UFS_DESC_SIZE)) {
nutrs = ufs_params.desc_size / UFS_DESC_SIZE;
}
if (ufs_params.flags & UFS_FLAGS_SKIPINIT) {
result = ufshc_dme_get(0x1571, 0, &data);
assert(result == 0);