From: Gabriel Gama <operatingsystemsdepression@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: patrik.r.jakobsson@gmail.com,
Gabriel Gama <operatingsystemsdepression@gmail.com>
Subject: [RFC PATCH 5/6] drm/gma500: Propagate SGX MMU setup and GEM pin failures
Date: Mon, 9 Nov 2026 02:54:49 -0300 [thread overview]
Message-ID: <20261109055451.17458-6-operatingsystemsdepression@gmail.com> (raw)
In-Reply-To: <20261109055451.17458-1-operatingsystemsdepression@gmail.com>
Check the GEM GPU address and perform transactional MMU insertion before
changing cache attributes or publishing the GTT mapping. On failure,
release temporary pages without publishing a pin and return the error.
Propagate stolen-memory mapping failures through probe cleanup before
installing a hardware context. Existing cache-attribute error handling
is unchanged. This depends on the preceding rollback fix.
Signed-off-by: Gabriel Gama <operatingsystemsdepression@gmail.com>
---
drivers/gpu/drm/gma500/gem.c | 19 ++++++++++++++-----
drivers/gpu/drm/gma500/psb_drv.c | 2 ++
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c
index fa5d3f137..c79713e26 100644
--- a/drivers/gpu/drm/gma500/gem.c
+++ b/drivers/gpu/drm/gma500/gem.c
@@ -32,7 +32,7 @@ int psb_gem_pin(struct psb_gem_object *pobj)
struct drm_gem_object *obj = &pobj->base;
struct drm_device *dev = obj->dev;
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
- u32 gpu_base = dev_priv->gtt.gatt_start;
+ u64 gpu_address = (u64)dev_priv->gtt.gatt_start + pobj->offset;
struct page **pages;
unsigned int npages;
int ret;
@@ -44,6 +44,11 @@ int psb_gem_pin(struct psb_gem_object *pobj)
if (pobj->in_gart || pobj->stolen)
goto out; /* already mapped */
+ if (gpu_address >= BIT_ULL(32)) {
+ ret = -ERANGE;
+ goto err_dma_resv_unlock;
+ }
+
pages = drm_gem_get_pages(obj);
if (IS_ERR(pages)) {
ret = PTR_ERR(pages);
@@ -52,12 +57,14 @@ int psb_gem_pin(struct psb_gem_object *pobj)
npages = obj->size / PAGE_SIZE;
- set_pages_array_wc(pages, npages);
+ ret = psb_mmu_insert_pages(psb_mmu_get_default_pd(dev_priv->mmu),
+ pages, gpu_address, npages, 0, 0,
+ PSB_MMU_CACHED_MEMORY);
+ if (ret)
+ goto err_put_pages;
+ set_pages_array_wc(pages, npages);
psb_gtt_insert_pages(dev_priv, &pobj->resource, pages);
- psb_mmu_insert_pages(psb_mmu_get_default_pd(dev_priv->mmu), pages,
- (gpu_base + pobj->offset), npages, 0, 0,
- PSB_MMU_CACHED_MEMORY);
pobj->pages = pages;
@@ -67,6 +74,8 @@ int psb_gem_pin(struct psb_gem_object *pobj)
return 0;
+err_put_pages:
+ drm_gem_put_pages(obj, pages, false, false);
err_dma_resv_unlock:
dma_resv_unlock(obj->resv);
return ret;
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index d17cb5b4a..d942f7264 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -354,6 +354,8 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
dev_priv->stolen_base >> PAGE_SHIFT,
pg->gatt_start,
pg->stolen_size >> PAGE_SHIFT, 0);
+ if (ret)
+ goto out_err;
psb_mmu_set_pd_context(psb_mmu_get_default_pd(dev_priv->mmu), 0);
psb_mmu_set_pd_context(dev_priv->pf_pd, 1);
next prev parent reply other threads:[~2026-11-09 5:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 5:54 [RFC PATCH 0/6] drm/gma500: prepare GEM and MMU for 3D rendering and hybrid 2D Gabriel Gama
2026-11-09 5:54 ` [RFC PATCH 1/6] drm/gma500: use the common dumb-buffer size helper Gabriel Gama
2026-11-09 5:54 ` [RFC PATCH 2/6] drm/gma500: do not underflow an unpinned GEM object Gabriel Gama
2026-11-09 5:54 ` [RFC PATCH 3/6] drm/gma500: Fix SGX page-table cache-flush mapping lifetime Gabriel Gama
2026-11-09 6:00 ` sashiko-bot
2026-11-09 5:54 ` [RFC PATCH 4/6] drm/gma500: Make SGX MMU insertion checked and transactional Gabriel Gama
2026-11-09 5:54 ` Gabriel Gama [this message]
2026-11-09 6:06 ` [RFC PATCH 5/6] drm/gma500: Propagate SGX MMU setup and GEM pin failures sashiko-bot
2026-11-09 5:54 ` [RFC PATCH 6/6] drm/gma500: Add software-only KUnit coverage for SGX page tables Gabriel Gama
2026-11-09 6:07 ` sashiko-bot
2026-11-09 6:26 ` Operating System's Depression
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=20261109055451.17458-6-operatingsystemsdepression@gmail.com \
--to=operatingsystemsdepression@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=patrik.r.jakobsson@gmail.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 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.