From patchwork Fri Jan 30 22:54:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 44068 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C8A0B20CA8 for ; Fri, 30 Jan 2015 22:56:04 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id fb4sf4542073wid.3 for ; Fri, 30 Jan 2015 14:56:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=bEvL9AOZA0tO2ewvZj8qZkyiiZCS0Lwoo2rN1YxHXHk=; b=G8lR+a0qOIsBXjddUW7foD4LE6bibvsQFxvQv9MA+mtP4N6sj/oQQlQuqMl1XNt2nD uW5dVj/bWCKCQs8+1Nq8afCJQEWk6ZqmbAefTOdUQbQ9ZbMC2PlZWrE5x7WaKxkjvMBd G3/yDgt+BVbO1ko+2sJeZamLkJXAhlM5sJqkPEAe+Gg3k6b7cMUHjdwjjwJBDJ/WlbEI gVYjgHQorE+7w/kIayqEac4x52RuF8f/JulfbMhtOANXWOZWAgEv0AO130fAAeMVVa5l JPza3xSc6dMF4O2iW6Qx/BTBb32z1dCpIcZXSVb+Oz+9fSNRmYckxZcF2zcDmKIckpad mV5w== X-Gm-Message-State: ALoCoQncFwpb/z7/KITShg7y61FUph3birheqCRTJBYfPw86j2jtcT+IRgWSB3iKNmG9MsHMdieQ X-Received: by 10.180.92.133 with SMTP id cm5mr117720wib.4.1422658563728; Fri, 30 Jan 2015 14:56:03 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.100 with SMTP id i4ls416895laa.106.gmail; Fri, 30 Jan 2015 14:56:03 -0800 (PST) X-Received: by 10.112.110.103 with SMTP id hz7mr8896835lbb.62.1422658563506; Fri, 30 Jan 2015 14:56:03 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id th6si11155830lbb.74.2015.01.30.14.56.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Jan 2015 14:56:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id hs14so26140843lab.9 for ; Fri, 30 Jan 2015 14:56:03 -0800 (PST) X-Received: by 10.152.116.43 with SMTP id jt11mr8803605lab.69.1422658563383; Fri, 30 Jan 2015 14:56:03 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp433501lbj; Fri, 30 Jan 2015 14:56:02 -0800 (PST) X-Received: by 10.70.35.15 with SMTP id d15mr12147879pdj.86.1422658561689; Fri, 30 Jan 2015 14:56:01 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rf8si15342926pab.79.2015.01.30.14.56.00; Fri, 30 Jan 2015 14:56:01 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932899AbbA3Wz5 (ORCPT + 29 others); Fri, 30 Jan 2015 17:55:57 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:63386 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760994AbbA3Wzj (ORCPT ); Fri, 30 Jan 2015 17:55:39 -0500 Received: by mail-pa0-f52.google.com with SMTP id kx10so57590401pab.11 for ; Fri, 30 Jan 2015 14:55:38 -0800 (PST) X-Received: by 10.70.50.165 with SMTP id d5mr2591570pdo.13.1422658538692; Fri, 30 Jan 2015 14:55:38 -0800 (PST) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPSA id le6sm11940249pab.33.2015.01.30.14.55.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Jan 2015 14:55:38 -0800 (PST) From: mathieu.poirier@linaro.org To: catalin.marinas@arm.com, will.deacon@arm.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] arm64: adding cpu lookup functionality Date: Fri, 30 Jan 2015 15:54:25 -0700 Message-Id: <1422658466-23984-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422658466-23984-1-git-send-email-mathieu.poirier@linaro.org> References: <1422658466-23984-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mathieu.poirier@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mathieu Poirier Adding a lookup function allowing for quick and easy mapping between processor HWID (as found, for example) in DT specifications and the CPU index known to the kernel. Signed-off-by: Mathieu Poirier --- arch/arm64/include/asm/smp_plat.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm64/include/asm/smp_plat.h b/arch/arm64/include/asm/smp_plat.h index 59e282311b58..8e4b011303b1 100644 --- a/arch/arm64/include/asm/smp_plat.h +++ b/arch/arm64/include/asm/smp_plat.h @@ -19,6 +19,7 @@ #ifndef __ASM_SMP_PLAT_H #define __ASM_SMP_PLAT_H +#include #include struct mpidr_hash { @@ -40,4 +41,15 @@ static inline u32 mpidr_hash_size(void) extern u64 __cpu_logical_map[NR_CPUS]; #define cpu_logical_map(cpu) __cpu_logical_map[cpu] +static inline int get_logical_index(u64 mpidr) +{ + int cpu; + + for (cpu = 0; cpu < nr_cpu_ids; cpu++) + if (cpu_logical_map(cpu) == mpidr) + return cpu; + return -EINVAL; +} + + #endif /* __ASM_SMP_PLAT_H */