* [mesa v2 1/9] nouveau: bump required libdrm version to 2.4.66
@ 2015-11-27 1:04 Ben Skeggs
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 19+ messages in thread
From: Ben Skeggs @ 2015-11-27 1:04 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
From: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 4016871..c02ee61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,7 +73,7 @@ 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_NOUVEAU_REQUIRED=2.4.66
LIBDRM_FREEDRENO_REQUIRED=2.4.65
DRI2PROTO_REQUIRED=2.6
DRI3PROTO_REQUIRED=1.0
--
2.6.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [mesa v2 2/9] nouveau: remove use of deprecated nouveau_device::fd
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-11-27 1:04 ` Ben Skeggs
2015-11-27 1:04 ` [mesa v2 3/9] nouveau: remove use of deprecated nouveau_device::drm_version Ben Skeggs
` (7 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Ben Skeggs @ 2015-11-27 1:04 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
From: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
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(-)
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index a6065e4..a012579 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -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);
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h
index 328646f..28c4760 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.h
+++ b/src/gallium/drivers/nouveau/nouveau_screen.h
@@ -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;
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
index c6603e3..3ed644e 100644
--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
@@ -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;
}
--
2.6.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [mesa v2 3/9] nouveau: remove use of deprecated nouveau_device::drm_version
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-27 1:04 ` [mesa v2 2/9] nouveau: remove use of deprecated nouveau_device::fd Ben Skeggs
@ 2015-11-27 1:04 ` Ben Skeggs
2015-11-27 1:04 ` [mesa v2 4/9] nouveau: return nouveau_screen from hw-specific creation functions Ben Skeggs
` (6 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Ben Skeggs @ 2015-11-27 1:04 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
From: Ben Skeggs <bskeggs@redhat.com>
v2. update for libdrm nouveau_drm::lib_version removal
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
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(-)
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
index 812d10c..7450119 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
@@ -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;
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 1e4b75f..87a3576 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -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);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
index 15991c3..ed1ac48 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
@@ -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;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
index d992b10..46ccc41 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
@@ -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++;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c
index fb2806a..e3a1dbf 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c
@@ -404,7 +404,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 (class_3d < NVE4_3D_CLASS) {
const struct nvc0_hw_metric_query_cfg **queries =
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c
index 7962143..93e2a63 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c
@@ -1251,7 +1251,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) &&
@@ -1341,7 +1341,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;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index 461fcaa..45ac7f3 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -687,7 +687,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);
@@ -811,10 +811,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);
@@ -910,7 +911,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");
--
2.6.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [mesa v2 4/9] nouveau: return nouveau_screen from hw-specific creation functions
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-27 1:04 ` [mesa v2 2/9] nouveau: remove use of deprecated nouveau_device::fd Ben Skeggs
2015-11-27 1:04 ` [mesa v2 3/9] nouveau: remove use of deprecated nouveau_device::drm_version Ben Skeggs
@ 2015-11-27 1:04 ` Ben Skeggs
2015-11-27 1:04 ` [mesa v2 5/9] nouveau: fix screen creation failure paths Ben Skeggs
` (5 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Ben Skeggs @ 2015-11-27 1:04 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
From: Ben Skeggs <bskeggs@redhat.com>
Kills off a void cast.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
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(-)
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index 1319c32..3a686bd 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -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
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 154c3d3..ea29811 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -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;
}
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 87a3576..82b9e93 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -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);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index 45ac7f3..e45031a 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -621,7 +621,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;
@@ -1062,7 +1062,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);
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
index 3ed644e..e117dfc 100644
--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
@@ -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;
--
2.6.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [mesa v2 5/9] nouveau: fix screen creation failure paths
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (2 preceding siblings ...)
2015-11-27 1:04 ` [mesa v2 4/9] nouveau: return nouveau_screen from hw-specific creation functions Ben Skeggs
@ 2015-11-27 1:04 ` Ben Skeggs
[not found] ` <1448586301-8351-5-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-27 1:04 ` [mesa v2 6/9] nouveau: remove use of deprecated nouveau_device_wrap() Ben Skeggs
` (4 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Ben Skeggs @ 2015-11-27 1:04 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
From: Ben Skeggs <bskeggs@redhat.com>
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.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
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(-)
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index a012579..3cdcc20 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -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)
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index ea29811..854f70c 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -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;
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 82b9e93..46c812b 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -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
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index e45031a..4897ebe 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -617,8 +617,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 *
@@ -650,6 +649,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) {
@@ -672,7 +672,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;
@@ -1065,8 +1064,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
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
index e117dfc..456530d 100644
--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
@@ -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;
}
--
2.6.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [mesa v2 6/9] nouveau: remove use of deprecated nouveau_device_wrap()
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (3 preceding siblings ...)
2015-11-27 1:04 ` [mesa v2 5/9] nouveau: fix screen creation failure paths Ben Skeggs
@ 2015-11-27 1:04 ` Ben Skeggs
2015-11-27 1:04 ` [mesa v2 7/9] nv50: fix g98+ vdec class allocation Ben Skeggs
` (3 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Ben Skeggs @ 2015-11-27 1:04 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
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 +++
.../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 +
4 files changed, 45 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/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.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [mesa v2 7/9] nv50: fix g98+ vdec class allocation
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (4 preceding siblings ...)
2015-11-27 1:04 ` [mesa v2 6/9] nouveau: remove use of deprecated nouveau_device_wrap() Ben Skeggs
@ 2015-11-27 1:04 ` Ben Skeggs
2015-11-27 1:05 ` [mesa v2 8/9] nvc0: remove allocation of unused sw class Ben Skeggs
` (2 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Ben Skeggs @ 2015-11-27 1:04 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
From: Ben Skeggs <bskeggs@redhat.com>
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>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
src/gallium/drivers/nouveau/nv50/nv98_video.c | 57 ++++++++++++++++++++++++---
1 file changed, 51 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nv50/nv98_video.c b/src/gallium/drivers/nouveau/nv50/nv98_video.c
index 20ea547..177a7e0 100644
--- a/src/gallium/drivers/nouveau/nv50/nv98_video.c
+++ b/src/gallium/drivers/nouveau/nv50/nv98_video.c
@@ -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;
--
2.6.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [mesa v2 8/9] nvc0: remove allocation of unused sw class
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (5 preceding siblings ...)
2015-11-27 1:04 ` [mesa v2 7/9] nv50: fix g98+ vdec class allocation Ben Skeggs
@ 2015-11-27 1:05 ` Ben Skeggs
[not found] ` <1448586301-8351-8-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-27 1:05 ` [mesa v2 9/9] nouveau: enable use of new kernel interfaces Ben Skeggs
2015-12-07 3:32 ` [mesa v2 1/9] nouveau: bump required libdrm version to 2.4.66 Ilia Mirkin
8 siblings, 1 reply; 19+ messages in thread
From: Ben Skeggs @ 2015-11-27 1:05 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
From: Ben Skeggs <bskeggs@redhat.com>
This would need to be fixed before NVIF can be switched on, but since we
don't use it anyway, just remove it.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 8 --------
src/gallium/drivers/nouveau/nvc0/nvc0_screen.h | 1 -
2 files changed, 9 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index 4897ebe..11cb74a 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -447,7 +447,6 @@ nvc0_screen_destroy(struct pipe_screen *pscreen)
nouveau_object_del(&screen->eng2d);
nouveau_object_del(&screen->m2mf);
nouveau_object_del(&screen->compute);
- nouveau_object_del(&screen->nvsw);
nouveau_screen_fini(&screen->base);
@@ -698,13 +697,6 @@ 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);
- if (ret)
- FAIL_SCREEN_INIT("Error creating SW object: %d\n", ret);
-
-
switch (dev->chipset & ~0xf) {
case 0x110:
case 0x100:
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
index 8b73102..caf34aa 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
@@ -105,7 +105,6 @@ struct nvc0_screen {
struct nouveau_object *eng2d;
struct nouveau_object *m2mf;
struct nouveau_object *compute;
- struct nouveau_object *nvsw;
};
static inline struct nvc0_screen *
--
2.6.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [mesa v2 9/9] nouveau: enable use of new kernel interfaces
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (6 preceding siblings ...)
2015-11-27 1:05 ` [mesa v2 8/9] nvc0: remove allocation of unused sw class Ben Skeggs
@ 2015-11-27 1:05 ` Ben Skeggs
[not found] ` <1448586301-8351-9-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-07 3:32 ` [mesa v2 1/9] nouveau: bump required libdrm version to 2.4.66 Ilia Mirkin
8 siblings, 1 reply; 19+ messages in thread
From: Ben Skeggs @ 2015-11-27 1:05 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
From: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c | 2 --
src/mesa/drivers/dri/nouveau/nouveau_screen.c | 2 --
2 files changed, 4 deletions(-)
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
index ff017e4..c44424f 100644
--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
@@ -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,
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index 1a74ae2..6f61f66 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -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,
--
2.6.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [mesa v2 1/9] nouveau: bump required libdrm version to 2.4.66
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (7 preceding siblings ...)
2015-11-27 1:05 ` [mesa v2 9/9] nouveau: enable use of new kernel interfaces Ben Skeggs
@ 2015-12-07 3:32 ` Ilia Mirkin
2015-12-07 3:49 ` Ben Skeggs
8 siblings, 1 reply; 19+ messages in thread
From: Ilia Mirkin @ 2015-12-07 3:32 UTC (permalink / raw)
To: Ben Skeggs
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Ben Skeggs
On Thu, Nov 26, 2015 at 8:04 PM, Ben Skeggs <skeggsb@gmail.com> wrote:
> From: Ben Skeggs <bskeggs@redhat.com>
>
> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
> ---
> configure.ac | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/configure.ac b/configure.ac
> index 4016871..c02ee61 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -73,7 +73,7 @@ LIBDRM_RADEON_REQUIRED=2.4.56
> LIBDRM_AMDGPU_REQUIRED=2.4.63
> LIBDRM_INTEL_REQUIRED=2.4.61
> LIBDRM_NVVIEUX_REQUIRED=2.4.33
Do you also need to bump this one? Not sure (yet) why you're bumping
the other one, but pointing this one out
> -LIBDRM_NOUVEAU_REQUIRED=2.4.62
> +LIBDRM_NOUVEAU_REQUIRED=2.4.66
> LIBDRM_FREEDRENO_REQUIRED=2.4.65
> DRI2PROTO_REQUIRED=2.6
> DRI3PROTO_REQUIRED=1.0
> --
> 2.6.3
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [mesa v2 5/9] nouveau: fix screen creation failure paths
[not found] ` <1448586301-8351-5-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-12-07 3:40 ` Ilia Mirkin
[not found] ` <CAKb7UvjwbztKvR3-PaUA+8=A+NZqBzCeP1KT7AfrNLq4HQsReQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 19+ messages in thread
From: Ilia Mirkin @ 2015-12-07 3:40 UTC (permalink / raw)
To: Ben Skeggs
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Ben Skeggs
This all seems very roundabout... Can't we do this in a somewhat
consistent way with the device being cleaned up in one place or
another but not both?
On Thu, Nov 26, 2015 at 8:04 PM, Ben Skeggs <skeggsb@gmail.com> wrote:
> From: Ben Skeggs <bskeggs@redhat.com>
>
> 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.
>
> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
> ---
> 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(-)
>
> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
> index a012579..3cdcc20 100644
> --- a/src/gallium/drivers/nouveau/nouveau_screen.c
> +++ b/src/gallium/drivers/nouveau/nouveau_screen.c
> @@ -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)
> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> index ea29811..854f70c 100644
> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> @@ -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;
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> index 82b9e93..46c812b 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> @@ -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
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> index e45031a..4897ebe 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> @@ -617,8 +617,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 *
> @@ -650,6 +649,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) {
> @@ -672,7 +672,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;
> @@ -1065,8 +1064,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
> diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
> index e117dfc..456530d 100644
> --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
> +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
> @@ -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;
> }
> --
> 2.6.3
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [mesa v2 9/9] nouveau: enable use of new kernel interfaces
[not found] ` <1448586301-8351-9-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-12-07 3:46 ` Ilia Mirkin
0 siblings, 0 replies; 19+ messages in thread
From: Ilia Mirkin @ 2015-12-07 3:46 UTC (permalink / raw)
To: Ben Skeggs
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Ben Skeggs
Other than the 2 patches I commented on, this series is
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
On Thu, Nov 26, 2015 at 8:05 PM, Ben Skeggs <skeggsb@gmail.com> wrote:
> From: Ben Skeggs <bskeggs@redhat.com>
>
> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
> ---
> src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c | 2 --
> src/mesa/drivers/dri/nouveau/nouveau_screen.c | 2 --
> 2 files changed, 4 deletions(-)
>
> diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
> index ff017e4..c44424f 100644
> --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
> +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
> @@ -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,
> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
> index 1a74ae2..6f61f66 100644
> --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
> +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
> @@ -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,
> --
> 2.6.3
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [mesa v2 5/9] nouveau: fix screen creation failure paths
[not found] ` <CAKb7UvjwbztKvR3-PaUA+8=A+NZqBzCeP1KT7AfrNLq4HQsReQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-12-07 3:48 ` Ben Skeggs
[not found] ` <566501AA.9010600-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 19+ messages in thread
From: Ben Skeggs @ 2015-12-07 3:48 UTC (permalink / raw)
To: Ilia Mirkin
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Ben Skeggs
[-- Attachment #1.1: Type: text/plain, Size: 9633 bytes --]
On 12/07/2015 01:40 PM, Ilia Mirkin wrote:
> This all seems very roundabout... Can't we do this in a somewhat
> consistent way with the device being cleaned up in one place or
> another but not both?
That would be lovely, but not possible. It has to be cleaned up by the
pipe screen destroy() function, as that's the normal exit path. If the
pipe driver creation path fails before it's got a struct, then the
winsys will have to clean up after itself instead.
>
> On Thu, Nov 26, 2015 at 8:04 PM, Ben Skeggs <skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> From: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>>
>> 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.
>>
>> Signed-off-by: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>> 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(-)
>>
>> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
>> index a012579..3cdcc20 100644
>> --- a/src/gallium/drivers/nouveau/nouveau_screen.c
>> +++ b/src/gallium/drivers/nouveau/nouveau_screen.c
>> @@ -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)
>> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> index ea29811..854f70c 100644
>> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> @@ -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;
>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> index 82b9e93..46c812b 100644
>> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> @@ -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
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> index e45031a..4897ebe 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> @@ -617,8 +617,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 *
>> @@ -650,6 +649,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) {
>> @@ -672,7 +672,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;
>> @@ -1065,8 +1064,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
>> diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
>> index e117dfc..456530d 100644
>> --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
>> +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
>> @@ -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;
>> }
>> --
>> 2.6.3
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
>> http://lists.freedesktop.org/mailman/listinfo/nouveau
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [mesa v2 1/9] nouveau: bump required libdrm version to 2.4.66
2015-12-07 3:32 ` [mesa v2 1/9] nouveau: bump required libdrm version to 2.4.66 Ilia Mirkin
@ 2015-12-07 3:49 ` Ben Skeggs
0 siblings, 0 replies; 19+ messages in thread
From: Ben Skeggs @ 2015-12-07 3:49 UTC (permalink / raw)
To: Ilia Mirkin
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Ben Skeggs
[-- Attachment #1.1: Type: text/plain, Size: 1200 bytes --]
On 12/07/2015 01:32 PM, Ilia Mirkin wrote:
> On Thu, Nov 26, 2015 at 8:04 PM, Ben Skeggs <skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> From: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>>
>> Signed-off-by: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>> configure.ac | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 4016871..c02ee61 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -73,7 +73,7 @@ LIBDRM_RADEON_REQUIRED=2.4.56
>> LIBDRM_AMDGPU_REQUIRED=2.4.63
>> LIBDRM_INTEL_REQUIRED=2.4.61
>> LIBDRM_NVVIEUX_REQUIRED=2.4.33
>
> Do you also need to bump this one? Not sure (yet) why you're bumping
> the other one, but pointing this one out
Oops, thanks!
>
>> -LIBDRM_NOUVEAU_REQUIRED=2.4.62
>> +LIBDRM_NOUVEAU_REQUIRED=2.4.66
>> LIBDRM_FREEDRENO_REQUIRED=2.4.65
>> DRI2PROTO_REQUIRED=2.6
>> DRI3PROTO_REQUIRED=1.0
>> --
>> 2.6.3
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
>> http://lists.freedesktop.org/mailman/listinfo/nouveau
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [mesa v2 5/9] nouveau: fix screen creation failure paths
[not found] ` <566501AA.9010600-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-12-07 3:53 ` Ilia Mirkin
[not found] ` <CAKb7Uvj_3wzh19C+TPe9c_1QJuGgU=JwrZeasjswZ4uM3JcoiA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 19+ messages in thread
From: Ilia Mirkin @ 2015-12-07 3:53 UTC (permalink / raw)
To: Ben Skeggs
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Ben Skeggs
On Sun, Dec 6, 2015 at 10:48 PM, Ben Skeggs <skeggsb@gmail.com> wrote:
> On 12/07/2015 01:40 PM, Ilia Mirkin wrote:
>> This all seems very roundabout... Can't we do this in a somewhat
>> consistent way with the device being cleaned up in one place or
>> another but not both?
> That would be lovely, but not possible. It has to be cleaned up by the
> pipe screen destroy() function, as that's the normal exit path. If the
> pipe driver creation path fails before it's got a struct, then the
> winsys will have to clean up after itself instead.
Couldn't you make the pipe_screen_create() function destroy the device
in all failure paths?
>
>>
>> On Thu, Nov 26, 2015 at 8:04 PM, Ben Skeggs <skeggsb@gmail.com> wrote:
>>> From: Ben Skeggs <bskeggs@redhat.com>
>>>
>>> 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.
>>>
>>> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
>>> ---
>>> 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(-)
>>>
>>> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
>>> index a012579..3cdcc20 100644
>>> --- a/src/gallium/drivers/nouveau/nouveau_screen.c
>>> +++ b/src/gallium/drivers/nouveau/nouveau_screen.c
>>> @@ -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)
>>> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>>> index ea29811..854f70c 100644
>>> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>>> @@ -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;
>>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>>> index 82b9e93..46c812b 100644
>>> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>>> @@ -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
>>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>>> index e45031a..4897ebe 100644
>>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>>> @@ -617,8 +617,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 *
>>> @@ -650,6 +649,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) {
>>> @@ -672,7 +672,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;
>>> @@ -1065,8 +1064,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
>>> diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
>>> index e117dfc..456530d 100644
>>> --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
>>> +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
>>> @@ -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;
>>> }
>>> --
>>> 2.6.3
>>>
>>> _______________________________________________
>>> Nouveau mailing list
>>> Nouveau@lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/nouveau
>
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [mesa v2 5/9] nouveau: fix screen creation failure paths
[not found] ` <CAKb7Uvj_3wzh19C+TPe9c_1QJuGgU=JwrZeasjswZ4uM3JcoiA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-12-07 3:57 ` Ben Skeggs
0 siblings, 0 replies; 19+ messages in thread
From: Ben Skeggs @ 2015-12-07 3:57 UTC (permalink / raw)
To: Ilia Mirkin, Ben Skeggs
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
[-- Attachment #1.1: Type: text/plain, Size: 10434 bytes --]
On 12/07/2015 01:53 PM, Ilia Mirkin wrote:
> On Sun, Dec 6, 2015 at 10:48 PM, Ben Skeggs <skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> On 12/07/2015 01:40 PM, Ilia Mirkin wrote:
>>> This all seems very roundabout... Can't we do this in a somewhat
>>> consistent way with the device being cleaned up in one place or
>>> another but not both?
>> That would be lovely, but not possible. It has to be cleaned up by the
>> pipe screen destroy() function, as that's the normal exit path. If the
>> pipe driver creation path fails before it's got a struct, then the
>> winsys will have to clean up after itself instead.
>
> Couldn't you make the pipe_screen_create() function destroy the device
> in all failure paths?
Probably. I guess that's slightly nicer, I'll re-spin them shortly.
>
>>
>>>
>>> On Thu, Nov 26, 2015 at 8:04 PM, Ben Skeggs <skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>>> From: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>>>>
>>>> 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.
>>>>
>>>> Signed-off-by: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>>>> ---
>>>> 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(-)
>>>>
>>>> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
>>>> index a012579..3cdcc20 100644
>>>> --- a/src/gallium/drivers/nouveau/nouveau_screen.c
>>>> +++ b/src/gallium/drivers/nouveau/nouveau_screen.c
>>>> @@ -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)
>>>> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>>>> index ea29811..854f70c 100644
>>>> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>>>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>>>> @@ -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;
>>>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>>>> index 82b9e93..46c812b 100644
>>>> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>>>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>>>> @@ -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
>>>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>>>> index e45031a..4897ebe 100644
>>>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>>>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>>>> @@ -617,8 +617,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 *
>>>> @@ -650,6 +649,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) {
>>>> @@ -672,7 +672,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;
>>>> @@ -1065,8 +1064,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
>>>> diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
>>>> index e117dfc..456530d 100644
>>>> --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
>>>> +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
>>>> @@ -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;
>>>> }
>>>> --
>>>> 2.6.3
>>>>
>>>> _______________________________________________
>>>> Nouveau mailing list
>>>> Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
>>>> http://lists.freedesktop.org/mailman/listinfo/nouveau
>>
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [mesa v2 8/9] nvc0: remove allocation of unused sw class
[not found] ` <1448586301-8351-8-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-12-08 14:56 ` Samuel Pitoiset
[not found] ` <5666EF90.2000701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 19+ messages in thread
From: Samuel Pitoiset @ 2015-12-08 14:56 UTC (permalink / raw)
To: Ben Skeggs, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs
NACK.
This patches breaks MP performance counters on Fermi/Kepler because they
actually use software methods to configure multiplexers. Global perf
counters will also use software methods to init, sample and read
hardware counters, so this SW object is definitely needed.
Instead of removing it, we need to do something like that:
http://paste.awesom.eu/EQeX
Thanks.
On 11/27/2015 02:05 AM, Ben Skeggs wrote:
> From: Ben Skeggs <bskeggs@redhat.com>
>
> This would need to be fixed before NVIF can be switched on, but since we
> don't use it anyway, just remove it.
>
> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
> ---
> src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 8 --------
> src/gallium/drivers/nouveau/nvc0/nvc0_screen.h | 1 -
> 2 files changed, 9 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> index 4897ebe..11cb74a 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> @@ -447,7 +447,6 @@ nvc0_screen_destroy(struct pipe_screen *pscreen)
> nouveau_object_del(&screen->eng2d);
> nouveau_object_del(&screen->m2mf);
> nouveau_object_del(&screen->compute);
> - nouveau_object_del(&screen->nvsw);
>
> nouveau_screen_fini(&screen->base);
>
> @@ -698,13 +697,6 @@ 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);
> - if (ret)
> - FAIL_SCREEN_INIT("Error creating SW object: %d\n", ret);
> -
> -
> switch (dev->chipset & ~0xf) {
> case 0x110:
> case 0x100:
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
> index 8b73102..caf34aa 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
> @@ -105,7 +105,6 @@ struct nvc0_screen {
> struct nouveau_object *eng2d;
> struct nouveau_object *m2mf;
> struct nouveau_object *compute;
> - struct nouveau_object *nvsw;
> };
>
> static inline struct nvc0_screen *
>
--
-Samuel
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [mesa v2 8/9] nvc0: remove allocation of unused sw class
[not found] ` <5666EF90.2000701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-12-08 15:30 ` Emil Velikov
[not found] ` <CACvgo50HH6fk+AtpGRsbkfzsn8nPDndcqzMo54cUfwX4hCjFsg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 19+ messages in thread
From: Emil Velikov @ 2015-12-08 15:30 UTC (permalink / raw)
To: Samuel Pitoiset; +Cc: ML nouveau, Ben Skeggs
On 8 December 2015 at 14:56, Samuel Pitoiset <samuel.pitoiset@gmail.com> wrote:
> NACK.
>
> This patches breaks MP performance counters on Fermi/Kepler because they
> actually use software methods to configure multiplexers. Global perf
> counters will also use software methods to init, sample and read hardware
> counters, so this SW object is definitely needed.
>
I'm curious how exactly this happens. Afaict there is no reference to
the nvsw object, which ought to be used, wouldn't it ?
Imho if there is something subtle it's worth adding a comment.
-Emil
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [mesa v2 8/9] nvc0: remove allocation of unused sw class
[not found] ` <CACvgo50HH6fk+AtpGRsbkfzsn8nPDndcqzMo54cUfwX4hCjFsg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-12-08 16:05 ` Samuel Pitoiset
0 siblings, 0 replies; 19+ messages in thread
From: Samuel Pitoiset @ 2015-12-08 16:05 UTC (permalink / raw)
To: Emil Velikov; +Cc: ML nouveau, Ben Skeggs
On 12/08/2015 04:30 PM, Emil Velikov wrote:
> On 8 December 2015 at 14:56, Samuel Pitoiset <samuel.pitoiset@gmail.com> wrote:
>> NACK.
>>
>> This patches breaks MP performance counters on Fermi/Kepler because they
>> actually use software methods to configure multiplexers. Global perf
>> counters will also use software methods to init, sample and read hardware
>> counters, so this SW object is definitely needed.
>>
> I'm curious how exactly this happens. Afaict there is no reference to
> the nvsw object, which ought to be used, wouldn't it ?
> Imho if there is something subtle it's worth adding a comment.
Usually, we need to "register" a subchannel using
the NV01_SUBCHAN_OBJECT command, but surprisingly this doesn't seem to
be needed for this SW subchan. Probably because it's not *really* a
subchan like 3D, 2D, COMPUTE, M2MF and so on.
I'm not sure if the right way is to use NV01_SUBCHAN_OBJECT like other
subchans (even if this one won't change anything), or to add a comment.
Ben, any ideas?
>
> -Emil
>
--
-Samuel
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2015-12-08 16:05 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-27 1:04 [mesa v2 1/9] nouveau: bump required libdrm version to 2.4.66 Ben Skeggs
[not found] ` <1448586301-8351-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-27 1:04 ` [mesa v2 2/9] nouveau: remove use of deprecated nouveau_device::fd Ben Skeggs
2015-11-27 1:04 ` [mesa v2 3/9] nouveau: remove use of deprecated nouveau_device::drm_version Ben Skeggs
2015-11-27 1:04 ` [mesa v2 4/9] nouveau: return nouveau_screen from hw-specific creation functions Ben Skeggs
2015-11-27 1:04 ` [mesa v2 5/9] nouveau: fix screen creation failure paths Ben Skeggs
[not found] ` <1448586301-8351-5-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-07 3:40 ` Ilia Mirkin
[not found] ` <CAKb7UvjwbztKvR3-PaUA+8=A+NZqBzCeP1KT7AfrNLq4HQsReQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-07 3:48 ` Ben Skeggs
[not found] ` <566501AA.9010600-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-07 3:53 ` Ilia Mirkin
[not found] ` <CAKb7Uvj_3wzh19C+TPe9c_1QJuGgU=JwrZeasjswZ4uM3JcoiA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-07 3:57 ` Ben Skeggs
2015-11-27 1:04 ` [mesa v2 6/9] nouveau: remove use of deprecated nouveau_device_wrap() Ben Skeggs
2015-11-27 1:04 ` [mesa v2 7/9] nv50: fix g98+ vdec class allocation Ben Skeggs
2015-11-27 1:05 ` [mesa v2 8/9] nvc0: remove allocation of unused sw class Ben Skeggs
[not found] ` <1448586301-8351-8-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-08 14:56 ` Samuel Pitoiset
[not found] ` <5666EF90.2000701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-08 15:30 ` Emil Velikov
[not found] ` <CACvgo50HH6fk+AtpGRsbkfzsn8nPDndcqzMo54cUfwX4hCjFsg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-08 16:05 ` Samuel Pitoiset
2015-11-27 1:05 ` [mesa v2 9/9] nouveau: enable use of new kernel interfaces Ben Skeggs
[not found] ` <1448586301-8351-9-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-07 3:46 ` Ilia Mirkin
2015-12-07 3:32 ` [mesa v2 1/9] nouveau: bump required libdrm version to 2.4.66 Ilia Mirkin
2015-12-07 3:49 ` Ben Skeggs
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.