From patchwork Thu Oct 12 18:32:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10002485 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B1BF60216 for ; Thu, 12 Oct 2017 18:34:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2FC128E64 for ; Thu, 12 Oct 2017 18:34:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7AE728E6C; Thu, 12 Oct 2017 18:34:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 658A428E64 for ; Thu, 12 Oct 2017 18:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4WIapHUswKAbDQlqfhHo1P2jA+xOf1JQnWY48neEH88=; b=AFD+VvHTbj6TSc6Lb8fBC+SSXK flzQwJeJDmdNsp67Oi3zpqz9wvbKNhg1LZn61Nq+FYY3EVgyxk9cM+FTvKgdtlB4FQSn9a1ks5uMT sQ1t6/LKt7iy4vnhawmyD8o4FcU/haR0Kxqs7jfkt5ZS0qXK4KGXqiG7T6VIR44hiH+lUiiIwLnYS vVDAwtpOtGGDkXNY632qOTBbqp9IoXM78ZO75KA4hf5dL4o4mCboidZ+vch6yz5uugYdO5o4N+hYj 5s4XguqBDTbRZSefst+H8Jthm2EzoHpR7+egusNktGmR0Vv9popdkfkcHPiOyCq8NO0U8WA5LKHt+ uo8cyXOA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e2iIu-0003Qw-LN; Thu, 12 Oct 2017 18:33:56 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e2iIW-0003LG-MA for linux-arm-kernel@bombadil.infradead.org; Thu, 12 Oct 2017 18:33:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6UJEeZLBbhQX13SJYZB/zIdzNpC/DSaYF7tRQvJrMdQ=; b=KqjSSL04mD/L8XqPRv4IsXSd7 QbKfefy7tU+nxgTVa9m1N996oWKTcN9BJiyBF6M54RTAV/SAu9j6qCAUPhZ/oeDFAc7BrO3mIDxwD J8R52c4KOKEA37DRuPix0vDT1eAAmuN/+2gxugBKwKKZduI8S4cPtHm35dFGhiBalcchitT4v1yeo oDE/CdMr5gziL0kuylrzaFReXW1zBPGT8bv10F8czEzsC+R6hIYOwgm2J0QurSfe+k2oZMXBtiNfQ 87HEKMv7U1nbvAfLEdmtlJuzMRCF/02QKjyXnNKa1JBY/pOdhIpVbNvmEELG7WAwgTd8oXtFSBV++ xNuGaok1g==; Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e2iIT-0006Ze-IV for linux-arm-kernel@lists.infradead.org; Thu, 12 Oct 2017 18:33:31 +0000 Received: by mail-wm0-x22b.google.com with SMTP id q132so15725509wmd.2 for ; Thu, 12 Oct 2017 11:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6UJEeZLBbhQX13SJYZB/zIdzNpC/DSaYF7tRQvJrMdQ=; b=RO6N56OAC29g5wF6WHfq7JT5ur4I0J8DucGTPDbWZcocYLUYOXU6NVddzUC0muuumB IW4wmulNoUAC8DGRpFius+CngmRnUuA9fisRRpo6Xa8W0qI7NlPG6/bVdlev2hd8kag9 pPMNTCBOC3MPAulPgpQvZ+oteJ35OObhod6SI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6UJEeZLBbhQX13SJYZB/zIdzNpC/DSaYF7tRQvJrMdQ=; b=UtyfuEi6bVzmoQZ14jU87ftmhrRKAvcVRUowB7ie5sF1YjqTS0kYPz5+WxcDFRO+n+ BCq48XbKnHu5hE2izB8uet2Hd5MyI4nn8dsD71mVtWemgpnwyFWRDcCtsMxTRmWF4pUZ mCb5ifLH1wqe+008xUctph4NsYmJ+0EvyoApM0JBhiL/X4bfKYunkv8fewvusijm6Ypm 9rNnYK3h/SYXGLYSo7XBhoB0u4Mb77noKFO53xaYwYdP5WqWq4tolIq2+MXB0ZWz76le aJOzL/Ajt955Z9Z85BrkpwcgoomodDXeoJGYRdD5ZbkhQERKOgiIzc91QIoWeWati1if pnWw== X-Gm-Message-State: AMCzsaUGrNGPcIiEBK4zeRjyaQQ5ekgOhljxaxVuN54krKJ8s85AkGLi J/Ptv1xYuR0K/kOIewopUd3lbQ== X-Google-Smtp-Source: AOwi7QDvIVF2JemxDDq5JzmhNlxYYuQHNiX3F5sKQ18lGyzIJQePw3Iqx6z16G7821w+jVukEl73cQ== X-Received: by 10.223.128.170 with SMTP id 39mr2817412wrl.236.1507833183801; Thu, 12 Oct 2017 11:33:03 -0700 (PDT) Received: from localhost.localdomain ([196.78.24.219]) by smtp.gmail.com with ESMTPSA id i13sm14730579wre.93.2017.10.12.11.33.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 11:33:03 -0700 (PDT) From: Ard Biesheuvel To: marc.zyngier@arm.com, robin.murphy@arm.com Subject: [PATCH v3 2/2] drivers/irqchip: gicv3: add workaround for Synquacer pre-ITS Date: Thu, 12 Oct 2017 19:32:47 +0100 Message-Id: <20171012183247.23679-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171012183247.23679-1-ard.biesheuvel@linaro.org> References: <20171012183247.23679-1-ard.biesheuvel@linaro.org> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, daniel.thompson@Linaro.org, graeme.gregory@linaro.org, Ard Biesheuvel , catalin.marinas@arm.com, will.deacon@arm.com, leif.lindholm@linaro.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The Socionext Synquacer SoC's implementation of GICv3 has a so-called 'pre-ITS', which maps 32-bit writes targeted at a separate window of size '4 << device_id_bits' onto writes to GITS_TRANSLATER with device ID taken from bits [device_id_bits + 1:2] of the window offset. Writes that target GITS_TRANSLATER directly are reported as originating from device ID #0. So add a workaround for this. Given that this breaks isolation, clear the IRQ_DOMAIN_FLAG_MSI_REMAP flag as well. Signed-off-by: Ard Biesheuvel Acked-by: Rob Herring --- Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt | 4 ++ arch/arm64/Kconfig | 8 +++ drivers/irqchip/irq-gic-v3-its.c | 63 +++++++++++++++++++- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt b/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt index 4c29cdab0ea5..0798a61bbf99 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt +++ b/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt @@ -75,6 +75,10 @@ These nodes must have the following properties: - reg: Specifies the base physical address and size of the ITS registers. +Optional: +- socionext,synquacer-pre-its: (u32, u32) tuple describing the host address + and size of the pre-ITS window, as implemented on the Socionext Synquacer SoC + The main GIC node must contain the appropriate #address-cells, #size-cells and ranges properties for the reg property of all ITS nodes. diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 0df64a6a56d4..c4361dff2b74 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -539,6 +539,14 @@ config QCOM_QDF2400_ERRATUM_0065 If unsure, say Y. +config SOCIONEXT_SYNQUACER_PREITS + bool "Socionext Synquacer: Workaround for GICv3 pre-ITS" + default y + help + Socionext Synquacer SoCs implement a separate h/w block to generate + MSI doorbell writes with non-zero values for the device ID. + + If unsure, say Y. endmenu diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 891de07fd4cc..2fc4fba0cc4c 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -97,12 +97,18 @@ struct its_node { struct its_cmd_block *cmd_write; struct its_baser tables[GITS_BASER_NR_REGS]; struct its_collection *collections; + struct fwnode_handle *fwnode_handle; struct list_head its_device_list; u64 flags; u32 ite_size; u32 device_ids; int numa_node; + unsigned int msi_domain_flag_mask; bool is_v4; + + /* for Socionext Synquacer pre-ITS */ + u32 pre_its_base; + u32 pre_its_size; }; #define ITS_ITT_ALIGN SZ_256 @@ -1095,14 +1101,29 @@ static int its_set_affinity(struct irq_data *d, const struct cpumask *mask_val, return IRQ_SET_MASK_OK_DONE; } +static u64 its_irq_get_msi_base(struct its_device *its_dev) +{ + struct its_node *its = its_dev->its; + + if (unlikely(its->pre_its_size > 0)) + /* + * The Socionext Synquacer SoC has a so-called 'pre-ITS', + * which maps 32-bit writes targeted at a separate window of + * size '4 << device_id_bits' onto writes to GITS_TRANSLATER + * with device ID taken from bits [device_id_bits + 1:2] of + * the window offset. + */ + return its->pre_its_base + (its_dev->device_id << 2); + + return its->phys_base + GITS_TRANSLATER; +} + static void its_irq_compose_msi_msg(struct irq_data *d, struct msi_msg *msg) { struct its_device *its_dev = irq_data_get_irq_chip_data(d); - struct its_node *its; u64 addr; - its = its_dev->its; - addr = its->phys_base + GITS_TRANSLATER; + addr = its_irq_get_msi_base(its_dev); msg->address_lo = lower_32_bits(addr); msg->address_hi = upper_32_bits(addr); @@ -2752,6 +2773,27 @@ static void __maybe_unused its_enable_quirk_qdf2400_e0065(void *data) its->ite_size = 16; } +static void __maybe_unused its_enable_quirk_socionext_synquacer(void *data) +{ + struct its_node *its = data; + u32 pre_its_window[2]; + u32 ids; + + if (!fwnode_property_read_u32_array(its->fwnode_handle, + "socionext,synquacer-pre-its", + pre_its_window, + ARRAY_SIZE(pre_its_window))) { + its->pre_its_base = pre_its_window[0]; + its->pre_its_size = pre_its_window[1]; + + ids = ilog2(its->pre_its_size) - 2; + if (its->device_ids > ids) + its->device_ids = ids; + + its->msi_domain_flag_mask = ~IRQ_DOMAIN_FLAG_MSI_REMAP; + } +} + static const struct gic_quirk its_quirks[] = { #ifdef CONFIG_CAVIUM_ERRATUM_22375 { @@ -2777,6 +2819,19 @@ static const struct gic_quirk its_quirks[] = { .init = its_enable_quirk_qdf2400_e0065, }, #endif +#ifdef CONFIG_SOCIONEXT_SYNQUACER_PREITS + { + /* + * The Socionext Synquacer SoC incorporates ARM's own GIC-500 + * implementation, but with a 'pre-ITS' added that requires + * special handling in software. + */ + .desc = "ITS: Socionext Synquacer pre-ITS", + .iidr = 0x0001143b, + .mask = 0xffffffff, + .init = its_enable_quirk_socionext_synquacer, + }, +#endif { } }; @@ -2806,6 +2861,7 @@ static int its_init_domain(struct fwnode_handle *handle, struct its_node *its) inner_domain->parent = its_parent; irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS); inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_REMAP; + inner_domain->flags &= its->msi_domain_flag_mask; info->ops = &its_msi_domain_ops; info->data = its; inner_domain->host_data = info; @@ -2959,6 +3015,7 @@ static int __init its_probe_one(struct resource *res, goto out_free_its; } its->cmd_write = its->cmd_base; + its->fwnode_handle = handle; its_enable_quirks(its);