Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp761725rdb; Fri, 22 Dec 2023 04:30:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFM/q5bX1td50h9WFhV72X7GOCINEJTr4Xro9IXLFmzDJxYo5aiqTemWxu5pWyj51xNJIWw X-Received: by 2002:a2e:9ac7:0:b0:2cc:6dde:b9be with SMTP id p7-20020a2e9ac7000000b002cc6ddeb9bemr588628ljj.18.1703248229354; Fri, 22 Dec 2023 04:30:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703248229; cv=none; d=google.com; s=arc-20160816; b=A0bU0DfLLgBZGWThQOkqtSTf2ywlTCK+sMBT8nm8+ogMH1egXYCEG6MzwlUNVKv6Ym nKDY+6w/8bQGYyvAa7MgQCYelQ45H88iNO8ToZUUsWFCVJk2uTvcadpLepbGHjaO4uoc YMlmhOdpQoAxUmX+tdrrNbJcxZvoEf/Fu+vmJoATwn7SF72azoaXcb00/KTsAvHeX/rv QZBPnXPyJdBs68CidpeI6Y2P1x7w+7Z+RrBvHkbHVfdazz8HCUwymvpey9+wtVZcoIY5 0h9iu/K1vEeqVHVmr5Xx0VsIg7s8CSY+Mf5F95dkL1Gd9t1+47k3/hEUJ1Q1n0A5Ga6Y T0DQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9704-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j20-20020a05640211d400b0054c652bd5a9si1789235edw.440.2023.12.22.04.30.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 04:30:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9704-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9704-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 12B3C1F25E6F for ; Fri, 22 Dec 2023 12:30:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBE6118043; Fri, 22 Dec 2023 12:29:51 +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=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Igor Mammedov , Lukas Wunner , Mika Westerberg , Andy Shevchenko , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 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, -- 2.30.2