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

Rafael J. Wysocki
2019-08-08T09:06:32Z

On Thu, Aug 8, 2019 at 10:48 AM Christoph Hellwig <hch@lst.de> wrote:
>
> > - 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.

Now that I think of that, it appears redundant. I'll drop 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?

That can be done.

> > @@ -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?

OK

> > +{
> > + 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.

Right, sorry.

> > +
> > +
> > #ifdef CONFIG_PCIEASPM_DEBUG
>
> Nit: double blank line here.

Overlooked, will fix.

Thanks!