intel/ds: use a per GPU clock ID

Multi-GPU setups :)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rohan Garg <rohan.garg@intel.com>
Acked-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13996>
This commit is contained in:
Lionel Landwerlin 2021-12-05 16:38:20 +02:00 committed by Marge Bot
parent 61766f9f90
commit cf9956a8c5
2 changed files with 49 additions and 6 deletions

View File

@ -27,6 +27,7 @@
#include <pps/pps_algorithm.h>
#include "intel_pps_perf.h"
#include "intel_pps_priv.h"
namespace pps
{
@ -43,12 +44,6 @@ uint64_t IntelDriver::get_min_sampling_period_ns()
IntelDriver::IntelDriver()
{
/* Note: clock_id's below 128 are reserved.. for custom clock sources,
* using the hash of a namespaced string is the recommended approach.
* See: https://perfetto.dev/docs/concepts/clock-sync
*/
this->clock_id =
_mesa_hash_string("org.freedesktop.mesa.intel") | 0x80000000;
}
IntelDriver::~IntelDriver()
@ -74,6 +69,12 @@ void IntelDriver::enable_all_counters()
bool IntelDriver::init_perfcnt()
{
/* Note: clock_id's below 128 are reserved.. for custom clock sources,
* using the hash of a namespaced string is the recommended approach.
* See: https://perfetto.dev/docs/concepts/clock-sync
*/
this->clock_id = intel_pps_clock_id(drm_device.gpu_num);
assert(!perf && "Intel perf should not be initialized at this point");
perf = std::make_unique<IntelPerf>(drm_device.fd);

View File

@ -0,0 +1,42 @@
/*
* Copyright © 2021 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef INTEL_PPS_PRIV_H
#define INTEL_PPS_PRIV_H
#include <string.h>
#include "util/hash_table.h"
/* Common clock_id name for all perfetto producers */
static inline uint32_t
intel_pps_clock_id(uint32_t gpu_id)
{
char buf[40];
snprintf(buf, sizeof(buf),
"org.freedesktop.mesa.intel.gpu%u", gpu_id);
return _mesa_hash_string(buf) | 0x80000000;
}
#endif /* INTEL_PPS_PRIV_H */