Commit Graph

37 Commits

Author SHA1 Message Date
78c2ced7d7 external-helper: improve run_external_process() robustness
run_external_process() contained pipe file descriptors leaks (e.g. one
pipe end was never closed). Also the stdout might have been captured
incomplete, since only a single read() was performed on the pipe.
Furthermore should a child process try to write a larger amount of data
onto the pipe then it will become stuck, because the parent process
isn't consuming the data. Thus the timeout would trigger in these cases
although the child process does nothing wrong.

This commit changes the implementation to follow a select() based
approach that continually reads from the pipe, but discards data that
doesn't fit in the provided buffer.
2019-04-04 13:19:22 +02:00
b411cfff6b gpuclockctl: refactor buffer size specification and avoid redundancies 2019-04-04 11:44:34 +02:00
d7394cbeb2 daemon: fix file descriptor leaks 2019-04-03 16:27:12 +02:00
618997f0b3 gpuclockctl: fix return value of get_gpu_state_amd() 2019-04-03 16:18:36 +02:00
45ba5bc4c4 Use matching signedness in format strings
Either cast the variable or change the format string to match the
signedness.
2019-03-28 11:40:40 +00:00
bbde1d0357 Ensure strncpy'ed strings are all null terminated
If there is no null byte among the first n bytes of the source the
resulting string will not be properly null terminated.
Ensure that all strings that are copied via strncpy are properly
terminated copy "sizeof (dest) - 1" bytes and manually terminate
the string in the cases the array was not initialized.

Example compiler warning:
  ../daemon/gamemode-tests.c: In function ‘run_cpu_governor_tests’:
  ../daemon/gamemode-tests.c:326:4: warning: ‘strncpy’ specified bound
      256 equals destination size [-Wstringop-truncation]
    strncpy(defaultgov, currentgov, CONFIG_VALUE_MAX);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-03-28 11:40:40 +00:00
10a31f8dec Update copyright years to 2019 2019-03-14 16:59:30 +00:00
1482a2b39e Get the gpu index for both get and set (thanks @rezzafr33!) 2019-03-12 08:52:58 +00:00
c1d06f2ad5 Try and make an educated guess at the correct nvidia gpu index
This should hopefully fix issue #113, where the user was in the common situation of having an intel and an nvidia GPU, at card0 and card1 respectively, but the nvidia gpu was [gpu:0] according to the driver
2019-03-11 21:58:51 +00:00
dc1258d750 Automatically adjust the nvidia gpu index
The drm device ID doesn't match up with the pci device as expected, spotted by issue #113

	I can't test this myself just yet, will need data from the user in question to verify PCIDevice is the right value
2019-03-11 16:27:49 +00:00
fec32ac53d Remove the nv_perf_level config option and figure it out programmatically
This also fixes the instances in testing where we don't have the nv overclock in use, but we do have the mode set

	Solves issues explaining the what the perf_level actually meant, and future proofs for any PR that wants to set individual perf levels
2019-03-10 15:19:34 +00:00
873d0a224b Remove passing the vendor to gpuclockctl 2019-03-10 15:19:34 +00:00
54d7d3f259 Allow nv_perl_level and nv_powermizer_mode to be set independently 2019-03-10 10:32:08 +00:00
834a18aab4 Implement nv_powermizer_mode option to allow setting the Nvidia powermizer mode 2019-03-10 10:32:08 +00:00
9ade4481c3 Change AMD overclocking to simply be setting the power_dpm_force_performance_level file for now
This covers the MVP for now, and simply allows pinning the power level to "high"

	Full overclocking set up is somewhat more complicated, and it'll be better to implement that at the same time as the same for Nvidia, where we're currently only really setting the top end power level
2019-03-10 10:32:08 +00:00
20efaaa33f Rename the core and mem stats to nv_ prefix
These will be NV only going forward, as AMD needs a different chunk of work
2019-03-10 10:32:08 +00:00
53d1700a68 Add the timout to the call signature of run_external_process 2019-03-07 17:51:57 +00:00
4578af47ba Combine the two run_external_process functions so they both have the same timeout protection 2019-03-07 17:51:57 +00:00
42d7503482 Adjust checking in gpuclockctl to assist when errors happen 2019-02-20 18:08:24 +00:00
e31a811946 Add run_external_process_get_output function to get output as well 2019-02-20 17:53:13 +00:00
392fb221dc Return failure on failure, and don't try and read past the end of argv 2019-02-20 17:53:13 +00:00
9cd32c63eb Implement getting GPU clocks for NV 2019-02-20 17:53:13 +00:00
00ed82f8e4 Extend the nvidia command size to 128
It was exactly 64 for small arguments, but that fails for larger overlocks
2019-02-12 08:55:23 +00:00
16ade5c1c9 Adjust the TODO list 2019-02-12 08:55:23 +00:00
d18f3fc584 Remove duplicate ERROR strings from error logs
Now visible in 5898538
2019-02-12 08:55:23 +00:00
db0f8f91f3 Update TODO comments 2019-02-12 08:55:23 +00:00
2aa2ca2f7d Implement AMD overclocking using AMDGPU
Again, simply set values based on our inputs, with appropriate error messages
2019-02-12 08:55:23 +00:00
f5e7fa3222 Set up overclocking calls on NVidia
These require the coolbits plugin to be activated on nvidia-xsettings
2019-02-12 08:55:23 +00:00
bd5baccc67 Hook up individual set state functions 2019-02-12 08:55:23 +00:00
53428356a5 Move control code back into the helper 2019-02-12 08:55:23 +00:00
ff1a838ab7 Apply format corrections 2019-02-12 08:55:23 +00:00
142b2fb32d Also add nv_perf_level for nvidia (needed as a parameter to nvidia-xsettings) 2019-02-12 08:55:23 +00:00
4152104d2b Correct the mem argv index and print the intended change 2019-02-12 08:55:23 +00:00
01dbe4e2b0 Rename gpu-query to gpu-control to better describe it's functions 2019-02-12 08:55:23 +00:00
a1a1829dea Add argument parsing and errors to gpuclockctl 2019-02-12 08:55:23 +00:00
8a52e812d9 Correct format args 2019-02-12 08:55:23 +00:00
8d4e9ac54e Add gpuclockctl to allow privilaged control of GPU parameters 2019-02-12 08:55:23 +00:00