On 2026-08-04 09:42, Matt Evans wrote:
>
> Just shoving an #ifdef in mlx5 isn't right, so would be grateful for
> your advice on the most tasteful resolution:
>
> 1. Imagining future drivers might use pcim_p2pdma_provider(), maybe
> p2pdma could export a `pcim_p2pdma_supported()` or similar which
> returns whether CONFIG_PCI_P2PDMA is present and P2P can ever work.
> A user of pcim_p2pdma_provider() is required to also check if P2P is
> overall supported.
>
> Ugliness aside, a driver could use #ifdef CONFIG_PCI_P2PDMA to test
> whether P2P is expected to work, except that doesn't stop modules
> falling into the same trap. I think a function export is better.
>
> 2. And/or a test (such the function from #1, or an #ifdef) in the IB
> core DMABUF path, to avoid individual drivers from doing the test in
> their .mmap_get_pfns(). Other future drivers would be expected to
> do similar.
>
> Any better ideas? Sorry I didn't catch this earlier in the review
> cycles, I know we've looked at this patch a few times now.
I see the problem now. Yes, it's a bit tricky and I don't have a great
answer. But the proposed solution seems very confusing. I definitely
don't think we should be adding ifdefs in the IB core for this.
For me, this is mainly a naming problem as there's a bunch of ways to
address it in the code. The question is what do we call p2pdma vs. core
p2pdma in a way that makes the distinction more obvious.
There's a vague convention for this already: the term 'p2pmem' is often
used for cases where the driver uses the allocator, etc. (I think I had
this intention when I wrote the code and have since forgotten about it).
I'm thinking we should lean into that more and instead of introducing
CONFIG_PCI_P2PDMA_CORE we introduce CONFIG_PCI_P2PMEM and move all that
code into it's own file, potentially renaming some functions. Then, in
the end, we would probably have a pcim_p2pdma_supported() function and a
pcim_p2pmem_supported() function, the latter being used by existing use
cases.
Logan