* [PATCH] drm/ttm: properly unmap dma page upon failure
@ 2019-03-25 20:22 Yu Zhao
2019-07-06 17:33 ` Yu Zhao
2019-08-21 19:09 ` Yu Zhao
0 siblings, 2 replies; 3+ messages in thread
From: Yu Zhao @ 2019-03-25 20:22 UTC (permalink / raw)
To: Christian Koenig, Huang Rui, Junwei Zhang, David Airlie, Daniel Vetter
Cc: dri-devel, linux-kernel, Yu Zhao
dma_unmap_page() must be called with exactly the same dma address
and size returned by dma_map_page(). Otherwise, the function may
fail.
This is at least the case for debug_dma_unmap_page() and AMD iommu
unmap_page callback.
Signed-off-by: Yu Zhao <yuzhao@google.com>
---
drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index f841accc2c00..c1636595f63c 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -1118,10 +1118,19 @@ int ttm_populate_and_map_pages(struct device *dev, struct ttm_dma_tt *tt,
0, num_pages * PAGE_SIZE,
DMA_BIDIRECTIONAL);
if (dma_mapping_error(dev, tt->dma_address[i])) {
+ num_pages = 1;
while (i--) {
+ if (i && tt->ttm.pages[i] -
+ tt->ttm.pages[i - 1] == 1) {
+ tt->dma_address[i] = 0;
+ num_pages++;
+ continue;
+ }
dma_unmap_page(dev, tt->dma_address[i],
- PAGE_SIZE, DMA_BIDIRECTIONAL);
+ num_pages * PAGE_SIZE,
+ DMA_BIDIRECTIONAL);
tt->dma_address[i] = 0;
+ num_pages = 1;
}
ttm_pool_unpopulate(&tt->ttm);
return -EFAULT;
--
2.21.0.392.gf8f6787159e-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/ttm: properly unmap dma page upon failure
2019-03-25 20:22 [PATCH] drm/ttm: properly unmap dma page upon failure Yu Zhao
@ 2019-07-06 17:33 ` Yu Zhao
2019-08-21 19:09 ` Yu Zhao
1 sibling, 0 replies; 3+ messages in thread
From: Yu Zhao @ 2019-07-06 17:33 UTC (permalink / raw)
To: Christian Koenig, Huang Rui, Junwei Zhang, David Airlie, Daniel Vetter
Cc: dri-devel, linux-kernel
On Mon, Mar 25, 2019 at 02:22:50PM -0600, Yu Zhao wrote:
> dma_unmap_page() must be called with exactly the same dma address
> and size returned by dma_map_page(). Otherwise, the function may
> fail.
>
> This is at least the case for debug_dma_unmap_page() and AMD iommu
> unmap_page callback.
Hi, can we please take this fix? Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/ttm: properly unmap dma page upon failure
2019-03-25 20:22 [PATCH] drm/ttm: properly unmap dma page upon failure Yu Zhao
2019-07-06 17:33 ` Yu Zhao
@ 2019-08-21 19:09 ` Yu Zhao
1 sibling, 0 replies; 3+ messages in thread
From: Yu Zhao @ 2019-08-21 19:09 UTC (permalink / raw)
To: Christian Koenig, Huang Rui, Junwei Zhang, David Airlie, Daniel Vetter
Cc: linux-kernel, dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 2132 bytes --]
Probably my previous emails went into the spam folder. Another friendly
reminder using web version of my Gmail. Thank you.
On Mon, Mar 25, 2019 at 2:22 PM Yu Zhao <yuzhao@google.com> wrote:
> dma_unmap_page() must be called with exactly the same dma address
> and size returned by dma_map_page(). Otherwise, the function may
> fail.
>
> This is at least the case for debug_dma_unmap_page() and AMD iommu
> unmap_page callback.
>
> Signed-off-by: Yu Zhao <yuzhao@google.com>
> ---
> drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c
> b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> index f841accc2c00..c1636595f63c 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> @@ -1118,10 +1118,19 @@ int ttm_populate_and_map_pages(struct device *dev,
> struct ttm_dma_tt *tt,
> 0, num_pages * PAGE_SIZE,
> DMA_BIDIRECTIONAL);
> if (dma_mapping_error(dev, tt->dma_address[i])) {
> + num_pages = 1;
> while (i--) {
> + if (i && tt->ttm.pages[i] -
> + tt->ttm.pages[i - 1] == 1) {
> + tt->dma_address[i] = 0;
> + num_pages++;
> + continue;
> + }
> dma_unmap_page(dev, tt->dma_address[i],
> - PAGE_SIZE,
> DMA_BIDIRECTIONAL);
> + num_pages * PAGE_SIZE,
> + DMA_BIDIRECTIONAL);
> tt->dma_address[i] = 0;
> + num_pages = 1;
> }
> ttm_pool_unpopulate(&tt->ttm);
> return -EFAULT;
> --
> 2.21.0.392.gf8f6787159e-goog
>
>
[-- Attachment #1.2: Type: text/html, Size: 2992 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-21 19:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-25 20:22 [PATCH] drm/ttm: properly unmap dma page upon failure Yu Zhao
2019-07-06 17:33 ` Yu Zhao
2019-08-21 19:09 ` Yu Zhao
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.