From patchwork Tue Jan 14 09:00:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Karas X-Patchwork-Id: 13938535 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 D26B7E77188 for ; Tue, 14 Jan 2025 09:01:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6942310E896; Tue, 14 Jan 2025 09:01:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="k/ZU6Clp"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB76910E896; Tue, 14 Jan 2025 09:01:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1736845303; x=1768381303; h=date:from:to:cc:subject:message-id:mime-version; bh=3WWLMnYZ5EMxmxsR4sVaIJfErSdPSYO4hrhh783niZk=; b=k/ZU6Clp3UnjvpUSk/sKmWJO1Q/f01PKBqu4iqg2bNcqDMOqMO1mG8pD wD+soL/22VNBApoXtlIqG1LFQ1xAM2zCmhbTaTtarwbC1GMLdARLDehb5 oWtEBd0fx5Nq0yr643/4zfcEmy2hu5g6ipRW0qIomxFhsao5Tz+xvTOmu VJ+DVLKobiFR+dfvKJPFNPCi2p2cSWecyU9ebzn6mqF0qTnWBEFmYYMqy C+fXwEgE98D0hSfr8aOX6ZJYChMVbRaH7g5u5sboUggQM/X0vUCY9ZHq2 E3yF7ET044yQ38JxN4g0CNZH00t7h+2W2+d7rkntgBFGWoWRNQ/LanPBZ g==; X-CSE-ConnectionGUID: HG+w1PZ2RUSnO9BH/NVZ4w== X-CSE-MsgGUID: UwUfeBddRN+Ae9UWCIJwuQ== X-IronPort-AV: E=McAfee;i="6700,10204,11314"; a="47798714" X-IronPort-AV: E=Sophos;i="6.12,313,1728975600"; d="scan'208";a="47798714" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2025 01:01:17 -0800 X-CSE-ConnectionGUID: 50jVHR+XSLmu9Ors1n+vuw== X-CSE-MsgGUID: TZz2q7l4R9OVX+24K3Sptw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,313,1728975600"; d="scan'208";a="104507021" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orviesa009.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 14 Jan 2025 01:01:16 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44; Tue, 14 Jan 2025 01:01:16 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44 via Frontend Transport; Tue, 14 Jan 2025 01:01:16 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.46) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.44; Tue, 14 Jan 2025 01:01:15 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LrTuR6Lk4CXZCoM4cnZDPgAFfHu74zcn03Qr7dkf5Zm9CNxBP+L6VsmvtNrdZjjSC+PAPPDt0QZN1aKScwrosxOTgqTMUyxWZMcY1sb9Iw0xCTYZyrY9vaEMr1a8+VczytPzTcqI6I7XnPeCJA7cCkyt09yR7VKaQd+t/t/Eq1FVqEQBos2YSVZZSqrPZb16AJdjRSaJQaXPITU0VbOMyv7iDSitWQ3tsC/jMQQGeA9IP/COFKeCgie+5MfHzoOV1C6HeQnMBatXXGA3mzlOAtkIusaqRR/9YYQt7cY+Qe/KTyk0JZzBRyji9+TF2Bo3eBfB/xDdiVTvc46D5kB27w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RFnfj0wKm8pf75VqRy8z+wuzErWXew5PdsUDQ3hUOwM=; b=Vv6Oyydq5dDoeMbcJ0DS3v1aVCgOxPKaJfQ762FSqiyziBkgoOeLem3WC/rwNh8Z0VUHbISxtp66dQ8ej6m9MObgcQ4pJJeJ6WwMO6wV3LY4Jo8vk9+r73p59t+0jyq7e63WOaEe6uqyA8U4SEebKCc2FGuY8IEy7WmQZALmKdD96BCsX2gWDrlae1r2+ur4RgmRCoVAEeYzph49RCrtSe/6R7cAYBC0chLBbFD82lvD1JuFXdqIhDwICtzb9Xbc/jO7cWD177vK2067bLZgPYfcn+EW+nihS2+NjXynFkp3a3fX3wi3n7GS+tbJota35rDcbsL6pw+XIh+mOp43OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CO1PR11MB5057.namprd11.prod.outlook.com (2603:10b6:303:6c::15) by CY8PR11MB7313.namprd11.prod.outlook.com (2603:10b6:930:9c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.18; Tue, 14 Jan 2025 09:00:32 +0000 Received: from CO1PR11MB5057.namprd11.prod.outlook.com ([fe80::4610:6d6c:9af6:2548]) by CO1PR11MB5057.namprd11.prod.outlook.com ([fe80::4610:6d6c:9af6:2548%4]) with mapi id 15.20.8335.017; Tue, 14 Jan 2025 09:00:32 +0000 Date: Tue, 14 Jan 2025 09:00:24 +0000 From: Krzysztof Karas To: intel-gfx , dri-devel CC: Maciej Patelczyk , Krzysztof Karas Subject: [PATCH v2] drm/i915/gt: Ensure irqs' status does not change with spin_unlock Message-ID: <5fnb3l7s5hr3yfehkpvf4jgcunm6qclxagvssdobvfxbwtjiyc@jzko7kb7svud> "Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316" Content-Disposition: inline X-ClientProxiedBy: VI1PR09CA0099.eurprd09.prod.outlook.com (2603:10a6:803:78::22) To CO1PR11MB5057.namprd11.prod.outlook.com (2603:10b6:303:6c::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR11MB5057:EE_|CY8PR11MB7313:EE_ X-MS-Office365-Filtering-Correlation-Id: 4de9b839-d069-4ecc-1960-08dd3479e6d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hK/uKqnPh92T2EP5Sl9mpOlSf+gRKdQ?= =?utf-8?q?bfU1DtmjWuvhjBm/rIKtYP0j7vS4SNHG4LCzyLbCNLhsnoCh2bKZfDOwIP/UfqbDa?= =?utf-8?q?m344bu3GPqQi2eUwQ37NdXbf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BTC4vewQgtER7UofuEwaGEeK/Jm?= =?utf-8?q?yPD6MNnG50wrsO28G/6QHV6+T9YdxalBGL7FXF4UIoT1zwwcX/XUpWRwMyga9johu?= =?utf-8?q?uJgcB2gX1BCagNvuucbMOLCow7A/TQpBNRLN1kI5w4sD4jJJRON0f2ByHo4iiGk/f?= =?utf-8?q?Y08rehCp/3W5xwOnsPMEJfXSMQIyNuL2OvxoT3YT3AmzDlrQAkAAhkhgPhNQTJLNd?= =?utf-8?q?MeMO6hmyLdVrGBSKhek6y/TZE4yxFWS+UzwqB0uDachpyIwGu7r2zPum778IpEo+o?= =?utf-8?q?VG/kEpgRsiL4YPe7O67oKYMy/N6GPGVxBRLbwJI5d/C28Ry1bRkYldMbs+fXSkQLa?= =?utf-8?q?5Y/o+RwQjs01?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB5057.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RcMOKLoJkJQipFAzcvPKTheoYX1N?= =?utf-8?q?Eb1q1bSfOrVpeu14OwiNoeuPi16VRmJ4Zc9JJv4zuDHXRl1xg5INzNl0eQd2WbM/s?= =?utf-8?q?g1HuBeK0hGCwPduBGOHLg5nqLSmxmpBnoOPxPHERSluil0zzza19mdQuAQt05f4yW?= =?utf-8?q?BlHmzgdKBLSE1NyI6S9MKIiwBGZiK5l6aQssNDmpDxaVUQdz5TXfvxiidDLNDUAZN?= =?utf-8?q?yc8tSbzjV8wQIIzRQ4nZPKGI5xfdFqpYO0Lm2avgc6+jxbVm9moQCqWyDeKCdRoCY?= =?utf-8?q?T9LUVYH31tQe3YHt/mEJejNF2+2A/ZhRyIxnkg6s0MLBZQIlQpVLS+qS5FMZCVkcc?= =?utf-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njZtnzQFQ8t9UE0J7pb7?= =?utf-8?q?Rassk3OaqSq1gW2IdUf+q8usHbJD0UkEUZlBhkzOEbnBB/aFFfxNAno7uFBsjAhEp?= =?utf-8?q?haY7WMG1N7p37Yf307GTWp6KsYuKbeatW5Iof3qB5Rwojd3OS41aKuPb36CLaXLHw?= =?utf-8?q?cxLoZJhQM8G1OeF44fb5VHc6z+aWIIv9MwZg4DuUS+jt79RODRKPCUqjAFpezwYmU?= =?utf-8?q?VO/75in7u9tZwgQXKCYNN76+D3YxLj/7cJf8TOI9gEhlJyXvZu3w11KqtdY8GQgdg?= =?utf-8?q?vAUAoGINMDJlFxUV7GmF6UUKCziO+gfB52b85O6dYkYXygAXTKN2Nq9N2Fks7gcil?= =?utf-8?q?GPBloMfMGfYE5OjOAWMBBMMmXT9MYgAUQg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4de9b839-d069-4ecc-1960-08dd3479e6d0 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5057.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2025 09:00:32.7406 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1HXj1fjyQQb0s5JSUWfI1O6Nkh3EDTLFsmTqd1ifUDwd6mxm1E+UYPOq1cA6oM8C5vNhUokqUdtqPFmiDrhtxqwkyakMRKv970/5F0LQ8pA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR11MB7313 X-OriginatorOrg: intel.com X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" spin_unlock() function enables irqs regardless of their state before spin_lock() was called. This might result in an interrupt while holding a lock further down in the execution, as seen in GitLab issue #13399. Try to remedy the problem by saving irq state before spin lock acquisition. v2: add irqs' state save/restore calls to all locks/unlocks in signal_irq_work() execution (Maciej) Signed-off-by: Krzysztof Karas --- This issue is hit rarely on CI and I was not able to reproduce it locally. There might be more places where we should save and restore irq state, so I am not adding "Closes" label for the issue yet. drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 21 ++++++++++++------- .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 5 +++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c index cc866773ba6f..dd5542726b41 100644 --- a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c +++ b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c @@ -53,13 +53,15 @@ static void __intel_breadcrumbs_arm_irq(struct intel_breadcrumbs *b) static void intel_breadcrumbs_arm_irq(struct intel_breadcrumbs *b) { + unsigned long flags; + if (!b->irq_engine) return; - spin_lock(&b->irq_lock); + spin_lock_irqsave(&b->irq_lock, flags); if (!b->irq_armed) __intel_breadcrumbs_arm_irq(b); - spin_unlock(&b->irq_lock); + spin_unlock_irqrestore(&b->irq_lock, flags); } static void __intel_breadcrumbs_disarm_irq(struct intel_breadcrumbs *b) @@ -76,10 +78,12 @@ static void __intel_breadcrumbs_disarm_irq(struct intel_breadcrumbs *b) static void intel_breadcrumbs_disarm_irq(struct intel_breadcrumbs *b) { - spin_lock(&b->irq_lock); + unsigned long flags; + + spin_lock_irqsave(&b->irq_lock, flags); if (b->irq_armed) __intel_breadcrumbs_disarm_irq(b); - spin_unlock(&b->irq_lock); + spin_unlock_irqrestore(&b->irq_lock, flags); } static void add_signaling_context(struct intel_breadcrumbs *b, @@ -173,6 +177,7 @@ static void signal_irq_work(struct irq_work *work) const ktime_t timestamp = ktime_get(); struct llist_node *signal, *sn; struct intel_context *ce; + unsigned long flags; signal = NULL; if (unlikely(!llist_empty(&b->signaled_requests))) @@ -226,10 +231,10 @@ static void signal_irq_work(struct irq_work *work) * spinlock as the callback chain may end up adding * more signalers to the same context or engine. */ - spin_lock(&ce->signal_lock); + spin_lock_irqsave(&ce->signal_lock, flags); list_del_rcu(&rq->signal_link); release = remove_signaling_context(b, ce); - spin_unlock(&ce->signal_lock); + spin_unlock_irqrestore(&ce->signal_lock, flags); if (release) { if (intel_timeline_is_last(ce->timeline, rq)) add_retire(b, ce->timeline); @@ -254,11 +259,11 @@ static void signal_irq_work(struct irq_work *work) if (rq->engine->sched_engine->retire_inflight_request_prio) rq->engine->sched_engine->retire_inflight_request_prio(rq); - spin_lock(&rq->lock); + spin_lock_irqsave(&rq->lock, flags); list_replace(&rq->fence.cb_list, &cb_list); __dma_fence_signal__timestamp(&rq->fence, timestamp); __dma_fence_signal__notify(&rq->fence, &cb_list); - spin_unlock(&rq->lock); + spin_unlock_irqrestore(&rq->lock, flags); i915_request_put(rq); } diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c index 12f1ba7ca9c1..e9102f7246f5 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c @@ -4338,10 +4338,11 @@ static void guc_bump_inflight_request_prio(struct i915_request *rq, static void guc_retire_inflight_request_prio(struct i915_request *rq) { struct intel_context *ce = request_to_scheduling_context(rq); + unsigned long flags; - spin_lock(&ce->guc_state.lock); + spin_lock_irqsave(&ce->guc_state.lock, flags); guc_prio_fini(rq, ce); - spin_unlock(&ce->guc_state.lock); + spin_unlock_irqrestore(&ce->guc_state.lock, flags); } static void sanitize_hwsp(struct intel_engine_cs *engine)