From: Alan Cox <alan@linux.jf.intel.com>
To: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: [PATCH 1/8] gma500: add the ability to request backed space or not
Date: Tue, 19 Apr 2011 15:27:10 +0100 [thread overview]
Message-ID: <20110419142658.16479.59689.stgit@localhost.localdomain> (raw)
In-Reply-To: <20110419142432.16479.89255.stgit@localhost.localdomain>
We will will need this for doing a GEM allocator. It should also avoid any
crashes with the current code if the stolen area is too small.
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
drivers/staging/gma500/psb_fb.c | 4 ++--
drivers/staging/gma500/psb_gtt.c | 17 ++++++++++++++---
drivers/staging/gma500/psb_gtt.h | 2 +-
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/gma500/psb_fb.c b/drivers/staging/gma500/psb_fb.c
index 0bad4e0..e06365b 100644
--- a/drivers/staging/gma500/psb_fb.c
+++ b/drivers/staging/gma500/psb_fb.c
@@ -479,8 +479,8 @@ static int psbfb_create(struct psb_fbdev *fbdev,
size = mode_cmd.pitch * mode_cmd.height;
aligned_size = ALIGN(size, PAGE_SIZE);
- /* Allocate the framebuffer in the GTT */
- backing = psb_gtt_alloc_range(dev, aligned_size, "fb");
+ /* Allocate the framebuffer in the GTT with stolen page backing */
+ backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
if (backing == NULL)
return -ENOMEM;
diff --git a/drivers/staging/gma500/psb_gtt.c b/drivers/staging/gma500/psb_gtt.c
index a97e7be..69323f9 100644
--- a/drivers/staging/gma500/psb_gtt.c
+++ b/drivers/staging/gma500/psb_gtt.c
@@ -972,6 +972,7 @@ struct gtt_range *psb_gtt_lookup_handle(struct drm_device *dev, int handle)
* @dev: Our DRM device
* @len: length (bytes) of address space required
* @name: resource name
+ * @backed: resource should be backed by stolen pages
*
* Ask the kernel core to find us a suitable range of addresses
* to use for a GTT mapping.
@@ -981,12 +982,23 @@ struct gtt_range *psb_gtt_lookup_handle(struct drm_device *dev, int handle)
* as in use.
*/
struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
- const char *name)
+ const char *name, int backed)
{
struct drm_psb_private *dev_priv = dev->dev_private;
struct gtt_range *gt;
struct resource *r = dev_priv->gtt_mem;
int ret;
+ unsigned long start, end;
+
+ if (backed) {
+ /* The start of the GTT is the stolen pages */
+ start = r->start;
+ end = r->start + dev_priv->pg->stolen_size - 1;
+ } else {
+ /* The rest we will use for GEM backed objects */
+ start = r->start + dev_priv->pg->stolen_size;
+ end = -1;
+ }
gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL);
if (gt == NULL)
@@ -996,8 +1008,7 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
kref_init(>->kref);
ret = allocate_resource(dev_priv->gtt_mem, >->resource,
- len, 0, -1, /*r->start, r->end - 1, */
- PAGE_SIZE, NULL, NULL);
+ len, start, end, PAGE_SIZE, NULL, NULL);
if (ret == 0) {
gt->offset = gt->resource.start - r->start;
return gt;
diff --git a/drivers/staging/gma500/psb_gtt.h b/drivers/staging/gma500/psb_gtt.h
index 010ef70..dc2259c 100644
--- a/drivers/staging/gma500/psb_gtt.h
+++ b/drivers/staging/gma500/psb_gtt.h
@@ -105,7 +105,7 @@ extern int psb_gtt_release_handle(struct drm_device *dev, struct gtt_range *gt);
extern struct gtt_range *psb_gtt_lookup_handle(struct drm_device *dev,
int handle);
extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
- const char *name);
+ const char *name, int backed);
extern void psb_gtt_kref_put(struct gtt_range *gt);
extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
next prev parent reply other threads:[~2011-04-19 14:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-19 14:26 [PATCH 0/8] Further clean up and setup Alan Cox
2011-04-19 14:27 ` Alan Cox [this message]
2011-04-20 20:31 ` [PATCH 1/8] gma500: add the ability to request backed space or not Greg KH
2011-04-20 21:21 ` Alan Cox
2011-04-21 5:05 ` Greg KH
2011-04-21 5:06 ` Greg KH
2011-04-21 8:49 ` Alan Cox
2011-04-26 0:15 ` Greg KH
2011-04-19 14:27 ` [PATCH 2/8] gma500: begin adding GEM Alan Cox
2011-04-19 14:27 ` [PATCH 3/8] gma500: Add support for inserting and removing pages from the GART Alan Cox
2011-04-19 14:27 ` [PATCH 4/8] gma500: Begin the GEMification of the cursor code Alan Cox
2011-04-19 14:28 ` [PATCH 5/8] gma500: GEMify the frame buffer base bits Alan Cox
2011-04-19 14:28 ` [PATCH 6/8] gma500: GEM - now we have the basics we shall stick pins in it Alan Cox
2011-04-19 14:28 ` [PATCH 7/8] gma500: prune some unused variables Alan Cox
2011-04-19 14:28 ` [PATCH 8/8] gma500: allow non stolen page backed framebuffer Alan Cox
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=20110419142658.16479.59689.stgit@localhost.localdomain \
--to=alan@linux.jf.intel.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.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