[PATCH] nvme: cleanup nvme_configure_apst

Niklas Cassel Niklas.Cassel at wdc.com
Mon Apr 19 08:32:22 BST 2021


On Fri, Apr 09, 2021 at 11:45:24AM +0200, Christoph Hellwig wrote:
> Remove a level of indentation from the main code implementating the table
> search by using a goto for the APST not supported case.  Also move the
> main comment above the function.
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>  drivers/nvme/host/core.c | 148 ++++++++++++++++++---------------------
>  1 file changed, 69 insertions(+), 79 deletions(-)
> 

(snip)

> +		/*
> +		 * This state is good.  Use it as the APST idle target for
> +		 * higher power states.
> +		 */
> +		transition_ms = total_latency_us + 19;
> +		do_div(transition_ms, 20);
> +		if (transition_ms > (1 << 24) - 1)
> +			transition_ms = (1 << 24) - 1;
> +
> +		target = cpu_to_le64((state << 3) | (transition_ms << 8));
> +		if (max_ps == -1)
> +			max_ps = state;
> +		if (total_latency_us > max_lat_us)
> +			max_lat_us = total_latency_us;
> +	}
>  

First new line.

> -		apste = 1;
>  

Second new line.

> -		if (max_ps == -1) {
> -			dev_dbg(ctrl->device, "APST enabled but no non-operational states are available\n");
> -		} else {
> -			dev_dbg(ctrl->device, "APST enabled: max PS = %d, max round-trip latency = %lluus, table = %*phN\n",
> -				max_ps, max_lat_us, (int)sizeof(*table), table);
> -		}
> -	}
> +	if (max_ps == -1)
> +		dev_dbg(ctrl->device, "APST enabled but no non-operational states are available\n");
> +	else
> +		dev_dbg(ctrl->device, "APST enabled: max PS = %d, max round-trip latency = %lluus, table = %*phN\n",
> +			max_ps, max_lat_us, (int)sizeof(*table), table);
> +	apste = 1;
>  
> +done:
>  	ret = nvme_set_features(ctrl, NVME_FEAT_AUTO_PST, apste,
>  				table, sizeof(*table), NULL);
>  	if (ret)
>  		dev_err(ctrl->device, "failed to set APST feature (%d)\n", ret);
> -
>  	kfree(table);
>  	return ret;
>  }

If you remove the second new line, such that there are not two succeeding
new lines:

Reviewed-by: Niklas Cassel <niklas.cassel at wdc.com>


More information about the Linux-nvme mailing list