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 8376BCD4F21 for ; Sat, 16 May 2026 09:35:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A24F10E189; Sat, 16 May 2026 09:35:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="fv1+W3T+"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 09CCF10E189 for ; Sat, 16 May 2026 09:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778924139; x=1810460139; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SjKB7hcU0jVavlFwyBxJENIes9evQ/4KufW6V1ZBMn8=; b=fv1+W3T+9Rn5zg5VXrdupOCCq2GWioTjo78lzIpaQAr0CIACJQGXULbP S8Dx06u3hZ3uyvvHDsdGSMvFZNFbSiVwGLeUPSVij3rNqYi3KUqetL2Ao BxWQHEQRGPwTpwmWDUxCtMF8A+JGc1RmDvG9b1Qq8pNM1X7IsEOwYaNv4 QvOGXtYZ+RxN9ycD4VkV8KwJbsjiQAOAmYTmVOGg2CcMHrn9tX3qZExpJ cNoQU5ciyP9lcafz3HIs9FMh6CcO/bDQeRmxKc0Q/6Hw4TOtoOD+KjCv4 XZPO8KNQcZHFQcuq/zSkZ1j6MzcswiIqFiCZQ1hbSkTp18RmX7GxiNcx5 g==; X-CSE-ConnectionGUID: WsW8/+2GTjSPHsAOBpzpvg== X-CSE-MsgGUID: J1mB1B4NStKldgtbQo+LQw== X-IronPort-AV: E=McAfee;i="6800,10657,11787"; a="90441925" X-IronPort-AV: E=Sophos;i="6.23,238,1770624000"; d="scan'208";a="90441925" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2026 02:35:39 -0700 X-CSE-ConnectionGUID: b1AYPl4MSaq68oeLMSLHcw== X-CSE-MsgGUID: qg7V9EloTC28YOMkDQta/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,238,1770624000"; d="scan'208";a="243911648" Received: from jraag-z790m-itx-wifi.iind.intel.com ([10.190.239.23]) by orviesa005.jf.intel.com with ESMTP; 16 May 2026 02:35:34 -0700 From: Raag Jadav To: intel-xe@lists.freedesktop.org Cc: matthew.brost@intel.com, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com, riana.tauro@intel.com, michal.wajdeczko@intel.com, matthew.d.roper@intel.com, michal.winiarski@intel.com, matthew.auld@intel.com, dev@lankhorst.se, jani.nikula@intel.com, lukasz.laguna@intel.com, zhanjun.dong@intel.com, lukas@wunner.de, daniele.ceraolospurio@intel.com, badal.nilawar@intel.com, Raag Jadav Subject: [PATCH v7 4/8] drm/xe/bo_evict: Introduce xe_bo_restore_map() Date: Sat, 16 May 2026 15:01:27 +0530 Message-ID: <20260516093131.27442-5-raag.jadav@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260516093131.27442-1-raag.jadav@intel.com> References: <20260516093131.27442-1-raag.jadav@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" PCIe FLR clears all hardware state along with GGTT mappings of all existing bos. Iterate over early and late kernel bo list and restore their GGTT mappings in hardware, so that driver can make use of them during re-initialization after PCIe FLR. Signed-off-by: Raag Jadav Tested-by: Lukasz Laguna --- v2: Add kernel doc (Matthew Brost) --- drivers/gpu/drm/xe/xe_bo_evict.c | 51 +++++++++++++++++++++++++++----- drivers/gpu/drm/xe/xe_bo_evict.h | 2 ++ 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_bo_evict.c b/drivers/gpu/drm/xe/xe_bo_evict.c index 7661fca7f278..fa75140c88fe 100644 --- a/drivers/gpu/drm/xe/xe_bo_evict.c +++ b/drivers/gpu/drm/xe/xe_bo_evict.c @@ -189,14 +189,8 @@ int xe_bo_evict_all(struct xe_device *xe) xe_bo_evict_pinned); } -static int xe_bo_restore_and_map_ggtt(struct xe_bo *bo) +static int xe_bo_map_ggtt(struct xe_bo *bo) { - int ret; - - ret = xe_bo_restore_pinned(bo); - if (ret) - return ret; - if (bo->flags & XE_BO_FLAG_GGTT) { struct xe_tile *tile; u8 id; @@ -212,6 +206,41 @@ static int xe_bo_restore_and_map_ggtt(struct xe_bo *bo) return 0; } +/** + * xe_bo_restore_map() - Restore GGTT mappings of kernel bos + * @xe: xe device + * + * PCIe FLR clears all hardware state along with GGTT mappings of all + * existing bos. Iterate over early and late kernel bo list and restore + * their GGTT mappings in hardware, so that driver can make use of them + * during re-initialization after PCIe FLR. + * + * Returns: 0 on success, negative error code otherwise. + */ +int xe_bo_restore_map(struct xe_device *xe) +{ + int ret; + + ret = xe_bo_apply_to_pinned(xe, &xe->pinned.early.kernel_bo_present, + &xe->pinned.early.kernel_bo_present, xe_bo_map_ggtt); + if (!ret) + ret = xe_bo_apply_to_pinned(xe, &xe->pinned.late.kernel_bo_present, + &xe->pinned.late.kernel_bo_present, xe_bo_map_ggtt); + + return ret; +} + +static int xe_bo_restore_and_map_ggtt(struct xe_bo *bo) +{ + int ret; + + ret = xe_bo_restore_pinned(bo); + if (ret) + return ret; + + return xe_bo_map_ggtt(bo); +} + /** * xe_bo_restore_early - restore early phase kernel BOs to VRAM * @@ -270,7 +299,13 @@ int xe_bo_restore_late(struct xe_device *xe) return ret; } -static void xe_bo_pci_dev_remove_pinned(struct xe_device *xe) +/** + * xe_bo_pci_dev_remove_pinned() - Unmap external bos + * @xe: xe device + * + * Drop dma mappings of all external pinned bos. + */ +void xe_bo_pci_dev_remove_pinned(struct xe_device *xe) { struct xe_tile *tile; unsigned int id; diff --git a/drivers/gpu/drm/xe/xe_bo_evict.h b/drivers/gpu/drm/xe/xe_bo_evict.h index e8385cb7f5e9..d4f5b87243e7 100644 --- a/drivers/gpu/drm/xe/xe_bo_evict.h +++ b/drivers/gpu/drm/xe/xe_bo_evict.h @@ -14,7 +14,9 @@ int xe_bo_notifier_prepare_all_pinned(struct xe_device *xe); void xe_bo_notifier_unprepare_all_pinned(struct xe_device *xe); int xe_bo_restore_early(struct xe_device *xe); int xe_bo_restore_late(struct xe_device *xe); +int xe_bo_restore_map(struct xe_device *xe); +void xe_bo_pci_dev_remove_pinned(struct xe_device *xe); void xe_bo_pci_dev_remove_all(struct xe_device *xe); int xe_bo_pinned_init(struct xe_device *xe); -- 2.43.0