From: Rosen Penev <rosenp@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
intel-gfx@lists.freedesktop.org (open list:INTEL DRM I915 DRIVER
(Meteor Lake, DG2 and old...),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] drm: i915: use kzalloc_flex
Date: Mon, 29 Jun 2026 18:19:07 -0700 [thread overview]
Message-ID: <20260630011907.1453253-1-rosenp@gmail.com> (raw)
Simplifies allocations by using a flexible array member in this struct.
No need to free separately.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/gpu/drm/i915/gt/intel_gtt.h | 2 +-
drivers/gpu/drm/i915/gt/intel_ppgtt.c | 15 +--------------
2 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h b/drivers/gpu/drm/i915/gt/intel_gtt.h
index f6f223090760..49b2d2d24fd8 100644
--- a/drivers/gpu/drm/i915/gt/intel_gtt.h
+++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
@@ -187,7 +187,7 @@ struct i915_page_table {
struct i915_page_directory {
struct i915_page_table pt;
spinlock_t lock;
- void **entry;
+ void *entry[];
};
#define __px_choose_expr(x, type, expr, other) \
diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
index 72d8473a448b..20cc59a005c9 100644
--- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
@@ -36,16 +36,10 @@ struct i915_page_directory *__alloc_pd(int count)
{
struct i915_page_directory *pd;
- pd = kzalloc_obj(*pd, I915_GFP_ALLOW_FAIL);
+ pd = kzalloc_flex(*pd, entry, count, I915_GFP_ALLOW_FAIL);
if (unlikely(!pd))
return NULL;
- pd->entry = kzalloc_objs(*pd->entry, count, I915_GFP_ALLOW_FAIL);
- if (unlikely(!pd->entry)) {
- kfree(pd);
- return NULL;
- }
-
spin_lock_init(&pd->lock);
return pd;
}
@@ -60,7 +54,6 @@ struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
pd->pt.base = vm->alloc_pt_dma(vm, I915_GTT_PAGE_SIZE_4K);
if (IS_ERR(pd->pt.base)) {
- kfree(pd->entry);
kfree(pd);
return ERR_PTR(-ENOMEM);
}
@@ -72,12 +65,6 @@ void free_px(struct i915_address_space *vm, struct i915_page_table *pt, int lvl)
{
BUILD_BUG_ON(offsetof(struct i915_page_directory, pt));
- if (lvl) {
- struct i915_page_directory *pd =
- container_of(pt, typeof(*pd), pt);
- kfree(pd->entry);
- }
-
if (pt->base)
i915_gem_object_put(pt->base);
--
2.54.0
next reply other threads:[~2026-06-30 1:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 1:19 Rosen Penev [this message]
2026-06-30 1:27 ` [PATCH] drm: i915: use kzalloc_flex sashiko-bot
2026-07-01 20:24 ` ✗ LGCI.VerificationFailed: failure for " 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=20260630011907.1453253-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
/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 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.