From nobody Fri Feb 13 14:10:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E299CE7A88 for ; Sat, 23 Sep 2023 11:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231502AbjIWLue (ORCPT ); Sat, 23 Sep 2023 07:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231168AbjIWLu0 (ORCPT ); Sat, 23 Sep 2023 07:50:26 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7FF51AD for ; Sat, 23 Sep 2023 04:50:19 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2bffdf50212so57568641fa.1 for ; Sat, 23 Sep 2023 04:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695469818; x=1696074618; 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=UPs/8kVgbnM0mW5nRHnV6PsEkWTa8KX9zy7vOpy7zco=; b=PweBAeQYomHnpiZ33syNTGedNrTDTDRbzwDrg2QFtoBAWX4zfrpQJWtGWfHpYUBFvz LjJ3D/C4MZX36ce4zqfbwiqTizZYeXmMzflqyNHdKSavFKR/y2p69e/S4dUz8bLypykt c+Upo6GoERq9MggkLvsUTLv3UJtwOLkczlWVB/TFXtwqFoyV9WhojPT4zmri5xu2BQKA +35LV/dGfnWyeBqI0c8qud3KWaV9/9JLGJgFYxrSyDmbzAZj3X2G2hbqiUHXH0JZxKqS MFOmHGL8ziqvMOFTdhsD9RfYljE24B+6XdUG6vM1L2SBkDbgd2r/+goXPNV0elSaoROM tW3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695469818; x=1696074618; 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=UPs/8kVgbnM0mW5nRHnV6PsEkWTa8KX9zy7vOpy7zco=; b=dyIvOOLG6sSkKebuIXaDwPlRHc1HHlIuuQhAN2Ord1oXfDKV+NfILpNx9002UlMy5S tpAKzTcR6lLV0qCHOhC8qvTZo+ycKlM86WkpP6yQn0BBX9YqZVtyL8xiQpwr19gUxp63 TPj3BnlP7xOZj4n40kL7IK4uZKePVQjbWpUyUSk5CCQOPTqYmpd8jXsqv+sBY0HhT43L uynCVpyiI2Trv2cWL3SBwDMeX2befCbBQBCm8YIrSvWNqO5Pc5fVWYEW1u+gKEd1KsIP crrzWiU5F9UxfMShIuVFpZSrvzM8vwy6ymzHedw65mJ7pr6QKifR1p2GPZ5K2TOepm0D NUYQ== X-Gm-Message-State: AOJu0Yz7dFFyjQfAu8w5phgWuHPuf1F0ZMBfXfJLqOjGckBxf6Ab2oc0 1pr0rSgvhF2EJ360s1W+OZyiVQ== X-Google-Smtp-Source: AGHT+IF3iCPcqri7mExufzMYrYPnONmgorXVtSZYUy19mZQ/qSGbhFXVMLsCZeWD4KykDA+ieBz8OA== X-Received: by 2002:a2e:9d98:0:b0:2bc:e882:f717 with SMTP id c24-20020a2e9d98000000b002bce882f717mr1448649ljj.53.1695469817288; Sat, 23 Sep 2023 04:50:17 -0700 (PDT) Received: from hackbox.lan ([86.120.16.169]) by smtp.gmail.com with ESMTPSA id k15-20020a1709062a4f00b009ad8084e08asm3853310eje.0.2023.09.23.04.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 04:50:16 -0700 (PDT) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Taniya Das Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org Subject: [RESEND v3 1/5] PM: domains: Allow devices attached to genpd to be managed by HW Date: Sat, 23 Sep 2023 14:50:04 +0300 Message-Id: <20230923115008.1698384-2-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923115008.1698384-1-abel.vesa@linaro.org> References: <20230923115008.1698384-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ulf Hansson Some power-domains may be capable of relying on the HW to control the power for a device that's hooked up to it. Typically, for these kinds of configurations the device doesn't really need to be attached to a PM domain (genpd), from Linux point of view. However, in some cases the behaviour of the power-domain and its device can be changed in runtime. To allow a consumer driver to change the behaviour of the PM domain for its device, let's provide a new function, dev_pm_genpd_set_hwmode(). Moreover, let's add a corresponding optional genpd callback, ->set_hwmode_dev(), which the genpd provider should implement if it can support switching between HW controlled mode and SW controlled mode. Similarly, add the dev_pm_genpd_get_hwmode() to allow consumers to read the current mode and its corresponding optional genpd callback, ->get_hwmode_dev(), which the genpd provider can also implement for reading back the mode from the hardware. Signed-off-by: Ulf Hansson Signed-off-by: Abel Vesa --- drivers/base/power/domain.c | 69 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 17 +++++++++ 2 files changed, 86 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 5cb2023581d4..dfb4f1de540d 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -541,6 +541,75 @@ void dev_pm_genpd_synced_poweroff(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_genpd_synced_poweroff); =20 +/** + * dev_pm_genpd_set_hwmode - Set the HW mode for the device and its PM dom= ain. + * + * @dev: Device for which the HW-mode should be changed. + * @enable: Value to set or unset the HW-mode. + * + * Some PM domains can rely on HW signals to control the power for a devic= e. To + * allow a consumer driver to switch the behaviour for its device in runti= me, + * which may be beneficial from a latency or energy point of view, this fu= nction + * may be called. + * + * It is assumed that the users guarantee that the genpd wouldn't be detac= hed + * while this routine is getting called. + * + * Returns 0 on success and negative error values on failures. + */ +int dev_pm_genpd_set_hwmode(struct device *dev, bool enable) +{ + struct generic_pm_domain *genpd; + int ret =3D 0; + + genpd =3D dev_to_genpd_safe(dev); + if (!genpd) + return -ENODEV; + + if (!genpd->set_hwmode_dev) + return -EOPNOTSUPP; + + genpd_lock(genpd); + + if (dev_gpd_data(dev)->hw_mode =3D=3D enable) + goto out; + + ret =3D genpd->set_hwmode_dev(genpd, dev, enable); + if (!ret) + dev_gpd_data(dev)->hw_mode =3D enable; + +out: + genpd_unlock(genpd); + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_set_hwmode); + +/** + * dev_pm_genpd_get_hwmode - Get the HW mode setting for the device. + * + * @dev: Device for which the current HW-mode setting should be fetched. + * + * This helper function allows consumer drivers to fetch the current HW mo= de + * setting of its the device. + * + * It is assumed that the users guarantee that the genpd wouldn't be detac= hed + * while this routine is getting called. + */ +bool dev_pm_genpd_get_hwmode(struct device *dev) +{ + struct generic_pm_domain *genpd; + + genpd =3D dev_to_genpd_safe(dev); + if (!genpd) + return false; + + if (genpd->get_hwmode_dev) + return genpd->get_hwmode_dev(genpd, dev); + + return dev_gpd_data(dev)->hw_mode; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_get_hwmode); + static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) { unsigned int state_idx =3D genpd->state_idx; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f776fb93eaa0..36d308ba40b0 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -146,6 +146,10 @@ struct generic_pm_domain { int (*set_performance_state)(struct generic_pm_domain *genpd, unsigned int state); struct gpd_dev_ops dev_ops; + int (*set_hwmode_dev)(struct generic_pm_domain *domain, + struct device *dev, bool enable); + bool (*get_hwmode_dev)(struct generic_pm_domain *domain, + struct device *dev); int (*attach_dev)(struct generic_pm_domain *domain, struct device *dev); void (*detach_dev)(struct generic_pm_domain *domain, @@ -208,6 +212,7 @@ struct generic_pm_domain_data { unsigned int performance_state; unsigned int default_pstate; unsigned int rpm_pstate; + bool hw_mode; void *data; }; =20 @@ -237,6 +242,8 @@ int dev_pm_genpd_remove_notifier(struct device *dev); void dev_pm_genpd_set_next_wakeup(struct device *dev, ktime_t next); ktime_t dev_pm_genpd_get_next_hrtimer(struct device *dev); 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); =20 extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -305,6 +312,16 @@ static inline ktime_t dev_pm_genpd_get_next_hrtimer(st= ruct device *dev) static inline void dev_pm_genpd_synced_poweroff(struct device *dev) { } =20 +static inline int dev_pm_genpd_set_hwmode(struct device *dev, bool enable) +{ + return -EOPNOTSUPP; +} + +static inline bool dev_pm_genpd_get_hwmode(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.34.1 From nobody Fri Feb 13 14:10:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAD58CE7A88 for ; Sat, 23 Sep 2023 11:50:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231462AbjIWLub (ORCPT ); Sat, 23 Sep 2023 07:50:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbjIWLu0 (ORCPT ); Sat, 23 Sep 2023 07:50:26 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 576561B0 for ; Sat, 23 Sep 2023 04:50:20 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-99357737980so443813466b.2 for ; Sat, 23 Sep 2023 04:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695469819; x=1696074619; 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=gkMg6Ss1ODOcr8VdxRq6yPqfjTyE6Onn/Fwc4BWB7DM=; b=rLkzUVP9FvDi4+xOnZH7Iga1U2MJSV+W/0G+rtds2o8MTzHpFrZ009AS4vb/8PN6td f9vExEq4tuN4HGGf7XfxTn1GwdiQhiq2QZ11Dyu6shWaC5nbvKNbgotBaGEmajaiBSW0 +gc72amGkuTSZxoRt/Kv4yH99qDceXRaltQ6HceQpxu+z9o1RXa07q0i7ymRcV4of6hf H1TXEbkI7YxfcN4wk+VvVt/uvBnohsgKBGXfTxIEqbLg7QVI7WZB7aFFxF+SE5/vHkHi qzgCk6EctIw9+jHV9x2iX5Zz4NXmrGfEj5Dt4AzZEqMqLS83NEF+JKgCl0eQKlExPsl0 R5Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695469819; x=1696074619; 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=gkMg6Ss1ODOcr8VdxRq6yPqfjTyE6Onn/Fwc4BWB7DM=; b=IEOa8wLaZ6ZJ9MC0jm8wO4fakzHUSGb/Idq0g4+QqzYBfQOgBAGzM+wnmOtk150gDL TsPOVi0XI4pY+9LVQ+46LxJDatVflshC+/C4PTpa1xN+3EritDC2eW/by/tsdt1u0LlM w7bGBenqBeKrAUpYCgWDzl+cmwRMCWweS71vPQsvIaG89yFfJ66Mp1P4zRyeHXRZBlvN G7S09jjLdtUJ+s8FnhgBmWNhzW6TmRxJNVwJfTZ8WuP8/1IT03CGxy46EGbKDkB0SVFW QR/P9wNNVUD1pCrsIwoTQrF2N/DcsoygZrYK2VxyPO36/uNQ4A78ZhfPUhKURrtyFBzJ JFHA== X-Gm-Message-State: AOJu0YzJPC9/v8bzzX0eEGdgSfhKVPxzpxcKdK/Z+ferXVZKy0fGXEms xfij8Ce8AWMjDrWS20122ireJw== X-Google-Smtp-Source: AGHT+IFA63qVcvn23d2cB7ArqMpEOgP3SaNn+1EhFxPur0BUfXBa/lAhkkc40O5YTXiHAPiXx/8TGQ== X-Received: by 2002:a17:906:310d:b0:9a2:24f9:fabe with SMTP id 13-20020a170906310d00b009a224f9fabemr2003596ejx.66.1695469818880; Sat, 23 Sep 2023 04:50:18 -0700 (PDT) Received: from hackbox.lan ([86.120.16.169]) by smtp.gmail.com with ESMTPSA id k15-20020a1709062a4f00b009ad8084e08asm3853310eje.0.2023.09.23.04.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 04:50:18 -0700 (PDT) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Taniya Das Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Taniya Das Subject: [RESEND v3 2/5] PM: domains: Add the domain HW-managed mode to the summary Date: Sat, 23 Sep 2023 14:50:05 +0300 Message-Id: <20230923115008.1698384-3-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923115008.1698384-1-abel.vesa@linaro.org> References: <20230923115008.1698384-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Now that genpd supports dynamically switching the control for an attached device between hardware- and software-mode, let's add this information to the genpd summary in debugfs. Suggested-by: Taniya Das Signed-off-by: Abel Vesa Reviewed-by: Ulf Hansson --- drivers/base/power/domain.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index dfb4f1de540d..93350e67b0e8 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -3171,6 +3171,15 @@ static void rtpm_status_str(struct seq_file *s, stru= ct device *dev) seq_printf(s, "%-25s ", p); } =20 +static void mode_status_str(struct seq_file *s, struct device *dev) +{ + struct generic_pm_domain_data *gpd_data; + + gpd_data =3D to_gpd_data(dev->power.subsys_data->domain_data); + + seq_printf(s, "%20s", gpd_data->hw_mode ? "HW" : "SW"); +} + static void perf_status_str(struct seq_file *s, struct device *dev) { struct generic_pm_domain_data *gpd_data; @@ -3229,6 +3238,7 @@ static int genpd_summary_one(struct seq_file *s, seq_printf(s, "\n %-50s ", kobj_path); rtpm_status_str(s, pm_data->dev); perf_status_str(s, pm_data->dev); + mode_status_str(s, pm_data->dev); kfree(kobj_path); } =20 @@ -3245,8 +3255,9 @@ static int summary_show(struct seq_file *s, void *dat= a) int ret =3D 0; =20 seq_puts(s, "domain status children = performance\n"); - seq_puts(s, " /device runt= ime status\n"); - seq_puts(s, "------------------------------------------------------------= ----------------------------------\n"); + seq_puts(s, " /device runt= ime status managed by\n"); + seq_puts(s, "------------------------------------------------------------= ------------------------------------------------\n"); + =20 ret =3D mutex_lock_interruptible(&gpd_list_lock); if (ret) --=20 2.34.1 From nobody Fri Feb 13 14:10:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1185FCE7A8C for ; Sat, 23 Sep 2023 11:50:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbjIWLuh (ORCPT ); Sat, 23 Sep 2023 07:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbjIWLu2 (ORCPT ); Sat, 23 Sep 2023 07:50:28 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C641A6 for ; Sat, 23 Sep 2023 04:50:21 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9b11cc499c2so182077566b.2 for ; Sat, 23 Sep 2023 04:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695469820; x=1696074620; 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=Z22Rfgd7UjpYt4TAoqngtq5qLN6/k4A45SAesnG+QTI=; b=JLBeSQiCAXlpMl4ybd17rbwgJeipNxL4Xo+SnWlEwAmABKLVqMjqxkkr4ceB5c3RnR cpi+25uwJq7kUlyaZdiHTvvdV9+XDaMuqs9Tgmg7j6J2sO+sV4HCqlMyppyVZ21R8M2M VzHHWPbJHb9THQBWcdXIUj3cGfFqK2tE/+IazsTuBOhxfERebBmuoMpJ+XwUNSpWzpcp /p0gINNfScBa0naH80YEgjiD2arIXQivf/ydWV1yctIa3qpDoUEa0OnanhTh+9ut++WH u20We6AN1Ws0vgf1n69T5eRG1WdJVUCy6IPZfQgXac1o0AzVnAQhzbgX4d6NmuZA9FQO cZzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695469820; x=1696074620; 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=Z22Rfgd7UjpYt4TAoqngtq5qLN6/k4A45SAesnG+QTI=; b=WSEwtXih779byWnojn19/zwikT4GcPl7xhUiaEdy1tLyzSEjUcgz6cGTPcANjqn+bZ GezFnX70/Z5phcFYUVsHFy9GFgQ4LWe/GiF5cS3Jl6bi+L+hBKOxY1Rdld64dDDEPgK8 /tAvbBu5ITTHjT1YmIx1o+DTUQNLCc+mEo2o9QQ+8JP2uHTjsh2u53Q9aK9mH3whYadW O6RfuAp7OQUG9syja/YG5lbAgJLD7dk9os6htJ+nY65KhOeq89EKaTcgthMKpXKoLJLh Hu0O9c2l/iiJxsYtH1eyh73e2CBf4u4b7OJDok7j5YowVKzcb1qyhLYtRNGRU1elAlEg uorA== X-Gm-Message-State: AOJu0Yyff94/pSvTpPOWLgie4Sv/teo8L5NnNejSZagpKYgHQdvxTCmM Ano8mAfRY+mu1jDkFogzPIJUPA== X-Google-Smtp-Source: AGHT+IHOKPV7tYEYJr657kkH+IPPQoUNAztuS8mSEUiRMTXXngg1z06D5l/pJFMhWEUG1uokl2U5lg== X-Received: by 2002:a17:907:3d86:b0:9ae:729c:f651 with SMTP id he6-20020a1709073d8600b009ae729cf651mr1743569ejc.17.1695469820447; Sat, 23 Sep 2023 04:50:20 -0700 (PDT) Received: from hackbox.lan ([86.120.16.169]) by smtp.gmail.com with ESMTPSA id k15-20020a1709062a4f00b009ad8084e08asm3853310eje.0.2023.09.23.04.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 04:50:19 -0700 (PDT) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Taniya Das Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Jagadeesh Kona Subject: [RESEND v3 3/5] clk: qcom: gdsc: Add set and get hwmode callbacks to switch GDSC mode Date: Sat, 23 Sep 2023 14:50:06 +0300 Message-Id: <20230923115008.1698384-4-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923115008.1698384-1-abel.vesa@linaro.org> References: <20230923115008.1698384-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jagadeesh Kona Add support for set and get hwmode callbacks to switch the GDSC between SW and HW modes. Currently, the GDSC is moved to HW control mode using HW_CTRL flag and if this flag is present, GDSC is moved to HW mode as part of GDSC enable itself. The intention is to keep the HW_CTRL flag functionality as is, since many older chipsets still use this flag. Introduce a new HW_CTRL_TRIGGER flag to switch the GDSC back and forth between HW/SW modes dynamically at runtime. If HW_CTRL_TRIGGER flag is present, register set_hwmode_dev callback to switch the GDSC mode which can be invoked from consumer drivers using dev_pm_genpd_set_hwmode function. Unlike HW_CTRL flag, HW_CTRL_TRIGGER won't move the GDSC to HW control mode as part of GDSC enable itself, GDSC will be moved to HW control mode only when consumer driver explicity calls dev_pm_genpd_set_hwmode to switch to HW mode. Also add the dev_pm_genpd_get_hwmode to allow the consumers to read the actual HW/SW mode from hardware. Signed-off-by: Jagadeesh Kona Signed-off-by: Abel Vesa --- drivers/clk/qcom/gdsc.c | 32 ++++++++++++++++++++++++++++++++ drivers/clk/qcom/gdsc.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 5358e28122ab..c763524cd5da 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -363,6 +363,34 @@ static int gdsc_disable(struct generic_pm_domain *doma= in) return 0; } =20 +static int gdsc_set_hwmode(struct generic_pm_domain *domain, struct device= *dev, bool mode) +{ + struct gdsc *sc =3D domain_to_gdsc(domain); + + if (sc->rsupply && !regulator_is_enabled(sc->rsupply)) { + pr_err("Cannot set mode while parent is disabled\n"); + return -EIO; + } + + return gdsc_hwctrl(sc, mode); +} + +static bool gdsc_get_hwmode(struct generic_pm_domain *domain, struct devic= e *dev) +{ + struct gdsc *sc =3D domain_to_gdsc(domain); + u32 val; + int ret; + + ret =3D regmap_read(sc->regmap, sc->gdscr, &val); + if (ret) + return ret; + + if (val & HW_CONTROL_MASK) + return true; + + return false; +} + static int gdsc_init(struct gdsc *sc) { u32 mask, val; @@ -451,6 +479,10 @@ static int gdsc_init(struct gdsc *sc) sc->pd.power_off =3D gdsc_disable; if (!sc->pd.power_on) sc->pd.power_on =3D gdsc_enable; + if (sc->flags & HW_CTRL_TRIGGER) { + sc->pd.set_hwmode_dev =3D gdsc_set_hwmode; + sc->pd.get_hwmode_dev =3D gdsc_get_hwmode; + } =20 ret =3D pm_genpd_init(&sc->pd, NULL, !on); if (ret) diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h index 803512688336..1e2779b823d1 100644 --- a/drivers/clk/qcom/gdsc.h +++ b/drivers/clk/qcom/gdsc.h @@ -67,6 +67,7 @@ struct gdsc { #define ALWAYS_ON BIT(6) #define RETAIN_FF_ENABLE BIT(7) #define NO_RET_PERIPH BIT(8) +#define HW_CTRL_TRIGGER BIT(9) struct reset_controller_dev *rcdev; unsigned int *resets; unsigned int reset_count; --=20 2.34.1 From nobody Fri Feb 13 14:10:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 014D6CE7A8F for ; Sat, 23 Sep 2023 11:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231579AbjIWLuk (ORCPT ); Sat, 23 Sep 2023 07:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231476AbjIWLua (ORCPT ); Sat, 23 Sep 2023 07:50:30 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99EE219F for ; Sat, 23 Sep 2023 04:50:23 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c135cf2459so45752051fa.0 for ; Sat, 23 Sep 2023 04:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695469822; x=1696074622; 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=aqRk4B6eKO4+DTlXGIdciaqzHBfx/5bfeFOsXKr6qVY=; b=Fr6ZRbzh+THiQKj7BOaugKhRzBi2YbMJJm38PigppjbdrqbfrPTfVQtWOD9lujcY4Z heEoN6qQxLXrC9glhbQ0n5Fl3Xl79uZAWAVLuP32c4IKzaqF/Uk869eGmv+zLFhH4i7F gFu5oHZNnv4ZYsHqyoez5SQFDmBPv6JO8qtUo7m6Rg2ALzRWY/xAb+1hvgh74jOLr0Pt Q8TTtz+wt1m1xY8B1Hwmbu96CvPCitAUpRZ2f2lh9NvZOZo0VtB4QeyHXVcjER7BXe8G YnCewKFlsTa9/Nfe7nLykRkqLnRSvBS2MXLoDBCJY7aSTQ4j5d/nVBYBdBbgoHSN95rV HJ8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695469822; x=1696074622; 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=aqRk4B6eKO4+DTlXGIdciaqzHBfx/5bfeFOsXKr6qVY=; b=v1x6kEdBNZLF/SY8VDSI2dnjRE4kgr66yYk+Z9ZuyCrFsh2MvIOrwEMODHujB+V/rj JQr+Z19DllyJKBosgfeBywWnF+e/VUYIJvbq6TuHYeKMhq7o3ZcY1nQQH6u+qSCpKcZf J9tBzjxvEP1D/gYpVTwMu14H1Zh2GsEAX97va3dRF3ur/GQfdf4T9pr9vOn78FffZm10 OFSmDG124w+fEUVrCLwdxLOsUd9VEYMTPtnPcCXvmccind0MUi78to1fJLONEOrQYEUU TxvF6CFU1Wntit2+TOPubgHyhmxM39LO9YUGPe2TYvZD5rC2TP0RlzRW7N72Wq2Ip/Iu pONw== X-Gm-Message-State: AOJu0Ywi2exSGuvSfJyBalWbu5xR4HeiSCcD8v4OpZiX9zeVsRa2IqdH 0xobsEUbhqJ81/fJsfUBRYhuJH7HcFakrwnsmr4HkQ== X-Google-Smtp-Source: AGHT+IFxM+9cjbaXbKMNtUEnghkJ1IXBuKOuFIJbf3xP74ETPHauPvQYJHUr6atrpZt19SZahTQthw== X-Received: by 2002:a2e:7a16:0:b0:2c0:192a:c567 with SMTP id v22-20020a2e7a16000000b002c0192ac567mr1567691ljc.20.1695469821952; Sat, 23 Sep 2023 04:50:21 -0700 (PDT) Received: from hackbox.lan ([86.120.16.169]) by smtp.gmail.com with ESMTPSA id k15-20020a1709062a4f00b009ad8084e08asm3853310eje.0.2023.09.23.04.50.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 04:50:21 -0700 (PDT) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Taniya Das Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Jagadeesh Kona Subject: [RESEND v3 4/5] clk: qcom: Use HW_CTRL_TRIGGER flag to switch video GDSC to HW mode Date: Sat, 23 Sep 2023 14:50:07 +0300 Message-Id: <20230923115008.1698384-5-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923115008.1698384-1-abel.vesa@linaro.org> References: <20230923115008.1698384-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jagadeesh Kona The current HW_CTRL flag switches the video GDSC to HW control mode as part of GDSC enable itself, instead of that use HW_CTRL_TRIGGER flag to give consumer drivers more control and switch the GDSC mode as and when required. HW_CTRL_TRIGGER flag allows consumer drivers to switch the video GDSC to HW/SW control modes at runtime using dev_pm_genpd_set_hwmode API. Signed-off-by: Jagadeesh Kona Signed-off-by: Abel Vesa --- drivers/clk/qcom/videocc-sc7180.c | 2 +- drivers/clk/qcom/videocc-sc7280.c | 2 +- drivers/clk/qcom/videocc-sdm845.c | 4 ++-- drivers/clk/qcom/videocc-sm8250.c | 4 ++-- drivers/clk/qcom/videocc-sm8550.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/clk/qcom/videocc-sc7180.c b/drivers/clk/qcom/videocc-s= c7180.c index 5b9b54f616b8..51439f7ba70c 100644 --- a/drivers/clk/qcom/videocc-sc7180.c +++ b/drivers/clk/qcom/videocc-sc7180.c @@ -166,7 +166,7 @@ static struct gdsc vcodec0_gdsc =3D { .pd =3D { .name =3D "vcodec0_gdsc", }, - .flags =3D HW_CTRL, + .flags =3D HW_CTRL_TRIGGER, .pwrsts =3D PWRSTS_OFF_ON, }; =20 diff --git a/drivers/clk/qcom/videocc-sc7280.c b/drivers/clk/qcom/videocc-s= c7280.c index 615695d82319..3d07b1e95986 100644 --- a/drivers/clk/qcom/videocc-sc7280.c +++ b/drivers/clk/qcom/videocc-sc7280.c @@ -236,7 +236,7 @@ static struct gdsc mvs0_gdsc =3D { .name =3D "mvs0_gdsc", }, .pwrsts =3D PWRSTS_OFF_ON, - .flags =3D HW_CTRL | RETAIN_FF_ENABLE, + .flags =3D HW_CTRL_TRIGGER | RETAIN_FF_ENABLE, }; =20 static struct gdsc mvsc_gdsc =3D { diff --git a/drivers/clk/qcom/videocc-sdm845.c b/drivers/clk/qcom/videocc-s= dm845.c index c77a4dd5d39c..dad011c48973 100644 --- a/drivers/clk/qcom/videocc-sdm845.c +++ b/drivers/clk/qcom/videocc-sdm845.c @@ -260,7 +260,7 @@ static struct gdsc vcodec0_gdsc =3D { }, .cxcs =3D (unsigned int []){ 0x890, 0x930 }, .cxc_count =3D 2, - .flags =3D HW_CTRL | POLL_CFG_GDSCR, + .flags =3D HW_CTRL_TRIGGER | POLL_CFG_GDSCR, .pwrsts =3D PWRSTS_OFF_ON, }; =20 @@ -271,7 +271,7 @@ static struct gdsc vcodec1_gdsc =3D { }, .cxcs =3D (unsigned int []){ 0x8d0, 0x950 }, .cxc_count =3D 2, - .flags =3D HW_CTRL | POLL_CFG_GDSCR, + .flags =3D HW_CTRL_TRIGGER | POLL_CFG_GDSCR, .pwrsts =3D PWRSTS_OFF_ON, }; =20 diff --git a/drivers/clk/qcom/videocc-sm8250.c b/drivers/clk/qcom/videocc-s= m8250.c index ad46c4014a40..c1b73d852f1c 100644 --- a/drivers/clk/qcom/videocc-sm8250.c +++ b/drivers/clk/qcom/videocc-sm8250.c @@ -293,7 +293,7 @@ static struct gdsc mvs0_gdsc =3D { .pd =3D { .name =3D "mvs0_gdsc", }, - .flags =3D HW_CTRL, + .flags =3D HW_CTRL_TRIGGER, .pwrsts =3D PWRSTS_OFF_ON, }; =20 @@ -302,7 +302,7 @@ static struct gdsc mvs1_gdsc =3D { .pd =3D { .name =3D "mvs1_gdsc", }, - .flags =3D HW_CTRL, + .flags =3D HW_CTRL_TRIGGER, .pwrsts =3D PWRSTS_OFF_ON, }; =20 diff --git a/drivers/clk/qcom/videocc-sm8550.c b/drivers/clk/qcom/videocc-s= m8550.c index 3bb136ec31b1..504b2ef264eb 100644 --- a/drivers/clk/qcom/videocc-sm8550.c +++ b/drivers/clk/qcom/videocc-sm8550.c @@ -324,7 +324,7 @@ static struct gdsc video_cc_mvs0_gdsc =3D { }, .pwrsts =3D PWRSTS_OFF_ON, .parent =3D &video_cc_mvs0c_gdsc.pd, - .flags =3D POLL_CFG_GDSCR | RETAIN_FF_ENABLE | HW_CTRL, + .flags =3D POLL_CFG_GDSCR | RETAIN_FF_ENABLE | HW_CTRL_TRIGGER, }; =20 static struct gdsc video_cc_mvs1c_gdsc =3D { @@ -349,7 +349,7 @@ static struct gdsc video_cc_mvs1_gdsc =3D { }, .pwrsts =3D PWRSTS_OFF_ON, .parent =3D &video_cc_mvs1c_gdsc.pd, - .flags =3D POLL_CFG_GDSCR | RETAIN_FF_ENABLE | HW_CTRL, + .flags =3D POLL_CFG_GDSCR | RETAIN_FF_ENABLE | HW_CTRL_TRIGGER, }; =20 static struct clk_regmap *video_cc_sm8550_clocks[] =3D { --=20 2.34.1 From nobody Fri Feb 13 14:10:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4155CCE7A89 for ; Sat, 23 Sep 2023 11:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231586AbjIWLum (ORCPT ); Sat, 23 Sep 2023 07:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231474AbjIWLug (ORCPT ); Sat, 23 Sep 2023 07:50:36 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12B911B0 for ; Sat, 23 Sep 2023 04:50:25 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-405361bb9cdso32254015e9.0 for ; Sat, 23 Sep 2023 04:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695469823; x=1696074623; 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=MeiFNC+rrHZ3HIl5q4lUJWW0SsohudondY4l8XE9nCs=; b=yBU/VdbM0W/CaM8Z5WFXHZ0Wl4WjxJBowwQ0yRGe9OLqZbPTJzTtAowfrGqiwkhGrd Qtd4kl+3B+g7Sy23u/BTS5KXE5w8wY0Gpx89Lb6EnSh9CpIPGiGedSkHeiObhn6EhbrL hIepGbzgADtHDe1Rs42OXhIWepg9/vc2bWGo2IWIKQhO0Es+Qv/jsRcO15/vxvXoW76R NhJqDKXFnyeyvLjwrwJq7DFheBo4S1QG7SFnoNsWQTQTIILMMBHVNuUDfUDkDzL/S9Cd ivSHxUXfS+CYlLE77wWhKQeOgsL6XRKQPy/TUCR/RNf88zrOQWxf2fSWUzFGx/xoOes4 ErqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695469823; x=1696074623; 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=MeiFNC+rrHZ3HIl5q4lUJWW0SsohudondY4l8XE9nCs=; b=lI4hxvIflexxmlUCal9lLDjHwdO3F9UFkPfrTJv7OEQFOJCL44Ib5kx02b4EBvkoj9 XVUCIo6ZXjhInotbJV8+xaomIB13/wP8TWWTuWyYQ2ovDSqYver/KlRqo/qVBm+GQd2V OfAAVjgtC7mIWOn/A2ynVEnNG5s8Vr22B7gRhPeigfqXTu1xiLu7qDHGI1uNNUHTV52X 1qemqGWrw1lWyGvPSkNgNELMLxDR+sqrHBwp0vA2hMBNnMySoEu3527/y/qHl5cMCnK8 tw3m1saXnIt0UMaIzmF9FKW/3wxYMThSF2PIuqF7clpeDgKxs6SAqXYyoylZb9Ryg9eO i45w== X-Gm-Message-State: AOJu0YxpJVHxRxLH5SAkrO8hu/9RDcdG1OUJAuK0Z2G15dXjUXw6/q87 6G0Vtv+ltMLjNXOSVDUp979UWw== X-Google-Smtp-Source: AGHT+IEEs3tycQ2S46mMPFPwhhvWTqLgXkB29lSmnmQuc0JgQ24wOK/BSGujJGfGOX6+kWrnT+6XHA== X-Received: by 2002:a5d:4e83:0:b0:319:785a:fce5 with SMTP id e3-20020a5d4e83000000b00319785afce5mr1816609wru.38.1695469823486; Sat, 23 Sep 2023 04:50:23 -0700 (PDT) Received: from hackbox.lan ([86.120.16.169]) by smtp.gmail.com with ESMTPSA id k15-20020a1709062a4f00b009ad8084e08asm3853310eje.0.2023.09.23.04.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 04:50:23 -0700 (PDT) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Taniya Das Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Jagadeesh Kona Subject: [RESEND v3 5/5] venus: pm_helpers: Use dev_pm_genpd_set_hwmode to switch GDSC mode Date: Sat, 23 Sep 2023 14:50:08 +0300 Message-Id: <20230923115008.1698384-6-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923115008.1698384-1-abel.vesa@linaro.org> References: <20230923115008.1698384-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jagadeesh Kona This change demonstrates the use of dev_pm_genpd_set_hwmode API from video driver to switch the video mvs0 gdsc to SW/HW modes at runtime based on requirement. This change adds a new boolean array member vcodec_pmdomains_hwctrl in venus_resources structure to indicate if GDSC's have HW control support or not. This data is used in vcodec_control_v4() to check if GDSC has support to switch to HW control mode and then call dev_pm_genpd_set_hwmode to switch the GDSC mode. Before the GDSC HWCTL was available to the consumer, the venus driver needed to somehow keep the power from collapsing while under the driver control. The only way to do that was to clear the CORE_PWR_DISABLE bit (in wrapper POWER_CONTROL register) and, respectively, set it back after the driver control was completed. Now, that there is a way to switch the GDSC HW/SW control back and forth, the CORE_PWR_DISABLE toggling can be dropped. Signed-off-by: Jagadeesh Kona Signed-off-by: Abel Vesa --- drivers/media/platform/qcom/venus/core.c | 4 ++ drivers/media/platform/qcom/venus/core.h | 1 + .../media/platform/qcom/venus/pm_helpers.c | 47 ++++++++----------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platf= orm/qcom/venus/core.c index 054b8e74ba4f..8145062ab6f7 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -706,6 +706,7 @@ static const struct venus_resources sdm845_res_v2 =3D { .vcodec1_clks =3D { "vcodec1_core", "vcodec1_bus" }, .vcodec_clks_num =3D 2, .vcodec_pmdomains =3D { "venus", "vcodec0", "vcodec1" }, + .vcodec_pmdomains_hwctrl =3D { false, true, true }, .vcodec_pmdomains_num =3D 3, .opp_pmdomain =3D (const char *[]) { "cx", NULL }, .vcodec_num =3D 2, @@ -755,6 +756,7 @@ static const struct venus_resources sc7180_res =3D { .vcodec0_clks =3D { "vcodec0_core", "vcodec0_bus" }, .vcodec_clks_num =3D 2, .vcodec_pmdomains =3D { "venus", "vcodec0" }, + .vcodec_pmdomains_hwctrl =3D { false, true }, .vcodec_pmdomains_num =3D 2, .opp_pmdomain =3D (const char *[]) { "cx", NULL }, .vcodec_num =3D 1, @@ -812,6 +814,7 @@ static const struct venus_resources sm8250_res =3D { .vcodec0_clks =3D { "vcodec0_core" }, .vcodec_clks_num =3D 1, .vcodec_pmdomains =3D { "venus", "vcodec0" }, + .vcodec_pmdomains_hwctrl =3D { false, true }, .vcodec_pmdomains_num =3D 2, .opp_pmdomain =3D (const char *[]) { "mx", NULL }, .vcodec_num =3D 1, @@ -871,6 +874,7 @@ static const struct venus_resources sc7280_res =3D { .vcodec0_clks =3D {"vcodec_core", "vcodec_bus"}, .vcodec_clks_num =3D 2, .vcodec_pmdomains =3D { "venus", "vcodec0" }, + .vcodec_pmdomains_hwctrl =3D { false, true }, .vcodec_pmdomains_num =3D 2, .opp_pmdomain =3D (const char *[]) { "cx", NULL }, .vcodec_num =3D 1, diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platf= orm/qcom/venus/core.h index 4a633261ece4..6d591ecad482 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -73,6 +73,7 @@ struct venus_resources { const char * const vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX]; unsigned int vcodec_clks_num; const char * const vcodec_pmdomains[VIDC_PMDOMAINS_NUM_MAX]; + bool vcodec_pmdomains_hwctrl[VIDC_PMDOMAINS_NUM_MAX]; unsigned int vcodec_pmdomains_num; const char **opp_pmdomain; unsigned int vcodec_num; diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media= /platform/qcom/venus/pm_helpers.c index 48c9084bb4db..c53eef23c793 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -408,35 +408,28 @@ static const struct venus_pm_ops pm_ops_v3 =3D { =20 static int vcodec_control_v4(struct venus_core *core, u32 coreid, bool ena= ble) { - void __iomem *ctrl, *stat; - u32 val; - int ret; - - if (IS_V6(core)) { - ctrl =3D core->wrapper_base + WRAPPER_CORE_POWER_CONTROL_V6; - stat =3D core->wrapper_base + WRAPPER_CORE_POWER_STATUS_V6; - } else if (coreid =3D=3D VIDC_CORE_ID_1) { - ctrl =3D core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL; - stat =3D core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_STATUS; - } else { - ctrl =3D core->wrapper_base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL; - stat =3D core->wrapper_base + WRAPPER_VCODEC1_MMCC_POWER_STATUS; - } - - if (enable) { - writel(0, ctrl); - - ret =3D readl_poll_timeout(stat, val, val & BIT(1), 1, 100); - if (ret) - return ret; - } else { - writel(1, ctrl); + int i, ret =3D 0; + struct device *dev =3D core->dev; + const struct venus_resources *res =3D core->res; =20 - ret =3D readl_poll_timeout(stat, val, !(val & BIT(1)), 1, 100); - if (ret) - return ret; + for (i =3D 0; i < res->vcodec_pmdomains_num; i++) { + if (res->vcodec_pmdomains_hwctrl[i]) { + + if (!core->pmdomains[i]) + return -ENODEV; + + /* + * enable( true ), switch the gdsc to SW mode + * enable( false), switch the gdsc to HW mode + */ + ret =3D dev_pm_genpd_set_hwmode(core->pmdomains[i], !enable); + if (ret) { + dev_err(dev, "Failed to switch power-domain:%d to %s mode\n", + i, enable ? "SW" : "HW"); + return ret; + } + } } - return 0; } =20 --=20 2.34.1