From nobody Thu Apr 9 18:03:00 2026 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 2251F423A6B for ; Tue, 3 Mar 2026 13:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772544209; cv=none; b=LyTmr4sARrj6i19K4sKpXd9HedL2fvBy65BsUl3Xt7P/2/9NLoC4hzA3IwMZNMSEJB/82lq/SsfybICrSKXP2dGhKsc9J7P0KrjTK99d1YDZFcDnTkTTe37M9YZ0ecAN8x5+5UZN5xOrvnYLnKrDbpyrJuEXKROpCyoBCXnZ7cU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772544209; c=relaxed/simple; bh=ryqZNJNqA365MRETYNHzz0EgbqcaPN3QUhG1y3UNT1k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VvTnfK4BvXTT4NMNUtQy2bsOxHEuYGendVf7XMrChulaJV2eKluvAG3FwpXZEFIisJyTuAHMJlWXAtN9sb8AbtYGRI09R/HgwVPxluXa+mQY/Vq/Lj+07e5VJbBx5KIuhIe8WBh71SA7fCZ6eIyJ4GgbDsG0D8FJNk6S2ZqMjEo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=FGiQqSp5; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FGiQqSp5" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-389fb626b67so91116481fa.2 for ; Tue, 03 Mar 2026 05:23:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772544206; x=1773149006; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DY+Uv5zbRZBrLkNEfOsAHSSzgZnf3SBlBifVwXPv9CE=; b=FGiQqSp5IG0COcpOM7SJNzO17LE8sv93D+xXaEHMFkO04tU5VOyrTgE0yW2GeAHkVn EEXcWqM8g/ryaLhTbYoWto66jlo4BKe6ZODaJ9FJBWRuLiTQr5CU+cgFMGOaBn1h1Ue3 /ouIOdZsKx5po6Ux4HdoxsKHt4O2cAx5+CN4NipbwkkTBTZwtpghO8pOEuAtK/bK5Xha hFjWN+IlwLxweCMlfNnn+fiRe3A9jmlRQ1s4MoSFrgXE5sNczlOWbg3hzPf08viabZd4 ZzTEj2YI+PhpJMuSYzpwoRk5robWrvhGsNI47Cnwcc5ECkgXBEg+RHX4iuKxVBap/maP B9oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772544206; x=1773149006; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DY+Uv5zbRZBrLkNEfOsAHSSzgZnf3SBlBifVwXPv9CE=; b=qj8UHjqayoiWv5TcVp6Gj6Yh+S3lB1N4eijV5ZG5gNFeXGBr8EWHE58ogCJi9L5TGW pIY2qZ83EeXV49n1n9evgnikgm+xXpAAPTg8+g/ouIzUAzK94HIccrBpkcQYU4mtIdHa IfIKN4cnUuCfoQ8snd7zo/p1sLB56BlVKc+oT9sELZvsFViCB9pXyl0hkSHM3Ba8mD4U DEsrNibs5cSXFpuZWCr0iifVh6s9huxf5TiLiEE6wKAMg/X7rY0p/Z6VZ9CUHhUQ3y+6 V7f1VkVoYNu3FPooZOpk1x8F3d3xdMo7PHV2Bm0IdHyBCTGr8wWFUDWbRPDSIrp2Zid/ 2Dlw== X-Forwarded-Encrypted: i=1; AJvYcCVeiRkukz1+DHwN95suDsQqayEFRh4KFSwAwRICTuiMRagVhUq2r50zWm85AE930O4Z/wtb6LcmGzceK2Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yxp8p4n1IOdgjbakZW74+y4BL5Lbh5ibWa/gf2ITFKMF0h+bagB ekzh0+F6R+zsOHYjw9Lai9XmU/FfiisCan2CwvyS2/HmpD3XYFv0KNm+JqbIqxBKmgM= X-Gm-Gg: ATEYQzwn7U2IwTjezx6sEtM46/fnPuAwAIaG2c3hUa4Ru9nBU1tJZeMky1xrGQ+GZnR ilkb+9qI/kQWXogVECL1qV4Vay7tDPk3BcLUMm0VWJu45ksxpZe3D4wPr51WnZyc+nPtCmE77SY CNrbNAohHg/s04Tfl7rTKVFxuw4M8ImhSZSe98cX/vRl/K7b5TreRHpJMeEJtxL/XLJmmNkb6do e8ww+dewh9ZBJZ1N7fByZtVb4WKV8K3pFhU0lbYTecwIRiuN5kE7kPKuQERBtj7LH7fVtWgHAqC a0wGUlUveIVLMmtMl5dP174QpLN2lS+o5Cb50fZXaxPyBAbHvY5LL8rJe48KloXiu0ubRhLh04J UDWLMhckKSlR9IU7/DuaoA/XlGTnK5yRop1jSRQebbaK0Bw/lq5vBk+CJ/hSBzznHx67++imhng ZMHmsVY1g69BqagKtsMndIdnZRuYobK0XqTP6SQN5hNR7EIhp3JzMXGgDwCxgAktYVDrAdC182 X-Received: by 2002:a2e:b896:0:b0:389:fd52:a1d9 with SMTP id 38308e7fff4ca-389ff141f4fmr91698381fa.14.1772544206259; Tue, 03 Mar 2026 05:23:26 -0800 (PST) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a1235811e3sm587866e87.29.2026.03.03.05.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 05:23:25 -0800 (PST) From: Ulf Hansson To: Saravana Kannan , "Rafael J . Wysocki" , Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: Kevin Hilman , Stephen Boyd , Marek Szyprowski , Bjorn Andersson , Abel Vesa , Peng Fan , Tomi Valkeinen , Maulik Shah , Konrad Dybcio , Thierry Reding , Jonathan Hunter , Geert Uytterhoeven , Dmitry Baryshkov , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] driver core: Enable suppliers to implement fine grained sync_state support Date: Tue, 3 Mar 2026 14:22:47 +0100 Message-ID: <20260303132305.438657-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260303132305.438657-1-ulf.hansson@linaro.org> References: <20260303132305.438657-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The common sync_state support isn't fine grained enough for some types of suppliers, like power domains for example. Especially when a supplier provides multiple independent power domains, each with their own set of consumers. In these cases we need to wait for all consumers for all the provided power domains before invoking the supplier's ->sync_state(). To allow a more fine grained sync_state support to be implemented on per supplier's driver basis, let's add a new optional callback. As soon as there is an update worth to consider in regards to managing sync_state for a supplier device, __device_links_queue_sync_state() invokes the callback. Signed-off-by: Ulf Hansson --- drivers/base/core.c | 7 ++++++- include/linux/device/driver.h | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 791f9e444df8..a262714a83b6 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1106,7 +1106,9 @@ int device_links_check_suppliers(struct device *dev) * Queues a device for a sync_state() callback when the device links write= lock * isn't held. This allows the sync_state() execution flow to use device l= inks * APIs. The caller must ensure this function is called with - * device_links_write_lock() held. + * device_links_write_lock() held. Note, if the optional queue_sync_state= () + * callback has been assigned too, it gets called for every update to allo= wing a + * more fine grained support to be implemented on per supplier basis. * * This function does a get_device() to make sure the device is not freed = while * on this list. @@ -1126,6 +1128,9 @@ static void __device_links_queue_sync_state(struct de= vice *dev, if (dev->state_synced) return; =20 + if (dev->driver && dev->driver->queue_sync_state) + dev->driver->queue_sync_state(dev); + list_for_each_entry(link, &dev->links.consumers, s_node) { if (!device_link_test(link, DL_FLAG_MANAGED)) continue; diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index bbc67ec513ed..bc9ae1cbe03c 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -68,6 +68,12 @@ enum probe_type { * be called at late_initcall_sync level. If the device has * consumers that are never bound to a driver, this function * will never get called until they do. + * @queue_sync_state: Similar to the ->sync_state() callback, but called to + * allow syncing device state to software state in a more fine + * grained way. It is called when there is an updated state that + * may be worth to consider for any of the consumers linked to + * this device. If implemented, the ->sync_state() callback is + * required too. * @remove: Called when the device is removed from the system to * unbind a device from this driver. * @shutdown: Called at shut-down time to quiesce the device. @@ -110,6 +116,7 @@ struct device_driver { =20 int (*probe) (struct device *dev); void (*sync_state)(struct device *dev); + void (*queue_sync_state)(struct device *dev); int (*remove) (struct device *dev); void (*shutdown) (struct device *dev); int (*suspend) (struct device *dev, pm_message_t state); --=20 2.43.0