From patchwork Mon Sep 23 23:17:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 20547 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6FE82246ED for ; Mon, 23 Sep 2013 23:18:15 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id l13sf3867180qcy.9 for ; Mon, 23 Sep 2013 16:18:15 -0700 (PDT) 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe :content-transfer-encoding; bh=VQR/tF+uU6UhBh1wIAwLnre/ZBn/l3yL/HKtWWQOI5Q=; b=gznOYIjHFWiemy3Rqlb9NMAt0+hbatI5oM9frxEX3cHwKx7g0Q1y9z37YolBc/JEbc jdXUOpn3jmI6F/nNK0MxiQ8TFSp76LwMW12ixbSe7aJJeyFVZ98uQl32GFOu2JQC+B9/ Ou4pS2GSjR4XOXBZe5ZIFxCoPIU6RQytpzrH3uxbwSemr5miPBjTNZDfMIHFFbkoLcwC fyBc8i1uU20LGnQmnBfH6HqGG082ZzewYan9iZU/6VQWrUFT8iOqzjDpOizJ9sqZX4Ez Zk5Hp/RJSOjvgXOaPtpoiGWu8WkvjjS8fpRIDoFeq37/UoXjrpx2qsPRc9oo2lCi6rwg ngCQ== X-Gm-Message-State: ALoCoQnEW5sOQO5brUEyJpdKQXdxaurvF2oTQsNqulhpk5mbP6OV4XN2u6PPveU0CoUK9Hs2NqSn X-Received: by 10.224.126.137 with SMTP id c9mr11458397qas.2.1379978295282; Mon, 23 Sep 2013 16:18:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.81.230 with SMTP id d6ls1404941qey.93.gmail; Mon, 23 Sep 2013 16:18:15 -0700 (PDT) X-Received: by 10.52.0.142 with SMTP id 14mr974252vde.94.1379978295069; Mon, 23 Sep 2013 16:18:15 -0700 (PDT) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by mx.google.com with ESMTPS id cz7si7548429veb.109.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Sep 2013 16:18:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.43; Received: by mail-vb0-f43.google.com with SMTP id h11so2726759vbh.2 for ; Mon, 23 Sep 2013 16:18:15 -0700 (PDT) X-Received: by 10.58.117.71 with SMTP id kc7mr24501410veb.16.1379978294986; Mon, 23 Sep 2013 16:18:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp208754vcz; Mon, 23 Sep 2013 16:18:14 -0700 (PDT) X-Received: by 10.49.15.97 with SMTP id w1mr30959160qec.13.1379978283657; Mon, 23 Sep 2013 16:18:03 -0700 (PDT) Received: from relais.videotron.ca (relais.videotron.ca. [24.201.245.36]) by mx.google.com with ESMTP id d7si13390068qeo.8.1969.12.31.16.00.00; Mon, 23 Sep 2013 16:18:03 -0700 (PDT) Received-SPF: neutral (google.com: 24.201.245.36 is neither permitted nor denied by best guess record for domain of nicolas.pitre@linaro.org) client-ip=24.201.245.36; Received: from yoda.home ([70.83.209.44]) by VL-VM-MR005.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0MTL003BDQ22N190@VL-VM-MR005.ip.videotron.ca> for patches@linaro.org; Mon, 23 Sep 2013 19:18:02 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 0761F2DA066C; Mon, 23 Sep 2013 19:18:02 -0400 (EDT) From: Nicolas Pitre To: linux-arm-kernel@lists.infradead.org Cc: dave.martin@arm.com, linaro-kernel@lists.linaro.org, patches@linaro.org Subject: [PATCH 13/13] ARM: bL_switcher: Add query interface to discover CPU affinities Date: Mon, 23 Sep 2013 19:17:56 -0400 Message-id: <1379978276-31241-14-git-send-email-nicolas.pitre@linaro.org> X-Mailer: git-send-email 1.8.4.98.gb022869 In-reply-to: <1379978276-31241-1-git-send-email-nicolas.pitre@linaro.org> References: <1379978276-31241-1-git-send-email-nicolas.pitre@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: nicolas.pitre@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-transfer-encoding: 7BIT From: Dave Martin When the switcher is active, there is no straightforward way to figure out which logical CPU a given physical CPU maps to. This patch provides a function bL_switcher_get_logical_index(mpidr), which is analogous to get_logical_index(). This function returns the logical CPU on which the specified physical CPU is grouped (or -EINVAL if unknown). If the switcher is inactive or not present, -EUNATCH is returned instead. Signed-off-by: Dave Martin Signed-off-by: Nicolas Pitre --- arch/arm/common/bL_switcher.c | 20 ++++++++++++++++++++ arch/arm/include/asm/bL_switcher.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c index f4878a3604..63bbc4f705 100644 --- a/arch/arm/common/bL_switcher.c +++ b/arch/arm/common/bL_switcher.c @@ -532,6 +532,26 @@ static int bL_switcher_halve_cpus(void) return 0; } +/* Determine the logical CPU a given physical CPU is grouped on. */ +int bL_switcher_get_logical_index(u32 mpidr) +{ + int cpu; + + if (!bL_switcher_active) + return -EUNATCH; + + mpidr &= MPIDR_HWID_BITMASK; + for_each_online_cpu(cpu) { + int pairing = bL_switcher_cpu_pairing[cpu]; + if (pairing == -1) + continue; + if ((mpidr == cpu_logical_map(cpu)) || + (mpidr == cpu_logical_map(pairing))) + return cpu; + } + return -EINVAL; +} + static void bL_switcher_trace_trigger_cpu(void *__always_unused info) { trace_cpu_migrate_current(get_ns(), read_mpidr()); diff --git a/arch/arm/include/asm/bL_switcher.h b/arch/arm/include/asm/bL_switcher.h index 8ada5a885c..1714800fa1 100644 --- a/arch/arm/include/asm/bL_switcher.h +++ b/arch/arm/include/asm/bL_switcher.h @@ -55,6 +55,7 @@ bool bL_switcher_get_enabled(void); void bL_switcher_put_enabled(void); int bL_switcher_trace_trigger(void); +int bL_switcher_get_logical_index(u32 mpidr); #else static inline int bL_switcher_register_notifier(struct notifier_block *nb) @@ -70,6 +71,7 @@ static inline int bL_switcher_unregister_notifier(struct notifier_block *nb) static inline bool bL_switcher_get_enabled(void) { return false; } static inline void bL_switcher_put_enabled(void) { } static inline int bL_switcher_trace_trigger(void) { return 0; } +static inline int bL_switcher_get_logical_index(u32 mpidr) { return -EUNATCH; } #endif /* CONFIG_BL_SWITCHER */ #endif