mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-03 06:07:20 +02:00
Prevent platform profile error on unsupported systems
If a system does not support setting the platform profile (i.e., does not have the file /sys/firmware/acpi/platform_profile), then everything that interacts with it is skipped to prevent errors. This situation is more common than I expected.[1] [1] https://github.com/FeralInteractive/gamemode/issues/524
This commit is contained in:
parent
5f691c3171
commit
499af4c7bb
@ -39,6 +39,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
const char *profile_path = "/sys/firmware/acpi/platform_profile";
|
const char *profile_path = "/sys/firmware/acpi/platform_profile";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if platform profile file exists
|
||||||
|
*/
|
||||||
|
int profile_exists(void)
|
||||||
|
{
|
||||||
|
return !access(profile_path, F_OK);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current platform profile state
|
* Return the current platform profile state
|
||||||
*/
|
*/
|
||||||
|
@ -32,12 +32,18 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path for platform profile
|
* Path for platform profile
|
||||||
*/
|
*/
|
||||||
extern const char *profile_path;
|
extern const char *profile_path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if platform profile file exists
|
||||||
|
*/
|
||||||
|
int profile_exists(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current platform profile state
|
* Get the current platform profile state
|
||||||
*/
|
*/
|
||||||
|
@ -317,7 +317,7 @@ static int game_mode_set_governor(GameModeContext *self, enum GameModeGovernor g
|
|||||||
|
|
||||||
static void game_mode_store_profile(GameModeContext *self)
|
static void game_mode_store_profile(GameModeContext *self)
|
||||||
{
|
{
|
||||||
if (self->current_profile != GAME_MODE_PROFILE_DEFAULT)
|
if (!profile_exists() || self->current_profile != GAME_MODE_PROFILE_DEFAULT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char *initial_state = get_profile_state();
|
const char *initial_state = get_profile_state();
|
||||||
@ -335,6 +335,11 @@ static int game_mode_set_profile(GameModeContext *self, enum GameModeProfile pro
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!profile_exists()) {
|
||||||
|
LOG_MSG("Setting platform profile unsupported; skipping\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const char *prof_str = NULL;
|
const char *prof_str = NULL;
|
||||||
char prof_config_str[CONFIG_VALUE_MAX] = { 0 };
|
char prof_config_str[CONFIG_VALUE_MAX] = { 0 };
|
||||||
switch (prof) {
|
switch (prof) {
|
||||||
|
@ -361,6 +361,9 @@ static int run_cpu_governor_tests(struct GameModeConfig *config)
|
|||||||
/* Check the platform profile setting works */
|
/* Check the platform profile setting works */
|
||||||
static int run_platform_profile_tests(struct GameModeConfig *config)
|
static int run_platform_profile_tests(struct GameModeConfig *config)
|
||||||
{
|
{
|
||||||
|
if (!profile_exists())
|
||||||
|
return 1;
|
||||||
|
|
||||||
/* get the two config parameters we care about */
|
/* get the two config parameters we care about */
|
||||||
char desiredprof[CONFIG_VALUE_MAX] = { 0 };
|
char desiredprof[CONFIG_VALUE_MAX] = { 0 };
|
||||||
config_get_desired_profile(config, desiredprof);
|
config_get_desired_profile(config, desiredprof);
|
||||||
@ -866,15 +869,17 @@ static int game_mode_run_feature_tests(struct GameModeConfig *config)
|
|||||||
{
|
{
|
||||||
LOG_MSG("::: Verifying platform profile setting\n");
|
LOG_MSG("::: Verifying platform profile setting\n");
|
||||||
|
|
||||||
int govstatus = run_platform_profile_tests(config);
|
int profstatus = run_platform_profile_tests(config);
|
||||||
|
|
||||||
if (govstatus == 0)
|
if (profstatus == 1)
|
||||||
|
LOG_MSG("::: Passed (platform profile not supported)\n");
|
||||||
|
else if (profstatus == 0)
|
||||||
LOG_MSG("::: Passed\n");
|
LOG_MSG("::: Passed\n");
|
||||||
else {
|
else {
|
||||||
LOG_MSG("::: Failed!\n");
|
LOG_MSG("::: Failed!\n");
|
||||||
LOG_MSG(" -- You may need to add your user to the gamemode group:");
|
LOG_MSG(" -- You may need to add your user to the gamemode group:");
|
||||||
LOG_MSG(" -- $ sudo usermod -aG gamemode $(whoami)");
|
LOG_MSG(" -- $ sudo usermod -aG gamemode $(whoami)");
|
||||||
// Consider the platform profile feature requried
|
// If available, setting the platform profile should work
|
||||||
status = -1;
|
status = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user