Commit 8b00ce36 authored by Dave Airlie's avatar Dave Airlie

drm: Sparc64 ffb compile fixes

Fixup ffb driver and interfaces it uses, also avoid bus_to_virt
on sparc, I'll look into using the proper APIs for the DRM soon.
Signed-off-by: default avatarDave Airlie <airlied@linux.ie>
parent 812cdfc6
......@@ -561,7 +561,7 @@ struct drm_driver_fn {
int (*context_ctor)(struct drm_device *dev, int context);
int (*context_dtor)(struct drm_device *dev, int context);
int (*kernel_context_switch)(struct drm_device *dev, int old, int new);
int (*kernel_context_switch_unlock)(struct drm_device *dev);
void (*kernel_context_switch_unlock)(struct drm_device *dev, drm_lock_t *lock);
int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence);
/* these have to be filled in */
irqreturn_t (*irq_handler)( DRM_IRQ_ARGS );
......
......@@ -659,7 +659,9 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
buf->used = 0;
buf->offset = (dma->byte_count + byte_count + offset);
buf->address = (void *)(page + offset);
#ifndef __sparc__
buf->bus_address = virt_to_bus(buf->address);
#endif
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
......
......@@ -174,9 +174,14 @@ MODULE_LICENSE("GPL and additional rights");
static int DRM(setup)( drm_device_t *dev )
{
int i;
int ret;
if (dev->fn_tbl.presetup)
dev->fn_tbl.presetup(dev);
{
ret=dev->fn_tbl.presetup(dev);
if (ret!=0)
return ret;
}
atomic_set( &dev->ioctl_count, 0 );
atomic_set( &dev->vma_count, 0 );
......@@ -1066,7 +1071,7 @@ int DRM(unlock)( struct inode *inode, struct file *filp,
* modules but is required by the Sparc driver.
*/
if (dev->fn_tbl.kernel_context_switch_unlock)
dev->fn_tbl.kernel_context_switch_unlock(dev);
dev->fn_tbl.kernel_context_switch_unlock(dev, &lock);
else {
DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT );
......
......@@ -354,7 +354,7 @@ static void FFBWait(ffb_fbcPtr ffb)
} while (--limit);
}
int DRM(context_switch)(drm_device_t *dev, int old, int new)
int ffb_driver_context_switch(drm_device_t *dev, int old, int new)
{
ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
......@@ -380,7 +380,7 @@ int DRM(context_switch)(drm_device_t *dev, int old, int new)
return 0;
}
int DRM(resctx)(struct inode *inode, struct file *filp, unsigned int cmd,
int ffb_driver_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
drm_ctx_res_t res;
......@@ -407,7 +407,7 @@ int DRM(resctx)(struct inode *inode, struct file *filp, unsigned int cmd,
}
int DRM(addctx)(struct inode *inode, struct file *filp, unsigned int cmd,
int ffb_driver_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -428,7 +428,7 @@ int DRM(addctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0;
}
int DRM(modctx)(struct inode *inode, struct file *filp, unsigned int cmd,
int ffb_driver_modctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -457,7 +457,7 @@ int DRM(modctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0;
}
int DRM(getctx)(struct inode *inode, struct file *filp, unsigned int cmd,
int ffb_driver_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -489,7 +489,7 @@ int DRM(getctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0;
}
int DRM(switchctx)(struct inode *inode, struct file *filp, unsigned int cmd,
int ffb_driver_switchctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -499,10 +499,10 @@ int DRM(switchctx)(struct inode *inode, struct file *filp, unsigned int cmd,
if (copy_from_user(&ctx, (drm_ctx_t __user *)arg, sizeof(ctx)))
return -EFAULT;
DRM_DEBUG("%d\n", ctx.handle);
return DRM(context_switch)(dev, dev->last_context, ctx.handle);
return ffb_driver_context_switch(dev, dev->last_context, ctx.handle);
}
int DRM(newctx)(struct inode *inode, struct file *filp, unsigned int cmd,
int ffb_driver_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
drm_ctx_t ctx;
......@@ -514,7 +514,7 @@ int DRM(newctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0;
}
int DRM(rmctx)(struct inode *inode, struct file *filp, unsigned int cmd,
int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
drm_ctx_t ctx;
......@@ -538,79 +538,14 @@ int DRM(rmctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0;
}
static void ffb_driver_release(drm_device_t *dev)
void ffb_set_context_ioctls(void)
{
ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
int context = _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock);
int idx;
idx = context - 1;
if (fpriv &&
context != DRM_KERNEL_CONTEXT &&
fpriv->hw_state[idx] != NULL) {
kfree(fpriv->hw_state[idx]);
fpriv->hw_state[idx] = NULL;
}
}
static int ffb_driver_presetup(drm_device_t *dev)
{
int ret;
ret = ffb_presetup(dev);
if (_ret != 0) return ret;
}
static void ffb_driver_pretakedown(drm_device_t *dev)
{
if (dev->dev_private) kfree(dev->dev_private);
}
static void ffb_driver_postcleanup(drm_device_t *dev)
{
if (ffb_position != NULL) kfree(ffb_position);
}
DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)].func = ffb_driver_addctx;
DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)].func = ffb_driver_rmctx;
DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)].func = ffb_driver_modctx;
DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)].func = ffb_driver_getctx;
DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)].func = ffb_driver_switchctx;
DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)].func = ffb_driver_newctx;
DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)].func = ffb_driver_resctx;
static int ffb_driver_kernel_context_switch_unlock(struct drm_device *dev)
{
dev->lock.filp = 0;
{
__volatile__ unsigned int *plock = &dev->lock.hw_lock->lock;
unsigned int old, new, prev, ctx;
ctx = lock.context;
do {
old = *plock;
new = ctx;
prev = cmpxchg(plock, old, new);
} while (prev != old);
}
wake_up_interruptible(&dev->lock.lock_queue);
}
static unsigned long ffb_driver_get_map_ofs(drm_map_t *map)
{
return (map->offset & 0xffffffff);
}
static unsigned long ffb_driver_get_reg_ofs(drm_device_t *dev)
{
ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *)dev->dev_private;
if (ffb_priv)
return ffb_priv->card_phys_base;
return 0;
}
static void ffb_driver_register_fns(drm_device_t *dev)
{
DRM(fops).get_unmapped_area = ffb_get_unmapped_area;
dev->fn_tbl.release = ffb_driver_release;
dev->fn_tbl.presetup = ffb_driver_presetup;
dev->fn_tbl.pretakedown = ffb_driver_pretakedown;
dev->fn_tbl.postcleanup = ffb_driver_postcleanup;
dev->fn_tbl.kernel_context_switch = ffb_context_switch;
dev->fn_tbl.kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock;
dev->fn_tbl.get_map_ofs = ffb_driver_get_map_ofs;
dev->fn_tbl.get_reg_ofs = ffb_driver_get_reg_ofs;
}
......@@ -140,33 +140,6 @@ static int ffb_init_one(drm_device_t *dev, int prom_node, int parent_node,
return 0;
}
static int __init ffb_count_siblings(int root)
{
int node, child, count = 0;
child = prom_getchild(root);
for (node = prom_searchsiblings(child, "SUNW,ffb"); node;
node = prom_searchsiblings(prom_getsibling(node), "SUNW,ffb"))
count++;
return count;
}
static int __init ffb_scan_siblings(int root, int instance)
{
int node, child;
child = prom_getchild(root);
for (node = prom_searchsiblings(child, "SUNW,ffb"); node;
node = prom_searchsiblings(prom_getsibling(node), "SUNW,ffb")) {
ffb_position[instance].node = node;
ffb_position[instance].root = root;
instance++;
}
return instance;
}
static drm_map_t *ffb_find_map(struct file *filp, unsigned long off)
{
drm_file_t *priv = filp->private_data;
......@@ -247,7 +220,7 @@ unsigned long ffb_get_unmapped_area(struct file *filp,
/* This functions must be here since it references DRM(numdevs)
* which drm_drv.h declares.
*/
int ffb_presetup(drm_device_t *dev)
static int ffb_presetup(drm_device_t *dev)
{
ffb_dev_priv_t *ffb_priv;
drm_device_t *temp_dev;
......@@ -284,8 +257,83 @@ int ffb_presetup(drm_device_t *dev)
#include "drm_fops.h"
#include "drm_init.h"
#include "drm_ioctl.h"
#include "drm_irq.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
#include "drm_scatter.h"
static void ffb_driver_release(drm_device_t *dev, struct file *filp)
{
ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
int context = _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock);
int idx;
idx = context - 1;
if (fpriv &&
context != DRM_KERNEL_CONTEXT &&
fpriv->hw_state[idx] != NULL) {
kfree(fpriv->hw_state[idx]);
fpriv->hw_state[idx] = NULL;
}
}
static void ffb_driver_pretakedown(drm_device_t *dev)
{
if (dev->dev_private) kfree(dev->dev_private);
}
static int ffb_driver_postcleanup(drm_device_t *dev)
{
if (ffb_position != NULL) kfree(ffb_position);
return 0;
}
static void ffb_driver_kernel_context_switch_unlock(struct drm_device *dev, drm_lock_t *lock)
{
dev->lock.filp = 0;
{
__volatile__ unsigned int *plock = &dev->lock.hw_lock->lock;
unsigned int old, new, prev, ctx;
ctx = lock->context;
do {
old = *plock;
new = ctx;
prev = cmpxchg(plock, old, new);
} while (prev != old);
}
wake_up_interruptible(&dev->lock.lock_queue);
}
static unsigned long ffb_driver_get_map_ofs(drm_map_t *map)
{
return (map->offset & 0xffffffff);
}
static unsigned long ffb_driver_get_reg_ofs(drm_device_t *dev)
{
ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *)dev->dev_private;
if (ffb_priv)
return ffb_priv->card_phys_base;
return 0;
}
void ffb_driver_register_fns(drm_device_t *dev)
{
ffb_set_context_ioctls();
DRM(fops).get_unmapped_area = ffb_get_unmapped_area;
dev->fn_tbl.release = ffb_driver_release;
dev->fn_tbl.presetup = ffb_presetup;
dev->fn_tbl.pretakedown = ffb_driver_pretakedown;
dev->fn_tbl.postcleanup = ffb_driver_postcleanup;
dev->fn_tbl.kernel_context_switch = ffb_context_switch;
dev->fn_tbl.kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock;
dev->fn_tbl.get_map_ofs = ffb_driver_get_map_ofs;
dev->fn_tbl.get_reg_ofs = ffb_driver_get_reg_ofs;
}
......@@ -281,3 +281,6 @@ extern unsigned long ffb_get_unmapped_area(struct file *filp,
unsigned long len,
unsigned long pgoff,
unsigned long flags);
extern void ffb_set_context_ioctls(void);
extern drm_ioctl_desc_t DRM(ioctls)[];
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