[PATCH] nvme-pci: try function level reset on init failure

Chaitanya Kulkarni chaitanyak at nvidia.com
Mon Jul 14 17:27:45 PDT 2025


On 7/14/25 10:13, Keith Busch wrote:
> From: Keith Busch <kbusch at kernel.org>
>
> I've encountered various nvme devices that for whatever reason are stuck
> in a reset state. Historically these have required a power cycle to make
> them usable again. Vendors don't report any problem with the device when
> we ship these for analysis.
>
> In many cases, a PCIe FLR is sufficient to restart operation without a
> power cycle. Try it if controller reset fails the first time.
>
> Signed-off-by: Keith Busch <kbusch at kernel.org>

I hope there are no setups that are relying on this failure and okay
with implicit PCIe FLR and any side-effects it might have,
but I think that is okay, looks good.

Reviewed-by: Chaitanya Kulkarni <kch at nvidia.com>

-ck

> ---
>   drivers/nvme/host/pci.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 4cf87fb5d8573..85749f19e3a23 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -2067,8 +2067,18 @@ static int nvme_pci_configure_admin_queue(struct nvme_dev *dev)
>   	 * might be pointing at!
>   	 */
>   	result = nvme_disable_ctrl(&dev->ctrl, false);
> -	if (result < 0)
> -		return result;
> +	if (result < 0) {
> +		struct pci_dev *pdev = to_pci_dev(dev->dev);
> +
> +		result = pcie_flr(pdev);
> +		if (result < 0)
> +			return result;
> +		pci_restore_state(pdev);
> +
> +		result = nvme_disable_ctrl(&dev->ctrl, false);
> +		if (result < 0)
> +			return result;
> +	}
>   
>   	result = nvme_alloc_queue(dev, 0, NVME_AQ_DEPTH);
>   	if (result)



More information about the Linux-nvme mailing list