linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: wens@csie.org
Cc: linux-arm-kernel@lists.infradead.org
Subject: [bug report] ARM: sun9i: smp: Support CPU/cluster power down and hotplugging for cpu1~7
Date: Tue, 14 May 2019 13:04:42 +0300	[thread overview]
Message-ID: <20190514100442.GA31718@mwanda> (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
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

                 reply	other threads:[~2019-05-14 10:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190514100442.GA31718@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).