From: Jason Gunthorpe <jgg@ziepe.ca>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: 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: [PATCH 5/6] drm/amdgpu: add support for exporting VRAM using DMA-buf v2
Date: Wed, 11 Mar 2020 11:33:35 -0300 [thread overview]
Message-ID: <20200311143335.GC31668@ziepe.ca> (raw)
In-Reply-To: <20200311135158.3310-6-christian.koenig@amd.com>
On Wed, Mar 11, 2020 at 02:51:57PM +0100, Christian König wrote:
> +/**
> + * 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)
single ** pointer with an int return is odd, use ERR_PTR?
> +{
> + 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_dma_addr(sg, addr, size, 0);
Is it possible that phys will need to have contiguous pages joined
here, or has 'node' already ensured contiguous pages?
Jason
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-03-12 8:09 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 13:51 P2P for DMA-buf Christian König
2020-03-11 13:51 ` [PATCH 1/6] lib/scatterlist: add sg_set_dma_addr() function Christian König
[not found] ` <20200311152838.GA24280@infradead.org>
2020-03-12 10:14 ` Christian König
[not found] ` <20200312101943.GA14618@infradead.org>
2020-03-12 10:31 ` Christian König
[not found] ` <20200312104729.GA26031@infradead.org>
2020-03-12 11:02 ` Christian König
2020-03-12 14:19 ` Jason Gunthorpe
2020-03-12 15:39 ` Christian König
2020-03-12 16:19 ` Jason Gunthorpe
2020-03-12 16:13 ` Logan Gunthorpe
[not found] ` <20200313112139.GA4913@infradead.org>
2020-03-13 12:17 ` Jason Gunthorpe
[not found] ` <20200316085642.GC1831@infradead.org>
2020-03-16 9:41 ` Christian König
[not found] ` <20200316095213.GA29212@infradead.org>
2020-03-16 12:37 ` Jason Gunthorpe
2020-03-13 13:33 ` Christian König
2020-03-11 13:51 ` [PATCH 2/6] dma-buf: add peer2peer flag Christian König
2020-03-11 13:51 ` [PATCH 3/6] drm/amdgpu: note that we can handle peer2peer DMA-buf Christian König
2020-03-11 13:51 ` [PATCH 4/6] drm/amdgpu: add checks if DMA-buf P2P is supported Christian König
2020-03-11 14:04 ` Jason Gunthorpe
2020-03-11 14:33 ` Christian König
2020-03-11 14:38 ` Jason Gunthorpe
2020-03-11 14:43 ` Christian König
2020-03-11 14:48 ` Jason Gunthorpe
2020-03-11 13:51 ` [PATCH 5/6] drm/amdgpu: add support for exporting VRAM using DMA-buf v2 Christian König
2020-03-11 14:33 ` Jason Gunthorpe [this message]
2020-03-11 14:39 ` Jason Gunthorpe
2020-03-11 15:08 ` Alex Deucher
2020-03-11 13:51 ` [PATCH 6/6] drm/amdgpu: improve amdgpu_gem_info debugfs file Christian König
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=20200311143335.GC31668@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@infradead.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.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).