* [PATCH] drm/ttm: Add helper functions to populate/map in one call
@ 2017-08-18 14:07 Tom St Denis
[not found] ` <20170818140727.8342-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Tom St Denis @ 2017-08-18 14:07 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
These functions replace a section of common code found
in radeon/amdgpu drivers (and possibly others) as part
of the ttm_tt_*populate() callbacks.
Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
---
drivers/gpu/drm/ttm/ttm_page_alloc.c | 41 ++++++++++++++++++++++++++++++++++++
include/drm/ttm/ttm_page_alloc.h | 11 ++++++++++
2 files changed, 52 insertions(+)
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index 871599826773..6a660d196d87 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -920,6 +920,47 @@ void ttm_pool_unpopulate(struct ttm_tt *ttm)
}
EXPORT_SYMBOL(ttm_pool_unpopulate);
+int ttm_populate_and_map_pages(struct device *dev, struct ttm_dma_tt *tt)
+{
+ unsigned i;
+ int r;
+
+ r = ttm_pool_populate(&tt->ttm);
+ if (r)
+ return r;
+
+ for (i = 0; i < tt->ttm.num_pages; i++) {
+ tt->dma_address[i] = dma_map_page(dev, tt->ttm.pages[i],
+ 0, PAGE_SIZE,
+ DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(dev, tt->dma_address[i])) {
+ while (i--) {
+ dma_unmap_page(dev, tt->dma_address[i],
+ PAGE_SIZE, DMA_BIDIRECTIONAL);
+ tt->dma_address[i] = 0;
+ }
+ ttm_pool_unpopulate(&tt->ttm);
+ return -EFAULT;
+ }
+ }
+ return 0;
+}
+EXPORT_SYMBOL(ttm_populate_and_map_pages);
+
+void ttm_unmap_and_unpopulate_pages(struct device *dev, struct ttm_dma_tt *tt)
+{
+ unsigned i;
+
+ for (i = 0; i < tt->ttm.num_pages; i++) {
+ if (tt->dma_address[i]) {
+ dma_unmap_page(dev, tt->dma_address[i],
+ PAGE_SIZE, DMA_BIDIRECTIONAL);
+ }
+ }
+ ttm_pool_unpopulate(&tt->ttm);
+}
+EXPORT_SYMBOL(ttm_unmap_and_unpopulate_pages);
+
int ttm_page_alloc_debugfs(struct seq_file *m, void *data)
{
struct ttm_page_pool *p;
diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
index 49a828425fa2..8695918ea629 100644
--- a/include/drm/ttm/ttm_page_alloc.h
+++ b/include/drm/ttm/ttm_page_alloc.h
@@ -83,6 +83,17 @@ extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
+
+/**
+ * Populates and DMA maps pages to fullfil a ttm_dma_populate() request
+ */
+int ttm_populate_and_map_pages(struct device *dev, struct ttm_dma_tt *tt);
+
+/**
+ * Unpopulates and DMA unmaps pages as part of a
+ * ttm_dma_unpopulate() request */
+void ttm_unmap_and_unpopulate_pages(struct device *dev, struct ttm_dma_tt *tt);
+
#else
static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob,
unsigned max_pages)
--
2.12.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/ttm: Add helper functions to populate/map in one call
[not found] ` <20170818140727.8342-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
@ 2017-08-22 11:13 ` Tom St Denis
[not found] ` <31be281b-7293-e7ef-1130-e8b6f5a01e2f-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Tom St Denis @ 2017-08-22 11:13 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
ping? Haven't seen any comments on amd-gfx or dri-devel.
Cheers,
Tom
On 18/08/17 10:07 AM, Tom St Denis wrote:
> These functions replace a section of common code found
> in radeon/amdgpu drivers (and possibly others) as part
> of the ttm_tt_*populate() callbacks.
>
> Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
> ---
> drivers/gpu/drm/ttm/ttm_page_alloc.c | 41 ++++++++++++++++++++++++++++++++++++
> include/drm/ttm/ttm_page_alloc.h | 11 ++++++++++
> 2 files changed, 52 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> index 871599826773..6a660d196d87 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> @@ -920,6 +920,47 @@ void ttm_pool_unpopulate(struct ttm_tt *ttm)
> }
> EXPORT_SYMBOL(ttm_pool_unpopulate);
>
> +int ttm_populate_and_map_pages(struct device *dev, struct ttm_dma_tt *tt)
> +{
> + unsigned i;
> + int r;
> +
> + r = ttm_pool_populate(&tt->ttm);
> + if (r)
> + return r;
> +
> + for (i = 0; i < tt->ttm.num_pages; i++) {
> + tt->dma_address[i] = dma_map_page(dev, tt->ttm.pages[i],
> + 0, PAGE_SIZE,
> + DMA_BIDIRECTIONAL);
> + if (dma_mapping_error(dev, tt->dma_address[i])) {
> + while (i--) {
> + dma_unmap_page(dev, tt->dma_address[i],
> + PAGE_SIZE, DMA_BIDIRECTIONAL);
> + tt->dma_address[i] = 0;
> + }
> + ttm_pool_unpopulate(&tt->ttm);
> + return -EFAULT;
> + }
> + }
> + return 0;
> +}
> +EXPORT_SYMBOL(ttm_populate_and_map_pages);
> +
> +void ttm_unmap_and_unpopulate_pages(struct device *dev, struct ttm_dma_tt *tt)
> +{
> + unsigned i;
> +
> + for (i = 0; i < tt->ttm.num_pages; i++) {
> + if (tt->dma_address[i]) {
> + dma_unmap_page(dev, tt->dma_address[i],
> + PAGE_SIZE, DMA_BIDIRECTIONAL);
> + }
> + }
> + ttm_pool_unpopulate(&tt->ttm);
> +}
> +EXPORT_SYMBOL(ttm_unmap_and_unpopulate_pages);
> +
> int ttm_page_alloc_debugfs(struct seq_file *m, void *data)
> {
> struct ttm_page_pool *p;
> diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
> index 49a828425fa2..8695918ea629 100644
> --- a/include/drm/ttm/ttm_page_alloc.h
> +++ b/include/drm/ttm/ttm_page_alloc.h
> @@ -83,6 +83,17 @@ extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
> extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
> extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
>
> +
> +/**
> + * Populates and DMA maps pages to fullfil a ttm_dma_populate() request
> + */
> +int ttm_populate_and_map_pages(struct device *dev, struct ttm_dma_tt *tt);
> +
> +/**
> + * Unpopulates and DMA unmaps pages as part of a
> + * ttm_dma_unpopulate() request */
> +void ttm_unmap_and_unpopulate_pages(struct device *dev, struct ttm_dma_tt *tt);
> +
> #else
> static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob,
> unsigned max_pages)
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/ttm: Add helper functions to populate/map in one call
[not found] ` <31be281b-7293-e7ef-1130-e8b6f5a01e2f-5C7GfCeVMHo@public.gmane.org>
@ 2017-08-22 12:51 ` Christian König
0 siblings, 0 replies; 3+ messages in thread
From: Christian König @ 2017-08-22 12:51 UTC (permalink / raw)
To: Tom St Denis, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Reviewed-by: Christian König <christian.koenig@amd.com> for this one as
well as the two patches for radeon and amdgpu.
Feel free to also add my Acked-by to the nouveau patch.
Regards,
Christian.
Am 22.08.2017 um 13:13 schrieb Tom St Denis:
> ping? Haven't seen any comments on amd-gfx or dri-devel.
>
> Cheers,
> Tom
>
>
> On 18/08/17 10:07 AM, Tom St Denis wrote:
>> These functions replace a section of common code found
>> in radeon/amdgpu drivers (and possibly others) as part
>> of the ttm_tt_*populate() callbacks.
>>
>> Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
>> ---
>> drivers/gpu/drm/ttm/ttm_page_alloc.c | 41
>> ++++++++++++++++++++++++++++++++++++
>> include/drm/ttm/ttm_page_alloc.h | 11 ++++++++++
>> 2 files changed, 52 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c
>> b/drivers/gpu/drm/ttm/ttm_page_alloc.c
>> index 871599826773..6a660d196d87 100644
>> --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
>> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
>> @@ -920,6 +920,47 @@ void ttm_pool_unpopulate(struct ttm_tt *ttm)
>> }
>> EXPORT_SYMBOL(ttm_pool_unpopulate);
>> +int ttm_populate_and_map_pages(struct device *dev, struct
>> ttm_dma_tt *tt)
>> +{
>> + unsigned i;
>> + int r;
>> +
>> + r = ttm_pool_populate(&tt->ttm);
>> + if (r)
>> + return r;
>> +
>> + for (i = 0; i < tt->ttm.num_pages; i++) {
>> + tt->dma_address[i] = dma_map_page(dev, tt->ttm.pages[i],
>> + 0, PAGE_SIZE,
>> + DMA_BIDIRECTIONAL);
>> + if (dma_mapping_error(dev, tt->dma_address[i])) {
>> + while (i--) {
>> + dma_unmap_page(dev, tt->dma_address[i],
>> + PAGE_SIZE, DMA_BIDIRECTIONAL);
>> + tt->dma_address[i] = 0;
>> + }
>> + ttm_pool_unpopulate(&tt->ttm);
>> + return -EFAULT;
>> + }
>> + }
>> + return 0;
>> +}
>> +EXPORT_SYMBOL(ttm_populate_and_map_pages);
>> +
>> +void ttm_unmap_and_unpopulate_pages(struct device *dev, struct
>> ttm_dma_tt *tt)
>> +{
>> + unsigned i;
>> +
>> + for (i = 0; i < tt->ttm.num_pages; i++) {
>> + if (tt->dma_address[i]) {
>> + dma_unmap_page(dev, tt->dma_address[i],
>> + PAGE_SIZE, DMA_BIDIRECTIONAL);
>> + }
>> + }
>> + ttm_pool_unpopulate(&tt->ttm);
>> +}
>> +EXPORT_SYMBOL(ttm_unmap_and_unpopulate_pages);
>> +
>> int ttm_page_alloc_debugfs(struct seq_file *m, void *data)
>> {
>> struct ttm_page_pool *p;
>> diff --git a/include/drm/ttm/ttm_page_alloc.h
>> b/include/drm/ttm/ttm_page_alloc.h
>> index 49a828425fa2..8695918ea629 100644
>> --- a/include/drm/ttm/ttm_page_alloc.h
>> +++ b/include/drm/ttm/ttm_page_alloc.h
>> @@ -83,6 +83,17 @@ extern int ttm_dma_page_alloc_debugfs(struct
>> seq_file *m, void *data);
>> extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct
>> device *dev);
>> extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct
>> device *dev);
>> +
>> +/**
>> + * Populates and DMA maps pages to fullfil a ttm_dma_populate() request
>> + */
>> +int ttm_populate_and_map_pages(struct device *dev, struct ttm_dma_tt
>> *tt);
>> +
>> +/**
>> + * Unpopulates and DMA unmaps pages as part of a
>> + * ttm_dma_unpopulate() request */
>> +void ttm_unmap_and_unpopulate_pages(struct device *dev, struct
>> ttm_dma_tt *tt);
>> +
>> #else
>> static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob,
>> unsigned max_pages)
>>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-22 12:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-18 14:07 [PATCH] drm/ttm: Add helper functions to populate/map in one call Tom St Denis
[not found] ` <20170818140727.8342-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2017-08-22 11:13 ` Tom St Denis
[not found] ` <31be281b-7293-e7ef-1130-e8b6f5a01e2f-5C7GfCeVMHo@public.gmane.org>
2017-08-22 12:51 ` Christian König
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).