From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Christian König" <christian.koenig@amd.com>,
"Matthew Brost" <matthew.brost@intel.com>,
dri-devel@lists.freedesktop.org
Subject: [PATCH 2/2] drm/ttm: Move pinned objects off LRU lists when pinning
Date: Mon, 2 Sep 2024 17:41:59 +0200 [thread overview]
Message-ID: <20240902154159.78871-3-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20240902154159.78871-1-thomas.hellstrom@linux.intel.com>
The ttm_bo_pin() and ttm_bo_unpin() functions weren't moving their
resources off the LRU list to the unevictable list.
Make sure that happens so that pinned objects don't accidently linger
on the LRU lists, and also make sure to move them back once they
are unpinned.
Cc: Christian König <christian.koenig@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: <dri-devel@lists.freedesktop.org>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index d244566a7e48..057a65f51969 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -592,9 +592,10 @@ void ttm_bo_pin(struct ttm_buffer_object *bo)
dma_resv_assert_held(bo->base.resv);
WARN_ON_ONCE(!kref_read(&bo->kref));
spin_lock(&bo->bdev->lru_lock);
- if (bo->resource)
+ if (!bo->pin_count++ && bo->resource) {
ttm_resource_del_bulk_move(bo->resource, bo);
- ++bo->pin_count;
+ ttm_resource_move_to_lru_tail(bo->resource);
+ }
spin_unlock(&bo->bdev->lru_lock);
}
EXPORT_SYMBOL(ttm_bo_pin);
@@ -613,9 +614,10 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo)
return;
spin_lock(&bo->bdev->lru_lock);
- --bo->pin_count;
- if (bo->resource)
+ if (!--bo->pin_count && bo->resource) {
ttm_resource_add_bulk_move(bo->resource, bo);
+ ttm_resource_move_to_lru_tail(bo->resource);
+ }
spin_unlock(&bo->bdev->lru_lock);
}
EXPORT_SYMBOL(ttm_bo_unpin);
--
2.46.0
next prev parent reply other threads:[~2024-09-02 15:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 15:41 [PATCH 0/2] drm/ttm: Really use a separate LRU list for swapped- and pinned objects Thomas Hellström
2024-09-02 15:41 ` [PATCH 1/2] drm/ttm: Move swapped objects off the manager's LRU list Thomas Hellström
2024-09-03 7:49 ` Christian König
2024-09-03 8:55 ` Thomas Hellström
2024-09-02 15:41 ` Thomas Hellström [this message]
2024-09-03 7:57 ` [PATCH 2/2] drm/ttm: Move pinned objects off LRU lists when pinning Christian König
2024-09-02 17:59 ` ✓ CI.Patch_applied: success for drm/ttm: Really use a separate LRU list for swapped- and pinned objects Patchwork
2024-09-02 17:59 ` ✓ CI.checkpatch: " Patchwork
2024-09-02 18:00 ` ✗ CI.KUnit: failure " Patchwork
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=20240902154159.78871-3-thomas.hellstrom@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@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