linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kyle McMartin <kyle@mcmartin.ca>
To: airlied@redhat.com
Cc: dri-devel@lists.sf.net, linux-kernel@vger.kernel.org,
	jbarnes@virtuousgeek.org, eric@anholt.net, stable@kernel.org,
	hugh.dickins@tiscali.co.uk, linux-mm@kvack.org,
	shaohua.li@intel.com
Subject: [PATCH] drm: i915: ensure objects are allocated below 4GB on PAE
Date: Tue, 26 May 2009 12:27:17 -0400	[thread overview]
Message-ID: <20090526162717.GC14808@bombadil.infradead.org> (raw)

From: Kyle McMartin <kyle@redhat.com>

Ensure we allocate GEM objects below 4GB on PAE machines, otherwise
misery ensues. This patch is based on a patch found on dri-devel by
Shaohua Li, but Keith P. expressed reticence that the changes unfairly
penalized other hardware.

(The mm/shmem.c hunk is necessary to ensure the DMA32 flag isn't used
 by the slab allocator via radix_tree_preload, which will hit a
 WARN_ON.)

Signed-off-by: Kyle McMartin <kyle@redhat.com>
---

We're shipping a variant of this in Fedora 11 to fix a myriad of bugs on
PAE hardware.

cheers, Kyle

---
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 4984aa8..ae52edc 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -142,6 +142,9 @@ drm_gem_object_alloc(struct drm_device *dev, size_t size)
 		return NULL;
 	}
 
+	if (dev->gem_flags)
+		mapping_set_gfp_mask(obj->filp->f_mapping, dev->gem_flags);
+
 	kref_init(&obj->refcount);
 	kref_init(&obj->handlecount);
 	obj->size = size;
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 53d5445..c89ae3d 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1153,12 +1153,12 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	}
 
 #ifdef CONFIG_HIGHMEM64G
-	/* don't enable GEM on PAE - needs agp + set_memory_* interface fixes */
-	dev_priv->has_gem = 0;
-#else
+	/* avoid allocating buffers above 4GB on PAE */
+	dev->gem_flags = GFP_USER | GFP_DMA32;
+#endif
+
 	/* enable GEM by default */
 	dev_priv->has_gem = 1;
-#endif
 
 	dev->driver->get_vblank_counter = i915_get_vblank_counter;
 	if (IS_GM45(dev))
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c8c4221..3744c1f 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1019,6 +1019,7 @@ struct drm_device {
 	uint32_t gtt_total;
 	uint32_t invalidate_domains;    /* domains pending invalidation */
 	uint32_t flush_domains;         /* domains pending flush */
+	gfp_t gem_flags;		/* object allocation flags */
 	/*@} */
 
 };
diff --git a/mm/shmem.c b/mm/shmem.c
index b25f95c..e615887 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1241,7 +1241,7 @@ repeat:
 		 * Try to preload while we can wait, to not make a habit of
 		 * draining atomic reserves; but don't latch on to this cpu.
 		 */
-		error = radix_tree_preload(gfp & ~__GFP_HIGHMEM);
+		error = radix_tree_preload(gfp & ~(__GFP_HIGHMEM|__GFP_DMA32));
 		if (error)
 			goto failed;
 		radix_tree_preload_end();

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2009-05-26 16:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26 16:27 Kyle McMartin [this message]
2009-05-26 19:17 ` Peter Zijlstra
2009-05-26 21:35   ` Eric Anholt
2009-05-26 21:41     ` Peter Zijlstra
2009-05-26 21:43       ` Kyle McMartin
2009-05-26 22:55 ` Hugh Dickins
2009-05-27  0:18   ` Kyle McMartin
2009-05-27  0:42     ` Shaohua Li
2009-05-27 17:40       ` Eric Anholt
2009-05-27 18:23         ` Kyle McMartin
2009-05-31  0:49         ` Shaohua Li

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=20090526162717.GC14808@bombadil.infradead.org \
    --to=kyle@mcmartin.ca \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.sf.net \
    --cc=eric@anholt.net \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shaohua.li@intel.com \
    --cc=stable@kernel.org \
    /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