summaryrefslogtreecommitdiff
path: root/lib/igt_device.c
AgeCommit message (Collapse)Author
2022-05-18lib/igt_device: Get gfx PCI card root portAnshuman Gupta
Utility library function to get the Gfx Card PCI topology root port pci device using libpaciaccess. root port will be used to get the real ACPI D state. Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
2022-02-23lib/igt_device: Add support for accessing unbound VF PCI devicesJanusz Krzysztofik
The library provides igt_device_get_pci_device() function that allows to get access to a PCI device from an open DRM device file descriptor. It can be used on VF devices as long as a DRM driver is bound to them. However, SR-IOV tests may want to exercise VF PCI devices created by a PF without binding any DRM driver to them. While keeping the API of igt_device_get_pci_device() untouched, extend API of its underlying helper __igt_device_get_pci_device() with an extra argument for specifying VF ID of the requested PCI device and expose this function as public. v2: refresh on top of IGT libpciaccess wrappers and drop previously added but no longer needed error unwind path and recommendations for users on calling pci_system_cleanup() after use (Chris), - fix incorrect validation of snprintf() result and misaligned formatting of igt_warn_on_f() arguments. Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> Reviewed-by: Chris Wilson <chris.p.wilson@intel.com> [jkrzyszt: DOC fix and wording improvement]
2022-02-23Revert "lib/igt_device: Add support for accessing unbound VF PCI devices"Janusz Krzysztofik
This reverts commit c220c60bb4679e2e9cdf8accbf90f888e6819456. Incorrect version of the patch has been pushed, sorry. Signed-of-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
2022-02-23lib/igt_device: Add support for accessing unbound VF PCI devicesJanusz Krzysztofik
The library provides igt_device_get_pci_device() function that allows to get access to a PCI device from an open DRM device file descriptor. It can be used on VF devices as long as a DRM driver is bound to them. However, SR-IOV tests may want to exercise VF PCI devices created by a PF without binding any DRM driver to them. While keeping the API of igt_device_get_pci_device() untouched, extend API of its underlying helper __igt_device_get_pci_device() with an extra argument for specifying VF ID of the requested PCI device and expose this function as public. While being at it, fix pci_system_cleanup() not called on errors and instruct users to call it for symmetry when the obtained struct pci_device is no longer needed. Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
2022-02-22lib: Use safe wrappers around libpciaccess initialization functionsJanusz Krzysztofik
Multiple calls to igt functions using pci_system_init() provided by libpciaccess result in memory leaking if not followed by its counterpart pci_system_cleanup() before next use. On the other hand, calling pci_system_cleanup() can affect other users which still depend on global data initialized by pci_system_init(). Introduce safe IGT wrappers around those libpciaccess functions and use those wrappers in IGT library and tests. Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> [jkrzyszt: shorten excessive long name of hidden variable (Chris)] Reviewed-by: Chris Wilson <chris.p.wilson@intel.com>
2019-08-29lib/igt_device: add igt_device_get_pci_addr by fdMichał Winiarski
This function get us pci address based by fd. It allows us to make things a little bit more generic. Also, we now require fd rather than doing guesswork when it comes to pci address. v4: close sysfs fd Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Signed-off-by: Daniel Mrzyglod <daniel.t.mrzyglod@intel.com>
2019-05-15lib: Show other clients when SETMASTER failsChris Wilson
Currently we only show the clients at DEBUG level which is not automatically shown for a SKIP. However, failing to SETMASTER is more often a mistake and we do want to see the other clients. The choice is at what level to show them? If we want to avoid having extra WARNs in CI, we should keep them to INFO, but on the other hand failing to acquire SETMASTER is tantamount to failure, so WARN. References: https://bugs.freedesktop.org/show_bug.cgi?id=110682 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Martin Peres <martin.peres@free.fr> Acked-by: Martin Peres <martin.peres@free.fr>
2019-03-29Revert "lib/igt_device: Move intel_get_pci_device under igt_device"Ville Syrjälä
One significant usecase for intel_reg/etc. is to be able to examine the hardware state *before* loading the driver. If the tool forces the driver to load we've totally lost that capability. This reverts commit 8ae86621d6fff60b6e20c6b0f9b336785c935b0f. Cc: Michał Winiarski <michal.winiarski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Acked-by: Michał Winiarski <michal.winiarski@intel.com>
2019-03-20lib/igt_device: Move intel_get_pci_device under igt_deviceMichał Winiarski
It allows us to make things a little bit more generic. Also, we now require fd rather than doing guesswork when it comes to pci address. v2: Use readlinkat rather than string concat, move stuff around, provide a version that does not assert. (Chris) v3: Print addr on failure, avoid assignment in conditionals. (Chris) Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> 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>
2018-05-15lib/igt_device: Add information why cannot drop drm masterKatarzyna Dec
Let's add additional information to igt_device_drop_master in case we try to run tests with e.g. x11 enabled. v2: Changed comment and added listing clients. v3: Changed igt_require to igt_assert. v4: Added checking if we are master already. References: https://bugs.freedesktop.org/show_bug.cgi?id=105990 Signed-off-by: Katarzyna Dec <katarzyna.dec@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-12-08lib: Print other clients when DRM_SET_MASTER failsChris Wilson
It looks like there are some rogue processes running in CI that prevent DRM_MASTER from being obtained. Dump the list of clients on failure to make it more obvious what is being left behind. v2: Fix up gtkdocs, meson build References: https://bugs.freedesktop.org/show_bug.cgi?id=104157 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>