All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Skeggs <skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [mesa v3 6/9] nouveau: remove use of deprecated nouveau_device_wrap()
Date: Thu, 17 Dec 2015 09:21:56 +1000	[thread overview]
Message-ID: <1450308119-11757-6-git-send-email-skeggsb@gmail.com> (raw)
In-Reply-To: <1450308119-11757-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

From: Ben Skeggs <bskeggs@redhat.com>

Switching to the newer libdrm entry-points tells libdrm that it's OK to
make use of newer kernel interfaces.

We want to be able to isolate any bugs to either the interfaces changes,
or the use of NVIF itself.  As such, this commit has a slight hack which
forces libdrm to continue using the older kernel interfaces.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
 src/gallium/drivers/nouveau/nouveau_screen.c       |  4 +++
 src/gallium/drivers/nouveau/nouveau_winsys.h       |  1 +
 .../winsys/nouveau/drm/nouveau_drm_winsys.c        | 31 ++++++++++++++++------
 src/mesa/drivers/dri/nouveau/nouveau_screen.c      | 18 ++++++++++++-
 src/mesa/drivers/dri/nouveau/nouveau_screen.h      |  1 +
 5 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index 3cdcc20..4ca9e5c 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -234,6 +234,8 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
 void
 nouveau_screen_fini(struct nouveau_screen *screen)
 {
+   int fd = screen->drm->fd;
+
    nouveau_mm_destroy(screen->mm_GART);
    nouveau_mm_destroy(screen->mm_VRAM);
 
@@ -243,6 +245,8 @@ nouveau_screen_fini(struct nouveau_screen *screen)
    nouveau_object_del(&screen->channel);
 
    nouveau_device_del(&screen->device);
+   nouveau_drm_del(&screen->drm);
+   close(fd);
 }
 
 static void
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index 3a686bd..f13988e 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -6,6 +6,7 @@
 
 #include "pipe/p_defines.h"
 
+#include <drm.h>
 #include <nouveau.h>
 
 #ifndef NV04_PFIFO_MAX_PACKET_LEN
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
index 456530d..ff017e4 100644
--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
@@ -13,6 +13,9 @@
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_screen.h"
 
+#include <nvif/class.h>
+#include <nvif/cl0080.h>
+
 static struct util_hash_table *fd_tab = NULL;
 
 pipe_static_mutex(nouveau_screen_mutex);
@@ -57,16 +60,19 @@ static int compare_fd(void *key1, void *key2)
 PUBLIC struct pipe_screen *
 nouveau_drm_screen_create(int fd)
 {
+	struct nouveau_drm *drm = NULL;
 	struct nouveau_device *dev = NULL;
 	struct nouveau_screen *(*init)(struct nouveau_device *);
 	struct nouveau_screen *screen = NULL;
-	int ret, dupfd = -1;
+	int ret, dupfd;
 
 	pipe_mutex_lock(nouveau_screen_mutex);
 	if (!fd_tab) {
 		fd_tab = util_hash_table_create(hash_fd, compare_fd);
-		if (!fd_tab)
-			goto err;
+		if (!fd_tab) {
+			pipe_mutex_unlock(nouveau_screen_mutex);
+			return NULL;
+		}
 	}
 
 	screen = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
@@ -86,7 +92,17 @@ nouveau_drm_screen_create(int fd)
 	 * creation error.
 	 */
 	dupfd = dup(fd);
-	ret = nouveau_device_wrap(dupfd, 1, &dev);
+
+	ret = nouveau_drm_new(dupfd, &drm);
+	if (ret)
+		goto err;
+
+	drm->nvif = false;
+
+	ret = nouveau_device_new(&drm->client, NV_DEVICE,
+				 &(struct nv_device_v0) {
+					.device = ~0ULL,
+				 }, sizeof(struct nv_device_v0), &dev);
 	if (ret)
 		goto err;
 
@@ -133,10 +149,9 @@ err:
 	if (screen) {
 		screen->base.destroy(&screen->base);
 	} else {
-		if (dev)
-			nouveau_device_del(&dev);
-		else if (dupfd >= 0)
-			close(dupfd);
+		nouveau_device_del(&dev);
+		nouveau_drm_del(&drm);
+		close(dupfd);
 	}
 	pipe_mutex_unlock(nouveau_screen_mutex);
 	return NULL;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index 153f18e..1a74ae2 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -40,6 +40,9 @@
 #include "main/renderbuffer.h"
 #include "swrast/s_renderbuffer.h"
 
+#include <nvif/class.h>
+#include <nvif/cl0080.h>
+
 static const __DRIextension *nouveau_screen_extensions[];
 
 static void
@@ -99,12 +102,24 @@ nouveau_init_screen2(__DRIscreen *dri_screen)
 	dri_screen->driverPrivate = screen;
 
 	/* Open the DRM device. */
-	ret = nouveau_device_wrap(dri_screen->fd, 0, &screen->device);
+	ret = nouveau_drm_new(dri_screen->fd, &screen->drm);
 	if (ret) {
 		nouveau_error("Error opening the DRM device.\n");
 		goto fail;
 	}
 
+	screen->drm->nvif = false;
+
+	ret = nouveau_device_new(&screen->drm->client, NV_DEVICE,
+				 &(struct nv_device_v0) {
+					.device = ~0ULL,
+				 }, sizeof(struct nv_device_v0),
+				 &screen->device);
+	if (ret) {
+		nouveau_error("Error creating device object.\n");
+		goto fail;
+	}
+
 	/* Choose the card specific function pointers. */
 	switch (screen->device->chipset & 0xf0) {
 	case 0x00:
@@ -213,6 +228,7 @@ nouveau_destroy_screen(__DRIscreen *dri_screen)
 		return;
 
 	nouveau_device_del(&screen->device);
+	nouveau_drm_del(&screen->drm);
 
 	free(screen);
 	dri_screen->driverPrivate = NULL;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.h b/src/mesa/drivers/dri/nouveau/nouveau_screen.h
index 45b1ee9..e3c1928 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.h
@@ -33,6 +33,7 @@ struct nouveau_context;
 
 struct nouveau_screen {
 	__DRIscreen *dri_screen;
+	struct nouveau_drm *drm;
 	struct nouveau_device *device;
 	const struct nouveau_driver *driver;
 };
-- 
2.6.4

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

  parent reply	other threads:[~2015-12-16 23:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-16 23:21 [mesa v3 1/9] nouveau: bump required libdrm version to 2.4.66 Ben Skeggs
     [not found] ` <1450308119-11757-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-16 23:21   ` [mesa v3 2/9] nouveau: remove use of deprecated nouveau_device::fd Ben Skeggs
2015-12-16 23:21   ` [mesa v3 3/9] nouveau: remove use of deprecated nouveau_device::drm_version Ben Skeggs
2015-12-16 23:21   ` [mesa v3 4/9] nouveau: return nouveau_screen from hw-specific creation functions Ben Skeggs
2015-12-16 23:21   ` [mesa v3 5/9] nouveau: fix screen creation failure paths Ben Skeggs
2015-12-16 23:21   ` Ben Skeggs [this message]
2015-12-16 23:21   ` [mesa v3 7/9] nv50: fix g98+ vdec class allocation Ben Skeggs
2015-12-16 23:21   ` [mesa v3 8/9] nvc0: remove use of deprecated sw class identifier Ben Skeggs
     [not found]     ` <1450308119-11757-8-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-18 10:19       ` Emil Velikov
     [not found]         ` <CACvgo52c7WTAqF0t7wz=R0avFnwUbHoPyypYYSO61XO3JEtS8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-18 15:24           ` Samuel Pitoiset
     [not found]             ` <56742540.9090202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-18 15:28               ` Emil Velikov
2015-12-16 23:21   ` [mesa v3 9/9] nouveau: enable use of new kernel interfaces Ben Skeggs
2015-12-17 14:13   ` [mesa v3 1/9] nouveau: bump required libdrm version to 2.4.66 Samuel Pitoiset
2015-12-18 10:53   ` Emil Velikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450308119-11757-6-git-send-email-skeggsb@gmail.com \
    --to=skeggsb-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.