Commit d985c108 authored by Dave Airlie's avatar Dave Airlie Committed by Dave Airlie
Browse files

drm: major update from CVS for radeon and core



This patch pull in a lot of changes from CVS to the main core DRM,
and updates the radeon driver to 1.21.0 that supports r300 texrect
and radeon card type ioctl.

Signed-off-by: default avatarDave Airlie <airlied@linux.ie>
parent b0cae664
Loading
Loading
Loading
Loading
+6 −12
Original line number Original line Diff line number Diff line
@@ -574,12 +574,11 @@ struct drm_driver {
	void (*irq_postinstall) (struct drm_device * dev);
	void (*irq_postinstall) (struct drm_device * dev);
	void (*irq_uninstall) (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 file * filp);
	void (*reclaim_buffers_locked) (struct drm_device *drv,
	void (*reclaim_buffers_locked) (struct drm_device *dev,
					struct file *filp);
					struct file *filp);
	unsigned long (*get_map_ofs) (drm_map_t * map);
	unsigned long (*get_map_ofs) (drm_map_t * map);
	unsigned long (*get_reg_ofs) (struct drm_device * dev);
	unsigned long (*get_reg_ofs) (struct drm_device * dev);
	void (*set_version) (struct drm_device * dev, drm_set_version_t * sv);
	void (*set_version) (struct drm_device * dev, drm_set_version_t * sv);
	int (*version) (drm_version_t * version);


	int major;
	int major;
	int minor;
	int minor;
@@ -774,10 +773,6 @@ static inline int drm_mtrr_del(int handle, unsigned long offset,
/** \name Internal function definitions */
/** \name Internal function definitions */
/*@{*/
/*@{*/


				/* Misc. support (drm_init.h) */
extern int drm_flags;
extern void drm_parse_options(char *s);

				/* Driver support (drm_drv.h) */
				/* Driver support (drm_drv.h) */
extern int drm_init(struct drm_driver *driver);
extern int drm_init(struct drm_driver *driver);
extern void drm_exit(struct drm_driver *driver);
extern void drm_exit(struct drm_driver *driver);
@@ -831,6 +826,8 @@ extern int drm_getstats(struct inode *inode, struct file *filp,
			unsigned int cmd, unsigned long arg);
			unsigned int cmd, unsigned long arg);
extern int drm_setversion(struct inode *inode, struct file *filp,
extern int drm_setversion(struct inode *inode, struct file *filp,
			  unsigned int cmd, unsigned long arg);
			  unsigned int cmd, unsigned long arg);
extern int drm_noop(struct inode *inode, struct file *filp,
		    unsigned int cmd, unsigned long arg);


				/* Context IOCTL support (drm_context.h) */
				/* Context IOCTL support (drm_context.h) */
extern int drm_resctx(struct inode *inode, struct file *filp,
extern int drm_resctx(struct inode *inode, struct file *filp,
@@ -867,10 +864,6 @@ extern int drm_rmdraw(struct inode *inode, struct file *filp,
extern int drm_getmagic(struct inode *inode, struct file *filp,
extern int drm_getmagic(struct inode *inode, struct file *filp,
			unsigned int cmd, unsigned long arg);
			unsigned int cmd, unsigned long arg);
extern int drm_authmagic(struct inode *inode, struct file *filp,
extern int drm_authmagic(struct inode *inode, struct file *filp,
			 unsigned int cmd, unsigned long arg);

				/* Placeholder for ioctls past */
extern int drm_noop(struct inode *inode, struct file *filp,
			 unsigned int cmd, unsigned long arg);
			 unsigned int cmd, unsigned long arg);


				/* Locking IOCTL support (drm_lock.h) */
				/* Locking IOCTL support (drm_lock.h) */
@@ -885,6 +878,7 @@ extern int drm_lock_free(drm_device_t * dev,
				/* Buffer management support (drm_bufs.h) */
				/* Buffer management support (drm_bufs.h) */
extern int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request);
extern int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request);
extern int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request);
extern int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request);
extern int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request);
extern int drm_addmap(drm_device_t * dev, unsigned int offset,
extern int drm_addmap(drm_device_t * dev, unsigned int offset,
		      unsigned int size, drm_map_type_t type,
		      unsigned int size, drm_map_type_t type,
		      drm_map_flags_t flags, drm_local_map_t ** map_ptr);
		      drm_map_flags_t flags, drm_local_map_t ** map_ptr);
@@ -920,8 +914,8 @@ extern void drm_core_reclaim_buffers(drm_device_t * dev, struct file *filp);
				/* IRQ support (drm_irq.h) */
				/* IRQ support (drm_irq.h) */
extern int drm_control(struct inode *inode, struct file *filp,
extern int drm_control(struct inode *inode, struct file *filp,
		       unsigned int cmd, unsigned long arg);
		       unsigned int cmd, unsigned long arg);
extern int drm_irq_uninstall(drm_device_t * dev);
extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
extern int drm_irq_uninstall(drm_device_t * dev);
extern void drm_driver_irq_preinstall(drm_device_t * dev);
extern void drm_driver_irq_preinstall(drm_device_t * dev);
extern void drm_driver_irq_postinstall(drm_device_t * dev);
extern void drm_driver_irq_postinstall(drm_device_t * dev);
extern void drm_driver_irq_uninstall(drm_device_t * dev);
extern void drm_driver_irq_uninstall(drm_device_t * dev);
+6 −4
Original line number Original line Diff line number Diff line
/**
/**
 * \file drm_agpsupport.h
 * \file drm_agpsupport.c
 * DRM support for AGP/GART backend
 * DRM support for AGP/GART backend
 *
 *
 * \author Rickard E. (Rik) Faith <faith@valinux.com>
 * \author Rickard E. (Rik) Faith <faith@valinux.com>
@@ -91,7 +91,7 @@ int drm_agp_info_ioctl(struct inode *inode, struct file *filp,
/**
/**
 * Acquire the AGP device.
 * Acquire the AGP device.
 *
 *
 * \param dev DRM device that is to acquire AGP
 * \param dev DRM device that is to acquire AGP.
 * \return zero on success or a negative number on failure.
 * \return zero on success or a negative number on failure.
 *
 *
 * Verifies the AGP device hasn't been acquired before and calls
 * Verifies the AGP device hasn't been acquired before and calls
@@ -134,7 +134,7 @@ int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp,
/**
/**
 * Release the AGP device.
 * Release the AGP device.
 *
 *
 * \param dev DRM device that is to release AGP
 * \param dev DRM device that is to release AGP.
 * \return zero on success or a negative number on failure.
 * \return zero on success or a negative number on failure.
 *
 *
 * Verifies the AGP device has been acquired and calls \c agp_backend_release.
 * Verifies the AGP device has been acquired and calls \c agp_backend_release.
@@ -147,7 +147,6 @@ int drm_agp_release(drm_device_t * dev)
	dev->agp->acquired = 0;
	dev->agp->acquired = 0;
	return 0;
	return 0;
}
}

EXPORT_SYMBOL(drm_agp_release);
EXPORT_SYMBOL(drm_agp_release);


int drm_agp_release_ioctl(struct inode *inode, struct file *filp,
int drm_agp_release_ioctl(struct inode *inode, struct file *filp,
@@ -447,6 +446,9 @@ int drm_agp_free_ioctl(struct inode *inode, struct file *filp,
 *
 *
 * \return pointer to a drm_agp_head structure.
 * \return pointer to a drm_agp_head structure.
 *
 *
 * Gets the drm_agp_t structure which is made available by the agpgart module
 * via the inter_module_* functions. Creates and initializes a drm_agp_head
 * structure.
 */
 */
drm_agp_head_t *drm_agp_init(drm_device_t * dev)
drm_agp_head_t *drm_agp_init(drm_device_t * dev)
{
{
+32 −15
Original line number Original line Diff line number Diff line
@@ -40,7 +40,6 @@ unsigned long drm_get_resource_start(drm_device_t * dev, unsigned int resource)
{
{
	return pci_resource_start(dev->pdev, resource);
	return pci_resource_start(dev->pdev, resource);
}
}

EXPORT_SYMBOL(drm_get_resource_start);
EXPORT_SYMBOL(drm_get_resource_start);


unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource)
unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource)
@@ -301,6 +300,9 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp,
		return -EFAULT;
		return -EFAULT;
	}
	}


	if (!(capable(CAP_SYS_ADMIN) || map.type == _DRM_AGP))
		return -EPERM;

	err = drm_addmap_core(dev, map.offset, map.size, map.type, map.flags,
	err = drm_addmap_core(dev, map.offset, map.size, map.type, map.flags,
			      &maplist);
			      &maplist);


@@ -384,7 +386,6 @@ int drm_rmmap_locked(drm_device_t * dev, drm_local_map_t * map)


	return 0;
	return 0;
}
}

EXPORT_SYMBOL(drm_rmmap_locked);
EXPORT_SYMBOL(drm_rmmap_locked);


int drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
int drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
@@ -397,7 +398,6 @@ int drm_rmmap(drm_device_t * dev, drm_local_map_t * map)


	return ret;
	return ret;
}
}

EXPORT_SYMBOL(drm_rmmap);
EXPORT_SYMBOL(drm_rmmap);


/* The rmmap ioctl appears to be unnecessary.  All mappings are torn down on
/* The rmmap ioctl appears to be unnecessary.  All mappings are torn down on
@@ -548,7 +548,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
	DRM_DEBUG("count:      %d\n", count);
	DRM_DEBUG("count:      %d\n", count);
	DRM_DEBUG("order:      %d\n", order);
	DRM_DEBUG("order:      %d\n", order);
	DRM_DEBUG("size:       %d\n", size);
	DRM_DEBUG("size:       %d\n", size);
	DRM_DEBUG("agp_offset: %lu\n", agp_offset);
	DRM_DEBUG("agp_offset: %lx\n", agp_offset);
	DRM_DEBUG("alignment:  %d\n", alignment);
	DRM_DEBUG("alignment:  %d\n", alignment);
	DRM_DEBUG("page_order: %d\n", page_order);
	DRM_DEBUG("page_order: %d\n", page_order);
	DRM_DEBUG("total:      %d\n", total);
	DRM_DEBUG("total:      %d\n", total);
@@ -649,6 +649,8 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
	}
	}


	dma->buf_count += entry->buf_count;
	dma->buf_count += entry->buf_count;
	dma->seg_count += entry->seg_count;
	dma->page_count += byte_count >> PAGE_SHIFT;
	dma->byte_count += byte_count;
	dma->byte_count += byte_count;


	DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
	DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
@@ -664,7 +666,6 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
	atomic_dec(&dev->buf_alloc);
	atomic_dec(&dev->buf_alloc);
	return 0;
	return 0;
}
}

EXPORT_SYMBOL(drm_addbufs_agp);
EXPORT_SYMBOL(drm_addbufs_agp);
#endif				/* __OS_HAS_AGP */
#endif				/* __OS_HAS_AGP */


@@ -689,9 +690,13 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)


	if (!drm_core_check_feature(dev, DRIVER_PCI_DMA))
	if (!drm_core_check_feature(dev, DRIVER_PCI_DMA))
		return -EINVAL;
		return -EINVAL;

	if (!dma)
	if (!dma)
		return -EINVAL;
		return -EINVAL;


	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;

	count = request->count;
	count = request->count;
	order = drm_order(request->size);
	order = drm_order(request->size);
	size = 1 << order;
	size = 1 << order;
@@ -882,7 +887,6 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
	return 0;
	return 0;


}
}

EXPORT_SYMBOL(drm_addbufs_pci);
EXPORT_SYMBOL(drm_addbufs_pci);


static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
@@ -908,6 +912,9 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
	if (!dma)
	if (!dma)
		return -EINVAL;
		return -EINVAL;


	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;

	count = request->count;
	count = request->count;
	order = drm_order(request->size);
	order = drm_order(request->size);
	size = 1 << order;
	size = 1 << order;
@@ -1026,6 +1033,8 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
	}
	}


	dma->buf_count += entry->buf_count;
	dma->buf_count += entry->buf_count;
	dma->seg_count += entry->seg_count;
	dma->page_count += byte_count >> PAGE_SHIFT;
	dma->byte_count += byte_count;
	dma->byte_count += byte_count;


	DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
	DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
@@ -1042,7 +1051,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
	return 0;
	return 0;
}
}


static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
{
{
	drm_device_dma_t *dma = dev->dma;
	drm_device_dma_t *dma = dev->dma;
	drm_buf_entry_t *entry;
	drm_buf_entry_t *entry;
@@ -1065,6 +1074,9 @@ static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
	if (!dma)
	if (!dma)
		return -EINVAL;
		return -EINVAL;


	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;

	count = request->count;
	count = request->count;
	order = drm_order(request->size);
	order = drm_order(request->size);
	size = 1 << order;
	size = 1 << order;
@@ -1181,6 +1193,8 @@ static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
	}
	}


	dma->buf_count += entry->buf_count;
	dma->buf_count += entry->buf_count;
	dma->seg_count += entry->seg_count;
	dma->page_count += byte_count >> PAGE_SHIFT;
	dma->byte_count += byte_count;
	dma->byte_count += byte_count;


	DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
	DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
@@ -1196,6 +1210,8 @@ static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
	atomic_dec(&dev->buf_alloc);
	atomic_dec(&dev->buf_alloc);
	return 0;
	return 0;
}
}
EXPORT_SYMBOL(drm_addbufs_fb);



/**
/**
 * Add buffers for DMA transfers (ioctl).
 * Add buffers for DMA transfers (ioctl).
@@ -1577,5 +1593,6 @@ int drm_order(unsigned long size)


	return order;
	return order;
}
}

EXPORT_SYMBOL(drm_order);
EXPORT_SYMBOL(drm_order);

+166 −123
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@
 */
 */


#include "drmP.h"
#include "drmP.h"
#include "drm_sarea.h"
#include <linux/poll.h>
#include <linux/poll.h>


static int drm_open_helper(struct inode *inode, struct file *filp,
static int drm_open_helper(struct inode *inode, struct file *filp,
@@ -42,6 +43,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,


static int drm_setup(drm_device_t * dev)
static int drm_setup(drm_device_t * dev)
{
{
	drm_local_map_t *map;
	int i;
	int i;
	int ret;
	int ret;


@@ -51,6 +53,11 @@ static int drm_setup(drm_device_t * dev)
			return ret;
			return ret;
	}
	}


	/* prebuild the SAREA */
	i = drm_addmap(dev, 0, SAREA_MAX, _DRM_SHM, _DRM_CONTAINS_LOCK, &map);
	if (i != 0)
		return i;

	atomic_set(&dev->ioctl_count, 0);
	atomic_set(&dev->ioctl_count, 0);
	atomic_set(&dev->vma_count, 0);
	atomic_set(&dev->vma_count, 0);
	dev->buf_use = 0;
	dev->buf_use = 0;
@@ -152,9 +159,167 @@ int drm_open(struct inode *inode, struct file *filp)


	return retcode;
	return retcode;
}
}

EXPORT_SYMBOL(drm_open);
EXPORT_SYMBOL(drm_open);


/**
 * File \c open operation.
 *
 * \param inode device inode.
 * \param filp file pointer.
 *
 * Puts the dev->fops corresponding to the device minor number into
 * \p filp, call the \c open method, and restore the file operations.
 */
int drm_stub_open(struct inode *inode, struct file *filp)
{
	drm_device_t *dev = NULL;
	int minor = iminor(inode);
	int err = -ENODEV;
	struct file_operations *old_fops;

	DRM_DEBUG("\n");

	if (!((minor >= 0) && (minor < drm_cards_limit)))
		return -ENODEV;

	if (!drm_heads[minor])
		return -ENODEV;

	if (!(dev = drm_heads[minor]->dev))
		return -ENODEV;

	old_fops = filp->f_op;
	filp->f_op = fops_get(&dev->driver->fops);
	if (filp->f_op->open && (err = filp->f_op->open(inode, filp))) {
		fops_put(filp->f_op);
		filp->f_op = fops_get(old_fops);
	}
	fops_put(old_fops);

	return err;
}

/**
 * Check whether DRI will run on this CPU.
 *
 * \return non-zero if the DRI will run on this CPU, or zero otherwise.
 */
static int drm_cpu_valid(void)
{
#if defined(__i386__)
	if (boot_cpu_data.x86 == 3)
		return 0;	/* No cmpxchg on a 386 */
#endif
#if defined(__sparc__) && !defined(__sparc_v9__)
	return 0;		/* No cmpxchg before v9 sparc. */
#endif
	return 1;
}

/**
 * Called whenever a process opens /dev/drm.
 *
 * \param inode device inode.
 * \param filp file pointer.
 * \param dev device.
 * \return zero on success or a negative number on failure.
 *
 * Creates and initializes a drm_file structure for the file private data in \p
 * filp and add it into the double linked list in \p dev.
 */
static int drm_open_helper(struct inode *inode, struct file *filp,
			   drm_device_t * dev)
{
	int minor = iminor(inode);
	drm_file_t *priv;
	int ret;

	if (filp->f_flags & O_EXCL)
		return -EBUSY;	/* No exclusive opens */
	if (!drm_cpu_valid())
		return -EINVAL;

	DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor);

	priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
	if (!priv)
		return -ENOMEM;

	memset(priv, 0, sizeof(*priv));
	filp->private_data = priv;
	priv->uid = current->euid;
	priv->pid = current->pid;
	priv->minor = minor;
	priv->head = drm_heads[minor];
	priv->ioctl_count = 0;
	/* for compatibility root is always authenticated */
	priv->authenticated = capable(CAP_SYS_ADMIN);
	priv->lock_count = 0;

	if (dev->driver->open) {
		ret = dev->driver->open(dev, priv);
		if (ret < 0)
			goto out_free;
	}

	down(&dev->struct_sem);
	if (!dev->file_last) {
		priv->next = NULL;
		priv->prev = NULL;
		dev->file_first = priv;
		dev->file_last = priv;
		/* first opener automatically becomes master */
		priv->master = 1;
	} else {
		priv->next = NULL;
		priv->prev = dev->file_last;
		dev->file_last->next = priv;
		dev->file_last = priv;
	}
	up(&dev->struct_sem);

#ifdef __alpha__
	/*
	 * Default the hose
	 */
	if (!dev->hose) {
		struct pci_dev *pci_dev;
		pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
		if (pci_dev) {
			dev->hose = pci_dev->sysdata;
			pci_dev_put(pci_dev);
		}
		if (!dev->hose) {
			struct pci_bus *b = pci_bus_b(pci_root_buses.next);
			if (b)
				dev->hose = b->sysdata;
		}
	}
#endif

	return 0;
      out_free:
	drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
	filp->private_data = NULL;
	return ret;
}

/** No-op. */
int drm_fasync(int fd, struct file *filp, int on)
{
	drm_file_t *priv = filp->private_data;
	drm_device_t *dev = priv->head->dev;
	int retcode;

	DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
		  (long)old_encode_dev(priv->head->device));
	retcode = fasync_helper(fd, filp, on, &dev->buf_async);
	if (retcode < 0)
		return retcode;
	return 0;
}
EXPORT_SYMBOL(drm_fasync);

/**
/**
 * Release file.
 * Release file.
 *
 *
@@ -291,7 +456,6 @@ int drm_release(struct inode *inode, struct file *filp)


	if (dev->driver->postclose)
	if (dev->driver->postclose)
		dev->driver->postclose(dev, priv);
		dev->driver->postclose(dev, priv);

	drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
	drm_free(priv, sizeof(*priv), DRM_MEM_FILES);


	/* ========================================================
	/* ========================================================
@@ -318,132 +482,11 @@ int drm_release(struct inode *inode, struct file *filp)


	return retcode;
	return retcode;
}
}

EXPORT_SYMBOL(drm_release);
EXPORT_SYMBOL(drm_release);


/**
 * Check whether DRI will run on this CPU.
 *
 * \return non-zero if the DRI will run on this CPU, or zero otherwise.
 */
static int drm_cpu_valid(void)
{
#if defined(__i386__)
	if (boot_cpu_data.x86 == 3)
		return 0;	/* No cmpxchg on a 386 */
#endif
#if defined(__sparc__) && !defined(__sparc_v9__)
	return 0;		/* No cmpxchg before v9 sparc. */
#endif
	return 1;
}

/**
 * Called whenever a process opens /dev/drm.
 *
 * \param inode device inode.
 * \param filp file pointer.
 * \param dev device.
 * \return zero on success or a negative number on failure.
 *
 * Creates and initializes a drm_file structure for the file private data in \p
 * filp and add it into the double linked list in \p dev.
 */
static int drm_open_helper(struct inode *inode, struct file *filp,
			   drm_device_t * dev)
{
	int minor = iminor(inode);
	drm_file_t *priv;
	int ret;

	if (filp->f_flags & O_EXCL)
		return -EBUSY;	/* No exclusive opens */
	if (!drm_cpu_valid())
		return -EINVAL;

	DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor);

	priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
	if (!priv)
		return -ENOMEM;

	memset(priv, 0, sizeof(*priv));
	filp->private_data = priv;
	priv->uid = current->euid;
	priv->pid = current->pid;
	priv->minor = minor;
	priv->head = drm_heads[minor];
	priv->ioctl_count = 0;
	priv->authenticated = capable(CAP_SYS_ADMIN);
	priv->lock_count = 0;

	if (dev->driver->open) {
		ret = dev->driver->open(dev, priv);
		if (ret < 0)
			goto out_free;
	}

	down(&dev->struct_sem);
	if (!dev->file_last) {
		priv->next = NULL;
		priv->prev = NULL;
		dev->file_first = priv;
		dev->file_last = priv;
	} else {
		priv->next = NULL;
		priv->prev = dev->file_last;
		dev->file_last->next = priv;
		dev->file_last = priv;
	}
	up(&dev->struct_sem);

#ifdef __alpha__
	/*
	 * Default the hose
	 */
	if (!dev->hose) {
		struct pci_dev *pci_dev;
		pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
		if (pci_dev) {
			dev->hose = pci_dev->sysdata;
			pci_dev_put(pci_dev);
		}
		if (!dev->hose) {
			struct pci_bus *b = pci_bus_b(pci_root_buses.next);
			if (b)
				dev->hose = b->sysdata;
		}
	}
#endif

	return 0;
      out_free:
	drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
	filp->private_data = NULL;
	return ret;
}

/** No-op. */
int drm_fasync(int fd, struct file *filp, int on)
{
	drm_file_t *priv = filp->private_data;
	drm_device_t *dev = priv->head->dev;
	int retcode;

	DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
		  (long)old_encode_dev(priv->head->device));
	retcode = fasync_helper(fd, filp, on, &dev->buf_async);
	if (retcode < 0)
		return retcode;
	return 0;
}

EXPORT_SYMBOL(drm_fasync);

/** No-op. */
/** No-op. */
unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait)
unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait)
{
{
	return 0;
	return 0;
}
}

EXPORT_SYMBOL(drm_poll);
EXPORT_SYMBOL(drm_poll);
+10 −8
Original line number Original line Diff line number Diff line
@@ -104,6 +104,9 @@ int drm_lock(struct inode *inode, struct file *filp,
	__set_current_state(TASK_RUNNING);
	__set_current_state(TASK_RUNNING);
	remove_wait_queue(&dev->lock.lock_queue, &entry);
	remove_wait_queue(&dev->lock.lock_queue, &entry);


	DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
	if (ret) return ret;

	sigemptyset(&dev->sigmask);
	sigemptyset(&dev->sigmask);
	sigaddset(&dev->sigmask, SIGSTOP);
	sigaddset(&dev->sigmask, SIGSTOP);
	sigaddset(&dev->sigmask, SIGTSTP);
	sigaddset(&dev->sigmask, SIGTSTP);
@@ -116,21 +119,20 @@ int drm_lock(struct inode *inode, struct file *filp,
	if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY))
	if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY))
		dev->driver->dma_ready(dev);
		dev->driver->dma_ready(dev);


	if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT))
	if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) {
		return dev->driver->dma_quiescent(dev);
		if (dev->driver->dma_quiescent(dev)) {

			DRM_DEBUG( "%d waiting for DMA quiescent\n", lock.context);
	/* dev->driver->kernel_context_switch isn't used by any of the x86
			return DRM_ERR(EBUSY);
	 *  drivers but is used by the Sparc driver.
		}
	 */
	}


	if (dev->driver->kernel_context_switch &&
	if (dev->driver->kernel_context_switch &&
	    dev->last_context != lock.context) {
	    dev->last_context != lock.context) {
		dev->driver->kernel_context_switch(dev, dev->last_context,
		dev->driver->kernel_context_switch(dev, dev->last_context,
						   lock.context);
						   lock.context);
	}
	}
	DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");


	return ret;
	return 0;
}
}


/**
/**
Loading