From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796140897; b=Pdgy6n05dbl42bw9GwF5MJmPz2kQlw+PscC+mGD7DIBdlMwM58AzZe5rTvNLpwGf4D/e RT2pAYIBM5W9QlBOf3oZlzF3/+nltl7tA+EO4Nte5IMA6Tcln+plPEs7sWIHN0fmH5Bsr sPMwO9e0yOeogR/6NWAiamT5AQqwgvFqSY0gf2gEwFaUdjMHuPcJDN709p4YymvzFdbwM TAPMVQxAeYYtUtiWdZRCYpb6wX1WeG2Qg9UQc9AB29rjZPKco+mKfGsftuivEkHKwUlnT qJocLuxZk4mC0sDMvsIa+884L1cF+osz/hmPVUquNSrOu+JJqSyA3VPHiY9k2UvwUVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796140897; 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=CD+54LYdQIiPHom2AFOtwNG1Q8XACTZiFzAHTye93C4=; b=RV2W1ttGXqi/LiT9ZwZcL42TPyDE+eS9kxB6RwK77wn7a/CPN+VxOs/v+d+6hq9lFYEd NyoKODiAu/DHSuw794bH5LYUdl4UkPtEeSFAHnn+ZRJRpFk50Ze0OLjf5bto3rSldz6II cz19wQrGwfeVEd0aDotCaVUyIg/VhyE8Sp9mlWKM+WGMVSCHbz4JzG+b2cxX9o+q1fSrW JgM28McLeYITmIdmM/Mvv3ntqzCRvu+w5SIFzSVJ5LA8beYYFpOBOd4iJEkXD5pqzMJCX AkOZ9SWZq8DSmNg301xKrFfCfGpnEMsGZyGYiSvWrMy56KYZ1mX1fmjxN5TFht3jKSA== 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=OLEs8G6I; arc=none smtp.remote-ip=198.175.65.19 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 5C587606A320 for ; Tue, 1 Dec 2026 16:01:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5C587606A320 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=OLEs8G6I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796140897; x=1827676897; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CD+54LYdQIiPHom2AFOtwNG1Q8XACTZiFzAHTye93C4=; b=OLEs8G6I6HXTZjAptZHfVAGrHtcSB9nPypGM/BeY1SqOQ7IYNzs+3k7w DwcqKVY5k8lgN6GVGepJXQ/R13ldlAiEj7TG6upOECUpq5ySOGAYylCie pV4JXqnOkDlYh1cz76W5o+FmrIfLjFD0t1QQJEvYG5zPzT72T2FDGim77 /mv3eDs+YoA7IJkrty10T1mKIffsZoYofj1fDUU3fw68CbSDh7IFMX6ZO 4IEcXZCeNTQ8m0zxNfs/I3Pjl1ZoaFaiZ3BNz3TLkUPyMLZDlvHlDTlp5 ICpkd1xmoPlSuZ1YbeQn+mG47JNmNzu8h84lnt5LmZeti6bZdaX2U9lop w==; X-CSE-ConnectionGUID: 4LSeSsNdRAym0wOyrdDP/A== X-CSE-MsgGUID: t0m/q4MdRHCBdiXvpCGfgA== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5098438" X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="5098438" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 08:01:37 -0800 X-CSE-ConnectionGUID: +fwEPXE1RaSL0RXwCNp4Fg== X-CSE-MsgGUID: YrmP3NAHSkG4qn3aGVNh0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="13399642" Received: from pgcooper-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.245.21]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 08:01:30 -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, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 12/15] resource: Add release_resource_locked() Date: Tue, 1 Dec 2026 17:58:36 +0200 Message-ID: <20261201155844.2278-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201155844.2278-1-ilpo.jarvinen@linux.intel.com> References: <20261201155844.2278-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 fbcbdae99887..35bd2fb91619 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