From patchwork Fri Oct 13 08:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 733977 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 78694CDB483 for ; Fri, 13 Oct 2023 08:48:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230223AbjJMIs6 (ORCPT ); Fri, 13 Oct 2023 04:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbjJMIsz (ORCPT ); Fri, 13 Oct 2023 04:48:55 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA98BF for ; Fri, 13 Oct 2023 01:48:53 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c8a1541232so16350055ad.0 for ; Fri, 13 Oct 2023 01:48:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697186933; x=1697791733; 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=9sgnTvvfVpiAPPJ8fiCTAGKK94xzxBt3csYQrYp95xs=; b=R2ylfw32owgpzXLev8WI4JbQpc3yML7eAnkdXT5dDeEAebPG0A/7OBW7J/dELPNu2w mJPUnQnN9+p6WFmju7Ewbaadn0kh1hsG+x9k/4dhf5zHJjQhJ+Qay8p8av5bpGpdM8Cx vM649EOJpmNOx3KT5sN1lBRqEFJSGLoLmBANaJfhJMjyg1CPMWB2U8Epyl4gzPJjRpNB PsTNY9980KC3u+d2e2ZSni/xHMJ1zJUrObOExCefmgzo38lj8R3CcK9OzW81CBRguljO dv5RQVWjKrKXc+DgATL9uDr0REFwOLN9GuRkI/RmNGaEgYZgv+rjTI06EtTj5Fxg62ta Ob8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697186933; x=1697791733; 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=9sgnTvvfVpiAPPJ8fiCTAGKK94xzxBt3csYQrYp95xs=; b=JCQlWJHjpRlNfuKgVqgB2G4F85ctKHXA4LL+6ifdnQPaUd55ex+KTtks8x1eMkk6lH 2WzFjDYG7qbJbXhQ+sFfKTVIL93aOlYUFgjxNS22XP48K4QoGsb24miBiPWYrrv2zorz Wh/PW/LevTvBeJGgs6ONa0GdSGa8g1lOdlSbqIZbKuhQY2ixIw69gI81AzHAVw4wOGoZ 2e68aelqKChJ/Au1JytInOOO8EAMi2n8PW5I1Nq9xbkI6JnURSqToFP0dSvO+JJLroWG CliA7gvoKDJBEU2phQtCJvoPFi8bwi6y2LJuLadVQWzi/u0r9Od6unw8vB1NRUJMbPVn mTxg== X-Gm-Message-State: AOJu0YxJoWRQAmxmaipR67ZcqZGzYzQtUnPUyecoONjfCJWyi4KdVd1k n2tinJSJ7VOQfydEtmPcpSxLlg== X-Google-Smtp-Source: AGHT+IF2PPXyHg4vc+2knzO5ZIY73/rxsaTy2n8oV7cgwV6Vqk1cB/jpSupaaNzdiEAXhUNvDwonwQ== X-Received: by 2002:a17:902:e84d:b0:1c5:ec97:1718 with SMTP id t13-20020a170902e84d00b001c5ec971718mr30704438plg.6.1697186932843; Fri, 13 Oct 2023 01:48:52 -0700 (PDT) Received: from localhost ([122.172.80.14]) by smtp.gmail.com with ESMTPSA id u9-20020a170902a60900b001c06dcd453csm3323741plq.236.2023.10.13.01.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:48:51 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] OPP: Fix formatting of if/else block Date: Fri, 13 Oct 2023 14:18:37 +0530 Message-Id: <58b984a1144b0db1dd6bdbcbbfbac69326f02dd1.1697186772.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 Add {} to both if else blocks or none. Signed-off-by: Viresh Kumar Reviewed-by: Ulf Hansson --- drivers/opp/of.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index ae5c405bbf9a..85e2af3d6a49 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -208,9 +208,9 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table, mutex_lock(&opp_table_lock); list_add(&opp_table->lazy, &lazy_opp_tables); mutex_unlock(&opp_table_lock); - } - else + } else { _update_set_required_opps(opp_table); + } goto put_np; From patchwork Fri Oct 13 08:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 733602 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 0E07ACDB482 for ; Fri, 13 Oct 2023 08:49:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230125AbjJMIs7 (ORCPT ); Fri, 13 Oct 2023 04:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230159AbjJMIs6 (ORCPT ); Fri, 13 Oct 2023 04:48:58 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88B62C0 for ; Fri, 13 Oct 2023 01:48:56 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c60cec8041so13460365ad.3 for ; Fri, 13 Oct 2023 01:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697186936; x=1697791736; 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=Uz759/oMLk+eLy7Ws95dezNQB9MhOE7jwblbgespyKU=; b=Pa8z4K60xTrZrs0pbRSt+uXHAxirfvwJnFfS+fvBmaHIF+7vPYoSzmAsKZ006jtFSw kFYeO0strsUSwb6eFCORNqGQCyW7RbB1SojSxbL6YLJ2bItef++hyco5BkVeQ5TnrqGd 9XrSBDyuBaTuXvpjh/AW/6ncIgJ0/lbH+DWONglt0zFyULaGKaTxZHAYBlUQOy6Csea5 hLq1ygBxsRJGBdo9r5J2PIllI1NcvqffY/nSmOr53zhrbpQuEqh/fF2qeXnfthBR7M54 UuQS+tWCYorJ+yp47hLG3DayVBq1wu1wWJFAcOJUzsxNX05T/M5TbjOdpxJATbKMC1s+ gQ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697186936; x=1697791736; 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=Uz759/oMLk+eLy7Ws95dezNQB9MhOE7jwblbgespyKU=; b=GA/6KezRjwC+/iZjvUSvHURjXpQdPAzJiGMj1VQzHgwgJdXzQkPMoV2kJXYejFV0Iw xiz5A9ZVo5h50Imr1HB+CiNxneF/Anh0g2V78XqD+Ih7IX/pan3gb31D8p+3nOYN5W8n qU1YyfZF2WlypR5Ep1Axiwlb5Kl/25tt/2aZrDLRl+brQ/qsF1M1i+/1g/xZPQYhuHrk 3L0sqatyR3bNjQfYHh8FVbFWLPDwrASyQmcaBKPmRtCcjyGcrEaqKOfO1Lb1NHa3VCOy aaAeIdxRBnAzW6tyulvgjnjwazHPwT1Nrrn8hkEC60srOffU28dUg/ja8NRhd0CdKH9k khMA== X-Gm-Message-State: AOJu0YwMR/2e8vNwbQUN/Mt7n/NLwI5spdTLme3uLDvRwbKxk6gCXgrj xzTTo86AoPH1W9WWbr9Gv5mQTQ== X-Google-Smtp-Source: AGHT+IEn4AbZLaJVaNmG1K6b3v0D9p4hLbiVeobmaJDFxcPbSUYBhHy5/sMFGyYpwHNr+iy8cE+XHQ== X-Received: by 2002:a17:902:b604:b0:1c9:ba6f:af04 with SMTP id b4-20020a170902b60400b001c9ba6faf04mr8135602pls.35.1697186935994; Fri, 13 Oct 2023 01:48:55 -0700 (PDT) Received: from localhost ([122.172.80.14]) by smtp.gmail.com with ESMTPSA id 6-20020a170902c14600b001b86492d724sm3321494plj.223.2023.10.13.01.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:48:55 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH 2/5] OPP: Add _link_required_opps() to avoid code duplication Date: Fri, 13 Oct 2023 14:18:38 +0530 Message-Id: <0890df8ddfafba0d9d214e73e4bb0e243a2db9fa.1697186772.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 Factor out _link_required_opps() to remove duplicate code. No functional change. Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 62 ++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 85e2af3d6a49..81fa27599d58 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -296,24 +296,41 @@ void _of_clear_opp(struct opp_table *opp_table, struct dev_pm_opp *opp) of_node_put(opp->np); } +static int _link_required_opps(struct dev_pm_opp *opp, + struct opp_table *required_table, int index) +{ + struct device_node *np; + + np = of_parse_required_opp(opp->np, index); + if (unlikely(!np)) + return -ENODEV; + + opp->required_opps[index] = _find_opp_of_np(required_table, np); + of_node_put(np); + + if (!opp->required_opps[index]) { + pr_err("%s: Unable to find required OPP node: %pOF (%d)\n", + __func__, opp->np, index); + return -ENODEV; + } + + return 0; +} + /* Populate all required OPPs which are part of "required-opps" list */ static int _of_opp_alloc_required_opps(struct opp_table *opp_table, struct dev_pm_opp *opp) { - struct dev_pm_opp **required_opps; struct opp_table *required_table; - struct device_node *np; int i, ret, count = opp_table->required_opp_count; if (!count) return 0; - required_opps = kcalloc(count, sizeof(*required_opps), GFP_KERNEL); - if (!required_opps) + opp->required_opps = kcalloc(count, sizeof(*opp->required_opps), GFP_KERNEL); + if (!opp->required_opps) return -ENOMEM; - opp->required_opps = required_opps; - for (i = 0; i < count; i++) { required_table = opp_table->required_opp_tables[i]; @@ -321,21 +338,9 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table, if (IS_ERR_OR_NULL(required_table)) continue; - np = of_parse_required_opp(opp->np, i); - if (unlikely(!np)) { - ret = -ENODEV; - goto free_required_opps; - } - - required_opps[i] = _find_opp_of_np(required_table, np); - of_node_put(np); - - if (!required_opps[i]) { - pr_err("%s: Unable to find required OPP node: %pOF (%d)\n", - __func__, opp->np, i); - ret = -ENODEV; + ret = _link_required_opps(opp, required_table, i); + if (ret) goto free_required_opps; - } } return 0; @@ -350,22 +355,13 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table, static int lazy_link_required_opps(struct opp_table *opp_table, struct opp_table *new_table, int index) { - struct device_node *required_np; struct dev_pm_opp *opp; + int ret; list_for_each_entry(opp, &opp_table->opp_list, node) { - required_np = of_parse_required_opp(opp->np, index); - if (unlikely(!required_np)) - return -ENODEV; - - opp->required_opps[index] = _find_opp_of_np(new_table, required_np); - of_node_put(required_np); - - if (!opp->required_opps[index]) { - pr_err("%s: Unable to find required OPP node: %pOF (%d)\n", - __func__, opp->np, index); - return -ENODEV; - } + ret = _link_required_opps(opp, new_table, index); + if (ret) + return ret; } return 0; From patchwork Fri Oct 13 08:48:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 733601 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 ACDA9CDB47E for ; Fri, 13 Oct 2023 08:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230246AbjJMItD (ORCPT ); Fri, 13 Oct 2023 04:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbjJMItC (ORCPT ); Fri, 13 Oct 2023 04:49:02 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9959FD9 for ; Fri, 13 Oct 2023 01:48:59 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6b26a3163acso343180b3a.2 for ; Fri, 13 Oct 2023 01:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697186939; x=1697791739; 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=Il8qfrUz/VvYSn9zWibaW2EcrYf9IhDD8qWnA/nDM/0=; b=zFvuZ+v6bcwUvKVEs+3fLEJhusLNtle5frH1gamu5LxaQSETaab5Aozpa6sGqw9qMT SeSmIxsc+ccqs/p+lveeerVxz4jHK1vGW2yXxcbFs9pbV72ge2///v4NJ6etsg5fnS/O jBl+qz7wLlkQxgSUN3yJuNZ6VLHqokTsEjBRD4yjJl9h5QP5cDpeYAbzU/sReQzli2p+ JgeJJvEgzZf/IDiR285Ev88BcpAfwZMlrxsJyplKi+s5EV/8oJzphjTXQe/shl5IGXSE B/rmGG4rVYoNPppTbjMidByz4p7KhBOpUe0PJnIbK9cZQ7TYd4Gje1CLVA/dp+s1VAOH WADg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697186939; x=1697791739; 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=Il8qfrUz/VvYSn9zWibaW2EcrYf9IhDD8qWnA/nDM/0=; b=ALSnX+q8ASubxT4PxvZiZYyJQaaabcxQYueg+7SUIxJGTooUqpVCi4JJWh/veNhYra Xn2dQbUhFjA16w2cIQzEQFxOo3i9l9BKk9xrt87oLYF2vHyjcBIMI7mdLP9HWOQYne7c 7YUveEXMPc9Sr6ranebhfIZzy38g1cNE9gYZ/NYxeziWdZNTRH2D9EBEtKA/2NiAt1MK yXzbHLp4ACa/vlfF3LM/mZxBaYi6+3MGgJ6U+CXqU2yUohj6yi2ylxgaWDczTZlN+bkH jQGpeRa+hdtGFp/nhU860jUxYb+j5UVA8qoAJBSY2n6ODBpe8L83fFT0Lx1JpsJc4z3o b19A== X-Gm-Message-State: AOJu0YwGrqq//YmPFPEI0eipqm7//d6ImfWV8O9Z3dTwytjUVlOFOAnU rBw/aAaePTEQTMfF5QyIXAMtZxA69IDGFlVYNqM= X-Google-Smtp-Source: AGHT+IFuX8OHWuQqLIHMu+hE/a9qLVdUVDAqw5Eo/AfAH/SMAqPwytZyqJGU2cHfT2sWeC/2xRVuaw== X-Received: by 2002:a05:6a00:b8f:b0:693:4202:b535 with SMTP id g15-20020a056a000b8f00b006934202b535mr29675823pfj.27.1697186939127; Fri, 13 Oct 2023 01:48:59 -0700 (PDT) Received: from localhost ([122.172.80.14]) by smtp.gmail.com with ESMTPSA id g24-20020a62e318000000b00696e8215d28sm13025120pfh.20.2023.10.13.01.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:48:58 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH 3/5] OPP: Reorder code in _opp_set_required_opps_genpd() Date: Fri, 13 Oct 2023 14:18:39 +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 Reorder code in _opp_set_required_opps_genpd() to reduce duplicate code. Signed-off-by: Viresh Kumar Reviewed-by: Ulf Hansson --- drivers/opp/core.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index f42b663a4d8b..3516e79cf743 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1076,7 +1076,18 @@ static int _opp_set_required_opps_genpd(struct device *dev, { struct device **genpd_virt_devs = opp_table->genpd_virt_devs ? opp_table->genpd_virt_devs : &dev; - int i, ret = 0; + int index, target, delta, ret; + + /* Scaling up? Set required OPPs in normal order, else reverse */ + if (!scaling_down) { + index = 0; + target = opp_table->required_opp_count; + delta = 1; + } else { + index = opp_table->required_opp_count - 1; + target = -1; + delta = -1; + } /* * Acquire genpd_virt_dev_lock to make sure we don't use a genpd_dev @@ -1084,24 +1095,17 @@ static int _opp_set_required_opps_genpd(struct device *dev, */ mutex_lock(&opp_table->genpd_virt_dev_lock); - /* Scaling up? Set required OPPs in normal order, else reverse */ - if (!scaling_down) { - for (i = 0; i < opp_table->required_opp_count; i++) { - ret = _set_performance_state(dev, genpd_virt_devs[i], opp, i); - if (ret) - break; - } - } else { - for (i = opp_table->required_opp_count - 1; i >= 0; i--) { - ret = _set_performance_state(dev, genpd_virt_devs[i], opp, i); - if (ret) - break; - } + while (index != target) { + ret = _set_performance_state(dev, genpd_virt_devs[index], opp, index); + if (ret) + break; + + index += delta; } mutex_unlock(&opp_table->genpd_virt_dev_lock); - return ret; + return 0; } /* This is only called for PM domain for now */ From patchwork Fri Oct 13 08:48:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 733976 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 4CAC2CDB47E for ; Fri, 13 Oct 2023 08:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230234AbjJMItM (ORCPT ); Fri, 13 Oct 2023 04:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbjJMItK (ORCPT ); Fri, 13 Oct 2023 04:49:10 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02298CE for ; Fri, 13 Oct 2023 01:49:02 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-690ce3c55f1so1479985b3a.0 for ; Fri, 13 Oct 2023 01:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697186942; x=1697791742; 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=mjra0WdYWK36KGusor5NGq8FRrUa/zXmRjm2tlyhEOI=; b=dVBG7CgmwOVdX0Q6tRMxDQHCe7vJKwugJ12eucHlErvu77dc9H9gbH41/UCtYo6lvO /57YJNjq95QSQfjp9hJHw+FTmzNpadKW9q6kJT+B61uJ5FzzTB1D4ehgImALPRuSrHnZ u9SezJZ4iG+3jPXaJHpXAeixqqK4kxwvFLUTKZAWBW+mbLO7U8kqh/if9sTdZepuBpqF pC9xgeQZpJMF7g4kbgMK7YHh/bdpeH/XYYCyQ+GGcCNBjZ2jTnJnsEU0UKawL7g5zmJQ N5zvrWB2d9FhnOyDwtREMwpgJPtn6LyNyOS+RrxE5zvclKo3MxThb1alp2nCVfzStpbJ yyDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697186942; x=1697791742; 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=mjra0WdYWK36KGusor5NGq8FRrUa/zXmRjm2tlyhEOI=; b=wkVEb8fsU0z1GLopPb7RKnSPdxigGtJNcW1q9WKUBpzBKh3qIcV+ND+zKvmUR2GfKy PJCjqcJxEtGBkcpLQG60tBfBnzsh1hSLIb+H/KQUfi+xzZdINJhbJ9PcMCdblH5yfZRO x0eQVxldhfM7fx8p4gPCN1ENpYl9Ya6Vw6Wr9lOJLg4h3mn+JVSPb57TGg6N68cbJNb7 dgOZiLjoxVRPLTNXVPhAxgZpgxwvCjDSxyApB+Iq/v4sCl9XmxhED/7tqWHy8IjyVZIt WgzaEEbXMXCWzzIbGZ6gTKm5WmqYb13wH3EjIGTE7LL0/Y451okwu/G2DAvGHLz0Tian NF7w== X-Gm-Message-State: AOJu0Yx/1LAC2wagJtnCBbwZbDZJM96xDuD5dOCE2WQwUDNdF9y2gJfy e1CgzjlUWg/fB91ZM5T1EsQDnQ== X-Google-Smtp-Source: AGHT+IG41+b3yJXum4xwBP/+ABHsqzUFb6HvYHzaanfXBpdfqmBBj6O4RsroSNMhxFSQ+EiCBLZ8jw== X-Received: by 2002:a05:6a20:3d89:b0:174:210c:34b0 with SMTP id s9-20020a056a203d8900b00174210c34b0mr6362313pzi.0.1697186942446; Fri, 13 Oct 2023 01:49:02 -0700 (PDT) Received: from localhost ([122.172.80.14]) by smtp.gmail.com with ESMTPSA id im16-20020a170902bb1000b001c5fed0b35esm3382039plb.300.2023.10.13.01.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:49:02 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH 4/5] OPP: Remove genpd_virt_dev_lock Date: Fri, 13 Oct 2023 14:18:40 +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 All the config operations for OPP tables share common code paths now and none of the other ones have such protection in place. Either all should have it or none. The understanding here is that user won't clear the OPP configs while still using them and so such a case won't happen. We can always come back and use a wider lock for all resource types if required. Also fix the error on failing to allocate memory. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 33 +++------------------------------ drivers/opp/opp.h | 2 -- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 3516e79cf743..befe46036ad5 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1089,12 +1089,6 @@ static int _opp_set_required_opps_genpd(struct device *dev, delta = -1; } - /* - * Acquire genpd_virt_dev_lock to make sure we don't use a genpd_dev - * after it is freed from another thread. - */ - mutex_lock(&opp_table->genpd_virt_dev_lock); - while (index != target) { ret = _set_performance_state(dev, genpd_virt_devs[index], opp, index); if (ret) @@ -1103,8 +1097,6 @@ static int _opp_set_required_opps_genpd(struct device *dev, index += delta; } - mutex_unlock(&opp_table->genpd_virt_dev_lock); - return 0; } @@ -1474,7 +1466,6 @@ static struct opp_table *_allocate_opp_table(struct device *dev, int index) return ERR_PTR(-ENOMEM); mutex_init(&opp_table->lock); - mutex_init(&opp_table->genpd_virt_dev_lock); INIT_LIST_HEAD(&opp_table->dev_list); INIT_LIST_HEAD(&opp_table->lazy); @@ -1510,7 +1501,6 @@ static struct opp_table *_allocate_opp_table(struct device *dev, int index) remove_opp_dev: _of_clear_opp_table(opp_table); _remove_opp_dev(opp_dev, opp_table); - mutex_destroy(&opp_table->genpd_virt_dev_lock); mutex_destroy(&opp_table->lock); err: kfree(opp_table); @@ -1678,7 +1668,6 @@ static void _opp_table_kref_release(struct kref *kref) list_for_each_entry_safe(opp_dev, temp, &opp_table->dev_list, node) _remove_opp_dev(opp_dev, opp_table); - mutex_destroy(&opp_table->genpd_virt_dev_lock); mutex_destroy(&opp_table->lock); kfree(opp_table); } @@ -2395,7 +2384,7 @@ static void _opp_put_config_regulators_helper(struct opp_table *opp_table) opp_table->config_regulators = NULL; } -static void _detach_genpd(struct opp_table *opp_table) +static void _opp_detach_genpd(struct opp_table *opp_table) { int index; @@ -2449,13 +2438,11 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, if (!opp_table->required_opp_count) return -EPROBE_DEFER; - mutex_lock(&opp_table->genpd_virt_dev_lock); - opp_table->genpd_virt_devs = kcalloc(opp_table->required_opp_count, sizeof(*opp_table->genpd_virt_devs), GFP_KERNEL); if (!opp_table->genpd_virt_devs) - goto unlock; + return -ENOMEM; while (*name) { if (index >= opp_table->required_opp_count) { @@ -2478,29 +2465,15 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, if (virt_devs) *virt_devs = opp_table->genpd_virt_devs; - mutex_unlock(&opp_table->genpd_virt_dev_lock); return 0; err: - _detach_genpd(opp_table); -unlock: - mutex_unlock(&opp_table->genpd_virt_dev_lock); + _opp_detach_genpd(opp_table); return ret; } -static void _opp_detach_genpd(struct opp_table *opp_table) -{ - /* - * Acquire genpd_virt_dev_lock to make sure virt_dev isn't getting - * used in parallel. - */ - mutex_lock(&opp_table->genpd_virt_dev_lock); - _detach_genpd(opp_table); - mutex_unlock(&opp_table->genpd_virt_dev_lock); -} - static void _opp_clear_config(struct opp_config_data *data) { if (data->flags & OPP_CONFIG_GENPD) diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index fefdf9845692..08366f90f16b 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -160,7 +160,6 @@ enum opp_table_access { * @rate_clk_single: Currently configured frequency for single clk. * @current_opp: Currently configured OPP for the table. * @suspend_opp: Pointer to OPP to be used during device suspend. - * @genpd_virt_dev_lock: Mutex protecting the genpd virtual device pointers. * @genpd_virt_devs: List of virtual devices for multiple genpd support. * @required_opp_tables: List of device OPP tables that are required by OPPs in * this table. @@ -212,7 +211,6 @@ struct opp_table { struct dev_pm_opp *current_opp; struct dev_pm_opp *suspend_opp; - struct mutex genpd_virt_dev_lock; struct device **genpd_virt_devs; struct opp_table **required_opp_tables; unsigned int required_opp_count; From patchwork Fri Oct 13 08:48:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 733600 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 C9866CDB47E for ; Fri, 13 Oct 2023 08:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbjJMItO (ORCPT ); Fri, 13 Oct 2023 04:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbjJMItM (ORCPT ); Fri, 13 Oct 2023 04:49:12 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24807FB for ; Fri, 13 Oct 2023 01:49:06 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c9d922c039so15338475ad.3 for ; Fri, 13 Oct 2023 01:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697186945; x=1697791745; 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=x9got1lZdwQorf5bG+rweB7SynI8yY1C0vhKZAmzQ80=; b=ITqoL4tejHHpgZHgD17QhB1xcEKmaQd4HB2FolgB5dTOnahgzgpBEiTaupow0WEenR yM6myTuRSOCKYV4eWjCxdnGfPp0FnklpgFKVmKjIldbk8uPWeGh8Qq3ucE4Qn5KWej4D XSJsraA8bZmEFyMMGkAY+f0nC/1B/y7kkj9Nw8sK6TZCyYqoDenQmw9DWUyMvjbr97h5 dgsyB6A2VW1PW+2RGg/F/hkMIlg6AwOr/Ev8U6iPOdQclQzm/XL1Z7JUp6TcvoHEq7Nn rT2+jyxZFUxCUpvBXBjtalXnzrYIGUt0kGkUla8zdNPi4QjB70fLKojKedlnTmZFn/r3 USaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697186945; x=1697791745; 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=x9got1lZdwQorf5bG+rweB7SynI8yY1C0vhKZAmzQ80=; b=lG85Hz+tbmE5kJtQ1KuKT30YHcVdHGQgpEcDbvn3nCp+QmZLSwtXolb+nj9ExBv1hB JNZTCEADxz89vkKZZMjvw7fEdN+hLsDn2ID4WFGn72XqZgvGHx4+mo36CrjWL5UcPkQv R7z6LOP+GDTXe2H+sD404p/qa3n1NKPDPQeF9KXgcCjVD1+BKjaHBEFJ1CoIivmL2m1/ C7RTejockGzmsg3D8V1Gr5oYlqOyKQCP2/sOXuvim5yB4NTJXmahyx2Zw2wI8+kaLsF2 R/klHRGNwZ8rWfRpXkMAKCMmHyE7Fho3wtaTQGdMyTu++Meh32yL/23E0kkXUGaul6Gv UNSQ== X-Gm-Message-State: AOJu0YymBQKPuumfkO8z7qu0C7KVaP2nNqQonyT4n5FYNKQenu697JYy EbEcs+moFknP22BHcXgmL9c6zw== X-Google-Smtp-Source: AGHT+IHR1Di5iTPJd4PZUXhJsWb4CbLa2qxXMmaVLrmyC8aci7p8IM2IzqlTvIcoLKJ+eTLd5hjsqg== X-Received: by 2002:a17:90a:195e:b0:27d:1cf4:500e with SMTP id 30-20020a17090a195e00b0027d1cf4500emr4491505pjh.7.1697186945589; Fri, 13 Oct 2023 01:49:05 -0700 (PDT) Received: from localhost ([122.172.80.14]) by smtp.gmail.com with ESMTPSA id nr20-20020a17090b241400b0027d1366d113sm3127687pjb.43.2023.10.13.01.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:49:05 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH 5/5] OPP: No need to defer probe from _opp_attach_genpd() Date: Fri, 13 Oct 2023 14:18:41 +0530 Message-Id: <4cd8fe2135128168c1cd80482359dc7a46550085.1697186772.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 When the new interface for attaching genpd's via the OPP core was added, it was possible for required_opp_count to be zero, but not anymore. Remove the unused check. Signed-off-by: Viresh Kumar Reviewed-by: Ulf Hansson --- drivers/opp/core.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index befe46036ad5..c069aabefa00 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2430,14 +2430,6 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, if (opp_table->genpd_virt_devs) return 0; - /* - * If the genpd's OPP table isn't already initialized, parsing of the - * required-opps fail for dev. We should retry this after genpd's OPP - * table is added. - */ - if (!opp_table->required_opp_count) - return -EPROBE_DEFER; - opp_table->genpd_virt_devs = kcalloc(opp_table->required_opp_count, sizeof(*opp_table->genpd_virt_devs), GFP_KERNEL);