summaryrefslogtreecommitdiff
path: root/lib/igt_sysfs.c
AgeCommit message (Collapse)Author
2019-04-15tests/fbcon_fbt: Enable cursor blinkingJosé Roberto de Souza
If cursor blinking is disabled no screen updates will happen and fbcon_fbt subtests will fail, so lets enable cursor blink while running this test and restore to the previous value when exiting it. v4: - renaming restore fd (Dhinakaran) - saving previous value as char (Dhinakaran) - skipping test if not able to open cursor blink file (Dhinakaran) Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
2019-03-20lib/igt_sysfs: Simplify obtaining sysfs pathMichał Winiarski
Now that we've extracted card index, we no longer have the need to iterate over device nodes. v2: Drop ret. Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-03-20lib/igt_sysfs: Remove idx from sysfs_openMichał Winiarski
Similar to sysfs_path - more explicit more better. Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-03-20lib/igt_device: Introduce igt_device_get_card_indexMichał Winiarski
And use it! But let's start small. Rather than going with "and by the way, here's the card index" from igt_sysfs_path, we're making things more explicit. v2: Drop idx comment. (Chris) Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-01-14igt/sysfs: drop support for passing -1 fd for IntelJani Nikula
The rabbit hole goes deep in this case, but I couldn't find any place where we'd still rely on -1 for Intel. Drop the remaining support to prevent anyone adding new code using this. Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
2019-01-10lib/sysfs: Repair override of params with -1Chris Wilson
Commit e27626898b87 ("igt: Check the physical swizzle status") stopped trying to chase the parameters from the device sysfs, entirely by accident. Make it a tiny bit more robust by forgiving the sysfs device not being present and jumping to the /sys/module + driver name param lookup fallback. Reported-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
2018-09-14igt_sysfs: Avoid double closing the fd in igt_sysfs_scanfTvrtko Ursulin
fdopen takes ownership of the fd so only one flavour of closing it is needed. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-08-30lib/sysfs: Avoid using FILE* temporary for igt_sysfs_[v]printfChris Wilson
Currently we wrap our fd inside a FILE* stream to make use of vfprintf, but the man page leaves the question of errno and signal handling in doubt. It is documented as returning a negative value and setting ferror(), but we have been interpreting errno to handle signal restarting. As that is in doubt, reduce it to a sprintf and reuse our common interrupt handling write() that already returns -errno. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Katarzyna Dec <katarzyna.dec@intel.com> Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
2018-03-05lib/sysfs: s/kick_fbcon/bind_fbcon/Ville Syrjälä
Rename kick_fbcon() into bind_fbcon() so that it's not so confusing. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-03-05lib/sysfs: Fix fbcon unbind, againVille Syrjälä
Looks like unbinding the dummy con doesn't work on all machines. Instead we have to bind fbcon (which is what we used to do before commit d18fca7f6cf3 ("lib/sysfs: Fix fbcon rebind")). Since some machines need the bind and others need the unbind let's do both. The most obvious difference I observed between two machines that behave differently was the order in which the console drivers were listed in sysfs. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-12-15lib/igt_sysfs: Let igt_sysfs_read|write return -errnoMichal Wajdeczko
In some cases debugfs or sysfs may return errors that we want to check. Return -errno from helper functions to make asserts easier. v2: don't forget about EOF ret=0 (Chris) small re-write (Michal) Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-12-15lib/sysfs: Handle EINTR from vfprintf()Chris Wilson
Some write operations into sysfs may be slow and potentially interrupted by a signal. So handle EINTR by repeating the vfprintf(). A partial is reported back to the caller, as is any other error. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com
2017-10-04Fix compilation on some distrosAusmus, James
Some distros (such as Gentoo) are removing the include of sys/sysmacros.h from sys/types.h. Explicitly include sysmacros.h in files where we use the minor() and major() functions. Signed-off-by: James Ausmus <james.ausmus@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2017-09-29lib: Fix igt_sysfs_set_u32 return valueTvrtko Ursulin
Printf family functions return a number of bytes, not tokens, printed so the existing check (== 1) was wrong. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-09-08lib/sysfs: Fix fbcon rebindVille Syrjälä
"echo 1 > vtconN/bind" doesn't actually do anything. Looks like the only way to rebind fbcon is to unbind the current console. I suppose the failure to rebind might be a kernel bug, but I can't be bothered to decode the vt.c spaghetti so let's just try to handle this in igt. For simplicity let's assume the currently bound console is the dummy console and unbind that when we want to rebind fbcon. That works for me. With rebinding not working we can't really tell wich console is going to get bound anyway, so there's no way to make this code really robust, assuming we ever had more than these two console drivers involved. Additionally Daniel Vetter pointed out: "We select the dummy con in i915, to be able to kick out vgacon before we register fbdev. So should always be there." Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-09-06igt/pm_rpm: Use libc 'ftw' rather than opencoding our own filetree walkChris Wilson
By using ftw, we avoid the issue of having to handle directory recursion ourselves and can focus on the test of checking the reading a sysfs/debugfs does not break runtime suspend. In the process, disregard errors when opening the individual files as they may fail for other reasons. v2: Bracket the file open/close with the wait_for_suspended() tests. Whilst the fd is open, it may be keeping the device awake, e.g. i915_forcewake_user. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Tested-by: Jari Tahvanainen <jari.tahvanainen@intel.com>
2017-09-05Use PATH_MAX to fix some sprintf-into-short-buffers warnings.Eric Anholt
Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2017-06-21lib: Force global reset + uevents for hang detectorChris Wilson
The hang detector relies on a uevent for notification and aborting the test. As proposed, fine-grained resets may not produce a global uevent and so this hang detection becomes void. As we don't expect any hang, we can just reduce the reset to only a global + uevent and so maintain functionality, and switch back to fine-grained resets afterwards. Note that any test that requires testing fine-grained resets should ensure that they are enabled first as igt may leave the global parameters in an inconsistent state. v2: Restore fine-grained resets for explict igt_allow_hang() Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Michel Thierry <michel.thierry@intel.com> Reviewed-by: Michel Thierry <michel.thierry@intel.com>
2017-03-27lib/sysfs: Fix using O_WRONLY in igt_sysfs_read()!Chris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-03-25lib/sysfs: stop before calling write with zero bytesChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-02-23lib/sysfs: Explicit read/write lengthChris Wilson
Export a couple of routines to read/write an exact length, rather than a strring. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-12-22lib: Kick all fbconChris Wilson
i915 may not be the only, nor the first, vtcon framebuffer device - we need to check them all! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-12-01lib/igt_kmod: New library to support driver loading/unloading and additional ↵Marius Vlad
helpers. lib/igt_aux: Added igt_pkill and igt_lsof helper. lib/igt_kmod: Added load/unload kmod helpers. v7: - document the case where leaving stray fd from drm_open_driver() might fail reloading the driver. - list also current opened files from /dev/dri in case we could not unload the driver. - convert igt_info to igt_warn (Chris Wilson) - added KMOD_|PROCPS CFLAGS (Chris Wilson) v6: - include latest modifications from tests/drv_module_reload: display all loaded modules and list information about opened files by processes (Petri Latvala) v5: - added igt_i915_driver_{load/unload}. - added kick_snd_hda_intel() to match current tests/drv_module_reload_basic and integrated into igt_i915_driver_load/unload. - added gtk-doc section for lib/igt_kmod v4: - decided to split libkmod helpers into their own file as there's another user lib/igt_gvt or tests/gvt_basic. - fixed some gtk-doc documentation. v3: - return -errno (igt_pkill()) in case of failure (Cris Wilson) - return bool for igt_kmod_is_loaded(), replaced strncasecmp with strncmp (Chris Wilson) v2: - Renamed libkmod helpers (Chris Wilson) - Removed SIGTERM/SIGKILL case where we repeatedly tried to terminate the process: just call kill(2) once (Chris Wilson) - Removed redundant check in igt_kmod_unload(), igt_module_in_use() (Chris Wilson) - Pass flags to igt_kmod_unload() from the caller (Chris Wilson) - Removed useless function igt_kill() which acts just as kill(2) (Chris Wilson) Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
2016-10-19igt: Check the physical swizzle statusChris Wilson
The kernel tries to hide L-shaped memory with asymmetric swizzling from userspace by reporting lies through the get-tiling interface. Check for these lies by comparing the reported swizzle with the actual swizzle, and only run swizzling tests where we know the underlying physical swizzling. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-10-14lib/sysfs: Use a fallback for builtin modulesChris Wilson
A builtin modules does not have a sysfs/device/module symlink, so be creative. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-08-04igt/gem_mocs_settings: adding RC6 testsPeter Antoine
This change adds a RC6 test for the MOCS. The MOCS registers are loaded and saved as part of the RC6 cycle but not all the registers are saved/restored. This tests that those registers are correctly restored. Signed-off-by: Peter Antoine <peter.antoine@intel.com>
2016-07-27lib: Update docs for igt_sysfs.cDaniel Vetter
Need to actually put it into the master .xml. Also rename the parameter names in the source with the ones in the header files to avoid confusion. gtkdoc requires that the names in the comment matches with the header. Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-07-22lib/sysfs: Provide scanf/printf wrappersChris Wilson
In order to avoid having to build and parse whole strings, use the FILE stream interface. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-07-22lib/sysfs: Provide a convenience function for reading a boolChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-07-22igt/gem_exec_nop: Display submission mechanismChris Wilson
Useful for confirmation when testing. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-06-20igt/vgem_basic: Exercise opening sysfs/debugfsChris Wilson
For fun, debugfs/.../names currently explodes, so lets capture that and make sure that basic access to debugfs does no harm. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-05-31lib: Add simple sysfs accessorsChris Wilson
igt_sysfs_set() for setting an attribute via sysfs, igt_sysfs_get() for reading. v2: Lots of little bugs in igt_sysfs_get() v3: Pass device to open, stop assuming Intel rules. v4: Test opening and reading! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>