From: Niklas Cassel <cassel@kernel.org>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: "Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Siddharth Vadapalli" <s-vadapalli@ti.com>,
"Udit Kumar" <u-kumar1@ti.com>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 2/7] PCI: endpoint: Add pci_epc_bar_size_to_rebar_cap()
Date: Wed, 19 Feb 2025 18:24:10 +0100 [thread overview]
Message-ID: <Z7YTukXh-Y3_HQsb@ryzen> (raw)
In-Reply-To: <20250218164804.GA181151@bhelgaas>
On Tue, Feb 18, 2025 at 10:48:04AM -0600, Bjorn Helgaas wrote:
> On Fri, Jan 31, 2025 at 07:29:51PM +0100, Niklas Cassel wrote:
> > Add a helper function to convert a size to the representation used by the
> > Resizable BAR Capability Register.
>
> > +/**
> > + * pci_epc_bar_size_to_rebar_cap() - convert a size to the representation used
> > + * by the Resizable BAR Capability Register
> > + * @size: the size to convert
> > + * @cap: where to store the result
> > + *
> > + * Returns 0 on success and a negative error code in case of error.
> > + */
> > +int pci_epc_bar_size_to_rebar_cap(size_t size, u32 *cap)
> > +{
> > + /*
> > + * According to PCIe base spec, min size for a resizable BAR is 1 MB,
> > + * thus disallow a requested BAR size smaller than 1 MB.
> > + * Disallow a requested BAR size larger than 128 TB.
> > + */
> > + if (size < SZ_1M || (u64)size > (SZ_128G * 1024))
> > + return -EINVAL;
> > +
> > + *cap = ilog2(size) - ilog2(SZ_1M);
> > +
> > + /* Sizes in REBAR_CAP start at BIT(4). */
> > + *cap = BIT(*cap + 4);
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(pci_epc_bar_size_to_rebar_cap);
>
> This doesn't seem specific to EPC. It looks basically similar to
> pci_rebar_bytes_to_size(). Can we consolidate anything there?
This function is to convert a size to
"Resizable BAR Capability Register", which includes one or more supported
BAR sizes.
This register should only ever by written by a PCI endpoint function,
so I think its current home in drivers/pci/endpoint/ is correct.
pci_rebar_bytes_to_size() is used to convert a size to
"Resizable BAR Control Register", specifically the field
"BAR Size".
This "BAR Size" field in the "Resizable BAR Control Register" can be
written by the host side (or endpoint side), to select one of the
supported bar sizes. So I think it makes sense for
pci_rebar_bytes_to_size() to live in pci.h.
>
> Since we're basing this on the spec, we should include a complete
> citation, e.g., PCIe r6.0, sec xxx.
I agree:
https://lore.kernel.org/linux-pci/20250219171454.2903059-2-cassel@kernel.org/T/#u
Kind regards,
Niklas
next prev parent reply other threads:[~2025-02-19 17:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 18:29 [PATCH v4 0/7] PCI: endpoint: Allow EPF drivers to configure the size of Resizable BARs Niklas Cassel
2025-01-31 18:29 ` [PATCH v4 1/7] " Niklas Cassel
2025-02-07 17:06 ` Manivannan Sadhasivam
2025-01-31 18:29 ` [PATCH v4 2/7] PCI: endpoint: Add pci_epc_bar_size_to_rebar_cap() Niklas Cassel
2025-02-07 17:11 ` Manivannan Sadhasivam
2025-02-18 16:48 ` Bjorn Helgaas
2025-02-19 17:24 ` Niklas Cassel [this message]
2025-02-19 17:49 ` Bjorn Helgaas
2025-02-19 18:00 ` Niklas Cassel
2025-01-31 18:29 ` [PATCH v4 3/7] PCI: dwc: ep: Move dw_pcie_ep_find_ext_capability() Niklas Cassel
2025-01-31 18:29 ` [PATCH v4 4/7] PCI: dwc: endpoint: Allow EPF drivers to configure the size of Resizable BARs Niklas Cassel
2025-02-07 17:17 ` Manivannan Sadhasivam
2025-01-31 18:29 ` [PATCH v4 5/7] PCI: keystone: Describe Resizable BARs as " Niklas Cassel
2025-01-31 18:29 ` [PATCH v4 6/7] PCI: keystone: Specify correct alignment requirement Niklas Cassel
2025-02-07 17:18 ` Manivannan Sadhasivam
2025-01-31 18:29 ` [PATCH v4 7/7] PCI: dw-rockchip: Describe Resizable BARs as Resizable BARs Niklas Cassel
2025-02-13 13:33 ` [PATCH v4 0/7] PCI: endpoint: Allow EPF drivers to configure the size of " Niklas Cassel
2025-02-14 17:40 ` Manivannan Sadhasivam
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=Z7YTukXh-Y3_HQsb@ryzen \
--to=cassel@kernel.org \
--cc=bhelgaas@google.com \
--cc=dlemoal@kernel.org \
--cc=helgaas@kernel.org \
--cc=kishon@kernel.org \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=s-vadapalli@ti.com \
--cc=u-kumar1@ti.com \
--cc=vigneshr@ti.com \
/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