- Add DRM_GET_PRIV_WITH_RETURN macro. This can be used in shared code to
get the drm_file_t * based on the filp passed in ioctl handlers. - Use this macro on BSD for simplification and improve its error reporting. Make failure to find the drm_file_t * print as an error, not debug. This failure may be part of the problem with KDE. - Make debug and error print macros include the pid on BSD.main
parent
4e6ddcbb69
commit
86e6325e5a
|
@ -120,13 +120,7 @@ int DRM(getmagic)(DRM_IOCTL_ARGS)
|
||||||
drm_file_t *priv;
|
drm_file_t *priv;
|
||||||
DRM_DEVICE;
|
DRM_DEVICE;
|
||||||
|
|
||||||
DRM_LOCK();
|
DRM_GET_PRIV_WITH_RETURN(priv, filp);
|
||||||
priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p);
|
|
||||||
DRM_UNLOCK();
|
|
||||||
if (priv == NULL) {
|
|
||||||
DRM_DEBUG("can't find authenticator\n");
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find unique magic */
|
/* Find unique magic */
|
||||||
if (priv->magic) {
|
if (priv->magic) {
|
||||||
|
|
|
@ -824,7 +824,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p)
|
||||||
priv = DRM(find_file_by_proc)(dev, p);
|
priv = DRM(find_file_by_proc)(dev, p);
|
||||||
if (!priv) {
|
if (!priv) {
|
||||||
DRM_UNLOCK();
|
DRM_UNLOCK();
|
||||||
DRM_DEBUG("can't find authenticator\n");
|
DRM_ERROR("can't find authenticator\n");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -938,13 +938,7 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
|
||||||
int nr = DRM_IOCTL_NR(cmd);
|
int nr = DRM_IOCTL_NR(cmd);
|
||||||
drm_file_t *priv;
|
drm_file_t *priv;
|
||||||
|
|
||||||
DRM_LOCK();
|
DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)DRM_CURRENTPID);
|
||||||
priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p);
|
|
||||||
DRM_UNLOCK();
|
|
||||||
if (priv == NULL) {
|
|
||||||
DRM_DEBUG("can't find authenticator\n");
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
|
atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
|
||||||
++priv->ioctl_count;
|
++priv->ioctl_count;
|
||||||
|
|
|
@ -173,6 +173,21 @@ typedef void irqreturn_t;
|
||||||
|
|
||||||
#define DRM_MTRR_WC MDF_WRITECOMBINE
|
#define DRM_MTRR_WC MDF_WRITECOMBINE
|
||||||
|
|
||||||
|
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \
|
||||||
|
do { \
|
||||||
|
if (_filp != (DRMFILE)DRM_CURRENTPID) { \
|
||||||
|
DRM_ERROR("filp doesn't match curproc\n"); \
|
||||||
|
return EINVAL; \
|
||||||
|
} \
|
||||||
|
DRM_LOCK(); \
|
||||||
|
_priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); \
|
||||||
|
DRM_UNLOCK(); \
|
||||||
|
if (_priv == NULL) { \
|
||||||
|
DRM_ERROR("can't find authenticator\n"); \
|
||||||
|
return EINVAL; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LOCK_TEST_WITH_RETURN(dev, filp) \
|
#define LOCK_TEST_WITH_RETURN(dev, filp) \
|
||||||
do { \
|
do { \
|
||||||
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
|
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
|
||||||
|
@ -391,17 +406,21 @@ find_first_zero_bit(volatile void *p, int max)
|
||||||
|
|
||||||
/* Macros to make printf easier */
|
/* Macros to make printf easier */
|
||||||
#define DRM_ERROR(fmt, arg...) \
|
#define DRM_ERROR(fmt, arg...) \
|
||||||
printf("error: " "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ## arg)
|
printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \
|
||||||
|
DRM_CURRENTPID, __func__ , ## arg)
|
||||||
|
|
||||||
#define DRM_MEM_ERROR(area, fmt, arg...) \
|
#define DRM_MEM_ERROR(area, fmt, arg...) \
|
||||||
printf("error: " "[" DRM_NAME ":%s:%s] *ERROR* " fmt , \
|
printf("error: [" DRM_NAME ":pid%d:%s:%s] *ERROR* " fmt, \
|
||||||
__func__, DRM(mem_stats)[area].name , ##arg)
|
DRM_CURRENTPID , __func__, DRM(mem_stats)[area].name , ##arg)
|
||||||
#define DRM_INFO(fmt, arg...) printf("info: " "[" DRM_NAME "] " fmt , ## arg)
|
|
||||||
|
#define DRM_INFO(fmt, arg...) printf("info: [" DRM_NAME "] " fmt , ## arg)
|
||||||
|
|
||||||
#if DRM_DEBUG_CODE
|
#if DRM_DEBUG_CODE
|
||||||
#define DRM_DEBUG(fmt, arg...) \
|
#define DRM_DEBUG(fmt, arg...) \
|
||||||
do { \
|
do { \
|
||||||
if (DRM(flags) & DRM_FLAG_DEBUG) \
|
if (DRM(flags) & DRM_FLAG_DEBUG) \
|
||||||
printf("[" DRM_NAME ":%s] " fmt , __func__ , ## arg); \
|
printf("[" DRM_NAME ":pid%d:%s] " fmt, \
|
||||||
|
DRM_CURRENTPID, __func__ , ## arg); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define DRM_DEBUG(fmt, arg...) do { } while (0)
|
#define DRM_DEBUG(fmt, arg...) do { } while (0)
|
||||||
|
|
|
@ -140,6 +140,19 @@ extern const int DRM(M_DRM) = M_DEVBUF;
|
||||||
|
|
||||||
#define DRM_AGP_FIND_DEVICE() agp_find_device(0)
|
#define DRM_AGP_FIND_DEVICE() agp_find_device(0)
|
||||||
|
|
||||||
|
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \
|
||||||
|
do { \
|
||||||
|
if (_filp != (DRMFILE)DRM_CURRENTPID) { \
|
||||||
|
DRM_ERROR("filp doesn't match curproc\n"); \
|
||||||
|
return EINVAL; \
|
||||||
|
} \
|
||||||
|
_priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); \
|
||||||
|
if (_priv == NULL) { \
|
||||||
|
DRM_ERROR("can't find authenticator\n"); \
|
||||||
|
return EINVAL; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LOCK_TEST_WITH_RETURN(dev, filp) \
|
#define LOCK_TEST_WITH_RETURN(dev, filp) \
|
||||||
do { \
|
do { \
|
||||||
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
|
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
|
||||||
|
|
|
@ -65,13 +65,7 @@ paddr_t DRM(mmap)(dev_t kdev, off_t offset, int prot)
|
||||||
drm_map_list_entry_t *listentry = NULL;
|
drm_map_list_entry_t *listentry = NULL;
|
||||||
drm_file_t *priv;
|
drm_file_t *priv;
|
||||||
|
|
||||||
DRM_LOCK();
|
DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)DRM_CURRENTPID);
|
||||||
priv = DRM(find_file_by_proc)(dev, DRM_CURPROC);
|
|
||||||
DRM_UNLOCK();
|
|
||||||
if (!priv) {
|
|
||||||
DRM_DEBUG("can't find authenticator\n");
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!priv->authenticated)
|
if (!priv->authenticated)
|
||||||
return DRM_ERR(EACCES);
|
return DRM_ERR(EACCES);
|
||||||
|
|
|
@ -120,13 +120,7 @@ int DRM(getmagic)(DRM_IOCTL_ARGS)
|
||||||
drm_file_t *priv;
|
drm_file_t *priv;
|
||||||
DRM_DEVICE;
|
DRM_DEVICE;
|
||||||
|
|
||||||
DRM_LOCK();
|
DRM_GET_PRIV_WITH_RETURN(priv, filp);
|
||||||
priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p);
|
|
||||||
DRM_UNLOCK();
|
|
||||||
if (priv == NULL) {
|
|
||||||
DRM_DEBUG("can't find authenticator\n");
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find unique magic */
|
/* Find unique magic */
|
||||||
if (priv->magic) {
|
if (priv->magic) {
|
||||||
|
|
|
@ -824,7 +824,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p)
|
||||||
priv = DRM(find_file_by_proc)(dev, p);
|
priv = DRM(find_file_by_proc)(dev, p);
|
||||||
if (!priv) {
|
if (!priv) {
|
||||||
DRM_UNLOCK();
|
DRM_UNLOCK();
|
||||||
DRM_DEBUG("can't find authenticator\n");
|
DRM_ERROR("can't find authenticator\n");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -938,13 +938,7 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
|
||||||
int nr = DRM_IOCTL_NR(cmd);
|
int nr = DRM_IOCTL_NR(cmd);
|
||||||
drm_file_t *priv;
|
drm_file_t *priv;
|
||||||
|
|
||||||
DRM_LOCK();
|
DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)DRM_CURRENTPID);
|
||||||
priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p);
|
|
||||||
DRM_UNLOCK();
|
|
||||||
if (priv == NULL) {
|
|
||||||
DRM_DEBUG("can't find authenticator\n");
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
|
atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
|
||||||
++priv->ioctl_count;
|
++priv->ioctl_count;
|
||||||
|
|
|
@ -173,6 +173,21 @@ typedef void irqreturn_t;
|
||||||
|
|
||||||
#define DRM_MTRR_WC MDF_WRITECOMBINE
|
#define DRM_MTRR_WC MDF_WRITECOMBINE
|
||||||
|
|
||||||
|
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \
|
||||||
|
do { \
|
||||||
|
if (_filp != (DRMFILE)DRM_CURRENTPID) { \
|
||||||
|
DRM_ERROR("filp doesn't match curproc\n"); \
|
||||||
|
return EINVAL; \
|
||||||
|
} \
|
||||||
|
DRM_LOCK(); \
|
||||||
|
_priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); \
|
||||||
|
DRM_UNLOCK(); \
|
||||||
|
if (_priv == NULL) { \
|
||||||
|
DRM_ERROR("can't find authenticator\n"); \
|
||||||
|
return EINVAL; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LOCK_TEST_WITH_RETURN(dev, filp) \
|
#define LOCK_TEST_WITH_RETURN(dev, filp) \
|
||||||
do { \
|
do { \
|
||||||
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
|
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
|
||||||
|
@ -391,17 +406,21 @@ find_first_zero_bit(volatile void *p, int max)
|
||||||
|
|
||||||
/* Macros to make printf easier */
|
/* Macros to make printf easier */
|
||||||
#define DRM_ERROR(fmt, arg...) \
|
#define DRM_ERROR(fmt, arg...) \
|
||||||
printf("error: " "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ## arg)
|
printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \
|
||||||
|
DRM_CURRENTPID, __func__ , ## arg)
|
||||||
|
|
||||||
#define DRM_MEM_ERROR(area, fmt, arg...) \
|
#define DRM_MEM_ERROR(area, fmt, arg...) \
|
||||||
printf("error: " "[" DRM_NAME ":%s:%s] *ERROR* " fmt , \
|
printf("error: [" DRM_NAME ":pid%d:%s:%s] *ERROR* " fmt, \
|
||||||
__func__, DRM(mem_stats)[area].name , ##arg)
|
DRM_CURRENTPID , __func__, DRM(mem_stats)[area].name , ##arg)
|
||||||
#define DRM_INFO(fmt, arg...) printf("info: " "[" DRM_NAME "] " fmt , ## arg)
|
|
||||||
|
#define DRM_INFO(fmt, arg...) printf("info: [" DRM_NAME "] " fmt , ## arg)
|
||||||
|
|
||||||
#if DRM_DEBUG_CODE
|
#if DRM_DEBUG_CODE
|
||||||
#define DRM_DEBUG(fmt, arg...) \
|
#define DRM_DEBUG(fmt, arg...) \
|
||||||
do { \
|
do { \
|
||||||
if (DRM(flags) & DRM_FLAG_DEBUG) \
|
if (DRM(flags) & DRM_FLAG_DEBUG) \
|
||||||
printf("[" DRM_NAME ":%s] " fmt , __func__ , ## arg); \
|
printf("[" DRM_NAME ":pid%d:%s] " fmt, \
|
||||||
|
DRM_CURRENTPID, __func__ , ## arg); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define DRM_DEBUG(fmt, arg...) do { } while (0)
|
#define DRM_DEBUG(fmt, arg...) do { } while (0)
|
||||||
|
|
|
@ -140,6 +140,19 @@ extern const int DRM(M_DRM) = M_DEVBUF;
|
||||||
|
|
||||||
#define DRM_AGP_FIND_DEVICE() agp_find_device(0)
|
#define DRM_AGP_FIND_DEVICE() agp_find_device(0)
|
||||||
|
|
||||||
|
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \
|
||||||
|
do { \
|
||||||
|
if (_filp != (DRMFILE)DRM_CURRENTPID) { \
|
||||||
|
DRM_ERROR("filp doesn't match curproc\n"); \
|
||||||
|
return EINVAL; \
|
||||||
|
} \
|
||||||
|
_priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); \
|
||||||
|
if (_priv == NULL) { \
|
||||||
|
DRM_ERROR("can't find authenticator\n"); \
|
||||||
|
return EINVAL; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LOCK_TEST_WITH_RETURN(dev, filp) \
|
#define LOCK_TEST_WITH_RETURN(dev, filp) \
|
||||||
do { \
|
do { \
|
||||||
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
|
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
|
||||||
|
|
|
@ -65,13 +65,7 @@ paddr_t DRM(mmap)(dev_t kdev, off_t offset, int prot)
|
||||||
drm_map_list_entry_t *listentry = NULL;
|
drm_map_list_entry_t *listentry = NULL;
|
||||||
drm_file_t *priv;
|
drm_file_t *priv;
|
||||||
|
|
||||||
DRM_LOCK();
|
DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)DRM_CURRENTPID);
|
||||||
priv = DRM(find_file_by_proc)(dev, DRM_CURPROC);
|
|
||||||
DRM_UNLOCK();
|
|
||||||
if (!priv) {
|
|
||||||
DRM_DEBUG("can't find authenticator\n");
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!priv->authenticated)
|
if (!priv->authenticated)
|
||||||
return DRM_ERR(EACCES);
|
return DRM_ERR(EACCES);
|
||||||
|
|
|
@ -83,6 +83,8 @@ typedef void irqreturn_t;
|
||||||
/** 'free' without the overhead of DRM(free)() */
|
/** 'free' without the overhead of DRM(free)() */
|
||||||
#define DRM_FREE(x,size) kfree(x)
|
#define DRM_FREE(x,size) kfree(x)
|
||||||
|
|
||||||
|
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the pointer to the SAREA.
|
* Get the pointer to the SAREA.
|
||||||
*
|
*
|
||||||
|
|
|
@ -83,6 +83,8 @@ typedef void irqreturn_t;
|
||||||
/** 'free' without the overhead of DRM(free)() */
|
/** 'free' without the overhead of DRM(free)() */
|
||||||
#define DRM_FREE(x,size) kfree(x)
|
#define DRM_FREE(x,size) kfree(x)
|
||||||
|
|
||||||
|
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the pointer to the SAREA.
|
* Get the pointer to the SAREA.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue