From patchwork Tue Jun 30 14:14:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 6696511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EDA749F40A for ; Tue, 30 Jun 2015 14:17:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14FD820618 for ; Tue, 30 Jun 2015 14:17:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 366142049E for ; Tue, 30 Jun 2015 14:17:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z9wJi-0003k9-AY; Tue, 30 Jun 2015 14:15:18 +0000 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z9wJB-0002Ff-4J for linux-arm-kernel@lists.infradead.org; Tue, 30 Jun 2015 14:14:46 +0000 Received: by wgqq4 with SMTP id q4so11015008wgq.1 for ; Tue, 30 Jun 2015 07:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=O7M/LEPOLPqfA02ay3HgfSCrziq5DuoHMttuwrqrb6Q=; b=jCH2Z1ZHPH3NhkFLz9WtnvrFYd3nJCLFq2bXeiP2mZJuXj145Od+b6HEYpNjxGB4XO CjMFzcoftS4A6Lzusrxql84HKUKWpqbXrJ8+ds3eHDI8DexW2Vv5dgKAzk4K6cYBoCg3 SnJtCnOmCh9RUwA2eRXC9FML/UbhjqNUW3slvGPxKUuA3tleSCMzTzz6oBgeawKOeKjl I4zC2th3d2oWMNUH5B+JDy0A+FoCkglcOUA/o4MRP70uuXN9UBu/WWUtWLyO4GqHgw/2 3cfV4qxLQ5hqrJ6y6ZNuVLLx3iW2njo/T/puSM+MzVH8HdTAoMMPiLGwiayQFwSAz31j wY+w== X-Received: by 10.180.37.230 with SMTP id b6mr33730823wik.14.1435673662922; Tue, 30 Jun 2015 07:14:22 -0700 (PDT) Received: from rric.localhost (f053084022.adsl.alicedsl.de. [78.53.84.22]) by mx.google.com with ESMTPSA id ym2sm69250192wjc.44.2015.06.30.07.14.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jun 2015 07:14:22 -0700 (PDT) From: Robert Richter To: Marc Zygnier , Thomas Gleixner , Jason Cooper Subject: [PATCH 3/4] irqchip, gicv3: Implement Cavium ThunderX erratum 23154 Date: Tue, 30 Jun 2015 16:14:02 +0200 Message-Id: <1435673643-31676-4-git-send-email-rric@kernel.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1435673643-31676-1-git-send-email-rric@kernel.org> References: <1435673643-31676-1-git-send-email-rric@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150630_071445_317486_E3C5F556 X-CRM114-Status: GOOD ( 13.44 ) X-Spam-Score: -2.4 (--) Cc: Robert Richter , Tirumalesh Chalamarla , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Robert Richter This patch implements Cavium ThunderX erratum 23154. The gicv3 of ThunderX requires a modified version for reading the IAR status to ensure data synchronization. Since this is in the fast-path and called with each interrupt, runtime patching is used using jump label patching for smallest overhead (no-op). This is the same technique as used for tracepoints. Signed-off-by: Robert Richter --- drivers/irqchip/irq-gic-v3.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index f4bafc69cc18..57bb69686ec6 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -107,14 +107,38 @@ static void gic_redist_wait_for_rwp(void) } /* Low level accessors */ -static u64 __maybe_unused gic_read_iar(void) +static u64 gic_read_iar_common(void) +{ + u64 irqstat; + + asm volatile("mrs_s %0, " __stringify(ICC_IAR1_EL1) : "=r" (irqstat)); + return irqstat; +} + +/* Cavium ThunderX erratum 23154 */ +static u64 gic_read_iar_cavium_thunderx(void) { u64 irqstat; + asm volatile("nop;nop;nop;nop;"); + asm volatile("nop;nop;nop;nop;"); asm volatile("mrs_s %0, " __stringify(ICC_IAR1_EL1) : "=r" (irqstat)); + asm volatile("nop;nop;nop;nop;"); + mb(); + return irqstat; } +struct static_key is_cavium_thunderx = STATIC_KEY_INIT_FALSE; + +static u64 __maybe_unused gic_read_iar(void) +{ + if (static_key_false(&is_cavium_thunderx)) + return gic_read_iar_common(); + else + return gic_read_iar_cavium_thunderx(); +} + static void __maybe_unused gic_write_pmr(u64 val) { asm volatile("msr_s " __stringify(ICC_PMR_EL1) ", %0" : : "r" (val)); @@ -765,8 +789,19 @@ static const struct irq_domain_ops gic_irq_domain_ops = { .free = gic_irq_domain_free, }; +static void gicv3_enable_cavium_thunderx(void *data) +{ + static_key_slow_inc(&is_cavium_thunderx); +} + static const struct gic_capabilities gicv3_errata[] = { { + .desc = "GIC: Cavium erratum 23154", + .id = 0xa100034c, /* ThunderX pass 1.x */ + .mask = 0xffff0fff, + .init = gicv3_enable_cavium_thunderx, + }, + { } };