From patchwork Fri Jan 7 08:41:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenxiang X-Patchwork-Id: 12706365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 864EFC433EF for ; Fri, 7 Jan 2022 08:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=G6FhZr0W2FNDjLkgb8QeESQ/e094B6U1PRbsCmjfFcE=; b=uExln8BDJIibWL KcSKMiMboUuCywqFJvtryZ8KgwVL92c64hSlKkqjjahUxFCThZNrwWWutNsr6I2wCG/XqW3o9VW9m EHG6Ek7QVYIDbkRDUtPNnoC9XLrlEStQBrU8xPdMnnK+Gyssazik2FNO2c4mxdyvx5BucxD1E8zGu J2oDn4pBGLzdzz+dGxK2vIgYu9HzRlLhYapZ8HVd4F9eiE8CZ4CznWbl7gwxUPYmjr8oSbWxdaxSa eqjrxxpWPrTzz3hVh5GzsucJNSyHX9TTJoLir1KWSabTuejm2Ie48oa8NuRiB6RRknwU8J01XF8mQ uuUxyEULi23JvyTMtZLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5ku5-002wKr-AF; Fri, 07 Jan 2022 08:47:17 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5ku1-002wJP-5n for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 08:47:15 +0000 Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4JVcGQ0Dxszbbjf; Fri, 7 Jan 2022 16:44:30 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Fri, 7 Jan 2022 16:47:07 +0800 From: chenxiang To: , , , , CC: , , , Xiang Chen Subject: [RFC PATCH] ACPI / amba: Skip creating amba device when associated cpu is not online Date: Fri, 7 Jan 2022 16:41:46 +0800 Message-ID: <1641544906-7069-1-git-send-email-chenxiang66@hisilicon.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220107_004713_418048_C8895776 X-CRM114-Status: GOOD ( 17.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Xiang Chen 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 --- 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 #include #include +#include #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",