Commit f11dd9b1 authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

gma500: add the ability to request backed space or not

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: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent cb0ff05a
...@@ -479,8 +479,8 @@ static int psbfb_create(struct psb_fbdev *fbdev, ...@@ -479,8 +479,8 @@ static int psbfb_create(struct psb_fbdev *fbdev,
size = mode_cmd.pitch * mode_cmd.height; size = mode_cmd.pitch * mode_cmd.height;
aligned_size = ALIGN(size, PAGE_SIZE); aligned_size = ALIGN(size, PAGE_SIZE);
/* Allocate the framebuffer in the GTT */ /* Allocate the framebuffer in the GTT with stolen page backing */
backing = psb_gtt_alloc_range(dev, aligned_size, "fb"); backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
if (backing == NULL) if (backing == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -972,6 +972,7 @@ struct gtt_range *psb_gtt_lookup_handle(struct drm_device *dev, int handle) ...@@ -972,6 +972,7 @@ struct gtt_range *psb_gtt_lookup_handle(struct drm_device *dev, int handle)
* @dev: Our DRM device * @dev: Our DRM device
* @len: length (bytes) of address space required * @len: length (bytes) of address space required
* @name: resource name * @name: resource name
* @backed: resource should be backed by stolen pages
* *
* Ask the kernel core to find us a suitable range of addresses * Ask the kernel core to find us a suitable range of addresses
* to use for a GTT mapping. * to use for a GTT mapping.
...@@ -981,12 +982,23 @@ struct gtt_range *psb_gtt_lookup_handle(struct drm_device *dev, int handle) ...@@ -981,12 +982,23 @@ struct gtt_range *psb_gtt_lookup_handle(struct drm_device *dev, int handle)
* as in use. * as in use.
*/ */
struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len, 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 drm_psb_private *dev_priv = dev->dev_private;
struct gtt_range *gt; struct gtt_range *gt;
struct resource *r = dev_priv->gtt_mem; struct resource *r = dev_priv->gtt_mem;
int ret; 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); gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL);
if (gt == NULL) if (gt == NULL)
...@@ -996,8 +1008,7 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len, ...@@ -996,8 +1008,7 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
kref_init(&gt->kref); kref_init(&gt->kref);
ret = allocate_resource(dev_priv->gtt_mem, &gt->resource, ret = allocate_resource(dev_priv->gtt_mem, &gt->resource,
len, 0, -1, /*r->start, r->end - 1, */ len, start, end, PAGE_SIZE, NULL, NULL);
PAGE_SIZE, NULL, NULL);
if (ret == 0) { if (ret == 0) {
gt->offset = gt->resource.start - r->start; gt->offset = gt->resource.start - r->start;
return gt; return gt;
......
...@@ -105,7 +105,7 @@ extern int psb_gtt_release_handle(struct drm_device *dev, struct gtt_range *gt); ...@@ -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, extern struct gtt_range *psb_gtt_lookup_handle(struct drm_device *dev,
int handle); int handle);
extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len, 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_kref_put(struct gtt_range *gt);
extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt); extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment