From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12C903F9F2F for ; Wed, 26 Aug 2026 21:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787781547; cv=none; b=Ld/N2dd2bFZNUh+PGfROYvNRsi8RC5SmrBywpkCvzA8DqTtfLozcWSYqMOpwkkQ9XjtFxJ9SWuaxwYzHyQKMCZSvVGai9/O5g4/14zbpjGQotNtuwYqehHcQr4ZfAOsiRn/jNxUxh4DmIqW28eTOqoX4BcshONPPvwXQOpgb41U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787781547; c=relaxed/simple; bh=qB2XYjGj60iW7URffgCn7dX+4S/gyULRetO7qyDA24s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=POlQYWfDFXmIBr0tsebd0mmIdF8nQ0GPPYbRYSYewskOJZIc9bTkYUrnXut994Z3lRdT1tQl8An6C5eH5uCn6E4zezT2w48x/iSpQUU6+1DoiRRMBPMgbwKbUEubyVrRRFxvimov1lu1GHYt66fo012Hhz05DvjvrAuT/TTWPPI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=NgZQHoJY; arc=none smtp.client-ip=209.85.215.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="NgZQHoJY" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-cc1c73645a1so860377a12.1 for ; Wed, 26 Aug 2026 14:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1787781543; x=1788386343; darn=vger.kernel.org; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZWfPZEMYmXjEOVTtuUiqR7EFAvZfcV1y1MLY6LFEEyw=; b=NgZQHoJYJmN7FLqCxvtgqLR56drY6tQXAy1XwQEAdz9zqtnDKo54vA/epd/VFz1iK4 jop7fRHwTYOGMQOUHyt2VXsYvvMnoi0dN3zKBzOXcDuXk94wFL9ifm0dGXBSV7khQckR ZHST1VpnCp8sVKnGlkkPvSiJIzsym0iREo8zrHeF6u/eQHMQZOsK1uWctQYIMnfM8Pgw GMcKip/raFqr7aYiwzxpFRDEFkUekn7cSGOb6qnCv9PufzSz1m/DmKp8IrIHgFCXe9Y3 3FCjNIfJtwFJVoamFIZ7j9oB9JWZ09KF9nkwTEoTd7Pwo/ZibXE4gbh46D/rCTP8AKeM HiYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787781543; x=1788386343; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=ZWfPZEMYmXjEOVTtuUiqR7EFAvZfcV1y1MLY6LFEEyw=; b=kyIuDDDMZbT6I4bJ5b7pUpi1txWPNkSmG1JAkQ+ryE3GgRlhz80j0uNzr5e+MYzIIt zEDGLNBcv19ctKvp/wzTyPzIzdouXEaxABM4R+nSIRIgjK2BRTGATeoQsGU2RBCkVkNi OLehcpZkFDGRWE3c/SQbiJIlPuH8TOhYFvKV/45+/3k/zUT8JOi+NZRcrk1YlkepvZuQ o//AcqGLeV+igx3dUk+s7f8f0mY2e8YcXYY2EsZgeSg1GKYjDDQTwGWH1dM9c7L0xQHk tfT1RV93R3AV4UgKs8/2DY0Z8cZ0Bj4EWTNGSJPpjBcMHRrf7qOmSHMvf5t+iYmHvB+I BagQ== X-Forwarded-Encrypted: i=1; AHgh+RrLuLEEny6cfEB73ZWFUCm1zAwKYzyYe7Bi4lky9jjiWhbU5vJY+NxWaEDe0NYZCtPYkaIO+fvCCYFuiCc=@vger.kernel.org X-Gm-Message-State: AFuF++lTX5kUkRXJi9JhSFTx7SUqqdTt89bTXkqkdLc9RLOq5aIATW/F kYuuXDo0c+FaCqI9DUDN3CG9YYOqIAdh+6yOVO0XofkWEUherbh0hNUeIK+t6MxCUsY= X-Gm-Gg: AR+sD11hPiprY+e/p0UGh6pdRwF9fXctk5ihnaZ9tzPsgTcjnn+oWcuBnc3EHvtI7z4 2SuO0XjRmV4kGme+y71NWdT6ECRlMVobFyuvgeG5xB7SsLntUqISVANLygNQP+S5/NN2OjZn3Tf TT5fJUiuIQgLF6NRw90DdkvEc7zBEmoS+HVCJljuBPbpc9ZmyoKy2rq+FwG5QmFv3BSuLL6pOOy avFXOxkVZMleGqvsnurERoywMCR9xTiEsfnst0ikGAQAj5egyExcixzMINCMroohAutc5a6APns iMDsXoB9mvXXRn4LoDn+bbfWiKBpSbWrR+FFW04mi0lvk+9PZu9gNw3XUj82BSBledhMdXJRKXU SNLNQMU3EvQFA3RIriNWfS3I3ff1hCr4m1mUK9fxHh81nJS/diiUXz+w9bs5TaW0Il+mNPtiqkh bICFleJqS2VnUftZ6PuEd9ACpR5fgR6njIX3qnQOTmWYzgSXxZYAnrrbfYL86LJH4M2q0d X-Received: by 2002:a17:90b:1d47:b0:38e:2e86:ed02 with SMTP id 98e67ed59e1d1-3966d458714mr20922013a91.14.1787781543124; Wed, 26 Aug 2026 14:59:03 -0700 (PDT) Received: from localhost ([71.212.202.210]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-3965547159asm8327576a91.12.2026.08.26.14.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2026 14:59:02 -0700 (PDT) From: Kevin Hilman To: Abel Vesa Cc: "Rafael J. Wysocki" , linux-pm@vger.kernel.org, Ulf Hansson , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 3/4] pmdomain: core: add genpd_for_each_child() helper In-Reply-To: References: <20260819-topic-lpm-pmdomain-device-constraints-v4-0-7ceb095f5474@baylibre.com> <20260819-topic-lpm-pmdomain-device-constraints-v4-3-7ceb095f5474@baylibre.com> Date: Wed, 26 Aug 2026 14:59:02 -0700 Message-ID: <7h33w08rx5.fsf@baylibre.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 Abel Vesa writes: > On 26-08-19 10:08:38, Kevin Hilman (TI) wrote: >> Add a new internal helper function genpd_for_each_child() that recursively >> iterates over all devices in a PM domain and its child domains (subdomains). >> This helper is useful for governors and other core PM domain code that needs >> to examine or apply operations to all devices within a domain hierarchy. >> >> The function takes a callback that is invoked for each device, and supports >> early termination if the callback returns a non-zero value. >> >> The helper is defined in a new internal header drivers/pmdomain/core.h and >> implemented in drivers/pmdomain/core.c, making it available to other PM >> domain subsystem components. >> >> The first user of this helper is the cpu_system_power_down_ok() governor >> function, which uses it to check device QoS latency constraints across the >> entire domain hierarchy. >> >> Signed-off-by: Kevin Hilman (TI) >> --- >> drivers/pmdomain/core.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ >> drivers/pmdomain/core.h | 17 +++++++++++++++++ >> 2 files changed, 62 insertions(+) >> >> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c >> index 842c4169e290..ff27369d9a97 100644 >> --- a/drivers/pmdomain/core.c >> +++ b/drivers/pmdomain/core.c >> @@ -24,6 +24,8 @@ >> #include >> #include >> >> +#include "core.h" >> + >> /* Provides a unique ID for each genpd device */ >> static DEFINE_IDA(genpd_ida); >> >> @@ -276,6 +278,49 @@ static void genpd_sd_counter_inc(struct generic_pm_domain *genpd) >> smp_mb__after_atomic(); >> } >> >> +/** >> + * genpd_for_each_child - Recursively iterate over all devices >> + * in a PM domain and its subdomains. >> + * @genpd: PM domain to iterate over. >> + * @fn: Callback function to invoke for each device. >> + * @data: Data to pass to the callback function. >> + * >> + * This function recursively walks through all devices in the given PM domain >> + * and all devices in its child PM domains (subdomains). For each device found, >> + * the callback function @fn is invoked with the device and @data as arguments. >> + * >> + * Note: this function is inteded for use by the core and governors, >> + * not for pmdomain providers. >> + * >> + * Returns: 0 on success, or the first non-zero value returned by @fn. >> + */ >> +int genpd_for_each_child(struct generic_pm_domain *genpd, >> + int (*fn)(struct device *dev, void *data), >> + void *data) >> +{ >> + struct pm_domain_data *pdd; >> + struct gpd_link *link; >> + int ret; >> + >> + /* First, iterate over all devices in this domain */ >> + list_for_each_entry(pdd, &genpd->dev_list, list_node) { >> + ret = fn(pdd->dev, data); >> + if (ret) >> + return ret; >> + } >> + >> + /* Then, recursively iterate over all child domains (subdomains) */ >> + list_for_each_entry(link, &genpd->parent_links, parent_node) { >> + struct generic_pm_domain *child_pd = link->child; >> + >> + ret = genpd_for_each_child(child_pd, fn, data); >> + if (ret) >> + return ret; >> + } >> + >> + return 0; >> +} > > This is usefull, I like it. Thanks for the review & feedback. >> + >> #ifdef CONFIG_DEBUG_FS >> static struct dentry *genpd_debugfs_dir; >> >> diff --git a/drivers/pmdomain/core.h b/drivers/pmdomain/core.h >> new file mode 100644 >> index 000000000000..7061891d31fb >> --- /dev/null >> +++ b/drivers/pmdomain/core.h >> @@ -0,0 +1,17 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +/* >> + * Internal header for PM domain core >> + * >> + * Copyright (C) 2011 Rafael J. Wysocki , Renesas Electronics Corp. >> + */ > > Year and author are wrong. Oops, copy/paste. > With this addressed: > > Reviewed-by: Abel Vesa Thanks, Kevin