Add epc_feature argument for pci_epf_free_space(), same as
pci_epf_alloc_space(). Doing so will allow to better handle
the iATU alignment requirements.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/pci/endpoint/functions/pci-epf-ntb.c | 3 ++-
drivers/pci/endpoint/functions/pci-epf-test.c | 2 ++
drivers/pci/endpoint/functions/pci-epf-vntb.c | 16 +++++++++++++---
drivers/pci/endpoint/pci-epf-core.c | 2 ++
include/linux/pci-epf.h | 1 +
5 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c
index e01a98e74d211174db3075c20457a3183f37e0a5..44775c41c10b90a56b1167f3f3869a60c686cf9e 100644
--- a/drivers/pci/endpoint/functions/pci-epf-ntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c
@@ -957,7 +957,8 @@ static void epf_ntb_config_spad_bar_free(struct epf_ntb *ntb)
ntb_epc = ntb->epc[type];
barno = ntb_epc->epf_ntb_bar[BAR_CONFIG];
if (ntb_epc->reg)
- pci_epf_free_space(epf, ntb_epc->reg, barno, type);
+ pci_epf_free_space(epf, ntb_epc->reg, barno,
+ ntb_epc->epc_features, type);
}
}
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 50eb4106369f41afa00ed3ae58c84922e0a49e51..8d5df47967226e1f02444e8d45f7aad1394afd04 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -740,6 +740,7 @@ static int pci_epf_test_set_bar(struct pci_epf *epf)
&epf->bar[bar]);
if (ret) {
pci_epf_free_space(epf, epf_test->reg[bar], bar,
+ epf_test->epc_features,
PRIMARY_INTERFACE);
epf_test->reg[bar] = NULL;
dev_err(dev, "Failed to set BAR%d\n", bar);
@@ -941,6 +942,7 @@ static void pci_epf_test_free_space(struct pci_epf *epf)
continue;
pci_epf_free_space(epf, epf_test->reg[bar], bar,
+ epf_test->epc_features,
PRIMARY_INTERFACE);
epf_test->reg[bar] = NULL;
}
diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index 874cb097b093ae645bbc4bf3c9d28ca812d7689d..8f59a5b9b7adec2c05eebae71c6a246bc5a8e88c 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -389,10 +389,15 @@ static int epf_ntb_config_sspad_bar_set(struct epf_ntb *ntb)
*/
static void epf_ntb_config_spad_bar_free(struct epf_ntb *ntb)
{
+ const struct pci_epc_features *epc_features;
enum pci_barno barno;
+ epc_features = pci_epc_get_features(ntb->epf->epc,
+ ntb->epf->func_no,
+ ntb->epf->vfunc_no);
+
barno = ntb->epf_ntb_bar[BAR_CONFIG];
- pci_epf_free_space(ntb->epf, ntb->reg, barno, 0);
+ pci_epf_free_space(ntb->epf, ntb->reg, barno, epc_features, 0);
}
/**
@@ -557,7 +562,7 @@ static int epf_ntb_db_bar_init(struct epf_ntb *ntb)
return ret;
err_alloc_peer_mem:
- pci_epf_free_space(ntb->epf, mw_addr, barno, 0);
+ pci_epf_free_space(ntb->epf, mw_addr, barno, epc_features, 0);
return -1;
}
@@ -570,10 +575,15 @@ static void epf_ntb_mw_bar_clear(struct epf_ntb *ntb, int num_mws);
*/
static void epf_ntb_db_bar_clear(struct epf_ntb *ntb)
{
+ const struct pci_epc_features *epc_features;
enum pci_barno barno;
+ epc_features = pci_epc_get_features(ntb->epf->epc,
+ ntb->epf->func_no,
+ ntb->epf->vfunc_no);
+
barno = ntb->epf_ntb_bar[BAR_DB];
- pci_epf_free_space(ntb->epf, ntb->epf_db, barno, 0);
+ pci_epf_free_space(ntb->epf, ntb->epf_db, barno, epc_features, 0);
pci_epc_clear_bar(ntb->epf->epc,
ntb->epf->func_no,
ntb->epf->vfunc_no,
diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c
index 394395c7f8decfa2010469655a4bd58a002993fd..b7deb0ee1760b23a24f49abf3baf53ea2f273476 100644
--- a/drivers/pci/endpoint/pci-epf-core.c
+++ b/drivers/pci/endpoint/pci-epf-core.c
@@ -213,11 +213,13 @@ EXPORT_SYMBOL_GPL(pci_epf_remove_vepf);
* @epf: the EPF device from whom to free the memory
* @addr: the virtual address of the PCI EPF register space
* @bar: the BAR number corresponding to the register space
+ * @epc_features: the features provided by the EPC specific to this EPF
* @type: Identifies if the allocated space is for primary EPC or secondary EPC
*
* Invoke to free the allocated PCI EPF register space.
*/
void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar,
+ const struct pci_epc_features *epc_features,
enum pci_epc_interface_type type)
{
struct device *dev;
diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h
index 879d19cebd4fc6d8df9d724e3a52fa7fbd61e535..d2d1c60fd5e0487b25aad51fee1b30554f630557 100644
--- a/include/linux/pci-epf.h
+++ b/include/linux/pci-epf.h
@@ -222,6 +222,7 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar,
const struct pci_epc_features *epc_features,
enum pci_epc_interface_type type);
void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar,
+ const struct pci_epc_features *epc_features,
enum pci_epc_interface_type type);
int pci_epf_bind(struct pci_epf *epf);
void pci_epf_unbind(struct pci_epf *epf);
--
2.47.2
Hi Jerome,
kernel test robot noticed the following build errors:
[auto build test ERROR on dea140198b846f7432d78566b7b0b83979c72c2b]
url: https://github.com/intel-lab-lkp/linux/commits/Jerome-Brunet/PCI-endpoint-add-epc_feature-argument-for-pci_epf_free_space/20250405-014733
base: dea140198b846f7432d78566b7b0b83979c72c2b
patch link: https://lore.kernel.org/r/20250404-pci-ep-size-alignment-v2-1-c3a0db4cfc57%40baylibre.com
patch subject: [PATCH v2 1/3] PCI: endpoint: add epc_feature argument for pci_epf_free_space()
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20250406/202504060315.dkEQSXkB-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250406/202504060315.dkEQSXkB-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504060315.dkEQSXkB-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/nvme/target/pci-epf.c:2165:69: error: too few arguments to function call, expected 5, have 4
2165 | pci_epf_free_space(epf, nvme_epf->reg_bar, BAR_0, PRIMARY_INTERFACE);
| ~~~~~~~~~~~~~~~~~~ ^
include/linux/pci-epf.h:224:6: note: 'pci_epf_free_space' declared here
224 | void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar,
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
225 | const struct pci_epc_features *epc_features,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226 | enum pci_epc_interface_type type);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
vim +2165 drivers/nvme/target/pci-epf.c
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2157
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2158 static void nvmet_pci_epf_free_bar(struct nvmet_pci_epf *nvme_epf)
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2159 {
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2160 struct pci_epf *epf = nvme_epf->epf;
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2161
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2162 if (!nvme_epf->reg_bar)
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2163 return;
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2164
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 @2165 pci_epf_free_space(epf, nvme_epf->reg_bar, BAR_0, PRIMARY_INTERFACE);
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2166 nvme_epf->reg_bar = NULL;
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2167 }
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2168
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Jerome,
kernel test robot noticed the following build errors:
[auto build test ERROR on dea140198b846f7432d78566b7b0b83979c72c2b]
url: https://github.com/intel-lab-lkp/linux/commits/Jerome-Brunet/PCI-endpoint-add-epc_feature-argument-for-pci_epf_free_space/20250405-014733
base: dea140198b846f7432d78566b7b0b83979c72c2b
patch link: https://lore.kernel.org/r/20250404-pci-ep-size-alignment-v2-1-c3a0db4cfc57%40baylibre.com
patch subject: [PATCH v2 1/3] PCI: endpoint: add epc_feature argument for pci_epf_free_space()
config: loongarch-randconfig-001-20250405 (https://download.01.org/0day-ci/archive/20250406/202504060122.RXfUdGx9-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250406/202504060122.RXfUdGx9-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504060122.RXfUdGx9-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/nvme/target/pci-epf.c: In function 'nvmet_pci_epf_free_bar':
>> drivers/nvme/target/pci-epf.c:2165:9: error: too few arguments to function 'pci_epf_free_space'
2165 | pci_epf_free_space(epf, nvme_epf->reg_bar, BAR_0, PRIMARY_INTERFACE);
| ^~~~~~~~~~~~~~~~~~
In file included from include/linux/pci-epc.h:12,
from drivers/nvme/target/pci-epf.c:19:
include/linux/pci-epf.h:224:6: note: declared here
224 | void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar,
| ^~~~~~~~~~~~~~~~~~
vim +/pci_epf_free_space +2165 drivers/nvme/target/pci-epf.c
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2157
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2158 static void nvmet_pci_epf_free_bar(struct nvmet_pci_epf *nvme_epf)
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2159 {
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2160 struct pci_epf *epf = nvme_epf->epf;
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2161
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2162 if (!nvme_epf->reg_bar)
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2163 return;
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2164
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 @2165 pci_epf_free_space(epf, nvme_epf->reg_bar, BAR_0, PRIMARY_INTERFACE);
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2166 nvme_epf->reg_bar = NULL;
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2167 }
0faa0fe6f90ea5 Damien Le Moal 2025-01-04 2168
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.