Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp218258rdb; Thu, 8 Feb 2024 04:11:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbg7r9sFhcViivHJWMSvkaGYHNpKhiqYbjzsJfbaLD3RxaVN7yisqp61YDdLbmaQkdglY5 X-Received: by 2002:a17:906:81a:b0:a36:8711:f7b6 with SMTP id e26-20020a170906081a00b00a368711f7b6mr6756912ejd.34.1707394273971; Thu, 08 Feb 2024 04:11:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707394273; cv=pass; d=google.com; s=arc-20160816; b=uHwWkmAqfNH18TMP78bhTr/+HWUWu+urqKsEENXysIgGSu3j3SorNPVaxAX49au4ei mT7Sz+vXqAQB8hIdOINZbK8bDKoWk5a3UU8oyraz7AU2ncRevklZJ0SiOWO7qBl9I0AN hNFS3npul00OFtaRmxYVnvmOgAg7CqevfA1kr8iLgQftsZslXeWZ+7Kg4hlt8Szz9YOg fpdifU0VdCJrI8oM0CYwAVxAQBTKi4iKgQ2XE8AwX2vZJrdg8tidjvKK6UsSx8A0/yy9 5KfaSqvPUqVAD555SYjJ9M+SsqIDr0rmn7MS7JWKuk1ZIDcWLb0Qhy1XP6dMZv109NIt RccQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=//BvnQ3lDHfbjL6yCZF7n7+BLmbP89NZh/OS+Rx56VM=; fh=ovYOVrsgRhd15YyI65bE7uzLOJJkY62AddfFuM1IdHc=; b=MPp9AegqvCfOwWLioqrJjJjPwJxBfOH037XU9LHN7E5dmsGfhQwlkhQObKxJDVNpig ZZBZsGxie1DAruDbkI7mDNTw6V/NDLzOwsolCv4wrOKEwtfrurtI9A83bw0fEPiAdDLg WInxo1Ns/GGj8wa8tPvVziMGsSdn1YWYW98tY4PnKd8l/WP8sjVT4w65CNfRa2YzZtTM VvgbC1BPXNEfWku+Bdb+rmQbCtaKkVaT+qzjKVGG2x5lYgYiQrOgSa1Jf/0Hi3WjG/i5 JMDmE+CiSbWlXZoNUsKg/Ce+DSj0tpL2SFkv3iT+/Wa402BedbYxNA35qL+tJS/Rq3SQ UFyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-58015-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58015-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCWEvan0wliK1sIvhp3QYNWD5Nqp3Hv5VksRIaAR7ITNXmezhu6J0oEMR7trSWfcqg+PxH7dx0jfAXwA9XQlOXiJS7NSejwhQFNKUBXTtg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hb6-20020a170906b88600b00a3bb58d312bsi303930ejb.438.2024.02.08.04.11.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:11:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58015-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-58015-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58015-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A7AB31F2D9E4 for ; Thu, 8 Feb 2024 12:02:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 852767FBCC; Thu, 8 Feb 2024 11:57:11 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B1AA7F48B; Thu, 8 Feb 2024 11:57:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707393430; cv=none; b=HXVKF0RVldHK28FWfYJVPga+SotaGaEP+byAmnGQNM9A1KpmxAQ3YjdnBinbo5P1FkaH9xNG+liOwTvmRSTI96PDyKkRnAZy4yz9nJR5MWqvBU4SP2PRg1SnttTLzyj22tIiGW5uEZTYgpXpf/1pTmezShkz7BZTdp9AgrXecIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707393430; c=relaxed/simple; bh=lzHdLn3RnU4KvLq9L4yLPglARNGzesbjMWjFLLMt1MQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fA0unZ3SnH+1hM/ZCfv25flhFrNcmIm0qKc50LpXBDNrMHphJ3qZC709MUkJ/Lhs+K6Y1DjgWdHavKAA5vH7hNeAa81NtufH3qljQNsoQWXiufDp14UyqivdXH8ZjPjOVrMsx8Qi2wC/Gl1aOUfTOjBl7aPLxgSS/gPTN2FRVOI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9B0C31FB; Thu, 8 Feb 2024 03:57:50 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.8.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BCACA3F5A1; Thu, 8 Feb 2024 03:57:05 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: lukasz.luba@arm.com, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, qyousef@layalina.io, wvw@google.com, xuewen.yan94@gmail.com Subject: [PATCH v8 21/23] PM: EM: Remove old table Date: Thu, 8 Feb 2024 11:55:55 +0000 Message-Id: <20240208115557.1273962-22-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240208115557.1273962-1-lukasz.luba@arm.com> References: <20240208115557.1273962-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Remove the old EM table which wasn't able to modify the data. Clean the unneeded function and refactor the code a bit. Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann Signed-off-by: Lukasz Luba --- include/linux/energy_model.h | 2 -- kernel/power/energy_model.c | 46 ++++++------------------------------ 2 files changed, 7 insertions(+), 41 deletions(-) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index aabfc26fcd31..92866a81abe4 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -53,7 +53,6 @@ struct em_perf_table { /** * struct em_perf_domain - Performance domain - * @table: List of performance states, in ascending order * @em_table: Pointer to the runtime modifiable em_perf_table * @nr_perf_states: Number of performance states * @flags: See "em_perf_domain flags" @@ -69,7 +68,6 @@ struct em_perf_table { * field is unused. */ struct em_perf_domain { - struct em_perf_state *table; struct em_perf_table __rcu *em_table; int nr_perf_states; unsigned long flags; diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index 548908e686ed..57838d28af85 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -276,17 +276,6 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table, return 0; } -static int em_allocate_perf_table(struct em_perf_domain *pd, - int nr_states) -{ - pd->table = kcalloc(nr_states, sizeof(struct em_perf_state), - GFP_KERNEL); - if (!pd->table) - return -ENOMEM; - - return 0; -} - /** * em_dev_update_perf_domain() - Update runtime EM table for a device * @dev : Device for which the EM is to be updated @@ -331,24 +320,6 @@ int em_dev_update_perf_domain(struct device *dev, } EXPORT_SYMBOL_GPL(em_dev_update_perf_domain); -static int em_create_runtime_table(struct em_perf_domain *pd) -{ - struct em_perf_table __rcu *table; - int table_size; - - table = em_table_alloc(pd); - if (!table) - return -ENOMEM; - - /* Initialize runtime table with existing data */ - table_size = sizeof(struct em_perf_state) * pd->nr_perf_states; - memcpy(table->state, pd->table, table_size); - - rcu_assign_pointer(pd->em_table, table); - - return 0; -} - static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd, struct em_perf_state *table, struct em_data_callback *cb, @@ -409,6 +380,7 @@ static int em_create_pd(struct device *dev, int nr_states, struct em_data_callback *cb, cpumask_t *cpus, unsigned long flags) { + struct em_perf_table __rcu *em_table; struct em_perf_domain *pd; struct device *cpu_dev; int cpu, ret, num_cpus; @@ -435,17 +407,15 @@ static int em_create_pd(struct device *dev, int nr_states, pd->nr_perf_states = nr_states; - ret = em_allocate_perf_table(pd, nr_states); - if (ret) + em_table = em_table_alloc(pd); + if (!em_table) goto free_pd; - ret = em_create_perf_table(dev, pd, pd->table, cb, flags); + ret = em_create_perf_table(dev, pd, em_table->state, cb, flags); if (ret) goto free_pd_table; - ret = em_create_runtime_table(pd); - if (ret) - goto free_pd_table; + rcu_assign_pointer(pd->em_table, em_table); if (_is_cpu_device(dev)) for_each_cpu(cpu, cpus) { @@ -458,7 +428,7 @@ static int em_create_pd(struct device *dev, int nr_states, return 0; free_pd_table: - kfree(pd->table); + kfree(em_table); free_pd: kfree(pd); return -EINVAL; @@ -629,7 +599,7 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, dev->em_pd->flags |= flags; - em_cpufreq_update_efficiencies(dev, dev->em_pd->table); + em_cpufreq_update_efficiencies(dev, dev->em_pd->em_table->state); em_debug_create_pd(dev); dev_info(dev, "EM: created perf domain\n"); @@ -666,8 +636,6 @@ void em_dev_unregister_perf_domain(struct device *dev) mutex_lock(&em_pd_mutex); em_debug_remove_pd(dev); - kfree(dev->em_pd->table); - em_table_free(dev->em_pd->em_table); kfree(dev->em_pd); -- 2.25.1