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 91C1CC77B7F for ; Wed, 17 May 2023 15:23:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6CA9010E44B; Wed, 17 May 2023 15:23:48 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 47E7F10E449 for ; Wed, 17 May 2023 15:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684337024; x=1715873024; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AshnQ7rClLuO1/+2nS7Klp7BiHKPvx28kqZHwZ2ForE=; b=RCx+ilhygAsAe8QrUuuNw7+H6WQ3vKxjNS3pQY2fvp1Qnmi6Gc6Dql/y RXzHyZv1xyvG2cpZSIxLewxxCDmzHvHglxwK/xCsEGcMduLdOx//ltget FHIWXY0bbwSDwGq+Mk9h/NNoUo7Q4RYRASV0teZM2IsDFR1yxjtox2aFo iWG7n8eEjVXRxD/EUYz5np6rzw6YRsL22TgS6DLMdTEhxZm7SPuCknkKA KfDnyMQNgYva8Z8f5w1uRz1RQlRSDIc9o4+ouJ7OWpFnbZ0x9uELehWs+ kl1fLDI0rAUpwTg0xt7yqk/pjgvdNd08zxTdCWJd2jgDezUSRfOI0DL2v g==; X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="438132155" X-IronPort-AV: E=Sophos;i="5.99,282,1677571200"; d="scan'208";a="438132155" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 08:23:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="846129311" X-IronPort-AV: E=Sophos;i="5.99,282,1677571200"; d="scan'208";a="846129311" Received: from fskirtun-mobl-g8.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.252.15.194]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 08:23:43 -0700 From: Matthew Auld To: intel-xe@lists.freedesktop.org Date: Wed, 17 May 2023 16:22:42 +0100 Message-Id: <20230517152244.348171-5-matthew.auld@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517152244.348171-1-matthew.auld@intel.com> References: <20230517152244.348171-1-matthew.auld@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Intel-xe] [PATCH v5 5/7] drm/xe/ggtt: prime ggtt->lock against FS_RECLAIM 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: , Cc: Rodrigo Vivi Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Increase the sensitivity of the ggtt->lock by priming it against FS_RECLAIM, such that allocating memory while holding will result in lockdep splats. Signed-off-by: Matthew Auld Cc: Thomas Hellström Cc: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_ggtt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c index f986e8218820..e25eb70d44f6 100644 --- a/drivers/gpu/drm/xe/xe_ggtt.c +++ b/drivers/gpu/drm/xe/xe_ggtt.c @@ -90,6 +90,16 @@ static void ggtt_fini_noalloc(struct drm_device *drm, void *arg) xe_bo_unpin_map_no_vm(ggtt->scratch); } +static void primelockdep(struct xe_ggtt *ggtt) +{ + if (!IS_ENABLED(CONFIG_LOCKDEP)) + return; + + fs_reclaim_acquire(GFP_KERNEL); + might_lock(&ggtt->lock); + fs_reclaim_release(GFP_KERNEL); +} + int xe_ggtt_init_noalloc(struct xe_gt *gt, struct xe_ggtt *ggtt) { struct xe_device *xe = gt_to_xe(gt); @@ -132,6 +142,7 @@ int xe_ggtt_init_noalloc(struct xe_gt *gt, struct xe_ggtt *ggtt) drm_mm_init(&ggtt->mm, xe_wopcm_size(xe), ggtt->size - xe_wopcm_size(xe)); mutex_init(&ggtt->lock); + primelockdep(ggtt); return drmm_add_action_or_reset(&xe->drm, ggtt_fini_noalloc, ggtt); } -- 2.40.1