Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ACPI / CPPC: clean up acpi_get_psd_map
@ 2020-03-26 14:29 luanshi
  2020-03-28 12:26 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: luanshi @ 2020-03-26 14:29 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown; +Cc: linux-acpi, linux-kernel

This patch cleans up acpi_get_psd_map function. If got here,
variable all_cpu_data[] can't be NULL. Variable match_cpc_ptr has been
checked before, no need check again at the end of the funchtion. Then
some code logic should be optimized.

Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com>
---
 drivers/acpi/cppc_acpi.c | 33 +++++++--------------------------
 1 file changed, 7 insertions(+), 26 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index a1a858a..8b2e89c 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -438,13 +438,10 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data)
 	 * domain info.
 	 */
 	for_each_possible_cpu(i) {
-		pr = all_cpu_data[i];
-		if (!pr)
-			continue;
-
 		if (cpumask_test_cpu(i, covered_cpus))
 			continue;
 
+		pr = all_cpu_data[i];
 		cpc_ptr = per_cpu(cpc_desc_ptr, i);
 		if (!cpc_ptr) {
 			retval = -EFAULT;
@@ -495,44 +492,28 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data)
 			cpumask_set_cpu(j, pr->shared_cpu_map);
 		}
 
-		for_each_possible_cpu(j) {
+		for_each_cpu(j, pr->shared_cpu_map) {
 			if (i == j)
 				continue;
 
 			match_pr = all_cpu_data[j];
-			if (!match_pr)
-				continue;
-
-			match_cpc_ptr = per_cpu(cpc_desc_ptr, j);
-			if (!match_cpc_ptr) {
-				retval = -EFAULT;
-				goto err_ret;
-			}
-
-			match_pdomain = &(match_cpc_ptr->domain_info);
-			if (match_pdomain->domain != pdomain->domain)
-				continue;
-
 			match_pr->shared_type = pr->shared_type;
 			cpumask_copy(match_pr->shared_cpu_map,
 				     pr->shared_cpu_map);
 		}
 	}
+	goto out;
 
 err_ret:
 	for_each_possible_cpu(i) {
 		pr = all_cpu_data[i];
-		if (!pr)
-			continue;
 
 		/* Assume no coordination on any error parsing domain info */
-		if (retval) {
-			cpumask_clear(pr->shared_cpu_map);
-			cpumask_set_cpu(i, pr->shared_cpu_map);
-			pr->shared_type = CPUFREQ_SHARED_TYPE_ALL;
-		}
+		cpumask_clear(pr->shared_cpu_map);
+		cpumask_set_cpu(i, pr->shared_cpu_map);
+		pr->shared_type = CPUFREQ_SHARED_TYPE_ALL;
 	}
-
+out:
 	free_cpumask_var(covered_cpus);
 	return retval;
 }
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI / CPPC: clean up acpi_get_psd_map
  2020-03-26 14:29 [PATCH] ACPI / CPPC: clean up acpi_get_psd_map luanshi
@ 2020-03-28 12:26 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2020-03-28 12:26 UTC (permalink / raw)
  To: luanshi
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Thu, Mar 26, 2020 at 3:29 PM luanshi <zhangliguang@linux.alibaba.com> wrote:
>
> This patch cleans up acpi_get_psd_map function. If got here,
> variable all_cpu_data[] can't be NULL. Variable match_cpc_ptr has been
> checked before, no need check again at the end of the funchtion. Then
> some code logic should be optimized.
>
> Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com>
> ---
>  drivers/acpi/cppc_acpi.c | 33 +++++++--------------------------
>  1 file changed, 7 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index a1a858a..8b2e89c 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -438,13 +438,10 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data)
>          * domain info.
>          */
>         for_each_possible_cpu(i) {
> -               pr = all_cpu_data[i];
> -               if (!pr)
> -                       continue;
> -
>                 if (cpumask_test_cpu(i, covered_cpus))
>                         continue;
>
> +               pr = all_cpu_data[i];
>                 cpc_ptr = per_cpu(cpc_desc_ptr, i);
>                 if (!cpc_ptr) {
>                         retval = -EFAULT;
> @@ -495,44 +492,28 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data)
>                         cpumask_set_cpu(j, pr->shared_cpu_map);
>                 }
>
> -               for_each_possible_cpu(j) {
> +               for_each_cpu(j, pr->shared_cpu_map) {
>                         if (i == j)
>                                 continue;
>
>                         match_pr = all_cpu_data[j];
> -                       if (!match_pr)
> -                               continue;
> -
> -                       match_cpc_ptr = per_cpu(cpc_desc_ptr, j);
> -                       if (!match_cpc_ptr) {
> -                               retval = -EFAULT;
> -                               goto err_ret;
> -                       }
> -
> -                       match_pdomain = &(match_cpc_ptr->domain_info);
> -                       if (match_pdomain->domain != pdomain->domain)
> -                               continue;
> -
>                         match_pr->shared_type = pr->shared_type;
>                         cpumask_copy(match_pr->shared_cpu_map,
>                                      pr->shared_cpu_map);
>                 }
>         }
> +       goto out;
>
>  err_ret:
>         for_each_possible_cpu(i) {
>                 pr = all_cpu_data[i];
> -               if (!pr)
> -                       continue;
>
>                 /* Assume no coordination on any error parsing domain info */
> -               if (retval) {
> -                       cpumask_clear(pr->shared_cpu_map);
> -                       cpumask_set_cpu(i, pr->shared_cpu_map);
> -                       pr->shared_type = CPUFREQ_SHARED_TYPE_ALL;
> -               }
> +               cpumask_clear(pr->shared_cpu_map);
> +               cpumask_set_cpu(i, pr->shared_cpu_map);
> +               pr->shared_type = CPUFREQ_SHARED_TYPE_ALL;
>         }
> -
> +out:
>         free_cpumask_var(covered_cpus);
>         return retval;
>  }
> --

Applied as 5.7 material with some changes in the changelog and subject, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 14:29 [PATCH] ACPI / CPPC: clean up acpi_get_psd_map luanshi
2020-03-28 12:26 ` Rafael J. Wysocki

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git