Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2488723lqt; Mon, 22 Apr 2024 12:07:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+CQyTtDY1uvSd4wWBG2qyLqpsHlxxs/B6CDoGLt3xRuGi/aCEEWp1uZAWs3mOPE8hTQY7CaEKT/XkJz9FUgQ/KD6xTPxjU2iLFMBCyA== X-Google-Smtp-Source: AGHT+IFKkK2pvpw1PdhCCU0TuSoWBA4OdzzTQwWFxTUZQlp7MI2DaANvsgl0U74uQjnWe7Ii0tA/ X-Received: by 2002:a17:906:1695:b0:a58:78ab:2763 with SMTP id s21-20020a170906169500b00a5878ab2763mr119285ejd.15.1713812851830; Mon, 22 Apr 2024 12:07:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713812851; cv=pass; d=google.com; s=arc-20160816; b=tL/tA1qKaqzniGVS4Xbhu1unY/bEdtyv9HLhd6bzKD2iozk7jDTGdQvTZS2zt6tDWA 3pxfUFXXzwCUb+RW308StgPlpKqzBb+GELalOt5OB7kEmP0RL3buAYNuh5LnU491JxtU AOYDJEEKU+W/WsWLu89y/Wb8XRNGo+s3Te1i5FqYOiy60Y7jtRAkRljs3iuFyP/axmuy VRaVWVnc0dygV3b5e+mRa0su8Z2mdQqiga5nM3E+jeedI46sdEpdhfU46C8lmhEbTh1E 8ZmbDrvR/um0f5BIQQf+UKQ6o2Xac6tePjsrMSxnCc8amM5BlnrekNGfCf8FPeslOhel Dm7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ZgeUGY2TkVWbCqTTW+o5X97ShyiI8mvLDuwa6IOfkPc=; fh=QOcr4YzgI57RSm6lbkQJ2STH5qD3QHATDVBvFnOcfDM=; b=SguUtD06VDAQ3PqYKZ+ZSziSl2urOt9Slk1czSxru1n4ZcCsF9IbQi07TiFJylmx3H JvZTCPOgaWMPyM3mU1KjLBO8bAyxM1xExeD5aDgEBf0q9y8OY8+NLiN9rT4np1pJRgi+ Sdkjmu9UbDfTH5SWv6CN1fHkPigQtwI8plGkq3QPM7eEmLxI8LepIiT1aFlFftSphJqd +REMXJ70JsfGmcNDdh+HjYr9YLqGUMdGxeE0azj60DEY2nyF3camuFx+RHgZEViSAcRY Kmgt+ju2urz94BKwmuh+p+gdvDu5ZV2lqt1OgmY/qLejl1oz4tCVIGKiHH4WmAfoCkT4 dosw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MA8qqOZ7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-153881-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153881-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id fx6-20020a170906b74600b00a5875f5a1f2si171026ejb.845.2024.04.22.12.07.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 12:07:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153881-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MA8qqOZ7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-153881-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153881-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 772AA1F23328 for ; Mon, 22 Apr 2024 18:57:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E4E31552FF; Mon, 22 Apr 2024 18:57:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MA8qqOZ7" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F424154BFF; Mon, 22 Apr 2024 18:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713812227; cv=none; b=JpD6kCJ0CO2gwhyy/pMHZ1cEQeYUcR6tNgp2F/I8mByEpss2QMl4Z/qH1T4BnIlhtUfL8eK30OalbGN94wRUr9H1cAfK9v4G7pVdtR7D5XM8KcUDw2h3PkIa1DIxqrDj3t2Gdma45xl89llvLV+9dwB94n3A8vXuGfLhNqOsmt4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713812227; c=relaxed/simple; bh=vUwFolvpY3txp2GkdU+PBaQbFE6hq0Faqzym3NAaAao=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=dpC+L+XE43QsXupVcPwlLEYRNJsvHMnq3EKHWM+NdhYOOpiNjv0MnLLbPgHMorXDoNat/imrdBTsKKDRYuWOFCH4uMslA/2oWYsbKkLDEv8IbGWyB7ms3WDs2QB5xffHGMzZ4ukau0cI5YLMMZ9GLYWXr7zFd/oGZWFB6mGleZA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MA8qqOZ7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 255D6C113CC; Mon, 22 Apr 2024 18:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713812227; bh=vUwFolvpY3txp2GkdU+PBaQbFE6hq0Faqzym3NAaAao=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MA8qqOZ74UviRkAJdioSgr48hye9xY6Bj4MF2wTrP34K/4KX719GV3qOMJw/OULIr e68+T+c7rxKVttGfYwgxNo9pMVrRkiLt7w8Hzn9oLQRAzXGYNsWa/veejvUxSXSYrN eSeONtLNO3MeUJWyID4rXzchILd32anjOPcj4m9KD0BpKDZ1cqV/badFtrvfJBBoPY ZCqPl/1fsXmFuIDbFXKZipwydtGK4iyvTYE9LA/2j7K434ls0BvRUBBFcpsq+L7WTb 8F2uVFKVU3cOW9CwRfumqc802CzAiJAmVR9oBZUTbvoI5HcVL/2TB7wFb9Yj96mykE ZN0jV1DjbLnZQ== Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5aa17bf8cf0so70185eaf.1; Mon, 22 Apr 2024 11:57:07 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXuEfaHYvrFVCPIpAwH3gAKRuQQ+Yacn5SljF3GzVo7HNWTOzW8PGylgmCUjSJN2ZzV1og/zTp+j3HG/mBOBTxV2oQAKBNJmo7bmZDekwH39JIDBJbzuAVoUnpDiJxiraPqhX5+HIs1gAEePkAKoun3M9lU1x12CUFWsVTMNj4axWfHeGcVPZPmPTDIGyIBRnnRhnPx2wMFcc58ioBvbQ== X-Gm-Message-State: AOJu0YxBC+2GddD3DeMsS9lhmQlBcf4u+wnfo5CTmlxnx2+uzax/oHs+ 6M8+uawaXZnTl9BIMLEsXnEN+sFNuhVFon7gcxmyRfCGQ0oBoV2QnYtDI1EVC8jzfOfu1pahkwa 4BWhh9fN9nGavVOdkzGH+4P9aOBI= X-Received: by 2002:a05:6871:821:b0:22e:8800:b8bc with SMTP id q33-20020a056871082100b0022e8800b8bcmr13965106oap.5.1713812226509; Mon, 22 Apr 2024 11:57:06 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240418135412.14730-1-Jonathan.Cameron@huawei.com> <20240418135412.14730-5-Jonathan.Cameron@huawei.com> In-Reply-To: <20240418135412.14730-5-Jonathan.Cameron@huawei.com> From: "Rafael J. Wysocki" Date: Mon, 22 Apr 2024 20:56:55 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 04/16] ACPI: processor: Move checks and availability of acpi_processor earlier To: Jonathan Cameron Cc: Thomas Gleixner , Peter Zijlstra , linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, x86@kernel.org, Russell King , "Rafael J . Wysocki" , Miguel Luis , James Morse , Salil Mehta , Jean-Philippe Brucker , Catalin Marinas , Will Deacon , Ingo Molnar , Borislav Petkov , Dave Hansen , linuxarm@huawei.com, justin.he@arm.com, jianyong.wu@arm.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 18, 2024 at 3:56=E2=80=AFPM Jonathan Cameron wrote: > > Make the per_cpu(processors, cpu) entries available earlier so that > they are available in arch_register_cpu() as ARM64 will need access > to the acpi_handle to distinguish between acpi_processor_add() > and earlier registration attempts (which will fail as _STA cannot > be checked). > > Reorder the remove flow to clear this per_cpu() after > arch_unregister_cpu() has completed, allowing it to be used in > there as well. > > Note that on x86 for the CPU hotplug case, the pr->id prior to > acpi_map_cpu() may be invalid. Thus the per_cpu() structures > must be initialized after that call or after checking the ID > is valid (not hotplug path). > > Signed-off-by: Jonathan Cameron > --- > v7: Swap order with acpi_unmap_cpu() in acpi_processor_remove() > to keep it in reverse order of the setup path. (thanks Salil) > Fix an issue with placement of CONFIG_ACPI_HOTPLUG_CPU guards. > v6: As per discussion in v5 thread, don't use the cpu->dev and > make this data available earlier by moving the assignment checks > int acpi_processor_get_info(). > --- > drivers/acpi/acpi_processor.c | 78 +++++++++++++++++++++-------------- > 1 file changed, 46 insertions(+), 32 deletions(-) > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.= c > index ba0a6f0ac841..ac7ddb30f10e 100644 > --- a/drivers/acpi/acpi_processor.c > +++ b/drivers/acpi/acpi_processor.c > @@ -183,8 +183,36 @@ static void __init acpi_pcc_cpufreq_init(void) {} > #endif /* CONFIG_X86 */ > > /* Initialization */ > +static DEFINE_PER_CPU(void *, processor_device_array); > + > +static void acpi_processor_set_per_cpu(struct acpi_processor *pr, > + struct acpi_device *device) > +{ > + BUG_ON(pr->id >=3D nr_cpu_ids); > + /* > + * Buggy BIOS check. > + * ACPI id of processors can be reported wrongly by the BIOS. > + * Don't trust it blindly > + */ > + if (per_cpu(processor_device_array, pr->id) !=3D NULL && > + per_cpu(processor_device_array, pr->id) !=3D device) { > + dev_warn(&device->dev, > + "BIOS reported wrong ACPI id %d for the processo= r\n", > + pr->id); > + /* Give up, but do not abort the namespace scan. */ > + return; In this case the caller should make acpi_pricessor_add() return 0, I think, because otherwise it will attempt to acpi_bind_one() "pr" to "device" which will confuse things. So I would make this return false to indicate that. Or just fold it into the caller and do the error handling there.