From mboxrd@z Thu Jan 1 00:00:00 1970 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 034B2CCD1BF for ; Sat, 25 Oct 2025 12:05:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4468A10E284; Sat, 25 Oct 2025 12:05:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="cJNa9ske"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4860C10E285; Sat, 25 Oct 2025 12:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761393909; x=1792929909; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OCpvNBcmA/iGVwlu41MEcZ+SMzdyXq6PIRCc3Tt/wXE=; b=cJNa9ske/AV/md4j/4S5/Pm8qDYeuLxEGmWA9QGG1TjN+YAj3UI1EpXP ybQA9DgpUu2urnOY+NsbssbNlbwYGJBqJBu86BhULqjMDPXAL0tQAnaX2 PmePQo0Y2HueSH9xKWJyphfo8GqSlr/a09+zyYhQ5Vt5VEV6a+/OB6KBi D9VQ6WgE5FdsajKoGzQOsvTUh8YVl4hwUafee7jf9P+F44XBme6ltLfUR SaZJvcm/siTIhlxWLCF32GuEQHAulyDNtAe36J5GhndVroV86h1siHe5I +6hp1unxvhhFb1R5bG1mmidj09zUcmQ+iLQgrF6pPWJN2iMC/CUVhYWlB Q==; X-CSE-ConnectionGUID: TfdigOCHSXGxZkkm+izZ/Q== X-CSE-MsgGUID: IivOQkkESmGZ2KWT0fIzQw== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="63590390" X-IronPort-AV: E=Sophos;i="6.19,254,1754982000"; d="scan'208";a="63590390" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2025 05:05:09 -0700 X-CSE-ConnectionGUID: WVyUnkV3Q+GsHaiASABmtg== X-CSE-MsgGUID: ejfXEb3rQCiEx9PFPVBzjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,254,1754982000"; d="scan'208";a="189023797" Received: from smoticic-mobl1.ger.corp.intel.com (HELO fedora) ([10.245.245.168]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2025 05:05:06 -0700 From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Cc: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , dri-devel@lists.freedesktop.org, himal.prasad.ghimiray@intel.com, apopple@nvidia.com, airlied@gmail.com, Simona Vetter , felix.kuehling@amd.com, Matthew Brost , =?UTF-8?q?Christian=20K=C3=B6nig?= , dakr@kernel.org, "Mrozek, Michal" , Joonas Lahtinen Subject: [PATCH 11/15] drm/xe: Simplify madvise_preferred_mem_loc() Date: Sat, 25 Oct 2025 14:04:08 +0200 Message-ID: <20251025120412.12262-12-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025120412.12262-1-thomas.hellstrom@linux.intel.com> References: <20251025120412.12262-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Simplify madvise_preferred_mem_loc by removing repetitive patterns in favour of local variables. Signed-off-by: Thomas Hellström --- drivers/gpu/drm/xe/xe_vm_madvise.c | 21 +++++++++++---------- drivers/gpu/drm/xe/xe_vm_types.h | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vm_madvise.c b/drivers/gpu/drm/xe/xe_vm_madvise.c index 9553008409d1..d6f47c8e146d 100644 --- a/drivers/gpu/drm/xe/xe_vm_madvise.c +++ b/drivers/gpu/drm/xe/xe_vm_madvise.c @@ -81,21 +81,22 @@ static void madvise_preferred_mem_loc(struct xe_device *xe, struct xe_vm *vm, xe_assert(vm->xe, op->type == DRM_XE_MEM_RANGE_ATTR_PREFERRED_LOC); for (i = 0; i < num_vmas; i++) { + struct xe_vma *vma = vmas[i]; + struct xe_vma_preferred_loc *loc = &vma->attr.preferred_loc; + /*TODO: Extend attributes to bo based vmas */ - if ((vmas[i]->attr.preferred_loc.devmem_fd == op->preferred_mem_loc.devmem_fd && - vmas[i]->attr.preferred_loc.migration_policy == - op->preferred_mem_loc.migration_policy) || - !xe_vma_is_cpu_addr_mirror(vmas[i])) { - vmas[i]->skip_invalidation = true; + if ((loc->devmem_fd == op->preferred_mem_loc.devmem_fd && + loc->migration_policy == op->preferred_mem_loc.migration_policy) || + !xe_vma_is_cpu_addr_mirror(vma)) { + vma->skip_invalidation = true; } else { - vmas[i]->skip_invalidation = false; - vmas[i]->attr.preferred_loc.devmem_fd = op->preferred_mem_loc.devmem_fd; + vma->skip_invalidation = false; + loc->devmem_fd = op->preferred_mem_loc.devmem_fd; /* Till multi-device support is not added migration_policy * is of no use and can be ignored. */ - vmas[i]->attr.preferred_loc.migration_policy = - op->preferred_mem_loc.migration_policy; - vmas[i]->attr.preferred_loc.dpagemap = NULL; + loc->migration_policy = op->preferred_mem_loc.migration_policy; + loc->dpagemap = NULL; } } } diff --git a/drivers/gpu/drm/xe/xe_vm_types.h b/drivers/gpu/drm/xe/xe_vm_types.h index 5313bf2afa54..a83a0bda6861 100644 --- a/drivers/gpu/drm/xe/xe_vm_types.h +++ b/drivers/gpu/drm/xe/xe_vm_types.h @@ -56,7 +56,7 @@ struct xe_vm_pgtable_update_op; */ struct xe_vma_mem_attr { /** @preferred_loc: perferred memory_location */ - struct { + struct xe_vma_preferred_loc { /** @preferred_loc.migration_policy: Pages migration policy */ u32 migration_policy; -- 2.51.0