summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/nouveau_nvif.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-09 17:46:39 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-09 17:46:39 -0700
commit913847586290d5de22659e2a6195d91ff24d5aa6 (patch)
tree98bd9bd7074dd2002fa13c680fb61efadeeabf6e /drivers/gpu/drm/nouveau/nouveau_nvif.c
parentc23190c0bf1236e1eb5521a8b10d0102fbc1338c (diff)
parent27111a23d01c1dba3180c998629004ab4c9ac985 (diff)
Merge branch 'linux-3.17' of git://anongit.freedesktop.org/git/nouveau/linux-2.6
Pull nouveau drm updates from Ben Skeggs: "Apologies for not getting this done in time for Dave's drm-next merge window. As he mentioned, a pre-existing bug reared its head a lot more obviously after this lot of changes. It took quite a bit of time to track it down. In any case, Dave suggested I try my luck by sending directly to you this time. Overview: - more code for Tegra GK20A from NVIDIA - probing, reclockig - better fix for Kepler GPUs that have the graphics engine powered off on startup, method courtesy of info provided by NVIDIA - unhardcoding of a bunch of graphics engine setup on Fermi/Kepler/Maxwell, will hopefully solve some issues people have noticed on higher-end models - support for "Zero Bandwidth Clear" on Fermi/Kepler/Maxwell, needs userspace support in general, but some lucky apps will benefit automagically - reviewed/exposed the full object APIs to userspace (finally), gives it access to perfctrs, ZBC controls, various events. More to come in the future. - various other fixes" Acked-by: Dave Airlie <airlied@redhat.com> * 'linux-3.17' of git://anongit.freedesktop.org/git/nouveau/linux-2.6: (87 commits) drm/nouveau: expose the full object/event interfaces to userspace drm/nouveau: fix headless mode drm/nouveau: hide sysfs pstate file behind an option again drm/nv50/disp: shhh compiler drm/gf100-/gr: implement the proper SetShaderExceptions method drm/gf100-/gr: remove some broken ltc bashing, for now drm/gf100-/gr: unhardcode attribute cb config drm/gf100-/gr: fetch tpcs-per-ppc info on startup drm/gf100-/gr: unhardcode pagepool config drm/gf100-/gr: unhardcode bundle cb config drm/gf100-/gr: improve initial context patch list helpers drm/gf100-/gr: add support for zero bandwidth clear drm/nouveau/ltc: add zbc drivers drm/nouveau/ltc: s/ltcg/ltc/ + cleanup drm/nouveau: use ram info from nvif_device drm/nouveau/disp: implement nvif event sources for vblank/connector notifiers drm/nouveau/disp: allow user direct access to channel control registers drm/nouveau/disp: audit and version display classes drm/nouveau/disp: audit and version SCANOUTPOS method drm/nv50-/disp: audit and version PIOR_PWR method ...
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_nvif.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_nvif.c136
1 files changed, 136 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_nvif.c b/drivers/gpu/drm/nouveau/nouveau_nvif.c
new file mode 100644
index 000000000000..47ca88623753
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nouveau_nvif.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2014 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Ben Skeggs <bskeggs@redhat.com>
+ */
+
+/*******************************************************************************
+ * NVIF client driver - NVKM directly linked
+ ******************************************************************************/
+
+#include <core/client.h>
+#include <core/notify.h>
+#include <core/ioctl.h>
+
+#include <nvif/client.h>
+#include <nvif/driver.h>
+#include <nvif/notify.h>
+#include <nvif/event.h>
+#include <nvif/ioctl.h>
+
+#include "nouveau_drm.h"
+#include "nouveau_usif.h"
+
+static void
+nvkm_client_unmap(void *priv, void *ptr, u32 size)
+{
+ iounmap(ptr);
+}
+
+static void *
+nvkm_client_map(void *priv, u64 handle, u32 size)
+{
+ return ioremap(handle, size);
+}
+
+static int
+nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack)
+{
+ return nvkm_ioctl(priv, super, data, size, hack);
+}
+
+static int
+nvkm_client_resume(void *priv)
+{
+ return nouveau_client_init(priv);
+}
+
+static int
+nvkm_client_suspend(void *priv)
+{
+ return nouveau_client_fini(priv, true);
+}
+
+static void
+nvkm_client_fini(void *priv)
+{
+ struct nouveau_object *client = priv;
+ nouveau_client_fini(nv_client(client), false);
+ atomic_set(&client->refcount, 1);
+ nouveau_object_ref(NULL, &client);
+}
+
+static int
+nvkm_client_ntfy(const void *header, u32 length, const void *data, u32 size)
+{
+ const union {
+ struct nvif_notify_req_v0 v0;
+ } *args = header;
+ u8 route;
+
+ if (length == sizeof(args->v0) && args->v0.version == 0) {
+ route = args->v0.route;
+ } else {
+ WARN_ON(1);
+ return NVKM_NOTIFY_DROP;
+ }
+
+ 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;
+ }
+
+ return NVKM_NOTIFY_DROP;
+}
+
+static int
+nvkm_client_init(const char *name, u64 device, const char *cfg,
+ const char *dbg, void **ppriv)
+{
+ struct nouveau_client *client;
+ int ret;
+
+ ret = nouveau_client_create(name, device, cfg, dbg, &client);
+ *ppriv = client;
+ if (ret)
+ return ret;
+
+ client->ntfy = nvkm_client_ntfy;
+ return 0;
+}
+
+const struct nvif_driver
+nvif_driver_nvkm = {
+ .name = "nvkm",
+ .init = nvkm_client_init,
+ .fini = nvkm_client_fini,
+ .suspend = nvkm_client_suspend,
+ .resume = nvkm_client_resume,
+ .ioctl = nvkm_client_ioctl,
+ .map = nvkm_client_map,
+ .unmap = nvkm_client_unmap,
+ .keep = false,
+};