From patchwork Tue Oct 4 15:25:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12998531 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 8314EC4332F for ; Tue, 4 Oct 2022 15:26:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C5D310E70F; Tue, 4 Oct 2022 15:26:20 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59FAA10E70F; Tue, 4 Oct 2022 15:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664897177; x=1696433177; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Clf9GMQsKEzztWw7j/XK8tJNYHv0oe7Vqj7K/36eT2Y=; b=T/XRMGBBs8VtMQ+F2APowOPSw+iy2E6CptZLpXgk0WlzuxPTyO5GiIgC sB434YNKceADxDm+3EmnFJn7yrQWwv26yjrlv6/RLt8yrC8doBQDM46VI EaYA8ZPo5nAuNEZCZAoreme9sBShT7PytQAcRUYIlKHVf/z2i4JvT8ZFE u1EHykZtLVmsG8wGdQNTfMFeqcFEBhZ0AWPNSWhzbo2mIDEptyCm03emi 5gFU5YQpbccFQTt5x3KceAmef9mKhORy0zekF4kOGAuz77ScBkIOgxhMj tdO9qclxlL/QL3AXnhHlpFmYRYBGKaNR7h4YiuJfHA8CLOZkkm4RB/deV w==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="301659395" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="301659395" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:16 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="601655859" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="601655859" Received: from ngverso-mobl2.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.252.7.149]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:14 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Tue, 4 Oct 2022 16:25:45 +0100 Message-Id: <20221004152549.436801-1-matthew.auld@intel.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 1/5] i915_drm.h sync 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: intel-gfx@lists.freedesktop.org, Andrzej Hajda , Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Get the small-bar related stuff at: 525e93f6317a ("drm/i915/uapi: add NEEDS_CPU_ACCESS hint"), and drop the local related bits. Signed-off-by: Matthew Auld Cc: Andrzej Hajda Cc: Nirmoy Das Reviewed-by: Nirmoy Das --- include/drm-uapi/i915_drm.h | 182 +++++++++++++++++++++++++-------- lib/i915/i915_drm_local.h | 21 ---- lib/i915/intel_memory_region.c | 3 +- tests/i915/gem_create.c | 5 - tests/i915/gem_exec_capture.c | 5 - tests/i915/i915_query.c | 6 -- 6 files changed, 141 insertions(+), 81 deletions(-) diff --git a/include/drm-uapi/i915_drm.h b/include/drm-uapi/i915_drm.h index b4efc96c..ae9558b3 100644 --- a/include/drm-uapi/i915_drm.h +++ b/include/drm-uapi/i915_drm.h @@ -3207,36 +3207,6 @@ struct drm_i915_gem_memory_class_instance { * struct drm_i915_memory_region_info - Describes one region as known to the * driver. * - * Note that we reserve some stuff here for potential future work. As an example - * we might want expose the capabilities for a given region, which could include - * things like if the region is CPU mappable/accessible, what are the supported - * mapping types etc. - * - * Note that to extend struct drm_i915_memory_region_info and struct - * drm_i915_query_memory_regions in the future the plan is to do the following: - * - * .. code-block:: C - * - * struct drm_i915_memory_region_info { - * struct drm_i915_gem_memory_class_instance region; - * union { - * __u32 rsvd0; - * __u32 new_thing1; - * }; - * ... - * union { - * __u64 rsvd1[8]; - * struct { - * __u64 new_thing2; - * __u64 new_thing3; - * ... - * }; - * }; - * }; - * - * With this things should remain source compatible between versions for - * userspace, even as we add new fields. - * * Note this is using both struct drm_i915_query_item and struct drm_i915_query. * For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS * at &drm_i915_query_item.query_id. @@ -3248,14 +3218,81 @@ struct drm_i915_memory_region_info { /** @rsvd0: MBZ */ __u32 rsvd0; - /** @probed_size: Memory probed by the driver (-1 = unknown) */ + /** + * @probed_size: Memory probed by the driver + * + * Note that it should not be possible to ever encounter a zero value + * here, also note that no current region type will ever return -1 here. + * Although for future region types, this might be a possibility. The + * same applies to the other size fields. + */ __u64 probed_size; - /** @unallocated_size: Estimate of memory remaining (-1 = unknown) */ + /** + * @unallocated_size: Estimate of memory remaining + * + * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable accounting. + * Without this (or if this is an older kernel) the value here will + * always equal the @probed_size. Note this is only currently tracked + * for I915_MEMORY_CLASS_DEVICE regions (for other types the value here + * will always equal the @probed_size). + */ __u64 unallocated_size; - /** @rsvd1: MBZ */ - __u64 rsvd1[8]; + union { + /** @rsvd1: MBZ */ + __u64 rsvd1[8]; + struct { + /** + * @probed_cpu_visible_size: Memory probed by the driver + * that is CPU accessible. + * + * This will be always be <= @probed_size, and the + * remainder (if there is any) will not be CPU + * accessible. + * + * On systems without small BAR, the @probed_size will + * always equal the @probed_cpu_visible_size, since all + * of it will be CPU accessible. + * + * Note this is only tracked for + * I915_MEMORY_CLASS_DEVICE regions (for other types the + * value here will always equal the @probed_size). + * + * Note that if the value returned here is zero, then + * this must be an old kernel which lacks the relevant + * small-bar uAPI support (including + * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS), but on + * such systems we should never actually end up with a + * small BAR configuration, assuming we are able to load + * the kernel module. Hence it should be safe to treat + * this the same as when @probed_cpu_visible_size == + * @probed_size. + */ + __u64 probed_cpu_visible_size; + + /** + * @unallocated_cpu_visible_size: Estimate of CPU + * visible memory remaining. + * + * Note this is only tracked for + * I915_MEMORY_CLASS_DEVICE regions (for other types the + * value here will always equal the + * @probed_cpu_visible_size). + * + * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable + * accounting. Without this the value here will always + * equal the @probed_cpu_visible_size. Note this is only + * currently tracked for I915_MEMORY_CLASS_DEVICE + * regions (for other types the value here will also + * always equal the @probed_cpu_visible_size). + * + * If this is an older kernel the value here will be + * zero, see also @probed_cpu_visible_size. + */ + __u64 unallocated_cpu_visible_size; + }; + }; }; /** @@ -3329,11 +3366,11 @@ struct drm_i915_query_memory_regions { * struct drm_i915_gem_create_ext - Existing gem_create behaviour, with added * extension support using struct i915_user_extension. * - * Note that in the future we want to have our buffer flags here, at least for - * the stuff that is immutable. Previously we would have two ioctls, one to - * create the object with gem_create, and another to apply various parameters, - * however this creates some ambiguity for the params which are considered - * immutable. Also in general we're phasing out the various SET/GET ioctls. + * Note that new buffer flags should be added here, at least for the stuff that + * is immutable. Previously we would have two ioctls, one to create the object + * with gem_create, and another to apply various parameters, however this + * creates some ambiguity for the params which are considered immutable. Also in + * general we're phasing out the various SET/GET ioctls. */ struct drm_i915_gem_create_ext { /** @@ -3341,7 +3378,6 @@ struct drm_i915_gem_create_ext { * * The (page-aligned) allocated size for the object will be returned. * - * * DG2 64K min page size implications: * * On discrete platforms, starting from DG2, we have to contend with GTT @@ -3353,7 +3389,9 @@ struct drm_i915_gem_create_ext { * * Note that the returned size here will always reflect any required * rounding up done by the kernel, i.e 4K will now become 64K on devices - * such as DG2. + * such as DG2. The kernel will always select the largest minimum + * page-size for the set of possible placements as the value to use when + * rounding up the @size. * * Special DG2 GTT address alignment requirement: * @@ -3377,14 +3415,58 @@ struct drm_i915_gem_create_ext { * is deemed to be a good compromise. */ __u64 size; + /** * @handle: Returned handle for the object. * * Object handles are nonzero. */ __u32 handle; - /** @flags: MBZ */ + + /** + * @flags: Optional flags. + * + * Supported values: + * + * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS - Signal to the kernel that + * the object will need to be accessed via the CPU. + * + * Only valid when placing objects in I915_MEMORY_CLASS_DEVICE, and only + * strictly required on configurations where some subset of the device + * memory is directly visible/mappable through the CPU (which we also + * call small BAR), like on some DG2+ systems. Note that this is quite + * undesirable, but due to various factors like the client CPU, BIOS etc + * it's something we can expect to see in the wild. See + * &drm_i915_memory_region_info.probed_cpu_visible_size for how to + * determine if this system applies. + * + * Note that one of the placements MUST be I915_MEMORY_CLASS_SYSTEM, to + * ensure the kernel can always spill the allocation to system memory, + * if the object can't be allocated in the mappable part of + * I915_MEMORY_CLASS_DEVICE. + * + * Also note that since the kernel only supports flat-CCS on objects + * that can *only* be placed in I915_MEMORY_CLASS_DEVICE, we therefore + * don't support I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS together with + * flat-CCS. + * + * Without this hint, the kernel will assume that non-mappable + * I915_MEMORY_CLASS_DEVICE is preferred for this object. Note that the + * kernel can still migrate the object to the mappable part, as a last + * resort, if userspace ever CPU faults this object, but this might be + * expensive, and so ideally should be avoided. + * + * On older kernels which lack the relevant small-bar uAPI support (see + * also &drm_i915_memory_region_info.probed_cpu_visible_size), + * usage of the flag will result in an error, but it should NEVER be + * possible to end up with a small BAR configuration, assuming we can + * also successfully load the i915 kernel module. In such cases the + * entire I915_MEMORY_CLASS_DEVICE region will be CPU accessible, and as + * such there are zero restrictions on where the object can be placed. + */ +#define I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS (1 << 0) __u32 flags; + /** * @extensions: The chain of extensions to apply to this object. * @@ -3443,6 +3525,22 @@ struct drm_i915_gem_create_ext { * At which point we get the object handle in &drm_i915_gem_create_ext.handle, * along with the final object size in &drm_i915_gem_create_ext.size, which * should account for any rounding up, if required. + * + * Note that userspace has no means of knowing the current backing region + * for objects where @num_regions is larger than one. The kernel will only + * ensure that the priority order of the @regions array is honoured, either + * when initially placing the object, or when moving memory around due to + * memory pressure + * + * On Flat-CCS capable HW, compression is supported for the objects residing + * in I915_MEMORY_CLASS_DEVICE. When such objects (compressed) have other + * memory class in @regions and migrated (by i915, due to memory + * constraints) to the non I915_MEMORY_CLASS_DEVICE region, then i915 needs to + * decompress the content. But i915 doesn't have the required information to + * decompress the userspace compressed objects. + * + * So i915 supports Flat-CCS, on the objects which can reside only on + * I915_MEMORY_CLASS_DEVICE regions. */ struct drm_i915_gem_create_ext_memory_regions { /** @base: Extension link. See struct i915_user_extension. */ diff --git a/lib/i915/i915_drm_local.h b/lib/i915/i915_drm_local.h index ac35abf6..9a2273c4 100644 --- a/lib/i915/i915_drm_local.h +++ b/lib/i915/i915_drm_local.h @@ -23,27 +23,6 @@ extern "C" { #define DRM_I915_QUERY_GEOMETRY_SUBSLICES 6 -/* - * Signal to the kernel that the object will need to be accessed via - * the CPU. - * - * Only valid when placing objects in I915_MEMORY_CLASS_DEVICE, and only - * strictly required on platforms where only some of the device memory - * is directly visible or mappable through the CPU, like on DG2+. - * - * One of the placements MUST also be I915_MEMORY_CLASS_SYSTEM, to - * ensure we can always spill the allocation to system memory, if we - * can't place the object in the mappable part of - * I915_MEMORY_CLASS_DEVICE. - * - * Without this hint, the kernel will assume that non-mappable - * I915_MEMORY_CLASS_DEVICE is preferred for this object. Note that the - * kernel can still migrate the object to the mappable part, as a last - * resort, if userspace ever CPU faults this object, but this might be - * expensive, and so ideally should be avoided. - */ -#define I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS (1 << 0) - #if defined(__cplusplus) } #endif diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c index d80cb3a0..075ba0ce 100644 --- a/lib/i915/intel_memory_region.c +++ b/lib/i915/intel_memory_region.c @@ -942,8 +942,7 @@ struct gem_memory_region *__gem_get_memory_regions(int i915) r->ci = info->regions[i].region; r->size = info->regions[i].probed_size; - /* XXX: replace with probed_cpu_visible_size */ - r->cpu_size = info->regions[i].rsvd1[0]; + r->cpu_size = info->regions[i].probed_cpu_visible_size; if (r->size == -1ull) r->size = igt_get_avail_ram_mb() << 20; diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c index c39390f3..becdc715 100644 --- a/tests/i915/gem_create.c +++ b/tests/i915/gem_create.c @@ -724,11 +724,6 @@ static void trap_sigbus(uint32_t *ptr) signal(SIGBUS, old_sigbus); } -/** - * XXX: Remove this once we can safely sync the uapi header with the kernel. - * Should be source compatible either way though. - */ -#define probed_cpu_visible_size rsvd1[0] static void create_ext_cpu_access_big(int fd) { struct drm_i915_query_memory_regions *regions; diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c index 6950b2d2..2db58266 100644 --- a/tests/i915/gem_exec_capture.c +++ b/tests/i915/gem_exec_capture.c @@ -578,11 +578,6 @@ __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx, return offsets; } -/* - * FIXME: remove once the kernel changes have landed and everything has settled. - * The change here is non-backwards compatible, and we don't want to upset CI. -*/ -#define probed_cpu_visible_size rsvd1[0] static bool kernel_supports_probed_size(int fd) { struct drm_i915_query_memory_regions *regions; diff --git a/tests/i915/i915_query.c b/tests/i915/i915_query.c index 8befd48b..2744421c 100644 --- a/tests/i915/i915_query.c +++ b/tests/i915/i915_query.c @@ -516,12 +516,6 @@ static bool query_regions_supported(int fd) return __i915_query_items(fd, &item, 1) == 0 && item.length > 0; } -/** - * XXX: Remove these once we can safely sync the uapi header with the kernel. - * Should be source compatible either way though. - */ -#define probed_cpu_visible_size rsvd1[0] -#define unallocated_cpu_visible_size rsvd1[1] static bool query_regions_unallocated_supported(int fd) { struct drm_i915_query_memory_regions *regions; From patchwork Tue Oct 4 15:25:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12998532 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 9AF13C433FE for ; Tue, 4 Oct 2022 15:26:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDB3810E722; Tue, 4 Oct 2022 15:26:20 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 56F5010E70F; Tue, 4 Oct 2022 15:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664897178; x=1696433178; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VI8xS+lNVNZznkWoVDxyvrxLVwdAmmGkz+rpfCtYR24=; b=Fx2/49tSrMcZu5DPJhQogXkN2cHsAhvJCBOIb3jXuqX2lDd5Mji+BmRd Avy+RwyAY9lZuWF22YudGIoXkwHnB7IjFPh441DHMYYXlnLfu+J6SPEyW CnYDxQVp3xZ0ciGNALnsd1c76a1uSWYdJr2FVoc5nlZ0TsOhgeIus139C qLqmsYxnn8f1ZTLusFnfkyWYjW6Tku8LqF3RHxqZzJFn5OKWloQxfdc2a t0rvD24rYdAVCw2vXK4qS3v0EOr1VTgeqeGZkTmfHE44YnSo64ufCQ/ix UOz4Vx/bCBZRwmSLCZDBaDh+K23eG6W7FX0tZM9Um3k88rV22UswR75/M Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="301659401" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="301659401" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:17 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="601655869" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="601655869" Received: from ngverso-mobl2.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.252.7.149]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:16 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Tue, 4 Oct 2022 16:25:46 +0100 Message-Id: <20221004152549.436801-2-matthew.auld@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221004152549.436801-1-matthew.auld@intel.com> References: <20221004152549.436801-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 2/5] tests/i915/query: fix igt_assert_eq_u32 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: intel-gfx@lists.freedesktop.org, Andrzej Hajda , Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" rsvd1 is u64 here. Signed-off-by: Matthew Auld Cc: Andrzej Hajda Cc: Nirmoy Das Reviewed-by: Nirmoy Das --- tests/i915/i915_query.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/i915/i915_query.c b/tests/i915/i915_query.c index 2744421c..b92d7593 100644 --- a/tests/i915/i915_query.c +++ b/tests/i915/i915_query.c @@ -588,7 +588,7 @@ static void test_query_regions_garbage_items(int fd) * rsvd1[1] : unallocated_cpu_visible_size */ for (j = 2; j < ARRAY_SIZE(info.rsvd1); j++) - igt_assert_eq_u32(info.rsvd1[j], 0); + igt_assert_eq_u64(info.rsvd1[j], 0); } /* Bogus; kernel is meant to set this */ From patchwork Tue Oct 4 15:25:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12998533 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 B8160C433FE for ; Tue, 4 Oct 2022 15:26:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BBF010E710; Tue, 4 Oct 2022 15:26:26 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9859210E70F; Tue, 4 Oct 2022 15:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664897179; x=1696433179; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2TDM69JJdlqzLx6tObLDhHFFpWOmYjLjnU2bKSTHhzM=; b=dPO3nxsVtOSD0lxQFawMfTbkLT7nbzFCuie7ZZL0XkjJqMWhhoEphL3H UgsREzzI9AJC4eBmjhi1ge1ZrujOAMFyQsxasy9JjBbbit446gIR1bvY1 9FCuMGJifz9L8Fa88/KtecVyXsWlHNGb6kDiXoG858D4jFam2CAyxU0Ry POZkIy/nFSnOhtFUuObefjojjujS7Mg+qm4ixbEfSHAnMpbLoJBUMzIlG FGCn7EQ8BWWqBYeMZcfb7ibpeJf0BbPL8mY89Bg3+jbePatYfDfWbzKt4 oPWwnaaqlvmVyqAJm8oPryBJTM81eVv6SIGKxBKw/EKzTrtXDs+FQr1C+ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="301659410" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="301659410" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:19 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="601655872" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="601655872" Received: from ngverso-mobl2.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.252.7.149]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:17 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Tue, 4 Oct 2022 16:25:47 +0100 Message-Id: <20221004152549.436801-3-matthew.auld@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221004152549.436801-1-matthew.auld@intel.com> References: <20221004152549.436801-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 3/5] tests/i915/query: stop checking rsvd0 in region info 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: intel-gfx@lists.freedesktop.org, Andrzej Hajda , Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" No longer reserved, in the near future this will be the GTT alignment. Signed-off-by: Matthew Auld Cc: Andrzej Hajda Cc: Nirmoy Das Reviewed-by: Nirmoy Das --- tests/i915/i915_query.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/i915/i915_query.c b/tests/i915/i915_query.c index b92d7593..4e43c7cd 100644 --- a/tests/i915/i915_query.c +++ b/tests/i915/i915_query.c @@ -581,8 +581,6 @@ static void test_query_regions_garbage_items(int fd) struct drm_i915_memory_region_info info = regions->regions[i]; int j; - igt_assert_eq_u32(info.rsvd0, 0); - /* * rsvd1[0] : probed_cpu_visible_size * rsvd1[1] : unallocated_cpu_visible_size From patchwork Tue Oct 4 15:25:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12998535 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 845E3C433FE for ; Tue, 4 Oct 2022 15:26:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE3E410E71C; Tue, 4 Oct 2022 15:26:33 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 49A3010E727; Tue, 4 Oct 2022 15:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664897181; x=1696433181; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8d/ADbuhOvs3KEKVxrJnpk+C1p02ViY5IqEI5d8ORSU=; b=hJBMIK7Mdx4VQSH+26yKQ+hsm0Pzodywr6tKJ0OhNKydj3doby95DYqV 2skJxqEwZjuj+SPlirb9sma1MkoPaKJKXTVvKltn9egmPu7o0pkBmA95w rOl3f+5OptDcYUA7IEYUU9R2fVrrZavrQnXVQdfYyipPuZE4FD/eO0hVd MA+NRW/bJc45qcV8XUy9YSYdZCqJbctL/7iec+2EzcWrQfzVAhjEv2koh HoVf2DOL/hRcprbkilt21Ny1z8cKXU3Suh04VNA2W8nxBGqnNzPZt69t7 aXAGHsFrvfZ8Io9EzjyggGxa8xLNFbgnTrscQPdRN1mJTSPh4W6uALR4h A==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="301659415" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="301659415" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:21 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="601655876" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="601655876" Received: from ngverso-mobl2.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.252.7.149]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:19 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Tue, 4 Oct 2022 16:25:48 +0100 Message-Id: <20221004152549.436801-4-matthew.auld@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221004152549.436801-1-matthew.auld@intel.com> References: <20221004152549.436801-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 4/5] tests/i915/query: sanity check reported GTT alignment 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: intel-gfx@lists.freedesktop.org, Andrzej Hajda , Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Ensure the kernel is reporting "normal" values here, based on our current expectations. v2: - Split the rsvd0 check out, so we can in theory land that patch by itself (since that will fix the kernel failure vs old igt and could be merged early). - s/4096/PAGE_SIZE/ (Nirmoy) Signed-off-by: Matthew Auld Cc: Andrzej Hajda Cc: Nirmoy Das Reviewed-by: Nirmoy Das --- tests/i915/i915_query.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/i915/i915_query.c b/tests/i915/i915_query.c index 4e43c7cd..366427b4 100644 --- a/tests/i915/i915_query.c +++ b/tests/i915/i915_query.c @@ -30,6 +30,8 @@ IGT_TEST_DESCRIPTION("Testing the i915 query uAPI."); +#define PAGE_SIZE 4096 + /* * We should at least get 3 bytes for data for each slices, subslices & EUs * masks. @@ -638,6 +640,8 @@ static void upload(int fd, struct igt_list_head *handles, uint32_t num_handles) free(exec); } +/** XXX: remove once we sync the uapi header */ +#define gtt_alignment rsvd0 static void test_query_regions_sanity_check(int fd) { struct drm_i915_query_memory_regions *regions; @@ -664,6 +668,11 @@ static void test_query_regions_sanity_check(int fd) struct drm_i915_gem_memory_class_instance r1 = info.region; int j; + if (info.gtt_alignment) { + igt_assert_lte_u64(PAGE_SIZE, info.gtt_alignment); + igt_assert(is_power_of_two(info.gtt_alignment)); + } + if (r1.memory_class == I915_MEMORY_CLASS_SYSTEM) { igt_assert_eq(r1.memory_instance, 0); found_system = true; @@ -674,6 +683,9 @@ static void test_query_regions_sanity_check(int fd) igt_assert(info.unallocated_cpu_visible_size == 0 || info.unallocated_cpu_visible_size == info.unallocated_size); + + igt_assert(info.gtt_alignment == 0 || + info.gtt_alignment == PAGE_SIZE); } else { igt_assert(info.probed_cpu_visible_size <= info.probed_size); igt_assert(info.unallocated_size <= info.probed_size); From patchwork Tue Oct 4 15:25:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12998534 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 11C72C4332F for ; Tue, 4 Oct 2022 15:26:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 30DC910E711; Tue, 4 Oct 2022 15:26:27 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA70110E724; Tue, 4 Oct 2022 15:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664897182; x=1696433182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=exIdKb5B73+GhD3q4SRTY1/IZO35AGSv2ITM754pZUQ=; b=Ne3ILYzcoFB7osUBLqOzKol/n2cI1m2gfCO9Da7ffBV38y+iy8ukoyuj hpOxAyA5Rl1m1ifpcxkQhrqhR8quMsvgx9tMMV1weZ8NiAHJuj36AIzJL SDPHAbb9riq/8wkYLXZ6jYvVfclCtJmx09AOPf1939gHD+yiBZj+ai2ST HZYcKtAh1wfNRSNe6biUn+6NgcFPetEuL5LRdIxSA+kyYhNilNQamkEnL fodZWQ9qNL/vFKH4LDorYcMNEcGZ4cRnkvqZtxyU5i9jNIzmt2kf57Ww8 n6sJdQo/I03uHqKmaobAik/Tdtthr7xy95MYfewZAv4/Wn63qqXR6WD6U Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="301659426" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="301659426" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:22 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="601655880" X-IronPort-AV: E=Sophos;i="5.95,158,1661842800"; d="scan'208";a="601655880" Received: from ngverso-mobl2.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.252.7.149]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 08:26:21 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Tue, 4 Oct 2022 16:25:49 +0100 Message-Id: <20221004152549.436801-5-matthew.auld@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221004152549.436801-1-matthew.auld@intel.com> References: <20221004152549.436801-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 5/5] tests/i915/gem_create: add some basic testing for GTT alignment 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: intel-gfx@lists.freedesktop.org, Andrzej Hajda , Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Make sure we can always place an object at some GTT address, so long as we adhere to the min GTT alignment for the given region. Signed-off-by: Matthew Auld Cc: Andrzej Hajda Cc: Nirmoy Das Reviewed-by: Nirmoy Das --- tests/i915/gem_create.c | 117 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c index becdc715..5ede76fa 100644 --- a/tests/i915/gem_create.c +++ b/tests/i915/gem_create.c @@ -821,6 +821,115 @@ static void create_ext_cpu_access_big(int fd) free(regions); } +/** XXX: remove once we sync the uapi header */ +#define gtt_alignment rsvd0 +static bool supports_gtt_alignment(int fd) +{ + struct drm_i915_query_memory_regions *regions; + uint32_t gtt_alignment; + + regions = gem_get_query_memory_regions(fd); + igt_assert(regions); + igt_assert(regions->num_regions); + + gtt_alignment = regions->regions[0].gtt_alignment; + free(regions); + + return gtt_alignment; +} + +static void create_ext_placement_alignment(int fd) +{ + struct drm_i915_gem_create_ext_memory_regions setparam_region = { + .base = { .name = I915_GEM_CREATE_EXT_MEMORY_REGIONS }, + }; + struct drm_i915_gem_memory_class_instance *uregions; + struct drm_i915_query_memory_regions *regions; + const uint32_t bbe = MI_BATCH_BUFFER_END; + struct drm_i915_gem_execbuffer2 execbuf = {}; + struct drm_i915_gem_exec_object2 obj = {}; + uint32_t max_gtt_alignment; + uint32_t handle; + uint32_t ctx; + uint64_t ahnd; + uint64_t size; + int i; + + regions = gem_get_query_memory_regions(fd); + igt_assert(regions); + igt_assert(regions->num_regions); + + uregions = calloc(regions->num_regions, sizeof(*uregions)); + + ctx = gem_context_create(fd); + + max_gtt_alignment = 0; + for (i = 0; i < regions->num_regions; i++) { + struct drm_i915_memory_region_info qmr = regions->regions[i]; + struct drm_i915_gem_memory_class_instance ci = qmr.region; + uint32_t gtt_alignment; + + gtt_alignment = qmr.gtt_alignment; + + setparam_region.regions = to_user_pointer(&ci); + setparam_region.num_regions = 1; + + size = PAGE_SIZE; + igt_assert_eq(__gem_create_ext(fd, &size, 0, &handle, + &setparam_region.base), 0); + gem_write(fd, handle, 0, &bbe, sizeof(bbe)); + + ahnd = intel_allocator_open_full(fd, ctx, 0, 0, + INTEL_ALLOCATOR_RANDOM, + ALLOC_STRATEGY_HIGH_TO_LOW, + gtt_alignment); + + obj.handle = handle; + obj.offset = CANONICAL(get_offset(ahnd, handle, size, 0)); + obj.flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_PINNED; + + execbuf.buffers_ptr = to_user_pointer(&obj); + execbuf.buffer_count = 1; + + gem_execbuf(fd, &execbuf); + + put_ahnd(ahnd); + + max_gtt_alignment = max(max_gtt_alignment, gtt_alignment); + uregions[i] = regions->regions[i].region; + } + + setparam_region.regions = to_user_pointer(uregions); + setparam_region.num_regions = regions->num_regions; + + size = PAGE_SIZE; + igt_assert_eq(__gem_create_ext(fd, &size, 0, &handle, + &setparam_region.base), 0); + gem_write(fd, handle, 0, &bbe, sizeof(bbe)); + + ahnd = intel_allocator_open_full(fd, ctx, 0, 0, + INTEL_ALLOCATOR_RANDOM, + ALLOC_STRATEGY_HIGH_TO_LOW, + max_gtt_alignment); + + obj.handle = handle; + obj.offset = CANONICAL(get_offset(ahnd, handle, size, 0)); + obj.flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_PINNED; + + execbuf.buffers_ptr = to_user_pointer(&obj); + execbuf.buffer_count = 1; + + gem_execbuf(fd, &execbuf); + + put_ahnd(ahnd); + + gem_context_destroy(fd, ctx); + + gem_close(fd, handle); + free(uregions); + free(regions); +} + igt_main { int fd = -1; @@ -906,4 +1015,12 @@ igt_main igt_require(supports_needs_cpu_access(fd)); create_ext_cpu_access_big(fd); } + + igt_describe("Check reported GTT alignment gives usable GTT address, for each region."); + igt_subtest("create-ext-placement-alignment") { + igt_require(supports_gtt_alignment(fd)); + igt_require(gem_uses_full_ppgtt(fd)); + create_ext_placement_alignment(fd); + } + }