From patchwork Fri Dec 22 12:28:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 182660 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1026048dyi; Fri, 22 Dec 2023 04:31:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMAB7d3KI0mnRcpyzsiC7s7lrqWXPBKor+q4jCUqTFepXDLT1R7eJFiU0i60OeUaja/joj X-Received: by 2002:a05:6358:290b:b0:173:22a:635a with SMTP id y11-20020a056358290b00b00173022a635amr1458007rwb.30.1703248294856; Fri, 22 Dec 2023 04:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703248294; cv=none; d=google.com; s=arc-20160816; b=V8CcIhI6gQp735LFBBtF155sIjJ4yHrXbkt8uVk+BwVsWHAJmGSMTsiyn/Rxkfc5z3 RqOG+k1X+x7UlX6Bznb8j1r73uNcoJOMs32ny9cbrywRyCfPs+ktJFAWXC7ozpqZQ2eX pz7BotzdNUhbOOy9v8XLj6z+t6LMBGBd16yOt3bmsXAKpNRVmJfFAzOja/Fx9PvXbYrM 4XpdE2lHNPjy/ofID07efcvZnfUMgYEaJLqdoxzk327+Sy2FWpH06JK5rj7/clvkhoUv bF2kZcJ2n16jzoS7E0oYez5cGPT+jmk8tphewWfTBnoZb7biPtATmxB06cAVPcI1Rz7u a4QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TRtiGIc23qKmjrBNJ6QQXiMnNcX8EOgP8YFUxP6ho8Y=; fh=yqUIIgKqVOYsTyZW6w8zcpjOuZt/iZwb7E0FG62Kafw=; b=cSE00mBACNWviLNBw1Msl+4ucI2VOAH/zDJmxfYAGiMw7uRhpKviFfX4+xI/MWIDJU AXYRJvtQxcpe7xYmwijb30vtsEvqg9S55HnWWc6dwMq14KfxqC5WW8MT+91KmZd9oGtc tkkojJpcWWrmuY3bbFyER/aSBis6UVM8Um3jUNzWgCmKHA3Q5OG6d57cMxnpS7WEvHZU +dMwYv4UgSn9OOQumCIeckPKcFJ/mc97f2y7UCD6KbY//IT6HpiR18xjPfk9oyPo7REB 54omua0fWpHRmoyNrp09TsnzmphNX+2XTeMY4E0Z6lB7A1BBvgm/fpdW4cJ1LL6sp1KI MfMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JXXrO801; spf=pass (google.com: domain of linux-kernel+bounces-9704-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9704-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id jc8-20020a056a006c8800b006cd8cddf8c5si3296280pfb.14.2023.12.22.04.31.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 04:31:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9704-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JXXrO801; spf=pass (google.com: domain of linux-kernel+bounces-9704-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9704-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1552DB23BC6 for ; Fri, 22 Dec 2023 12:30:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A56FE199A1; Fri, 22 Dec 2023 12:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JXXrO801" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE6C218026; Fri, 22 Dec 2023 12:29:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703248189; x=1734784189; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SPf7dIwu/u/tUoIaF73pw1QNlo/ef/Z/+GNbum46mDI=; b=JXXrO801MSdlKvcv99uRptsPnECD/eb/2tit8Cuquf9hTi9zMhTSYRaB +5n2Et2pIGDvsmov0XVqkWBQvygk80VzhU/CHFSaCS7oIaAyl1UvZDw39 cgI38674OliU7h9RlM7LI/xDCb0ofY54w9tKio4eqsC2V6rCOGPwmPpfB TDOraIWJjCeX8BuHuRnEmaQF49gzeaEtrm58Zwg8odGYNpo9IoUCl+x9C rhT/816JCeWNYoAPm/X+ZYYmUcCBd57aeQAD25UYa4SNfRr1NWwiRJu7L iPffobaqNuCBRgTjoDxkm36G2mq/EpOcWf3yKyZSDd8tmNCAwAtTOriQI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="3195422" X-IronPort-AV: E=Sophos;i="6.04,296,1695711600"; d="scan'208";a="3195422" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2023 04:29:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="950263970" X-IronPort-AV: E=Sophos;i="6.04,296,1695711600"; d="scan'208";a="950263970" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.94.248.105]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2023 04:29:44 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Igor Mammedov , Lukas Wunner , Mika Westerberg , Andy Shevchenko , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 3/7] resource: Document find_empty_resource_slot() and resource_constraint Date: Fri, 22 Dec 2023 14:28:57 +0200 Message-Id: <20231222122901.49538-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231222122901.49538-1-ilpo.jarvinen@linux.intel.com> References: <20231222122901.49538-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785985283950215466 X-GMAIL-MSGID: 1785985283950215466 Document find_empty_resource_slot() and the struct resource_constraint as they are going to be exposed outside of resource.c. Signed-off-by: Ilpo Järvinen Reviewed-by: Andy Shevchenko --- kernel/resource.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 94f67005e1e2..ed4bb8ad701a 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -46,7 +46,18 @@ struct resource iomem_resource = { }; EXPORT_SYMBOL(iomem_resource); -/* constraints to be met while allocating resources */ +/** + * resource_constraint - constraints to be met while searching empty resource slots + * @min: The minimum address for the memory range + * @max: The maximum address for the memory range + * @align: Alignment for the start address of the empty slot + * @alignf: Additional alignment constraints callback + * @alignf_data: Data provided for @alignf callback + * + * Contains the range and alignment constraints that have to be met during + * find_empty_resource_slot(). @alignf can be NULL indicating no alignment + * beyond @align is necessary. + */ struct resource_constraint { resource_size_t min, max, align; resource_size_t (*alignf)(void *, const struct resource *, @@ -629,8 +640,19 @@ next: if (!this || this->end == root->end) return -EBUSY; } -/* - * Find empty slot in the resource tree given range and alignment. +/** + * find_empty_resource_slot - Find empty slot in the resource tree + * @root: Root resource descriptor + * @new: Resource descriptor awaiting an empty resource slot + * @size: The minimum size of the empty slot + * @constraint: The range and alignment constraints to be met + * + * Finds an empty slot under @root in the resource tree satisfying range and + * alignment @constraints. + * + * Return: + * * %0 - if successful, @new members start, end, and flags are altered. + * * %-EBUSY - if no empty slot was found. */ static int find_empty_resource_slot(struct resource *root, struct resource *new, resource_size_t size,