Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3408451pxf; Mon, 22 Mar 2021 05:55:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxjkDszQMW7WKZJKC8RPAX8EvA2QgKlNpvjRMl1kAp4Ly8GxUokZfH0JW2eDVs9pvV/mqg X-Received: by 2002:a17:906:cb0a:: with SMTP id lk10mr18984074ejb.479.1616417715264; Mon, 22 Mar 2021 05:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616417715; cv=none; d=google.com; s=arc-20160816; b=x9+SUXG3SDhE5VQ0xp6+LNzGHNW+xsnuQ1wfu3lUDNgSM9RFbKMi4/+JMXficaPYa5 dzLk2ncC1dtmVfU4unFivJs3fYiaXfZyxi4/B2kE2kvh3Pz3S+CmGhO2jo0exof9itpk 5NAysG7XEyHp4EYic2AAhKSUszEP0XCM5vceCy5zL8oBRYg9o3E86ikekzABmZsabC2v LbKIcd9g38QozB/WrkV7onCj+jnFHhXfFlq7JIsLTv7/7TKcIbPu4vYxN6sraP4A4iII tCRD33D/cTe8vLxZqfmbcFeJUTDVL3cbVUY7286Wz7cNI+3IvKRwvyh39VcwWZnoCuD0 lf8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+a/jD9ts25qG6hKIZUCU3IW8NDN1UK3dYSoz6hIfePs=; b=AZ6OiCF2wvi5Df2YBd8xhGOB/F+kz6Z7uXu3m10I/hOgQO7Zlq/R4/lyaSUsed6KnT jDzNSuiwRTxrrZ7hUbfmCE5dMAyQ6VBmUInTfPEyjn5w7CiZNZ9Tk2P2yfEkLRKlO3ou kdJp++dP2oT3ocibTvr4c/r9TIWMqBxz318LFuxpw7OLButtf0Non0hN2fG5bb7jACzL HpFu4I1Es73KI3im84OXfMGQpUHl4YnNL5ebkaK5b/9oY8RWu+wdZB2v72pIn9c6hpna yCjh77pJRrdaJVmGIuzKWRA6SKI/aEXt3BE0pR2bP9RiAQjJvtD17l6WM87PS4zQFRhL s/ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kjxFC9I7; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si10506203edq.173.2021.03.22.05.54.52; Mon, 22 Mar 2021 05:55:15 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=kjxFC9I7; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231946AbhCVMxw (ORCPT + 99 others); Mon, 22 Mar 2021 08:53:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:35528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232697AbhCVMnO (ORCPT ); Mon, 22 Mar 2021 08:43:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9B2F46199E; Mon, 22 Mar 2021 12:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616416875; bh=ZpEdCe8QuqCUDcs5vE1hwzwaex3zGkU23O5Awm6ILJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kjxFC9I72dF4wwon8BeYlE/miEi2SVz8bRK8HLHfZZmvXoJChRKP40sv/DXDre4Jo UdT3qz68XoCqJvNnX3WhI5xn6Xqxh4EPrUhwg+1BFvLeccjMZrLtoLv/Hj6SIDxJP5 0t3AZD+4GWTGqNVVV6SID62XgTqe7aeqnK+dzqc0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Thomas Gleixner Subject: [PATCH 5.10 157/157] x86/apic/of: Fix CPU devicetree-node lookups Date: Mon, 22 Mar 2021 13:28:34 +0100 Message-Id: <20210322121938.719266188@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121933.746237845@linuxfoundation.org> References: <20210322121933.746237845@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit dd926880da8dbbe409e709c1d3c1620729a94732 upstream. Architectures that describe the CPU topology in devicetree and do not have an identity mapping between physical and logical CPU ids must override the default implementation of arch_match_cpu_phys_id(). Failing to do so breaks CPU devicetree-node lookups using of_get_cpu_node() and of_cpu_device_node_get() which several drivers rely on. It also causes the CPU struct devices exported through sysfs to point to the wrong devicetree nodes. On x86, CPUs are described in devicetree using their APIC ids and those do not generally coincide with the logical ids, even if CPU0 typically uses APIC id 0. Add the missing implementation of arch_match_cpu_phys_id() so that CPU-node lookups work also with SMP. Apart from fixing the broken sysfs devicetree-node links this likely does not affect current users of mainline kernels on x86. Fixes: 4e07db9c8db8 ("x86/devicetree: Use CPU description from Device Tree") Signed-off-by: Johan Hovold Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20210312092033.26317-1-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/apic/apic.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2317,6 +2317,11 @@ static int cpuid_to_apicid[] = { [0 ... NR_CPUS - 1] = -1, }; +bool arch_match_cpu_phys_id(int cpu, u64 phys_id) +{ + return phys_id == cpuid_to_apicid[cpu]; +} + #ifdef CONFIG_SMP /** * apic_id_is_primary_thread - Check whether APIC ID belongs to a primary thread