From: Niklas Cassel <cassel@kernel.org>
To: "Manivannan Sadhasivam" <mani@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Jonathan Corbet" <corbet@lwn.net>
Cc: Frank.Li@nxp.com, dlemoal@kernel.org,
Koichiro Den <den@valinux.co.jp>,
linux-pci@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v2] PCI: endpoint: pci-epf-test: Allow overriding default BAR sizes
Date: Wed, 28 Jan 2026 20:21:18 +0100 [thread overview]
Message-ID: <aXphrhdY8ZBKBOEF@ryzen> (raw)
In-Reply-To: <20260128171157.1795146-2-cassel@kernel.org>
On Wed, Jan 28, 2026 at 06:11:57PM +0100, Niklas Cassel wrote:
> @@ -1312,6 +1315,87 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
> pci_epf_test_free_space(epf);
> }
>
> +#define PCI_EPF_TEST_BAR_SIZE_R(_name, _id) \
> + static ssize_t pci_epf_test_##_name##_show(struct config_item *item, \
> + char *page) \
> + { \
> + struct config_group *group = to_config_group(item); \
> + struct pci_epf_test *epf_test = container_of(group, \
> + struct pci_epf_test, group); \
> + \
> + return sprintf(page, "%zu\n", epf_test->bar_size[_id]); \
> + }
> +
> +#define PCI_EPF_TEST_BAR_SIZE_W(_name, _id) \
> + static ssize_t pci_epf_test_##_name##_store(struct config_item *item, \
> + const char *page, size_t len) \
> + { \
> + struct config_group *group = to_config_group(item); \
> + struct pci_epf_test *epf_test = container_of(group, \
> + struct pci_epf_test, group); \
> + int val; \
> + int ret; \
> + \
> + ret = kstrtouint(page, 0, &val); \
> + if (ret) \
> + return ret; \
> + \
> + if (!is_power_of_2(val)) \
> + return -EINVAL; \
> + \
> + epf_test->bar_size[_id] = val; \
> + \
> + return len; \
> + }
> +
This code does not handle:
# echo 1024 > functions/pci_epf_test/func1/pci_epf_test.0/bar1_size
# echo 0 > controllers/a40000000.pcie-ep/start
# echo 2048 > functions/pci_epf_test/func1/pci_epf_test.0/bar1_size
# echo 1 > controllers/a40000000.pcie-ep/start
Since backing memory for a BAR is allocated in .bind()
And set_bar() is called in .epc_init()
Setting/overriding the BAR size must be done before .bind(), i.e.
at probe() time.
(probe() is called when doing: mkdir functions/pci_epf_test/func1 in configfs)
Therefore, we must make sure that modifying bar*_size after the EPF has
been bound to a EPC will result in an error.
Will send a V3.
Kind regards,
Niklas
next prev parent reply other threads:[~2026-01-28 19:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 17:11 [PATCH v2] PCI: endpoint: pci-epf-test: Allow overriding default BAR sizes Niklas Cassel
2026-01-28 19:21 ` Niklas Cassel [this message]
2026-01-29 4:33 ` Damien Le Moal
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=aXphrhdY8ZBKBOEF@ryzen \
--to=cassel@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=bhelgaas@google.com \
--cc=corbet@lwn.net \
--cc=den@valinux.co.jp \
--cc=dlemoal@kernel.org \
--cc=kishon@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mani@kernel.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