From: Thomas Zimmermann <tzimmermann@suse.de>
To: patrik.r.jakobsson@gmail.com, airlied@linux.ie, daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v3 08/10] drm/gma500: Set page-caching flags in GEM pin/unpin
Date: Fri, 15 Oct 2021 10:40:51 +0200 [thread overview]
Message-ID: <20211015084053.13708-9-tzimmermann@suse.de> (raw)
In-Reply-To: <20211015084053.13708-1-tzimmermann@suse.de>
Caching of the GEM object's backing pages are unrelated to GTT
management. Move the respective calls from GTT code to GEM code.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
---
drivers/gpu/drm/gma500/gem.c | 9 ++++++++-
drivers/gpu/drm/gma500/gtt.c | 17 ++---------------
drivers/gpu/drm/gma500/gtt.h | 2 +-
3 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c
index 425d183c76ca..def26d9ce89d 100644
--- a/drivers/gpu/drm/gma500/gem.c
+++ b/drivers/gpu/drm/gma500/gem.c
@@ -13,6 +13,8 @@
#include <linux/pagemap.h>
+#include <asm/set_memory.h>
+
#include <drm/drm.h>
#include <drm/drm_vma_manager.h>
@@ -41,7 +43,9 @@ int psb_gem_pin(struct gtt_range *gt)
npages = gt->gem.size / PAGE_SIZE;
- ret = psb_gtt_insert(dev, gt, 0);
+ set_pages_array_wc(pages, npages);
+
+ ret = psb_gtt_insert(dev, gt);
if (ret)
goto err_drm_gem_put_pages;
@@ -84,6 +88,9 @@ void psb_gem_unpin(struct gtt_range *gt)
(gpu_base + gt->offset), gt->npage, 0, 0);
psb_gtt_remove(dev, gt);
+ /* Reset caching flags */
+ set_pages_array_wb(gt->pages, gt->npage);
+
drm_gem_put_pages(>->gem, gt->pages, true, false);
gt->pages = NULL;
diff --git a/drivers/gpu/drm/gma500/gtt.c b/drivers/gpu/drm/gma500/gtt.c
index d00ca065f3d3..3a716a970a8a 100644
--- a/drivers/gpu/drm/gma500/gtt.c
+++ b/drivers/gpu/drm/gma500/gtt.c
@@ -7,10 +7,6 @@
* Alan Cox <alan@linux.intel.com>
*/
-#include <linux/shmem_fs.h>
-
-#include <asm/set_memory.h>
-
#include "psb_drv.h"
@@ -92,17 +88,15 @@ static u32 __iomem *psb_gtt_entry(struct drm_device *dev, struct gtt_range *r)
* psb_gtt_insert - put an object into the GTT
* @dev: our DRM device
* @r: our GTT range
- * @resume: on resume
*
* Take our preallocated GTT range and insert the GEM object into
* the GTT. This is protected via the gtt mutex which the caller
* must hold.
*/
-int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r, int resume)
+int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r)
{
u32 __iomem *gtt_slot;
u32 pte;
- struct page **pages;
int i;
if (r->pages == NULL) {
@@ -113,12 +107,6 @@ int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r, int resume)
WARN_ON(r->stolen); /* refcount these maybe ? */
gtt_slot = psb_gtt_entry(dev, r);
- pages = r->pages;
-
- if (!resume) {
- /* Make sure changes are visible to the GPU */
- set_pages_array_wc(pages, r->npage);
- }
/* Write our page entries into the GTT itself */
for (i = 0; i < r->npage; i++) {
@@ -158,7 +146,6 @@ void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r)
for (i = 0; i < r->npage; i++)
iowrite32(pte, gtt_slot++);
ioread32(gtt_slot - 1);
- set_pages_array_wb(r->pages, r->npage);
}
static void psb_gtt_alloc(struct drm_device *dev)
@@ -349,7 +336,7 @@ int psb_gtt_restore(struct drm_device *dev)
while (r != NULL) {
range = container_of(r, struct gtt_range, resource);
if (range->pages) {
- psb_gtt_insert(dev, range, 1);
+ psb_gtt_insert(dev, range);
size += range->resource.end - range->resource.start;
restored++;
}
diff --git a/drivers/gpu/drm/gma500/gtt.h b/drivers/gpu/drm/gma500/gtt.h
index 6f3808e29059..ddb4f3af93f7 100644
--- a/drivers/gpu/drm/gma500/gtt.h
+++ b/drivers/gpu/drm/gma500/gtt.h
@@ -49,7 +49,7 @@ int psb_gtt_allocate_resource(struct drm_psb_private *pdev, struct resource *res
const char *name, resource_size_t size, resource_size_t align,
bool stolen, u32 *offset);
-int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r, int resume);
+int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r);
void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r);
#endif
--
2.33.0
next prev parent reply other threads:[~2021-10-15 8:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 8:40 [PATCH v3 00/10] drm/gma500: Refactor GEM code Thomas Zimmermann
2021-10-15 8:40 ` [PATCH v3 01/10] drm/gma500: Move helpers for struct gtt_range from gtt.c to gem.c Thomas Zimmermann
2021-10-15 8:40 ` [PATCH v3 02/10] drm/gma500: Use to_gtt_range() everywhere Thomas Zimmermann
2021-10-15 8:40 ` [PATCH v3 03/10] drm/gma500: Reimplement psb_gem_create() Thomas Zimmermann
2021-10-15 8:40 ` [PATCH v3 04/10] drm/gma500: Allocate GTT ranges in stolen memory with psb_gem_create() Thomas Zimmermann
2021-10-15 8:40 ` [PATCH v3 05/10] drm/gma500: Rename psb_gtt_{pin, unpin}() to psb_gem_{pin, unpin}() Thomas Zimmermann
2021-10-15 8:40 ` [PATCH v3 06/10] drm/gma500: Inline psb_gtt_attach_pages() and psb_gtt_detach_pages() Thomas Zimmermann
2021-10-15 8:40 ` [PATCH v3 07/10] drm/gma500: Inline psb_gtt_{alloc, free}_range() into rsp callers Thomas Zimmermann
2021-10-18 12:27 ` Patrik Jakobsson
2021-10-15 8:40 ` Thomas Zimmermann [this message]
2021-10-15 8:40 ` [PATCH v3 09/10] drm/gma500: Rewrite GTT page insert/remove without struct gtt_range Thomas Zimmermann
2021-10-18 12:27 ` Patrik Jakobsson
2021-10-15 8:40 ` [PATCH v3 10/10] drm/gma500: Rename struct gtt_range to struct psb_gem_object Thomas Zimmermann
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=20211015084053.13708-9-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox