From patchwork Wed Jul 28 10:30:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405369 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 C00E0C4338F for ; Wed, 28 Jul 2021 10:31:45 +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 7791E6023F for ; Wed, 28 Jul 2021 10:31:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7791E6023F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 180A36E4DE; Wed, 28 Jul 2021 10:31:45 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85FC56E088; Wed, 28 Jul 2021 10:31:43 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627049" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627049" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:42 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179356" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:38 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:31 +0100 Message-Id: <20210728103041.1669985-1-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 01/11] lib/i915/gem_mman: add FIXED mmap mode 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We need this for discrete. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- lib/i915/gem_mman.c | 37 +++++++++++++++++++++++++++++++++++++ lib/i915/gem_mman.h | 4 ++++ 2 files changed, 41 insertions(+) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index 4b4f2114..e2514f0c 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -497,6 +497,43 @@ void *gem_mmap_offset__cpu(int fd, uint32_t handle, uint64_t offset, return ptr; } +#define LOCAL_I915_MMAP_OFFSET_FIXED 4 + +void *__gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, + uint64_t size, unsigned prot) +{ + return __gem_mmap_offset(fd, handle, offset, size, prot, + LOCAL_I915_MMAP_OFFSET_FIXED); +} + +/** + * gem_mmap_offset__fixed: Used to mmap objects on discrete platforms + * @fd: open i915 drm file descriptor + * @handle: gem buffer object handle + * @offset: offset in the gem buffer of the mmap arena + * @size: size of the mmap arena + * @prot: memory protection bits as used by mmap() + * + * Like __gem_mmap_offset__fixed() except we assert on failure. + * + * For discrete the caching attributes for the pages are fixed at allocation + * time, and can't be changed. The FIXED mode will simply use the same caching * + * mode of the allocated pages. This mode will always be coherent with GPU + * access. + * + * On non-discrete platforms this mode is not supported. + * + * Returns: A pointer to the created memory mapping + */ +void *gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, + uint64_t size, unsigned prot) +{ + void *ptr = __gem_mmap_offset__fixed(fd, handle, offset, size, prot); + + igt_assert(ptr); + return ptr; +} + /** * __gem_mmap__cpu_coherent: * @fd: open i915 drm file descriptor diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h index 5695d2ad..290c997d 100644 --- a/lib/i915/gem_mman.h +++ b/lib/i915/gem_mman.h @@ -37,6 +37,8 @@ bool gem_mmap_offset__has_wc(int fd); void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); void *gem_mmap_offset__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); +void *gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, + uint64_t size, unsigned prot); void *gem_mmap__device_coherent(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); void *gem_mmap__cpu_coherent(int fd, uint32_t handle, uint64_t offset, @@ -54,6 +56,8 @@ void *__gem_mmap_offset__cpu(int fd, uint32_t handle, uint64_t offset, void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); void *__gem_mmap_offset__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); +void *__gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, + uint64_t size, unsigned prot); void *__gem_mmap__device_coherent(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); void *__gem_mmap_offset(int fd, uint32_t handle, uint64_t offset, uint64_t size, From patchwork Wed Jul 28 10:30:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405371 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 63518C4338F for ; Wed, 28 Jul 2021 10:31:49 +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 03FC66023F for ; Wed, 28 Jul 2021 10:31:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 03FC66023F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A79F46E560; Wed, 28 Jul 2021 10:31:48 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F5196E511; Wed, 28 Jul 2021 10:31:45 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627054" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627054" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:44 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179372" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:42 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:32 +0100 Message-Id: <20210728103041.1669985-2-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 02/11] lib/i915/gem_mman: add fixed mode to mmap__device_coherent 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On discrete we need to fallback to this mode. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- lib/i915/gem_mman.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index e2514f0c..222e8896 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -383,9 +383,10 @@ void *__gem_mmap__device_coherent(int fd, uint32_t handle, uint64_t offset, I915_MMAP_OFFSET_WC); if (!ptr) ptr = __gem_mmap__wc(fd, handle, offset, size, prot); - if (!ptr) ptr = __gem_mmap__gtt(fd, handle, size, prot); + if (!ptr) + ptr = __gem_mmap_offset__fixed(fd, handle, offset, size, prot); return ptr; } From patchwork Wed Jul 28 10:30:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405373 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 EDCF6C4338F for ; Wed, 28 Jul 2021 10:31:51 +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 B1F8A60EB2 for ; Wed, 28 Jul 2021 10:31:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B1F8A60EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E2756E088; Wed, 28 Jul 2021 10:31:51 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id F2E2E6E560; Wed, 28 Jul 2021 10:31:47 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627063" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627063" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:47 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179390" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:44 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:33 +0100 Message-Id: <20210728103041.1669985-3-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 03/11] lib/i915/gem_mman: add fixed mode to mmap__cpu_coherent 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On discrete we only support the new fixed mode. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- lib/i915/gem_mman.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index 222e8896..337d28fb 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -580,6 +580,8 @@ void *gem_mmap__cpu_coherent(int fd, uint32_t handle, uint64_t offset, igt_assert(offset == 0); ptr = __gem_mmap__cpu_coherent(fd, handle, offset, size, prot); + if (!ptr) + ptr = __gem_mmap_offset__fixed(fd, handle, offset, size, prot); igt_assert(ptr); return ptr; From patchwork Wed Jul 28 10:30:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405375 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 53775C4320A for ; Wed, 28 Jul 2021 10:31:53 +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 11CC66023F for ; Wed, 28 Jul 2021 10:31:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 11CC66023F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 93AC36E846; Wed, 28 Jul 2021 10:31:52 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DA416E846; Wed, 28 Jul 2021 10:31:50 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627069" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627069" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:50 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179412" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:47 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:34 +0100 Message-Id: <20210728103041.1669985-4-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 04/11] lib/i915/gem_mman: add fixed mode to gem_mmap__cpu 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On discrete we only support the new fixed mode. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- lib/i915/gem_mman.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index 337d28fb..6f5e6d72 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -434,7 +434,13 @@ void *gem_mmap__device_coherent(int fd, uint32_t handle, uint64_t offset, */ void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot) { - return __gem_mmap(fd, handle, offset, size, prot, 0); + void *ptr; + + ptr = __gem_mmap(fd, handle, offset, size, prot, 0); + if (!ptr) + ptr = __gem_mmap_offset__fixed(fd, handle, offset, size, prot); + + return ptr; } /** From patchwork Wed Jul 28 10:30:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405377 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 0632EC4338F for ; Wed, 28 Jul 2021 10:31:57 +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 C177260EB2 for ; Wed, 28 Jul 2021 10:31:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C177260EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6314C6E52E; Wed, 28 Jul 2021 10:31:56 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id A4EBE6E880; Wed, 28 Jul 2021 10:31:53 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627086" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627086" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:53 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179426" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:50 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:35 +0100 Message-Id: <20210728103041.1669985-5-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 05/11] lib/i915/gem_mman: update mmap_offset_types with FIXED 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We need to also iterate the fixed mode in the tests which rely on this. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- lib/i915/gem_mman.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index 6f5e6d72..16168a32 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -617,6 +617,7 @@ const struct mmap_offset mmap_offset_types[] = { { "wb", I915_MMAP_OFFSET_WB, I915_GEM_DOMAIN_CPU }, { "wc", I915_MMAP_OFFSET_WC, I915_GEM_DOMAIN_WC }, { "uc", I915_MMAP_OFFSET_UC, I915_GEM_DOMAIN_WC }, + { "fixed", LOCAL_I915_MMAP_OFFSET_FIXED, 0}, {}, }; From patchwork Wed Jul 28 10:30:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405379 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 E49BBC4338F for ; Wed, 28 Jul 2021 10:32:00 +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 A961E60FC0 for ; Wed, 28 Jul 2021 10:32:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A961E60FC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D15E6E896; Wed, 28 Jul 2021 10:32:00 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 84CF46E83F; Wed, 28 Jul 2021 10:31:57 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627103" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627103" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:56 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179444" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:53 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:36 +0100 Message-Id: <20210728103041.1669985-6-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 06/11] lib/ioctl_wrappers: update mmap_{read, write} for discrete 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We can no longer just call get_caching or set_domain, and the mmap mode must be FIXED. This should bring back gem_exec_basic and a few others in CI on DG1. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- lib/ioctl_wrappers.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 25c5e495..7e27a1b3 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -339,7 +339,18 @@ static void mmap_write(int fd, uint32_t handle, uint64_t offset, if (!length) return; - if (is_cache_coherent(fd, handle)) { + if (gem_has_lmem(fd)) { + /* + * set/get_caching and set_domain are no longer supported on + * discrete, also the only mmap mode supportd is FIXED. + */ + map = gem_mmap_offset__fixed(fd, handle, 0, + offset + length, + PROT_READ | PROT_WRITE); + igt_assert_eq(gem_wait(fd, handle, 0), 0); + } + + if (!map && is_cache_coherent(fd, handle)) { /* offset arg for mmap functions must be 0 */ map = __gem_mmap__cpu_coherent(fd, handle, 0, offset + length, PROT_READ | PROT_WRITE); @@ -369,7 +380,17 @@ static void mmap_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint6 if (!length) return; - if (gem_has_llc(fd) || is_cache_coherent(fd, handle)) { + if (gem_has_lmem(fd)) { + /* + * set/get_caching and set_domain are no longer supported on + * discrete, also the only supported mmap mode is FIXED. + */ + map = gem_mmap_offset__fixed(fd, handle, 0, + offset + length, PROT_READ); + igt_assert_eq(gem_wait(fd, handle, 0), 0); + } + + if (!map && (gem_has_llc(fd) || is_cache_coherent(fd, handle))) { /* offset arg for mmap functions must be 0 */ map = __gem_mmap__cpu_coherent(fd, handle, 0, offset + length, PROT_READ); From patchwork Wed Jul 28 10:30:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405381 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 799EDC4338F for ; Wed, 28 Jul 2021 10:32:04 +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 4885960FC2 for ; Wed, 28 Jul 2021 10:32:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4885960FC2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D7B6D6E852; Wed, 28 Jul 2021 10:32:03 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01ED16E852; Wed, 28 Jul 2021 10:32:00 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627113" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627113" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:32:00 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179458" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:31:57 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:37 +0100 Message-Id: <20210728103041.1669985-7-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 07/11] lib/intel_bufops: update mmap_{read, write} for discrete 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On discrete we can no longer call get_caching or set_domain, and the mmap mode must be FIXED. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- lib/intel_bufops.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c index 3ce68663..faca4406 100644 --- a/lib/intel_bufops.c +++ b/lib/intel_bufops.c @@ -424,7 +424,18 @@ static void *mmap_write(int fd, struct intel_buf *buf) { void *map = NULL; - if (is_cache_coherent(fd, buf->handle)) { + if (gem_has_lmem(fd)) { + /* + * set/get_caching and set_domain are no longer supported on + * discrete, also the only mmap mode supportd is FIXED. + */ + map = gem_mmap_offset__fixed(fd, buf->handle, 0, + buf->surface[0].size, + PROT_READ | PROT_WRITE); + igt_assert_eq(gem_wait(fd, buf->handle, 0), 0); + } + + if (!map && is_cache_coherent(fd, buf->handle)) { map = __gem_mmap_offset__cpu(fd, buf->handle, 0, buf->surface[0].size, PROT_READ | PROT_WRITE); if (!map) @@ -455,7 +466,17 @@ static void *mmap_read(int fd, struct intel_buf *buf) { void *map = NULL; - if (gem_has_llc(fd) || is_cache_coherent(fd, buf->handle)) { + if (gem_has_lmem(fd)) { + /* + * set/get_caching and set_domain are no longer supported on + * discrete, also the only supported mmap mode is FIXED. + */ + map = gem_mmap_offset__fixed(fd, buf->handle, 0, + buf->surface[0].size, PROT_READ); + igt_assert_eq(gem_wait(fd, buf->handle, 0), 0); + } + + if (!map && (gem_has_llc(fd) || is_cache_coherent(fd, buf->handle))) { map = __gem_mmap_offset__cpu(fd, buf->handle, 0, buf->surface[0].size, PROT_READ); if (!map) From patchwork Wed Jul 28 10:30:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405383 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 B3E33C432BE for ; Wed, 28 Jul 2021 10:32:05 +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 8377260EB2 for ; Wed, 28 Jul 2021 10:32:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8377260EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB9436E8CE; Wed, 28 Jul 2021 10:32:04 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0746E6E852; Wed, 28 Jul 2021 10:32:02 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627114" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627114" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:32:02 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179476" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:32:00 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:38 +0100 Message-Id: <20210728103041.1669985-8-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 08/11] lib/ioctl_wrappers: update set_domain for discrete 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On discrete set_domain is now gone, instead we just need to add the wait. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- lib/ioctl_wrappers.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 7e27a1b3..09eb3ce7 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -565,7 +565,12 @@ int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write) */ void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write) { - igt_assert_eq(__gem_set_domain(fd, handle, read, write), 0); + int ret = __gem_set_domain(fd, handle, read, write); + + if (ret == -ENODEV && gem_has_lmem(fd)) + igt_assert_eq(gem_wait(fd, handle, 0), 0); + else + igt_assert_eq(ret, 0); } /** From patchwork Wed Jul 28 10:30:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405385 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 910AFC4338F for ; Wed, 28 Jul 2021 10:32:06 +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 5E7BB60EB2 for ; Wed, 28 Jul 2021 10:32:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5E7BB60EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C56626E83F; Wed, 28 Jul 2021 10:32:05 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id C1B706E8AD; Wed, 28 Jul 2021 10:32:04 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627117" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627117" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:32:04 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179483" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:32:02 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:39 +0100 Message-Id: <20210728103041.1669985-9-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 09/11] tests/i915/module_load: update for discrete 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The set_caching ioctl is gone for discrete, and now just returns -ENODEV. Update the gem_sanitycheck to account for that. After this we should be back to just having the breakage caused by missing reloc support for the reload testcase. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- tests/i915/i915_module_load.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c index 98ceb5d8..4b42fe3e 100644 --- a/tests/i915/i915_module_load.c +++ b/tests/i915/i915_module_load.c @@ -172,17 +172,22 @@ static void gem_sanitycheck(void) { struct drm_i915_gem_caching args = {}; int i915 = __drm_open_driver(DRIVER_INTEL); + int expected; int err; + expected = -ENOENT; + if (gem_has_lmem(i915)) + expected = -ENODEV; + err = 0; if (ioctl(i915, DRM_IOCTL_I915_GEM_SET_CACHING, &args)) err = -errno; - if (err == -ENOENT) + if (err == expected) store_all(i915); errno = 0; close(i915); - igt_assert_eq(err, -ENOENT); + igt_assert_eq(err, expected); } static void From patchwork Wed Jul 28 10:30:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405387 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 227DFC4338F for ; Wed, 28 Jul 2021 10:32:09 +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 E0B9A60EB2 for ; Wed, 28 Jul 2021 10:32:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E0B9A60EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 66E8B6E904; Wed, 28 Jul 2021 10:32:08 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D4CD6E8D2; Wed, 28 Jul 2021 10:32:06 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627121" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627121" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:32:06 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179492" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:32:04 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:40 +0100 Message-Id: <20210728103041.1669985-10-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 10/11] lib/i915/gem_mman: add helper query for has_device_coherent 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Might be useful in some tests, where we are not explicitly testing WC maps, but rather just require something that is "device coherent", which should also play nice on discrete platforms. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- lib/i915/gem_mman.c | 43 +++++++++++++++++++++++++++++++++++++++++-- lib/i915/gem_mman.h | 11 +++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index 16168a32..27ef97cf 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -196,6 +196,47 @@ bool gem_mmap_offset__has_wc(int fd) return has_wc > 0; } +#define LOCAL_I915_MMAP_OFFSET_FIXED 4 + +bool gem_mmap__has_device_coherent(int fd) +{ + struct drm_i915_gem_mmap_offset arg; + bool supported; + + if (gem_mmap__has_wc(fd)) + return true; + + /* Maybe we still have GTT mmaps? */ + memset(&arg, 0, sizeof(arg)); + arg.handle = gem_create(fd, 4096); + arg.offset = 0; + arg.flags = I915_MMAP_OFFSET_GTT; + supported = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, + &arg) == 0; + gem_close(fd, arg.handle); + + errno = 0; + + if (supported) + return true; + + /* + * Maybe this is a discrete device, which only supports fixed mmaps? + * Such mappings should also be considered device coherent. + */ + memset(&arg, 0, sizeof(arg)); + arg.handle = gem_create(fd, 4096); + arg.offset = 0; + arg.flags = LOCAL_I915_MMAP_OFFSET_FIXED; + supported = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, + &arg) == 0; + gem_close(fd, arg.handle); + + errno = 0; + + return supported; +} + /** * __gem_mmap: * @fd: open i915 drm file descriptor @@ -504,8 +545,6 @@ void *gem_mmap_offset__cpu(int fd, uint32_t handle, uint64_t offset, return ptr; } -#define LOCAL_I915_MMAP_OFFSET_FIXED 4 - void *__gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot) { diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h index 290c997d..5966ddb5 100644 --- a/lib/i915/gem_mman.h +++ b/lib/i915/gem_mman.h @@ -41,6 +41,7 @@ void *gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); void *gem_mmap__device_coherent(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); +bool gem_mmap__has_device_coherent(int fd); void *gem_mmap__cpu_coherent(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); @@ -96,6 +97,16 @@ int gem_munmap(void *ptr, uint64_t size); */ #define gem_require_mmap_offset_wc(fd) igt_require(gem_mmap_offset__has_wc(fd)) +/** + * gem_require_mmap_offset_device_coherent: + * @fd: open i915 drm file descriptor + * + * Feature test macro to query whether direct (i.e. cpu access path, bypassing + * the gtt) write-combine memory mappings are available, or fixed mapping for + * discrete. Automatically skips through igt_require() if not. + */ +#define gem_require_mmap_device_coherent(fd) igt_require(gem_mmap__has_device_coherent(fd)) + extern const struct mmap_offset { const char *name; unsigned int type; From patchwork Wed Jul 28 10:30:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12405389 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 F0099C4338F for ; Wed, 28 Jul 2021 10:32:12 +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 C30866023F for ; Wed, 28 Jul 2021 10:32:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C30866023F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 62C786E8E3; Wed, 28 Jul 2021 10:32:12 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 60C396E8E3; Wed, 28 Jul 2021 10:32:08 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212627124" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212627124" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:32:08 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="499179507" Received: from sdrogers-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.245.248]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 03:32:06 -0700 From: Matthew Auld To: igt-dev@lists.freedesktop.org Date: Wed, 28 Jul 2021 11:30:41 +0100 Message-Id: <20210728103041.1669985-11-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> References: <20210728103041.1669985-1-matthew.auld@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 11/11] tests/i915/gem_exec_fence: use device_coherent mmap 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: Daniel Vetter , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We lost explicit WC mmaps on discrete, where we now only support FIXED, however such mappings should be device coherent. In gem_exec_fence it looks like we can just use mmap__device_coherent, which should also work on discrete platforms, while still using an explicit WC mmap on integrated platforms. Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Ashutosh Dixit Cc: Daniel Vetter Cc: Ramalingam C --- tests/i915/gem_exec_fence.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c index ef1bb0ca..620e7ac2 100644 --- a/tests/i915/gem_exec_fence.c +++ b/tests/i915/gem_exec_fence.c @@ -152,7 +152,7 @@ static void test_fence_busy(int fd, const intel_ctx_t *ctx, obj.relocation_count = 1; memset(&reloc, 0, sizeof(reloc)); - batch = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); + batch = gem_mmap__device_coherent(fd, obj.handle, 0, 4096, PROT_WRITE); gem_set_domain(fd, obj.handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); @@ -244,7 +244,7 @@ static void test_fence_busy_all(int fd, const intel_ctx_t *ctx, unsigned flags) obj.relocation_count = 1; memset(&reloc, 0, sizeof(reloc)); - batch = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); + batch = gem_mmap__device_coherent(fd, obj.handle, 0, 4096, PROT_WRITE); gem_set_domain(fd, obj.handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); @@ -353,7 +353,7 @@ static void test_fence_await(int fd, const intel_ctx_t *ctx, uint32_t *out; int i; - out = gem_mmap__wc(fd, scratch, 0, 4096, PROT_WRITE); + out = gem_mmap__device_coherent(fd, scratch, 0, 4096, PROT_WRITE); gem_set_domain(fd, scratch, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); @@ -617,7 +617,7 @@ static void test_parallel(int i915, const intel_ctx_t *ctx, const struct intel_execution_engine2 *e2; const unsigned int gen = intel_gen(intel_get_drm_devid(i915)); uint32_t scratch = gem_create(i915, 4096); - uint32_t *out = gem_mmap__wc(i915, scratch, 0, 4096, PROT_READ); + uint32_t *out = gem_mmap__device_coherent(i915, scratch, 0, 4096, PROT_READ); uint32_t handle[I915_EXEC_RING_MASK]; IGT_CORK_FENCE(cork); igt_spin_t *spin; @@ -2813,7 +2813,7 @@ static void test_syncobj_timeline_chain_engines(int fd, const intel_ctx_cfg_t *c gem_sync(fd, ctx.engine_counter_object.handle); - counter_output = gem_mmap__wc(fd, ctx.engine_counter_object.handle, 0, 4096, PROT_READ); + counter_output = gem_mmap__device_coherent(fd, ctx.engine_counter_object.handle, 0, 4096, PROT_READ); for (uint32_t i = 0; i < ctx.engines.nengines; i++) igt_debug("engine %i (%s)\t= %016"PRIx64"\n", i, @@ -2879,7 +2879,7 @@ static void test_syncobj_stationary_timeline_chain_engines(int fd, const intel_c gem_sync(fd, ctx.engine_counter_object.handle); - counter_output = gem_mmap__wc(fd, ctx.engine_counter_object.handle, 0, 4096, PROT_READ); + counter_output = gem_mmap__device_coherent(fd, ctx.engine_counter_object.handle, 0, 4096, PROT_READ); for (uint32_t i = 0; i < ctx.engines.nengines; i++) igt_debug("engine %i (%s)\t= %016"PRIx64"\n", i, @@ -2940,7 +2940,7 @@ static void test_syncobj_backward_timeline_chain_engines(int fd, const intel_ctx gem_sync(fd, ctx.engine_counter_object.handle); - counter_output = gem_mmap__wc(fd, ctx.engine_counter_object.handle, 0, 4096, PROT_READ); + counter_output = gem_mmap__device_coherent(fd, ctx.engine_counter_object.handle, 0, 4096, PROT_READ); for (uint32_t i = 0; i < ctx.engines.nengines; i++) igt_debug("engine %i (%s)\t= %016"PRIx64"\n", i, @@ -2963,7 +2963,7 @@ igt_main i915 = drm_open_driver(DRIVER_INTEL); igt_require_gem(i915); igt_require(gem_has_exec_fence(i915)); - gem_require_mmap_wc(i915); + gem_require_mmap_device_coherent(i915); ctx = intel_ctx_create_all_physical(i915); gem_submission_print_method(i915);