Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1543489lqp; Mon, 15 Apr 2024 09:19:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVWu8T9nF24LuuhCZ9MrbjDjuXq3Qzd/VviksDQjNBYKYMCmvFHonsCF8OByuJaH6S92fSROjl0JIWS2ijnMf2g0Ds/Nhvr/5fOduGvag== X-Google-Smtp-Source: AGHT+IESke2A1V7uqj6EzG8jFWKrMPmS+gLrJk3eBb1FEOO7ZWvpXXj5vB0pFHA2Jm+Tl0AeN6UH X-Received: by 2002:a17:906:3bd2:b0:a52:5277:7d16 with SMTP id v18-20020a1709063bd200b00a5252777d16mr4564633ejf.33.1713197979678; Mon, 15 Apr 2024 09:19:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713197979; cv=pass; d=google.com; s=arc-20160816; b=LsGfiVkLKTLeM1O0YY9j5K2Ta7QJ9fQpE8lJquUluAHHZAVUtnHBN/+sQmMd68BYdD 0dH+UMR2nfakJZmefGtJYWTjyBeoXLxYcu+FgZRrMNlL2ipEBdiXKmJC8vUFP8mKsMLM G3KPamAfOHkaAPjIyPCi7XgQcAeKdJF6R+n3O4NrWdGswv//rIaZ53r2mRClpIA2/KoK F5KHGggHynsz8SM2ev1r+9fze62sipYlF+XwFnxYnkxCStnD19Sk7ulVytztTzdexHq6 aH6kEz+tQC+LpIzD7abCk1ZstOfSc3nMF4U/OZtjQR/2e0RnUjILcWcgPsvSOwXoQTfY +VAQ== 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=UZoyetDCjQ2eL43YQMmYR6Q4IjxF/haeIh3f8hEthyc=; fh=pieQbr+GyTMZe+qJ+K0IGOOLXaGiuYZmSj2xyd8g+Yo=; b=VFCUTPsJnVGvfGV4DGJjdD8cYIPJQ+5lthGZgbUxq8ndaeaVQFMOAR+j7I0WAQksSC br2ZT/vekraOhqTOE2FC552tXIUFm4GyKoDHo2HNl8ZDKRKAjQTwp0zSaaYghL2HWN+N iqcoklDNv8agXntShiOGx6sj7+WctNyeWTY6AazJgAcG7Z73AWb/rXl815XCouTcSetx 7EzYXLA4FrvwqOAYp/LoddNERolwP39Lm4gC4c/gnXiW0YxBOO6bRWvM/nCkt08m1vsY vVLSkKBm8xx/OwkVLE3bMoKGJZ1PjWG7joBwAG0OXogT1wRxbBHHzbyyVQ7SPM7qiX6e 00hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YZN7k995; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145538-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145538-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f27-20020a17090624db00b00a51ab4027a4si4693179ejb.992.2024.04.15.09.19.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 09:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145538-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YZN7k995; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145538-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145538-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 443C11F21319 for ; Mon, 15 Apr 2024 16:19:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7EA07F7C1; Mon, 15 Apr 2024 16:19:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YZN7k995" 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 A66877F7FD; Mon, 15 Apr 2024 16:19:29 +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=1713197969; cv=none; b=AD4ZwUfu3Wxm63ylOy0QaX1VOwRFbB9Du3loXVdwJ5/njMI7VkIKEhV0Y0ORMMWhJbUBkzrWCwo6LB5kTRFXA2qI5CA8vgG5K6Q4/q6aeZGffwR/emFjp1+WlvbGp31A4RWWGOoqRv6hVSP60W/+4ODTeurN+iz8wC7WxFk6lDc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713197969; c=relaxed/simple; bh=ceUpnS+eAL52LEzx3dIV9vtzMz89ZqI4TX/q8s7Nmhs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=co+/uMZpjd13WRIjhTfyK7l0+XVaXBjf9A0j6j0x6dcNUQhXy1/OE+vL+Y0JIEKJpKkMnLfnCcYPCspEhHGg7xlYph1iuHRZDV6BHA48Jy+U1BKTp1JQBRXckQPBahHordZaCESEeebtqVK0c8OgndV15yH/G6YWMQa5Ad3h1es= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YZN7k995; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35A45C32783; Mon, 15 Apr 2024 16:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713197969; bh=ceUpnS+eAL52LEzx3dIV9vtzMz89ZqI4TX/q8s7Nmhs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=YZN7k995Uxxea0cJLwZLFIVIoQ7wp4CsvNgcQEJv0/H4PEK0Rj6G6ExZxAU5C2HZ9 oetjXZtceZ0YEAvUxjxRwLvZYaJPbdijx0hAxdZEqI/RmU2mkVjdkegWRU67E9DiVT 7nt7RCMikPwEBCK2HXe1kb6XWUZoGtkxnZwBj4DrXQL7BEqP87amqLDJ3tjA5Etmsk vuXruQZFUlOY8T5lDQ0klKgSJEEzwHGOTueOQ+F49KRvkMlM8WOjqotu/EkKMUxBfN yS6Hp96ZLU0ez8Yb3Y7Qwmuy0/Qbh7vCV6fGTkkQ5lXMzWxQslMwxSU9nne9ShPxgT KFFnVCiW9bcmA== Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5a9ef9ba998so909881eaf.1; Mon, 15 Apr 2024 09:19:29 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWV44e5W19QNmWFEKDZAZ+gBg/Kr1J/Xx641P91JrFsbt+ACE1zMbTGRrP79sCxHLPBpTIdom8KXmgHcNCf9sIWr7r3gpJjTccaOHcMx3K+kWlkMv45ylRlGpyrtAUgp9p+5LA/U/IZEOKUim9iMVsvW6flDacYhLqNMFZ4FHLEh4VmdClQIVoePRT72YmJUs8LCpqWiudsINToV9rkkw== X-Gm-Message-State: AOJu0YzdAOaEhP8vf2Aa7csFQNGhMjQxT+jnPrPlUt8+1rUL4Qol34ws UU9iUlkcdL3AYDkUaVYXmT5BpRGJJznbXRMaxoH8rji7Cu2/LD1wlDfrm5vGCZqnSAjdR54ELxt fb0onMVgnbeDC79Jccf9Swz5ArRM= X-Received: by 2002:a05:6870:9a97:b0:22e:514f:cd11 with SMTP id hp23-20020a0568709a9700b0022e514fcd11mr11036260oab.1.1713197968510; Mon, 15 Apr 2024 09:19:28 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240412143719.11398-1-Jonathan.Cameron@huawei.com> <20240412143719.11398-3-Jonathan.Cameron@huawei.com> <20240415164854.0000264f@Huawei.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 15 Apr 2024 18:19:17 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 02/18] ACPI: processor: Set the ACPI_COMPANION for the struct cpu instance To: Jonathan Cameron Cc: "Rafael J. Wysocki" , 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 , Miguel Luis , James Morse , Salil Mehta , Jean-Philippe Brucker , Catalin Marinas , Will Deacon , linuxarm@huawei.com, justin.he@arm.com, jianyong.wu@arm.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 15, 2024 at 6:16=E2=80=AFPM Rafael J. Wysocki wrote: > > On Mon, Apr 15, 2024 at 5:49=E2=80=AFPM Jonathan Cameron > wrote: > > > > On Fri, 12 Apr 2024 20:10:54 +0200 > > "Rafael J. Wysocki" wrote: > > > > > On Fri, Apr 12, 2024 at 4:38=E2=80=AFPM Jonathan Cameron > > > wrote: > > > > > > > > The arm64 specific arch_register_cpu() needs to access the _STA > > > > method of the DSDT object so make it available by assigning the > > > > appropriate handle to the struct cpu instance. > > > > > > > > Signed-off-by: Jonathan Cameron > > > > --- > > > > drivers/acpi/acpi_processor.c | 3 +++ > > > > 1 file changed, 3 insertions(+) > > > > > > > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_proc= essor.c > > > > index 7a0dd35d62c9..93e029403d05 100644 > > > > --- a/drivers/acpi/acpi_processor.c > > > > +++ b/drivers/acpi/acpi_processor.c > > > > @@ -235,6 +235,7 @@ static int acpi_processor_get_info(struct acpi_= device *device) > > > > union acpi_object object =3D { 0 }; > > > > struct acpi_buffer buffer =3D { sizeof(union acpi_object), = &object }; > > > > struct acpi_processor *pr =3D acpi_driver_data(device); > > > > + struct cpu *c; > > > > int device_declaration =3D 0; > > > > acpi_status status =3D AE_OK; > > > > static int cpu0_initialized; > > > > @@ -314,6 +315,8 @@ static int acpi_processor_get_info(struct acpi_= device *device) > > > > cpufreq_add_device("acpi-cpufreq"); > > > > } > > > > > > > > + c =3D &per_cpu(cpu_devices, pr->id); > > > > + ACPI_COMPANION_SET(&c->dev, device); > > > > > > This is also set for per_cpu(cpu_sys_devices, pr->id) in > > > acpi_processor_add(), via acpi_bind_one(). > > > > Hi Rafael, > > > > cpu_sys_devices gets filled with a pointer to this same structure. > > The contents gets set in register_cpu() so at this point > > it doesn't point anywhere. As a side note register_cpu() > > memsets to zero the value I set it to in the code above which isn't > > great, particularly as I want to use this in post_eject for > > arm64. > > > > We could make a copy of the handle and put it back after > > the memset in register_cpu() but that is also ugly. > > It's the best I've come up with to make sure this is still set > > come remove time but is rather odd. > > > > > > Moreover, there is some pr->id validation in acpi_processor_add(), so > > > it seems premature to use it here this way. > > > > > > I think that ACPI_COMPANION_SET() should be called from here on > > > per_cpu(cpu_sys_devices, pr->id) after validating pr->id (so the > > > pr->id validation should all be done here) and then NULL can be passe= d > > > as acpi_dev to acpi_bind_one() in acpi_processor_add(). Then, there > > > will be one physical device corresponding to the processor ACPI devic= e > > > and no confusion. > > > > I'm fairly sure this is pointing to the same device but agreed this > > is a tiny bit confusing. However we can't use cpu_sys_devices at this p= oint > > so I'm not immediately seeing a cleaner solution :( > > Well, OK. > > Please at least consider doing the pr->id validation checks before > setting the ACPI companion for &per_cpu(cpu_devices, pr->id). > > Also, acpi_bind_one() needs to be called on the "physical" devices > passed to ACPI_COMPANION_SET() (with NULL as the second argument) for > the reference counting and physical device lookup to work. > > Please also note that acpi_primary_dev_companion() should return > per_cpu(cpu_sys_devices, pr->id) for the processor ACPI device, which > depends on the order of acpi_bind_one() calls involving the same ACPI > device. Of course, if the value set by ACPI_COMPANION_SET() is cleared subsequently, the above is not needed, but then using ACPI_COMPANION_SET() is questionable overall.