dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Jason Gunthorpe <jgg@mellanox.com>,
	Dave Airlie <airlied@gmail.com>,
	Christoph Hellwig <hch@infradead.org>
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: Thu, 4 Jun 2020 10:10:21 +0200	[thread overview]
Message-ID: <1d1ad025-e215-da23-5282-bbaf154fa979@amd.com> (raw)
In-Reply-To: <20200603201337.GA225528@ziepe.ca>

Am 03.06.20 um 22:13 schrieb Jason Gunthorpe:
> 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??

Dave and Daniel explicitly said they want to have this and it is ok as 
long as I open code it in the driver and keep it AMD internal.

We have that in discussion for years now and constructing/using the sg 
table is actually only the very minor piece of it. On the other hand 
there is a lot of work underway to get rid of abusing the sg tables as well.

>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fintel-gfx%2F20200311152838.GA24280%40infradead.org%2F&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7C55b238b9104d4a8d4feb08d807faa11c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637268120315706063&amp;sdata=AgVJ45%2Ft%2FVYkyIGIGgMrop69XLQReLDpF0ahL5rjEjo%3D&amp;reserved=0
>
> Are we now OK with this same approach open coded in a driver?

Intel is apparently doing this as well for years, see the i915 driver 
internals.

> This wasn't Cc'd to the usual people doing work in this PCI P2P area??

I certainly prefer a common framework for this, but when my upstream 
maintainer says he wants to take this who am I to object?

Christian.

>
> 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://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.freedesktop.org%2Fpatch%2F359295&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7C55b238b9104d4a8d4feb08d807faa11c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637268120315706063&amp;sdata=YzNvxBVOf5hcUm5KjOzzV%2FcHG5jdGEYmrI76PQN9v3U%3D&amp;reserved=0
>
> [..]
>
> 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

  reply	other threads:[~2020-06-04  8:10 UTC|newest]

Thread overview: 74+ 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 21:21 ` Linus Torvalds
2020-06-02 21:22   ` Linus Torvalds
2020-06-02 21:56   ` Linus Torvalds
2020-06-03  7:18     ` Thomas Zimmermann
2020-06-03  7:43       ` Daniel Vetter
2020-06-02 22:14 ` Linus Torvalds
2020-06-02 23:03   ` Dave Airlie
2020-06-02 22:20 ` pr-tracker-bot
2020-06-03 20:13 ` Jason Gunthorpe
2020-06-04  8:10   ` Christian König [this message]
2020-06-30 23:08 ` Kirill A. Shutemov
2020-07-01  4:40   ` James Jones
2020-07-01  7:57     ` Kirill A. Shutemov
2020-07-01  7:59       ` Kirill A. Shutemov
2020-07-01 19:45         ` James Jones
2020-07-02  7:36           ` Daniel Vetter
2020-07-02  7:59           ` Pekka Paalanen
2020-07-02  8:22           ` Daniel Stone
2020-07-02 21:14             ` James Jones
2020-07-03  6:01               ` James Jones
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 15:51       ` James Jones
2020-07-01 16:01         ` Daniel Vetter
2020-07-01 17:04           ` Karol Herbst
2020-07-01 17:37             ` James Jones
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=1d1ad025-e215-da23-5282-bbaf154fa979@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hch@infradead.org \
    --cc=jgg@mellanox.com \
    --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 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).