linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: chenxiang <chenxiang66@hisilicon.com>
To: <linux@armlinux.org.uk>, <vkoul@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<mathieu.poirier@linaro.org>, <suzuki.poulose@arm.com>
Cc: <coresight@lists.linaro.org>, <linux-kernel@vger.kernel.org>,
	<linuxarm@huawei.com>, Xiang Chen <chenxiang66@hisilicon.com>
Subject: [RFC PATCH] ACPI / amba: Skip creating amba device when associated cpu is not online
Date: Fri, 7 Jan 2022 16:41:46 +0800	[thread overview]
Message-ID: <1641544906-7069-1-git-send-email-chenxiang66@hisilicon.com> (raw)

From: Xiang Chen <chenxiang66@hisilicon.com>

If not up all the cpus with command line "maxcpus=x", system will be
blocked.
We find that some amba devices such as ETM devices, are associated with
special cpus, and if the cpu is not up, the register of associated device
is not allowed to access. BIOS reports all the ETM device nodes and a
amba device is created for every ETM device, so even if one cpu is not up,
the amba device will still be created for the associated device, and also
the register of device (pid and cid) will be accessed when adding amba
device which will cause the issue.
To fix it, skip creating amba device if it is associated with a cpu which
is not online.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/acpi/acpi_amba.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/acpi/acpi_amba.c b/drivers/acpi/acpi_amba.c
index ab8a4e0191b1..2369198f734b 100644
--- a/drivers/acpi/acpi_amba.c
+++ b/drivers/acpi/acpi_amba.c
@@ -16,6 +16,7 @@
 #include <linux/ioport.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <acpi/processor.h>
 
 #include "internal.h"
 
@@ -45,6 +46,35 @@ static void amba_register_dummy_clk(void)
 	clk_register_clkdev(amba_dummy_clk, "apb_pclk", NULL);
 }
 
+static int acpi_handle_to_cpuid(acpi_handle handle)
+{
+	int cpu = -1;
+	struct acpi_processor *pr;
+
+	for_each_possible_cpu(cpu) {
+		pr = per_cpu(processors, cpu);
+		if (pr && pr->handle == handle)
+			break;
+	}
+
+	return cpu;
+}
+
+static int acpi_dev_get_cpu(struct acpi_device *adev)
+{
+	acpi_handle cpu_handle;
+	acpi_status status;
+	int cpu;
+
+	status = acpi_get_parent(adev->handle, &cpu_handle);
+	if (ACPI_FAILURE(status))
+		return -1;
+	cpu = acpi_handle_to_cpuid(cpu_handle);
+	if (cpu >= nr_cpu_ids)
+		return -1;
+	return cpu;
+}
+
 static int amba_handler_attach(struct acpi_device *adev,
 				const struct acpi_device_id *id)
 {
@@ -54,11 +84,17 @@ static int amba_handler_attach(struct acpi_device *adev,
 	bool address_found = false;
 	int irq_no = 0;
 	int ret;
+	int cpu;
 
 	/* If the ACPI node already has a physical device attached, skip it. */
 	if (adev->physical_node_count)
 		return 0;
 
+	/* If the cpu associated with the device is not online, skip it. */
+	cpu = acpi_dev_get_cpu(adev);
+	if (cpu >= 0 && !cpu_online(cpu))
+		return 0;
+
 	dev = amba_device_alloc(dev_name(&adev->dev), 0, 0);
 	if (!dev) {
 		dev_err(&adev->dev, "%s(): amba_device_alloc() failed\n",
-- 
2.33.0


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

             reply	other threads:[~2022-01-07  8:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07  8:41 chenxiang [this message]
2022-01-27 20:28 ` [RFC PATCH] ACPI / amba: Skip creating amba device when associated cpu is not online Mathieu Poirier
2022-01-28 11:00 ` Suzuki K Poulose
2022-01-28 15:28   ` Robin Murphy
2022-01-28 16:19     ` Suzuki K Poulose
2022-02-09  7:06   ` chenxiang (M)

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=1641544906-7069-1-git-send-email-chenxiang66@hisilicon.com \
    --to=chenxiang66@hisilicon.com \
    --cc=coresight@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linuxarm@huawei.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=suzuki.poulose@arm.com \
    --cc=vkoul@kernel.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).