Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.6)

set(CMAKE_CXX_STANDARD 11 LANGUAGES CXX)
add_compile_options(-Wall -Wextra)

project("URM-Extensions")
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
Expand Down
61 changes: 3 additions & 58 deletions Extensions/GenieT2T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,7 @@
#include <algorithm>

#include "Helpers.h"

static std::vector<std::pair<std::string, std::string>> gIrqAffBackup;

static void irqAffinityApplierCallback(void* context) {
LOGD("RESTUNE_COCO_TABLE", "enter irqAffinityApplierCallback");

if(context == nullptr) return;
Resource* resource = static_cast<Resource*>(context);

gIrqAffBackup.clear();
uint64_t mask = 0;
for(int32_t i = 0; i < resource->getValuesCount(); i++) {
mask |= ((uint64_t)1 << (resource->getValueAt(i)));
}

std::string dirPath = "/proc/irq/";
DIR* dir = opendir(dirPath.c_str());
if(dir == nullptr) {
return;
}

struct dirent* entry;
while((entry = readdir(dir)) != nullptr) {
std::string filePath = dirPath + std::string(entry->d_name) + "/";
filePath.append("smp_affinity");

if(AuxRoutines::fileExists(filePath)) {
gIrqAffBackup.emplace_back(filePath, AuxRoutines::readFromFile(filePath));

// Convert to hex
std::ostringstream oss;
oss<<std::hex<<std::nouppercase;
if(mask == 0) {
oss<<"0";
} else {
oss<<mask;
}
std::string hexMask = oss.str();
TYPELOGV(NOTIFY_NODE_WRITE_S, filePath.c_str(), hexMask.c_str());
AuxRoutines::writeToFile(filePath, hexMask);
}
}
closedir(dir);
}

static void irqAffinityTearCallback(void* context) {
if(context == nullptr) return;

for(const auto& kv : gIrqAffBackup) {
const std::string& path = kv.first;
const std::string& oldVal = kv.second;
TYPELOGV(NOTIFY_NODE_RESET, path.c_str(), oldVal.c_str());
AuxRoutines::writeToFile(path, oldVal);
}
gIrqAffBackup.clear();
}
#include "PredefCallbacks.h"

static void workloadPostprocessCallback(void* context) {
if(context == nullptr) {
Expand All @@ -83,8 +28,8 @@ static void workloadPostprocessCallback(void* context) {
cbData->mSigType = DEFAULT_SIGNAL_TYPE;
}

URM_REGISTER_RES_APPLIER_CB(0x00f00001, irqAffinityApplierCallback)
URM_REGISTER_RES_TEAR_CB(0x00f00001, irqAffinityTearCallback)
URM_REGISTER_RES_APPLIER_CB(0x00f00001, getApplyCb(IRQ_AFFINE_ALL))
URM_REGISTER_RES_TEAR_CB(0x00f00001, getTearCb(IRQ_AFFINE_ALL))

// genie-t2t-run
URM_REGISTER_POST_PROCESS_CB("genie-t2t-run", workloadPostprocessCallback);
33 changes: 33 additions & 0 deletions Extensions/Include/PredefCallbacks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
// SPDX-License-Identifier: BSD-3-Clause-Clear

#ifndef PREDEF_CALLBACKS_H
#define PREDEF_CALLBACKS_H

#include "Helpers.h"

void irqAffinityApplierCallback(void* context);
void irqAffinityTearCallback(void* context);

typedef struct {
ResourceLifecycleCallback mApply;
ResourceLifecycleCallback mTear;
} LifecycleCbSet;

enum PredefCallbackId : int32_t {
IRQ_AFFINE_ALL = 0,
};

static LifecycleCbSet predefCallbacks[] = {
{irqAffinityApplierCallback, irqAffinityTearCallback},
};

inline ResourceLifecycleCallback getApplyCb(int32_t id) {
return predefCallbacks[id].mApply;
}

inline ResourceLifecycleCallback getTearCb(int32_t id) {
return predefCallbacks[id].mTear;
}

#endif
6 changes: 4 additions & 2 deletions Extensions/PostProcessingBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@ int32_t PostProcessingBlock::FetchUsecaseDetails(int32_t pid,
size_t sz,
uint32_t& sigId,
uint32_t& sigType) {
/* For encoder, width of encoding, v4l2h264enc in line
/*
* For encoder, width of encoding, v4l2h264enc in line
* For decoder, v4l2h264dec, or may be 265 as well, decoder bit
*/
(void)sz;

int32_t ret = -1, numSrc = 0;
int32_t encode = 0, decode = 0, preview = 0;
int32_t height = 0;
Expand Down Expand Up @@ -187,7 +190,6 @@ int32_t PostProcessingBlock::FetchUsecaseDetails(int32_t pid,
/*Preview case*/
if (encode == 0 && decode == 0) {
char *d = buf;
size_t d_str_sz = strlen(qmm_str);
if ((d = strstr(d, qmm_str)) != nullptr) {
preview += 1;
sigId = URM_SIG_CAMERA_PREVIEW;
Expand Down
58 changes: 58 additions & 0 deletions Extensions/PredefCallbacks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
// SPDX-License-Identifier: BSD-3-Clause-Clear

#include "PredefCallbacks.h"

static std::vector<std::pair<std::string, std::string>> gIrqAffBackup;

void irqAffinityApplierCallback(void* context) {
if(context == nullptr) return;
Resource* resource = static_cast<Resource*>(context);

gIrqAffBackup.clear();
uint64_t mask = 0;
for(int32_t i = 0; i < resource->getValuesCount(); i++) {
mask |= ((uint64_t)1 << (resource->getValueAt(i)));
}

std::string dirPath = "/proc/irq/";
DIR* dir = opendir(dirPath.c_str());
if(dir == nullptr) {
return;
}

struct dirent* entry;
while((entry = readdir(dir)) != nullptr) {
std::string filePath = dirPath + std::string(entry->d_name) + "/";
filePath.append("smp_affinity");

if(AuxRoutines::fileExists(filePath)) {
gIrqAffBackup.emplace_back(filePath, AuxRoutines::readFromFile(filePath));

// Convert to hex
std::ostringstream oss;
oss<<std::hex<<std::nouppercase;
if(mask == 0) {
oss<<"0";
} else {
oss<<mask;
}
std::string hexMask = oss.str();
TYPELOGV(NOTIFY_NODE_WRITE_S, filePath.c_str(), hexMask.c_str());
AuxRoutines::writeToFile(filePath, hexMask);
}
}
closedir(dir);
}

void irqAffinityTearCallback(void* context) {
if(context == nullptr) return;

for(const auto& kv : gIrqAffBackup) {
const std::string& path = kv.first;
const std::string& oldVal = kv.second;
TYPELOGV(NOTIFY_NODE_RESET, path.c_str(), oldVal.c_str());
AuxRoutines::writeToFile(path, oldVal);
}
gIrqAffBackup.clear();
}
Loading