Commit 66755b48 authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Javier Martinez Canillas

drm/qxl: Move ioctl array next to its only user

Move the array qxl_ioctl to qxl_drv.c and initialize the num_ioctls
field of struct drm_driver at runtime. Replaces the current fragile
ioctl setup and allows for generating the module init/exit code.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Signed-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20211217144615.32733-8-tzimmermann@suse.de
parent a7b23fd9
...@@ -269,6 +269,16 @@ static struct pci_driver qxl_pci_driver = { ...@@ -269,6 +269,16 @@ static struct pci_driver qxl_pci_driver = {
.driver.pm = &qxl_pm_ops, .driver.pm = &qxl_pm_ops,
}; };
static const struct drm_ioctl_desc qxl_ioctls[] = {
DRM_IOCTL_DEF_DRV(QXL_ALLOC, qxl_alloc_ioctl, DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_MAP, qxl_map_ioctl, DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_EXECBUFFER, qxl_execbuffer_ioctl, DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_UPDATE_AREA, qxl_update_area_ioctl, DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_GETPARAM, qxl_getparam_ioctl, DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_CLIENTCAP, qxl_clientcap_ioctl, DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_ALLOC_SURF, qxl_alloc_surf_ioctl, DRM_AUTH),
};
static struct drm_driver qxl_driver = { static struct drm_driver qxl_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
...@@ -282,6 +292,7 @@ static struct drm_driver qxl_driver = { ...@@ -282,6 +292,7 @@ static struct drm_driver qxl_driver = {
.gem_prime_import_sg_table = qxl_gem_prime_import_sg_table, .gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
.fops = &qxl_fops, .fops = &qxl_fops,
.ioctls = qxl_ioctls, .ioctls = qxl_ioctls,
.num_ioctls = ARRAY_SIZE(qxl_ioctls),
.name = DRIVER_NAME, .name = DRIVER_NAME,
.desc = DRIVER_DESC, .desc = DRIVER_DESC,
.date = DRIVER_DATE, .date = DRIVER_DATE,
...@@ -299,7 +310,6 @@ static int __init qxl_init(void) ...@@ -299,7 +310,6 @@ static int __init qxl_init(void)
if (qxl_modeset == 0) if (qxl_modeset == 0)
return -EINVAL; return -EINVAL;
qxl_driver.num_ioctls = qxl_max_ioctls;
return pci_register_driver(&qxl_pci_driver); return pci_register_driver(&qxl_pci_driver);
} }
......
...@@ -65,7 +65,6 @@ struct dma_buf_map; ...@@ -65,7 +65,6 @@ struct dma_buf_map;
#define QXL_DEBUGFS_MAX_COMPONENTS 32 #define QXL_DEBUGFS_MAX_COMPONENTS 32
extern int qxl_num_crtc; extern int qxl_num_crtc;
extern int qxl_max_ioctls;
#define QXL_INTERRUPT_MASK (\ #define QXL_INTERRUPT_MASK (\
QXL_INTERRUPT_DISPLAY |\ QXL_INTERRUPT_DISPLAY |\
...@@ -261,9 +260,6 @@ struct qxl_device { ...@@ -261,9 +260,6 @@ struct qxl_device {
int qxl_debugfs_fence_init(struct qxl_device *rdev); int qxl_debugfs_fence_init(struct qxl_device *rdev);
extern const struct drm_ioctl_desc qxl_ioctls[];
extern int qxl_max_ioctl;
int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev); int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
void qxl_device_fini(struct qxl_device *qdev); void qxl_device_fini(struct qxl_device *qdev);
...@@ -457,4 +453,13 @@ struct qxl_drv_surface * ...@@ -457,4 +453,13 @@ struct qxl_drv_surface *
qxl_surface_lookup(struct drm_device *dev, int surface_id); qxl_surface_lookup(struct drm_device *dev, int surface_id);
void qxl_surface_evict(struct qxl_device *qdev, struct qxl_bo *surf, bool freeing); void qxl_surface_evict(struct qxl_device *qdev, struct qxl_bo *surf, bool freeing);
/* qxl_ioctl.c */
int qxl_alloc_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
int qxl_map_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
int qxl_execbuffer_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
int qxl_update_area_ioctl(struct drm_device *dev, void *data, struct drm_file *file);
int qxl_getparam_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
int qxl_clientcap_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data, struct drm_file *file);
#endif #endif
...@@ -33,8 +33,7 @@ ...@@ -33,8 +33,7 @@
* TODO: allocating a new gem(in qxl_bo) for each request. * TODO: allocating a new gem(in qxl_bo) for each request.
* This is wasteful since bo's are page aligned. * This is wasteful since bo's are page aligned.
*/ */
static int qxl_alloc_ioctl(struct drm_device *dev, void *data, int qxl_alloc_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
struct drm_file *file_priv)
{ {
struct qxl_device *qdev = to_qxl(dev); struct qxl_device *qdev = to_qxl(dev);
struct drm_qxl_alloc *qxl_alloc = data; struct drm_qxl_alloc *qxl_alloc = data;
...@@ -61,8 +60,7 @@ static int qxl_alloc_ioctl(struct drm_device *dev, void *data, ...@@ -61,8 +60,7 @@ static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
return 0; return 0;
} }
static int qxl_map_ioctl(struct drm_device *dev, void *data, int qxl_map_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
struct drm_file *file_priv)
{ {
struct qxl_device *qdev = to_qxl(dev); struct qxl_device *qdev = to_qxl(dev);
struct drm_qxl_map *qxl_map = data; struct drm_qxl_map *qxl_map = data;
...@@ -272,8 +270,7 @@ static int qxl_process_single_command(struct qxl_device *qdev, ...@@ -272,8 +270,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
return ret; return ret;
} }
static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data, int qxl_execbuffer_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
struct drm_file *file_priv)
{ {
struct qxl_device *qdev = to_qxl(dev); struct qxl_device *qdev = to_qxl(dev);
struct drm_qxl_execbuffer *execbuffer = data; struct drm_qxl_execbuffer *execbuffer = data;
...@@ -297,8 +294,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data, ...@@ -297,8 +294,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
return 0; return 0;
} }
static int qxl_update_area_ioctl(struct drm_device *dev, void *data, int qxl_update_area_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
struct drm_file *file)
{ {
struct qxl_device *qdev = to_qxl(dev); struct qxl_device *qdev = to_qxl(dev);
struct drm_qxl_update_area *update_area = data; struct drm_qxl_update_area *update_area = data;
...@@ -347,8 +343,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data, ...@@ -347,8 +343,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
return ret; return ret;
} }
static int qxl_getparam_ioctl(struct drm_device *dev, void *data, int qxl_getparam_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
struct drm_file *file_priv)
{ {
struct qxl_device *qdev = to_qxl(dev); struct qxl_device *qdev = to_qxl(dev);
struct drm_qxl_getparam *param = data; struct drm_qxl_getparam *param = data;
...@@ -366,8 +361,7 @@ static int qxl_getparam_ioctl(struct drm_device *dev, void *data, ...@@ -366,8 +361,7 @@ static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
return 0; return 0;
} }
static int qxl_clientcap_ioctl(struct drm_device *dev, void *data, int qxl_clientcap_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
struct drm_file *file_priv)
{ {
struct qxl_device *qdev = to_qxl(dev); struct qxl_device *qdev = to_qxl(dev);
struct pci_dev *pdev = to_pci_dev(dev->dev); struct pci_dev *pdev = to_pci_dev(dev->dev);
...@@ -388,8 +382,7 @@ static int qxl_clientcap_ioctl(struct drm_device *dev, void *data, ...@@ -388,8 +382,7 @@ static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
return -ENOSYS; return -ENOSYS;
} }
static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data, int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
struct drm_file *file)
{ {
struct qxl_device *qdev = to_qxl(dev); struct qxl_device *qdev = to_qxl(dev);
struct drm_qxl_alloc_surf *param = data; struct drm_qxl_alloc_surf *param = data;
...@@ -422,23 +415,3 @@ static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data, ...@@ -422,23 +415,3 @@ static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data,
param->handle = handle; param->handle = handle;
return ret; return ret;
} }
const struct drm_ioctl_desc qxl_ioctls[] = {
DRM_IOCTL_DEF_DRV(QXL_ALLOC, qxl_alloc_ioctl, DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_MAP, qxl_map_ioctl, DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_EXECBUFFER, qxl_execbuffer_ioctl,
DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_UPDATE_AREA, qxl_update_area_ioctl,
DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_GETPARAM, qxl_getparam_ioctl,
DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_CLIENTCAP, qxl_clientcap_ioctl,
DRM_AUTH),
DRM_IOCTL_DEF_DRV(QXL_ALLOC_SURF, qxl_alloc_surf_ioctl,
DRM_AUTH),
};
int qxl_max_ioctls = ARRAY_SIZE(qxl_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