Skip to contentSkip to conversation

ARM: sun9i: smp: Support CPU/cluster power down and hotplugging for cpu1~7

bug report Dan Carpenter 1 participant 1 message May 14, 2019

lore
Share & tools
lore
#0 lore raw

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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel