From patchwork Tue May 11 16:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12251541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A83EDC43461 for ; Tue, 11 May 2021 16:51:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4B835613C6 for ; Tue, 11 May 2021 16:51:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B835613C6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF4F66EA98; Tue, 11 May 2021 16:51:58 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 674926EA98; Tue, 11 May 2021 16:51:56 +0000 (UTC) IronPort-SDR: hpnOgNCPB6KpKEk3Dadg4KeanyaYRx9MZ76r1ZNjX6lUN9CUWVWGMwSRCRQx8kd6m6FH8F0ZHs 7Gi1Kpm6na9g== X-IronPort-AV: E=McAfee;i="6200,9189,9981"; a="199544273" X-IronPort-AV: E=Sophos;i="5.82,291,1613462400"; d="scan'208";a="199544273" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 09:51:56 -0700 IronPort-SDR: NewfVhNpwjet4LJhFHSe3egsQYPgfeI/+NSwKie4iHszaX2gnOjK9GWnkM8mZCjhnZoib0dIxw P5TBSWo/ZUAw== X-IronPort-AV: E=Sophos;i="5.82,291,1613462400"; d="scan'208";a="537104875" Received: from rdavies-mobl.ger.corp.intel.com (HELO mwauld-desk1.ger.corp.intel.com) ([10.252.2.133]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 09:51:53 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Tue, 11 May 2021 17:51:16 +0100 Message-Id: <20210511165117.428062-12-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210511165117.428062-1-matthew.auld@intel.com> References: <20210511165117.428062-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 11/12] lib/i915/intel_memory_region: Add new macros and support for igt_collection X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.hellstrom@linux.intel.com, Janusz Krzysztofik , intel-gfx@lists.freedesktop.org, Dominik Grzegorzek Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Zbigniew Kempczyński As with new memory region era we will have to cover different sets of memory regions inside the tests this patch adds support for generating subtest names according to passed memory region collection. Signed-off-by: Zbigniew Kempczyński Signed-off-by: José Roberto de Souza Cc: Vinay Belgaumkar Cc: Janusz Krzysztofik Cc: Ashutosh Dixit Cc: Dominik Grzegorzek --- lib/i915/intel_memory_region.c | 26 ++++++++++++++++++-------- lib/i915/intel_memory_region.h | 15 ++++++++++++++- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c index 91d3ef18..983ac4df 100644 --- a/lib/i915/intel_memory_region.c +++ b/lib/i915/intel_memory_region.c @@ -80,9 +80,12 @@ const char *get_memory_region_name(uint32_t region) { uint16_t class = MEMORY_TYPE_FROM_REGION(region); - if (class == I915_MEMORY_CLASS_SYSTEM) + switch (class) { + case I915_MEMORY_CLASS_SYSTEM: return "smem"; - + case I915_MEMORY_CLASS_DEVICE: + return "lmem"; + } igt_assert_f(false, "Unknown memory region"); } @@ -169,11 +172,13 @@ int __gem_create_in_memory_region_list(int fd, uint32_t *handle, uint64_t size, struct drm_i915_gem_memory_class_instance *mem_regions, int num_regions) { - /* a temporary solution, to be removed when these arguments will be used */ - (void) mem_regions; - (void) num_regions; + struct drm_i915_gem_create_ext_memory_regions ext_regions = { + .base = { .name = I915_GEM_CREATE_EXT_MEMORY_REGIONS }, + .num_regions = num_regions, + .regions = to_user_pointer(mem_regions), + }; - return __gem_create(fd, &size, handle); + return __gem_create_ext(fd, &size, handle, &ext_regions.base); } /* gem_create_in_memory_region_list: @@ -264,8 +269,13 @@ char *memregion_dynamic_subtest_name(struct igt_collection *set) int r; region = data->value; - - r = snprintf(p, len, "%s-", get_memory_region_name(region)); + if (IS_DEVICE_MEMORY_REGION(region)) + r = snprintf(p, len, "%s%d-", + get_memory_region_name(region), + MEMORY_INSTANCE_FROM_REGION(region)); + else + r = snprintf(p, len, "%s-", + get_memory_region_name(region)); igt_assert(r > 0); p += r; diff --git a/lib/i915/intel_memory_region.h b/lib/i915/intel_memory_region.h index 3e53d8de..e9d1d66d 100644 --- a/lib/i915/intel_memory_region.h +++ b/lib/i915/intel_memory_region.h @@ -26,6 +26,9 @@ #define INTEL_MEMORY_REGION_H #define I915_SYSTEM_MEMORY I915_MEMORY_CLASS_SYSTEM +#define I915_DEVICE_MEMORY I915_MEMORY_CLASS_DEVICE +#define I915_STOLEN_SYSTEM_MEMORY I915_MEMORY_CLASS_STOLEN_SYSTEM +#define I915_STOLEN_DEVICE_MEMORY I915_MEMORY_CLASS_STOLEN_DEVICE #define INTEL_MEMORY_REGION_ID(type, instance) ((type) << 16u | (instance)) #define MEMORY_TYPE_FROM_REGION(r) ((r) >> 16u) @@ -34,10 +37,19 @@ #define IS_MEMORY_REGION_TYPE(region, type) \ (MEMORY_TYPE_FROM_REGION(region) == type) +#define IS_DEVICE_MEMORY_REGION(region) \ + IS_MEMORY_REGION_TYPE(region, I915_MEMORY_CLASS_DEVICE) #define IS_SYSTEM_MEMORY_REGION(region) \ IS_MEMORY_REGION_TYPE(region, I915_MEMORY_CLASS_SYSTEM) +#define IS_STOLEN_MEMORY_REGION(region) \ + (IS_MEMORY_REGION_TYPE(region, I915_MEMORY_CLASS_STOLEN_SYSTEM) || \ + IS_MEMORY_REGION_TYPE(region, I915_MEMORY_CLASS_STOLEN_DEVICE)) + #define REGION_SMEM INTEL_MEMORY_REGION_ID(I915_MEMORY_CLASS_SYSTEM, 0) +#define REGION_LMEM(n) INTEL_MEMORY_REGION_ID(I915_MEMORY_CLASS_DEVICE, (n)) +#define REGION_STLN_SMEM(n) INTEL_MEMORY_REGION_ID(I915_MEMORY_CLASS_STOLEN_SYSTEM, (n)) +#define REGION_STLN_LMEM(n) INTEL_MEMORY_REGION_ID(I915_MEMORY_CLASS_STOLEN_DEVICE, (n)) bool gem_has_query_support(int fd); @@ -89,7 +101,8 @@ __get_memory_region_set(struct drm_i915_query_memory_regions *regions, /* * Helper macro to create igt_collection which contains all memory regions - * which matches mem_region_types array. + * which matches mem_region_types array. Useful to filter out stolen memory + * from accessible memory regions. */ #define get_memory_region_set(regions, mem_region_types...) ({ \ unsigned int arr__[] = { mem_region_types }; \