Skip to contentSkip to conversation

nouveau: bump required libdrm version to 2.4.66

PATCH In review Ben Skeggs 3 participants 14 messages Dec 16, 2015 – Dec 18, 2015 4 messages not in the archive

lore
Share & tools
lore

Ben Skeggs

author
#0 lore raw

PATCH v3 1/9 nouveau: bump required libdrm version to 2.4.66

From: Ben Skeggs <[email protected]>

v2. forgot bump for non-gallium driver

---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +2 -2
index b6680d0..965c6f7 100644
@@ -72,8 +72,8 @@ LIBDRM_REQUIRED=2.4.60
 LIBDRM_RADEON_REQUIRED=2.4.56
 LIBDRM_AMDGPU_REQUIRED=2.4.63
 LIBDRM_INTEL_REQUIRED=2.4.61
-LIBDRM_NVVIEUX_REQUIRED=2.4.33
-LIBDRM_NOUVEAU_REQUIRED=2.4.62
+LIBDRM_NVVIEUX_REQUIRED=2.4.66
+LIBDRM_NOUVEAU_REQUIRED=2.4.66
 LIBDRM_FREEDRENO_REQUIRED=2.4.65
 DRI2PROTO_REQUIRED=2.6
 DRI3PROTO_REQUIRED=1.0
Signature · 6 lines
2.6.4

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1450308119-11757-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#2 lore raw

PATCH v3 2/9 nouveau: remove use of deprecated nouveau_device::fd

From: Ben Skeggs <[email protected]>

---
 src/gallium/drivers/nouveau/nouveau_screen.c        | 1 +
 src/gallium/drivers/nouveau/nouveau_screen.h        | 1 +
 src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)
src/gallium/drivers/nouveau/nouveau_screen.c +1 -0
index a6065e4..a012579 100644
@@ -175,6 +175,7 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
                             data, size, &screen->channel);
    if (ret)
       return ret;
+   screen->drm = nouveau_drm(&dev->object);
    screen->device = dev;
 
    ret = nouveau_client_new(screen->device, &screen->client);
src/gallium/drivers/nouveau/nouveau_screen.h +1 -0
index 328646f..28c4760 100644
@@ -17,6 +17,7 @@ struct nouveau_bo;
 
 struct nouveau_screen {
    struct pipe_screen base;
+   struct nouveau_drm *drm;
    struct nouveau_device *device;
    struct nouveau_object *channel;
    struct nouveau_client *client;
src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +1 -1
index c6603e3..3ed644e 100644
@@ -27,7 +27,7 @@ bool nouveau_drm_screen_unref(struct nouveau_screen *screen)
 	ret = --screen->refcount;
 	assert(ret >= 0);
 	if (ret == 0)
-		util_hash_table_remove(fd_tab, intptr_to_pointer(screen->device->fd));
+		util_hash_table_remove(fd_tab, intptr_to_pointer(screen->drm->fd));
 	pipe_mutex_unlock(nouveau_screen_mutex);
 	return ret == 0;
 }
Signature · 6 lines
2.6.4

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
author
#3 lore raw

PATCH v3 3/9 nouveau: remove use of deprecated nouveau_device::drm_version

In reply to a message not in the archive

From: Ben Skeggs <[email protected]>

v2. update for libdrm nouveau_drm::lib_version removal

---
 src/gallium/drivers/nouveau/nv50/nv50_miptree.c         | 3 ++-
 src/gallium/drivers/nouveau/nv50/nv50_screen.c          | 4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c         | 3 ++-
 src/gallium/drivers/nouveau/nvc0/nvc0_query.c           | 2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c | 2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c     | 4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c          | 9 +++++----
 7 files changed, 15 insertions(+), 12 deletions(-)
src/gallium/drivers/nouveau/nv50/nv50_miptree.c +2 -1
index 812d10c..7450119 100644
@@ -336,9 +336,10 @@ nv50_miptree_create(struct pipe_screen *pscreen,
                     const struct pipe_resource *templ)
 {
    struct nouveau_device *dev = nouveau_screen(pscreen)->device;
+   struct nouveau_drm *drm = nouveau_screen(pscreen)->drm;
    struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
    struct pipe_resource *pt = &mt->base.base;
-   bool compressed = dev->drm_version >= 0x01000101;
+   bool compressed = drm->version >= 0x01000101;
    int ret;
    union nouveau_bo_config bo_config;
    uint32_t bo_flags;
src/gallium/drivers/nouveau/nv50/nv50_screen.c +2 -2
index 1e4b75f..87a3576 100644
@@ -518,11 +518,11 @@ nv50_screen_init_hwctx(struct nv50_screen *screen)
    }
 
    BEGIN_NV04(push, NV50_3D(ZETA_COMP_ENABLE), 1);
-   PUSH_DATA(push, screen->base.device->drm_version >= 0x01000101);
+   PUSH_DATA(push, screen->base.drm->version >= 0x01000101);
 
    BEGIN_NV04(push, NV50_3D(RT_COMP_ENABLE(0)), 8);
    for (i = 0; i < 8; ++i)
-      PUSH_DATA(push, screen->base.device->drm_version >= 0x01000101);
+      PUSH_DATA(push, screen->base.drm->version >= 0x01000101);
 
    BEGIN_NV04(push, NV50_3D(RT_CONTROL), 1);
    PUSH_DATA (push, 1);
src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c +2 -1
index 15991c3..ed1ac48 100644
@@ -248,9 +248,10 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
                     const struct pipe_resource *templ)
 {
    struct nouveau_device *dev = nouveau_screen(pscreen)->device;
+   struct nouveau_drm *drm = nouveau_screen(pscreen)->drm;
    struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
    struct pipe_resource *pt = &mt->base.base;
-   bool compressed = dev->drm_version >= 0x01000101;
+   bool compressed = drm->version >= 0x01000101;
    int ret;
    union nouveau_bo_config bo_config;
    uint32_t bo_flags;
src/gallium/drivers/nouveau/nvc0/nvc0_query.c +1 -1
index 3845d61..7497317 100644
@@ -184,7 +184,7 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen *pscreen,
    count++;
 #endif
 
-   if (screen->base.device->drm_version >= 0x01000101) {
+   if (screen->base.drm->version >= 0x01000101) {
       if (screen->compute) {
          if (screen->base.class_3d == NVE4_3D_CLASS) {
             count += 2;
src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c +1 -1
index f020d0d..7a64b69 100644
@@ -565,7 +565,7 @@ nvc0_hw_metric_get_driver_query_info(struct nvc0_screen *screen, unsigned id,
    uint16_t class_3d = screen->base.class_3d;
    int count = 0;
 
-   if (screen->base.device->drm_version >= 0x01000101) {
+   if (screen->base.drm->version >= 0x01000101) {
       if (screen->compute) {
          if (screen->base.class_3d == NVE4_3D_CLASS) {
             count += NVE4_HW_METRIC_QUERY_COUNT;
src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c +2 -2
index 3f5a876..721857e 100644
@@ -1121,7 +1121,7 @@ nvc0_hw_sm_create_query(struct nvc0_context *nvc0, unsigned type)
    struct nvc0_hw_query *hq;
    unsigned space;
 
-   if (nvc0->screen->base.device->drm_version < 0x01000101)
+   if (nvc0->screen->base.drm->version < 0x01000101)
       return NULL;
 
    if ((type < NVE4_HW_SM_QUERY(0) || type > NVE4_HW_SM_QUERY_LAST) &&
@@ -1216,7 +1216,7 @@ nvc0_hw_sm_get_driver_query_info(struct nvc0_screen *screen, unsigned id,
 {
    int count = 0;
 
-   if (screen->base.device->drm_version >= 0x01000101) {
+   if (screen->base.drm->version >= 0x01000101) {
       if (screen->compute) {
          if (screen->base.class_3d == NVE4_3D_CLASS) {
             count += NVE4_HW_SM_QUERY_COUNT;
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +5 -4
index 4757fe2..c3bf399 100644
@@ -688,7 +688,7 @@ nvc0_screen_create(struct nouveau_device *dev)
    screen->base.base.is_video_format_supported = nouveau_vp3_screen_video_supported;
 
    flags = NOUVEAU_BO_GART | NOUVEAU_BO_MAP;
-   if (dev->drm_version >= 0x01000202)
+   if (screen->base.drm->version >= 0x01000202)
       flags |= NOUVEAU_BO_COHERENT;
 
    ret = nouveau_bo_new(dev, flags, 0, 4096, NULL, &screen->fence.bo);
@@ -812,10 +812,11 @@ nvc0_screen_create(struct nouveau_device *dev)
       PUSH_DATA (push, 0x17);
    }
 
-   IMMED_NVC0(push, NVC0_3D(ZETA_COMP_ENABLE), dev->drm_version >= 0x01000101);
+   IMMED_NVC0(push, NVC0_3D(ZETA_COMP_ENABLE),
+                    screen->base.drm->version >= 0x01000101);
    BEGIN_NVC0(push, NVC0_3D(RT_COMP_ENABLE(0)), 8);
    for (i = 0; i < 8; ++i)
-           PUSH_DATA(push, dev->drm_version >= 0x01000101);
+           PUSH_DATA(push, screen->base.drm->version >= 0x01000101);
 
    BEGIN_NVC0(push, NVC0_3D(RT_CONTROL), 1);
    PUSH_DATA (push, 1);
@@ -911,7 +912,7 @@ nvc0_screen_create(struct nouveau_device *dev)
    PUSH_DATAh(push, screen->uniform_bo->offset + (5 << 16) + (6 << 9));
    PUSH_DATA (push, screen->uniform_bo->offset + (5 << 16) + (6 << 9));
 
-   if (dev->drm_version >= 0x01000101) {
+   if (screen->base.drm->version >= 0x01000101) {
       ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_GRAPH_UNITS, &value);
       if (ret) {
          NOUVEAU_ERR("NOUVEAU_GETPARAM_GRAPH_UNITS failed.\n");
Signature · 6 lines
2.6.4

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
author
#4 lore raw

PATCH v3 4/9 nouveau: return nouveau_screen from hw-specific creation functions

In reply to a message not in the archive

From: Ben Skeggs <[email protected]>

Kills off a void cast.

---
 src/gallium/drivers/nouveau/nouveau_winsys.h        | 6 +++---
 src/gallium/drivers/nouveau/nv30/nv30_screen.c      | 4 ++--
 src/gallium/drivers/nouveau/nv50/nv50_screen.c      | 4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c      | 4 ++--
 src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c | 4 ++--
 5 files changed, 11 insertions(+), 11 deletions(-)
src/gallium/drivers/nouveau/nouveau_winsys.h +3 -3
index 1319c32..3a686bd 100644
@@ -79,13 +79,13 @@ nouveau_screen_transfer_flags(unsigned pipe)
    return flags;
 }
 
-extern struct pipe_screen *
+extern struct nouveau_screen *
 nv30_screen_create(struct nouveau_device *);
 
-extern struct pipe_screen *
+extern struct nouveau_screen *
 nv50_screen_create(struct nouveau_device *);
 
-extern struct pipe_screen *
+extern struct nouveau_screen *
 nvc0_screen_create(struct nouveau_device *);
 
 #endif
src/gallium/drivers/nouveau/nv30/nv30_screen.c +2 -2
index 154c3d3..ea29811 100644
@@ -417,7 +417,7 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
       return NULL;                                    \
    } while(0)
 
-struct pipe_screen *
+struct nouveau_screen *
 nv30_screen_create(struct nouveau_device *dev)
 {
    struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen);
@@ -693,5 +693,5 @@ nv30_screen_create(struct nouveau_device *dev)
    nouveau_pushbuf_kick(push, push->channel);
 
    nouveau_fence_new(&screen->base, &screen->base.fence.current, false);
-   return pscreen;
+   return &screen->base;
 }
src/gallium/drivers/nouveau/nv50/nv50_screen.c +2 -2
index 87a3576..82b9e93 100644
@@ -747,7 +747,7 @@ int nv50_tls_realloc(struct nv50_screen *screen, unsigned tls_space)
    return 1;
 }
 
-struct pipe_screen *
+struct nouveau_screen *
 nv50_screen_create(struct nouveau_device *dev)
 {
    struct nv50_screen *screen;
@@ -961,7 +961,7 @@ nv50_screen_create(struct nouveau_device *dev)
 
    nouveau_fence_new(&screen->base, &screen->base.fence.current, false);
 
-   return pscreen;
+   return &screen->base;
 
 fail:
    nv50_screen_destroy(pscreen);
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +2 -2
index c3bf399..b573ada 100644
@@ -622,7 +622,7 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
       return NULL;                                    \
    } while(0)
 
-struct pipe_screen *
+struct nouveau_screen *
 nvc0_screen_create(struct nouveau_device *dev)
 {
    struct nvc0_screen *screen;
@@ -1063,7 +1063,7 @@ nvc0_screen_create(struct nouveau_device *dev)
 
    nouveau_fence_new(&screen->base, &screen->base.fence.current, false);
 
-   return pscreen;
+   return &screen->base;
 
 fail:
    nvc0_screen_destroy(pscreen);
src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +2 -2
index 3ed644e..e117dfc 100644
@@ -58,7 +58,7 @@ PUBLIC struct pipe_screen *
 nouveau_drm_screen_create(int fd)
 {
 	struct nouveau_device *dev = NULL;
-	struct pipe_screen *(*init)(struct nouveau_device *);
+	struct nouveau_screen *(*init)(struct nouveau_device *);
 	struct nouveau_screen *screen;
 	int ret, dupfd = -1;
 
@@ -116,7 +116,7 @@ nouveau_drm_screen_create(int fd)
 		goto err;
 	}
 
-	screen = (struct nouveau_screen*)init(dev);
+	screen = init(dev);
 	if (!screen)
 		goto err;
 
Signature · 6 lines
2.6.4

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
author
#5 lore raw

PATCH v3 5/9 nouveau: fix screen creation failure paths

In reply to a message not in the archive

From: Ben Skeggs <[email protected]>

The winsys layer would attempt to cleanup the nouveau_device if screen init failed, however, in most paths the pipe driver would have already destroyed it, resulting in accesses to freed memory etc.

This commit fixes the problem by allowing the winsys to detect whether the pipe driver's destroy function needs to be called or not.

---
 src/gallium/drivers/nouveau/nouveau_screen.c        |  8 ++++++--
 src/gallium/drivers/nouveau/nv30/nv30_screen.c      | 19 ++++++++++---------
 src/gallium/drivers/nouveau/nv50/nv50_screen.c      |  6 +++---
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c      |  9 ++++-----
 src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c | 16 ++++++++++------
 5 files changed, 33 insertions(+), 25 deletions(-)
src/gallium/drivers/nouveau/nouveau_screen.c +6 -2
index a012579..3cdcc20 100644
@@ -147,6 +147,12 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
    if (nv_dbg)
       nouveau_mesa_debug = atoi(nv_dbg);
 
+   /* These must be set before any failure is possible, as the cleanup
+    * paths assume they're responsible for deleting them.
+    */
+   screen->drm = nouveau_drm(&dev->object);
+   screen->device = dev;
+
    /*
     * this is initialized to 1 in nouveau_drm_screen_create after screen
     * is fully constructed and added to the global screen list.
@@ -175,8 +181,6 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
                             data, size, &screen->channel);
    if (ret)
       return ret;
-   screen->drm = nouveau_drm(&dev->object);
-   screen->device = dev;
 
    ret = nouveau_client_new(screen->device, &screen->client);
    if (ret)
src/gallium/drivers/nouveau/nv30/nv30_screen.c +10 -9
index ea29811..854f70c 100644
@@ -413,23 +413,20 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
 #define FAIL_SCREEN_INIT(str, err)                    \
    do {                                               \
       NOUVEAU_ERR(str, err);                          \
-      nv30_screen_destroy(pscreen);                   \
-      return NULL;                                    \
+      screen->base.base.context_create = NULL;        \
+      return &screen->base;                           \
    } while(0)
 
 struct nouveau_screen *
 nv30_screen_create(struct nouveau_device *dev)
 {
-   struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen);
+   struct nv30_screen *screen;
    struct pipe_screen *pscreen;
    struct nouveau_pushbuf *push;
    struct nv04_fifo *fifo;
    unsigned oclass = 0;
    int ret, i;
 
-   if (!screen)
-      return NULL;
-
    switch (dev->chipset & 0xf0) {
    case 0x30:
       if (RANKINE_0397_CHIPSET & (1 << (dev->chipset & 0x0f)))
@@ -458,10 +455,16 @@ nv30_screen_create(struct nouveau_device *dev)
 
    if (!oclass) {
       NOUVEAU_ERR("unknown 3d class for 0x%02x\n", dev->chipset);
-      FREE(screen);
       return NULL;
    }
 
+   screen = CALLOC_STRUCT(nv30_screen);
+   if (!screen)
+      return NULL;
+
+   pscreen = &screen->base.base;
+   pscreen->destroy = nv30_screen_destroy;
+
    /*
     * Some modern apps try to use msaa without keeping in mind the
     * restrictions on videomem of older cards. Resulting in dmesg saying:
@@ -479,8 +482,6 @@ nv30_screen_create(struct nouveau_device *dev)
    if (screen->max_sample_count > 4)
       screen->max_sample_count = 4;
 
-   pscreen = &screen->base.base;
-   pscreen->destroy = nv30_screen_destroy;
    pscreen->get_param = nv30_screen_get_param;
    pscreen->get_paramf = nv30_screen_get_paramf;
    pscreen->get_shader_param = nv30_screen_get_shader_param;
src/gallium/drivers/nouveau/nv50/nv50_screen.c +3 -3
index 82b9e93..46c812b 100644
@@ -762,6 +762,7 @@ nv50_screen_create(struct nouveau_device *dev)
    if (!screen)
       return NULL;
    pscreen = &screen->base.base;
+   pscreen->destroy = nv50_screen_destroy;
 
    ret = nouveau_screen_init(&screen->base, dev);
    if (ret) {
@@ -782,7 +783,6 @@ nv50_screen_create(struct nouveau_device *dev)
 
    chan = screen->base.channel;
 
-   pscreen->destroy = nv50_screen_destroy;
    pscreen->context_create = nv50_create;
    pscreen->is_format_supported = nv50_screen_is_format_supported;
    pscreen->get_param = nv50_screen_get_param;
@@ -964,8 +964,8 @@ nv50_screen_create(struct nouveau_device *dev)
    return &screen->base;
 
 fail:
-   nv50_screen_destroy(pscreen);
-   return NULL;
+   screen->base.base.context_create = NULL;
+   return &screen->base;
 }
 
 int
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +4 -5
index b573ada..b5d0830 100644
@@ -618,8 +618,7 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
 #define FAIL_SCREEN_INIT(str, err)                    \
    do {                                               \
       NOUVEAU_ERR(str, err);                          \
-      nvc0_screen_destroy(pscreen);                   \
-      return NULL;                                    \
+      goto fail;                                      \
    } while(0)
 
 struct nouveau_screen *
@@ -651,6 +650,7 @@ nvc0_screen_create(struct nouveau_device *dev)
    if (!screen)
       return NULL;
    pscreen = &screen->base.base;
+   pscreen->destroy = nvc0_screen_destroy;
 
    ret = nouveau_screen_init(&screen->base, dev);
    if (ret) {
@@ -673,7 +673,6 @@ nvc0_screen_create(struct nouveau_device *dev)
       screen->base.vidmem_bindings = 0;
    }
 
-   pscreen->destroy = nvc0_screen_destroy;
    pscreen->context_create = nvc0_create;
    pscreen->is_format_supported = nvc0_screen_is_format_supported;
    pscreen->get_param = nvc0_screen_get_param;
@@ -1066,8 +1065,8 @@ nvc0_screen_create(struct nouveau_device *dev)
    return &screen->base;
 
 fail:
-   nvc0_screen_destroy(pscreen);
-   return NULL;
+   screen->base.base.context_create = NULL;
+   return &screen->base;
 }
 
 int
src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +10 -6
index e117dfc..456530d 100644
@@ -59,7 +59,7 @@ nouveau_drm_screen_create(int fd)
 {
 	struct nouveau_device *dev = NULL;
 	struct nouveau_screen *(*init)(struct nouveau_device *);
-	struct nouveau_screen *screen;
+	struct nouveau_screen *screen = NULL;
 	int ret, dupfd = -1;
 
 	pipe_mutex_lock(nouveau_screen_mutex);
@@ -117,7 +117,7 @@ nouveau_drm_screen_create(int fd)
 	}
 
 	screen = init(dev);
-	if (!screen)
+	if (!screen || !screen->base.context_create)
 		goto err;
 
 	/* Use dupfd in hash table, to avoid errors if the original fd gets
@@ -130,10 +130,14 @@ nouveau_drm_screen_create(int fd)
 	return &screen->base;
 
 err:
-	if (dev)
-		nouveau_device_del(&dev);
-	else if (dupfd >= 0)
-		close(dupfd);
+	if (screen) {
+		screen->base.destroy(&screen->base);
+	} else {
+		if (dev)
+			nouveau_device_del(&dev);
+		else if (dupfd >= 0)
+			close(dupfd);
+	}
 	pipe_mutex_unlock(nouveau_screen_mutex);
 	return NULL;
 }
Signature · 6 lines
2.6.4

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
author
#6 lore raw

PATCH v3 6/9 nouveau: remove use of deprecated nouveau_device_wrap()

In reply to a message not in the archive

From: Ben Skeggs <[email protected]>

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.

---
 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(-)
src/gallium/drivers/nouveau/nouveau_screen.c +4 -0
index 3cdcc20..4ca9e5c 100644
@@ -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
src/gallium/drivers/nouveau/nouveau_winsys.h +1 -0
index 3a686bd..f13988e 100644
@@ -6,6 +6,7 @@
 
 #include "pipe/p_defines.h"
 
+#include <drm.h>
 #include <nouveau.h>
 
 #ifndef NV04_PFIFO_MAX_PACKET_LEN
src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +23 -8
index 456530d..ff017e4 100644
@@ -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;
src/mesa/drivers/dri/nouveau/nouveau_screen.c +17 -1
index 153f18e..1a74ae2 100644
@@ -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;
src/mesa/drivers/dri/nouveau/nouveau_screen.h +1 -0
index 45b1ee9..e3c1928 100644
@@ -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;
 };
Signature · 6 lines
2.6.4

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
author
#7 lore raw

PATCH v3 7/9 nv50: fix g98+ vdec class allocation

In reply to a message not in the archive

From: Ben Skeggs <[email protected]>

The kernel previously exposed incorrect classes for some of the chipsets that this code supports. It no longer does, but the older object ioctls have compatibility to avoid breaking userspace.

This needs to be fixed before switching over to the newer interfaces.

Rather than hardcoding chipset->class like the rest of the driver does, this makes use of (new) sclass queries to determine what's available.

v2.
- update to use symbolic class identifier from <nvif/class.h>

---
 src/gallium/drivers/nouveau/nv50/nv98_video.c | 57 ++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 6 deletions(-)
src/gallium/drivers/nouveau/nv50/nv98_video.c +51 -6
index 20ea547..177a7e0 100644
@@ -25,6 +25,8 @@
 #include "util/u_sampler.h"
 #include "util/u_format.h"
 
+#include <nvif/class.h>
+
 static void
 nv98_decoder_decode_bitstream(struct pipe_video_codec *decoder,
                               struct pipe_video_buffer *video_target,
@@ -56,6 +58,28 @@ nv98_decoder_decode_bitstream(struct pipe_video_codec *decoder,
    nv98_decoder_ppp(dec, desc, target, comm_seq);
 }
 
+static const struct nouveau_mclass
+nv98_decoder_msvld[] = {
+   { G98_MSVLD, -1 },
+   { IGT21A_MSVLD, -1 },
+   { GT212_MSVLD, -1 },
+   {}
+};
+
+static const struct nouveau_mclass
+nv98_decoder_mspdec[] = {
+   { G98_MSPDEC, -1 },
+   { GT212_MSPDEC, -1 },
+   {}
+};
+
+static const struct nouveau_mclass
+nv98_decoder_msppp[] = {
+   { G98_MSPPP, -1 },
+   { GT212_MSPPP, -1 },
+   {}
+};
+
 struct pipe_video_codec *
 nv98_create_decoder(struct pipe_context *context,
                     const struct pipe_video_codec *templ)
@@ -103,12 +127,33 @@ nv98_create_decoder(struct pipe_context *context,
    }
    push = dec->pushbuf;
 
-   if (!ret)
-      ret = nouveau_object_new(dec->channel[0], 0x390b1, 0x85b1, NULL, 0, &dec->bsp);
-   if (!ret)
-      ret = nouveau_object_new(dec->channel[1], 0x190b2, 0x85b2, NULL, 0, &dec->vp);
-   if (!ret)
-      ret = nouveau_object_new(dec->channel[2], 0x290b3, 0x85b3, NULL, 0, &dec->ppp);
+   if (!ret) {
+      ret = nouveau_object_mclass(dec->channel[0], nv98_decoder_msvld);
+      if (ret >= 0) {
+         ret = nouveau_object_new(dec->channel[0], 0xbeef85b1,
+                                  nv98_decoder_msvld[ret].oclass, NULL, 0,
+                                  &dec->bsp);
+      }
+   }
+
+   if (!ret) {
+      ret = nouveau_object_mclass(dec->channel[1], nv98_decoder_mspdec);
+      if (ret >= 0) {
+         ret = nouveau_object_new(dec->channel[1], 0xbeef85b2,
+                                  nv98_decoder_mspdec[ret].oclass, NULL, 0,
+                                  &dec->vp);
+      }
+   }
+
+   if (!ret) {
+      ret = nouveau_object_mclass(dec->channel[2], nv98_decoder_msppp);
+      if (ret >= 0) {
+         ret = nouveau_object_new(dec->channel[2], 0xbeef85b3,
+                                  nv98_decoder_msppp[ret].oclass, NULL, 0,
+                                  &dec->ppp);
+      }
+   }
+
    if (ret)
       goto fail;
 
Signature · 6 lines
2.6.4

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
author
#8 lore raw

PATCH v3 8/9 nvc0: remove use of deprecated sw class identifier

In reply to a message not in the archive

From: Ben Skeggs <[email protected]>

Also emits a method to properly bind the class to a subchannel, which was missing previously. The kernel currently doesn't care, but this will break if it ever decides to (ie. to support multiple sw classes).

---
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +5 -3
index b5d0830..3995446 100644
@@ -22,6 +22,7 @@
 
 #include <xf86drm.h>
 #include <nouveau_drm.h>
+#include <nvif/class.h>
 #include "util/u_format.h"
 #include "util/u_format_s3tc.h"
 #include "pipe/p_screen.h"
@@ -699,12 +700,13 @@ nvc0_screen_create(struct nouveau_device *dev)
    screen->base.fence.update = nvc0_screen_fence_update;
 
 
-   ret = nouveau_object_new(chan,
-                            (dev->chipset < 0xe0) ? 0x1f906e : 0x906e, 0x906e,
-                            NULL, 0, &screen->nvsw);
+   ret = nouveau_object_new(chan, (dev->chipset < 0xe0) ? 0x1f906e : 0x906e,
+                            NVIF_CLASS_SW_GF100, NULL, 0, &screen->nvsw);
    if (ret)
       FAIL_SCREEN_INIT("Error creating SW object: %d\n", ret);
 
+   BEGIN_NVC0(push, SUBC_SW(NV01_SUBCHAN_OBJECT), 1);
+   PUSH_DATA (push, screen->nvsw->handle);
 
    switch (dev->chipset & ~0xf) {
    case 0x110:
Signature · 6 lines
2.6.4

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1450308119-11757-8-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

A message that is not in the archive (sent off-list or not yet received): CACvgo52c7WTAqF0t7wz=R0avFnwUbHoPyypYYSO61XO3JEtS8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#12 lore raw

Re: [mesa v3 8/9] nvc0: remove use of deprecated sw class identifier

Quoted 3 lines · Emil Velikov

The commit summary "remove use of deprecated..." is no longer applicable. Feel free to tweak (use nvif provided class name/define ?) before pushing.

Well, the commit summary is fine by me because the old sw class identifier is actually deprecated with that new interface and won"t work if it's not updated accordingly.

But, feel free to change it. :-)

Quoted 7 lines

-Emil
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw

Re: [mesa v3 8/9] nvc0: remove use of deprecated sw class identifier

Quoted 7 lines · Samuel Pitoiset
Quoted 4 lines · Emil Velikov

The commit summary "remove use of deprecated..." is no longer applicable. Feel free to tweak (use nvif provided class name/define ?) before pushing.

Quoted 6 lines

Well, the commit summary is fine by me because the old sw class identifier is actually deprecated with that new interface and won"t work if it's not updated accordingly.

But, feel free to change it. :-)

Indeed you're correct. I got mesmerised with the *906e repetition. Comment/suggestion withdraw - sorry for the noise.

-Emil
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

author
#15 lore raw

PATCH v3 9/9 nouveau: enable use of new kernel interfaces

In reply to a message not in the archive

From: Ben Skeggs <[email protected]>

---
 src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c | 2 --
 src/mesa/drivers/dri/nouveau/nouveau_screen.c       | 2 --
 2 files changed, 4 deletions(-)
src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +0 -2
index ff017e4..c44424f 100644
@@ -97,8 +97,6 @@ nouveau_drm_screen_create(int fd)
 	if (ret)
 		goto err;
 
-	drm->nvif = false;
-
 	ret = nouveau_device_new(&drm->client, NV_DEVICE,
 				 &(struct nv_device_v0) {
 					.device = ~0ULL,
src/mesa/drivers/dri/nouveau/nouveau_screen.c +0 -2
index 1a74ae2..6f61f66 100644
@@ -108,8 +108,6 @@ nouveau_init_screen2(__DRIscreen *dri_screen)
 		goto fail;
 	}
 
-	screen->drm->nvif = false;
-
 	ret = nouveau_device_new(&screen->drm->client, NV_DEVICE,
 				 &(struct nv_device_v0) {
 					.device = ~0ULL,
Signature · 6 lines
2.6.4

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
Reviewed-by Tested-by
#16 lore raw
In reply to a message not in the archive

This series is:

Quoted 25 lines · Ben Skeggs

From: Ben Skeggs <[email protected]>

v2. forgot bump for non-gallium driver

---
  configure.ac | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +2 -2
index b6680d0..965c6f7 100644
@@ -72,8 +72,8 @@ LIBDRM_REQUIRED=2.4.60
  LIBDRM_RADEON_REQUIRED=2.4.56
  LIBDRM_AMDGPU_REQUIRED=2.4.63
  LIBDRM_INTEL_REQUIRED=2.4.61
-LIBDRM_NVVIEUX_REQUIRED=2.4.33
-LIBDRM_NOUVEAU_REQUIRED=2.4.62
+LIBDRM_NVVIEUX_REQUIRED=2.4.66
+LIBDRM_NOUVEAU_REQUIRED=2.4.66
  LIBDRM_FREEDRENO_REQUIRED=2.4.65
  DRI2PROTO_REQUIRED=2.6
  DRI3PROTO_REQUIRED=1.0
Signature · 5 lines
-Samuel
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau