lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 8 Aug 2020 15:56:53 -0700
From:   Bart Van Assche <bvanassche@....org>
To:     daejun7.park@...sung.com,
        "avri.altman@....com" <avri.altman@....com>,
        "jejb@...ux.ibm.com" <jejb@...ux.ibm.com>,
        "martin.petersen@...cle.com" <martin.petersen@...cle.com>,
        "asutoshd@...eaurora.org" <asutoshd@...eaurora.org>,
        "beanhuo@...ron.com" <beanhuo@...ron.com>,
        "stanley.chu@...iatek.com" <stanley.chu@...iatek.com>,
        "cang@...eaurora.org" <cang@...eaurora.org>,
        "tomas.winkler@...el.com" <tomas.winkler@...el.com>,
        ALIM AKHTAR <alim.akhtar@...sung.com>
Cc:     "linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Sang-yoon Oh <sangyoon.oh@...sung.com>,
        Sung-Jun Park <sungjun07.park@...sung.com>,
        yongmyung lee <ymhungry.lee@...sung.com>,
        Jinyoung CHOI <j-young.choi@...sung.com>,
        Adel Choi <adel.choi@...sung.com>,
        BoRam Shin <boram.shin@...sung.com>
Subject: Re: [PATCH v8 2/4] scsi: ufs: Introduce HPB feature

On 2020-08-06 02:11, Daejun Park wrote:
> +static void ufshpb_issue_hpb_reset_query(struct ufs_hba *hba)
> +{
> +	int err;
> +	int retries;
> +
> +	for (retries = 0; retries < HPB_RESET_REQ_RETRIES; retries++) {
> +		err = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_SET_FLAG,
> +				QUERY_FLAG_IDN_HPB_RESET, 0, NULL);
> +		if (err)
> +			dev_dbg(hba->dev,
> +				"%s: failed with error %d, retries %d\n",
> +				__func__, err, retries);
> +		else
> +			break;
> +	}
> +
> +	if (err) {
> +		dev_err(hba->dev,
> +			"%s setting fHpbReset flag failed with error %d\n",
> +			__func__, err);
> +		return;
> +	}
> +}

Please change the "break" into an early return, remove the last
occurrence "if (err)" and remove the final return statement.

> +static void ufshpb_check_hpb_reset_query(struct ufs_hba *hba)
> +{
> +	int err;
> +	bool flag_res = true;
> +	int try = 0;
> +
> +	/* wait for the device to complete HPB reset query */
> +	do {
> +		if (++try == HPB_RESET_REQ_RETRIES)
> +			break;
> +
> +		dev_info(hba->dev,
> +			"%s start flag reset polling %d times\n",
> +			__func__, try);
> +
> +		/* Poll fHpbReset flag to be cleared */
> +		err = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG,
> +				QUERY_FLAG_IDN_HPB_RESET, 0, &flag_res);
> +		usleep_range(1000, 1100);
> +	} while (flag_res);
> +
> +	if (err) {
> +		dev_err(hba->dev,
> +			"%s reading fHpbReset flag failed with error %d\n",
> +			__func__, err);
> +		return;
> +	}
> +
> +	if (flag_res) {
> +		dev_err(hba->dev,
> +			"%s fHpbReset was not cleared by the device\n",
> +			__func__);
> +	}
> +}

Should "polling %d times" perhaps be changed into "attempt %d"?

The "if (err)" statement may be reached without "err" having been
initialized. Please fix.

Additionally, please change the do-while loop into a for-loop, e.g. as
follows:

	for (try = 0; try < HPB_RESET_REQ_RETRIES; try++)
		...

Thanks,

Bart.

Powered by blists - more mailing lists