From patchwork Fri Nov 11 15:58:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13040579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45649C433FE for ; Fri, 11 Nov 2022 15:59:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 34A4B10E888; Fri, 11 Nov 2022 15:59:19 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id D06B510E871; Fri, 11 Nov 2022 15:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668182350; x=1699718350; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SFGLmHc7XVOfYnYhdlVGwKT2+NH6RYdNaTqCCMoIymk=; b=YVDFTaIc2Uyngqz8m+9sIUMgz/cgMPmqcEH8QyKEizrPGgeEkhMQYX4Y yebcqDXIKBCpABBN+s22khskYlEMdqzCd3MECzwlup7yDUnj0uy14Igmx nusxOW2iFMYjPSbtHzvgQ0qL2MsRnE9bqOJ1QB6w7A9hGqAuPRU8NYEnI s19Sx3ESTzVIs2LI4GnVHKWobsmuN48tA8VoawuHIJUFv21d7dSTVTvYg e3+6/l25UTSGdmXfcP+YHkXOm94ahqX+Ib6enuJcBYx1ZLxfDrnJ/dn6S aLsaUI5aDUbCM0vU/GeOzq007T2V9wJl0/37nGlu/Xv7efy66lO9ZwRCr A==; X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="375883653" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="375883653" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 07:59:10 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="706577572" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="706577572" Received: from eharkin-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.208.27]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 07:59:08 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH i-g-t 4/8] libdrmclient: Support multiple DRM cards Date: Fri, 11 Nov 2022 15:58:40 +0000 Message-Id: <20221111155844.3290531-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111155844.3290531-1-tvrtko.ursulin@linux.intel.com> References: <20221111155844.3290531-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin Require DRM minor match during client lookup. Signed-off-by: Tvrtko Ursulin --- lib/igt_drm_clients.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c index c23a3fae9793..e11c8b18188f 100644 --- a/lib/igt_drm_clients.c +++ b/lib/igt_drm_clients.c @@ -49,7 +49,7 @@ struct igt_drm_clients *igt_drm_clients_init(void *private_data) static struct igt_drm_client * igt_drm_clients_find(struct igt_drm_clients *clients, enum igt_drm_client_status status, - unsigned int id) + unsigned int drm_minor, unsigned int id) { unsigned int start, num; struct igt_drm_client *c; @@ -61,7 +61,8 @@ igt_drm_clients_find(struct igt_drm_clients *clients, if (status != c->status) continue; - if (status == IGT_DRM_CLIENT_FREE || c->id == id) + if (status == IGT_DRM_CLIENT_FREE || + (drm_minor == c->drm_minor && c->id == id)) return c; } @@ -119,9 +120,10 @@ igt_drm_client_add(struct igt_drm_clients *clients, { struct igt_drm_client *c; - assert(!igt_drm_clients_find(clients, IGT_DRM_CLIENT_ALIVE, info->id)); + assert(!igt_drm_clients_find(clients, IGT_DRM_CLIENT_ALIVE, + drm_minor, info->id)); - c = igt_drm_clients_find(clients, IGT_DRM_CLIENT_FREE, 0); + c = igt_drm_clients_find(clients, IGT_DRM_CLIENT_FREE, 0, 0); if (!c) { unsigned int idx = clients->num_clients; @@ -411,11 +413,11 @@ igt_drm_clients_scan(struct igt_drm_clients *clients, continue; if (igt_drm_clients_find(clients, IGT_DRM_CLIENT_ALIVE, - info.id)) + minor, info.id)) continue; /* Skip duplicate fds. */ c = igt_drm_clients_find(clients, IGT_DRM_CLIENT_PROBE, - info.id); + minor, info.id); if (!c) igt_drm_client_add(clients, &info, client_pid, client_name, minor);