From nobody Wed Oct 8 14:20:57 2025 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 A055E2609C7; Thu, 26 Jun 2025 21:59:37 +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=1750975180; cv=none; b=WKHCwckUo27TWJYxGxkQwaypM+2sf9dW0K4HDinYOv25+6loTDAU0yROBI+JUokt5fVjsL7DUmjQd0CgMRPUGV4GKovFkWY3eQJ3Wq+uChW4hv8bfpUj2jc6SQOE2+oWuKCtLYU50N3lxuyhgmaCbCA2J3hqtl0P7OuYBoBprQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750975180; c=relaxed/simple; bh=UufGGLlkb3UuTQ0EXDh1Zt5ACyC08b6N5Er0XaAmRE4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oEEFdA+nrpueiDTR1DY2HSOey2qUdfn6NKzZETSKUCugmAqUsxm/OI8A9wnFcqD4S9HTw+6WwwWEfBtzacmMAnN8bJ2P44aJ+OZSZ74pdALKHcDW2/GWk2y7dB+/fjX26JCoQFdYnh8w5xAZl1czDbn/X2gfhHPKfi6SD1RmZbM= 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=NWC8rccl; arc=none smtp.client-ip=209.85.215.176 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="NWC8rccl" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-b3182c6d03bso1810509a12.0; Thu, 26 Jun 2025 14:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750975177; x=1751579977; 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=MqUm180eQDox8Xlw05sxg5F58P/BrEE00f+0gmB6rO8=; b=NWC8rcclmk1NhEISpJL/1RUPd5RMQ2vTR4m89Oq4ubnTQ9+ofXbDSCD+3vUuoqfR6W sniw2W5kab3Z8IrantmaRcPszxV77obIP8ZInzfiUaf2ihPPF2l9nOy9c8jeh9W/yF2n zIdoWm+SmXrIwx3AFueayyAdYNhlmWFASLOprxwjGLfHIrIWJ4m6HWI+MiSL3Jj24i2K jtQRlGJJcBqS7oyUCBylQC/Q6HCezY5s2aQxo1smipUyEc0phpTNlUxMJgakitHQPDPX rokmVoN3x0aHS7OjJKGUCWW4+6w8x+KrLC77uZMXOY2YohTREpbRf/8dN0JU62ufZH6A 0kcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750975177; x=1751579977; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MqUm180eQDox8Xlw05sxg5F58P/BrEE00f+0gmB6rO8=; b=ux81bZowlPaK+pKcQGh8FZcWPU3nPvLELZ9qUBVvPTVTEY2neWVfEUgbiChbUYeXWY YkFkPOwJL9SppiwuPN8j7G5hJHKTY8HHlSJjHSa59pePYw3kg+/kaJpv6dV+f4N2c6z6 ENHNGBdlVGDgwKJ+lS0D1ac3Q9Sy74Ri9hagqsgUOFPdBcXFlPgn0BbGQH67dOe/uBZ/ XF0Pux6umbjGFaK79z/9PUqjK58oiLc6ikj7j0BnrE9pddm4TzPooOxb01KSr68cWPKA 4VZM2p9OGV5GetJ1HefZREO9ELM1ev9Bo1w3Lbv8ehlapmj2/AqQDfFkBN7/lc+G4EBn 25Pg== X-Forwarded-Encrypted: i=1; AJvYcCU5l5edGwcalb7CzpI+Ehh3HTUq1coMXoARxZ6EkoUjVbwvRV4HY/njARUxns/gykPflc8uUkta1KALqnQ=@vger.kernel.org, AJvYcCXR5SZ7woGtXQkz8OAMpU3BDlRRpMl1Tqm/nPeo+IMTIDw/EHvzhxpvRUS1MvvTOV5Dr+6aqpjfHG0=@vger.kernel.org, AJvYcCXjlSWUpbYnkpEyreCEEBD2tfclzTCB/SitPP8NzkqFE4ZHbFi4bm0E681bhk4p8knc2flulITYwdjC9KBSr/8TCQ==@vger.kernel.org X-Gm-Message-State: AOJu0YwMObRshoJiNOlHBb7aypMAAJQoh+zLas5HbQQQTuyhRo0DZmEA R/RCSiuSa44kPULapEMudnvCE1hnxBnLwPn3MsKCM370bN7UaVW/jrxb X-Gm-Gg: ASbGncspy/PLsZfeyIgpLlze6u4ovkKRxwzHI/18KdSQgnbr3DPx4cnmDU9oJwDtxjQ OHhn8AV6YAgJpzfJGksxYqwrGchC6DayVNtE2Elfxd+wsRrTKLOc91P0pJucTGpl36Gk6VNxZuI IjnOvx4YK8v2qNsOSRTrmtTuFkgJ0wBS2rY1d91GO/Z+8BN1ABh4T9VkGXlB3EJv4dRnYRUiuT8 CB1gsArLxOfN21/qJazAzJR2MPcSdpt0jWbFJFYw5+aNpBrcLzCZiMzYf4CyzKog5XT/AencRoa ldR7Xa1ecGJE9W7dAUTTVzUskEBUZjOCgUb8aLPeUornL6FOJu/VphXLpu6YmdZfEDfZczkzFCn xnaI= X-Google-Smtp-Source: AGHT+IEj6BGM+Mz3MmkFvPoHUKb7LLDLDubf4oTZNcLqHe+6ea1uskvJ137D58tQnmG8MNIGyCBZFg== X-Received: by 2002:a17:90b:1643:b0:311:abba:53d2 with SMTP id 98e67ed59e1d1-318c92ec11amr909084a91.17.1750975176799; Thu, 26 Jun 2025 14:59:36 -0700 (PDT) Received: from localhost.localdomain ([2804:1b3:a7c3:c88d:6da3:af6d:a237:3289]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23acb39b8b9sm585275ad.118.2025.06.26.14.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jun 2025 14:59:36 -0700 (PDT) From: Hiago De Franco To: Mathieu Poirier , Ulf Hansson , linux-pm@vger.kernel.org, linux-remoteproc@vger.kernel.org Cc: Shawn Guo , Sascha Hauer , Bjorn Andersson , Hiago De Franco , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan , daniel.baluta@nxp.com, iuliana.prodan@oss.nxp.com, "Rafael J . Wysocki" Subject: [PATCH v6 1/3] pmdomain: core: introduce dev_pm_genpd_is_on() Date: Thu, 26 Jun 2025 18:59:09 -0300 Message-Id: <20250626215911.5992-2-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250626215911.5992-1-hiagofranco@gmail.com> References: <20250626215911.5992-1-hiagofranco@gmail.com> 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" From: Hiago De Franco This helper function returns the current power status of a given generic power domain. As example, remoteproc/imx_rproc.c can now use this function to check the power status of the remote core to properly set "attached" or "offline" modes. Suggested-by: Ulf Hansson Reviewed-by: Bjorn Andersson Signed-off-by: Hiago De Franco --- v5 -> v6: - Added Bjorn reviewed-by. v4 -> v5: - s/dev_pm_genpd_is_on/dev_pm_genpd_is_on()/ in function description. - Updated function description to be explicit the function reflects the current power status and that this might change after the function returns, especially if the genpd is shared. v3 -> v4: - New patch. --- drivers/pmdomain/core.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 6 ++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index ff5c7f2b69ce..2f387e15cb75 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -758,6 +758,39 @@ int dev_pm_genpd_rpm_always_on(struct device *dev, boo= l on) } EXPORT_SYMBOL_GPL(dev_pm_genpd_rpm_always_on); =20 +/** + * dev_pm_genpd_is_on() - Get device's current power domain status + * + * @dev: Device to get the current power status + * + * This function checks whether the generic power domain associated with t= he + * given device is on or not by verifying if genpd_status_on equals + * GENPD_STATE_ON. + * + * Note: this function returns the power status of the genpd at the time o= f the + * call. The power status may change after due to activity from other devi= ces + * sharing the same genpd. Therefore, this information should not be relie= d for + * long-term decisions about the device power state. + * + * Return: 'true' if the device's power domain is on, 'false' otherwise. + */ +bool dev_pm_genpd_is_on(struct device *dev) +{ + struct generic_pm_domain *genpd; + bool is_on; + + genpd =3D dev_to_genpd_safe(dev); + if (!genpd) + return false; + + genpd_lock(genpd); + is_on =3D genpd_status_on(genpd); + genpd_unlock(genpd); + + return is_on; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_is_on); + /** * pm_genpd_inc_rejected() - Adjust the rejected/usage counts for an idle-= state. * diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 0b18160901a2..c12580b6579b 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -301,6 +301,7 @@ void dev_pm_genpd_synced_poweroff(struct device *dev); int dev_pm_genpd_set_hwmode(struct device *dev, bool enable); bool dev_pm_genpd_get_hwmode(struct device *dev); int dev_pm_genpd_rpm_always_on(struct device *dev, bool on); +bool dev_pm_genpd_is_on(struct device *dev); =20 extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -393,6 +394,11 @@ static inline int dev_pm_genpd_rpm_always_on(struct de= vice *dev, bool on) return -EOPNOTSUPP; } =20 +static inline bool dev_pm_genpd_is_on(struct device *dev) +{ + return false; +} + #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) #endif --=20 2.39.5 From nobody Wed Oct 8 14:20:57 2025 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 5A4B6267B61; Thu, 26 Jun 2025 21:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750975184; cv=none; b=cEDoGC0aTMryjKPVbrEzsj3beIjjPXATLvUEPa7D9m1T6e5e58e6nLVjMvAJx+4uYswH45lKvdsJ1d9vc4Q7FrkxAfVSWKDpM2BQ/004TmpG47L8zvtjbU03dlg5MV/nTs0UIZeYCXujEAR88WiXKTdFxnchxcDSDbDLgt3bLOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750975184; c=relaxed/simple; bh=HGCefvJVkJYHUUtIEx37dq0fjaTZbRZcwkr3/SvRe/Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dKa/HcnF1IIwYnNt8v3vAThO4+7ji1WcJlPQRrZCtaSwLsxlCs7ku1SWR+Jur5YkjtOp2+zKrZLYpT/ttpcnSdP32kh34pM/jQUobwg4NQr9r3LrOuxaSmh1cIr2ylEjo5O7bu5YNiJXTbNxolZFfGU8iJw4ABx2u7+hzl1G3So= 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=YddFxxTR; arc=none smtp.client-ip=209.85.214.179 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="YddFxxTR" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-234bfe37cccso20374145ad.0; Thu, 26 Jun 2025 14:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750975181; x=1751579981; 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=19+6eq/UcLTUhcGPnlhBGclygh3KIPHQ5cqQpFzjJBc=; b=YddFxxTRosLKsyqLu/Y5FjV75dEPfumkvM9Q+Y56Be/+DIAUfHBL02Qmsgu6QeKxru JHG6LYTXJLp61z2raVDno/8Nvt/uKPeENqlVZpJLVFxbDs1nDqGb1xcYjzvA0B9oUMN6 PkfN1J6zVyOXCS6fDrapQzusTpEfiFJ4dJkbgysd9Ypf+ugV2nggdDNf0j7jiAq0O5YK wDvtuyCWBlyrdpY7jBQIawQORLQmCYgKL3IXitDLjXFoCDw2XzBkbYGcciHzVsfMXPHD mKq5ZypJAKEntcz2M15VnlxYJjvBUQGRbWqAiRyHEwuV8GKrHOsD0SDVVrGv6cNvgylp BUGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750975181; x=1751579981; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=19+6eq/UcLTUhcGPnlhBGclygh3KIPHQ5cqQpFzjJBc=; b=bWklFbqJSbrI1pBpkVdgIV6Gn3kEuK/ACjUdCzlWc49ro+LpPHZ5vc/FFMaSxvni6S iUF9tLRiOSMygco5fX3kYtj0UBGe/3gQazVmzpr7MZEyqrwWF4aJBgVieK9RnAYs24We 7DoDI1Z3lBEV3KzVMa93zJihARzqNx0/vkDXzSfMF6zyeOtwswNm/3XYgHXtD9tkAGNT D8TITgRqsZduiEdIA8C5iZ4ApZo16i+sRYozmOfz0u2tGQpxo2/DOdPw0mNhWEpl24hm E3D2yK4mFHwryZREJ5OQFgue9v7yTXXVveSi0OMNcelYrYsRPDlGoxo3Qp5tUKRjKyaN CgcA== X-Forwarded-Encrypted: i=1; AJvYcCV4afO4xCyC9VX7q5zIU1wWhWCIJjQGW0VcIZ2TkeyCpimBCXUW/ZS3q7pD4YUPq8VLGHsqt6M7GEXKgpf35I17Xw==@vger.kernel.org, AJvYcCW3N/HOi9mZF8bzNYZfc//BMK3MmWLregRp0P+GD6zwBCKmnQ6j8j99GsPtaXkhN0AnYiMsh6Uqu3tQMqg=@vger.kernel.org, AJvYcCWo3Lx1+9cEbq1AtVeYCedQ2XWuoo0dxmqVNqOG+U8nN1FYc7YY5mFRlrBBKB+tMOl8G7gwpTRAagg=@vger.kernel.org X-Gm-Message-State: AOJu0YyJXpstjksk03bhW9SaYJn/MKp7CG6dCJtQbdPIdtqTiuJsCOUA yPYeA1jPxULU99NQ0TLr3Mru+Y04J9beGHHoa5XBzlWC4YyhytBlSfGi X-Gm-Gg: ASbGnctvBsGRXYzjwisFQ88qFnRn3diVNl8NnmkCrb0+4rBV0yl1IMv7iblhMPVnvfs xFmA0JNgypj0UZdXaoT9F0uF6VC6posjNxxUTrCRg8VUR0mDbZzEt9iO4a/k+1E4v/mXx3f7giM ujKOX425BlXksYBQO3/AiBlsbUZ7C3hHwQ4bvCpjOiunoMkzzhFnaT6ZVsr1k2724xzy3Gk/34j Yj3oTH6s+dwIJaMbwQfKeq01UnAp1C0THfZbh/8KEeAnjh90S7+aoEhQzC5YDfE362U+YpS/sDJ VlWa2MA2QyoDeCkt4HgnvfbxpMwVEkvfxHinwMVrmptJHZDo/3Kpc2Cj2+kJ4hwbtmqxakod29B wsjo= X-Google-Smtp-Source: AGHT+IFGHYw7pNh3YY2ppWd/GXJ7nll6kZo8n/rfheAtH7R1R5QnYe8TH6ojABszFWMLG+uP4MGkOg== X-Received: by 2002:a17:902:ec89:b0:234:8a4a:adad with SMTP id d9443c01a7336-23ac46824a1mr12395525ad.26.1750975181615; Thu, 26 Jun 2025 14:59:41 -0700 (PDT) Received: from localhost.localdomain ([2804:1b3:a7c3:c88d:6da3:af6d:a237:3289]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23acb39b8b9sm585275ad.118.2025.06.26.14.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jun 2025 14:59:40 -0700 (PDT) From: Hiago De Franco To: Mathieu Poirier , Ulf Hansson , linux-pm@vger.kernel.org, linux-remoteproc@vger.kernel.org Cc: Shawn Guo , Sascha Hauer , Bjorn Andersson , Hiago De Franco , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan , daniel.baluta@nxp.com, iuliana.prodan@oss.nxp.com, "Rafael J . Wysocki" , Peng Fan Subject: [PATCH v6 2/3] remoteproc: imx_rproc: skip clock enable when M-core is managed by the SCU Date: Thu, 26 Jun 2025 18:59:10 -0300 Message-Id: <20250626215911.5992-3-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250626215911.5992-1-hiagofranco@gmail.com> References: <20250626215911.5992-1-hiagofranco@gmail.com> 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" From: Hiago De Franco For the i.MX8X and i.MX8 family SoCs, when the Cortex-M core is powered up and started by the Cortex-A core using the bootloader (e.g., via the U-Boot bootaux command), both M-core and Linux run within the same SCFW (System Controller Firmware) partition. With that, Linux has permission to control the M-core. But once the M-core is started by the bootloader, the SCFW automatically enables its clock and sets the clock rate. If Linux later attempts to enable the same clock via clk_prepare_enable(), the SCFW returns a 'LOCKED' error, as the clock is already configured by the SCFW. This causes the probe function in imx_rproc.c to fail, leading to the M-core power domain being shut down while the core is still running. This results in a fault from the SCU (System Controller Unit) and triggers a system reset. To address this issue, ignore handling the clk for i.MX8X and i.MX8 M-core, as SCFW already takes care of enabling and configuring the clock. Suggested-by: Peng Fan Reviewed-by: Ulf Hansson Signed-off-by: Hiago De Franco --- v5 -> v6: - Commit description improved, as suggested. v4 -> v5: - Unchanged. v3 -> v4: - Unchanged. v2 -> v3: - Unchanged. v1 -> v2: - Commit description updated, as suggested. Fixed Peng Fan email. --- drivers/remoteproc/imx_rproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 74299af1d7f1..627e57a88db2 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -1029,8 +1029,8 @@ static int imx_rproc_clk_enable(struct imx_rproc *pri= v) struct device *dev =3D priv->dev; int ret; =20 - /* Remote core is not under control of Linux */ - if (dcfg->method =3D=3D IMX_RPROC_NONE) + /* Remote core is not under control of Linux or it is managed by SCU API = */ + if (dcfg->method =3D=3D IMX_RPROC_NONE || dcfg->method =3D=3D IMX_RPROC_S= CU_API) return 0; =20 priv->clk =3D devm_clk_get(dev, NULL); --=20 2.39.5 From nobody Wed Oct 8 14:20:57 2025 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 327BF2641C6; Thu, 26 Jun 2025 21:59:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750975188; cv=none; b=LKWghVVcJ0d3bMmTP+yo8D8Wa8ki1GfNP8i85ekhoyqOTJUWsdBEtlDewmOmMI4lUqbdn2aWHPOIUnyNdt65mfiEpsSUsP48gUQyOgc2HCs1rktyyO4JH9EJO+5Ie4oRLcY/aljIJhzxVtzWpthYNz5fEPQURpgfvvdFYBbsBro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750975188; c=relaxed/simple; bh=k3zq9pu7WuH1hHhTGsaYg2LsWiWO/Oz0cFzLmODzdr8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ojshfQSUHC2a9urx9yKZEfpczFDX3JF09V2Aq+Jh1gnb2goo0scjd4onb++yZGbs+rPhhTbyngxspNgP6AE5Bu5O+kRSsflpDrTLrNMaEDAkoeiwB0puDqmE4ES86BTGTBpVZHldGjNwg/dEkga+Vwn8TgJxgZ34M8BhZVwbKt4= 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=f9bfy5sZ; arc=none smtp.client-ip=209.85.214.182 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="f9bfy5sZ" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-236377f00easo20280075ad.1; Thu, 26 Jun 2025 14:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750975186; x=1751579986; 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=0AuC+j/+IsbYylelRyqiT00La77hywMse6Qq0j4Ebms=; b=f9bfy5sZpywrFisyrSTR/Mh9L6RME5TBYK3c83V4ssSmcT6RxHv0CnscFtB8WrQ3st 6Q8A0JtameGNQ/eRkRHzvw9dE7QFo1PAbwhykj+OyhUrL99eXtBVMZX9nThyET9JrhQE niBobz/4KH3HHyp3Ns/+28wsi2cmwXGBnjVow1bgODv030462lIHVWTyw2YKUk8wYdkS ikkRJPDxTd2jKBrKqkqCHa1+LUnNCOtifCy4JqAonpMBX58Gz6T4roX7zS12Mr6txZ7z D6NOh9jQn7J9Mo6ETVvgFbU9ZHW9tunz8MvRpqqpgRiXuDQaTmwko5/3I5t8X8A/5lLV oeLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750975186; x=1751579986; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0AuC+j/+IsbYylelRyqiT00La77hywMse6Qq0j4Ebms=; b=TmZlwg4sQXz9GQ1cPsJMUdE9HAvu2PVNKrknzuIPEqNS4GuzcxYyqggk9ax31Ml4eH pEfRkRd8r6dOdmC0l1Ta9QdZQ58rRdlbZc503QC12a9q4Yj/j53TZmWqVFKsimASyzBe LpOBsycLPXrcSF1H66hEKmJFMq1XcCpc4jBfw/8pycBDekkfjBlxO+YdzzQ6T+1SLC/v bImfoS6/DuPVLJCJPadJIqQqHqUkCKHyBeNAYpuaQEhsCRXoQCUX+MVoOtkihSfrLOWv 6E8nJae2RoTuCdJFOZef0zozuPM9LXa+K/0GAhNFGjllEbBXt2TnNmmndRpyHRtYivP6 B7CA== X-Forwarded-Encrypted: i=1; AJvYcCU1eRrkgcNBSaJYnZDVYYeA0MtBkQichyccITD3bsFNJAUKeELJKxSw7uioSH84+uS/4Tg7uPQk6qi/YjY=@vger.kernel.org, AJvYcCUrao/1R7y9H9gOWQEEDY2HYBka0/YvqQwu9aSZf9RTCk05zEa4e2UGCnu+jHvoIFuNWTMyc84jC7Xb+ywZnmEGTA==@vger.kernel.org, AJvYcCVg38EvGxgsB6sF8emFoc3vG4dHCzO8tI8Pst1UvPhISAgJoXbjpctlVKFzJBqd3E+CiyqAC5TnMkk=@vger.kernel.org X-Gm-Message-State: AOJu0YxiA/BOpim/Ste2WNho3NQrVPs03Ndxc7qk2i6et7gq5GnLn3oO vb8qrqo2pfxniIfUCVx20KPzqU0Bxsn7SHg9mluiSVU+TdUyzH9frVYf X-Gm-Gg: ASbGnctpa+6vBLQQCAatNK0fg7KCoqdHXz7YRQwCtbBysG0p6/aLm1PXwEj2y3AZBlK DzNGXMH4RWDzxN95mmQeCs8b0zZ9fd2pb6Y1v+qsozucOih36sFqv4NbZY6OoVp/mSFYOTcB2Zf y56fGgdlHoHbIZzVtLVaT+fwKdewhB2hdBjJmq4R6fwZZIZnF36lgFId4mD5q283JeQnQB3IkqA ac5s2zNLvP1h/sa/PdS//zn1J2qpOEfRNgeROccMIqHq9otJVFMv5RZbjj95Oc1c6FQ/E6QTkGa RMYDakTbaam+ruOzjZX0L5m3ZNQXXryG37LWfi3aH1t4JPTylBtH6JoiYbHL2s1QWgOjlPhDLcm JAV0= X-Google-Smtp-Source: AGHT+IHYm6yWXmePXx+iACWxwFDVihZU8YA/nUsAgOctnIRwFpQL3m8bnSqHAPDOWVIimwF958Hqrw== X-Received: by 2002:a17:903:19ce:b0:236:6f5f:caa9 with SMTP id d9443c01a7336-23ac4605d7cmr12135545ad.32.1750975186333; Thu, 26 Jun 2025 14:59:46 -0700 (PDT) Received: from localhost.localdomain ([2804:1b3:a7c3:c88d:6da3:af6d:a237:3289]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23acb39b8b9sm585275ad.118.2025.06.26.14.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jun 2025 14:59:45 -0700 (PDT) From: Hiago De Franco To: Mathieu Poirier , Ulf Hansson , linux-pm@vger.kernel.org, linux-remoteproc@vger.kernel.org Cc: Shawn Guo , Sascha Hauer , Bjorn Andersson , Hiago De Franco , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan , daniel.baluta@nxp.com, iuliana.prodan@oss.nxp.com, "Rafael J . Wysocki" Subject: [PATCH v6 3/3] remoteproc: imx_rproc: detect and attach to pre-booted remote cores Date: Thu, 26 Jun 2025 18:59:11 -0300 Message-Id: <20250626215911.5992-4-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250626215911.5992-1-hiagofranco@gmail.com> References: <20250626215911.5992-1-hiagofranco@gmail.com> 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" From: Hiago De Franco When the Cortex-M remote core is started and already running before Linux boots (typically by the Cortex-A bootloader using a command like bootaux), the current driver is unable to attach to it. This is because the driver only checks for remote cores running in different SCFW partitions. However in this case, the M-core is in the same partition as Linux and is already powered up and running by the bootloader. This patch adds a check using dev_pm_genpd_is_on() to verify whether the M-core's power domains are already on. If all power domain devices are on, the driver assumes the M-core is running and proceed to attach to it. To accomplish this, we need to avoid passing any attach_data or flags to dev_pm_domain_attach_list(), allowing the platform device become a consumer of the power domain provider without changing its current state. During probe, also enable and sync the device runtime PM to make sure the power domains are correctly managed when the core is controlled by the kernel. Suggested-by: Ulf Hansson Reviewed-by: Ulf Hansson Signed-off-by: Hiago De Franco --- v5 -> v6: - Commit description improved, as suggested. Added Ulf Hansson reviewed by. Comment on imx-rproc.c improved. v4 -> v5: - pm_runtime_get_sync() removed in favor of pm_runtime_resume_and_get(). Now it also checks the return value of this function. - Added pm_runtime_disable() and pm_runtime_put() to imx_rproc_remove() function. v3 -> v4: - Changed to use the new dev_pm_genpd_is_on() function instead, as suggested by Ulf. This will now get the power status of the two remote cores power domains to decided if imx_rpoc needs to attach or not. In order to do that, pm_runtime_enable() and pm_runtime_get_sync() were introduced and pd_data was removed. v2 -> v3: - Unchanged. v1 -> v2: - Dropped unecessary include. Removed the imx_rproc_is_on function, as suggested. --- drivers/remoteproc/imx_rproc.c | 37 +++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 627e57a88db2..24597b60c5b0 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -890,10 +891,8 @@ static int imx_rproc_partition_notify(struct notifier_= block *nb, static int imx_rproc_attach_pd(struct imx_rproc *priv) { struct device *dev =3D priv->dev; - int ret; - struct dev_pm_domain_attach_data pd_data =3D { - .pd_flags =3D PD_FLAG_DEV_LINK_ON, - }; + int ret, i; + bool detached =3D true; =20 /* * If there is only one power-domain entry, the platform driver framework @@ -902,7 +901,22 @@ static int imx_rproc_attach_pd(struct imx_rproc *priv) if (dev->pm_domain) return 0; =20 - ret =3D dev_pm_domain_attach_list(dev, &pd_data, &priv->pd_list); + ret =3D dev_pm_domain_attach_list(dev, NULL, &priv->pd_list); + /* + * If all the power domain devices are already turned on, the remote + * core is already powered up and running when the kernel booted (e.g., + * started by U-Boot's bootaux command). In this case attach to it. + */ + for (i =3D 0; i < ret; i++) { + if (!dev_pm_genpd_is_on(priv->pd_list->pd_devs[i])) { + detached =3D false; + break; + } + } + + if (detached) + priv->rproc->state =3D RPROC_DETACHED; + return ret < 0 ? ret : 0; } =20 @@ -1146,6 +1160,15 @@ static int imx_rproc_probe(struct platform_device *p= dev) } } =20 + if (dcfg->method =3D=3D IMX_RPROC_SCU_API) { + pm_runtime_enable(dev); + ret =3D pm_runtime_resume_and_get(dev); + if (ret) { + dev_err(dev, "pm_runtime get failed: %d\n", ret); + goto err_put_clk; + } + } + ret =3D rproc_add(rproc); if (ret) { dev_err(dev, "rproc_add failed\n"); @@ -1171,6 +1194,10 @@ static void imx_rproc_remove(struct platform_device = *pdev) struct rproc *rproc =3D platform_get_drvdata(pdev); struct imx_rproc *priv =3D rproc->priv; =20 + if (priv->dcfg->method =3D=3D IMX_RPROC_SCU_API) { + pm_runtime_disable(priv->dev); + pm_runtime_put(priv->dev); + } clk_disable_unprepare(priv->clk); rproc_del(rproc); imx_rproc_put_scu(rproc); --=20 2.39.5