From: Matthew Auld <matthew.auld@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: intel-xe@lists.freedesktop.org,
"Himal Prasad Ghimiray" <himal.prasad.ghimiray@intel.com>,
"Tejas Upadhyay" <tejas.upadhyay@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH 4/4] drm/xe/bo: add some annotations in bo_put()
Date: Tue, 10 Sep 2024 15:52:26 +0100 [thread overview]
Message-ID: <62149100-98df-46ea-87d3-9aefb060b655@intel.com> (raw)
In-Reply-To: <ZuBQ1CGPrZkx5/Eh@DUT025-TGLU.fm.intel.com>
Hi,
On 10/09/2024 14:59, Matthew Brost wrote:
> On Tue, Sep 10, 2024 at 02:11:49PM +0100, Matthew Auld wrote:
>> If the put() triggers bo destroy then there is at least one potential
>> sleeping lock. Also annotate bos_lock and ggtt lock.
>>
>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>> Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
>> Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
>> Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
>> ---
>> drivers/gpu/drm/xe/xe_bo.c | 14 ++++++++++++++
>> drivers/gpu/drm/xe/xe_bo.h | 6 +-----
>> 2 files changed, 15 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
>> index 53948a965404..4176b302c38d 100644
>> --- a/drivers/gpu/drm/xe/xe_bo.c
>> +++ b/drivers/gpu/drm/xe/xe_bo.c
>> @@ -2320,6 +2320,20 @@ void xe_bo_put_commit(struct llist_head *deferred)
>> drm_gem_object_free(&bo->ttm.base.refcount);
>> }
>>
>> +void xe_bo_put(struct xe_bo *bo)
>
> These are helpful but thinking we might need a version without asserts
> that can be used in code paths where we know that we have another ref to
> the BO. I can already think of a case in the SVM code where this would
> be needed. In that version maybe we assert the ref count > 1, granted
> that races but probably the best we can there.
Yeah, adding another put() variant or similar for that case should be
totally fine I think.
>
> What do you think?
>
> Asserts look good though.
>
> Matt
>
>> +{
>> + might_sleep();
>> + if (bo) {
>> +#ifdef CONFIG_PROC_FS
>> + if (bo->client)
>> + might_lock(&bo->client->bos_lock);
>> +#endif
>> + if (bo->ggtt_node && bo->ggtt_node->ggtt)
>> + might_lock(&bo->ggtt_node->ggtt->lock);
>> + drm_gem_object_put(&bo->ttm.base);
>> + }
>> +}
>> +
>> /**
>> * xe_bo_dumb_create - Create a dumb bo as backing for a fb
>> * @file_priv: ...
>> diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
>> index dbfb3209615d..6e4be52306df 100644
>> --- a/drivers/gpu/drm/xe/xe_bo.h
>> +++ b/drivers/gpu/drm/xe/xe_bo.h
>> @@ -126,11 +126,7 @@ static inline struct xe_bo *xe_bo_get(struct xe_bo *bo)
>> return bo;
>> }
>>
>> -static inline void xe_bo_put(struct xe_bo *bo)
>> -{
>> - if (bo)
>> - drm_gem_object_put(&bo->ttm.base);
>> -}
>> +void xe_bo_put(struct xe_bo *bo);
>>
>> static inline void __xe_bo_unset_bulk_move(struct xe_bo *bo)
>> {
>> --
>> 2.46.0
>>
next prev parent reply other threads:[~2024-09-10 14:52 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 13:11 [PATCH 1/4] drm/xe/client: fix deadlock in show_meminfo() Matthew Auld
2024-09-10 13:11 ` [PATCH 2/4] drm/xe/client: add missing bo locking " Matthew Auld
2024-09-10 14:16 ` Matthew Brost
2024-09-11 5:39 ` Upadhyay, Tejas
2024-09-11 8:35 ` Matthew Auld
2024-09-11 9:40 ` Upadhyay, Tejas
2024-09-10 13:11 ` [PATCH 3/4] drm/xe/client: use mem_type from the current resource Matthew Auld
2024-09-10 14:18 ` Matthew Brost
2024-09-11 5:45 ` Upadhyay, Tejas
2024-09-10 13:11 ` [PATCH 4/4] drm/xe/bo: add some annotations in bo_put() Matthew Auld
2024-09-10 13:59 ` Matthew Brost
2024-09-10 14:52 ` Matthew Auld [this message]
2024-09-10 15:59 ` Matthew Brost
2024-09-10 14:49 ` Matthew Brost
2024-09-10 15:03 ` Matthew Auld
2024-09-10 15:26 ` Matthew Brost
2024-09-10 15:29 ` Matthew Brost
2024-09-11 5:40 ` Upadhyay, Tejas
2024-09-10 13:29 ` ✓ CI.Patch_applied: success for series starting with [1/4] drm/xe/client: fix deadlock in show_meminfo() Patchwork
2024-09-10 13:30 ` ✓ CI.checkpatch: " Patchwork
2024-09-10 13:31 ` ✓ CI.KUnit: " Patchwork
2024-09-10 13:48 ` ✓ CI.Build: " Patchwork
2024-09-10 13:53 ` ✓ CI.Hooks: " Patchwork
2024-09-10 13:55 ` [PATCH 1/4] " Matthew Brost
2024-09-10 13:56 ` ✓ CI.checksparse: success for series starting with [1/4] " Patchwork
2024-09-10 14:39 ` ✓ CI.BAT: " Patchwork
2024-09-10 15:45 ` ✗ CI.FULL: failure " Patchwork
2024-09-11 5:19 ` [PATCH 1/4] " Upadhyay, Tejas
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=62149100-98df-46ea-87d3-9aefb060b655@intel.com \
--to=matthew.auld@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=tejas.upadhyay@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
/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