From: "Christian König" <christian.koenig@amd.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: David1.Zhou@amd.com, Logan Gunthorpe <logang@deltatee.com>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
hch@infradead.org, linaro-mm-sig@lists.linaro.org,
linux-media@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH 4/6] drm/amdgpu: add checks if DMA-buf P2P is supported
Date: Wed, 11 Mar 2020 15:43:03 +0100 [thread overview]
Message-ID: <58916fcc-6d5e-4f6a-3de3-7bc90a4a5145@amd.com> (raw)
In-Reply-To: <20200311143835.GD31668@ziepe.ca>
Am 11.03.20 um 15:38 schrieb Jason Gunthorpe:
> On Wed, Mar 11, 2020 at 03:33:01PM +0100, Christian König wrote:
>> Am 11.03.20 um 15:04 schrieb Jason Gunthorpe:
>>> On Wed, Mar 11, 2020 at 02:51:56PM +0100, Christian König wrote:
>>>> Check if we can do peer2peer on the PCIe bus.
>>>>
>>>> Signed-off-by: Christian König <christian.koenig@amd.com>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 ++++
>>>> 1 file changed, 4 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
>>>> index aef12ee2f1e3..bbf67800c8a6 100644
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
>>>> @@ -38,6 +38,7 @@
>>>> #include <drm/amdgpu_drm.h>
>>>> #include <linux/dma-buf.h>
>>>> #include <linux/dma-fence-array.h>
>>>> +#include <linux/pci-p2pdma.h>
>>>> /**
>>>> * amdgpu_gem_prime_vmap - &dma_buf_ops.vmap implementation
>>>> @@ -179,6 +180,9 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
>>>> struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
>>>> int r;
>>>> + if (pci_p2pdma_distance_many(adev->pdev, &attach->dev, 1, true) < 0)
>>>> + attach->peer2peer = false;
>>>> +
>>> Are there other related patches than this series?
>>>
>>> p2p dma mapping needs to be done in common code, in p2pdma.c - ie this
>>> open coding is missing the bus_offset stuff, at least.
>> Yeah, I'm aware of this. But I couldn't find a better way for now.
> Well, it isn't optional :)
>
>>> I really do not want to see drivers open code this stuff.
>>>
>>> We already have a p2pdma API for handling the struct page case, so I
>>> suggest adding some new p2pdma API to handle this for non-struct page
>>> cases.
>>>
>>> ie some thing like:
>>>
>>> int 'p2pdma map bar'(
>>> struct pci_device *source,
>>> unsigned int source_bar_number,
>>> struct pci_device *dest,
>>> physaddr&len *array_of_offsets & length pairs into source bar,
>>> struct scatterlist *output_sgl)
>> Well that's exactly what I have to avoid since I don't have the array of
>> offsets around and want to avoid constructing it.
> Maybe it doesn't need an array of offsets - just a single offset and
> callers can iterate the API?
Yes, that would of course work as well.
But I was assuming that p2pdma_map_bar() needs some state between those
calls.
>
>> Similar problem for dma_map_resource(). My example does this on demand, but
>> essentially we also have use cases where this is done only once.
> I'm not sure if this is portable. Does any IOMMU HW need to know P2P
> is happening to setup successfully? We currently support such a narrow
> scope of HW for P2P..
On the AMD hardware I'm testing this calling dma_map_resource() already
seems to work with IOMMU enabled. (Well at least it seemed so 6month ago
when I last tested this).
>> Ideally we would have some function to create an sgl based on some arbitrary
>> collection of offsets and length inside a BAR.
> Isn't that what I just proposed above ?
Yes, just didn't thought that this would easily possible. I will double
check the p2pdma code again.
Thanks,
Christian.
>
> Jason
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-03-11 14:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 13:51 [Intel-gfx] P2P for DMA-buf Christian König
2020-03-11 13:51 ` [Intel-gfx] [PATCH 1/6] lib/scatterlist: add sg_set_dma_addr() function Christian König
2020-03-11 15:28 ` Christoph Hellwig
2020-03-12 10:14 ` Christian König
2020-03-12 10:19 ` Christoph Hellwig
2020-03-12 10:31 ` Christian König
2020-03-12 10:47 ` Christoph Hellwig
2020-03-12 11:02 ` Christian König
[not found] ` <20200312141928.GK31668@ziepe.ca>
2020-03-12 15:39 ` Christian König
2020-03-12 16:13 ` Logan Gunthorpe
2020-03-13 11:21 ` Christoph Hellwig
2020-03-13 13:33 ` Christian König
[not found] ` <20200313121742.GZ31668@ziepe.ca>
2020-03-16 8:56 ` Christoph Hellwig
2020-03-16 9:41 ` Christian König
2020-03-16 9:52 ` Christoph Hellwig
2020-03-11 13:51 ` [Intel-gfx] [PATCH 2/6] dma-buf: add peer2peer flag Christian König
2020-03-11 13:51 ` [Intel-gfx] [PATCH 3/6] drm/amdgpu: note that we can handle peer2peer DMA-buf Christian König
2020-03-11 13:51 ` [Intel-gfx] [PATCH 4/6] drm/amdgpu: add checks if DMA-buf P2P is supported Christian König
[not found] ` <20200311140415.GB31668@ziepe.ca>
2020-03-11 14:33 ` Christian König
[not found] ` <20200311143835.GD31668@ziepe.ca>
2020-03-11 14:43 ` Christian König [this message]
2020-03-11 13:51 ` [Intel-gfx] [PATCH 5/6] drm/amdgpu: add support for exporting VRAM using DMA-buf v2 Christian König
2020-03-11 15:08 ` Alex Deucher
2020-03-11 13:51 ` [Intel-gfx] [PATCH 6/6] drm/amdgpu: improve amdgpu_gem_info debugfs file Christian König
2020-03-11 18:09 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/6] lib/scatterlist: add sg_set_dma_addr() function Patchwork
2020-03-11 18:34 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
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=58916fcc-6d5e-4f6a-3de3-7bc90a4a5145@amd.com \
--to=christian.koenig@amd.com \
--cc=David1.Zhou@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@infradead.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=logang@deltatee.com \
/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;
as well as URLs for NNTP newsgroup(s).