* [PATCH] drm/ttm: fix the tt_populated check in ttm_tt_destroy()
@ 2013-09-17 4:21 Ben Skeggs
2013-09-17 6:40 ` Thomas Hellstrom
0 siblings, 1 reply; 2+ messages in thread
From: Ben Skeggs @ 2013-09-17 4:21 UTC (permalink / raw)
To: dri-devel; +Cc: Jerome Glisse, Ben Skeggs, Thomas Hellstrom
From: Ben Skeggs <bskeggs@redhat.com>
After a vmalloc failure in ttm_dma_tt_alloc_page_directory(),
ttm_dma_tt_init() will call ttm_tt_destroy() to cleanup, and end up
inside the driver's unpopulate() hook when populate() has never yet
been called.
On nouveau, the first issue to be hit because of this is that
dma_address[] may be a NULL pointer. After working around this,
ttm_pool_unpopulate() may potentially hit the same issue with
the pages[] array.
It seems to make more sense to avoid calling unpopulate on already
unpopulated TTMs than to add checks to all the implementations.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
---
drivers/gpu/drm/ttm/ttm_tt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 5e93a52..210d503 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -170,7 +170,7 @@ void ttm_tt_destroy(struct ttm_tt *ttm)
ttm_tt_unbind(ttm);
}
- if (likely(ttm->pages != NULL)) {
+ if (ttm->state == tt_unbound) {
ttm->bdev->driver->ttm_tt_unpopulate(ttm);
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/ttm: fix the tt_populated check in ttm_tt_destroy()
2013-09-17 4:21 [PATCH] drm/ttm: fix the tt_populated check in ttm_tt_destroy() Ben Skeggs
@ 2013-09-17 6:40 ` Thomas Hellstrom
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Hellstrom @ 2013-09-17 6:40 UTC (permalink / raw)
To: Ben Skeggs; +Cc: Jerome Glisse, Ben Skeggs, dri-devel
On 09/17/2013 06:21 AM, Ben Skeggs wrote:
> From: Ben Skeggs <bskeggs@redhat.com>
>
> After a vmalloc failure in ttm_dma_tt_alloc_page_directory(),
> ttm_dma_tt_init() will call ttm_tt_destroy() to cleanup, and end up
> inside the driver's unpopulate() hook when populate() has never yet
> been called.
>
> On nouveau, the first issue to be hit because of this is that
> dma_address[] may be a NULL pointer. After working around this,
> ttm_pool_unpopulate() may potentially hit the same issue with
> the pages[] array.
>
> It seems to make more sense to avoid calling unpopulate on already
> unpopulated TTMs than to add checks to all the implementations.
>
> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
> Cc: Jerome Glisse <jglisse@redhat.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> ---
> drivers/gpu/drm/ttm/ttm_tt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index 5e93a52..210d503 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -170,7 +170,7 @@ void ttm_tt_destroy(struct ttm_tt *ttm)
> ttm_tt_unbind(ttm);
> }
>
> - if (likely(ttm->pages != NULL)) {
> + if (ttm->state == tt_unbound) {
> ttm->bdev->driver->ttm_tt_unpopulate(ttm);
> }
>
Looks good to me.
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-17 6:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-17 4:21 [PATCH] drm/ttm: fix the tt_populated check in ttm_tt_destroy() Ben Skeggs
2013-09-17 6:40 ` Thomas Hellstrom
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.