Skip to content

Commit

Permalink
drm/nouveau: expose the full object/event interfaces to userspace
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Ben Skeggs committed Aug 9, 2014
1 parent 771fa0e commit 27111a2
Show file tree
Hide file tree
Showing 9 changed files with 427 additions and 10 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ nouveau-y += nouveau_drm.o nouveau_chan.o nouveau_dma.o nouveau_fence.o
nouveau-y += nouveau_vga.o nouveau_agp.o
nouveau-y += nouveau_ttm.o nouveau_sgdma.o nouveau_bo.o nouveau_gem.o
nouveau-y += nouveau_prime.o nouveau_abi16.o
nouveau-y += nouveau_nvif.o
nouveau-y += nouveau_nvif.o nouveau_usif.o
nouveau-y += nv04_fence.o nv10_fence.o nv17_fence.o
nouveau-y += nv50_fence.o nv84_fence.o nvc0_fence.o

Expand Down
25 changes: 18 additions & 7 deletions drivers/gpu/drm/nouveau/nouveau_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "nouveau_fbcon.h"
#include "nouveau_fence.h"
#include "nouveau_debugfs.h"
#include "nouveau_usif.h"

MODULE_PARM_DESC(config, "option string to pass to driver core");
static char *nouveau_config;
Expand Down Expand Up @@ -107,8 +108,10 @@ nouveau_cli_create(u64 name, const char *sname,
int ret = nvif_client_init(NULL, NULL, sname, name,
nouveau_config, nouveau_debug,
&cli->base);
if (ret == 0)
if (ret == 0) {
mutex_init(&cli->mutex);
usif_client_init(cli);
}
return ret;
}
return -ENOMEM;
Expand All @@ -119,6 +122,7 @@ nouveau_cli_destroy(struct nouveau_cli *cli)
{
nouveau_vm_ref(NULL, &nvkm_client(&cli->base)->vm, NULL);
nvif_client_fini(&cli->base);
usif_client_fini(cli);
}

static void
Expand Down Expand Up @@ -810,24 +814,31 @@ nouveau_ioctls[] = {
DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_UNLOCKED|DRM_AUTH|DRM_RENDER_ALLOW),
};

long nouveau_drm_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
long
nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct drm_file *file_priv = filp->private_data;
struct drm_device *dev;
struct drm_file *filp = file->private_data;
struct drm_device *dev = filp->minor->dev;
long ret;
dev = file_priv->minor->dev;

ret = pm_runtime_get_sync(dev->dev);
if (ret < 0 && ret != -EACCES)
return ret;

ret = drm_ioctl(filp, cmd, arg);
switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
case DRM_NOUVEAU_NVIF:
ret = usif_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
break;
default:
ret = drm_ioctl(file, cmd, arg);
break;
}

pm_runtime_mark_last_busy(dev->dev);
pm_runtime_put_autosuspend(dev->dev);
return ret;
}

static const struct file_operations
nouveau_driver_fops = {
.owner = THIS_MODULE,
Expand Down
9 changes: 7 additions & 2 deletions drivers/gpu/drm/nouveau/nouveau_drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#define DRIVER_DATE "20120801"

#define DRIVER_MAJOR 1
#define DRIVER_MINOR 1
#define DRIVER_PATCHLEVEL 2
#define DRIVER_MINOR 2
#define DRIVER_PATCHLEVEL 0

/*
* 1.1.1:
Expand All @@ -23,6 +23,9 @@
* bounds access to local memory to be silently ignored / return 0).
* 1.1.2:
* - fixes multiple bugs in flip completion events and timestamping
* 1.2.0:
* - object api exposed to userspace
* - fermi,kepler,maxwell zbc
*/

#include <nvif/client.h>
Expand Down Expand Up @@ -79,6 +82,8 @@ struct nouveau_cli {
struct list_head head;
struct mutex mutex;
void *abi16;
struct list_head objects;
struct list_head notifys;
};

static inline struct nouveau_cli *
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/nouveau/nouveau_nvif.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <nvif/ioctl.h>

#include "nouveau_drm.h"
#include "nouveau_usif.h"

static void
nvkm_client_unmap(void *priv, void *ptr, u32 size)
Expand Down Expand Up @@ -95,6 +96,8 @@ nvkm_client_ntfy(const void *header, u32 length, const void *data, u32 size)
switch (route) {
case NVDRM_NOTIFY_NVIF:
return nvif_notify(header, length, data, size);
case NVDRM_NOTIFY_USIF:
return usif_notify(header, length, data, size);
default:
WARN_ON(1);
break;
Expand Down
Loading

0 comments on commit 27111a2

Please sign in to comment.