[igt-dev] [PATCH i-g-t] lib/i915/perf: return NULL when platform is not supported

Lionel Landwerlin lionel.g.landwerlin at intel.com
Tue Feb 25 11:22:18 UTC 2020


Instead of asserting.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 lib/i915/perf.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index 5b5b7f90..a5dd3eab 100644
--- a/lib/i915/perf.c
+++ b/lib/i915/perf.c
@@ -116,6 +116,13 @@ eu_available(const struct drm_i915_query_topology_info *topo,
 			   eu / 8] >> (eu % 8)) & 1;
 }
 
+static struct intel_perf *
+unsupported_i915_perf_platform(struct intel_perf *perf)
+{
+	intel_perf_free(perf);
+	return NULL;
+}
+
 struct intel_perf *
 intel_perf_for_devinfo(uint32_t device_id,
 		       uint32_t revision,
@@ -193,7 +200,7 @@ intel_perf_for_devinfo(uint32_t device_id,
 			intel_perf_load_metrics_sklgt4(perf);
 			break;
 		default:
-			assert(0); /* unreachable */
+			return unsupported_i915_perf_platform(perf);
 		}
 	} else if (devinfo->is_broxton) {
 		perf->devinfo.eu_threads_count = 6;
@@ -207,7 +214,7 @@ intel_perf_for_devinfo(uint32_t device_id,
 			intel_perf_load_metrics_kblgt3(perf);
 			break;
 		default:
-			assert(0); /* unreachable */
+			return unsupported_i915_perf_platform(perf);
 		}
 	} else if (devinfo->is_geminilake) {
 		perf->devinfo.eu_threads_count = 6;
@@ -221,7 +228,7 @@ intel_perf_for_devinfo(uint32_t device_id,
 			intel_perf_load_metrics_cflgt3(perf);
 			break;
 		default:
-			assert(0); /* unreachable */
+			return unsupported_i915_perf_platform(perf);
 		}
 	} else if (devinfo->is_cannonlake) {
 		intel_perf_load_metrics_cnl(perf);
@@ -232,7 +239,7 @@ intel_perf_for_devinfo(uint32_t device_id,
 	} else if (devinfo->is_tigerlake) {
 		intel_perf_load_metrics_tgl(perf);
 	} else {
-		assert(0); /* unreachable */
+		return unsupported_i915_perf_platform(perf);
 	}
 
 	return perf;
-- 
2.25.1



More information about the igt-dev mailing list