From: Bart Van Assche <bvanassche@acm.org>
To: Wonkon Kim <wkon.kim@samsung.com>,
James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com, peter.wang@mediatek.com,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ufs: core: Initialize a variable mode for PA_PWRMODE
Date: Mon, 13 Oct 2025 09:19:39 -0700 [thread overview]
Message-ID: <f90010b2-7db1-412c-8526-47339bf4aa6b@acm.org> (raw)
In-Reply-To: <000001dc3c1a$33e23030$9ba69090$@samsung.com>
On 10/13/25 1:20 AM, Wonkon Kim wrote:
>> On 10/2/25 12:00 AM, Wonkon Kim wrote:
>>> static bool ufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba)
>>> {
>>> struct ufs_pa_layer_attr *pwr_info = &hba->pwr_info;
>>> - u32 mode;
>>> + u32 mode = 0;
>>>
>>> ufshcd_dme_get(hba, UIC_ARG_MIB(PA_PWRMODE), &mode);
>>
>> Since there is more code that passes a pointer to an uninitialized
>> variable to ufshcd_dme_get(), the untested patch below may be a better
>> solution:
>>
>> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index
>> 127b691402f9..5226fbca29ec 100644
>> --- a/drivers/ufs/core/ufshcd.c
>> +++ b/drivers/ufs/core/ufshcd.c
>> @@ -4277,8 +4277,8 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32
>> attr_sel,
>> get, UIC_GET_ATTR_ID(attr_sel),
>> UFS_UIC_COMMAND_RETRIES - retries);
>>
>> - if (mib_val && !ret)
>> - *mib_val = uic_cmd.argument3;
>> + if (mib_val)
>> + *mib_val = ret == 0 ? uic_cmd.argument3 : 0;
>>
>> if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE)
>> && pwr_mode_change)
>>
>>
>
> There are some attributes to use 0 as valid value.
> e.g. PA_MAXRXHSGEAR is set to 0 for NO_HS=0
> If it has 0 for valid value, most of value 0 are regarded as FALSE, unsupported or minimum.
> And these cases seems to check ret for command success/fail in code.
> However, is it ok to set 0 for ufshcd_send_uic_cmd() fail?
>
> If it can't, it needs to initialize mode.
> Value 0 for PA_PWRMODE is invalid.
Hi Wonkon,
Modifying ufshcd_dme_get_attr() doesn't exclude checking the return
value of ufshcd_dme_get_attr(). I propose to modify
ufshcd_dme_get_attr() such that it always initializes *mib_val and also
to check the ufshcd_dme_get_attr() return value wherever appropriate.
Thanks,
Bart.
next prev parent reply other threads:[~2025-10-13 16:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20251002070057epcas1p49ac487359f24f6813ba8f9f44bcf0924@epcas1p4.samsung.com>
2025-10-02 7:00 ` Wonkon Kim
2025-10-02 8:00 ` Peter Wang (王信友)
2025-10-02 16:18 ` Bart Van Assche
2025-10-02 16:23 ` Bart Van Assche
2025-10-13 2:23 ` Wonkon Kim
2025-10-13 8:20 ` Wonkon Kim
2025-10-13 16:19 ` Bart Van Assche [this message]
2025-10-14 4:35 ` Wonkon Kim
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=f90010b2-7db1-412c-8526-47339bf4aa6b@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=peter.wang@mediatek.com \
--cc=wkon.kim@samsung.com \
/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
all inboxes | Powered by JetHome®