From patchwork Sat Oct 12 02:40:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 13833768 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 750F3D1A42C for ; Sat, 12 Oct 2024 03:09:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E623710E2E9; Sat, 12 Oct 2024 03:09:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="TiX5Fbfa"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 68D2110E03B; Sat, 12 Oct 2024 03:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728702576; x=1760238576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sCLXIH+f41dp6R34CT4MxqUaL5J7BMa4OgN8f/KYKjs=; b=TiX5Fbfae8Dp4TQ/EVLWbqozzw8f9oiSNGUI5D9C8V/ABcSRO4N02fdc vZrkA0fcEu6/A8Wudipl+FBeGGaxL2KyzmdfJ+d8+uoWO9IadrNxFPJ+9 hw5Tu0XBMU7GsyALhj587NW9Rxl5QHAb8fQKUJuBsCA6SCXOQJWUeQZaV XIkJF5M8T7acsi63X4nKFoM90C6TG3Cykk1O5rcqpIFpQZx5oNEC4jQVI pe9KqSnZfWf6lg4v+i1qQbXeyN8cVDYQB/dNDRsWGcd2cHjYjjvn2cf4b 2f4S7/MHw7OfUvC/IQyb/GKoAy/pOyuUt/syEEe3d/O02zswZHMOazVGa w==; X-CSE-ConnectionGUID: 8HxCUVhSTum6v5+8hVj4Lw== X-CSE-MsgGUID: Kdh4RfKUQA6cSUmd3i83aQ== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="38687318" X-IronPort-AV: E=Sophos;i="6.11,197,1725346800"; d="scan'208";a="38687318" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2024 20:09:36 -0700 X-CSE-ConnectionGUID: QDUZkImSQzW/qXI7cIQZMQ== X-CSE-MsgGUID: +KVn5d4hR1WGMnRVGP4FLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,197,1725346800"; d="scan'208";a="77278461" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2024 20:09:36 -0700 From: Vivek Kasireddy To: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: Vivek Kasireddy Subject: [PATCH v1 2/5] drm/xe/dmabuf: Don't migrate BO to System RAM while running in VF mode Date: Fri, 11 Oct 2024 19:40:24 -0700 Message-ID: <20241012024524.1377836-3-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241012024524.1377836-1-vivek.kasireddy@intel.com> References: <20241012024524.1377836-1-vivek.kasireddy@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" If the importer has allow_peer2peer set to true, then we can expect that it would be able to handle VRAM addresses. Therefore, in this specific case and only while running in VF mode, do not migrate the BO to System RAM before exporting it. Signed-off-by: Vivek Kasireddy --- drivers/gpu/drm/xe/xe_dma_buf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_buf.c index 68f309f5e981..a90c9368d265 100644 --- a/drivers/gpu/drm/xe/xe_dma_buf.c +++ b/drivers/gpu/drm/xe/xe_dma_buf.c @@ -17,6 +17,7 @@ #include "xe_bo.h" #include "xe_device.h" #include "xe_pm.h" +#include "xe_sriov.h" #include "xe_ttm_vram_mgr.h" #include "xe_vm.h" @@ -26,8 +27,11 @@ static int xe_dma_buf_attach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach) { struct drm_gem_object *obj = attach->dmabuf->priv; + struct xe_bo *bo = gem_to_xe_bo(obj); + struct xe_device *xe = xe_bo_device(bo); if (attach->peer2peer && + !IS_SRIOV_VF(xe) && pci_p2pdma_distance(to_pci_dev(obj->dev->dev), attach->dev, false) < 0) attach->peer2peer = false; @@ -51,7 +55,7 @@ static int xe_dma_buf_pin(struct dma_buf_attachment *attach) struct drm_gem_object *obj = attach->dmabuf->priv; struct xe_bo *bo = gem_to_xe_bo(obj); struct xe_device *xe = xe_bo_device(bo); - int ret; + int ret = 0; /* * For now only support pinning in TT memory, for two reasons: @@ -63,7 +67,8 @@ static int xe_dma_buf_pin(struct dma_buf_attachment *attach) return -EINVAL; } - ret = xe_bo_migrate(bo, XE_PL_TT); + if (!IS_SRIOV_VF(xe) || !attach->peer2peer) + ret = xe_bo_migrate(bo, XE_PL_TT); if (ret) { if (ret != -EINTR && ret != -ERESTARTSYS) drm_dbg(&xe->drm,