Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gpu device never parsed? #486

Open
Ciflire opened this issue Jul 10, 2024 · 2 comments
Open

Gpu device never parsed? #486

Ciflire opened this issue Jul 10, 2024 · 2 comments

Comments

@Ciflire
Copy link

Ciflire commented Jul 10, 2024

Describe the bug
gamemoded -t does not look for the device set in settings, it always looks for default value which is 0

To Reproduce
Steps used to reproduce the behavior:

  1. configure your gpu device to be different from 0
  2. run gamemoded -t
  3. get the following error ERROR: Couldn't open vendor file at /sys/class/drm/card0/device/vendor, will not apply gpu optimisations!
  4. See that it's looking for card0 even if gpu device is not 0

Expected behavior
I do not expect it to pass all the tests but at least not for it to look for card 0 when specified 1

System Info (please complete the following information):

  • OS and version: Nixos 24.11
  • GameMode Version 1.8.1

Additional context
this is my config, generated by nix in /etc/gamemode.ini, it is found by process

[custom]
end=/nix/store/qjc7b5l019p260qv9r7w39hsap656jbl-libnotify-0.8.3/bin/notify-send 'GameMode ended'
start=/nix/store/qjc7b5l019p260qv9r7w39hsap656jbl-libnotify-0.8.3/bin/notify-send 'GameMode started'

[general]
disable_splitlock=0
igpu_desiredgov=performance
inhibit_screensaver=0
renice=10

[gpu]
apply_gpu_optimisations=accept-responsibility
gpu_device=1
nv_powermizer_mode=2

i do belive but could be wrong that you never parse this part of the config and keep it to default
i belive the device should be set here
https://github.com/FeralInteractive/gamemode/blob/master/daemon/gamemode-gpu.c#L74-L75
but this symbol leads to a reference in
https://github.com/FeralInteractive/gamemode/blob/master/daemon/gamemode-config.h#L116-L117
but i think is never implemented

@MrSn0wy
Copy link

MrSn0wy commented Jul 23, 2024

i had the same issue.
A thing i noticed is that when it is set to 2 it does use card2, i guess for some reason it just doesn't like card1 lmao.

OS: Nixos 24.05
GameMode Version 1.8.1

@djahandarie
Copy link

Same issue, it doesn't seem to successfully read the config when gpu_device=1 but does when it's gpu_device=2.

This seems to be the relevant code for reading the config:

DEFINE_CONFIG_GET(gpu_device)

#define DEFINE_CONFIG_GET(name) \
long config_get_##name(GameModeConfig *self) \
{ \
long value = 0; \
memcpy_locked_config(self, &value, &self->values.name, sizeof(long)); \
return value; \
}

static void memcpy_locked_config(GameModeConfig *self, void *dst, void *src, size_t n)
{
/* Take the read lock */
pthread_rwlock_rdlock(&self->rwlock);
/* copy the data */
memcpy(dst, src, n);
/* release the lock */
pthread_rwlock_unlock(&self->rwlock);
}

And this is the place that calls that code:

new_info->device = config_get_gpu_device(config);
/* verify device ID */
if (new_info->device == -1) {
LOG_ERROR(
"Invalid gpu_device value set in configuration, will not apply "
"optimisations!\n");
free(new_info);
return -1;
}
/* Fill in GPU vendor */
new_info->vendor = gamemode_get_gpu_vendor(new_info->device);

And this is what ends up being 0 instead of 1:

enum GPUVendor gamemode_get_gpu_vendor(long device)
{
enum GPUVendor vendor = Vendor_Invalid;
/* Fill in GPU vendor */
char path[64] = { 0 };
if (snprintf(path, 64, "/sys/class/drm/card%ld/device/vendor", device) < 0) {
LOG_ERROR("snprintf failed, will not apply gpu optimisations!\n");
return Vendor_Invalid;
}
FILE *file = fopen(path, "r");
if (!file) {
LOG_ERROR("Couldn't open vendor file at %s, will not apply gpu optimisations!\n", path);
return Vendor_Invalid;
}

ERROR: Couldn't open vendor file at /sys/class/drm/card0/device/vendor, will not apply gpu optimisations!

I can't immediately see an error here just from looking at the code, as it seems to just boil down to a memcpy followed by a snprintf. I guess someone would need to get a local build running to debug it further.

@afayaz-feral Sorry for the direct ping, would you have any guess why this function fails to work when the value is 1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants