From: "Nicolai Hähnle" <nicolai.haehnle-5C7GfCeVMHo@public.gmane.org>
To: zhoucm1 <david1.zhou-5C7GfCeVMHo@public.gmane.org>,
"Nicolai Hähnle"
<nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 1/3] drm/ttm: split BO structure initialization into a separate function
Date: Wed, 15 Feb 2017 15:05:33 +0100 [thread overview]
Message-ID: <5b5dd111-c701-2832-641a-2f5700d67c81@amd.com> (raw)
In-Reply-To: <58A3C7FE.2080308-5C7GfCeVMHo@public.gmane.org>
On 15.02.2017 04:16, zhoucm1 wrote:
>
>
> On 2017年02月14日 18:37, Nicolai Hähnle wrote:
>> From: Nicolai Hähnle <nicolai.haehnle@amd.com>
>>
>> Allow callers to opt out of calling ttm_bo_validate immediately. This
>> allows more flexibility in how locking of the reservation object is
>> done, which is needed to fix a locking bug (destroy locked mutex)
>> in amdgpu.
>>
>> Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
>> ---
>> drivers/gpu/drm/ttm/ttm_bo.c | 62
>> +++++++++++++++++++++++++++++---------------
>> include/drm/ttm/ttm_bo_api.h | 45 ++++++++++++++++++++++++++++++++
>> 2 files changed, 86 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>> index 76bee42..ce4c0f5 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -1120,41 +1120,30 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
>> }
>> EXPORT_SYMBOL(ttm_bo_validate);
>> -int ttm_bo_init(struct ttm_bo_device *bdev,
>> - struct ttm_buffer_object *bo,
>> - unsigned long size,
>> - enum ttm_bo_type type,
>> - struct ttm_placement *placement,
>> - uint32_t page_alignment,
>> - bool interruptible,
>> - struct file *persistent_swap_storage,
>> - size_t acc_size,
>> - struct sg_table *sg,
>> - struct reservation_object *resv,
>> - void (*destroy) (struct ttm_buffer_object *))
>> +int ttm_bo_init_top(struct ttm_bo_device *bdev,
>> + struct ttm_buffer_object *bo,
>> + unsigned long size,
>> + enum ttm_bo_type type,
>> + uint32_t page_alignment,
>> + struct file *persistent_swap_storage,
>> + size_t acc_size,
>> + struct sg_table *sg,
>> + struct reservation_object *resv,
>> + void (*destroy) (struct ttm_buffer_object *))
>> {
>> int ret = 0;
>> unsigned long num_pages;
>> struct ttm_mem_global *mem_glob = bdev->glob->mem_glob;
>> - bool locked;
>> ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
>> if (ret) {
>> pr_err("Out of kernel memory\n");
>> - if (destroy)
>> - (*destroy)(bo);
>> - else
>> - kfree(bo);
>> return -ENOMEM;
>> }
>> num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
>> if (num_pages == 0) {
>> pr_err("Illegal buffer object size\n");
>> - if (destroy)
>> - (*destroy)(bo);
>> - else
>> - kfree(bo);
>> ttm_mem_global_free(mem_glob, acc_size);
>> return -EINVAL;
>> }
>> @@ -1204,6 +1193,37 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
>> ret = drm_vma_offset_add(&bdev->vma_manager, &bo->vma_node,
>> bo->mem.num_pages);
> if (ret && !resv), we should call
> reservation_object_fini(&bo->ttm_resv), right?
FWIW, you were right about this (and also mutex_destroy needs to be
called for wu_mutex, etc.). But I'm following Christian's suggestion of
having the caller use ttm_bo_unref for error cleanup, so all this error
cleanup needn't be duplicated.
Cheers,
Nicola
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2017-02-15 14:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 10:37 [PATCH 1/3] drm/ttm: split BO structure initialization into a separate function Nicolai Hähnle
[not found] ` <20170214103744.4133-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-14 10:37 ` [PATCH 2/3] drm/ttm: fix the documentation of ttm_bo_init Nicolai Hähnle
2017-02-14 10:37 ` [PATCH 3/3] drm/amdgpu: fix lock cleanup during buffer creation Nicolai Hähnle
2017-02-15 3:16 ` [PATCH 1/3] drm/ttm: split BO structure initialization into a separate function zhoucm1
[not found] ` <58A3C7FE.2080308-5C7GfCeVMHo@public.gmane.org>
2017-02-15 10:43 ` Nicolai Hähnle
[not found] ` <403a8be3-7f55-085c-b9ad-19551be33332-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-15 10:47 ` zhoucm1
2017-02-15 14:05 ` Nicolai Hähnle [this message]
2017-02-14 10:49 ` Christian König
[not found] ` <b9c665fe-4e9a-7163-aa8a-0c9ce73a78a0-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-02-14 12:00 ` Nicolai Hähnle
[not found] ` <9229e0d9-4e9d-0233-4ba2-c54c7192acfa-5C7GfCeVMHo@public.gmane.org>
2017-02-14 12:51 ` Christian König
[not found] ` <f43631b3-2527-54c1-d0bc-98460772b77b-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-02-15 13:35 ` Nicolai Hähnle
[not found] ` <06a90674-9f46-e646-9893-8b2748ddd9e4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-15 13:54 ` Nicolai Hähnle
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=5b5dd111-c701-2832-641a-2f5700d67c81@amd.com \
--to=nicolai.haehnle-5c7gfcevmho@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=david1.zhou-5C7GfCeVMHo@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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