From: Lukas Wunner <lukas@wunner.de>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
"Maciej W. Rozycki" <macro@orcam.me.uk>
Subject: Re: [PATCH v2 1/1] PCI/bwctrl: Replace lbms_count with PCI_LINK_LBMS_SEEN flag
Date: Wed, 23 Apr 2025 12:07:27 +0200 [thread overview]
Message-ID: <aAi734h55l7g6eXH@wunner.de> (raw)
In-Reply-To: <20250422115548.1483-1-ilpo.jarvinen@linux.intel.com>
[cc += Maciej, start of thread is here:
https://lore.kernel.org/r/20250422115548.1483-1-ilpo.jarvinen@linux.intel.com/
]
On Tue, Apr 22, 2025 at 02:55:47PM +0300, Ilpo Järvinen wrote:
> +void pcie_reset_lbms(struct pci_dev *port)
> {
> - struct pcie_bwctrl_data *data;
> -
> - guard(rwsem_read)(&pcie_bwctrl_lbms_rwsem);
> - data = port->link_bwctrl;
> - if (data)
> - atomic_set(&data->lbms_count, 0);
> - else
> - pcie_capability_write_word(port, PCI_EXP_LNKSTA,
> - PCI_EXP_LNKSTA_LBMS);
> + clear_bit(PCI_LINK_LBMS_SEEN, &port->priv_flags);
> + pcie_capability_write_word(port, PCI_EXP_LNKSTA, PCI_EXP_LNKSTA_LBMS);
> }
Hm, previously the LBMS bit was only cleared in the Link Status register
if the bandwith controller hadn't probed yet. Now it's cleared
unconditionally. I'm wondering if this changes the logic somehow?
> static bool pcie_lbms_seen(struct pci_dev *dev, u16 lnksta)
> {
> - unsigned long count;
> - int ret;
> -
> - ret = pcie_lbms_count(dev, &count);
> - if (ret < 0)
> - return lnksta & PCI_EXP_LNKSTA_LBMS;
> + if (test_bit(PCI_LINK_LBMS_SEEN, &dev->priv_flags))
> + return true;
>
> - return count > 0;
> + return lnksta & PCI_EXP_LNKSTA_LBMS;
> }
Another small logic change here: Previously pcie_lbms_count()
returned a negative value if the bandwidth controller hadn't
probed yet or wasn't compiled into the kernel. Only in those
two cases was the LBMS flag in the lnksta variable returned.
Now the LBMS flag is also returned if the bandwidth controller
is compiled into the kernel and has probed, but its irq handler
hasn't recorded a seen LBMS bit yet.
I'm guessing this can happen if the quirk races with the irq
handler and wins the race, so this safety net is needed?
This is quite subtle so I thought I'd ask. The patch otherwise
LGTM, so assuming the two subtle logic changes above are intentional
and can be explained, this is
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Thanks,
Lukas
next prev parent reply other threads:[~2025-04-23 10:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 11:55 [PATCH v2 1/1] PCI/bwctrl: Replace lbms_count with PCI_LINK_LBMS_SEEN flag Ilpo Järvinen
2025-04-23 10:07 ` Lukas Wunner [this message]
2025-04-23 11:37 ` Ilpo Järvinen
2025-04-24 5:38 ` Lukas Wunner
2025-04-24 12:37 ` Ilpo Järvinen
2025-04-25 10:12 ` Lukas Wunner
2025-04-25 12:24 ` Ilpo Järvinen
2025-04-29 10:02 ` Lukas Wunner
2025-04-23 21:04 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aAi734h55l7g6eXH@wunner.de \
--to=lukas@wunner.de \
--cc=bhelgaas@google.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=macro@orcam.me.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox