* [PATCH] drm/ttm: handle OOM in ttm_tt_swapout
@ 2010-02-20 2:22 Maarten Maathuis
2010-02-23 5:59 ` Dave Airlie
0 siblings, 1 reply; 4+ messages in thread
From: Maarten Maathuis @ 2010-02-20 2:22 UTC (permalink / raw)
To: dri-devel
- Without this change I get a general protection fault.
- Also use PTR_ERR where applicable.
Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
---
drivers/gpu/drm/ttm/ttm_tt.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 9c2b1cc..5b5c320 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -467,7 +467,7 @@ static int ttm_tt_swapin(struct ttm_tt *ttm)
void *from_virtual;
void *to_virtual;
int i;
- int ret;
+ int ret = -ENOMEM;
if (ttm->page_flags & TTM_PAGE_FLAG_USER) {
ret = ttm_tt_set_user(ttm, ttm->tsk, ttm->start,
@@ -486,8 +486,10 @@ static int ttm_tt_swapin(struct ttm_tt *ttm)
for (i = 0; i < ttm->num_pages; ++i) {
from_page = read_mapping_page(swap_space, i, NULL);
- if (IS_ERR(from_page))
+ if (IS_ERR(from_page)) {
+ ret = PTR_ERR(from_page);
goto out_err;
+ }
to_page = __ttm_tt_get_page(ttm, i);
if (unlikely(to_page == NULL))
goto out_err;
@@ -510,7 +512,7 @@ static int ttm_tt_swapin(struct ttm_tt *ttm)
return 0;
out_err:
ttm_tt_free_alloced_pages(ttm);
- return -ENOMEM;
+ return ret;
}
int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
@@ -522,6 +524,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
void *from_virtual;
void *to_virtual;
int i;
+ int ret = -ENOMEM;
BUG_ON(ttm->state != tt_unbound && ttm->state != tt_unpopulated);
BUG_ON(ttm->caching_state != tt_cached);
@@ -544,7 +547,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
0);
if (unlikely(IS_ERR(swap_storage))) {
printk(KERN_ERR "Failed allocating swap storage.\n");
- return -ENOMEM;
+ return PTR_ERR(swap_storage);
}
} else
swap_storage = persistant_swap_storage;
@@ -556,9 +559,10 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
if (unlikely(from_page == NULL))
continue;
to_page = read_mapping_page(swap_space, i, NULL);
- if (unlikely(to_page == NULL))
+ if (unlikely(IS_ERR(to_page))) {
+ ret = PTR_ERR(to_page);
goto out_err;
-
+ }
preempt_disable();
from_virtual = kmap_atomic(from_page, KM_USER0);
to_virtual = kmap_atomic(to_page, KM_USER1);
@@ -582,5 +586,5 @@ out_err:
if (!persistant_swap_storage)
fput(swap_storage);
- return -ENOMEM;
+ return ret;
}
--
1.7.0
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] drm/ttm: handle OOM in ttm_tt_swapout
2010-02-20 2:22 [PATCH] drm/ttm: handle OOM in ttm_tt_swapout Maarten Maathuis
@ 2010-02-23 5:59 ` Dave Airlie
2010-02-23 8:39 ` Maarten Maathuis
0 siblings, 1 reply; 4+ messages in thread
From: Dave Airlie @ 2010-02-23 5:59 UTC (permalink / raw)
To: Maarten Maathuis, Thomas Hellstrom; +Cc: dri-devel
On Sat, Feb 20, 2010 at 12:22 PM, Maarten Maathuis <madman2003@gmail.com> wrote:
> - Without this change I get a general protection fault.
> - Also use PTR_ERR where applicable.
I just want to make sure I understand, but really the only bit of this
patch that matters is:
> @@ -556,9 +559,10 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
> if (unlikely(from_page == NULL))
> continue;
> to_page = read_mapping_page(swap_space, i, NULL);
> - if (unlikely(to_page == NULL))
> + if (unlikely(IS_ERR(to_page))) {
^^ these two lines where we are testing for NULL but should be
checking for an error?
> + ret = PTR_ERR(to_page);
> goto out_err;
> -
> + }
If that is true and the rest is just nice cleanups then I'm okay with it,.
Reviewed-by: Dave Airlie <airlied@redhat.com>
I'll need Thomas's ack on this also.
Dave.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drm/ttm: handle OOM in ttm_tt_swapout
2010-02-23 5:59 ` Dave Airlie
@ 2010-02-23 8:39 ` Maarten Maathuis
2010-02-23 13:26 ` Thomas Hellstrom
0 siblings, 1 reply; 4+ messages in thread
From: Maarten Maathuis @ 2010-02-23 8:39 UTC (permalink / raw)
To: Dave Airlie; +Cc: Thomas Hellstrom, dri-devel
On Tue, Feb 23, 2010 at 6:59 AM, Dave Airlie <airlied@gmail.com> wrote:
> On Sat, Feb 20, 2010 at 12:22 PM, Maarten Maathuis <madman2003@gmail.com> wrote:
>> - Without this change I get a general protection fault.
>> - Also use PTR_ERR where applicable.
>
> I just want to make sure I understand, but really the only bit of this
> patch that matters is:
>
>> @@ -556,9 +559,10 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
>> if (unlikely(from_page == NULL))
>> continue;
>> to_page = read_mapping_page(swap_space, i, NULL);
>> - if (unlikely(to_page == NULL))
>> + if (unlikely(IS_ERR(to_page))) {
>
> ^^ these two lines where we are testing for NULL but should be
> checking for an error?
Yes, that's the critical bit. As you can see we were already doing
this for ttm_tt_swapin.
>
>> + ret = PTR_ERR(to_page);
>> goto out_err;
>> -
>> + }
>
> If that is true and the rest is just nice cleanups then I'm okay with it,.
>
> Reviewed-by: Dave Airlie <airlied@redhat.com>
>
> I'll need Thomas's ack on this also.
>
> Dave.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drm/ttm: handle OOM in ttm_tt_swapout
2010-02-23 8:39 ` Maarten Maathuis
@ 2010-02-23 13:26 ` Thomas Hellstrom
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Hellstrom @ 2010-02-23 13:26 UTC (permalink / raw)
To: Maarten Maathuis; +Cc: dri-devel@lists.sf.net
Maarten Maathuis wrote:
> On Tue, Feb 23, 2010 at 6:59 AM, Dave Airlie <airlied@gmail.com> wrote:
>
>> On Sat, Feb 20, 2010 at 12:22 PM, Maarten Maathuis <madman2003@gmail.com> wrote:
>>
>>> - Without this change I get a general protection fault.
>>> - Also use PTR_ERR where applicable.
>>>
>> I just want to make sure I understand, but really the only bit of this
>> patch that matters is:
>>
>>
>>> @@ -556,9 +559,10 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
>>> if (unlikely(from_page == NULL))
>>> continue;
>>> to_page = read_mapping_page(swap_space, i, NULL);
>>> - if (unlikely(to_page == NULL))
>>> + if (unlikely(IS_ERR(to_page))) {
>>>
>> ^^ these two lines where we are testing for NULL but should be
>> checking for an error?
>>
>
> Yes, that's the critical bit. As you can see we were already doing
> this for ttm_tt_swapin.
>
>
>>> + ret = PTR_ERR(to_page);
>>> goto out_err;
>>> -
>>> + }
>>>
>> If that is true and the rest is just nice cleanups then I'm okay with it,.
>>
>> Reviewed-by: Dave Airlie <airlied@redhat.com>
>>
>> I'll need Thomas's ack on this also.
>>
>> Dave.
>>
Acked-by: Thomas Hellstrom <thellstrom@vmware.com>
/Thomas
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-23 13:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-20 2:22 [PATCH] drm/ttm: handle OOM in ttm_tt_swapout Maarten Maathuis
2010-02-23 5:59 ` Dave Airlie
2010-02-23 8:39 ` Maarten Maathuis
2010-02-23 13:26 ` 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.