From patchwork Wed Sep 11 11:59:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 19965 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6325925E63 for ; Wed, 11 Sep 2013 11:59:53 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hf12sf10215887vcb.3 for ; Wed, 11 Sep 2013 04:59:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state: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; bh=2q/kWYVisP5PgZwlzlpYGlMXUiTubpDW0w8lBeoJnXc=; b=a5iHfIijXL+SU8MKmJnSywX2jSYFnQXNw7T1INHQ+U2uLIFKYq1q/jb84/dEPnTOKh OAa3/gKep4MHINg8zxSsTcefLZxSIDDC09g67RHw4gViEv+Qdop/cjNGAXP2aB8lB5mr V8OIjdbtU9INkj3JS8ch2ZcWBk9CTBP5Qzn5DYA1cn/EfA/u1mLdx9UngnCbFzQ+b8MP NIHJb5x7LW/ZBfd4XmF6qFSIDfsj4YnSWzvjyqjqFow3CDWfuhLMC1TwYrWCz/vWHasR euzAQ1ECkdHHaQmRduc5HaOYQz/TdRJlqrU4BJjHxBBwTYoKSzZCV00s8eiZufXx86Ys 8UEg== X-Received: by 10.236.45.102 with SMTP id o66mr449373yhb.47.1378900793236; Wed, 11 Sep 2013 04:59:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.62.72 with SMTP id w8ls216663qer.2.gmail; Wed, 11 Sep 2013 04:59:53 -0700 (PDT) X-Received: by 10.220.13.20 with SMTP id z20mr941452vcz.0.1378900792998; Wed, 11 Sep 2013 04:59:52 -0700 (PDT) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id j1si4421353vci.26.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Sep 2013 04:59:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.46 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.46; Received: by mail-vb0-f46.google.com with SMTP id p13so5840330vbe.19 for ; Wed, 11 Sep 2013 04:59:52 -0700 (PDT) X-Gm-Message-State: ALoCoQmjFXQojowdTiFVLINwnU2Jtc7/lnLZuHuqzg9FPDbZ4xbxqVJ8HJZHbYFr0IRrrxQhWcz8 X-Received: by 10.220.43.19 with SMTP id u19mr916926vce.3.1378900792916; Wed, 11 Sep 2013 04:59:52 -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 u4csp52079vcz; Wed, 11 Sep 2013 04:59:52 -0700 (PDT) X-Received: by 10.14.175.2 with SMTP id y2mr1631356eel.83.1378900791820; Wed, 11 Sep 2013 04:59:51 -0700 (PDT) Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com [74.125.83.42]) by mx.google.com with ESMTPS id x43si4265874eep.220.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Sep 2013 04:59:51 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.42 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.42; Received: by mail-ee0-f42.google.com with SMTP id b45so4569097eek.29 for ; Wed, 11 Sep 2013 04:59:51 -0700 (PDT) X-Received: by 10.14.194.131 with SMTP id m3mr1680420een.45.1378900790976; Wed, 11 Sep 2013 04:59:50 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id p5sm39687866eeg.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Sep 2013 04:59:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, patches@linaro.org, Julien Grall Subject: [PATCH v2 3/6] xen/arm: gic: Use the correct CPU ID Date: Wed, 11 Sep 2013 12:59:41 +0100 Message-Id: <1378900784-16949-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1378900784-16949-1-git-send-email-julien.grall@linaro.org> References: <1378900784-16949-1-git-send-email-julien.grall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.46 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: , The GIC mapping of CPU interfaces does not necessarily match the logical CPU numbering. When Xen wants to send an SGI to specific CPU, it needs to use the GIC CPU ID. It can be retrieved from ITARGETSR0, in fact when this field is read, the GIC will return a value that corresponds only to the processor reading the register. So Xen can use the PPI 0 to initialize the mapping. Signed-off-by: Julien Grall --- Changes in v2: - Use per-cpu variable instead of an array - Add comment for NR_GIC_CPU_IF --- xen/arch/arm/gic.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index a10416d..7ea9ed6 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -57,6 +57,29 @@ static DEFINE_PER_CPU(uint64_t, lr_mask); static unsigned nr_lrs; +/* The GIC mapping of CPU interfaces does not necessarily match the + * logical CPU numbering. Let's use mapping as returned by the GIC + * itself + */ +static DEFINE_PER_CPU(u8, gic_cpu_id); + +/* Maximum cpu interface per GIC */ +#define NR_GIC_CPU_IF 8 + +static unsigned int gic_cpu_mask(const cpumask_t *cpumask) +{ + unsigned int cpu; + unsigned int mask = 0; + + for_each_cpu(cpu, cpumask) + { + ASSERT(cpu < NR_GIC_CPU_IF); + mask = per_cpu(gic_cpu_id, cpu); + } + + return mask; +} + unsigned int gic_number_lines(void) { return gic.lines; @@ -206,9 +229,7 @@ static void gic_set_irq_properties(unsigned int irq, bool_t level, { volatile unsigned char *bytereg; uint32_t cfg, edgebit; - unsigned int mask = cpumask_bits(cpu_mask)[0]; - - ASSERT(!(mask & ~0xff)); /* Target bitmap only support 8 CPUS */ + unsigned int mask = gic_cpu_mask(cpu_mask); /* Set edge / level */ cfg = GICD[GICD_ICFGR + irq / 16]; @@ -317,6 +338,8 @@ static void __cpuinit gic_cpu_init(void) { int i; + this_cpu(gic_cpu_id) = GICD[GICD_ITARGETSR] & 0xff; + /* The first 32 interrupts (PPI and SGI) are banked per-cpu, so * even though they are controlled with GICD registers, they must * be set up here with the other per-cpu state. */ @@ -448,13 +471,13 @@ void __init gic_init(void) void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) { - unsigned long mask = cpumask_bits(cpumask)[0]; + cpumask_t online_mask; + unsigned int mask = 0; ASSERT(sgi < 16); /* There are only 16 SGIs */ - mask &= cpumask_bits(&cpu_online_map)[0]; - - ASSERT(mask < 0x100); /* The target bitmap only supports 8 CPUs */ + cpumask_and(&online_mask, cpumask, &cpu_online_map); + mask = gic_cpu_mask(&online_mask); dsb();