Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Marek Vasut <marek.vasut+renesas@mailbox.org>, linux-pci@vger.kernel.org
Cc: "Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Frank Li" <Frank.Li@nxp.com>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Niklas Cassel" <cassel@kernel.org>,
	"Wang Jiang" <jiangwang@kylinos.cn>,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] PCI: endpoint: pci-epf-test: Limit PCIe BAR size for fixed BARs
Date: Thu, 4 Sep 2025 11:40:15 +0900	[thread overview]
Message-ID: <b3d5773d-c573-4491-b799-90405a8af6a9@kernel.org> (raw)
In-Reply-To: <20250904023753.494147-1-marek.vasut+renesas@mailbox.org>

On 9/4/25 11:37 AM, Marek Vasut wrote:
> Currently, the test allocates BAR sizes according to fixed table
> bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 } . This
> does not work with controllers which have fixed size BARs, like
> Renesas R-Car V4H PCIe controller, which has BAR4 size limited
> to 256 Bytes, which is much less than 131072 currently requested
> by this test.
> 
> Adjust the test such, that in case a fixed size BAR is detected
> on a controller, minimum of requested size and fixed size BAR
> size is used during the test instead.
> 
> This helps with test failures reported as follows:
> "
> pci_epf_test pci_epf_test.0: requested BAR size is larger than fixed size
> pci_epf_test pci_epf_test.0: Failed to allocate space for BAR4
> "
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Cc: "Krzysztof Wilczyński" <kwilczynski@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Damien Le Moal <dlemoal@kernel.org>
> Cc: Frank Li <Frank.Li@nxp.com>
> Cc: Kishon Vijay Abraham I <kishon@kernel.org>
> Cc: Manivannan Sadhasivam <mani@kernel.org>
> Cc: Niklas Cassel <cassel@kernel.org>
> Cc: Wang Jiang <jiangwang@kylinos.cn>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-pci@vger.kernel.org
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>  drivers/pci/endpoint/functions/pci-epf-test.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index e091193bd8a8a..d9c950d4c9a9e 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -1022,7 +1022,8 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf)
>  	enum pci_barno test_reg_bar = epf_test->test_reg_bar;
>  	enum pci_barno bar;
>  	const struct pci_epc_features *epc_features = epf_test->epc_features;
> -	size_t test_reg_size;
> +	size_t test_reg_size, test_bar_size;
> +	u64 bar_fixed_size;
>  
>  	test_reg_bar_size = ALIGN(sizeof(struct pci_epf_test_reg), 128);
>  
> @@ -1050,7 +1051,13 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf)
>  		if (bar == test_reg_bar)
>  			continue;
>  
> -		base = pci_epf_alloc_space(epf, bar_size[bar], bar,
> +		test_bar_size = bar_size[bar];
> +
> +		bar_fixed_size = epc_features->bar[bar].fixed_size;
> +		if (epc_features->bar[bar].type == BAR_FIXED && bar_fixed_size)
> +			test_bar_size = min(bar_size[bar], bar_fixed_size);

I think this can be simplified to:

		if (epc_features->bar[bar].type == BAR_FIXED)
			test_bar_size = epc_features->bar[bar].fixed_size;
		else
			test_bar_size = bar_size[bar];

because if the bar type is BAR_FIXED, then the size of the bar can only be its
fixed size.

> +
> +		base = pci_epf_alloc_space(epf, test_bar_size, bar,
>  					   epc_features, PRIMARY_INTERFACE);
>  		if (!base)
>  			dev_err(dev, "Failed to allocate space for BAR%d\n",


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2025-09-04  2:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04  2:37 [PATCH] PCI: endpoint: pci-epf-test: Limit PCIe BAR size for fixed BARs Marek Vasut
2025-09-04  2:40 ` Damien Le Moal [this message]
2025-09-04  3:32   ` Marek Vasut
2025-09-04  3:39     ` Damien Le Moal
2025-09-04 17:35       ` Marek Vasut
2025-09-04 12:28   ` Niklas Cassel
2025-09-04 21:29     ` Marek Vasut
2025-09-05  7:43       ` Jerome Brunet
2025-09-05 11:38         ` Marek Vasut
2025-09-05  7:32     ` Jerome Brunet
2025-09-05  8:36       ` Niklas Cassel
2025-09-05 12:14         ` Marek Vasut

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=b3d5773d-c573-4491-b799-90405a8af6a9@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=cassel@kernel.org \
    --cc=jiangwang@kylinos.cn \
    --cc=kishon@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=marek.vasut+renesas@mailbox.org \
    /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