Re: [PATCH 05/11] PCI: endpoint: pci-epf-vntb: Allocate packed outbound MW space

[email protected] Mon, 03 Aug 2026 18:32:21 +0000
Newsgroups dev.linux.lists.ntb,org.kernel.vger.linux-pci
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(=
s) to consider:
- [High] Packed outbound MW space is allocated but can never be mapped to t=
he host, rendering it unusable.
--

--- Patch [5]: [PATCH 05/11] PCI: endpoint: pci-epf-vntb: Allocate packed o=
utbound MW space ---
commit 1f91a957de194db5f5786ea1932b0222be01c3a2
Author: Koichiro Den <[email protected]>

PCI: endpoint: pci-epf-vntb: Allocate packed outbound MW space

A packed MW group can use one outbound iATU region only when its EPC
address range is contiguous.

Allocate one EPC address range for the group and expose each logical MW
as a subrange. Singleton MWs keep separate allocations.

> diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/=
endpoint/functions/pci-epf-vntb.c
> index 0c72b907c2896..aa8d304fe861f 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
[ ... ]
> @@ -926,6 +936,9 @@ static int epf_ntb_mw_bar_init(struct epf_ntb *ntb)
> =20
>  alloc_vpci_mw:
>  		/* Allocate EPC outbound memory windows to vpci vntb device */
> +		count =3D ntb->packed_mws ? ntb->packed_mws : 1;
> +		size =3D epf_ntb_mw_group_size(ntb, i, count);
> +		/* Only the group head owns the allocation handle. */
>  		ntb->vpci_mw_addr[i] =3D pci_epc_mem_alloc_addr(ntb->epf->epc,
>  							      &ntb->vpci_mw_phy[i],
>  							      size);

[Severity: High]
Will the newly allocated packed MW space ever be mapped to the host, or does
it remain unusable?

In epf_ntb_configure_mw() (which handles VHOST CMD_CONFIGURE_MW requests fr=
om
the host), the driver explicitly rejects packed groups:

drivers/pci/endpoint/functions/pci-epf-vntb.c:epf_ntb_configure_mw() {
	...
	ret =3D epf_ntb_get_mw_group(ntb, mw, NULL, &count);
	if (ret)
		return ret;
	if (count > 1)
		return -EOPNOTSUPP;
	...
}

Since mapping of packed groups returns -EOPNOTSUPP without calling
pci_epc_map_addr(), won't the configuration fail when requested by the host?
If so, does the memory allocated here go unused, preventing host memory acc=
ess
for packed MW groups?

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260803180439.1963=
[email protected]?part=3D5