From patchwork Thu Jan 16 10:40:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Karas X-Patchwork-Id: 13941563 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 4A212C02180 for ; Thu, 16 Jan 2025 10:41:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8FDA110E93D; Thu, 16 Jan 2025 10:41:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="WIijitTQ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A62C10E0CC; Thu, 16 Jan 2025 10:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737024063; x=1768560063; h=date:from:to:cc:subject:message-id:mime-version; bh=emqR0W7R3imhMSy67pdyFeMVHQ+6Z7r04W/XAYgxtGU=; b=WIijitTQQyE/RbkM/ckYjYZ7e+zkTAfmndnL26lAyEr6QbI4x+7jVAHx XqkJDv2VIZ6jLidTaetzVD8yvkrwrGmE6GudyP2fYPv7ihN1eOva0yHLU +0oup9nkgXHBdW+mBP89ZuGAZQo3p80kY9Ti8J+hMGd1POLqiCFlvkrs3 zBH8otwHR8kRVEdL59p82BgA+UkaWUgEf4ncOlISv3EPdnX+tvHwcGswf wPiV5o/decjFFdaNLqNFhC5HrI4Kxu45U9b0lm0xzwhRXDkjeM71jproZ jWe4LUzrS0MXLYYs4osi2kSltJ1NBoFSW5wh3FT/aTQJH82RPU7qn9GGV g==; X-CSE-ConnectionGUID: wgbYgrwsTwCrviGm53UyPg== X-CSE-MsgGUID: tckPk8RlT4qNstoIu8HAGQ== X-IronPort-AV: E=McAfee;i="6700,10204,11316"; a="41081514" X-IronPort-AV: E=Sophos;i="6.13,209,1732608000"; d="scan'208";a="41081514" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2025 02:41:03 -0800 X-CSE-ConnectionGUID: Tyj2d8R+R5ONROfWWN4ecQ== X-CSE-MsgGUID: Gj350qMDRBmET6S1NA6p3Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,209,1732608000"; d="scan'208";a="136294206" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 16 Jan 2025 02:41:02 -0800 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) 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; Thu, 16 Jan 2025 02:41:02 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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 via Frontend Transport; Thu, 16 Jan 2025 02:41:02 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.47) 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; Thu, 16 Jan 2025 02:41:01 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jHPJpWs0Bnfiju/W0/ztjYE1DCozwe1Ewi6UGcqeHtsqctKyRvpaA2/TNmjEq0MFLEkx7OlWyJa7X7qQyIrUXFOUDjeqr4RGJ9JJskJ5ntHbwWwqRQfF046KhELsjURrukD7GllLzWHjSuVDC0URc90ByzBzV4yDiZGv0Xx8zadSIsM/f2gaXs1eAwJ6drFE/+byXSaZ4BhG4eYghUAkTq7K+7tCAsF4g3OVMVdfr0B5RTmU7VYkFwrDJbsyDEZAmC6oerQVvDmXZSfPRd6DawZJtHaNRewnXDtAkDJpK5crTf6Nbpn+aW1l/Qyu6SSylF3+4TSh6xqSvJTTQJvyCw== 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=7q5Q5z2aPerH7PkDne21DhFeZHM0hsB2u4eR1NwVGwQ=; b=W4/VPpX32SlpVVa5YMFLMI73v6ljRJDuWOHLUqTUwaoNdeFzHRlhGsV5zgxQO01Hazze9MTPNjoKjRg0Km1NjmMnS1a2y2bipt6/oQFe9TSYIdKUanJUh9E3GKVplFk1iVPGbDnroJbkuoVzjWrldxpbgCBhiEqb6iXNuGKHrkYYjmQUKS1KMRfy4VYT4EXicBotYVrf5N4KUS6kK3YfjxKHMhoKJUZaUHO9SPQc0Bny5R73gh6TPWn/Yh+JCQ6w/2pYsSWMxThz4Uq/+Zel4SKYyShrGT4Uo7E/NAQ0tBOeAgP4ZcPpGB7ETft/3DN9qLOPFy7NEUfLLf+s1wEPwQ== 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 MN6PR11MB8104.namprd11.prod.outlook.com (2603:10b6:208:46c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.13; Thu, 16 Jan 2025 10:40:59 +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.8356.010; Thu, 16 Jan 2025 10:40:59 +0000 Date: Thu, 16 Jan 2025 10:40:46 +0000 From: Krzysztof Karas To: intel-gfx , dri-devel CC: Maciej Patelczyk , Tvrtko Ursulin Subject: [PATCH v3] drm/i915/gt: Use spin_lock_irqsave() in interruptible context Message-ID: "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: ZR2P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:53::19) To CO1PR11MB5057.namprd11.prod.outlook.com (2603:10b6:303:6c::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR11MB5057:EE_|MN6PR11MB8104:EE_ X-MS-Office365-Filtering-Correlation-Id: 01de1da8-5759-4290-5e97-08dd361a43d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?LHUCyeKPCjHysLLHaF8csT6eASdcGAQ?= =?utf-8?q?bt18dTuYENOOtd3HMPim/I974ItS5HffV+XshLxCDIDhl2mhStD47GkwzXERz2uDG?= =?utf-8?q?CrAt6dpsf1woxoBz5oSlZ3AWyrlQHWGXMbMpH5Z1kvqSuIG81VCi0YB6R/o7EmLmq?= =?utf-8?q?fJvzlakn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XxpRAxBqw8XRa/eHZHGXeLXcL9StzuzqqGClp/DzO2hMVp3vesdV8F+?= =?utf-8?q?gBkyA7lvRSKmY6lXuQfafp5hqbV6H4rUa3NyZVhNPFbpweSHrne351IYbmz6Rr0r3?= =?utf-8?q?avyVcPDSSdF5a8igs90pg8HnV1z5D8btWk2q03R+EN2fNRENbOUY3pjnsJLLm7lOm?= =?utf-8?q?54olI5QCdpATHasHZ61v1SuIPYG8Wz6zlyFcXK+vq6mE6DWF+8lGXjd287G4JZ/mf?= =?utf-8?q?DEJDMBWHZdHkQvaJGg1FTQMaqXmgLd7seKQ=3D=3D?= 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)(366016)(1800799024)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3ISA25eLhBGhWMyDwgI+Be+NVl6y?= =?utf-8?q?tJEilhJJ+KhvcXT0BQh5GtfW+ItqsB97Is0U8LXMToRCnC2gYHqZOX6bWnUJ39nGA?= =?utf-8?q?7gPPYqfys33vHYwcXVi9nA2V0BRu/aYokdGhwcgKmIR7jTPqKYgs3ThTQtU9fJONP?= =?utf-8?q?OqV0GMSpsD45S+n6uh+gyF7gOb4DcO4SG9Elhs86lbXR9nDMiMgU55/x8UIgXJdMW?= =?utf-8?q?G0FpeuDxLTuJ+q5MWtE2EnAVkkGZDcGiQAxK4g3p7qVlgNC1e8Ga/VMkFPE8Wi1af?= =?utf-8?q?ed2dgIRtNOsVGO7HnYgTMBuUlspGUc5UffvcrLSsuFOxuGC8uobiaFKUruVhK0j9g?= =?utf-8?q?N/AYBsdSLCj5q3WGY5Lx/nEpKrh4lTBJ6zwOjky9uEbSR0ZLJaKATO2SXlo2ZnhEE?= =?utf-8?q?s9hbofoJFZ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-8?q?OYXyuwPskaAi+A3rmdA6NeQQ1FbsBQumluIIx/bu/ptwYvWwMrirMbQHze0mj2b7I?= =?utf-8?q?2E+x07ZybX428mt9X0djO0u8P/DQPfdzv/BVzujMj5CE4k1fDUeY1DPZtMs0qfXcJ?= =?utf-8?q?M61ca8uXlOK+Js80xjoM9ukLIRoXx8MFW4gc8ZtBxAwpNYkTVVMbfI2FqKomMM1xM?= =?utf-8?q?vbZpn30dtv9AWa+yaXK5UywGcL28AasWY88qGbNH/85XVHy9vfsgnZbqXf232Iy1+?= =?utf-8?q?kkYWo6Vlasia6g4ptq3CR0oZ8BtSQ/goQw=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 01de1da8-5759-4290-5e97-08dd361a43d5 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5057.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2025 10:40:59.2808 (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: fUvL8+IIhPCYKVjgYoz7IDTITaBxk/bV8jKPz8f8DZb2QVvQUL9LE951NjX6mGxd12JqAsCRrEjHx9QzNDTnauN11zkRx3I1hsU1+aklZwg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR11MB8104 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_lock/unlock() functions used in interrupt contexts could result in a deadlock, as seen in GitLab issue #13399: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13399, which occurs when interrupt comes in while holding a lock. 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) v3: use with spin_lock_irqsave() in guc_lrc_desc_unpin() instead of other lock/unlock calls and add Fixes and Cc tags (Tvrtko); change title and commit message Signed-off-by: Krzysztof Karas Fixes: 2f2cc53b5fe7 ("drm/i915/guc: Close deregister-context race against CT-loss") Cc: # v6.9+ Reviewed-by: Maciej Patelczyk --- drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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..29d9c81473cc 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c @@ -3433,10 +3433,10 @@ static inline int guc_lrc_desc_unpin(struct intel_context *ce) */ ret = deregister_context(ce, ce->guc_id.id); if (ret) { - spin_lock(&ce->guc_state.lock); + spin_lock_irqsave(&ce->guc_state.lock, flags); set_context_registered(ce); clr_context_destroyed(ce); - spin_unlock(&ce->guc_state.lock); + spin_unlock_irqrestore(&ce->guc_state.lock, flags); /* * As gt-pm is awake at function entry, intel_wakeref_put_async merely decrements * the wakeref immediately but per function spec usage call this after unlock.