SWDEV-469750: Load libpciaccess-dev functions with dlopen. Removed libsystemd-dev from CMakeLists.txt
Change-Id: I314c188fabc2dd4de3b633d722599bc11a046622
[ROCm/rocprofiler commit: 4ed346aa63]
Tá an tiomantas seo le fáil i:
@@ -21,8 +21,10 @@
|
||||
#include "mmio.h"
|
||||
#include <cstdint>
|
||||
#include "../../../utils/helper.h"
|
||||
#include "../../../utils/libpci_helper.h"
|
||||
#include "pcie_perfmon_registers_mi200.h"
|
||||
#include "df_perfmon_registers_mi200.h"
|
||||
|
||||
namespace rocprofiler {
|
||||
|
||||
namespace mmio {
|
||||
@@ -57,23 +59,24 @@ MMIO::MMIO(const HSAAgentInfo& info)
|
||||
const auto pci_location_id = agent_info_->GetDeviceInfo().getPCILocationID();
|
||||
|
||||
pci_device_ =
|
||||
pci_device_find_by_slot(pci_domain, pci_location_id >> 8, pci_location_id & 0xFF, 0);
|
||||
if (!pci_device_ || pci_device_probe(pci_device_)) fatal("failed to probe the GPU device\n");
|
||||
GetPciAccessLibApi()->pci_device_find_by_slot(pci_domain, pci_location_id >> 8, pci_location_id & 0xFF, 0);
|
||||
if (!pci_device_ || GetPciAccessLibApi()->pci_device_probe(pci_device_)) fatal("failed to probe the GPU device\n");
|
||||
|
||||
// Look for a region between 256KB and 4096KB, 32-bit, non IO, and non prefetchable.
|
||||
for (size_t region = 0; region < sizeof(pci_device::regions) / sizeof(pci_device::regions[0]);
|
||||
++region)
|
||||
++region){
|
||||
if (pci_device_->regions[region].is_64 == 0 &&
|
||||
pci_device_->regions[region].is_prefetchable == 0 &&
|
||||
pci_device_->regions[region].is_IO == 0 &&
|
||||
pci_device_->regions[region].size >= (256UL * 1024) &&
|
||||
pci_device_->regions[region].size <= (4096UL * 1024)) {
|
||||
pci_memory_size_ = pci_device_->regions[region].size;
|
||||
int err = pci_device_map_range(pci_device_, pci_device_->regions[region].base_addr,
|
||||
int err = GetPciAccessLibApi()->pci_device_map_range(pci_device_, pci_device_->regions[region].base_addr,
|
||||
pci_device_->regions[region].size, PCI_DEV_MAP_FLAG_WRITABLE,
|
||||
(void**)&pci_memory_);
|
||||
if (err) fatal("failed to map the registers. Error code: %d\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
if (pci_memory_ == nullptr) fatal("could not find the pci memory address\n");
|
||||
|
||||
@@ -82,7 +85,7 @@ MMIO::MMIO(const HSAAgentInfo& info)
|
||||
|
||||
MMIO::~MMIO() {
|
||||
if (pci_memory_) {
|
||||
int err = pci_device_unmap_range(pci_device_, pci_memory_, pci_memory_size_);
|
||||
int err = GetPciAccessLibApi()->pci_device_unmap_range(pci_device_, pci_memory_, pci_memory_size_);
|
||||
if (err) warning("failed to unmap the pci memory. Error code: %d\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "src/api/rocprofiler_singleton.h"
|
||||
#include "src/core/counters/mmio/pcie_counters_mi200.h"
|
||||
#include "src/core/counters/mmio/df_counters_mi200.h"
|
||||
#include "src/utils/libpci_helper.h"
|
||||
|
||||
namespace rocprofiler {
|
||||
|
||||
@@ -32,9 +33,9 @@ CountersSampler::CountersSampler(rocprofiler_buffer_id_t buffer_id,
|
||||
: buffer_id_(buffer_id),
|
||||
filter_id_(filter_id),
|
||||
session_id_(session_id),
|
||||
pci_system_initialized_(pci_system_init() == 0)
|
||||
|
||||
pci_system_initialized_(false)
|
||||
{
|
||||
pci_system_initialized_ = GetPciAccessLibApi()->pci_system_init() == 0;
|
||||
params_ = rocprofiler::ROCProfiler_Singleton::GetInstance()
|
||||
.GetSession(session_id_)
|
||||
->GetFilter(filter_id_)
|
||||
@@ -94,8 +95,9 @@ CountersSampler::~CountersSampler() {
|
||||
// clean up libpcieaccess resources
|
||||
// TODO: should be part of mmio class in future
|
||||
if (pci_system_initialized_) {
|
||||
pci_system_cleanup();
|
||||
GetPciAccessLibApi()->pci_system_cleanup();
|
||||
pci_system_initialized_ = false;
|
||||
UnLoadPcieAccessLibAPI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Tagairt in Eagrán Nua
Cuir bac ar úsáideoir