summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2007-07-27 15:45:59 -0700
committerIan Romanick <idr@us.ibm.com>2007-07-27 15:45:59 -0700
commitcd51f131389297f923798daef6c734ba93f4422b (patch)
treecb453e5f4773a6ccfa20e20adddd3c3eb2b9a38f
parentc37ed9eca57a42b98cc67ca98dbf5135f5ab7aba (diff)
Convert to new ioctl interface between core DRM and device-specific module.
-rw-r--r--linux-core/xgi_cmdlist.c36
-rw-r--r--linux-core/xgi_drv.c53
-rw-r--r--linux-core/xgi_drv.h48
-rw-r--r--linux-core/xgi_fb.c42
-rw-r--r--linux-core/xgi_misc.c14
-rw-r--r--linux-core/xgi_pcie.c52
6 files changed, 101 insertions, 144 deletions
diff --git a/linux-core/xgi_cmdlist.c b/linux-core/xgi_cmdlist.c
index 10ee9764..1d0ee754 100644
--- a/linux-core/xgi_cmdlist.c
+++ b/linux-core/xgi_cmdlist.c
@@ -76,9 +76,12 @@ unsigned int get_batch_command(enum xgi_batch_type type)
}
-static void xgi_submit_cmdlist(struct xgi_info * info,
- const struct xgi_cmd_info * pCmdInfo)
+int xgi_submit_cmdlist(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
+ struct xgi_info *const info = dev->dev_private;
+ const struct xgi_cmd_info *const pCmdInfo =
+ (struct xgi_cmd_info *) data;
const unsigned int cmd = get_batch_command(pCmdInfo->type);
u32 begin[4];
@@ -130,24 +133,6 @@ static void xgi_submit_cmdlist(struct xgi_info * info,
}
info->cmdring.last_ptr = xgi_find_pcie_virt(info, pCmdInfo->hw_addr);
-}
-
-
-int xgi_submit_cmdlist_ioctl(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
- struct xgi_cmd_info cmd_list;
- struct xgi_info *info = dev->dev_private;
-
- DRM_COPY_FROM_USER_IOCTL(cmd_list,
- (struct xgi_cmd_info __user *) data,
- sizeof(cmd_list));
-
- if (cmd_list.type > BTYPE_CTRL) {
- return -EINVAL;
- }
-
- xgi_submit_cmdlist(info, &cmd_list);
return 0;
}
@@ -187,16 +172,15 @@ int xgi_state_change(struct xgi_info * info, unsigned int to,
}
-int xgi_state_change_ioctl(DRM_IOCTL_ARGS)
+int xgi_state_change_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
- struct xgi_state_info state;
+ struct xgi_state_info *const state =
+ (struct xgi_state_info *) data;
struct xgi_info *info = dev->dev_private;
- DRM_COPY_FROM_USER_IOCTL(state, (struct xgi_state_info __user *) data,
- sizeof(state));
- return xgi_state_change(info, state._toState, state._fromState);
+ return xgi_state_change(info, state->_toState, state->_fromState);
}
diff --git a/linux-core/xgi_drv.c b/linux-core/xgi_drv.c
index ec87df0a..0b094a31 100644
--- a/linux-core/xgi_drv.c
+++ b/linux-core/xgi_drv.c
@@ -37,23 +37,23 @@ static struct pci_device_id pciidlist[] = {
xgi_PCI_IDS
};
-static int xgi_bootstrap(DRM_IOCTL_ARGS);
+static int xgi_bootstrap(struct drm_device *, void *, struct drm_file *);
-static drm_ioctl_desc_t xgi_ioctls[] = {
- [DRM_IOCTL_NR(DRM_XGI_BOOTSTRAP)] = {xgi_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
+static struct drm_ioctl_desc xgi_ioctls[] = {
+ DRM_IOCTL_DEF(DRM_XGI_BOOTSTRAP, xgi_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- [DRM_IOCTL_NR(DRM_XGI_FB_ALLOC)] = {xgi_fb_alloc_ioctl, DRM_AUTH},
- [DRM_IOCTL_NR(DRM_XGI_FB_FREE)] = {xgi_fb_free_ioctl, DRM_AUTH},
+ DRM_IOCTL_DEF(DRM_XGI_FB_ALLOC, xgi_fb_alloc_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_XGI_FB_FREE, xgi_fb_free_ioctl, DRM_AUTH),
- [DRM_IOCTL_NR(DRM_XGI_PCIE_ALLOC)] = {xgi_pcie_alloc_ioctl, DRM_AUTH},
- [DRM_IOCTL_NR(DRM_XGI_PCIE_FREE)] = {xgi_pcie_free_ioctl, DRM_AUTH},
+ DRM_IOCTL_DEF(DRM_XGI_PCIE_ALLOC, xgi_pcie_alloc_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_XGI_PCIE_FREE, xgi_pcie_free_ioctl, DRM_AUTH),
- [DRM_IOCTL_NR(DRM_XGI_GE_RESET)] = {xgi_ge_reset_ioctl, DRM_AUTH},
- [DRM_IOCTL_NR(DRM_XGI_DUMP_REGISTER)] = {xgi_dump_register_ioctl, DRM_AUTH},
- [DRM_IOCTL_NR(DRM_XGI_DEBUG_INFO)] = {xgi_restore_registers_ioctl, DRM_AUTH},
- [DRM_IOCTL_NR(DRM_XGI_SUBMIT_CMDLIST)] = {xgi_submit_cmdlist_ioctl, DRM_AUTH},
- [DRM_IOCTL_NR(DRM_XGI_TEST_RWINKERNEL)] = {xgi_test_rwinkernel_ioctl, DRM_AUTH},
- [DRM_IOCTL_NR(DRM_XGI_STATE_CHANGE)] = {xgi_state_change_ioctl, DRM_AUTH|DRM_MASTER},
+ DRM_IOCTL_DEF(DRM_XGI_GE_RESET, xgi_ge_reset_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_XGI_DUMP_REGISTER, xgi_dump_register_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_XGI_DEBUG_INFO, xgi_restore_registers_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_XGI_SUBMIT_CMDLIST, xgi_submit_cmdlist, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_XGI_TEST_RWINKERNEL, xgi_test_rwinkernel_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_XGI_STATE_CHANGE, xgi_state_change_ioctl, DRM_AUTH|DRM_MASTER),
};
static const int xgi_max_ioctl = DRM_ARRAY_SIZE(xgi_ioctls);
@@ -61,8 +61,9 @@ static const int xgi_max_ioctl = DRM_ARRAY_SIZE(xgi_ioctls);
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent);
static int xgi_driver_load(struct drm_device *dev, unsigned long flags);
static int xgi_driver_unload(struct drm_device *dev);
-static void xgi_driver_preclose(struct drm_device * dev, DRMFILE filp);
-static void xgi_driver_lastclose(drm_device_t * dev);
+static void xgi_driver_preclose(struct drm_device * dev,
+ struct drm_file * filp);
+static void xgi_driver_lastclose(struct drm_device * dev);
static irqreturn_t xgi_kern_isr(DRM_IRQ_ARGS);
@@ -139,18 +140,15 @@ MODULE_LICENSE("GPL and additional rights");
void xgi_kern_isr_bh(struct drm_device *dev);
-int xgi_bootstrap(DRM_IOCTL_ARGS)
+int xgi_bootstrap(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
struct xgi_info *info = dev->dev_private;
- struct xgi_bootstrap bs;
+ struct xgi_bootstrap * bs = (struct xgi_bootstrap *) data;
struct drm_map_list *maplist;
int err;
- DRM_COPY_FROM_USER_IOCTL(bs, (struct xgi_bootstrap __user *) data,
- sizeof(bs));
-
if (info->mmio_map == NULL) {
err = drm_addmap(dev, info->mmio.base, info->mmio.size,
_DRM_REGISTERS, _DRM_KERNEL,
@@ -187,7 +185,7 @@ int xgi_bootstrap(DRM_IOCTL_ARGS)
}
- info->pcie.size = bs.gart.size;
+ info->pcie.size = bs->gart.size;
/* Init the resource manager */
if (!info->pcie_heap.initialized) {
@@ -224,16 +222,13 @@ int xgi_bootstrap(DRM_IOCTL_ARGS)
return -EINVAL;
}
- bs.gart = *info->pcie_map;
- bs.gart.handle = (void *)(unsigned long) maplist->user_token;
- DRM_COPY_TO_USER_IOCTL((struct xgi_bootstrap __user *) data,
- bs, sizeof(bs));
-
+ bs->gart = *info->pcie_map;
+ bs->gart.handle = (void *)(unsigned long) maplist->user_token;
return 0;
}
-void xgi_driver_preclose(struct drm_device * dev, DRMFILE filp)
+void xgi_driver_preclose(struct drm_device * dev, struct drm_file * filp)
{
struct xgi_info * info = dev->dev_private;
@@ -242,7 +237,7 @@ void xgi_driver_preclose(struct drm_device * dev, DRMFILE filp)
}
-void xgi_driver_lastclose(drm_device_t * dev)
+void xgi_driver_lastclose(struct drm_device * dev)
{
struct xgi_info * info = dev->dev_private;
diff --git a/linux-core/xgi_drv.h b/linux-core/xgi_drv.h
index 2061189a..8dec1fa1 100644
--- a/linux-core/xgi_drv.h
+++ b/linux-core/xgi_drv.h
@@ -52,7 +52,7 @@ struct xgi_mem_block {
struct list_head list;
unsigned long offset;
unsigned long size;
- DRMFILE filp;
+ struct drm_file * filp;
unsigned int owner;
};
@@ -111,7 +111,7 @@ extern struct kmem_cache *xgi_mem_block_cache;
extern struct xgi_mem_block *xgi_mem_alloc(struct xgi_mem_heap * heap,
unsigned long size, enum PcieOwner owner);
extern int xgi_mem_free(struct xgi_mem_heap * heap, unsigned long offset,
- DRMFILE filp);
+ struct drm_file * filp);
extern int xgi_mem_heap_init(struct xgi_mem_heap * heap, unsigned int start,
unsigned int end);
extern void xgi_mem_heap_cleanup(struct xgi_mem_heap * heap);
@@ -119,34 +119,44 @@ extern void xgi_mem_heap_cleanup(struct xgi_mem_heap * heap);
extern int xgi_fb_heap_init(struct xgi_info * info);
extern int xgi_fb_alloc(struct xgi_info * info, struct xgi_mem_alloc * alloc,
- DRMFILE filp);
+ struct drm_file * filp);
extern int xgi_fb_free(struct xgi_info * info, unsigned long offset,
- DRMFILE filp);
+ struct drm_file * filp);
extern int xgi_pcie_heap_init(struct xgi_info * info);
extern void xgi_pcie_lut_cleanup(struct xgi_info * info);
extern int xgi_pcie_alloc(struct xgi_info * info,
- struct xgi_mem_alloc * alloc, DRMFILE filp);
+ struct xgi_mem_alloc * alloc, struct drm_file * filp);
extern int xgi_pcie_free(struct xgi_info * info, unsigned long offset,
- DRMFILE filp);
+ struct drm_file * filp);
extern void *xgi_find_pcie_virt(struct xgi_info * info, u32 address);
-extern void xgi_pcie_free_all(struct xgi_info *, DRMFILE);
-extern void xgi_fb_free_all(struct xgi_info *, DRMFILE);
-
-extern int xgi_fb_alloc_ioctl(DRM_IOCTL_ARGS);
-extern int xgi_fb_free_ioctl(DRM_IOCTL_ARGS);
-extern int xgi_pcie_alloc_ioctl(DRM_IOCTL_ARGS);
-extern int xgi_pcie_free_ioctl(DRM_IOCTL_ARGS);
-extern int xgi_ge_reset_ioctl(DRM_IOCTL_ARGS);
-extern int xgi_dump_register_ioctl(DRM_IOCTL_ARGS);
-extern int xgi_restore_registers_ioctl(DRM_IOCTL_ARGS);
-extern int xgi_submit_cmdlist_ioctl(DRM_IOCTL_ARGS);
-extern int xgi_test_rwinkernel_ioctl(DRM_IOCTL_ARGS);
-extern int xgi_state_change_ioctl(DRM_IOCTL_ARGS);
+extern void xgi_pcie_free_all(struct xgi_info *, struct drm_file *);
+extern void xgi_fb_free_all(struct xgi_info *, struct drm_file *);
+
+extern int xgi_fb_alloc_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp);
+extern int xgi_fb_free_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp);
+extern int xgi_pcie_alloc_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp);
+extern int xgi_pcie_free_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp);
+extern int xgi_ge_reset_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp);
+extern int xgi_dump_register_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp);
+extern int xgi_restore_registers_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp);
+extern int xgi_submit_cmdlist(struct drm_device * dev, void * data,
+ struct drm_file * filp);
+extern int xgi_test_rwinkernel_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp);
+extern int xgi_state_change_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp);
#endif
diff --git a/linux-core/xgi_fb.c b/linux-core/xgi_fb.c
index 10343c13..9c60a874 100644
--- a/linux-core/xgi_fb.c
+++ b/linux-core/xgi_fb.c
@@ -94,7 +94,7 @@ struct xgi_mem_block *xgi_mem_new_node(void)
block->offset = 0;
block->size = 0;
block->owner = PCIE_INVALID;
- block->filp = (DRMFILE) -1;
+ block->filp = (struct drm_file *) -1;
return block;
}
@@ -173,7 +173,7 @@ struct xgi_mem_block *xgi_mem_alloc(struct xgi_mem_heap * heap,
}
int xgi_mem_free(struct xgi_mem_heap * heap, unsigned long offset,
- DRMFILE filp)
+ struct drm_file * filp)
{
struct xgi_mem_block *used_block = NULL, *block;
struct xgi_mem_block *prev, *next;
@@ -246,7 +246,7 @@ int xgi_mem_free(struct xgi_mem_heap * heap, unsigned long offset,
int xgi_fb_alloc(struct xgi_info * info, struct xgi_mem_alloc * alloc,
- DRMFILE filp)
+ struct drm_file * filp)
{
struct xgi_mem_block *block;
@@ -282,29 +282,19 @@ int xgi_fb_alloc(struct xgi_info * info, struct xgi_mem_alloc * alloc,
}
-int xgi_fb_alloc_ioctl(DRM_IOCTL_ARGS)
+int xgi_fb_alloc_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
- struct xgi_mem_alloc alloc;
+ struct xgi_mem_alloc *alloc =
+ (struct xgi_mem_alloc *) data;
struct xgi_info *info = dev->dev_private;
- int err;
- DRM_COPY_FROM_USER_IOCTL(alloc, (struct xgi_mem_alloc __user *) data,
- sizeof(alloc));
-
- err = xgi_fb_alloc(info, & alloc, filp);
- if (err) {
- return err;
- }
-
- DRM_COPY_TO_USER_IOCTL((struct xgi_mem_alloc __user *) data,
- alloc, sizeof(alloc));
-
- return 0;
+ return xgi_fb_alloc(info, alloc, filp);
}
-int xgi_fb_free(struct xgi_info * info, unsigned long offset, DRMFILE filp)
+int xgi_fb_free(struct xgi_info * info, unsigned long offset,
+ struct drm_file * filp)
{
int err = 0;
@@ -320,16 +310,12 @@ int xgi_fb_free(struct xgi_info * info, unsigned long offset, DRMFILE filp)
}
-int xgi_fb_free_ioctl(DRM_IOCTL_ARGS)
+int xgi_fb_free_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
struct xgi_info *info = dev->dev_private;
- u32 offset;
-
- DRM_COPY_FROM_USER_IOCTL(offset, (unsigned long __user *) data,
- sizeof(offset));
- return xgi_fb_free(info, offset, filp);
+ return xgi_fb_free(info, *(u32 *) data, filp);
}
@@ -342,7 +328,7 @@ int xgi_fb_heap_init(struct xgi_info * info)
/**
* Free all blocks associated with a particular file handle.
*/
-void xgi_fb_free_all(struct xgi_info * info, DRMFILE filp)
+void xgi_fb_free_all(struct xgi_info * info, struct drm_file * filp)
{
if (!info->fb_heap.initialized) {
return;
diff --git a/linux-core/xgi_misc.c b/linux-core/xgi_misc.c
index 5e8c3da8..6c029782 100644
--- a/linux-core/xgi_misc.c
+++ b/linux-core/xgi_misc.c
@@ -27,9 +27,9 @@
#include "xgi_drv.h"
#include "xgi_regs.h"
-int xgi_ge_reset_ioctl(DRM_IOCTL_ARGS)
+int xgi_ge_reset_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
struct xgi_info *info = dev->dev_private;
xgi_disable_ge(info);
@@ -436,25 +436,23 @@ void xgi_dump_register(struct xgi_info * info)
}
-int xgi_dump_register_ioctl(DRM_IOCTL_ARGS)
+int xgi_dump_register_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
struct xgi_info *info = dev->dev_private;
xgi_dump_register(info);
-
return 0;
}
-int xgi_restore_registers_ioctl(DRM_IOCTL_ARGS)
+int xgi_restore_registers_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
struct xgi_info *info = dev->dev_private;
OUT3X5B(info->mmio_map, 0x13, 0);
OUT3X5B(info->mmio_map, 0x8b, 2);
-
return 0;
}
diff --git a/linux-core/xgi_pcie.c b/linux-core/xgi_pcie.c
index 4c369a2a..b91471b8 100644
--- a/linux-core/xgi_pcie.c
+++ b/linux-core/xgi_pcie.c
@@ -33,7 +33,7 @@ static struct xgi_mem_block *xgi_pcie_cmdlist_block = NULL;
static struct xgi_mem_block *xgi_pcie_scratchpad_block = NULL;
static int xgi_pcie_free_locked(struct xgi_info * info,
- unsigned long offset, DRMFILE filp);
+ unsigned long offset, struct drm_file * filp);
static int xgi_pcie_lut_init(struct xgi_info * info)
{
@@ -148,7 +148,7 @@ int xgi_pcie_heap_init(struct xgi_info * info)
int xgi_pcie_alloc(struct xgi_info * info, struct xgi_mem_alloc * alloc,
- DRMFILE filp)
+ struct drm_file * filp)
{
struct xgi_mem_block *block;
@@ -199,32 +199,21 @@ int xgi_pcie_alloc(struct xgi_info * info, struct xgi_mem_alloc * alloc,
}
-int xgi_pcie_alloc_ioctl(DRM_IOCTL_ARGS)
+int xgi_pcie_alloc_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
- struct xgi_mem_alloc alloc;
+ struct xgi_mem_alloc *const alloc =
+ (struct xgi_mem_alloc *) data;
struct xgi_info *info = dev->dev_private;
- int err;
-
- DRM_COPY_FROM_USER_IOCTL(alloc, (struct xgi_mem_alloc __user *) data,
- sizeof(alloc));
-
- err = xgi_pcie_alloc(info, & alloc, filp);
- if (err) {
- return err;
- }
-
- DRM_COPY_TO_USER_IOCTL((struct xgi_mem_alloc __user *) data,
- alloc, sizeof(alloc));
- return 0;
+ return xgi_pcie_alloc(info, alloc, filp);
}
/**
* Free all blocks associated with a particular file handle.
*/
-void xgi_pcie_free_all(struct xgi_info * info, DRMFILE filp)
+void xgi_pcie_free_all(struct xgi_info * info, struct drm_file * filp)
{
if (!info->pcie_heap.initialized) {
return;
@@ -252,8 +241,8 @@ void xgi_pcie_free_all(struct xgi_info * info, DRMFILE filp)
}
-int xgi_pcie_free_locked(struct xgi_info * info,
- unsigned long offset, DRMFILE filp)
+int xgi_pcie_free_locked(struct xgi_info * info, unsigned long offset,
+ struct drm_file * filp)
{
const bool isvertex = (xgi_pcie_vertex_block
&& (xgi_pcie_vertex_block->offset == offset));
@@ -266,7 +255,8 @@ int xgi_pcie_free_locked(struct xgi_info * info,
}
-int xgi_pcie_free(struct xgi_info * info, unsigned long offset, DRMFILE filp)
+int xgi_pcie_free(struct xgi_info * info, unsigned long offset,
+ struct drm_file * filp)
{
int err;
@@ -282,16 +272,12 @@ int xgi_pcie_free(struct xgi_info * info, unsigned long offset, DRMFILE filp)
}
-int xgi_pcie_free_ioctl(DRM_IOCTL_ARGS)
+int xgi_pcie_free_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
struct xgi_info *info = dev->dev_private;
- u32 offset;
-
- DRM_COPY_FROM_USER_IOCTL(offset, (unsigned long __user *) data,
- sizeof(offset));
- return xgi_pcie_free(info, offset, filp);
+ return xgi_pcie_free(info, *(u32 *) data, filp);
}
@@ -312,15 +298,13 @@ void *xgi_find_pcie_virt(struct xgi_info * info, u32 address)
/*
address -- GE hw address
*/
-int xgi_test_rwinkernel_ioctl(DRM_IOCTL_ARGS)
+int xgi_test_rwinkernel_ioctl(struct drm_device * dev, void * data,
+ struct drm_file * filp)
{
- DRM_DEVICE;
struct xgi_info *info = dev->dev_private;
- u32 address;
+ u32 address = *(u32 *) data;
u32 *virtaddr = 0;
- DRM_COPY_FROM_USER_IOCTL(address, (unsigned long __user *) data,
- sizeof(address));
DRM_INFO("input GE HW addr is 0x%x\n", address);