intel/perf: allow opening perf stream with no context filtering
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 5 May 2021 20:24:47 +0000 (23:24 +0300)
committerMarge Bot <eric+marge@anholt.net>
Tue, 18 May 2021 14:28:48 +0000 (14:28 +0000)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10216>

src/intel/perf/intel_perf.c
src/intel/perf/intel_perf.h
src/intel/perf/intel_perf_query.c

index 3321887..80660fb 100644 (file)
@@ -53,8 +53,6 @@
 
 #define FILE_DEBUG_FLAG DEBUG_PERFMON
 
-#define OA_REPORT_INVALID_CTX_ID (0xffffffff)
-
 static bool
 is_dir_or_link(const struct dirent *entry, const char *parent_dir)
 {
@@ -1052,8 +1050,8 @@ intel_perf_query_result_accumulate(struct intel_perf_query_result *result,
 {
    int i;
 
-   if (result->hw_id == OA_REPORT_INVALID_CTX_ID &&
-       start[2] != OA_REPORT_INVALID_CTX_ID)
+   if (result->hw_id == INTEL_PERF_INVALID_CTX_ID &&
+       start[2] != INTEL_PERF_INVALID_CTX_ID)
       result->hw_id = start[2];
    if (result->reports_accumulated == 0)
       result->begin_timestamp = start[1];
@@ -1229,7 +1227,7 @@ void
 intel_perf_query_result_clear(struct intel_perf_query_result *result)
 {
    memset(result, 0, sizeof(*result));
-   result->hw_id = OA_REPORT_INVALID_CTX_ID; /* invalid */
+   result->hw_id = INTEL_PERF_INVALID_CTX_ID;
 }
 
 void
index 74aa362..6f8c1a5 100644 (file)
@@ -50,6 +50,8 @@ struct intel_device_info;
 struct intel_perf_config;
 struct intel_perf_query_info;
 
+#define INTEL_PERF_INVALID_CTX_ID (0xffffffff)
+
 enum intel_perf_counter_type {
    INTEL_PERF_COUNTER_TYPE_EVENT,
    INTEL_PERF_COUNTER_TYPE_DURATION_NORM,
index cc1981a..cff3138 100644 (file)
@@ -375,9 +375,11 @@ intel_perf_open(struct intel_perf_context *perf_ctx,
    uint64_t properties[DRM_I915_PERF_PROP_MAX * 2];
    uint32_t p = 0;
 
-   /* Single context sampling */
-   properties[p++] = DRM_I915_PERF_PROP_CTX_HANDLE;
-   properties[p++] = ctx_id;
+   /* Single context sampling if valid context id. */
+   if (ctx_id != INTEL_PERF_INVALID_CTX_ID) {
+      properties[p++] = DRM_I915_PERF_PROP_CTX_HANDLE;
+      properties[p++] = ctx_id;
+   }
 
    /* Include OA reports in samples */
    properties[p++] = DRM_I915_PERF_PROP_SAMPLE_OA;