From patchwork Mon Aug 5 10:25:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 13753469 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 58E39C3DA4A for ; Mon, 5 Aug 2024 10:26:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C27D510E19C; Mon, 5 Aug 2024 10:26:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="KyUMD/eF"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id E847F10E19C; Mon, 5 Aug 2024 10:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722853587; x=1754389587; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X1ZFFRFIhMBs5KT2PsG5UXEe4EuK7kxomaYoyvQO7xg=; b=KyUMD/eFi7Hy2rN8o8dQNNdRyv3vm0zaJzntIxB4dISE8cUXX5aXpjHr ZJV8foU4TG4vwRguJLDtoi5JhDjZZZfQvOZF+nlubca5uDNzTtQn0rSvp YXI0crhdYVhj7xNFzo9TsoRaE62HxLpuiMcDZyVcr9cfFPErrIWM44jTT BGHmEfUH2RqGQYN5DR6nxbnJen3IDiZKIWJd7tPo+kGghzqbE0DuOPxfW IimNy/jt4XYC+PjaYyOeoAXkRp4ovG98mskpwfjW/E3rH5UQM0hFsyQEb NOAQCpcmjjqDhOA1AAbV9i1BCiElLkGk80yjs0AuDlaQ/EelrnDT9L+49 g==; X-CSE-ConnectionGUID: fa9CDqvvT7aWblNogubDyQ== X-CSE-MsgGUID: 24nrur7aSnu5Xhaq84qDaA== X-IronPort-AV: E=McAfee;i="6700,10204,11154"; a="20948794" X-IronPort-AV: E=Sophos;i="6.09,264,1716274800"; d="scan'208";a="20948794" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 03:26:26 -0700 X-CSE-ConnectionGUID: fCOFMRYFSbuM2eaDZjlMfw== X-CSE-MsgGUID: HMBgVM99SkiCZMif7Q66/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,264,1716274800"; d="scan'208";a="93647552" Received: from fpallare-mobl3.ger.corp.intel.com (HELO intel.com) ([10.245.245.249]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 03:26:22 -0700 From: Andi Shyti To: intel-gfx , dri-devel Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Jann Horn , Chris Wilson , Krzysztof Niemiec , Andi Shyti , Andi Shyti Subject: [PATCH v2 1/2] drm/i915/gem: Adjust vma offset for framebuffer mmap offset Date: Mon, 5 Aug 2024 11:25:53 +0100 Message-ID: <20240805102554.154464-2-andi.shyti@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805102554.154464-1-andi.shyti@linux.intel.com> References: <20240805102554.154464-1-andi.shyti@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When mapping a framebuffer object, the virtual memory area (VMA) offset ('vm_pgoff') should be adjusted by the start of the 'vma_node' associated with the object. This ensures that the VMA offset is correctly aligned with the corresponding offset within the GGTT aperture. Increment vm_pgoff by the start of the vma_node with the offset= provided by the user. Suggested-by: Chris Wilson Signed-off-by: Andi Shyti Reviewed-by: Jonathan Cavitt --- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c index a2195e28b625..ce10dd259812 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c @@ -1084,6 +1084,8 @@ int i915_gem_fb_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct *vma mmo = mmap_offset_attach(obj, mmap_type, NULL); if (IS_ERR(mmo)) return PTR_ERR(mmo); + + vma->vm_pgoff += drm_vma_node_start(&mmo->vma_node); } /*