Browse Source

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>
pull/1985/head
anans 3 years ago
parent
commit
0956319b58
  1. 12
      drivers/ufs/ufs.c

12
drivers/ufs/ufs.c

@ -739,11 +739,6 @@ static void ufs_enum(void)
unsigned int blk_num, blk_size; unsigned int blk_num, blk_size;
int i; 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_init();
ufs_verify_ready(); 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)); 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) { if (ufs_params.flags & UFS_FLAGS_SKIPINIT) {
result = ufshc_dme_get(0x1571, 0, &data); result = ufshc_dme_get(0x1571, 0, &data);
assert(result == 0); assert(result == 0);

Loading…
Cancel
Save