From patchwork Thu Nov 3 11:01:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 13029891 X-Patchwork-Delegate: viresh.linux@gmail.com 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 B5B1BC4332F for ; Thu, 3 Nov 2022 11:01:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231343AbiKCLBh (ORCPT ); Thu, 3 Nov 2022 07:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231393AbiKCLBa (ORCPT ); Thu, 3 Nov 2022 07:01:30 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFD01B7EB for ; Thu, 3 Nov 2022 04:01:27 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d10so1247881pfh.6 for ; Thu, 03 Nov 2022 04:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=rdlSJiSDdFVNFGf7aj1iVzyqCpSjnjyK7zZt5V+eoFk=; b=UAmCLml2yroJcnFXFQvvkzy2aNsqlmSGQS5t8dAlzArMlFBKaJvBqOYgjVuzPCG/bE L2WuZiDJamaQQHF2ZtSeEUW7/i0igpivEDO/H0L4WEvA96KyIp4Ir6RN5mH65cTc+2M7 uSNZPqD1dPevSMC1cs4iZuhIbno4Gm1Rqm0SPA93wu+ObgvakF0ME6NX0J9HsYvsCZvF gYm49A8S1d6ELns4/t72kFySs2bKD4wSQcIFa2W4uAii1H6TKDUFwRr3OI63qafeKe4t 1/WNmtSiTXdFO7DIb5EO1TUOV4ctgbAKuGeVs62PKSYpI4fPzdnAVRZR26VNUsmsW+eI RMcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=rdlSJiSDdFVNFGf7aj1iVzyqCpSjnjyK7zZt5V+eoFk=; b=wNV3p5PZoHwBCL1ksXsaNRJcYyQ+zjtfLgkeeQtLXkC59rZJQrGrCEzzQjgMJKFNVB KK30W9XzvHapaMgVZfRfxrVVr2f+RTWl7N1JeK6+QsKLHdiJIZPUvJDKF8wXzEsRMBVg uyq0Xvhb5Mc2+8E2jw07+tEVsLXCuRHrQuB/WMvP8GBMDjML7Z9l+2svr/u+kjWDqOF/ QPUYSbwe+CYRpR5A5u0UsmnGWFWkYhR/6HltV6l78BmGLbXNQIaXvaC3eTdN6s0T4Tm4 LShff7nstyhzni3y/Djsaa6NOSDx5hG6h9RKuJtV1FZidq+Pm6o5dG/+hQr18NHaplZp 2Kaw== X-Gm-Message-State: ACrzQf0LdEGxmzdJKpEnqbPzYyY4HvFrfuhLiy5CAUZ0ifhcbWpC6HGK SWVX10xP++5kFAfM6iRm3FNWDQ== X-Google-Smtp-Source: AMsMyM5Tmy8uLzzWKsj3p8zB/Bu8mxxZ/K6C/aTTqngKlL9AKMx2cTWBUah3RAb1oXK+BGWrxzA2qQ== X-Received: by 2002:a05:6a00:140f:b0:56e:1190:e731 with SMTP id l15-20020a056a00140f00b0056e1190e731mr7920554pfu.39.1667473287402; Thu, 03 Nov 2022 04:01:27 -0700 (PDT) Received: from localhost ([122.172.84.80]) by smtp.gmail.com with ESMTPSA id gm22-20020a17090b101600b002132f3e71c6sm684726pjb.52.2022.11.03.04.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 04:01:22 -0700 (PDT) From: Viresh Kumar To: James Calligeros , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] dt-bindings: opp: Fix usage of current in microwatt property Date: Thu, 3 Nov 2022 16:31:04 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The bindings mentions "current" instead of "power". Fix it. Signed-off-by: Viresh Kumar --- Documentation/devicetree/bindings/opp/opp-v2-base.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/opp/opp-v2-base.yaml b/Documentation/devicetree/bindings/opp/opp-v2-base.yaml index 66d0ec763f0b..cb025b0a346d 100644 --- a/Documentation/devicetree/bindings/opp/opp-v2-base.yaml +++ b/Documentation/devicetree/bindings/opp/opp-v2-base.yaml @@ -108,7 +108,7 @@ select: false The power for the OPP in micro-Watts. Entries for multiple regulators shall be provided in the same field - separated by angular brackets <>. If current values aren't required + separated by angular brackets <>. If power values aren't required for a regulator, then it shall be filled with 0. If power values aren't required for any of the regulators, then this field is not required. The OPP binding doesn't provide any provisions to relate the From patchwork Thu Nov 3 11:01:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 13029892 X-Patchwork-Delegate: viresh.linux@gmail.com 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 0C020C4332F for ; Thu, 3 Nov 2022 11:01:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbiKCLBi (ORCPT ); Thu, 3 Nov 2022 07:01:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbiKCLBc (ORCPT ); Thu, 3 Nov 2022 07:01:32 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB983B7DD for ; Thu, 3 Nov 2022 04:01:31 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id 64so1342241pgc.5 for ; Thu, 03 Nov 2022 04:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=E6BayU7+whKMo3/qWo30Lf+/AWFHgaDluxjQcRS3B+I=; b=zBFjYYnEhLeXIdKyW1HwYfCDZkwamdYAyCaULgx22W6EDH2VciVt6JBdjuhARELL7Z B6TRmjSnBhSjw1uHc1PgyjAgbZqRJCo/5A1nWb5bHfG6WOF/WuQVA4HTv7b0a2xLswx1 HYopKypv+/vT4/DxU0fHpK1pQNpu1pB7+3PElCF168ELSPW39BWfKleEHxSU9J0Fy7KB YvV1ZlHt3T1RcAuYWKU57QZY6hn+uM3jd72mlvRAKS7NYweoyk951Iy2kJIO03mAzs65 VNKwiTb/seEZcw+57WkozNYEn0gMa3GDAhUC+tFjhSNTyu07QiIx4cWUWLhKftY/l7dd FQfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=E6BayU7+whKMo3/qWo30Lf+/AWFHgaDluxjQcRS3B+I=; b=AGII1CMFmOeMiOnpDMa97+etxeUCoUh7MN4mSerxYXfYEUOL38ABuHEFnwrhuAEgzb mAXfDy3uxKsh0UnwzZ8JPnmQKWWGwz/EmkiX7yIFqZLvnGFiX2/krlc6WqOzfG0WEsIc EFLFDCtG1t6CXSFO8RHMkY914Mg9dJWmGvjBH5GvXdQpxIXuBeEcGpp5dRGNZpeaz/bT nB8RgHq3MFbK1JTXacC3yIsWJe9iDDZjry22+7VYGpyzcT8AHD7Y8tZ6cBKAiCVbTgt0 HL5khTWQw5qUWzHv4zAtTjP03rktVWnWBZvOSo+A0bDT6m+w+fFbf4nRG/voDKBIiCdN Qagg== X-Gm-Message-State: ACrzQf2Ycrs8xWML+cYUsRpM1LDVimjqu3ITd0QtxjqmyKVhwNY/zela 9oQpZmPeppdHO9IDcrycmnklKg== X-Google-Smtp-Source: AMsMyM4HjVW6bkRyhyG5xTtXGuUSaciInOBhBw7kerR3KeoO2GrpLemNgw+shfbnxFL628VqHpEE9g== X-Received: by 2002:a63:3347:0:b0:470:1a94:4bf with SMTP id z68-20020a633347000000b004701a9404bfmr3864142pgz.374.1667473291406; Thu, 03 Nov 2022 04:01:31 -0700 (PDT) Received: from localhost ([122.172.84.80]) by smtp.gmail.com with ESMTPSA id f3-20020a170902f38300b0016c50179b1esm355601ple.152.2022.11.03.04.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 04:01:30 -0700 (PDT) From: Viresh Kumar To: James Calligeros , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] dt-bindings: opp: Fix named microwatt property Date: Thu, 3 Nov 2022 16:31:05 +0530 Message-Id: <52bfa57ae698da9881e8a9302473e87f5757d5b6.1667473008.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The named microwatt- property should look exactly like microvolt and microamp properties. There were some differences, fix them. Signed-off-by: Viresh Kumar --- Documentation/devicetree/bindings/opp/opp-v2-base.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/opp/opp-v2-base.yaml b/Documentation/devicetree/bindings/opp/opp-v2-base.yaml index cb025b0a346d..cf9c2f7bddc2 100644 --- a/Documentation/devicetree/bindings/opp/opp-v2-base.yaml +++ b/Documentation/devicetree/bindings/opp/opp-v2-base.yaml @@ -230,9 +230,9 @@ select: false minItems: 1 maxItems: 8 # Should be enough regulators - '^opp-microwatt': + '^opp-microwatt-': description: - Named opp-microwatt property. Similar to opp-microamp property, + Named opp-microwatt property. Similar to opp-microamp- property, but for microwatt instead. $ref: /schemas/types.yaml#/definitions/uint32-array minItems: 1 From patchwork Thu Nov 3 11:01:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 13029893 X-Patchwork-Delegate: viresh.linux@gmail.com 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 41E2BC4332F for ; Thu, 3 Nov 2022 11:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231381AbiKCLBm (ORCPT ); Thu, 3 Nov 2022 07:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231373AbiKCLBh (ORCPT ); Thu, 3 Nov 2022 07:01:37 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78BC5B862 for ; Thu, 3 Nov 2022 04:01:36 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id k7so1563614pll.6 for ; Thu, 03 Nov 2022 04:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=CUlxdNeoLlpwqgvI1vJN7b1g7ZmITiL31RBfTgzzy+4=; b=XJqmPRwvw+FN/EEePw4qaKUzYroDLu2G9Z6BA7HPgsLyBuvWmXKCSGvjHrIuOEIARG uLbAxrwgIuW4C5fAjPdhLpEMEd99EaT457UbyTI8jBNoVJv6ZVLJnMKPnFxE94t0pcCL ir0xmdfgQ/FjROoq+EP+b2wH+9gP6VhFXEjgdgSxIout3u2ddUFIXPyJL8HVuA+JcCEc AGD/OxvZS1hTK32WR0qll0Hdq/35CG2SO78CgHKA9m/Xi8/d69FtbaYQvyZsPFGyGHTi 0LG17JB/H9gightd066xVQsKspk0uBv9QvMyjhnSLn1vEY/pM4WshA9PVhP4R62yNHhJ 5Vsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=CUlxdNeoLlpwqgvI1vJN7b1g7ZmITiL31RBfTgzzy+4=; b=6ZS59rPCUM8hjZURYQRlYjSGpW7e2JD09wQoe7f0uO4gYM8Xvjqg1d5+DB11xI/6Mu dopC2X5Ud24QPD3nDVIvWiJopn3h0v8ML9T6j0ihQond2rOJgS6S3vA3MwjpNZzhHpM7 V50Yj5yChlqWLGn+RU2d9bJG09YgBmDRWg0rOSZBh2yCDWuF0Aewe+YKjZZ0J5MyYPiB VkbaUWxrLFJEthQ94zf2VWM9/jwgiAyDfiCg1QFzRWFtL/gEWT7/RnydT4K6I9EisTcL y8UCtlsdiu1VhcY7sUcPbhqoqGiVdRb+u0p/3k3mysKBhIl5XVox7efvCgPnyDJvDRid rW4g== X-Gm-Message-State: ACrzQf0XPEaPENlAm4du+LIbpDIobxeIIAVSXtMpDhdFrMDT/tYksMUb rLoeLsgUap6CF6aurdiu0M0k1Q== X-Google-Smtp-Source: AMsMyM7+o44INWslrGpI+jefjbcGs9mWsqvc/VDaW4kwMbJEnEDqYNM+dVUGYoQeRY7M6xLcvREWxQ== X-Received: by 2002:a17:90a:d084:b0:213:8cf1:4d34 with SMTP id k4-20020a17090ad08400b002138cf14d34mr31351688pju.150.1667473295998; Thu, 03 Nov 2022 04:01:35 -0700 (PDT) Received: from localhost ([122.172.84.80]) by smtp.gmail.com with ESMTPSA id s2-20020a170902b18200b001871acf245csm391281plr.37.2022.11.03.04.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 04:01:35 -0700 (PDT) From: Viresh Kumar To: James Calligeros , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH 3/5] OPP: Parse named opp-microwatt property too Date: Thu, 3 Nov 2022 16:31:06 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org We missed parsing the named opp-microwatt- property, fix that. Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 605d68673f92..e010e119c42b 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -695,9 +695,19 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, } } - /* Search for "opp-microwatt" */ - sprintf(name, "opp-microwatt"); - prop = of_find_property(opp->np, name, NULL); + /* Search for "opp-microwatt-" */ + prop = NULL; + if (opp_table->prop_name) { + snprintf(name, sizeof(name), "opp-microwatt-%s", + opp_table->prop_name); + prop = of_find_property(opp->np, name, NULL); + } + + if (!prop) { + /* Search for "opp-microwatt" */ + sprintf(name, "opp-microwatt"); + prop = of_find_property(opp->np, name, NULL); + } if (prop) { pcount = of_property_count_u32_elems(opp->np, name); From patchwork Thu Nov 3 11:01:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 13029894 X-Patchwork-Delegate: viresh.linux@gmail.com 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 5BE84C4332F for ; Thu, 3 Nov 2022 11:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230396AbiKCLBp (ORCPT ); Thu, 3 Nov 2022 07:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231378AbiKCLBl (ORCPT ); Thu, 3 Nov 2022 07:01:41 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E480B85F for ; Thu, 3 Nov 2022 04:01:40 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id r18so1321173pgr.12 for ; Thu, 03 Nov 2022 04:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=jKnEZG0ef1w3+ZtyBo/x5Fjh/UyIelJHnysoJI3A1/8=; b=M/k9L/GATSz3t4hC6JTpBUGIjCJJ+L5qRie3ARsFP0YAVMwwS8hJcprzYnjHgBiZFC JQsycKDKpqWj8grx1dC5NEnjUIk2Sc4Nh3jWiqN8/ECXYdWtTAaKHZo0qV2rKIek12Xw 2TVsLH4Cz4GmkwcJSrR59QhTA1KmNdS1Hw2fx2ZHK9H+yr3QfkFuQO9DL47np6DRic4g Un5TVyF+TMYrtZWrYQ8QvE16ARmZMQV7rFI0AUa/2h+CxzLhQIiulGBW1W3ced9RNGCD dG++DjXtkjNM4EfSy61SpEIHefsrFsX67Swfdbwko9yf3HirK83PtIZ3o7uSCPnQ2hEn tm8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=jKnEZG0ef1w3+ZtyBo/x5Fjh/UyIelJHnysoJI3A1/8=; b=WuKG9abExdrom4v7BGoS5x8J122oXGNMZuWhWGRLdoQr6HgbNPOLnhwCzbzigohVCT wSKhv7NjtxTHG7EKomvZkT0KL1L76qHd8Ap8q/AUYB4MD0Dw75cdlaZ0VMP6lLR3DAWU pioiyzli60gNYI+hSX+89gNj+6x9Ejtb0rRsq9jNHnynUj3qh7JZgs8k2ENEDpuwjSlX jRdng4ZNKe3WNpY81CriV+Rl62zK+mmTvIa5pL6kWP1TVlAM7L4M7hUGwL3qZBvMQy7z L7j4TUV6J4npLx10WX1+4GJyQMFLrx0xGa23kZO25R9mlRB+khtk6K2h5YbXK7mUMFMU NUAg== X-Gm-Message-State: ACrzQf3tLX0P9Twv+aigU556EsQd8WckTb+Dif9UFnq5sUV+AuJglKFb 8N+rYHv1ktKcK/UrqgSEC9k2zA== X-Google-Smtp-Source: AMsMyM4dVhJX1yGhZhr6WzIziWnaGlZDw/A/iObTpehlPp5zHnq37z035BHCsoaJg+MsELfh+4zvqg== X-Received: by 2002:a63:106:0:b0:460:64ce:51c4 with SMTP id 6-20020a630106000000b0046064ce51c4mr25372692pgb.17.1667473299580; Thu, 03 Nov 2022 04:01:39 -0700 (PDT) Received: from localhost ([122.172.84.80]) by smtp.gmail.com with ESMTPSA id o9-20020a17090ab88900b0020d39ffe987sm699759pjr.50.2022.11.03.04.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 04:01:39 -0700 (PDT) From: Viresh Kumar To: James Calligeros , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH 4/5] OPP: Simplify opp_parse_supplies() by restructuring it Date: Thu, 3 Nov 2022 16:31:07 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org opp_parse_supplies() has grown into too big of a routine (~190 lines) and it is not straight-forward to understand it anymore. Break it into smaller routines and reduce code redundancy a bit by using the same code to parse properties. This shouldn't result in any logical changes. Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 216 ++++++++++++++++++----------------------------- 1 file changed, 81 insertions(+), 135 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index e010e119c42b..e51c43495e21 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -578,179 +578,126 @@ static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, return false; } -static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, - struct opp_table *opp_table) +static u32 *_parse_named_prop(struct dev_pm_opp *opp, struct device *dev, + struct opp_table *opp_table, + const char *prop_type, bool *triplet) { - u32 *microvolt, *microamp = NULL, *microwatt = NULL; - int supplies = opp_table->regulator_count; - int vcount, icount, pcount, ret, i, j; struct property *prop = NULL; char name[NAME_MAX]; + int count, ret; + u32 *out; - /* Search for "opp-microvolt-" */ + /* Search for "opp--" */ if (opp_table->prop_name) { - snprintf(name, sizeof(name), "opp-microvolt-%s", + snprintf(name, sizeof(name), "opp-%s-%s", prop_type, opp_table->prop_name); prop = of_find_property(opp->np, name, NULL); } if (!prop) { - /* Search for "opp-microvolt" */ - sprintf(name, "opp-microvolt"); + /* Search for "opp-" */ + snprintf(name, sizeof(name), "opp-%s", prop_type); prop = of_find_property(opp->np, name, NULL); - - /* Missing property isn't a problem, but an invalid entry is */ - if (!prop) { - if (unlikely(supplies == -1)) { - /* Initialize regulator_count */ - opp_table->regulator_count = 0; - return 0; - } - - if (!supplies) - return 0; - - dev_err(dev, "%s: opp-microvolt missing although OPP managing regulators\n", - __func__); - return -EINVAL; - } - } - - if (unlikely(supplies == -1)) { - /* Initialize regulator_count */ - supplies = opp_table->regulator_count = 1; - } else if (unlikely(!supplies)) { - dev_err(dev, "%s: opp-microvolt wasn't expected\n", __func__); - return -EINVAL; + if (!prop) + return NULL; } - vcount = of_property_count_u32_elems(opp->np, name); - if (vcount < 0) { - dev_err(dev, "%s: Invalid %s property (%d)\n", - __func__, name, vcount); - return vcount; + count = of_property_count_u32_elems(opp->np, name); + if (count < 0) { + dev_err(dev, "%s: Invalid %s property (%d)\n", __func__, name, + count); + return ERR_PTR(count); } - /* There can be one or three elements per supply */ - if (vcount != supplies && vcount != supplies * 3) { - dev_err(dev, "%s: Invalid number of elements in %s property (%d) with supplies (%d)\n", - __func__, name, vcount, supplies); - return -EINVAL; + /* + * Initialize regulator_count, if regulator information isn't provided + * by the platform. Now that one of the properties is available, fix the + * regulator_count to 1. + */ + if (unlikely(opp_table->regulator_count == -1)) + opp_table->regulator_count = 1; + + if (count != opp_table->regulator_count && + (!triplet || count != opp_table->regulator_count * 3)) { + dev_err(dev, "%s: Invalid number of elements in %s property (%u) with supplies (%d)\n", + __func__, prop_type, count, opp_table->regulator_count); + return ERR_PTR(-EINVAL); } - microvolt = kmalloc_array(vcount, sizeof(*microvolt), GFP_KERNEL); - if (!microvolt) - return -ENOMEM; + out = kmalloc_array(count, sizeof(*out), GFP_KERNEL); + if (!out) + return ERR_PTR(-EINVAL); - ret = of_property_read_u32_array(opp->np, name, microvolt, vcount); + ret = of_property_read_u32_array(opp->np, name, out, count); if (ret) { dev_err(dev, "%s: error parsing %s: %d\n", __func__, name, ret); - ret = -EINVAL; - goto free_microvolt; + kfree(out); + return ERR_PTR(-EINVAL); } - /* Search for "opp-microamp-" */ - prop = NULL; - if (opp_table->prop_name) { - snprintf(name, sizeof(name), "opp-microamp-%s", - opp_table->prop_name); - prop = of_find_property(opp->np, name, NULL); - } + if (triplet) + *triplet = count != opp_table->regulator_count; - if (!prop) { - /* Search for "opp-microamp" */ - sprintf(name, "opp-microamp"); - prop = of_find_property(opp->np, name, NULL); - } - - if (prop) { - icount = of_property_count_u32_elems(opp->np, name); - if (icount < 0) { - dev_err(dev, "%s: Invalid %s property (%d)\n", __func__, - name, icount); - ret = icount; - goto free_microvolt; - } + return out; +} - if (icount != supplies) { - dev_err(dev, "%s: Invalid number of elements in %s property (%d) with supplies (%d)\n", - __func__, name, icount, supplies); - ret = -EINVAL; - goto free_microvolt; - } +static u32 *opp_parse_microvolt(struct dev_pm_opp *opp, struct device *dev, + struct opp_table *opp_table, bool *triplet) +{ + u32 *microvolt; - microamp = kmalloc_array(icount, sizeof(*microamp), GFP_KERNEL); - if (!microamp) { - ret = -EINVAL; - goto free_microvolt; - } + microvolt = _parse_named_prop(opp, dev, opp_table, "microvolt", triplet); + if (IS_ERR(microvolt)) + return microvolt; - ret = of_property_read_u32_array(opp->np, name, microamp, - icount); - if (ret) { - dev_err(dev, "%s: error parsing %s: %d\n", __func__, - name, ret); - ret = -EINVAL; - goto free_microamp; + if (!microvolt) { + /* + * Missing property isn't a problem, but an invalid + * entry is. This property isn't optional if regulator + * information is provided. + */ + if (opp_table->regulator_count > 0) { + dev_err(dev, "%s: opp-microvolt missing although OPP managing regulators\n", + __func__); + return ERR_PTR(-EINVAL); } } - /* Search for "opp-microwatt-" */ - prop = NULL; - if (opp_table->prop_name) { - snprintf(name, sizeof(name), "opp-microwatt-%s", - opp_table->prop_name); - prop = of_find_property(opp->np, name, NULL); - } - - if (!prop) { - /* Search for "opp-microwatt" */ - sprintf(name, "opp-microwatt"); - prop = of_find_property(opp->np, name, NULL); - } + return microvolt; +} - if (prop) { - pcount = of_property_count_u32_elems(opp->np, name); - if (pcount < 0) { - dev_err(dev, "%s: Invalid %s property (%d)\n", __func__, - name, pcount); - ret = pcount; - goto free_microamp; - } +static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, + struct opp_table *opp_table) +{ + u32 *microvolt, *microamp, *microwatt; + int ret, i, j; + bool triplet; - if (pcount != supplies) { - dev_err(dev, "%s: Invalid number of elements in %s property (%d) with supplies (%d)\n", - __func__, name, pcount, supplies); - ret = -EINVAL; - goto free_microamp; - } + microvolt = opp_parse_microvolt(opp, dev, opp_table, &triplet); + if (IS_ERR_OR_NULL(microvolt)) + return PTR_ERR(microvolt); - microwatt = kmalloc_array(pcount, sizeof(*microwatt), - GFP_KERNEL); - if (!microwatt) { - ret = -EINVAL; - goto free_microamp; - } + microamp = _parse_named_prop(opp, dev, opp_table, "microamp", NULL); + if (IS_ERR(microamp)) { + ret = PTR_ERR(microamp); + goto free_microvolt; + } - ret = of_property_read_u32_array(opp->np, name, microwatt, - pcount); - if (ret) { - dev_err(dev, "%s: error parsing %s: %d\n", __func__, - name, ret); - ret = -EINVAL; - goto free_microwatt; - } + microwatt = _parse_named_prop(opp, dev, opp_table, "microwatt", NULL); + if (IS_ERR(microwatt)) { + ret = PTR_ERR(microwatt); + goto free_microamp; } - for (i = 0, j = 0; i < supplies; i++) { + for (i = 0, j = 0; i < opp_table->regulator_count; i++) { opp->supplies[i].u_volt = microvolt[j++]; - if (vcount == supplies) { - opp->supplies[i].u_volt_min = opp->supplies[i].u_volt; - opp->supplies[i].u_volt_max = opp->supplies[i].u_volt; - } else { + if (triplet) { opp->supplies[i].u_volt_min = microvolt[j++]; opp->supplies[i].u_volt_max = microvolt[j++]; + } else { + opp->supplies[i].u_volt_min = opp->supplies[i].u_volt; + opp->supplies[i].u_volt_max = opp->supplies[i].u_volt; } if (microamp) @@ -760,7 +707,6 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, opp->supplies[i].u_watt = microwatt[i]; } -free_microwatt: kfree(microwatt); free_microamp: kfree(microamp); From patchwork Thu Nov 3 11:01:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 13029896 X-Patchwork-Delegate: viresh.linux@gmail.com 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 5004DC4332F for ; Thu, 3 Nov 2022 11:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231484AbiKCLCP (ORCPT ); Thu, 3 Nov 2022 07:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbiKCLCB (ORCPT ); Thu, 3 Nov 2022 07:02:01 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3990B11471 for ; Thu, 3 Nov 2022 04:01:55 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id c2so1541768plz.11 for ; Thu, 03 Nov 2022 04:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=fsmUR9VBjzdfb/PGMg0vmzjLCq4QjfuLi4iPrW87qL0=; b=GHinC0PrjwVZKhYfmM8nt17mNc2XQ9VSl2eWqe4GgpapVAog+Tw41GRAzFQDLdwSfh 3U27PBnVZm8Z31LLeWf798nvm6I8hmccO+gZsY8kqIMjeRMuE6yovKGZTftmyFWoNXMx nQX/kahB2mbF7pom1+RpekbBuhWNpUUy/17bBbYAvjDZPAp5bqtFuWwQ7ii4/apHMqQ+ v5qdpSlzR0b4MQuhEkxaKojApu8ykXPymUmAb63meFdW3KxBXuYS4SBRtkmJIs4YHBrR jeSy+UfYb4f/uBYwd9A/FslWy97JajxeHtcU1FLdd60oolyMEa/NwIYdHCCx5TozlFZ4 C/2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=fsmUR9VBjzdfb/PGMg0vmzjLCq4QjfuLi4iPrW87qL0=; b=gBbwqoKvcjNOJq09hCSJpna/yCQ4S5aONm0ANpslKDyzNcCKW5fxlaiGcImKCiTb04 Mhy8iz574DFRy9DPuELRztr/FyOs0e1pAIXxenFgF+ex4For9UJ+HWzCtk5GzUTqxV5K ABO5atOQj7I1ADk+ZSiZZp3su2D47lMTNvOupr3bXnrhOL8umPs1hmoZmZSD8aApRSpk eencauuaTsVyc4S82ijziq1ObrZjor3fMcrB4CrZMHoWwQZ8+gJ5W64LXT1dxmiiiS4V 5OM4YGIBcTxoL3hKbBcn2SEup1SoyzQs7NretHYJNU/BW4sK1QJCmreAk1pZCtp1VZT4 pOkA== X-Gm-Message-State: ACrzQf2HK2L5Es+BIUNdsM+JBNHWp27ceCzJ6k1zJQ4geghKDMmAZNzL Zxo8IRBj1j8O9sRZCqqdsWKIxA== X-Google-Smtp-Source: AMsMyM6XSKlbSK0JuqjYQIz/h/+VQHH4mk0vaC5SsBya5JFSTXHYTK4fF7hmoELCXp9bmqBQJsmNNw== X-Received: by 2002:a17:90b:3690:b0:213:c985:b5ee with SMTP id mj16-20020a17090b369000b00213c985b5eemr25247343pjb.192.1667473314641; Thu, 03 Nov 2022 04:01:54 -0700 (PDT) Received: from localhost ([122.172.84.80]) by smtp.gmail.com with ESMTPSA id b33-20020a630c21000000b00461b85e5ad6sm560176pgl.19.2022.11.03.04.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 04:01:43 -0700 (PDT) From: Viresh Kumar To: James Calligeros , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH V2 5/5] OPP: decouple dt properties in opp_parse_supplies() Date: Thu, 3 Nov 2022 16:31:08 +0530 Message-Id: <5acd93462bff6c108d65802fd39f6002dfadd1a0.1667473008.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: James Calligeros The opp-microwatt property was added with the intention of providing platforms a way to specify a precise value for the power consumption of a device at a given OPP to enable better energy-aware scheduling decisions by informing the kernel of the total static and dynamic power of a device at a given OPP, removing the reliance on the EM subsystem's often flawed estimations. This property is parsed by opp_parse_supplies(), which creates a hard dependency on the opp-microvolt property. Some platforms, such as Apple Silicon, do not describe their device's voltage regulators in the DT as they cannot be controlled by the kernel and/or rely on opaque firmware algorithms to control their voltage and current characteristics at runtime. We can, however, experimentally determine the power consumption of a given device at a given OPP, taking advantage of opp-microwatt to provide EAS on such devices as was initially intended. Allow platforms to specify and consume any subset of opp-microvolt, opp-microamp, or opp-microwatt without a hard dependency on opp-microvolt to enable this functionality on such platforms. Signed-off-by: James Calligeros Co-developed-by: Viresh Kumar Signed-off-by: Viresh Kumar Tested-by: James Calligeros --- V2: Rewritten by Viresh on top of his changes. drivers/opp/of.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index e51c43495e21..273fa9c0e1c0 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -654,9 +654,12 @@ static u32 *opp_parse_microvolt(struct dev_pm_opp *opp, struct device *dev, /* * Missing property isn't a problem, but an invalid * entry is. This property isn't optional if regulator - * information is provided. + * information is provided. Check only for the first OPP, as + * regulator_count may get initialized after that to a valid + * value. */ - if (opp_table->regulator_count > 0) { + if (list_empty(&opp_table->opp_list) && + opp_table->regulator_count > 0) { dev_err(dev, "%s: opp-microvolt missing although OPP managing regulators\n", __func__); return ERR_PTR(-EINVAL); @@ -674,7 +677,7 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, bool triplet; microvolt = opp_parse_microvolt(opp, dev, opp_table, &triplet); - if (IS_ERR_OR_NULL(microvolt)) + if (IS_ERR(microvolt)) return PTR_ERR(microvolt); microamp = _parse_named_prop(opp, dev, opp_table, "microamp", NULL); @@ -689,15 +692,26 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, goto free_microamp; } - for (i = 0, j = 0; i < opp_table->regulator_count; i++) { - opp->supplies[i].u_volt = microvolt[j++]; + /* + * Initialize regulator_count if it is uninitialized and no properties + * are found. + */ + if (unlikely(opp_table->regulator_count == -1)) { + opp_table->regulator_count = 0; + return 0; + } - if (triplet) { - opp->supplies[i].u_volt_min = microvolt[j++]; - opp->supplies[i].u_volt_max = microvolt[j++]; - } else { - opp->supplies[i].u_volt_min = opp->supplies[i].u_volt; - opp->supplies[i].u_volt_max = opp->supplies[i].u_volt; + for (i = 0, j = 0; i < opp_table->regulator_count; i++) { + if (microvolt) { + opp->supplies[i].u_volt = microvolt[j++]; + + if (triplet) { + opp->supplies[i].u_volt_min = microvolt[j++]; + opp->supplies[i].u_volt_max = microvolt[j++]; + } else { + opp->supplies[i].u_volt_min = opp->supplies[i].u_volt; + opp->supplies[i].u_volt_max = opp->supplies[i].u_volt; + } } if (microamp)