Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3050928ybi; Tue, 2 Jul 2019 01:09:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzZAKUyTpArj+9j5J5CJhFUIE859eu7Sox6DEakzsB6KuIvBQze7Lb6azy8xTwvAYCTPXw X-Received: by 2002:a17:902:a504:: with SMTP id s4mr20089932plq.117.1562054991620; Tue, 02 Jul 2019 01:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562054991; cv=none; d=google.com; s=arc-20160816; b=hwa+cKA/GecsC+BBzrTlF7GmyY9XQoXxJ891Gbl++7JrwA/5+hXed1WpIzWjjliCpx hBCCYeKdewY15QIuXCkDlQB2JeRhYyoBDtnoi+9zXRvO4lJXy7PuX3d7mqlQ3zokoMXK DYnQbGDV3rCFppYBuqMOyacJNRTnE2qOePMwkG0s87m7Tk3UQmrrdmGhfTE6ZGeKM/Ck O5LUm2rAnOAEHyb/CuOYyC3VkztvbtEckjOGGREK91NLUD/N/Yj94NhIJZWAC/7Lr80m JghWshM5UfNvmnDL1QkSAmV+ADlKTJIKQJX1+zi1P/gec+GWnhZ/p9DdalZ1qLZ/Nc+Z 5yog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uNp7n6KXo1A+MTbfpjVz98Ksx/lMliHvfFjL8eyUfM8=; b=I8zsYNOxuZOTITfR+JSrlanFbs9+8BV5xNe62ARhr4VZiAOdvnYt2wE18H1DP7qUo+ D1vcTU7ytrN9XpvUM5mP4ie44gJNPISQ4aJEwdQ9qyRqUjqbu+ePCIVWtkhQu8ZO2UtW 5VJ8mzm/5h6ZHFmNB6hzoMQT1LscYCT6C0R/aE6itF4EhnX3rcbfk06IOfuKCyuBemz4 PQLRvSrPN68s9QO7EjMIXYAWSZAB7sXKg9LCeA/fk7FkKj5A+ShbjwJAe2m+izhE9BXn T7Z0+Xovl0UkRRZ4oJptEdOyHFzF9InCFPvDf3lNr0Abq9gn6M/0nOUJW29z5VX8Fqtk 2hTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X9TK0cdI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g129si14294951pfb.1.2019.07.02.01.09.37; Tue, 02 Jul 2019 01:09:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X9TK0cdI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727628AbfGBIHT (ORCPT + 99 others); Tue, 2 Jul 2019 04:07:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:54446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728207AbfGBIHQ (ORCPT ); Tue, 2 Jul 2019 04:07:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A14C021479; Tue, 2 Jul 2019 08:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054835; bh=29iVjL43COetC4HE2QtP8mHrhTybEpva3vP4Pue+hlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9TK0cdIESs94JptYVCJJSzYluaDn9liU8KX7MrIs/w95BzJT/VIBYBqkXxKTjqjT QAVxL02JDTG43TXnaH+qLkFHHnE4kSrY1sH1mlT/GHkQmX0bGkXINNDtX4eC0j09t5 PY7q2CZO/QMaL4CSK52p0EPdZgER8UBM1hd232ME= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Burton , Thomas Gleixner , Jason Cooper , Marc Zyngier , Archer Yan Subject: [PATCH 4.19 48/72] irqchip/mips-gic: Use the correct local interrupt map registers Date: Tue, 2 Jul 2019 10:01:49 +0200 Message-Id: <20190702080127.083118366@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paul Burton commit 6d4d367d0e9ffab4d64a3436256a6a052dc1195d upstream. The MIPS GIC contains a block of registers used to map local interrupts to a particular CPU interrupt pin. Since these registers are found at a consecutive range of addresses we access them using an index, via the (read|write)_gic_v[lo]_map accessor functions. We currently use values from enum mips_gic_local_interrupt as those indices. Unfortunately whilst enum mips_gic_local_interrupt provides the correct offsets for bits in the pending & mask registers, the ordering of the map registers is subtly different... Compared with the ordering of pending & mask bits, the map registers move the FDC from the end of the list to index 3 after the timer interrupt. As a result the performance counter & software interrupts are therefore at indices 4-6 rather than indices 3-5. Notably this causes problems with performance counter interrupts being incorrectly mapped on some systems, and presumably will also cause problems for FDC interrupts. Introduce a function to map from enum mips_gic_local_interrupt to the index of the corresponding map register, and use it to ensure we access the map registers for the correct interrupts. Signed-off-by: Paul Burton Fixes: a0dc5cb5e31b ("irqchip: mips-gic: Simplify gic_local_irq_domain_map()") Fixes: da61fcf9d62a ("irqchip: mips-gic: Use irq_cpu_online to (un)mask all-VP(E) IRQs") Reported-and-tested-by: Archer Yan Cc: Thomas Gleixner Cc: Jason Cooper Cc: stable@vger.kernel.org # v4.14+ Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- arch/mips/include/asm/mips-gic.h | 30 ++++++++++++++++++++++++++++++ drivers/irqchip/irq-mips-gic.c | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) --- a/arch/mips/include/asm/mips-gic.h +++ b/arch/mips/include/asm/mips-gic.h @@ -315,6 +315,36 @@ static inline bool mips_gic_present(void } /** + * mips_gic_vx_map_reg() - Return GIC_Vx__MAP register offset + * @intr: A GIC local interrupt + * + * Determine the index of the GIC_VL__MAP or GIC_VO__MAP register + * within the block of GIC map registers. This is almost the same as the order + * of interrupts in the pending & mask registers, as used by enum + * mips_gic_local_interrupt, but moves the FDC interrupt & thus offsets the + * interrupts after it... + * + * Return: The map register index corresponding to @intr. + * + * The return value is suitable for use with the (read|write)_gic_v[lo]_map + * accessor functions. + */ +static inline unsigned int +mips_gic_vx_map_reg(enum mips_gic_local_interrupt intr) +{ + /* WD, Compare & Timer are 1:1 */ + if (intr <= GIC_LOCAL_INT_TIMER) + return intr; + + /* FDC moves to after Timer... */ + if (intr == GIC_LOCAL_INT_FDC) + return GIC_LOCAL_INT_TIMER + 1; + + /* As a result everything else is offset by 1 */ + return intr + 1; +} + +/** * gic_get_c0_compare_int() - Return cp0 count/compare interrupt virq * * Determine the virq number to use for the coprocessor 0 count/compare --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -388,7 +388,7 @@ static void gic_all_vpes_irq_cpu_online( intr = GIC_HWIRQ_TO_LOCAL(d->hwirq); cd = irq_data_get_irq_chip_data(d); - write_gic_vl_map(intr, cd->map); + write_gic_vl_map(mips_gic_vx_map_reg(intr), cd->map); if (cd->mask) write_gic_vl_smask(BIT(intr)); } @@ -517,7 +517,7 @@ static int gic_irq_domain_map(struct irq spin_lock_irqsave(&gic_lock, flags); for_each_online_cpu(cpu) { write_gic_vl_other(mips_cm_vp_id(cpu)); - write_gic_vo_map(intr, map); + write_gic_vo_map(mips_gic_vx_map_reg(intr), map); } spin_unlock_irqrestore(&gic_lock, flags);