Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp759184pxb; Fri, 28 Jan 2022 09:20:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBLE7VVcr4C2F9X7wUdEFe6wAufJy2epjhoEpoayPBc6tlWZGlfmNIdl8A6wZcBMWucHQ5 X-Received: by 2002:a17:90a:c302:: with SMTP id g2mr11000794pjt.0.1643390439191; Fri, 28 Jan 2022 09:20:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643390439; cv=none; d=google.com; s=arc-20160816; b=ECgc80VmwrNGxUVLxOCwuPSRcp8K8tAdhabvuBznO/Khs3/lSAYGc6n4mb8z5TaH+f 8MbD3HeFiBClluCQ0UTdMV0nGRJaY2Zbg9OaGTFWCXOEKj7pr5oCTUpRWGqQ2/L3eE6e SfBbiY0xr5uvUv+xD0bMLuGnvc0cULbCOKHE81ahoESfu7RIrp5RziYpHGG2Nh+vmPim Hde0wfL6j90rBzt0PvEL9nQXzmrdg7tui3ee5cvBrKVstHSaZAKK3KGMGpQ+UuWwHfOx fTpQ67R6N5cWE51Dy4zoXBlMLQltRslrvyIx+qjhkBFoQh2JEW+rgmNzIZlCbPWFGVxG Ey8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=41+S3e1G9az4hjoyIeQC86UioZgpO/adTzdGdboWJEs=; b=RlxXG2R/2ocj8fdmVfm6c/nd56la/CxyeYy1Xq4DLq6hRImCgTe4qO4j5BXBZddW81 UG0229RLFjwtu7qz0EDUDNHOsHbDfSk5UcsGYE12G5nUu1CphH5127rawoNfMFOuVQ/V gQwP+mXWi3RSDvbsBBIpwrEvvRGlueg1TqbtY+SV+M7+8hVAB4QrWCVLuxuOf3Nh7aeW AbmMEhhywM4JNdYRVM22FweA/1Tah8Hofe7Fgl4/NYtKXU3wUDlv5R2ywsI0VylKbnNr fAUUs2947Pk6j+CKo8Vp3b1XgGgk/r8sgRimrLdN7tC/JQ6zBfHFsLjvqBdvXi9e5UmF 4ryw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tkxspR5j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si6725722plh.437.2022.01.28.09.20.27; Fri, 28 Jan 2022 09:20:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tkxspR5j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344026AbiA0U2j (ORCPT + 99 others); Thu, 27 Jan 2022 15:28:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231384AbiA0U2g (ORCPT ); Thu, 27 Jan 2022 15:28:36 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 786C1C061714 for ; Thu, 27 Jan 2022 12:28:36 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id s5so8586029ejx.2 for ; Thu, 27 Jan 2022 12:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=41+S3e1G9az4hjoyIeQC86UioZgpO/adTzdGdboWJEs=; b=tkxspR5jl3OqRnxMSq8JDCc/cDWEPcSLiVi0a4mJ7qF992fNUR+q3YQCA1hwakMvH+ /fZw1S+ki4w/7BxmAGOMfJPn4TiITIGxMr5DImnsW5S6YSFhqk8ksufG4P05yest9uUk qGrWiIjJA57IzJmWodDAHMtH/1QT4MKWsasSqKoX8wNdVRNRixGZHM+4fFCcW2RrEKV4 Kn1WrqIBsbdeg0pTaZHEi5vt2qUL8mPlI8Q7HfMa1YxlQ85DMH1zRrHRyRrlNRGeBBml K90ZH5xajUuFBiIL8XvWWR1m3ahFyvb/k3gMq0mChUO580tNN/NONhl61tYJHmChAmKD ofag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=41+S3e1G9az4hjoyIeQC86UioZgpO/adTzdGdboWJEs=; b=N1VRi6bBrlcYfmeUklx/Scb10oH9hC8TfcKG8DI9/XL28c+12KLPQtRf1GjQk1UJIb aO2Bco+Bbcm050UroGdvVWBbTmPWydgDHKUN05l7NqIDCXi5w+bn3kck+StGhhutpYAj 67mDAKJMkFzY2wXnqwmn6NYy9bSF6XeiNai3jFlkVw0HfIVkITTnIvjZ2sseClW/RPEf h3RS9ulqQrlCyHMv1Wi6ePsn+YB8jxw9O1OvzAx5SHshW0saw2IefXum0rXm8DCGUKp+ Yso//ZggN7lF9WZWCfjnMOi12iy4/s39yjUvUuvTEJbkNU5dzdIjk53XXbnTdxd7ae1R Saew== X-Gm-Message-State: AOAM530iFfXlNeluBHi1xpaoKoIwzvVCcn5+Jby33aq1DmJOQ1+B65KX AkAiuhwekQlm4oRLMDFh2mpqMBetmpvnJ8wSEyiXgw== X-Received: by 2002:a17:907:6d25:: with SMTP id sa37mr4293287ejc.202.1643315315038; Thu, 27 Jan 2022 12:28:35 -0800 (PST) MIME-Version: 1.0 References: <1641544906-7069-1-git-send-email-chenxiang66@hisilicon.com> In-Reply-To: <1641544906-7069-1-git-send-email-chenxiang66@hisilicon.com> From: Mathieu Poirier Date: Thu, 27 Jan 2022 13:28:23 -0700 Message-ID: Subject: Re: [RFC PATCH] ACPI / amba: Skip creating amba device when associated cpu is not online To: chenxiang Cc: linux@armlinux.org.uk, vkoul@kernel.org, linux-arm-kernel@lists.infradead.org, Suzuki.Poulose@arm.com, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Cheng, I am severely behind in my patch review process and as such will not be able to start reviewing your work before the week of February 7th. Thanks, Mathieu On Fri, 7 Jan 2022 at 01:47, chenxiang wrote: > > 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", > -- > 2.33.0 >