From patchwork Tue Jun 17 19:34:48 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: 897455 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 B186628D8C2; Tue, 17 Jun 2025 19:36:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750188966; cv=none; b=JE7OS/pPsIS0esqJ1cuH1tlY1/P2BIX5AEIM1CIoyCJCutpuFvSAjMlOjkMHRstQmY8PKYBUMTTJYsZJsDpMvZ/ZfSuOsYaJBn9q0/qoth3u2TFyCd21VPcO7vLf1e1OY0lR2VINmVeSjA7+gBnuBksgqtVNfEeWzeYD2U4GsPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750188966; c=relaxed/simple; bh=OYtfVADC3YbaOkP37R0UIhy3l79PKRTWkTBXrHQnV+4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=isYX5qoHDNE/adsrmPLjWXEU17cSm59nUh+Oavab5xXkEnmpK93/TQ4altEd57Zr51V1FAOrTW0eYZlftGrlHDKgfL5VAKfzM4/XpTgjmRC9In8uo4A202Q3G+Yl/IRCGZgauTMaa/CR/0FLahhSZj58yglppzJB8MTzB/07kxU= 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=Qz8sWiB+; arc=none smtp.client-ip=209.85.210.171 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="Qz8sWiB+" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7487d2b524eso3197691b3a.0; Tue, 17 Jun 2025 12:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750188964; x=1750793764; 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=9+Jp9u/wRva4rrnrWzobzjZRnSw87IvFwB/n0IWH6u8=; b=Qz8sWiB+DD9HYnX+T22+hQ81OfQd3iCDqkhueh4j/JAmRSKQ5/Yb7T5F96I6asAFfu 7d1+7XWLo487lMPXfSGRefKXXsKpvAInAoW1Ryjzmv1Xy1iebocHqKMfi+n13P+wheUI lKIeq1KlWjv8BbVDBALocA7+EjR9YU+abdk4XkNVn92dzLpJ20JjFJOWRLX2728bWzu1 XYhXrdI3RsbMj+uxSKtQ93V5fWLvGmL9B9EJebQzJP3W1VGtvaQaWAS1LqlQ3UMy9Uuj VJulKE/gFd9ChOuJZ/bdswxhscyp1MXNWjLBWGlWLH5a1bNIqfMyx0eScpHt/i+pQo8R g9Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750188964; x=1750793764; 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=9+Jp9u/wRva4rrnrWzobzjZRnSw87IvFwB/n0IWH6u8=; b=dsum1LyMjbkdHOQD13JXBIDWqd+u1AGNBzTzHm2+vLNrYX31D347ew8X76mNEeTE7p cbXXgIudBQoGU3FQd97ywsEJ0s7IDuGAA05eLHr4WJQ1Uiq5ozeaM/21+gGeNzgH8Wzs vAAUfBoUReYlD6x+09GIZXHDpQitCs/bxzFfPJg5YYfjal7zSxERFkyQb0LqRfsNnZn7 5b9LU31eVLlW2dzzT03OVU12tLNWApiZ8MU7v1wIr+c2CMIBm5W8pcjn+XpQQm8oEQwX b5Sp6lcnTTv2f+Q0BijaVDQitruP6cWroHWfbttXX8i4KD4q2s0hVhZ+pkX4HWWWq6w2 fKug== X-Forwarded-Encrypted: i=1; AJvYcCUwbFEB4b5n5Afgb0f8gtE1XBdopbMuv/MhMWPW/x3r7kG1vYBlQh4ojCH5YsblrhOi20ASIdQMCIn+dLIPs8mlBg==@vger.kernel.org, AJvYcCVJjNi/HEkQ8ARtkpdcmR8vpXfZcaZKm2uO3dH7WTvpFvy+Zu1dI0jGKYe/S3is0ws/9+bebHmiXK8=@vger.kernel.org, AJvYcCWmS9OXaqllhJIQEENI5BP+0Qka1DTArQ1ZlBIjdemTAZaMQ5cN0HeknK8hjPpu7UPHQQ8p7U7sD9U/jRI=@vger.kernel.org X-Gm-Message-State: AOJu0Ywg5ZgI38d+8gbyFi8zdayOPe1tQiygDDxlj+SvTvv+HOTWfDgv 5AS0iqjvGO6NMqkIt8jePlh63VXijAJG7oUSxdqvJAy7OL6IP4h25c8H X-Gm-Gg: ASbGncvOjYhb1XMEz4UmhHtdBmWNahJWxVmCERZEy9ddDqEzY2lCr4g1ZQOCMP6ce5E ouL7hMHbt2QIRM7YssFyiQJpz+8UcTSgv6nQGzoCdJ2y/wIiREoWmp83U3Ezbk3lgaesfGPNdCs 6suwRYXHQ6PgAq3HGfNV1rmdacTUF6Sg3KnhkeZLTIrE7988S9+6cOvPg0XMhrnxtufz5GICxt+ FwPLLn6I34fVo45Mzc1u42z30MN2jwf493D1oEUyxA9apc2oY6gykSOR60UEfClHAy5FgtTNM0Z ci1C3JUrFg5gI80QMvel+vvU8LBfuZIzzZ4E4VIshACQ456x8VMKqniFFTGE7/faPvdC9tl9aTj kiBEoKsHbVNZxPVWJCHo= X-Google-Smtp-Source: AGHT+IGcDSspfVbPpwb0f/ablI94JBqFeuuwuuxpXOVNcm2A90uM3TKWTA7DXqp9K6lERbNZaC1dhg== X-Received: by 2002:a05:6a00:2d06:b0:736:5725:59b4 with SMTP id d2e1a72fcca58-7489cf62aa3mr20044531b3a.3.1750188963855; Tue, 17 Jun 2025 12:36:03 -0700 (PDT) Received: from hiagof-nb.corp.toradex.com ([67.159.246.222]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-748900d7340sm9648582b3a.179.2025.06.17.12.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 12:36:03 -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 v5 1/3] pmdomain: core: introduce dev_pm_genpd_is_on() Date: Tue, 17 Jun 2025 16:34:48 -0300 Message-Id: <20250617193450.183889-2-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250617193450.183889-1-hiagofranco@gmail.com> References: <20250617193450.183889-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 -> 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, bool on) } EXPORT_SYMBOL_GPL(dev_pm_genpd_rpm_always_on); +/** + * 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 the + * 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 of the + * call. The power status may change after due to activity from other devices + * sharing the same genpd. Therefore, this information should not be relied 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 = 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 Tue Jun 17 19:34:50 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: 897454 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 643972EBB9F; Tue, 17 Jun 2025 19:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750188974; cv=none; b=jajKb+2O04y6a0FjnyeFlKVPod+uYLrG7Tm00UlVHY+4/ZE7uXcIS5uosOS71xGqXpsOZsHNBLpZjs+fGeGO8x9BQ6f8hzdm3p84sY84QplhcZ0epQWguvjAWJl/Du+EDlgvaLsscyhsdRATAt2ImS9+uXnAD8Vsu/coEFDNrxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750188974; c=relaxed/simple; bh=fiKFmvWMLDxz/CfyNaXTHlbGkJloAVbfV0MGXrNa5X8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sXuNvzLVLQP2llV6gcffcUJTl9bdBufoCoJVodHAGNF7o3fdi7mU7sJtFjO86Z/uw1x8EYn0tIvtEQRFZZEsh5UOVfnOlPQPP85nyslU54+DMqG0hQFOAv2aSnWrVTU0iHoVFS0amoZEZnt/5+tzQ7wip87aK2C6xoxXXY7PLp0= 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=aznWCBlq; arc=none smtp.client-ip=209.85.215.171 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="aznWCBlq" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-b1396171fb1so3819301a12.2; Tue, 17 Jun 2025 12:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750188973; x=1750793773; 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=/r2c8EaAsxVPli8mnl+dP2Lkz2s+hxXrFoO6K6wz64E=; b=aznWCBlqwlNkhwq08Spogl0CPs0vf8tWECc9y415lXULbsWTPoM9SjycwZDPlGLWpi Hzt6SNUzCPIts1kPuxXBx3KRgXjWoqr6TBl25ic0BCjVQ1YDwbXuS2cfpEYQJsZan8s+ CI2uxLjV7Cx2mgn2z9zgeFq3yxPOvHH08Dvs1D2Ow5zalyHe73+8z3CUlOpx6a8diRBF NSmMmveugCyiOSn23PggKbfzGYr83Mk1PWTFN9IYAOMU+iabBjB29CYmYt4WWaxjVU1o 9SEDRZce7+yCnOJi7urh/vX/dqF6BOpXH/APM0YFjKUlS97mYhET++R388XmhZqYX7Z2 afZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750188973; x=1750793773; 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=/r2c8EaAsxVPli8mnl+dP2Lkz2s+hxXrFoO6K6wz64E=; b=acj7R5nlHOtfVussK/J4Fg9iK7H23zOSbTS1hpWUozUC6oFTf8QAv3cF8gBVJYeiDv WIvNoFHSbDGe8R2pNJw4sbZTxGRUKEtGzJIx1AZVXZma1ejQtisPyhIl4u5fREqPMElD Coo2uvZ9tVGi2dj+osVJInRySJktjgJdV5KwDhbKkx50KzUBGnuz7xzTKwqntHyOjY0V etkalw5FbtsnyBtAFUYwOWu+7NLWjCWLrxTn8kdJuWpirSuAgL4g7mlUzYlXhdyOsIoQ u7UKFchScg4EfNRWN4uWN7AISOxCmwwsSjl8WrGtPhxFF4N/SJEPSis2lynhqUxAdylF xySQ== X-Forwarded-Encrypted: i=1; AJvYcCUVZp7fzyHEDUpl+ikomUvZjxtHlr4PS5K19rafbeeYIw6CupLpYrh+hC+lgtFD0I/G86eHjVLMLkE=@vger.kernel.org, AJvYcCVfHqsjvJhqOejIsom5mUL/mIAJq27z7l4CIOFo2CcspSX8gqA8G/N+uBOL68P0Hp3JzKCnKK3BMOtLh0M=@vger.kernel.org, AJvYcCWQOLSsvL9u7kfY3XoyTlgKHoIT2MsxdH8jjxkvJ84CRBCz1lQcx6vOz4yl3iZWlORH+sCehm5sL/+N3KoqNH2iog==@vger.kernel.org X-Gm-Message-State: AOJu0Yz4xVRT7QtMf/5vS8DqKDuotuuz9W0111YjsX1Rr5N9bssZFQw7 zwCQYAJOooKTIHghUjh8uh5VC1CMeEA60XaUssvjY3a7LNipn3PLmo28 X-Gm-Gg: ASbGncv//ioIYuoHy8cV1ApMq6Ua65cCkxsK6exrtZDPQuczT56O7Z4bzvPwrolkvxy 8mAhqwjicDoOD54jitjJ+/wrBPbfOLyrvA2jvLBQ6OMQwP8VowOtUiOz1qPTgl65U+mMwYWHN0A HNBJ9tFAkFc4Dti73/2QTuIkx/cAv/xrgZxUBSGZwLQ3dQv/ixH0dwtR962BmHYbi/agURfN8pY 3x3IjfU5QpGcpNcaDWerVJW0p6+vmTEsquVFWMJXvoyoKImGbM3LjuXLApF0QBGzIVmy3LfrqYc Tff1faucwGS1xIVzkACUs5xVlIxyHPlkDYDPsN1+fmx+ELBkc/hyYio8mkNF8b2OV8aT8DOUig+ kb3d/9Zqs X-Google-Smtp-Source: AGHT+IEcTxTFfNUX47ya/EUrbwJwh97FMbsvWdj3uruF5I0lImwMUF7tir/4Fz62IdKM4n1FplyKAQ== X-Received: by 2002:a05:6a00:14c2:b0:742:a77b:8bc with SMTP id d2e1a72fcca58-7489ce0cd46mr19370746b3a.2.1750188972450; Tue, 17 Jun 2025 12:36:12 -0700 (PDT) Received: from hiagof-nb.corp.toradex.com ([67.159.246.222]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-748900d7340sm9648582b3a.179.2025.06.17.12.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 12:36:11 -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 v5 3/3] remoteproc: imx_rproc: detect and attach to pre-booted remote cores Date: Tue, 17 Jun 2025 16:34:50 -0300 Message-Id: <20250617193450.183889-4-hiagofranco@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250617193450.183889-1-hiagofranco@gmail.com> References: <20250617193450.183889-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 -> 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..b53083f2553e 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,15 @@ static int imx_rproc_probe(struct platform_device *pdev) } } + if (dcfg->method == IMX_RPROC_SCU_API) { + pm_runtime_enable(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret) { + dev_err(dev, "pm_runtime get failed: %d\n", ret); + goto err_put_clk; + } + } + ret = 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 = platform_get_drvdata(pdev); struct imx_rproc *priv = rproc->priv; + if (priv->dcfg->method == 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);