intel/perf: Move code that will be shared by both KMDs
More code will be shared in the next patches. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29421>
This commit is contained in:
committed by
Marge Bot
parent
b601e4a18f
commit
8ad56247c3
@@ -43,6 +43,7 @@
|
||||
|
||||
#include "perf/i915/intel_perf.h"
|
||||
#include "perf/intel_perf.h"
|
||||
#include "perf/intel_perf_common.h"
|
||||
#include "perf/intel_perf_regs.h"
|
||||
#include "perf/intel_perf_mdapi.h"
|
||||
#include "perf/intel_perf_metrics.h"
|
||||
@@ -135,27 +136,6 @@ get_sysfs_dev_dir(struct intel_perf_config *perf, int fd)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
read_file_uint64(const char *file, uint64_t *val)
|
||||
{
|
||||
char buf[32];
|
||||
int fd, n;
|
||||
|
||||
fd = open(file, 0);
|
||||
if (fd < 0)
|
||||
return false;
|
||||
while ((n = read(fd, buf, sizeof (buf) - 1)) < 0 &&
|
||||
errno == EINTR);
|
||||
close(fd);
|
||||
if (n < 0)
|
||||
return false;
|
||||
|
||||
buf[n] = '\0';
|
||||
*val = strtoull(buf, NULL, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
read_sysfs_drm_device_file_uint64(struct intel_perf_config *perf,
|
||||
const char *file,
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2024 Intel Corporation
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "intel_perf_common.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
bool
|
||||
read_file_uint64(const char *file, uint64_t *val)
|
||||
{
|
||||
char buf[32];
|
||||
int fd, n;
|
||||
|
||||
fd = open(file, 0);
|
||||
if (fd < 0)
|
||||
return false;
|
||||
while ((n = read(fd, buf, sizeof (buf) - 1)) < 0 &&
|
||||
errno == EINTR);
|
||||
close(fd);
|
||||
if (n < 0)
|
||||
return false;
|
||||
|
||||
buf[n] = '\0';
|
||||
*val = strtoull(buf, NULL, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2024 Intel Corporation
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool read_file_uint64(const char *file, uint64_t *val);
|
||||
@@ -19,6 +19,8 @@ endforeach
|
||||
intel_perf_sources = [
|
||||
'i915/intel_perf.c',
|
||||
'i915/intel_perf.h',
|
||||
'intel_perf_common.c',
|
||||
'intel_perf_common.h',
|
||||
'intel_perf.c',
|
||||
'intel_perf_query.c',
|
||||
'intel_perf_mdapi.c',
|
||||
|
||||
Reference in New Issue
Block a user