2011-05-09 15:23:27

by Alan Cox

[permalink] [raw]
Subject: [PATCH 0/2] Further small GMA500 fixes


Alan Cox (2):
gma500: Fix dumb create crash
gma500: sort out the file operations


drivers/staging/gma500/psb_drv.c | 50 +++++---------------------------------
drivers/staging/gma500/psb_gem.c | 6 ++---
drivers/staging/gma500/psb_gtt.c | 2 +-
3 files changed, 10 insertions(+), 48 deletions(-)


2011-05-09 15:23:44

by Alan Cox

[permalink] [raw]
Subject: [PATCH 1/2] gma500: sort out the file operations

Route everything via the proper DRM layer calls. This fixes the crash in
plymouth and is also necessary to begin supporting libkms.

Signed-off-by: Alan Cox <[email protected]>
Cc:[email protected]

---

drivers/staging/gma500/psb_drv.c | 50 +++++---------------------------------
1 files changed, 6 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/gma500/psb_drv.c b/drivers/staging/gma500/psb_drv.c
index b0bf1a0..360d582 100644
--- a/drivers/staging/gma500/psb_drv.c
+++ b/drivers/staging/gma500/psb_drv.c
@@ -1332,13 +1332,6 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
return 0;
}

-/* always available as we are SIGIO'd */
-static unsigned int psb_poll(struct file *filp,
- struct poll_table_struct *wait)
-{
- return POLLIN | POLLRDNORM;
-}
-
static int psb_driver_open(struct drm_device *dev, struct drm_file *priv)
{
return 0;
@@ -1364,29 +1357,9 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
pm_runtime_allow(&dev->pdev->dev);
dev_priv->rpm_enabled = 1;
}
- /*
- * The driver private ioctls should be thread-safe.
- */
-
- if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END)
- && (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls)) {
- struct drm_ioctl_desc *ioctl =
- &psb_ioctls[nr - DRM_COMMAND_BASE];
-
- if (unlikely(ioctl->cmd != cmd)) {
- DRM_ERROR(
- "Invalid drm cmnd %d ioctl->cmd %x, cmd %x\n",
- nr - DRM_COMMAND_BASE, ioctl->cmd, cmd);
- return -EINVAL;
- }
-
- return drm_ioctl(filp, cmd, arg);
- }
- /*
- * Not all old drm ioctls are thread-safe.
- */
-
return drm_ioctl(filp, cmd, arg);
+
+ /* FIXME: do we need to wrap the other side of this */
}


@@ -1403,17 +1376,6 @@ static void psb_remove(struct pci_dev *pdev)
drm_put_dev(dev);
}

-static int psb_open(struct inode *inode, struct file *filp)
-{
- return 0;
-}
-
-static int psb_release(struct inode *inode, struct file *filp)
-{
- return 0;
-}
-
-
static const struct dev_pm_ops psb_pm_ops = {
.runtime_suspend = psb_runtime_suspend,
.runtime_resume = psb_runtime_resume,
@@ -1457,11 +1419,11 @@ static struct drm_driver driver = {

.fops = {
.owner = THIS_MODULE,
- .open = psb_open,
- .release = psb_release,
+ .open = drm_open,
+ .release = drm_release,
.unlocked_ioctl = psb_unlocked_ioctl,
- /* .mmap = psb_mmap, */
- .poll = psb_poll,
+ .mmap = drm_mmap,
+ .poll = drm_poll,
.fasync = drm_fasync,
.read = drm_read,
},

2011-05-09 15:23:57

by Alan Cox

[permalink] [raw]
Subject: [PATCH 2/2] gma500: Fix dumb create crash

The error path from gtt_alloc returns NULL not a ptr error. The underlying
fail is caused by a bug in the size calculation. With these two fixed it
passes kmstest, although it's not really doing anything useful yet.

Signed-off-by: Alan Cox <[email protected]>
---

drivers/staging/gma500/psb_gem.c | 6 +++---
drivers/staging/gma500/psb_gtt.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gma500/psb_gem.c b/drivers/staging/gma500/psb_gem.c
index d47c187..518f8c1 100644
--- a/drivers/staging/gma500/psb_gem.c
+++ b/drivers/staging/gma500/psb_gem.c
@@ -100,8 +100,8 @@ static int psb_gem_create(struct drm_file *file,
/* Allocate our object - for now a direct gtt range which is not
stolen memory backed */
r = psb_gtt_alloc_range(dev, size, "gem", 0);
- if (IS_ERR(r))
- return PTR_ERR(r);
+ if (r == NULL)
+ return -ENOSPC;
/* Initialize the extra goodies GEM needs to do all the hard work */
if (drm_gem_object_init(dev, &r->gem, size) != 0) {
psb_gtt_free_range(dev, r);
@@ -135,7 +135,7 @@ static int psb_gem_create(struct drm_file *file,
int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args)
{
- args->pitch = ALIGN(args->width & ((args->bpp + 1) / 8), 64);
+ args->pitch = ALIGN(args->width * ((args->bpp + 7) / 8), 64);
args->size = args->pitch * args->height;
return psb_gem_create(file, dev, args->size, &args->handle);
}
diff --git a/drivers/staging/gma500/psb_gtt.c b/drivers/staging/gma500/psb_gtt.c
index 10d772a..dc0a4b7 100644
--- a/drivers/staging/gma500/psb_gtt.c
+++ b/drivers/staging/gma500/psb_gtt.c
@@ -277,7 +277,7 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
} else {
/* The rest we will use for GEM backed objects */
start = r->start + dev_priv->pg->stolen_size;
- end = -1;
+ end = r->end;
}

gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL);