Re: [PATCH] nvme-pci: Allow PCI bus-level PM to be used if ASPM is disabled

From: Christoph Hellwig
Date: Thu Aug 08 2019 - 04:48:12 EST


> - ndev->last_ps = 0;
> ret = nvme_get_power_state(ctrl, &ndev->last_ps);
> - if (ret < 0)
> + if (ret < 0 || ndev->last_ps == U32_MAX)

Is the intent of the magic U32_MAX check to see if the
nvme_get_power_state failed at the nvme level? In that case just
checking for any non-zero return value from nvme_get_power_state might
be the easier and more clear way to do it.

> Index: linux-pm/drivers/pci/pcie/aspm.c
> ===================================================================
> --- linux-pm.orig/drivers/pci/pcie/aspm.c
> +++ linux-pm/drivers/pci/pcie/aspm.c

Shouldn't we split PCI vs nvme in two patches?

> @@ -1170,6 +1170,26 @@ static int pcie_aspm_get_policy(char *bu
> module_param_call(policy, pcie_aspm_set_policy, pcie_aspm_get_policy,
> NULL, 0644);
>
> +/*
> + * pcie_aspm_enabled - Return the mask of enabled ASPM link states.
> + * @pci_device: Target device.
> + */
> +u32 pcie_aspm_enabled(struct pci_dev *pci_device)

pcie_aspm_enabled sounds like it returns a boolean. Shouldn't there be
a mask or so in the name better documenting what it returns?

> +{
> + struct pci_dev *bridge = pci_upstream_bridge(pci_device);
> + u32 ret;
> +
> + if (!bridge)
> + return 0;
> +
> + mutex_lock(&aspm_lock);
> + ret = bridge->link_state ? bridge->link_state->aspm_enabled : 0;
> + mutex_unlock(&aspm_lock);
> +
> + return ret;
> +}

I think this will need a EXPORT_SYMBOL_GPL thrown in so that modular
nvme continues working.

> +
> +
> #ifdef CONFIG_PCIEASPM_DEBUG

Nit: double blank line here.