From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796431369; b=suxD1aj53TSigHaIQxLfL7bHV1RejhpZjHvUFjim18dM8snu5VXOZ8EN3s/F5dg47k60 4XeA6rdiw3UTYnRqUcfKCMqyew/9jxnPydwiJY0njUPWpHBXEFPYUzIm9XlOI37JofK0q bMgi+EcQbCE6KnTpaHbwQP6R5h5lILXOeqUSktIxdMA6bxXR5fPJQKw4Tl6p4O5auyngI YD7EzK5MGnkrXHdMsq7vT8Zwdc0tTdWZQEOelwl21lBOGIjTrA2dP8ltXQLx1A34C2tmj fHZJfBcI4FXd5yPFwR4wUxFp0dPXdhBzl5jtPUQDkWCxdjZbTG/nM/8j49LxP3MKAOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796431369; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=RNucDOdQaOrsTstdCBZpYl8g5yBiwXnm78nXmD9ZPVI=; b=3pGQCBEJ95ijf3T9+tgc6fgEtYMEyLE4op9vOXp4i/n7aU+kw5FYEvsISwxJKqSobtmj VS4AT2A2wOur5OXHBL+FTHx9UD2a/WqfbZC1u8YnWQN4xq0D9jgqt42RaKpw80juUaesB kTHaruB354jAKSPSfjLb4+8rgQqCySe2mKyQrv3m3kkOSGRfaHUZXapRjR4QKsbylmVrV Xu9r+YYoy6LVHU9J+/EXWOyhARthpLRK6uByLZfEqIvWJU/h9eTYONLNR8Iu25dnZOPfu Q4J8jsuTaZc++sGCMFUSDVPwPHEE2Ct0iUkXe+Z6Vjw5RsqlThM7Vk4aXpL5QKqD6bg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b="lUq/l/jj"; arc=none smtp.remote-ip=192.198.163.5 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.5]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 582D6606A322 for ; Sat, 5 Dec 2026 00:42:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 582D6606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lUq/l/jj DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796431369; x=1827967369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YXzfugKJv3jBi562TPNMur0ZPPjBeBOa9aCBHOhkqMk=; b=lUq/l/jjRXZBJR5jlnw0CQDOXCx4thJRdCXztshF7i/tQ6O+sAeeyko6 QOqR+3N3BWEyKJXlI24YKUpyzLYaWs8JVxhlmVPrE2ZiwCqoRsQnPiy70 n80DC4yD/NoA6NFkg6Fx/c7KZs0pMhSgGDXEohLfuSv9zKzy4Lq/mGdlb 8KS036RL+Et/Z/+/5b/547CL9b8Rm3bTO2UUx8+778EcI9Y03NMPeAGVZ h8azfHYbqidS50hauyzTCZaM1yL2VsT+rluDxowaWyxsPvjkRd8ueTg4w anaZs+2cgMhOzz+AkANsnNXexEQRnwLDsONj3wfPVFPIbM49Mra69rPeV g==; X-CSE-ConnectionGUID: pX0fmSsCTMyQHXnh/xdDxA== X-CSE-MsgGUID: pzvKU+rCSLaQsfZa+fnObQ== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="100886" X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="100886" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa115.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 16:42:48 -0800 X-CSE-ConnectionGUID: RAgoDYdkT4+8PZcpqlckbQ== X-CSE-MsgGUID: ewJ9AsUFQ/KeixRxwLdEJQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="14068957" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.245.47]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 16:42:41 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Matthew Brost , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , =?UTF-8?q?Micha=C5=82=20Winiarski?= , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Anthony Pighin , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 12/16] resource: Add release_resource_locked() Date: Sat, 5 Dec 2026 02:39:47 +0200 Message-ID: <20261205003957.3304-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261205003957.3304-1-ilpo.jarvinen@linux.intel.com> References: <20261205003957.3304-1-ilpo.jarvinen@linux.intel.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit release_resource() takes resource_lock, so it cannot be used to release resources while traversing the resource tree under the lock. Add release_resource_locked() for callers that already hold resource_lock for writing. Signed-off-by: Ilpo Järvinen --- include/linux/ioport.h | 1 + kernel/resource.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 830d621907b7..60d15191bcc3 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -265,6 +265,7 @@ struct resource *resource_tree_next(struct resource *p, bool skip_children, extern struct resource *request_resource_conflict(struct resource *root, struct resource *new); extern int request_resource(struct resource *root, struct resource *new); extern int release_resource(struct resource *new); +int release_resource_locked(struct resource *old); int release_leaf_resource(struct resource *old); void release_child_resources(struct resource *new); extern void reserve_region_with_split(struct resource *root, diff --git a/kernel/resource.c b/kernel/resource.c index 5e3853610b58..18127dde53b8 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -321,6 +321,22 @@ int release_resource(struct resource *old) EXPORT_SYMBOL(release_resource); +/** + * release_resource_locked - release a previously reserved resource + * @old: resource pointer + * + * Like release_resource() but the caller must hold resource_lock for + * writing. + * + * Return: 0 on success, or -EINVAL if @old is not in a resource tree. + */ +int release_resource_locked(struct resource *old) +{ + lockdep_assert_held_write(&resource_lock); + + return __release_resource(old, true); +} + /** * release_leaf_resource - release a resource that has no children * @old: resource pointer -- 2.47.3