diff mbox series

[1/3] PCI/ASPM: Disable ASPM_STATE_L1 only when class driver disables L1 ASPM

Message ID 20230411111034.1473044-2-ajayagarwal@google.com (mailing list archive)
State Not Applicable
Headers show
Series ASPM: aspm_disable/default/support state handling fixes | expand

Commit Message

Ajay Agarwal April 11, 2023, 11:10 a.m. UTC
Currently the aspm driver sets ASPM_STATE_L1 as well as
ASPM_STATE_L1SS bits when the class driver disables L1.
pcie_config_aspm_link takes care that L1ss ASPM is not enabled
if L1 is disabled. ASPM_STATE_L1SS bits do not need to be
explicitly set. The sysfs node store() function, which also
modifies the aspm_disable value, does not set these bits either
when only L1 ASPM is disabled by the user.

Disable ASPM_STATE_L1 only when class driver disables L1 ASPM.

Signed-off-by: Ajay Agarwal <ajayagarwal@google.com>
---
 drivers/pci/pcie/aspm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Bjorn Helgaas May 1, 2023, 5:21 p.m. UTC | #1
On Tue, Apr 11, 2023 at 04:40:32PM +0530, Ajay Agarwal wrote:
> Currently the aspm driver sets ASPM_STATE_L1 as well as
> ASPM_STATE_L1SS bits when the class driver disables L1.

I would have said just "driver" -- do you mean something different by
using "class driver"?  The callers I see are garden-variety drivers
for individual devices like hci_bcm4377, xillybus_pcie, e1000e, jme,
etc.

> pcie_config_aspm_link takes care that L1ss ASPM is not enabled
> if L1 is disabled. ASPM_STATE_L1SS bits do not need to be
> explicitly set. The sysfs node store() function, which also
> modifies the aspm_disable value, does not set these bits either
> when only L1 ASPM is disabled by the user.

Right.  It'd be nice to combine __pci_disable_link_state() and
aspm_attr_store_common() so they use the same logic for this, but
that's not really trivial to do.

> Disable ASPM_STATE_L1 only when class driver disables L1 ASPM.

So IIUC, this is a cleanup and should not fix any actual function
bugs, right?  If it *does* fix a bug, we should add a Fixes: tag and a
description of the bug.

> Signed-off-by: Ajay Agarwal <ajayagarwal@google.com>
> ---
>  drivers/pci/pcie/aspm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
> index 66d7514ca111..5765b226102a 100644
> --- a/drivers/pci/pcie/aspm.c
> +++ b/drivers/pci/pcie/aspm.c
> @@ -1095,8 +1095,7 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
>  	if (state & PCIE_LINK_STATE_L0S)
>  		link->aspm_disable |= ASPM_STATE_L0S;
>  	if (state & PCIE_LINK_STATE_L1)
> -		/* L1 PM substates require L1 */
> -		link->aspm_disable |= ASPM_STATE_L1 | ASPM_STATE_L1SS;
> +		link->aspm_disable |= ASPM_STATE_L1;
>  	if (state & PCIE_LINK_STATE_L1_1)
>  		link->aspm_disable |= ASPM_STATE_L1_1;
>  	if (state & PCIE_LINK_STATE_L1_2)
> -- 
> 2.40.0.577.gac1e443424-goog
>
Ajay Agarwal May 2, 2023, 12:38 p.m. UTC | #2
On Mon, May 01, 2023 at 12:21:14PM -0500, Bjorn Helgaas wrote:
> On Tue, Apr 11, 2023 at 04:40:32PM +0530, Ajay Agarwal wrote:
> > Currently the aspm driver sets ASPM_STATE_L1 as well as
> > ASPM_STATE_L1SS bits when the class driver disables L1.
> 
> I would have said just "driver" -- do you mean something different by
> using "class driver"?  The callers I see are garden-variety drivers
> for individual devices like hci_bcm4377, xillybus_pcie, e1000e, jme,
> etc.
No, I do not mean anything different by "class driver". I just wanted
to name the caller drivers of the ASPM APIs as something other than
just "driver". Do you want me to change this to "driver" ?
> 
> > pcie_config_aspm_link takes care that L1ss ASPM is not enabled
> > if L1 is disabled. ASPM_STATE_L1SS bits do not need to be
> > explicitly set. The sysfs node store() function, which also
> > modifies the aspm_disable value, does not set these bits either
> > when only L1 ASPM is disabled by the user.
> 
> Right.  It'd be nice to combine __pci_disable_link_state() and
> aspm_attr_store_common() so they use the same logic for this, but
> that's not really trivial to do.
> 
Ack.
> > Disable ASPM_STATE_L1 only when class driver disables L1 ASPM.
> 
> So IIUC, this is a cleanup and should not fix any actual function
> bugs, right?  If it *does* fix a bug, we should add a Fixes: tag and a
> description of the bug.
> 
Yes, this is just a cleanup.
> > Signed-off-by: Ajay Agarwal <ajayagarwal@google.com>
> > ---
> >  drivers/pci/pcie/aspm.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
> > index 66d7514ca111..5765b226102a 100644
> > --- a/drivers/pci/pcie/aspm.c
> > +++ b/drivers/pci/pcie/aspm.c
> > @@ -1095,8 +1095,7 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
> >  	if (state & PCIE_LINK_STATE_L0S)
> >  		link->aspm_disable |= ASPM_STATE_L0S;
> >  	if (state & PCIE_LINK_STATE_L1)
> > -		/* L1 PM substates require L1 */
> > -		link->aspm_disable |= ASPM_STATE_L1 | ASPM_STATE_L1SS;
> > +		link->aspm_disable |= ASPM_STATE_L1;
> >  	if (state & PCIE_LINK_STATE_L1_1)
> >  		link->aspm_disable |= ASPM_STATE_L1_1;
> >  	if (state & PCIE_LINK_STATE_L1_2)
> > -- 
> > 2.40.0.577.gac1e443424-goog
> >
Bjorn Helgaas May 2, 2023, 4:07 p.m. UTC | #3
On Tue, May 02, 2023 at 06:08:13PM +0530, Ajay Agarwal wrote:
> On Mon, May 01, 2023 at 12:21:14PM -0500, Bjorn Helgaas wrote:
> > On Tue, Apr 11, 2023 at 04:40:32PM +0530, Ajay Agarwal wrote:
> > > Currently the aspm driver sets ASPM_STATE_L1 as well as
> > > ASPM_STATE_L1SS bits when the class driver disables L1.
> > 
> > I would have said just "driver" -- do you mean something different by
> > using "class driver"?  The callers I see are garden-variety drivers
> > for individual devices like hci_bcm4377, xillybus_pcie, e1000e, jme,
> > etc.
>
> No, I do not mean anything different by "class driver". I just wanted
> to name the caller drivers of the ASPM APIs as something other than
> just "driver". Do you want me to change this to "driver" ?

Yes, please, I think "driver" by itself is sufficient.  IIUC, "class
driver" generally refers to a generic or abstract driver that provides
a common interface to a variety of different devices.  This interface
could be used by such a class driver or by the driver for a specific
device, but the type of driver is not relevant to this patch.

Bjorn
Ajay Agarwal May 2, 2023, 6:32 p.m. UTC | #4
On Tue, May 02, 2023 at 11:07:22AM -0500, Bjorn Helgaas wrote:
> On Tue, May 02, 2023 at 06:08:13PM +0530, Ajay Agarwal wrote:
> > On Mon, May 01, 2023 at 12:21:14PM -0500, Bjorn Helgaas wrote:
> > > On Tue, Apr 11, 2023 at 04:40:32PM +0530, Ajay Agarwal wrote:
> > > > Currently the aspm driver sets ASPM_STATE_L1 as well as
> > > > ASPM_STATE_L1SS bits when the class driver disables L1.
> > > 
> > > I would have said just "driver" -- do you mean something different by
> > > using "class driver"?  The callers I see are garden-variety drivers
> > > for individual devices like hci_bcm4377, xillybus_pcie, e1000e, jme,
> > > etc.
> >
> > No, I do not mean anything different by "class driver". I just wanted
> > to name the caller drivers of the ASPM APIs as something other than
> > just "driver". Do you want me to change this to "driver" ?
> 
> Yes, please, I think "driver" by itself is sufficient.  IIUC, "class
> driver" generally refers to a generic or abstract driver that provides
> a common interface to a variety of different devices.  This interface
> could be used by such a class driver or by the driver for a specific
> device, but the type of driver is not relevant to this patch.
> 
> Bjorn

Ack. Will do in the next revision.
diff mbox series

Patch

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 66d7514ca111..5765b226102a 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -1095,8 +1095,7 @@  static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
 	if (state & PCIE_LINK_STATE_L0S)
 		link->aspm_disable |= ASPM_STATE_L0S;
 	if (state & PCIE_LINK_STATE_L1)
-		/* L1 PM substates require L1 */
-		link->aspm_disable |= ASPM_STATE_L1 | ASPM_STATE_L1SS;
+		link->aspm_disable |= ASPM_STATE_L1;
 	if (state & PCIE_LINK_STATE_L1_1)
 		link->aspm_disable |= ASPM_STATE_L1_1;
 	if (state & PCIE_LINK_STATE_L1_2)