Re: [PATCH v4] nvme: reduce firmware activation poll interval

Keith Busch <[email protected]>
Newsgroups org.infradead.lists.linux-nvme,org.kernel.vger.linux-kernel
Message-ID <antJGoTgL-1sbpyy@kbusch-mbp>
On Tue, Jul 28, 2026 at 08:17:35PM +0800, guzebing wrote:
> +static int nvme_wait_csts(struct nvme_ctrl *ctrl, u32 mask, u32 val,
> +			  unsigned long timeout, bool exit_if_ctrl_disabled,
> +			  u32 *csts)
>  {
> -	unsigned long timeout_jiffies = jiffies + timeout * HZ;
> -	u32 csts;
>  	int ret;
>  
> -	while ((ret = ctrl->ops->reg_read32(ctrl, NVME_REG_CSTS, &csts)) == 0) {
> -		if (csts == ~0)
> +	while ((ret = ctrl->ops->reg_read32(ctrl, NVME_REG_CSTS, csts)) == 0) {
> +		if (*csts == ~0)
>  			return -ENODEV;
> -		if ((csts & mask) == val)
> -			break;
> +		if (exit_if_ctrl_disabled &&
> +		    !(ctrl->ctrl_config & NVME_CC_ENABLE))
> +			return 0;
> +		if ((*csts & mask) == val)
> +			return 0;
>  
>  		usleep_range(1000, 2000);
>  		if (fatal_signal_pending(current))
>  			return -EINTR;
> -		if (time_after(jiffies, timeout_jiffies)) {
> -			dev_err(ctrl->device,
> -				"Device not ready; aborting %s, CSTS=0x%x\n",
> -				op, csts);
> -			return -ENODEV;
> -		}
> +		if (time_after(jiffies, timeout))
> +			return -ETIMEDOUT;

Mostly looks fine, though I was hoping to converge a little more
commonality among these functions. I folded some minor changes in when
applying, so please have a look at the current git tree to see if the
result is okay.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.