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 7BAB3CCD185 for ; Tue, 7 Oct 2025 11:26:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 36D3710E671; Tue, 7 Oct 2025 11:26:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ZsikXeCA"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A61E10E671 for ; Tue, 7 Oct 2025 11:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1759836408; x=1791372408; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=dIk8TMicjtz7qPObrJCoUDLroKf3o/Pi+PRMX5hSss0=; b=ZsikXeCA/floWK+Dzvzt6l98I1YVMsJ3F+WFQP3qiGJDPPwBDxTBtVo/ PdSeJ6C8KSGz9MRF78RAMKMcf+5pf6w0ZeuKtb88DXFtxBiypTfazAInB kyghj+wLek6qzyuaeqvNSXTmju3mFsHltin6an1vgpQ7f1sYk8tM6pkzY YQvp5CEDyKC4a94aw+HfbCSFNHYMSiVJUx1qVDoSW5NAMptuPhGKddNJk WzfYxOWGOwaTwwoaTCNlVx9M3YhNRJzKuVQznTTvs7jXNYwLZ5ewgBsJN IZEVoACLNK0izu00NQgnWiVm+fuwEcLGNfc+d1MfCZtrFCrikPfKN6q4W g==; X-CSE-ConnectionGUID: gageNMe0Tl+jZkIWbSkiHw== X-CSE-MsgGUID: vuy+eW+bTVenFT5mdbkRCQ== X-IronPort-AV: E=McAfee;i="6800,10657,11574"; a="65660679" X-IronPort-AV: E=Sophos;i="6.18,321,1751266800"; d="scan'208";a="65660679" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2025 04:26:48 -0700 X-CSE-ConnectionGUID: DsAf01VyQP+na3yTRw7rfQ== X-CSE-MsgGUID: LkbSywwjTUWstLBS7chibQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,321,1751266800"; d="scan'208";a="180923996" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2025 04:26:47 -0700 From: Matthew Brost To: intel-xe@lists.freedesktop.org Subject: [PATCH v7 10/32] drm/xe/vf: Remove memory allocations from VF post migration recovery Date: Tue, 7 Oct 2025 04:26:19 -0700 Message-Id: <20251007112641.2669655-11-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251007112641.2669655-1-matthew.brost@intel.com> References: <20251007112641.2669655-1-matthew.brost@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" VF post migration recovery is the path of dma-fence signaling / reclaim, avoid memory allocations in this path. v3: - s/lrc_wa_bb/scratch (Tomasz) Signed-off-by: Matthew Brost Reviewed-by: Tomasz Lis --- drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 23 +++++++++++++---------- drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h | 2 ++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c index 1a2cf58f5dfd..31a80d77da36 100644 --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c @@ -1160,17 +1160,13 @@ static size_t post_migration_scratch_size(struct xe_device *xe) static int vf_post_migration_fixups(struct xe_gt *gt) { + void *buf = gt->sriov.vf.migration.scratch; s64 shift; - void *buf; int err; - buf = kmalloc(post_migration_scratch_size(gt_to_xe(gt)), GFP_ATOMIC); - if (!buf) - return -ENOMEM; - err = xe_gt_sriov_vf_query_config(gt); if (err) - goto out; + return err; shift = xe_gt_sriov_vf_ggtt_shift(gt); if (shift) { @@ -1178,12 +1174,10 @@ static int vf_post_migration_fixups(struct xe_gt *gt) xe_gt_sriov_vf_default_lrcs_hwsp_rebase(gt); err = xe_guc_contexts_hwsp_rebase(>->uc.guc, buf); if (err) - goto out; + return err; } -out: - kfree(buf); - return err; + return 0; } static void vf_post_migration_kickstart(struct xe_gt *gt) @@ -1268,9 +1262,18 @@ static void migration_worker_func(struct work_struct *w) */ int xe_gt_sriov_vf_init_early(struct xe_gt *gt) { + void *buf; + if (!xe_sriov_vf_migration_supported(gt_to_xe(gt))) return 0; + buf = drmm_kmalloc(>_to_xe(gt)->drm, + post_migration_scratch_size(gt_to_xe(gt)), + GFP_KERNEL); + if (!buf) + return -ENOMEM; + + gt->sriov.vf.migration.scratch = buf; spin_lock_init(>->sriov.vf.migration.lock); INIT_WORK(>->sriov.vf.migration.worker, migration_worker_func); diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h b/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h index b2c8e8c89c30..e753646debc4 100644 --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h @@ -55,6 +55,8 @@ struct xe_gt_sriov_vf_migration { struct work_struct worker; /** @lock: Protects recovery_queued */ spinlock_t lock; + /** @scratch: Scratch memory for VF recovery */ + void *scratch; /** @recovery_queued: VF post migration recovery in queued */ bool recovery_queued; /** @recovery_inprogress: VF post migration recovery in progress */ -- 2.34.1