From: Hongfu Li <hongfu.li@linux.dev>
To: jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
rodrigo.vivi@intel.com, tursulin@ursulin.net, airlied@gmail.com,
simona@ffwll.ch, kees@kernel.org, tzimmermann@suse.de
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, hongfu.li@linux.dev,
Hongfu Li <lihongfu@kylinos.cn>
Subject: [PATCH] drm/i915/userptr: Convert page APIs to folio equivalents in put_pages
Date: Thu, 23 Jul 2026 14:46:51 +0800 [thread overview]
Message-ID: <20260723064651.4100-1-hongfu.li@linux.dev> (raw)
From: Hongfu Li <lihongfu@kylinos.cn>
Cache the folio with page_folio() at the start of the sg_table loop,
then use folio helpers directly to eliminate repeated compound_head()
lookups inside page API wrappers.
Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
---
drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
index 043095f93ac6..0ae68c52cc12 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
@@ -160,6 +160,7 @@ i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj,
struct sg_table *pages)
{
struct sgt_iter sgt_iter;
struct page *page;
+ struct folio *folio;
if (!pages)
@@ -177,7 +178,9 @@ i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj,
obj->mm.dirty = false;
for_each_sgt_page(page, sgt_iter, pages) {
- if (obj->mm.dirty && trylock_page(page)) {
+ folio = page_folio(page);
+
+ if (obj->mm.dirty && folio_trylock(folio)) {
/*
* As this may not be anonymous memory (e.g. shmem)
* but exist on a real mapping, we have to lock
@@ -193,14 +196,14 @@ i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj,
* on the folio. Such a try_to_unmap() will result
* in us calling put_pages() and so recursively try
* to lock the page. We avoid that deadlock with
- * a trylock_page() and in exchange we risk missing
+ * a folio_trylock() and in exchange we risk missing
* some page dirtying.
*/
- set_page_dirty(page);
- unlock_page(page);
+ folio_mark_dirty(folio);
+ folio_unlock(folio);
}
- mark_page_accessed(page);
+ folio_mark_accessed(folio);
}
obj->mm.dirty = false;
--
2.54.0
next reply other threads:[~2026-07-23 14:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 6:46 Hongfu Li [this message]
2026-07-23 15:19 ` ✓ i915.CI.BAT: success for drm/i915/userptr: Convert page APIs to folio equivalents in put_pages Patchwork
2026-07-24 19:18 ` ✓ i915.CI.Full: " 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=20260723064651.4100-1-hongfu.li@linux.dev \
--to=hongfu.li@linux.dev \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kees@kernel.org \
--cc=lihongfu@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
/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