diff mbox series

[RFC,i-g-t] lib/igt_kms: Set capabilities before get resource

Message ID 20190306224938.opisj72oa2kxxrwi@smtp.gmail.com (mailing list archive)
State New, archived
Headers show
Series [RFC,i-g-t] lib/igt_kms: Set capabilities before get resource | expand

Commit Message

Rodrigo Siqueira March 6, 2019, 10:49 p.m. UTC
Hi, I was working on adding the writeback support to VKMS; as a result,
I was using the Liviu’s patchset to validate my implementation [1].
However, I consistently failed to pass the requirements in
igt_display_require(); more specifically, I couldn't pass this test:

 igt_skip("No KMS driver or no outputs, pipes: %d, outputs: %d\n",
               display->n_pipes, display->n_outputs);

Next, I made a simple code that does the following three steps:

 1. Open the device
 2. Collect the resource information with drmModeGetResources()
 3. Set writeback capability via drmSetClientCap()
 4. Print the total of connectors

I noticed that I could not get any connector as well; after some time
debugging the issue and thanks to Anholt’s help in the dri-channel I
learned that I had to use drmSetClientCap() before
drmModeGetResources(). After move all drmSetClientCap() above
drmModeGetResources(), my simple coded displayed the connector
information. I did the same thing within igt_display_require(), and this
test started to pass for me (I did it, in the Liviu’s patch).

In this sense, I checked the igt_display_require() code in the master
branch; and again, I noticed that capabilities are set after getting the
resource information. Is that correct? Is it ok to call
drmModeGetResources() before drmSetClientCap() in this case?

P.s.: I sent it as a RFC because I’m not 100% sure about the change and
the impacts on the tests. If it make sense, I can make a real patch.

1. https://patchwork.freedesktop.org/series/39229/

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
---
 lib/igt_kms.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 7ebab4ca..2de9ac41 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1886,6 +1886,10 @@  void igt_display_require(igt_display_t *display, int drm_fd)
 
 	display->drm_fd = drm_fd;
 
+	drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+	if (drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0)
+		display->is_atomic = 1;
+
 	resources = drmModeGetResources(display->drm_fd);
 	if (!resources)
 		goto out;
@@ -1898,10 +1902,6 @@  void igt_display_require(igt_display_t *display, int drm_fd)
 	display->pipes = calloc(sizeof(igt_pipe_t), display->n_pipes);
 	igt_assert_f(display->pipes, "Failed to allocate memory for %d pipes\n", display->n_pipes);
 
-	drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
-	if (drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0)
-		display->is_atomic = 1;
-
 	plane_resources = drmModeGetPlaneResources(display->drm_fd);
 	igt_assert(plane_resources);