Skip to content

Commit f63f6a5

Browse files
thomashvmwairlied
authored andcommitted
vmwgfx: Add functionality to get 3D caps
Since we don't allow user-space to map the fifo anymore, add a parameter to get fifo hw version and an ioctl to copy the 3D capabilities. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Jakob Bornecranz <jakob@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 07999a7 commit f63f6a5

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
#define DRM_IOCTL_VMW_FENCE_WAIT \
8686
DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_FENCE_WAIT, \
8787
struct drm_vmw_fence_wait_arg)
88+
#define DRM_IOCTL_VMW_GET_3D_CAP \
89+
DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_GET_3D_CAP, \
90+
struct drm_vmw_get_3d_cap_arg)
8891

8992
/**
9093
* The core DRM version of this macro doesn't account for
@@ -130,6 +133,8 @@ static struct drm_ioctl_desc vmw_ioctls[] = {
130133
DRM_AUTH | DRM_UNLOCKED),
131134
VMW_IOCTL_DEF(VMW_FENCE_WAIT, vmw_fence_wait_ioctl,
132135
DRM_AUTH | DRM_UNLOCKED),
136+
VMW_IOCTL_DEF(VMW_GET_3D_CAP, vmw_get_cap_3d_ioctl,
137+
DRM_AUTH | DRM_UNLOCKED),
133138
};
134139

135140
static struct pci_device_id vmw_pci_id_list[] = {

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ extern int vmw_user_stream_lookup(struct vmw_private *dev_priv,
397397

398398
extern int vmw_getparam_ioctl(struct drm_device *dev, void *data,
399399
struct drm_file *file_priv);
400+
extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,
401+
struct drm_file *file_priv);
400402

401403
/**
402404
* Fifo utilities - vmwgfx_fifo.c

drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,
5454
case DRM_VMW_PARAM_MAX_FB_SIZE:
5555
param->value = dev_priv->vram_size;
5656
break;
57+
case DRM_VMW_PARAM_FIFO_HW_VERSION:
58+
{
59+
__le32 __iomem *fifo_mem = dev_priv->mmio_virt;
60+
61+
param->value = ioread32(fifo_mem + SVGA_FIFO_3D_HWVERSION);
62+
break;
63+
}
5764
default:
5865
DRM_ERROR("Illegal vmwgfx get param request: %d\n",
5966
param->param);
@@ -62,3 +69,44 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,
6269

6370
return 0;
6471
}
72+
73+
74+
int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,
75+
struct drm_file *file_priv)
76+
{
77+
struct drm_vmw_get_3d_cap_arg *arg =
78+
(struct drm_vmw_get_3d_cap_arg *) data;
79+
struct vmw_private *dev_priv = vmw_priv(dev);
80+
uint32_t size;
81+
__le32 __iomem *fifo_mem;
82+
void __user *buffer = (void __user *)((unsigned long)(arg->buffer));
83+
void *bounce;
84+
int ret;
85+
86+
if (unlikely(arg->pad64 != 0)) {
87+
DRM_ERROR("Illegal GET_3D_CAP argument.\n");
88+
return -EINVAL;
89+
}
90+
91+
size = (SVGA_FIFO_3D_CAPS_LAST - SVGA_FIFO_3D_CAPS + 1) << 2;
92+
93+
if (arg->max_size < size)
94+
size = arg->max_size;
95+
96+
bounce = vmalloc(size);
97+
if (unlikely(bounce == NULL)) {
98+
DRM_ERROR("Failed to allocate bounce buffer for 3D caps.\n");
99+
return -ENOMEM;
100+
}
101+
102+
fifo_mem = dev_priv->mmio_virt;
103+
memcpy_fromio(bounce, &fifo_mem[SVGA_FIFO_3D_CAPS], size);
104+
105+
ret = copy_to_user(buffer, bounce, size);
106+
vfree(bounce);
107+
108+
if (unlikely(ret != 0))
109+
DRM_ERROR("Failed to report 3D caps info.\n");
110+
111+
return ret;
112+
}

include/drm/vmwgfx_drm.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#define DRM_VMW_REF_SURFACE 11
5050
#define DRM_VMW_EXECBUF 12
5151
#define DRM_VMW_FENCE_WAIT 13
52+
#define DRM_VMW_GET_3D_CAP 14
5253

5354
/*************************************************************************/
5455
/**
@@ -68,6 +69,7 @@
6869
#define DRM_VMW_PARAM_HW_CAPS 3
6970
#define DRM_VMW_PARAM_FIFO_CAPS 4
7071
#define DRM_VMW_PARAM_MAX_FB_SIZE 5
72+
#define DRM_VMW_PARAM_FIFO_HW_VERSION 6
7173

7274
/**
7375
* struct drm_vmw_getparam_arg
@@ -557,6 +559,29 @@ struct drm_vmw_stream_arg {
557559
* Return a single stream that was claimed by this process. Also makes
558560
* sure that the stream has been stopped.
559561
*/
562+
/*************************************************************************/
563+
/**
564+
* DRM_VMW_GET_3D_CAP
565+
*
566+
* Read 3D capabilities from the FIFO
567+
*
568+
*/
569+
570+
/**
571+
* struct drm_vmw_get_3d_cap_arg
572+
*
573+
* @buffer: Pointer to a buffer for capability data, cast to an uint64_t
574+
* @size: Max size to copy
575+
*
576+
* Input argument to the DRM_VMW_GET_3D_CAP_IOCTL
577+
* ioctls.
578+
*/
579+
580+
struct drm_vmw_get_3d_cap_arg {
581+
uint64_t buffer;
582+
uint32_t max_size;
583+
uint32_t pad64;
584+
};
560585

561586
/*************************************************************************/
562587
/**

0 commit comments

Comments
 (0)