From: Jason Gunthorpe <jgg@mellanox.com>
To: "Dave Airlie" <airlied@gmail.com>,
"Christoph Hellwig" <hch@infradead.org>,
"Christian König" <christian.koenig@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
Logan Gunthorpe <logang@deltatee.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [git pull] drm for 5.8-rc1
Date: Wed, 3 Jun 2020 17:13:37 -0300 [thread overview]
Message-ID: <20200603201337.GA225528@ziepe.ca> (raw)
In-Reply-To: <CAPM=9txGww+omvateOTizZRV9_wLdAbq6uAz3DRa_S6bn1jQuQ@mail.gmail.com>
On Tue, Jun 02, 2020 at 04:06:32PM +1000, Dave Airlie wrote:
> Hi Linus,
>
> This is the main drm pull request for 5.8-rc1.
>
> Highlights:
> Core DRM had a lot of refactoring around managed drm resources to make
> drivers simpler.
> Intel Tigerlake support is on by default
> amdgpu now support p2p PCI buffer sharing and encrypted GPU memory
Christoph Hellwig basically NAK'd this approach, why is it getting
merged all of a sudden??
https://lore.kernel.org/intel-gfx/20200311152838.GA24280@infradead.org/
Are we now OK with this same approach open coded in a driver?
This wasn't Cc'd to the usual people doing work in this PCI P2P area??
See
commit f44ffd677fb3562ac0a1ff9c8ae52672be741f00
Author: Christian König <christian.koenig@amd.com>
Date: Fri Mar 23 16:56:37 2018 +0100
drm/amdgpu: add support for exporting VRAM using DMA-buf v3
We should be able to do this now after checking all the prerequisites.
v2: fix entrie count in the sgt
v3: manually construct the sg
Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/359295
[..]
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 82a3299e53c042..128a667ed8fa0d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -22,6 +22,7 @@
* Authors: Christian König
*/
+#include <linux/dma-mapping.h>
#include "amdgpu.h"
#include "amdgpu_vm.h"
#include "amdgpu_atomfirmware.h"
@@ -458,6 +459,104 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
mem->mm_node = NULL;
}
+/**
+ * amdgpu_vram_mgr_alloc_sgt - allocate and fill a sg table
+ *
+ * @adev: amdgpu device pointer
+ * @mem: TTM memory object
+ * @dev: the other device
+ * @dir: dma direction
+ * @sgt: resulting sg table
+ *
+ * Allocate and fill a sg table from a VRAM allocation.
+ */
+int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
+ struct ttm_mem_reg *mem,
+ struct device *dev,
+ enum dma_data_direction dir,
+ struct sg_table **sgt)
+{
+ struct drm_mm_node *node;
+ struct scatterlist *sg;
+ int num_entries = 0;
+ unsigned int pages;
+ int i, r;
+
+ *sgt = kmalloc(sizeof(*sg), GFP_KERNEL);
+ if (!*sgt)
+ return -ENOMEM;
+
+ for (pages = mem->num_pages, node = mem->mm_node;
+ pages; pages -= node->size, ++node)
+ ++num_entries;
+
+ r = sg_alloc_table(*sgt, num_entries, GFP_KERNEL);
+ if (r)
+ goto error_free;
+
+ for_each_sg((*sgt)->sgl, sg, num_entries, i)
+ sg->length = 0;
+
+ node = mem->mm_node;
+ for_each_sg((*sgt)->sgl, sg, num_entries, i) {
+ phys_addr_t phys = (node->start << PAGE_SHIFT) +
+ adev->gmc.aper_base;
+ size_t size = node->size << PAGE_SHIFT;
+ dma_addr_t addr;
+
+ ++node;
+ addr = dma_map_resource(dev, phys, size, dir,
+ DMA_ATTR_SKIP_CPU_SYNC);
+ r = dma_mapping_error(dev, addr);
+ if (r)
+ goto error_unmap;
+
+ sg_set_page(sg, NULL, size, 0);
+ sg_dma_address(sg) = addr;
+ sg_dma_len(sg) = size;
^^^^^^^^^^^^^^
Jason
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgg@mellanox.com>
To: "Dave Airlie" <airlied@gmail.com>,
"Christoph Hellwig" <hch@infradead.org>,
"Christian König" <christian.koenig@amd.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
dri-devel <dri-devel@lists.freedesktop.org>,
LKML <linux-kernel@vger.kernel.org>,
Logan Gunthorpe <logang@deltatee.com>
Subject: Re: [git pull] drm for 5.8-rc1
Date: Wed, 3 Jun 2020 17:13:37 -0300 [thread overview]
Message-ID: <20200603201337.GA225528@ziepe.ca> (raw)
In-Reply-To: <CAPM=9txGww+omvateOTizZRV9_wLdAbq6uAz3DRa_S6bn1jQuQ@mail.gmail.com>
On Tue, Jun 02, 2020 at 04:06:32PM +1000, Dave Airlie wrote:
> Hi Linus,
>
> This is the main drm pull request for 5.8-rc1.
>
> Highlights:
> Core DRM had a lot of refactoring around managed drm resources to make
> drivers simpler.
> Intel Tigerlake support is on by default
> amdgpu now support p2p PCI buffer sharing and encrypted GPU memory
Christoph Hellwig basically NAK'd this approach, why is it getting
merged all of a sudden??
https://lore.kernel.org/intel-gfx/20200311152838.GA24280@infradead.org/
Are we now OK with this same approach open coded in a driver?
This wasn't Cc'd to the usual people doing work in this PCI P2P area??
See
commit f44ffd677fb3562ac0a1ff9c8ae52672be741f00
Author: Christian König <christian.koenig@amd.com>
Date: Fri Mar 23 16:56:37 2018 +0100
drm/amdgpu: add support for exporting VRAM using DMA-buf v3
We should be able to do this now after checking all the prerequisites.
v2: fix entrie count in the sgt
v3: manually construct the sg
Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/359295
[..]
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 82a3299e53c042..128a667ed8fa0d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -22,6 +22,7 @@
* Authors: Christian König
*/
+#include <linux/dma-mapping.h>
#include "amdgpu.h"
#include "amdgpu_vm.h"
#include "amdgpu_atomfirmware.h"
@@ -458,6 +459,104 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
mem->mm_node = NULL;
}
+/**
+ * amdgpu_vram_mgr_alloc_sgt - allocate and fill a sg table
+ *
+ * @adev: amdgpu device pointer
+ * @mem: TTM memory object
+ * @dev: the other device
+ * @dir: dma direction
+ * @sgt: resulting sg table
+ *
+ * Allocate and fill a sg table from a VRAM allocation.
+ */
+int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
+ struct ttm_mem_reg *mem,
+ struct device *dev,
+ enum dma_data_direction dir,
+ struct sg_table **sgt)
+{
+ struct drm_mm_node *node;
+ struct scatterlist *sg;
+ int num_entries = 0;
+ unsigned int pages;
+ int i, r;
+
+ *sgt = kmalloc(sizeof(*sg), GFP_KERNEL);
+ if (!*sgt)
+ return -ENOMEM;
+
+ for (pages = mem->num_pages, node = mem->mm_node;
+ pages; pages -= node->size, ++node)
+ ++num_entries;
+
+ r = sg_alloc_table(*sgt, num_entries, GFP_KERNEL);
+ if (r)
+ goto error_free;
+
+ for_each_sg((*sgt)->sgl, sg, num_entries, i)
+ sg->length = 0;
+
+ node = mem->mm_node;
+ for_each_sg((*sgt)->sgl, sg, num_entries, i) {
+ phys_addr_t phys = (node->start << PAGE_SHIFT) +
+ adev->gmc.aper_base;
+ size_t size = node->size << PAGE_SHIFT;
+ dma_addr_t addr;
+
+ ++node;
+ addr = dma_map_resource(dev, phys, size, dir,
+ DMA_ATTR_SKIP_CPU_SYNC);
+ r = dma_mapping_error(dev, addr);
+ if (r)
+ goto error_unmap;
+
+ sg_set_page(sg, NULL, size, 0);
+ sg_dma_address(sg) = addr;
+ sg_dma_len(sg) = size;
^^^^^^^^^^^^^^
Jason
next prev parent reply other threads:[~2020-06-04 7:12 UTC|newest]
Thread overview: 103+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 6:06 [git pull] drm for 5.8-rc1 Dave Airlie
2020-06-02 6:06 ` Dave Airlie
2020-06-02 21:21 ` Linus Torvalds
2020-06-02 21:21 ` Linus Torvalds
2020-06-02 21:22 ` Linus Torvalds
2020-06-02 21:22 ` Linus Torvalds
2020-06-02 21:56 ` Linus Torvalds
2020-06-02 21:56 ` Linus Torvalds
2020-06-03 7:18 ` Thomas Zimmermann
2020-06-03 7:18 ` Thomas Zimmermann
2020-06-03 7:43 ` Daniel Vetter
2020-06-03 7:43 ` Daniel Vetter
2020-06-02 22:14 ` Linus Torvalds
2020-06-02 22:14 ` Linus Torvalds
2020-06-02 23:03 ` Dave Airlie
2020-06-02 23:03 ` Dave Airlie
2020-06-02 22:20 ` pr-tracker-bot
2020-06-02 22:20 ` pr-tracker-bot
2020-06-03 20:13 ` Jason Gunthorpe [this message]
2020-06-03 20:13 ` Jason Gunthorpe
2020-06-04 8:10 ` Christian König
2020-06-04 8:10 ` Christian König
2020-06-04 8:13 ` Christoph Hellwig
2020-06-30 23:08 ` Kirill A. Shutemov
2020-06-30 23:08 ` Kirill A. Shutemov
2020-07-01 4:40 ` James Jones
2020-07-01 4:40 ` James Jones
2020-07-01 7:57 ` Kirill A. Shutemov
2020-07-01 7:57 ` Kirill A. Shutemov
2020-07-01 7:59 ` Kirill A. Shutemov
2020-07-01 7:59 ` Kirill A. Shutemov
2020-07-01 19:45 ` James Jones
2020-07-01 19:45 ` James Jones
2020-07-02 7:36 ` Daniel Vetter
2020-07-02 7:36 ` Daniel Vetter
2020-07-02 7:59 ` Pekka Paalanen
2020-07-02 7:59 ` Pekka Paalanen
2020-07-02 8:22 ` Daniel Stone
2020-07-02 8:22 ` Daniel Stone
2020-07-02 21:14 ` James Jones
2020-07-02 21:14 ` James Jones
2020-07-03 6:01 ` James Jones
2020-07-03 6:01 ` James Jones
2020-07-03 7:16 ` Daniel Vetter
2020-07-03 7:16 ` Daniel Vetter
2020-07-13 1:37 ` Dave Airlie
2020-07-14 14:31 ` James Jones
2020-08-04 8:58 ` Karol Herbst
2020-08-12 0:19 ` James Jones
2020-08-12 10:27 ` Karol Herbst
2020-08-12 10:43 ` Karol Herbst
2020-08-12 12:24 ` Karol Herbst
2020-08-12 12:37 ` Ilia Mirkin
2020-08-12 17:03 ` James Jones
2020-08-12 17:10 ` Karol Herbst
2020-08-12 17:19 ` James Jones
2020-08-12 17:40 ` Alyssa Rosenzweig
2020-08-12 18:24 ` James Jones
2020-08-12 18:51 ` Karol Herbst
2020-08-13 13:00 ` Karol Herbst
2020-08-13 15:39 ` Karol Herbst
2020-08-13 17:19 ` Karol Herbst
2020-08-13 17:45 ` James Jones
2020-08-13 17:48 ` Karol Herbst
2020-08-14 13:57 ` Thierry Reding
2020-08-14 13:59 ` Karol Herbst
2020-08-14 14:10 ` Thierry Reding
2020-08-14 14:05 ` Thierry Reding
2020-08-14 14:44 ` Karol Herbst
2020-08-14 15:34 ` Thierry Reding
2020-08-14 15:40 ` Karol Herbst
2020-08-14 16:06 ` Thierry Reding
2020-08-14 16:12 ` Karol Herbst
2020-08-14 16:22 ` Thierry Reding
2020-08-14 17:17 ` Daniel Stone
2020-08-14 17:25 ` Daniel Vetter
2020-08-18 14:37 ` Thierry Reding
2020-09-01 7:13 ` Daniel Vetter
2020-09-01 10:42 ` Daniel Stone
2020-09-01 10:59 ` Karol Herbst
2020-09-01 14:42 ` James Jones
2020-08-14 14:08 ` Thierry Reding
2020-08-14 14:45 ` Karol Herbst
2020-08-14 15:24 ` Thierry Reding
2020-08-14 15:43 ` Karol Herbst
2020-08-14 13:54 ` Thierry Reding
2020-08-14 13:40 ` Thierry Reding
2020-08-14 13:56 ` Karol Herbst
2020-08-12 15:05 ` Thierry Reding
2020-08-12 15:20 ` Karol Herbst
2020-08-12 15:49 ` Karol Herbst
2020-07-01 11:24 ` Karol Herbst
2020-07-01 11:24 ` Karol Herbst
2020-07-01 15:51 ` James Jones
2020-07-01 15:51 ` James Jones
2020-07-01 16:01 ` Daniel Vetter
2020-07-01 16:01 ` Daniel Vetter
2020-07-01 17:04 ` Karol Herbst
2020-07-01 17:04 ` Karol Herbst
2020-07-01 17:37 ` James Jones
2020-07-01 17:37 ` James Jones
2020-07-01 18:08 ` Karol Herbst
2020-07-01 18:08 ` Karol Herbst
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=20200603201337.GA225528@ziepe.ca \
--to=jgg@mellanox.com \
--cc=airlied@gmail.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.