Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Niklas Cassel <cassel@kernel.org>
Cc: "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 1/7] PCI: endpoint: Allow EPF drivers to configure the size of Resizable BARs
Date: Fri, 7 Feb 2025 22:36:28 +0530	[thread overview]
Message-ID: <20250207170628.au23b5cw3s7il67j@thinkpad> (raw)
In-Reply-To: <20250131182949.465530-10-cassel@kernel.org>

On Fri, Jan 31, 2025 at 07:29:50PM +0100, Niklas Cassel wrote:
> A resizable BAR is different from a normal BAR in a few ways:
> -The minimum size of a resizable BAR is 1 MB.
> -Each BAR that is resizable has a Capability and Control register in the
>  Resizable BAR Capability structure.
> 
> These registers contain the supported sizes and the currently selected
> size of a resizable BAR.
> 
> The supported sizes is a bitmap of the supported sizes. The selected size
> is a single value that is equal to one of the supported sizes.
> 
> A resizable BAR thus has to be configured differently than a
> BAR_PROGRAMMABLE BAR, which usually sets the BAR size/mask in a vendor
> specific way.
> 
> The PCI endpoint framework currently does not support resizable BARs.
> 
> Add a BAR type BAR_RESIZABLE, so that an EPC driver can support resizable
> BARs properly.
> 
> Note that the pci_epc_set_bar() API takes a struct pci_epf_bar which tells
> the EPC driver how it wants to configure the BAR.
> 
> struct pci_epf_bar only has a single size struct member.
> 
> This means that an EPC driver will only be able to set a single supported
> size. This is perfectly fine, as we do not need the complexity of allowing
> a host to change the size of the BAR. If someone ever wants to support
> resizing a resizable BAR, the pci_epc_set_bar() API can be extended in the
> future.
> 
> With these changes, we allow an EPF driver to configure the size of
> Resizable BARs, rather than forcing them to a 1 MB size.
> 
> Signed-off-by: Niklas Cassel <cassel@kernel.org>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> ---
>  drivers/pci/endpoint/pci-epc-core.c | 4 ++++
>  drivers/pci/endpoint/pci-epf-core.c | 4 ++++
>  include/linux/pci-epc.h             | 4 ++++
>  3 files changed, 12 insertions(+)
> 
> diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
> index 9e9ca5f8e8f8..10dfc716328e 100644
> --- a/drivers/pci/endpoint/pci-epc-core.c
> +++ b/drivers/pci/endpoint/pci-epc-core.c
> @@ -609,6 +609,10 @@ int pci_epc_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
>  	if (!epc_features)
>  		return -EINVAL;
>  
> +	if (epc_features->bar[bar].type == BAR_RESIZABLE &&
> +	    (epf_bar->size < SZ_1M || (u64)epf_bar->size > (SZ_128G * 1024)))
> +		return -EINVAL;
> +
>  	if (epc_features->bar[bar].type == BAR_FIXED &&
>  	    (epc_features->bar[bar].fixed_size != epf_bar->size))
>  		return -EINVAL;
> diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c
> index 50bc2892a36c..394395c7f8de 100644
> --- a/drivers/pci/endpoint/pci-epf-core.c
> +++ b/drivers/pci/endpoint/pci-epf-core.c
> @@ -274,6 +274,10 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar,
>  	if (size < 128)
>  		size = 128;
>  
> +	/* According to PCIe base spec, min size for a resizable BAR is 1 MB. */
> +	if (epc_features->bar[bar].type == BAR_RESIZABLE && size < SZ_1M)
> +		size = SZ_1M;
> +
>  	if (epc_features->bar[bar].type == BAR_FIXED && bar_fixed_size) {
>  		if (size > bar_fixed_size) {
>  			dev_err(&epf->dev,
> diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h
> index e818e3fdcded..91ce39dc0fd4 100644
> --- a/include/linux/pci-epc.h
> +++ b/include/linux/pci-epc.h
> @@ -188,11 +188,15 @@ struct pci_epc {
>   * enum pci_epc_bar_type - configurability of endpoint BAR
>   * @BAR_PROGRAMMABLE: The BAR mask can be configured by the EPC.
>   * @BAR_FIXED: The BAR mask is fixed by the hardware.
> + * @BAR_RESIZABLE: The BAR implements the PCI-SIG Resizable BAR Capability.
> + *		   NOTE: An EPC driver can currently only set a single supported
> + *		   size.
>   * @BAR_RESERVED: The BAR should not be touched by an EPF driver.
>   */
>  enum pci_epc_bar_type {
>  	BAR_PROGRAMMABLE = 0,
>  	BAR_FIXED,
> +	BAR_RESIZABLE,
>  	BAR_RESERVED,
>  };
>  
> -- 
> 2.48.1
> 

-- 
மணிவண்ணன் சதாசிவம்

  reply	other threads:[~2025-02-07 17:06 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 [this message]
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
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=20250207170628.au23b5cw3s7il67j@thinkpad \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=bhelgaas@google.com \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=kishon@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.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