All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] ARM: sun9i: smp: Support CPU/cluster power down and hotplugging for cpu1~7
@ 2019-05-14 10:04 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2019-05-14 10:04 UTC (permalink / raw)
  To: wens; +Cc: linux-arm-kernel

Hello Chen-Yu Tsai,

The patch 7cbea6327e76: "ARM: sun9i: smp: Support CPU/cluster power
down and hotplugging for cpu1~7" from Jan 17, 2018, leads to the
following static checker warning:

	arch/arm/mach-sunxi/mc_smp.c:581 sunxi_mc_smp_cpu_kill()
	error: scheduling with locks held: 'spin_lock:boot_lock'

arch/arm/mach-sunxi/mc_smp.c
   546          /* wait for CPU core to die and enter WFI */
   547          count = TIMEOUT_USEC / POLL_USEC;
   548          spin_lock_irq(&boot_lock);
                ^^^^^^^^^^^^^^^^^^^^^^^^^
Atomic context.

   549          for (tries = 0; tries < count; tries++) {
   550                  spin_unlock_irq(&boot_lock);
   551                  usleep_range(POLL_USEC / 2, POLL_USEC);
   552                  spin_lock_irq(&boot_lock);
   553  
   554                  /*
   555                   * If the user turns off a bunch of cores at the same
   556                   * time, the kernel might call cpu_kill before some of
   557                   * them are ready. This is because boot_lock serializes
   558                   * both cpu_die and cpu_kill callbacks. Either one could
   559                   * run first. We should wait for cpu_die to complete.
   560                   */
   561                  if (sunxi_mc_smp_cpu_table[cluster][cpu])
   562                          continue;
   563  
   564                  reg = readl(cpucfg_base + CPUCFG_CX_STATUS(cluster));
   565                  if (reg & CPUCFG_CX_STATUS_STANDBYWFI(cpu))
   566                          break;
   567          }
   568  
   569          if (tries >= count) {
   570                  ret = ETIMEDOUT;
   571                  goto out;
   572          }
   573  
   574          /* power down CPU core */
   575          sunxi_cpu_powerdown(cpu, cluster);
   576  
   577          if (!sunxi_mc_smp_cluster_is_down(cluster))
   578                  goto out;
   579  
   580          /* wait for cluster L2 WFI */
   581          ret = readl_poll_timeout(cpucfg_base + CPUCFG_CX_STATUS(cluster), reg,
   582                                   reg & CPUCFG_CX_STATUS_STANDBYWFIL2,
   583                                   POLL_USEC, TIMEOUT_USEC);
                                         ^^^^^^^^^
This is 100.  Use zero instead to avoid sleeping?

   584          if (ret) {
   585                  /*
   586                   * Ignore timeout on the cluster. Leaving the cluster on
   587                   * will not affect system execution, just use a bit more
   588                   * power. But returning an error here will only confuse
   589                   * the user as the CPU has already been shutdown.
   590                   */
   591                  ret = 0;
   592                  goto out;
   593          }
   594  
   595          /* Power down cluster */
   596          sunxi_cluster_powerdown(cluster);
   597  
   598  out:
   599          spin_unlock_irq(&boot_lock);
                                 ^^^^^^^^^
   600          pr_debug("%s: cluster %u cpu %u powerdown: %d\n",
   601                   __func__, cluster, cpu, ret);
   602          return !ret;
   603  }


regards,
dan carpenter

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-14 10:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-14 10:04 [bug report] ARM: sun9i: smp: Support CPU/cluster power down and hotplugging for cpu1~7 Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.