Re: [PATCH v3 1/2] PCI: Initialize RCB from pci_configure_device

From: Bjorn Helgaas

Date: Tue Jan 27 2026 - 16:58:58 EST


On Thu, Jan 22, 2026 at 03:45:58PM +0200, Ilpo Järvinen wrote:
> On Thu, 22 Jan 2026, Håkon Bugge wrote:
>
> > Commit e42010d8207f ("PCI: Set Read Completion Boundary to 128 iff
> > Root Port supports it (_HPX)") fixed a bogus _HPX type 2 record, which
> > instructed program_hpx_type2() to set the RCB in an endpoint,
> > although it's RC did not have the RCB bit set.

> > + pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &lnkctl);
> > + if (rcb) {
> > + if (lnkctl & PCI_EXP_LNKCTL_RCB)
> > + return;
> > +
> > + lnkctl |= PCI_EXP_LNKCTL_RCB;
> > + } else {
> > + if (!(lnkctl & PCI_EXP_LNKCTL_RCB))
> > + return;
> > +
> > + pci_info(dev, FW_INFO "clearing RCB (RCB not set in Root Port)\n");
> > + lnkctl &= ~PCI_EXP_LNKCTL_RCB;
> > + }
> > +
> > + pcie_capability_write_word(dev, PCI_EXP_LNKCTL, lnkctl);
>
> So this sequence is effectively implementing this simple statement:
>
> pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
> PCI_EXP_LNKCTL_RCB,
> rcb ? PCI_EXP_LNKCTL_RCB : 0);
>
> + the print.
>
> Is there a good reason why you want to avoid the write by using early
> returns?

Good question, pcie_capability_clear_and_set_word() is much more
readable.

> I also wonder if those clear & set & clean_and_set interfaces should
> implement the write avoidance if it's an useful thing (callers should be
> checked they're not used for RW1C bits if that's implemented though).