From cf58debf63b6b5485368bea8e50b4073b5de7a3d Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Sun, 21 Mar 2021 04:06:09 -0400 Subject: [PATCH] nvc0: fix reported driver queries for Pascal and later GPUs We haven't added the sm/metric info post-GM200. So make sure we don't report available queries there. Additionally, fix the group retrieval to take into account that either driver stats or SM stats may not be available. Signed-off-by: Ilia Mirkin Reviewed-by: Karol Herbst Part-of: --- src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 39 +++++++++++----------- .../drivers/nouveau/nvc0/nvc0_query_hw_metric.c | 8 +++-- .../drivers/nouveau/nvc0/nvc0_query_hw_sm.c | 8 +++-- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c index d07be34..41d7ab9 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c @@ -206,24 +206,27 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen *pscreen, { struct nvc0_screen *screen = nvc0_screen(pscreen); int count = 0; - -#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - count++; -#endif + int map[3] = {}; if (screen->base.drm->version >= 0x01000101) { if (screen->compute) { if (screen->base.class_3d <= GM200_3D_CLASS) { - count += 2; + map[count++] = NVC0_HW_SM_QUERY_GROUP; + map[count++] = NVC0_HW_METRIC_QUERY_GROUP; } } } +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + map[count++] = NVC0_SW_QUERY_DRV_STAT_GROUP; +#endif + if (!info) return count; - if (id == NVC0_HW_SM_QUERY_GROUP) { - if (screen->compute) { + switch (map[id]) { + case NVC0_HW_SM_QUERY_GROUP: + if (screen->compute && screen->base.class_3d <= GM200_3D_CLASS) { info->name = "MP counters"; /* Expose the maximum number of hardware counters available, although @@ -234,25 +237,23 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen *pscreen, info->num_queries = nvc0_hw_sm_get_num_queries(screen); return 1; } - } else - if (id == NVC0_HW_METRIC_QUERY_GROUP) { - if (screen->compute) { - if (screen->base.class_3d <= GM200_3D_CLASS) { - info->name = "Performance metrics"; - info->max_active_queries = 4; /* A metric uses at least 2 queries */ - info->num_queries = nvc0_hw_metric_get_num_queries(screen); - return 1; - } + break; + case NVC0_HW_METRIC_QUERY_GROUP: + if (screen->compute && screen->base.class_3d <= GM200_3D_CLASS) { + info->name = "Performance metrics"; + info->max_active_queries = 4; /* A metric uses at least 2 queries */ + info->num_queries = nvc0_hw_metric_get_num_queries(screen); + return 1; } - } + break; #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - else if (id == NVC0_SW_QUERY_DRV_STAT_GROUP) { + case NVC0_SW_QUERY_DRV_STAT_GROUP: info->name = "Driver statistics"; info->max_active_queries = NVC0_SW_QUERY_DRV_STAT_COUNT; info->num_queries = NVC0_SW_QUERY_DRV_STAT_COUNT; return 1; - } #endif + } /* user asked for info about non-existing query group */ info->name = "this_is_not_the_query_group_you_are_looking_for"; 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 c78b046..be9d51c 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c @@ -407,7 +407,9 @@ nvc0_hw_metric_get_queries(struct nvc0_screen *screen) return sm35_hw_metric_queries; case NVE4_3D_CLASS: return sm30_hw_metric_queries; - default: + case NVC0_3D_CLASS: + case NVC1_3D_CLASS: + case NVC8_3D_CLASS: if (dev->chipset == 0xc0 || dev->chipset == 0xc8) return sm20_hw_metric_queries; return sm21_hw_metric_queries; @@ -429,7 +431,9 @@ nvc0_hw_metric_get_num_queries(struct nvc0_screen *screen) return ARRAY_SIZE(sm35_hw_metric_queries); case NVE4_3D_CLASS: return ARRAY_SIZE(sm30_hw_metric_queries); - default: + case NVC0_3D_CLASS: + case NVC1_3D_CLASS: + case NVC8_3D_CLASS: if (dev->chipset == 0xc0 || dev->chipset == 0xc8) return ARRAY_SIZE(sm20_hw_metric_queries); return ARRAY_SIZE(sm21_hw_metric_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 9050f99..4cc5642 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c @@ -2243,7 +2243,9 @@ nvc0_hw_sm_get_queries(struct nvc0_screen *screen) return sm35_hw_sm_queries; case NVE4_3D_CLASS: return sm30_hw_sm_queries; - default: + case NVC0_3D_CLASS: + case NVC1_3D_CLASS: + case NVC8_3D_CLASS: if (dev->chipset == 0xc0 || dev->chipset == 0xc8) return sm20_hw_sm_queries; return sm21_hw_sm_queries; @@ -2266,7 +2268,9 @@ nvc0_hw_sm_get_num_queries(struct nvc0_screen *screen) return ARRAY_SIZE(sm35_hw_sm_queries); case NVE4_3D_CLASS: return ARRAY_SIZE(sm30_hw_sm_queries); - default: + case NVC0_3D_CLASS: + case NVC1_3D_CLASS: + case NVC8_3D_CLASS: if (dev->chipset == 0xc0 || dev->chipset == 0xc8) return ARRAY_SIZE(sm20_hw_sm_queries); return ARRAY_SIZE(sm21_hw_sm_queries); -- 2.7.4