From patchwork Mon Jun 2 13:19:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiago De Franco X-Patchwork-Id: 893980 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.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 A585A220F51; Mon, 2 Jun 2025 13:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748870395; cv=none; b=HpsX655ieljb5qsgH/0B7JhD05Y+5misbOcb4a54zrGetW7j8EH1ErqZG0yBUwnfRVAfC/yjz+ONie+xjUexXZsDUhgs+stB9n9TszZPR/fwiRcKKSth0SKYc8XZ0JAPbQjddNJ1HhzdiNfvz3+OWr1WLqHbg4yH7J+Pwjbkklw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748870395; c=relaxed/simple; bh=GPsdVxlMIyFLjpYoGg3d0W6mL1zKPBYJinSVZjWHCvc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k8+xeIOuvl3JiiN8OGfMJx+SvT8JRzCWO5AFBIJaKBVmCwDeWFTOuDm5vzcNYGxWHLAqqVMgMFOzVhIZGx2Nf0CMU9edlTCNak+KF0zfNTXTvi797VxaO3dw+tDS+ejRSS5JnYUSXJbZVSWxFTz8hn4W1RPbHd02VFPOtEkybC4= 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=JCu1chwT; arc=none smtp.client-ip=209.85.215.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="JCu1chwT" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-b26f7d2c1f1so4112351a12.0; Mon, 02 Jun 2025 06:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748870392; x=1749475192; 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=YJ6sDs0ap5mby7PucN1jBOGKcXROdaugyvIe6KS1zRU=; b=JCu1chwTyxSek5uj9UFZMguD/pMKWhY//MvU0ksnKSJq1ajXJ0jIBDxRzup/HfX2qG aGFspvM+8EGcfPUZrznYfiwdH+bvPl1r6JrH6USSQyjboaFo3rFEYsMT5Cd31bHAz3Dp BTHKNtT73qt1TePQfFnuFVz2n2Y4nkdpihoiZOA2rHmvtGOlmAY8sW9ic2/WZ8LHC0uy F2uX6IE4nq5pjl5cP+/PQBPgVlXfacmTZIyNEHcpJ+VL+9pM/uYFUrsXQioSylajq1h2 HqrOCl3DSft2XA8Sj9f0fZDMhTvqEps21kTa7soQOweZX4nL6oG1LMERPennohnC4G6p xn0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748870392; x=1749475192; 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=YJ6sDs0ap5mby7PucN1jBOGKcXROdaugyvIe6KS1zRU=; b=GGF6Y38FQPTeO+NgPQyqpEH9S2H6iempQKzcFI6aMTbPpREi5OwgvOQP2DAGpLdGby nC0Xo2aa/6gxH/9/SxRIYgjhUwX4i81b2hxAsePaPe19+jO8mfnShLPWd4Zoh+9/meWD zU+J0i4KRTf7MMLiBVKpemUSywlBxbz1/pKyaK9dyqM/aDEmLLL5ErQOi8seok+ugR6t 1WuCoXx4VvK28e0qhYDeXRT1Tw+ZUhA0Ocb1WRc5p9Dh1OiJQZ1amN0hh7jdpNvQZZ3y N6e8rmMIbEtPRStI2kCYe+3OhuCI/BqX7WGda1lhhve7DQ+j69EbcuuEgSzmyaBGdIy2 xz+w== X-Forwarded-Encrypted: i=1; AJvYcCVgug5PbBL+ZllldM/gAtT8HalGqO21W2z58ZpxQsvAqZHSYuyQqGkIRm7xyTGXRouCzWCtJC1qtzeTz6Vs07yHdQ==@vger.kernel.org, AJvYcCWiDNoqKMi/867nIx+MbYo11oTL5R1k+clgcDmNYwCMBJjpCPC7AHhRT/Aq44pJQXrczyp4nMAKM25axC0=@vger.kernel.org, AJvYcCXiezb6M/tw9JSKJZUlY2TMhEmcWo0AOCewsQ/xumVPxVoldjfW2KNfwOW0b6ifiL/fwL4OKkt7JAU=@vger.kernel.org X-Gm-Message-State: AOJu0YxmJwmGiX4Y9RIBioBGWgc88mT90gg6NVRmkwWMYbyGzXnhvwoG HMm5aMPEHl6F+tHu1G4veo7j2weEW+KlAzNYyndICcxgIuPQhEztq6uU X-Gm-Gg: ASbGncuITOPc9Ru8Z4O8ObQHA631Ke9AhDsr76TPOuOLGP9wliqnPRW2SLAjLfMgV9k TkJn3FuzW+Hmizlr1n70OvA6ObAeGejNsaxTdqVGw3xsh9OAg2+0J8lAgUelesH8z4Qsjo47JG7 h10ZBVSI1XO5greSO1EZ4Bio+6jqEezf7uybmBFXtTBQvjA5ZuQmxDGI7uG3RxZzWiZNk4DvXxr Ry+fzNdw/FB17MToygQr/LhVg6Ga7htNhSwgsPhRcpj6/YCI7STO2ua54DR/rFd3+oUy8E98zcZ THBJcYxYk1d/d5ODQgc60XLn2Ib+u8s0Er7vN/e7zMrZ2Mn3NZzbZ3UnhtvYe4Suv4PpkBewnq/ N+lOzx+v0 X-Google-Smtp-Source: AGHT+IErgHS5snsVnZ//qcUNKvfllIsynXPhb7js8d1BuZtiwj0gMVWZpcbDBi6UEa1UGSsp0FKEfg== X-Received: by 2002:a17:90b:268f:b0:311:a314:c2d9 with SMTP id 98e67ed59e1d1-31250357f1bmr19303166a91.9.1748870391611; Mon, 02 Jun 2025 06:19:51 -0700 (PDT) Received: from hiagof-nb.corp.toradex.com ([67.159.246.222]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3124e2b67bcsm6130983a91.8.2025.06.02.06.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jun 2025 06:19:50 -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 v4 1/3] pmdomain: core: introduce dev_pm_genpd_is_on Date: Mon, 2 Jun 2025 10:19:03 -0300 Message-Id: <20250602131906.25751-2-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250602131906.25751-1-hiagofranco@gmail.com> References: <20250602131906.25751-1-hiagofranco@gmail.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Signed-off-by: Hiago De Franco --- v4: New patch. --- drivers/pmdomain/core.c | 27 +++++++++++++++++++++++++++ include/linux/pm_domain.h | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index ff5c7f2b69ce..bcb74d10960c 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -758,6 +758,33 @@ int dev_pm_genpd_rpm_always_on(struct device *dev, bool on) } EXPORT_SYMBOL_GPL(dev_pm_genpd_rpm_always_on); +/** + * dev_pm_genpd_is_on - Get device's power status + * + * @dev: Device to get the current power status + * + * This function checks whether the generic power domain is on or not by + * verifying if genpd_status_on equals GENPD_STATE_ON. + * + * 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 = dev_to_genpd_safe(dev); + if (!genpd) + return false; + + genpd_lock(genpd); + is_on = 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); 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 device *dev, bool on) return -EOPNOTSUPP; } +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 From patchwork Mon Jun 2 13:19:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiago De Franco X-Patchwork-Id: 893810 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 9E7F2221727; Mon, 2 Jun 2025 13:19:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748870399; cv=none; b=Z1YL8sQWwM/0wng0XGq7/1PGfIU35wN7MhZIyG4efxvN9vfd/rW9GVrT4UP4M55k9d4YJ7duWaqmSt6I8n+C6uptPpNsJ6oiXukOgOpRAQT12McpL2pHuk8ght7p7Re+2ffrVqQDQYugBzJSPIfO9fJ2giZzKG/HlDf04ipJBuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748870399; c=relaxed/simple; bh=oL2pBfAmXooSdMFJKON1dq1V6xiD8s5/TFtFSgq1qmw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ULfMtKsr+V5nPPIF5Jt/EI3H/TBD0Uz9qzng0NHjc+6uji4d58WniCVYaQethd4E2TNA+u+vBGAMyeodr3iaWWl+L46JuSJVsOyleYpvdQBgPpAbie1mZFWTEG0XFKoNf7wmwJ23H7qOc9hHZGic0Md0aiGSw1xxOTo/d9hF6Vs= 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=hBBxuLaJ; arc=none smtp.client-ip=209.85.216.44 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="hBBxuLaJ" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-30e542e4187so3022915a91.3; Mon, 02 Jun 2025 06:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748870397; x=1749475197; 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=4pcvAbNlPqy8avpN6kp5KhushkYLoqeoRe8/zurysr4=; b=hBBxuLaJOZGizMD+D4M2HtYBD8eNo1YubdbgOsjomVkFQUpQlyGU53vMK5V+Urf+o9 zed8S9sxPQi/AJ3HXnx+XRWnoD48Jj4fOagmnPyX0PJDkHOlyltnlUH/4+xmNDBRwdx2 Ya2oCzBqGmXUyUaLuSdEqqKZvqNQqMOawiRhfT4fdIeOKZ5luLffcLim9idq4K7UEqPk DJtRuwCCXZBpaZmGSVRuzeQKeI2v4kKkM0LJqI8dSQRHmDuL+j6DIq9eRt2pL1Xp6kvx BSRjNQ+uI/SLviAj13OW40TORp6R5WP5y8geJr5429kUHSq+0MUYeR8+k3zWlOpn/Rz1 szKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748870397; x=1749475197; 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=4pcvAbNlPqy8avpN6kp5KhushkYLoqeoRe8/zurysr4=; b=FktLp2RD8L7uSn1S2kUnBv4YpZ4bmtjFX5BY+A7weQEUD4ZtgVWDbGu8u4+uFuW+A/ X/Y1NXk1RxYccA9VgyaEuFYjBqcPu2cNXtAfka9xszMpwzNirxvJ9Cz+728GkOLJFBrn X4aki6mibk3ER4G/kW+b0dtsnLQIgyy9hwM72fz8fuQsnRK5C2xsFlDIViigZQ1yvNS+ 0d39wkxmjhO+udpLE+Tx8IvYOnYBIWAIbXiWEjaZjZNHUE+Uwe1Ov6/8t+BqkpIKM0K5 fW7UYFMC4ntv+MpuLHfd7u/7GUk6SyfaCt5qgKR1b/Rc+6f2o7znX5aSA+bU/3wf5F0u aW0A== X-Forwarded-Encrypted: i=1; AJvYcCWO7A9uD4mDapy8grQw6P8x9kiE8/AVpi9YNuFo6hK7FKPnDtp1o4McJXNH9Ds0oDLQvrHb8QZ93WY0xMCBHmwrxg==@vger.kernel.org, AJvYcCXAzfCvkTiEL0nSymsFbGPWmAmfDUZXLO55/5KkqTlIgaW5bBYQFA4CGadhbgRjqjUHfPioJbcW1U/oTOQ=@vger.kernel.org, AJvYcCXbnd58JSGpxWwrrJnxKfdTf1DLMw8MtyL+mQORRL1jBH54k45mJ1ZaiZGmV281FElHKTDP72Rrw7Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yxk/DPu2+Qi6KOc2zH6Y/cubtbPK8CuikkbWjJTD3v1yzB2BvjN rM3CBRzxcudUMWzCu5GwGbL0BsOPBzg8kNo8SIouSTkM4FT54zzVaDLN92jHSGHQ X-Gm-Gg: ASbGncuPug1oxwOG8OGyh2umpCquZ3IASFyl/AmuYUCtqbKOFZKdHraI3o1rmJ0ukKB PO2GR3GS1vkyA3DM4DRl7r4bwp+fyyqh5+5L7RwamW6rbGIIIS/T3+ldUAUWJBByNs+Tgfq4iTB GhawjYSd4Gbe+VpaJe8ntrUTDixvogxcwFTW1R0bBgWKreReAuIW3lJdPwK8oumUZC4WFxgGrx4 wxHUSBZVaqAToJRNlXvoYR0af8GaZw+jrI9ScJrj2UzEGVUGLYdFuUZeXv+Mli7SWqrsWZIQFIh BS2zkZI8S3W5rnITLFBwVYBKJgss3A5OcSidNjCVCAVpmLZoWBaORRYcI4zDqLTOaNYflwVqgLf zQKAfzME3 X-Google-Smtp-Source: AGHT+IGmdU9yIWWKtV28WuEUnscGkG0AjD3tLXlSKHPKML0pCpHKekiyfiKqp/DGTPbox5idKuB7SA== X-Received: by 2002:a17:90b:1a88:b0:311:f30b:c18 with SMTP id 98e67ed59e1d1-3124100ca0dmr20343807a91.4.1748870396838; Mon, 02 Jun 2025 06:19:56 -0700 (PDT) Received: from hiagof-nb.corp.toradex.com ([67.159.246.222]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3124e2b67bcsm6130983a91.8.2025.06.02.06.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jun 2025 06:19:55 -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 v4 2/3] remoteproc: imx_rproc: skip clock enable when M-core is managed by the SCU Date: Mon, 2 Jun 2025 10:19:04 -0300 Message-Id: <20250602131906.25751-3-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250602131906.25751-1-hiagofranco@gmail.com> References: <20250602131906.25751-1-hiagofranco@gmail.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hiago De Franco For the i.MX8X and i.MX8 family SoCs, when the M-core is powered up by the bootloader, M-core and Linux are in same SCFW (System Controller Firmware) partition, so linux has permission to control M-core. But when M-core is started, the SCFW will automatically enable the clock and configure the rate, and any users that want to enable the clock will get error 'LOCKED' from SCFW. So current imx_rproc.c probe function fails because clk_prepare_enable also fails. With that, the M-core power domain is powered off when it is still running, causing a SCU (System Controller Unit) fault reset, and the system restarts. To address the issue, ignore handling the clk for i.MX8X and i.MX8 M-core, because SCFW will automatically enable and configure the clock. Suggested-by: Peng Fan Signed-off-by: Hiago De Franco --- v4: Unchanged. v3: Unchanged. v2: Commit description updated, as suggested. Fixed Peng Fan email. v1: https://lore.kernel.org/lkml/20250505154849.64889-2-hiagofranco@gmail.com/ --- 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 *priv) struct device *dev = priv->dev; int ret; - /* Remote core is not under control of Linux */ - if (dcfg->method == IMX_RPROC_NONE) + /* Remote core is not under control of Linux or it is managed by SCU API */ + if (dcfg->method == IMX_RPROC_NONE || dcfg->method == IMX_RPROC_SCU_API) return 0; priv->clk = devm_clk_get(dev, NULL); From patchwork Mon Jun 2 13:19:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiago De Franco X-Patchwork-Id: 893979 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 223B522068E; Mon, 2 Jun 2025 13:20:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748870404; cv=none; b=u0/c6EvkYu00sOj1qbsmzVaciAvhDtdEcS6ZIlU52e8+FG4qRrGe3knxeQ2uNjroYgCisoZUW24m7ZUXbzq9Naw7GL9ZLU55JWDvHuzB5y/HDLj+uFkrfBeCp3a3kV+5PQUNbpWo0x+KXkHdk2KGCtzub7/B0eVYxnztsDDhpZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748870404; c=relaxed/simple; bh=kWoyBBVAR9Ha1I3eVXr883D+sm5esK1y5bluwlJLzPQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f7Tvr/VPZMVh8jY/ZkWQ8dJBRv4H1TAEQ6MT2U8I8SZFFCbNmeOyzn4sx+NRT/1DdVINMm1uASJwaeNmqM8QFnZN/xDJ9jWxsLA5xXEthyvtndZHGy40dE8yY9dRRgsK1IpimyqMfSU8uQmsmFYJFV3K08EcPMRfH1M8QWt8CVk= 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=LLEKDtlr; arc=none smtp.client-ip=209.85.216.42 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="LLEKDtlr" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-3122368d7c4so3129033a91.1; Mon, 02 Jun 2025 06:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748870402; x=1749475202; 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=GhKP5iYORRYNLEnbf33EP9epGoMRKymXdxcO+qLp2CY=; b=LLEKDtlrBqfa+3v6+COKWMroTzEVNCzNF9mAGBKQhjgP912z9I2GVgijbKYPM8VErF 5y0W0L8U0yoGyikwp/mJ2zCZ+OLSAmezILaIeITLoyBz9Igyd6uZsNwnXAf1Xt05JG2j gWJXux2JYDcXbOQNqK24UeS3stIzANx8yffbfdf/LwBLZjLTMl/YqHBOiUD2HXLT4Ehp zwCThO7q8cODxr7a8IpwW4w0ZO2os7QGgAvrNg0ab5Y9bq5z7AM8eKS9MLgQWyuv9bBN 3HuqYiPBcG2Wes9FSTfsXqqjHDZ4QP5KgXTt4OlNQD6kwXIJx/1Ny8ZOUHXVGhMx0ADK L0PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748870402; x=1749475202; 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=GhKP5iYORRYNLEnbf33EP9epGoMRKymXdxcO+qLp2CY=; b=eCDrGdDuqEYnkc/dRdopYm/Pp9A1bB0oKjGgqJPNAn0kegDpe/ksRNl3xocDGohHuq 9Oe8zp2mAaxZgzZ+ICmK0sin476NVJozzo/Tb4xjX2Ab0akks2x0Y6rzDgycKn5dp+Jq q9CnHO0//FpCnciGsCZfRZfm+l0nlnJnr2Siurwvri3izHYhk0uQumpyjuNANN+VjJEw t3YoLT5IHCJsrRV/YGfDnWblUIx1sBDo+1hwrR1i0BVGOynb5dd1FgrbYnrlu4507nq4 f6r5P2NgcsDq/9DywOZ5oHmPoYMawSp9UxAh14M7KvvuHpwsrwugPDz2l7+ntO8O7kXa F8Yg== X-Forwarded-Encrypted: i=1; AJvYcCUeiYaGZUdZ7g+DGOZ+czK2IjHhXhZJYrqZ8fygztSdOSYXT6xslny2XZ4mMEzuHu8fMwNEw1xKtXCM3MY=@vger.kernel.org, AJvYcCVjgGvD9yo+sHm7ZO0Ins17Byw8nByYBiEMA9lDQpy/P68g4o6auyERdWdJT+XlbVVAR7nCMLgZXG8=@vger.kernel.org, AJvYcCVyK4Nhp5ooJg9FfcVTuPRnEJvZiIlHoEmfPZZ8rRGUMe+/FBprtKiG1XhB2Bao54511fKlkccvBma58rb7DEdy2w==@vger.kernel.org X-Gm-Message-State: AOJu0Yz7vIJYHuwSlI9vAo5X6TJ+8dxQG53FApD7JyjCpJBklHBq1Z9P Ira2EN+MTa+ADDLShswJtvl0PhYM6fRhK5IqfwNeLSwgQO5aq3roWJPi X-Gm-Gg: ASbGncviFJqpaqBGjIRpbPQQJlXXIdTB2Fii7po5RxpVif4xoSeSNcLt2VArjrKNEEr aZTZDqBo2SbtD7nHDK9vb1dU6MBMYGFIOt4rsJ6koHJ1NWiPGdzV0aGKNSEb8ykOyZmZJ9zhzJ1 EaEtT0ZYF018yTPR7fgarIKYyvhGFC7mLtjqDSMWmzyj4nIb5H6Abk+ciLeLyChYdWnz20jiTdG WR6KCWpIoPeUTN1+2PKcSeX54dGxbH55UmvqSL1da84p5BBqHTIEOH99ESBhtluqa+USvTRGziJ +pd44jQaObyYQW9NYi6LfDm6N9O9VLBKCexNLnJPzykxsKMUU8Cfbm2ha/a1tKKMJTxoyj0YQw= = X-Google-Smtp-Source: AGHT+IGpk0MW40KUnLGhZi6aTcs7hziCgisIwOKdVotPNVMy0bYaTAXay/v52EDp38MmY2gyBOvaiQ== X-Received: by 2002:a17:90b:5344:b0:301:9f62:a944 with SMTP id 98e67ed59e1d1-31241e9846dmr20882041a91.33.1748870402169; Mon, 02 Jun 2025 06:20:02 -0700 (PDT) Received: from hiagof-nb.corp.toradex.com ([67.159.246.222]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3124e2b67bcsm6130983a91.8.2025.06.02.06.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jun 2025 06:20:00 -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 v4 3/3] remoteproc: imx_rproc: detect and attach to pre-booted remote cores Date: Mon, 2 Jun 2025 10:19:05 -0300 Message-Id: <20250602131906.25751-4-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250602131906.25751-1-hiagofranco@gmail.com> References: <20250602131906.25751-1-hiagofranco@gmail.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hiago De Franco When the remote core is started before Linux boots (e.g., by the bootloader), the driver currently is not able to attach because it only checks for cores running in different partitions. If the core was kicked by the bootloader, it is in the same partition as Linux and it is already up and running. This adds power mode verification through dev_pm_genpd_is_on(), enabling the driver to detect when the remote core is already running and properly attach to it if all the power domain devices are on. To accomplish this, we need to avoid passing any attach_data or flags to dev_pm_domain_attach_list(), letting the platform device become a consumer of the power domain provider. With that the current power state of the genpds will not change, allowing the detection of the remote core power state. We enable and sync the device runtime PM during probe to make sure the power domains are correctly managed when the core is controlled by the kernel. Suggested-by: Ulf Hansson Signed-off-by: Hiago De Franco --- 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. v3: Unchanged. v2: Dropped unecessary include. Removed the imx_rproc_is_on function, as suggested. v1: https://lore.kernel.org/lkml/20250505154849.64889-4-hiagofranco@gmail.com/ --- drivers/remoteproc/imx_rproc.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 627e57a88db2..6f9680142704 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 = priv->dev; - int ret; - struct dev_pm_domain_attach_data pd_data = { - .pd_flags = PD_FLAG_DEV_LINK_ON, - }; + int ret, i; + bool detached = true; /* * 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; - ret = dev_pm_domain_attach_list(dev, &pd_data, &priv->pd_list); + ret = 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 up when the kernel booted (e.g. kicked by the + * bootloader). In this case attach to it. + */ + for (i = 0; i < ret; i++) { + if (!dev_pm_genpd_is_on(priv->pd_list->pd_devs[i])) { + detached = false; + break; + } + } + + if (detached) + priv->rproc->state = RPROC_DETACHED; + return ret < 0 ? ret : 0; } @@ -1146,6 +1160,11 @@ static int imx_rproc_probe(struct platform_device *pdev) } } + if (dcfg->method == IMX_RPROC_SCU_API) { + pm_runtime_enable(dev); + pm_runtime_get_sync(dev); + } + ret = rproc_add(rproc); if (ret) { dev_err(dev, "rproc_add failed\n");