From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 8580D1E8342 for ; Tue, 9 Dec 2025 15:04:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765292674; cv=none; b=tQiQcFaGklMOrE+D5sVUfW8DTb3c/XhI0RE4YNXXCpwJuHnIemq7XoQI3izERE5I0qq2BRBaBWTNF4ING1DRCVhNze4/fl/Qww4K6uuoP45oBZGZnA8fygjq0WsrEcH4dIYqAzRJVYchBw9RmpHf+M2zEUugOREo684cyy3Rq2M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765292674; c=relaxed/simple; bh=Na/pC0kVeCH56IKvI8lxJhknz8vSWeGqlxbZOiq0FaE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QU5p7/K/PwEATcJ2ytsQfPx4Eks66KOlSdf9z6+TNOWKCe4abrAMdKC3LlrJGV0Yic8VQ6N4HX+RaMS2pHnaHRQ/GDirGymxboP/Gxvnjza/os2QklTM0rzf54nMgQYgc4S8lojBaJ60131qSCBBOJVe5hB7g7mgYq5xrxjUs5s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Sewn7ldr; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Sewn7ldr" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-7ab689d3fa0so475973b3a.0 for ; Tue, 09 Dec 2025 07:04:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765292671; x=1765897471; 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=PfnacZa7lQk1UkoU+10PADVx4NiV/d9RSz8Lvu845xI=; b=Sewn7ldrGXOa4w4Z3eYzhD3GGO0ByqSM9DzTr7OqCMKaBc9tytLj6w7ZaUW1yZrl1d 1dZIcNXdVwfOYTeM+XkS7IJnHriBDuez06NAQFBzSDGtMJb3QhRQhU8x5jzQjeW7pWF0 8LLRwLL9F6OzrsOEU5pmcmJHtrtm5VfVuTrEDZEYvl3rhbR0VtjzkRcxCh9A/wtnzWI1 fGNMmtqJT17bTw0p0m/thY8mETzjDaSu5kKpgOG/nW1uctsDReyyNAKwDHR54elpqeWZ dNlU76R446DKZxKvJttjW8Diwq40tZU8Ju3BkD2rDbd3Jnal176uQmxK9RmJu5SPpCSo H8ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765292671; x=1765897471; 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=PfnacZa7lQk1UkoU+10PADVx4NiV/d9RSz8Lvu845xI=; b=qk3XOrKdvJOF9loRjgns9aRF1Tl/uPNeq5ztFKLkxPNAUir/8pCVS4f0D19edMsRzi LR9LrBU96cH3lXk2o5HaMWLiOSnkSiZMzVwjFWjfmcSKoVGStdAs/BMwDuEbtgP1ubzU 3RX5BV44GuND5G4B9q+LnunLFyL/bxH+P79H9WXn4Ymku7sxdW77GEmOpuYwkoyKAt6G AZOIWI8HzpouFwiuhddqZvQs2lcyiORbjT0uRnfdrHNyV2oiYGgGoSOkuEA+CDQBM9eO 7IaNNcZyaE/HeYjEqle+uhW5UCnqRanMGHTAsdQHtwtgs069mSP/9wenEHD6v2oQ15UP 8XfQ== X-Forwarded-Encrypted: i=1; AJvYcCVBgoeJZbXWEnpUDZHpXU5f4OzQfjyOhoFrDYlgLd4WgNoXq6GpkCRnApyrD6943e/BksKRYQC2YjKAKP0=@vger.kernel.org X-Gm-Message-State: AOJu0YyopI5j1E37eiqu5BRmBaUBqsqOXvwLB9YuuW/UEJE2kNyM0Xee GexoAut+YzRgJruKf3Bcf9foXwHKRe8geXDpoUip+AAtNrkeGMkADHSw X-Gm-Gg: ASbGncs/0gJovMJsR0clbPA9J3LfrloVFnmJwF69OAV+h6YWxwmivW19xBDqwGOZfC6 3HQnWCHV0PpYcQBXxTaz7LSmYAcUhVqbr7H7ypgx+ih76aYVtBpDpp0oT96lsTJ9Qdcr5SD/OQU /XOvdUPH5hqhe2Rfj6xD6XQfe7oUUCN9y78wI2ZvmAPBdXnd4IWHzVoLY0aWeG+ZZveMljDw9DJ 8mEwfbnV1JS+PFRqyDgfDy0I+k7FW+XwxjfMUNFCy9Aeuop1wGz75zKvnfDq8RvdsPFeP6L+f/3 58+qxSjpi6jtHeHaHLCR7hmVC2cCecuZsA0YEKUeTV4kxlOVqj3yB/bDlUXIMOY6VgVcAd+AwFW THlDzGVWlicgkJEY26KMf8toIyXIm9ZxS/Ba8RcDTwR5e6zzh1dBjBLpM9WxknxMaGwcPvG5kEZ vxpSTXwlSfB1aZr1cdctA= X-Google-Smtp-Source: AGHT+IH6fU4r16kU8MAxX63Y2MbZhh1Vkb7M4IyVPwitFIhNynOKo+wM4p1RzfclauryAhGCHkY8BA== X-Received: by 2002:a05:6a00:240f:b0:7ba:13f4:a992 with SMTP id d2e1a72fcca58-7e8c68c6d04mr6571572b3a.5.1765292670382; Tue, 09 Dec 2025 07:04:30 -0800 (PST) Received: from ArchLinux ([240e:47e:2e50:e3f:8b77:7554:2025:6aac]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7e2a0a008e2sm16396684b3a.28.2025.12.09.07.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 07:04:29 -0800 (PST) From: rmxpzlb To: sebastian.reichel@collabora.com Cc: heiko@sntech.de, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org, rmxpzlb@gmail.com, ulf.hansson@linaro.org Subject: Re: [PATCH] pmdomain:rockchip: Fix init genpd as GENPD_STATE_ON before regulator ready Date: Tue, 9 Dec 2025 23:04:21 +0800 Message-ID: <20251209150421.2229-1-rmxpzlb@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit >Hi, >> On Fri, Dec 05, 2025 at 02:47:39PM +0800, Frank Zhang wrote: >> RK3588_PD_NPU initialize as GENPD_STATE_ON before regulator ready. >> rknn_iommu initlized success and suspend RK3588_PD_NPU. When rocket >> driver register, it will resume rknn_iommu. >> >> If regulator is still not ready at this point, rknn_iommu resume fail, >> pm runtime status will be error: -EPROBE_DEFER. >> >> This patch check regulator when pmdomain init, if regulator is not ready >> or not enabled, power off pmdomain. Consumer device can power on it's >> pmdomain after regulator ready >> >> Signed-off-by: Frank Zhang >> --- >> drivers/pmdomain/rockchip/pm-domains.c | 14 ++++++++++++++ >> 1 file changed, 14 insertions(+) >> >> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c >> index 1955c6d453e4..bc69f5d840e6 100644 >> --- a/drivers/pmdomain/rockchip/pm-domains.c >> +++ b/drivers/pmdomain/rockchip/pm-domains.c >> @@ -659,6 +659,11 @@ static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on) >> return ret; >> } >> >> +static bool rockchip_pd_regulator_is_enabled(struct rockchip_pm_domain *pd) >> +{ >> + return IS_ERR_OR_NULL(pd->supply) ? false : regulator_is_enabled(pd->supply); >> +} >> + >> static int rockchip_pd_regulator_disable(struct rockchip_pm_domain *pd) >> { >> return IS_ERR_OR_NULL(pd->supply) ? 0 : regulator_disable(pd->supply); >> @@ -861,6 +866,15 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, >> pd->genpd.name = pd->info->name; >> else >> pd->genpd.name = kbasename(node->full_name); >> + >> + if (pd->info->need_regulator) { >> + if (IS_ERR_OR_NULL(pd->supply)) >> + pd->supply = devm_of_regulator_get(pmu->dev, pd->node, "domain"); >> + >> + if (!rockchip_pd_regulator_is_enabled(pd)) >> + rockchip_pd_power(pd, false); >> + } > >It is extremly unlikely, that you will be able to get the regulator >at driver probe time. The typical regulator for NPU or GPU is >connected via SPI or I2C, which will only be available after the >power domain driver has been probed. So I suppose this could be >simplified as: > >-------------------------------------------- >/* > * power domain's needing a regulator should default to off, since > * the regulator state is unknown at probe time. Also the regulator > * state cannot be checked, since that usually requires IP needing > * (a different) power domain. > */ >if (pd->info->need_regulator) > rockchip_pd_power(pd, false); >-------------------------------------------- > >I think the proper fix would be to add support for registering the >regulator needing power-domain's delayed and then enforce requesting >the regulator at probe time. That's not trivial to implement, though. > >Greetings, > >-- Sebastian > >> + >> pd->genpd.power_off = rockchip_pd_power_off; >> pd->genpd.power_on = rockchip_pd_power_on; >> pd->genpd.attach_dev = rockchip_pd_attach_dev; Thanks for your comment. This simplification is OK for me. I will test and send new patch.