Skip to content

Commit

Permalink
drm: Replace filp in ioctl arguments with drm_file *file_priv.
Browse files Browse the repository at this point in the history
As a fallout, replace filp storage with file_priv storage for "unique
identifier of a client" all over the DRM.  There is a 1:1 mapping, so this
should be a noop.  This could be a minor performance improvement, as everyth
on Linux dereferenced filp to get file_priv anyway, while only the mmap ioct
went the other direction.

Signed-off-by: Dave Airlie <airlied@linux.ie>
  • Loading branch information
Eric Anholt authored and Dave Airlie committed Oct 15, 2007
1 parent 20caafa commit 6c340ea
Show file tree
Hide file tree
Showing 43 changed files with 603 additions and 661 deletions.
112 changes: 58 additions & 54 deletions drivers/char/drm/drmP.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#ifndef _DRM_P_H_
#define _DRM_P_H_

struct drm_file;

/* If you want the memory alloc debug functionality, change define below */
/* #define DEBUG_MEMORY */

Expand Down Expand Up @@ -257,11 +259,11 @@ do { \
* Ioctl function type.
*
* \param inode device inode.
* \param filp file pointer.
* \param file_priv DRM file private pointer.
* \param cmd command.
* \param arg argument.
*/
typedef int drm_ioctl_t(struct inode *inode, struct file *filp,
typedef int drm_ioctl_t(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);

typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
Expand Down Expand Up @@ -304,7 +306,7 @@ struct drm_buf {
__volatile__ int waiting; /**< On kernel DMA queue */
__volatile__ int pending; /**< On hardware DMA queue */
wait_queue_head_t dma_wait; /**< Processes waiting */
struct file *filp; /**< Pointer to holding file descr */
struct drm_file *file_priv; /**< Private of holding file descr */
int context; /**< Kernel queue for this buffer */
int while_locked; /**< Dispatch this buffer while locked */
enum {
Expand Down Expand Up @@ -377,6 +379,7 @@ struct drm_file {
int remove_auth_on_close;
unsigned long lock_count;
void *driver_priv;
struct file *filp;
};

/** Wait queue */
Expand All @@ -403,7 +406,7 @@ struct drm_queue {
*/
struct drm_lock_data {
struct drm_hw_lock *hw_lock; /**< Hardware lock */
struct file *filp; /**< File descr of lock holder (0=kernel) */
struct drm_file *file_priv; /**< File descr of lock holder (0=kernel) */
wait_queue_head_t lock_queue; /**< Queue of blocked processes */
unsigned long lock_time; /**< Time of last lock in jiffies */
spinlock_t spinlock;
Expand Down Expand Up @@ -552,7 +555,7 @@ struct drm_driver {
int (*load) (struct drm_device *, unsigned long flags);
int (*firstopen) (struct drm_device *);
int (*open) (struct drm_device *, struct drm_file *);
void (*preclose) (struct drm_device *, struct file * filp);
void (*preclose) (struct drm_device *, struct drm_file *file_priv);
void (*postclose) (struct drm_device *, struct drm_file *);
void (*lastclose) (struct drm_device *);
int (*unload) (struct drm_device *);
Expand Down Expand Up @@ -587,11 +590,12 @@ struct drm_driver {
void (*irq_preinstall) (struct drm_device *dev);
void (*irq_postinstall) (struct drm_device *dev);
void (*irq_uninstall) (struct drm_device *dev);
void (*reclaim_buffers) (struct drm_device *dev, struct file * filp);
void (*reclaim_buffers) (struct drm_device *dev,
struct drm_file * file_priv);
void (*reclaim_buffers_locked) (struct drm_device *dev,
struct file *filp);
struct drm_file *file_priv);
void (*reclaim_buffers_idlelocked) (struct drm_device *dev,
struct file * filp);
struct drm_file *file_priv);
unsigned long (*get_map_ofs) (struct drm_map * map);
unsigned long (*get_reg_ofs) (struct drm_device *dev);
void (*set_version) (struct drm_device *dev,
Expand Down Expand Up @@ -850,69 +854,69 @@ extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
extern int drm_unbind_agp(DRM_AGP_MEM * handle);

/* Misc. IOCTL support (drm_ioctl.h) */
extern int drm_irq_by_busid(struct inode *inode, struct file *filp,
extern int drm_irq_by_busid(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_getunique(struct inode *inode, struct file *filp,
extern int drm_getunique(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_setunique(struct inode *inode, struct file *filp,
extern int drm_setunique(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_getmap(struct inode *inode, struct file *filp,
extern int drm_getmap(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_getclient(struct inode *inode, struct file *filp,
extern int drm_getclient(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_getstats(struct inode *inode, struct file *filp,
extern int drm_getstats(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_setversion(struct inode *inode, struct file *filp,
extern int drm_setversion(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_noop(struct inode *inode, struct file *filp,
extern int drm_noop(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);

/* Context IOCTL support (drm_context.h) */
extern int drm_resctx(struct inode *inode, struct file *filp,
extern int drm_resctx(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_addctx(struct inode *inode, struct file *filp,
extern int drm_addctx(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_modctx(struct inode *inode, struct file *filp,
extern int drm_modctx(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_getctx(struct inode *inode, struct file *filp,
extern int drm_getctx(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_switchctx(struct inode *inode, struct file *filp,
extern int drm_switchctx(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_newctx(struct inode *inode, struct file *filp,
extern int drm_newctx(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_rmctx(struct inode *inode, struct file *filp,
extern int drm_rmctx(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);

extern int drm_ctxbitmap_init(struct drm_device *dev);
extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);

extern int drm_setsareactx(struct inode *inode, struct file *filp,
extern int drm_setsareactx(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_getsareactx(struct inode *inode, struct file *filp,
extern int drm_getsareactx(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);

/* Drawable IOCTL support (drm_drawable.h) */
extern int drm_adddraw(struct inode *inode, struct file *filp,
extern int drm_adddraw(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_rmdraw(struct inode *inode, struct file *filp,
extern int drm_rmdraw(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_update_drawable_info(struct inode *inode, struct file *filp,
extern int drm_update_drawable_info(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
drm_drawable_t id);
extern void drm_drawable_free_all(struct drm_device *dev);

/* Authentication IOCTL support (drm_auth.h) */
extern int drm_getmagic(struct inode *inode, struct file *filp,
extern int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_authmagic(struct inode *inode, struct file *filp,
extern int drm_authmagic(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);

/* Locking IOCTL support (drm_lock.h) */
extern int drm_lock(struct inode *inode, struct file *filp,
extern int drm_lock(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_unlock(struct inode *inode, struct file *filp,
extern int drm_unlock(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
Expand All @@ -924,32 +928,31 @@ extern void drm_idlelock_release(struct drm_lock_data *lock_data);
* DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
*/

extern int drm_i_have_hw_lock(struct file *filp);
extern int drm_kernel_take_hw_lock(struct file *filp);
extern int drm_i_have_hw_lock(struct drm_file *file_priv);

/* Buffer management support (drm_bufs.h) */
extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
extern int drm_addmap(struct drm_device *dev, unsigned int offset,
unsigned int size, enum drm_map_type type,
enum drm_map_flags flags, drm_local_map_t ** map_ptr);
extern int drm_addmap_ioctl(struct inode *inode, struct file *filp,
extern int drm_addmap_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_rmmap(struct drm_device *dev, drm_local_map_t * map);
extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t * map);
extern int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
extern int drm_rmmap_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);

extern int drm_order(unsigned long size);
extern int drm_addbufs(struct inode *inode, struct file *filp,
extern int drm_addbufs(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_infobufs(struct inode *inode, struct file *filp,
extern int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_markbufs(struct inode *inode, struct file *filp,
extern int drm_markbufs(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_freebufs(struct inode *inode, struct file *filp,
extern int drm_freebufs(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_mapbufs(struct inode *inode, struct file *filp,
extern int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern unsigned long drm_get_resource_start(struct drm_device *dev,
unsigned int resource);
Expand All @@ -960,18 +963,19 @@ extern unsigned long drm_get_resource_len(struct drm_device *dev,
extern int drm_dma_setup(struct drm_device *dev);
extern void drm_dma_takedown(struct drm_device *dev);
extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
extern void drm_core_reclaim_buffers(struct drm_device *dev, struct file *filp);
extern void drm_core_reclaim_buffers(struct drm_device *dev,
struct drm_file *filp);

/* IRQ support (drm_irq.h) */
extern int drm_control(struct inode *inode, struct file *filp,
extern int drm_control(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
extern int drm_irq_uninstall(struct drm_device *dev);
extern void drm_driver_irq_preinstall(struct drm_device *dev);
extern void drm_driver_irq_postinstall(struct drm_device *dev);
extern void drm_driver_irq_uninstall(struct drm_device *dev);

extern int drm_wait_vblank(struct inode *inode, struct file *filp,
extern int drm_wait_vblank(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
extern void drm_vbl_send_signals(struct drm_device *dev);
Expand All @@ -980,28 +984,28 @@ extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_de
/* AGP/GART support (drm_agpsupport.h) */
extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
extern int drm_agp_acquire(struct drm_device *dev);
extern int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp,
extern int drm_agp_acquire_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_agp_release(struct drm_device *dev);
extern int drm_agp_release_ioctl(struct inode *inode, struct file *filp,
extern int drm_agp_release_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
extern int drm_agp_enable_ioctl(struct inode *inode, struct file *filp,
extern int drm_agp_enable_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info * info);
extern int drm_agp_info_ioctl(struct inode *inode, struct file *filp,
extern int drm_agp_info_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
extern int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp,
extern int drm_agp_alloc_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
extern int drm_agp_free_ioctl(struct inode *inode, struct file *filp,
extern int drm_agp_free_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
extern int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp,
extern int drm_agp_unbind_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
extern int drm_agp_bind_ioctl(struct inode *inode, struct file *filp,
extern int drm_agp_bind_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge,
size_t pages, u32 type);
Expand Down Expand Up @@ -1033,9 +1037,9 @@ extern int drm_proc_cleanup(int minor,

/* Scatter Gather Support (drm_scatter.h) */
extern void drm_sg_cleanup(struct drm_sg_mem * entry);
extern int drm_sg_alloc(struct inode *inode, struct file *filp,
extern int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);
extern int drm_sg_free(struct inode *inode, struct file *filp,
extern int drm_sg_free(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg);

/* ATI PCIGART support (ati_pcigart.h) */
Expand Down
Loading

0 comments on commit 6c340ea

Please sign in to comment.