Re: [PATCH] PCI: Disable PTM on Upstream Ports during suspend

From: Bjorn Helgaas
Date: Wed Aug 31 2022 - 09:23:15 EST


[+cc Rafael, Rajvi, linux-pm]

On Wed, Aug 31, 2022 at 12:53:05PM +0300, Mika Westerberg wrote:
> On Tue, Aug 30, 2022 at 10:52:24AM -0500, Bjorn Helgaas wrote:
> > + type = pci_pcie_type(dev);
> > + if (!(type == PCI_EXP_TYPE_ROOT_PORT ||
> > + type == PCI_EXP_TYPE_UPSTREAM ||
> > + type == PCI_EXP_TYPE_ENDPOINT))
> > + return;
>
> Perhaps switch () instead?
>
> switch (pci_pcie_type(dev)) {
> case PCI_EXP_TYPE_ROOT_PORT:
> case PCI_EXP_TYPE_UPSTREAM:
> case PCI_EXP_TYPE_ENDPOINT:
> break;
> default:
> return;
> }
>
> Either way,
>
> Reviewed-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>

Thanks! I dropped this patch for now. I think Rajvi's similar
patch [1] is much better because we only need this kind of check in
one place -- where we enable PTM.

Also, we need to tighten this up so we *always* disable PTM [2]. The
patch I posted still calls pci_disable_ptm() from
pci_prepare_to_sleep(), which means we only do it when
!pdev->state_saved, so we leave PTM enabled if the driver saves its
own state.

Bjorn

[1] https://lore.kernel.org/r/20220830104913.1620539-2-rajvi.jingar@xxxxxxxxxxxxxxx
[2] https://lore.kernel.org/r/CAJZ5v0iHckqia4OywKzSNWFCaq7eOkJcm5yXJdT2_sNdd36gDw@xxxxxxxxxxxxxx