From nobody Wed Oct 8 10:58:19 2025 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.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 EC4A423C4FF; Sun, 29 Jun 2025 17:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751217938; cv=none; b=JCLZF23Kmh3klf1XqjvIgjK32FfErGZF0EY8+OZwcSHpVMAbL1HaQGIaCRKbZXspJP7NsOlBHnfgtcvRQ2Bpw+fMNQALalUCAO7QIs31atW6XqdxZ6SskQySq7N4bCWxuDU6zzW6GEhe/iCwnnnl0BNiEnXa4l//IQvZai/jwQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751217938; c=relaxed/simple; bh=Pzuko6p5X7nNXZXr5mX6MGJAHdvlnWWK8W+rzZlOCQY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aXdiuvl+e2w4uheNIaej5nS5FvAgBOjQX1VndNMVgG9mhLOk9dr9NxQBRoJENT/PZXm//tlfkhUBwJahxB1pCCCnDUF3r6jtN7K3pj+qNHknUe4caWRWtj4KBqu9cHG9K2xV2iGuXKAqNj74y90d/ArYTLzJdWztSpfR1kwUS9A= 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=NesDrHRm; arc=none smtp.client-ip=209.85.160.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="NesDrHRm" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-4a440a72584so15895331cf.2; Sun, 29 Jun 2025 10:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751217936; x=1751822736; 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=do+WrCyUk54RUggZsmiUqY5/C6vOQx+Ug7MOVtvuvcQ=; b=NesDrHRmcDUkYK6C6iNqWw+FyploL2Wg4DhOg0LXsP5Q6RSNcjUUH7LF7YZ+PNkPMu gR4xfDHLeczyDChmVQlwNpAWKKpB4bREQUdSRik2FOXRzutfaMHg6OJ8sPKWPZwwjXGm GlbBZtE1sjmwbVRnERLFFERqJ/bv/0daohlz/xPfo5V3Bm8JsyYZMDfA3z7zrkMPJEPb U56PLQp/wzptcaQKsORZB+KLIOTzv6hm44GHoAsrus6djOWCS6WnKPaHjg5ecHUyrXd+ lI9COdB2MHzE9LanlGnw7xhbhgSb90qQbXkTHQFfHc3ZZzoUwKteDjrFfj23o7rNasgu fWgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751217936; x=1751822736; 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=do+WrCyUk54RUggZsmiUqY5/C6vOQx+Ug7MOVtvuvcQ=; b=LXfN4JVlkQ3nbmiYOQaptHrDgtd7UHyzaKmAwSk5sues1yBkCYGp2kRVucGLx9j4lb kgx1pRpwwQx1o09Bmx4y3e2fy2PtOSV1uqXzbqLQ4yAazq+RDJYaEDLTsxTrlD6bO3D3 vy9J05hm9y94ShV0RC8g9hk/uKfULtAkeOx4YoW7aqeMJs8bcaKxsdzjcaKwf0O8cV1K k9CFsOoFNyqmiDjYP5duqtoGqNbO79f75MKOLnmE5VsxQBsU6WVRdn1ubcUkEpTk3Uep upNP1mrJ1SBYucJszolgqApt93K41wnA5ABF3qG2t3tPOT13NLmKmh1xSBurkpReD0pV bWRA== X-Forwarded-Encrypted: i=1; AJvYcCUBvYxeUAwfHpIsEmoC5s9rLPm2qm41LpQ30Wjw7/q03sVUAEqNK6vVfu9nPcSsAGPk6PD+Kugjzf0=@vger.kernel.org, AJvYcCVFKfDbVj1VkGaRP1W7lpy1+YVsJjXmBJsIubd4fdkVErpkXp+wTuuqF0w0VAWOJjQq3ZPj5yQ+/ALqdNf90TdhTQ==@vger.kernel.org, AJvYcCWz6T1EooGGbN/7cOsd/YB/CD0TYhGWoeF++JlRYYfjG+xYUVW2D01rIT0qgojOgVXBNDh66ohiBAl2wgg=@vger.kernel.org X-Gm-Message-State: AOJu0YzEtcjioPXXuNcg5/1RVXnEYYkm7A2bz48k2JzrESHGKNsbHS+9 nw+ROlGneF/dYAVhvCYjYwmRr+ZJq/7PWIq4dFqWelqvpoRpbydXKoga X-Gm-Gg: ASbGncu+dCIExy1m0K9UaLNEnw+3y5T8zcOcOSMn9DQNdq/0CONMT2seGGffuGrgQjn 5M+XTirgRmwiHWGFPMGZYW8avDHuUAQGdUMP8KDyNGTmnlkR/Nvx/NDGNG+fhxQ49+8UDoZBTnl 1CoJe98EuazSF/IrxUnb0GXO97s17evik8mEY0UlpK1r8Om7duOEMmciKqQYxPvwKLxEzRVs/x0 cGLYcHRKk+cqqDQeoM0tJrzOrFqvKr6Zgs4VHbdzKd3umWlYi5SpAIVshy9KnG/rc74PIRNFSru t0RNVrIpo1+MteizQVM+c8vK5bQqIFeocDr/Yaj4/2YdYAumVnf1slJtoLnfQes3tzdiHgckTJ+ RLL8= X-Google-Smtp-Source: AGHT+IEtbacLnJPOYdFPR4Qbf+3fCv4tbuGcOhmfcatWVey4R8ndXu0J2Fw9Zxydr+PjYKNsz5WN+A== X-Received: by 2002:ac8:7c4c:0:b0:4a5:98ad:5640 with SMTP id d75a77b69052e-4a7fca4e44cmr189456211cf.23.1751217935798; Sun, 29 Jun 2025 10:25:35 -0700 (PDT) Received: from localhost.localdomain ([2804:1b3:a7c3:c88d:6da3:af6d:a237:3289]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4a7fc57d7dcsm45549761cf.60.2025.06.29.10.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 10:25:35 -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 v7 1/3] pmdomain: core: introduce dev_pm_genpd_is_on() Date: Sun, 29 Jun 2025 14:25:10 -0300 Message-Id: <20250629172512.14857-2-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250629172512.14857-1-hiagofranco@gmail.com> References: <20250629172512.14857-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 Reviewed-by: Peng Fan Signed-off-by: Hiago De Franco --- v6 -> v7: - Added Peng reviewed-by. 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 10:58:19 2025 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 766A1238C20; Sun, 29 Jun 2025 17:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751217945; cv=none; b=sMCr9uVHQIIUiTaZjb8rEqHT0oIEmYwA4RX5gReIhu5nb2CIINgXgQ15PqrlvarDHyoI7EM6HwCG+c4lI2IvMJHGlsRqbnqocICePveG57EoMPw+2HjUd9cXeootaqctZe8A5//J3YQlZBfDULFkorurnI1p8i+ciLaS/FxagpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751217945; c=relaxed/simple; bh=tFhG1J9WX6lkOz2RvO67ATCtV9LPDz6zL613qycQaQk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d9oL3tdvlX08ls5+EUgVzruAKD7ti6aT6wLumprLC3MiLMBNzbqqiol3SIDn3PTqy3AlZ28eYPR/jY5lbAq9yBX/brUo0qy2/TMX5RwUGHrZ8JewDTSjgWqY20pivIy+0npxgf0vSsIhmzzKseXguOhZ9YgAKTzNc9UZM8iWJbg= 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=FpALvyYa; arc=none smtp.client-ip=209.85.160.181 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="FpALvyYa" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-4a589b7dd5fso71691311cf.0; Sun, 29 Jun 2025 10:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751217942; x=1751822742; 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=vBbPPcEdQtei5+NuNnufcyttJ+zLeB0/TIiitwhS+8E=; b=FpALvyYar7kx8D+2iFMbwPEbReMpd9kh2OlG7Y+TBcfj5jnEnJ6AJvm9gCzIR240mp dj6ovgjj7Nn5eVIGkQMN7IjIEYgOVZW4cEb/E0iURuZmauyHrAd5QqR3D7kvEVO/ggdl twARtSM7bHGvR8ekQ5BWnru60o4QHVv0ZXKQCHzrKOp0yDF8T0mqxoo56fG8/0ASLgPb 8L2Z17KbQ1CPy9zK5l+Jubf7tpPU1rSxgD1+dzhRBTjhGs9a0irxQ3sozABwXgvPs/aC wub1/rzanY/R5YfhtC5/iSy3fn0/aCEEcTguiZ4P5wHYZ1QRtEZZmxCsXh6VpKZLm0IY PeFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751217942; x=1751822742; 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=vBbPPcEdQtei5+NuNnufcyttJ+zLeB0/TIiitwhS+8E=; b=Iq5sSNbBKnpJAXeuCSDLbDETjH1P2eN8wmznVWrIBxgWhSzz/7chiTHVBlXyCEKPSv 0QZwjCcB+80fYoTceEBPno21zP6SLRly8w8S7DEhMs1iJ3ackcMW4vetfTRdBysDaUhP cSdYd332Z1cr6pYMd+nNR2gTqiY4rRfy6vhbSIig3Jx8JAhOCo2BzTxfQWBAiwKZ9nqu IUFDo7m9gl3bTj/Whj3uWUpPrKpp7qNqJsrhejzHb42kHE1qrhGvgQ8KssTHhtpix5M6 gsS9BkL/1L8lv+qKnZp47CjvZnr/M3jCk5jVnH//akqYCdp408FEpfgmMnHObYl7we+y EwlQ== X-Forwarded-Encrypted: i=1; AJvYcCVZuG2yV7wd3dDObZ/L4u58fb/E4fAqrGEbhCA5ja53wm7vSQhyeED18Nj1aaj1JdEha/2yrkY41m8=@vger.kernel.org, AJvYcCVpItFB1cvmtchG+BL99RbfJ+UKve5po7GZtw0bj2P1qKExV/VsPk/Yf8MY9vC793/iY7mIB6Rvq6y54jk=@vger.kernel.org, AJvYcCWPfFDaS9C2j01JrYUjt/NEVgH0Ddvl29GqUFYuYiWmmrMjofxFkMx0QtcTU2ZGWSatw/5Se0kNb1ccBIHLpQOTOg==@vger.kernel.org X-Gm-Message-State: AOJu0YypSiF44NyGo4o+qFSXC4um7z+RLpNWCEc2WU4zWZ0x7K3vZ8sr bmQo9atxaxHT1Jf0v8zIaX6u2x1HmtyW0LlrNrm7XbyfmSNm3YV7p/oB X-Gm-Gg: ASbGncsXgRD5fitFzdxl46qs20yaOxoOtdIrhSUG7XA7Uew5/sILglXf2zdnx7ANAtL OgAXY3MCxadQ2VTwMbjzOFVW5n1XqExVyPaWD+FdlkscV322p3BkoZlHctMUyM2a/cOAdfTGNWc uixmLQdWnhsY1UtYoHBeXQYeqL4NecggSTGnkZv/OJnnykUC9MDTVQEts/CU9fQc6JEciO4s2bH bGI0hROoRxfBfFu5H2mgXdEf2Dmr2TPlhiDjPm4LzuTlL6/BV0PhWyjPFRoS82DeW2bRYpS6+gF pFxAKkyFRcguRxTWJI1ZjWWbHF6odZr8TaCdyCts08+MEYqf12frgrCIjpuNGpbw5g1FEQmwHjN 05HU= X-Google-Smtp-Source: AGHT+IH0oA4OuFF0x2nQSxRW9BOpq3H9adGI3VCEA8SilmvSk/JkXEeS26LmCye5qmOTPQlaP6fQKQ== X-Received: by 2002:a05:622a:506:b0:4a7:f683:975d with SMTP id d75a77b69052e-4a7fcb3aacbmr184575131cf.49.1751217942253; Sun, 29 Jun 2025 10:25:42 -0700 (PDT) Received: from localhost.localdomain ([2804:1b3:a7c3:c88d:6da3:af6d:a237:3289]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4a7fc57d7dcsm45549761cf.60.2025.06.29.10.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 10:25:41 -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 v7 2/3] remoteproc: imx_rproc: skip clock enable when M-core is managed by the SCU Date: Sun, 29 Jun 2025 14:25:11 -0300 Message-Id: <20250629172512.14857-3-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250629172512.14857-1-hiagofranco@gmail.com> References: <20250629172512.14857-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 Reviewed-by: Peng Fan Signed-off-by: Hiago De Franco --- v6 -> v7: - Added Peng reviewed-by. 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 10:58:19 2025 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (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 938BE238D57; Sun, 29 Jun 2025 17:25:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751217951; cv=none; b=iVR+sFm4cVGxBxzZyZmz+YiqksSUg6d5Y+g9lZvAVGnc4urYVBm9RriCg3DarR9aaALjbbndPSuAhZxVkt+qn7CIcKBKXJRwXXL7mHPOERrAMvoHFx+hhPHJ7sZKZ2Yf/R6h18FiEABKUzxKJINH+zGh0mubn1VIOCih3Wnl6KM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751217951; c=relaxed/simple; bh=dX5CgCff38oCxVYrv1myAPN8VV6/co07Gu9nbEQT2ec=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CfYxJdcz5jraFbjMx/kDjUHEHK1XRxN/e1O7WS2QtD28aPPSm4kOirVTRkWXI1DB0BKidPQmvySMsOloBOuFRzG0sl8Xy86mWrc0RuDv1Y4aqCwe2wpbJH0ZKhBYIPR2AhJdI8DG3FvmM1Om3a4cxpxoRUbd/wbpyCBN2gc9BII= 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=ebHmg64/; arc=none smtp.client-ip=209.85.160.169 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="ebHmg64/" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-4a818ed5b51so1825011cf.1; Sun, 29 Jun 2025 10:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751217948; x=1751822748; 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=CC9iUQpNk2KWt1DZhVabqrPCsFfxqA98Z3a6X4JvyBM=; b=ebHmg64/Hx8o5Q46lfBuqitsGPMhQK1A4ZNTeO68+qZSP4h/DAPRsqm7isITBySEjw idSE3xFvpjvToM/clc1y4Sq25aKGewRIiM+D69YHsDgDosLSsmi3t+n80CYqPi+j2fci 1R7Oj+tKyr7gzFH9oBJxMlcDdYBlmhXVO/1F4q5+KJl9PKWR4mndqAJYspiCrL2escLA CbI7dyKXUplnaF/S4IiHfei6KbM2Ih1QfxiTem6eCM0io1zwTLlCaUEBIYauTvv4kqAR hwFJg4j4eJuLqA94/2Tystao86FG9arT3WI2Xs6VeLa6mMPtuX1zHoQxXYZKvN4HYgEh 2OdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751217948; x=1751822748; 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=CC9iUQpNk2KWt1DZhVabqrPCsFfxqA98Z3a6X4JvyBM=; b=jzFuaDuLZFyWry7XVaWQuA03tesf6vKwBgaJ+uplsEh5zf6zfMQHV2eyRQ/vEOGW12 pppSSJ1iAFoc8BZA77UoQtlzwKLRPnyRBAmaMl8T1oJUA6LFGZDsuVtic5biF6c9XlST tFE2JLfdfFB48iFZ3nnoPBnY0Pr+jw0KTmYmyMowgotnqBi3PeOyVNMY2ug3Q1jmGP2s ZvvIbCB7G/ZrcqOihxpfi8tppQa13QoeGP3orYffpHIfy0ZJHisqlBFCov7UYdgFMFE7 qqHD6OdDbzzafH8L8cyUkdSl8YNcDHLTbmkDr5D+q9Na8bgrZFnx063aY/F1rM3meQ38 dOgQ== X-Forwarded-Encrypted: i=1; AJvYcCUVOgC8cJhFDCu2zjUNeaHG9CvKMwq4f7dqgNji6/BQ4VxtBcRbET2CZBncIE7lVwdRyh/7xUdCWirxmYg=@vger.kernel.org, AJvYcCUk8Rq8hSwGYbJUB3pM8wXjJeu1jmn/Urh2Ieyd/NSDsWczKnS+u3dKbDtkqZbEyTC1WIeOLQU+VNsXMcqAX3F3Sg==@vger.kernel.org, AJvYcCVDgCRx1n3MhgZOTzMx3z9bNuw+Ujiqn9eGGkVEvLm4hGADLvB25T3my4UwDEn9WvimN7657awrhao=@vger.kernel.org X-Gm-Message-State: AOJu0YwphXE4EMRiJDH/udE4n5naEfSAAxTWMFbHqlFQAnyvsEbIJjQ2 HUoUwQMAeRVPnTLujYJdgv/Otrr84SbQxL4jJRusM3f9QapH+ZDkT0lG X-Gm-Gg: ASbGncsESPHPln1r5Lxxa6lHH9zN3ZsjCBTPDdgM82rHQmwpa96DsgFHuwFPShh2Svp FgqjEFnPX5FoYWvg0NQ9BUg0D/N/KP2KY4zUt9DKX6T+8cRc87RvnGT8cKhuGD/efWG60bRCIqe 94+Hf1cN/IsltmHrSR2AhyzuJfXrzlB5BSqqVtevPIxFzYEsq2YjYMKx+uo0P8k/bW0iKVTAMv0 tEZulUCccf3T5lEMWqMP1LIrhghX2W2irZAYplM8+MicdjsRYP5D4g1hAzZ3xlOqUTaoz+FBqCE yIHJ2fqkppVb4ao4L7VQ6IHFGWUbLv4OC9H9SYSVupVyLGgUDCqMD+I8x/w/xHIodjqrqBpLW1x OTLI= X-Google-Smtp-Source: AGHT+IHL+yIWTipjXDrBIV1HOTDHYJtyQk3xOUCkDv6eXNSuiH8iXZMcrL3wqtORw+/eQhaCGyQTew== X-Received: by 2002:a05:622a:5b03:b0:4a7:6e64:a52b with SMTP id d75a77b69052e-4a804b3926dmr128171311cf.35.1751217948303; Sun, 29 Jun 2025 10:25:48 -0700 (PDT) Received: from localhost.localdomain ([2804:1b3:a7c3:c88d:6da3:af6d:a237:3289]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4a7fc57d7dcsm45549761cf.60.2025.06.29.10.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 10:25:47 -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 v7 3/3] remoteproc: imx_rproc: detect and attach to pre-booted remote cores Date: Sun, 29 Jun 2025 14:25:12 -0300 Message-Id: <20250629172512.14857-4-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250629172512.14857-1-hiagofranco@gmail.com> References: <20250629172512.14857-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 Reviewed-by: Peng Fan Signed-off-by: Hiago De Franco --- v6 -> v7: - Added Peng reviewed-by. 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