From patchwork Fri Oct 13 15:56:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 115782 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp887964qgn; Fri, 13 Oct 2017 08:58:02 -0700 (PDT) X-Received: by 10.98.103.93 with SMTP id b90mr1783197pfc.2.1507910282820; Fri, 13 Oct 2017 08:58:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507910282; cv=none; d=google.com; s=arc-20160816; b=Z0+cJmo23L2j0HPZcRXn2WXYU0qFH4kHRnq7mUArglbUo52gUZuGviy/Hc2Xg3IUhl 1oE00yXJzpDzoFDGeJi2/c9hMi/RWXQK8oq20TsBod9LcujoIjcbL7i+twGtAqtwdHWi 3IYdBaHsX+YkZa6UDTkXF3rxrS294VwxVf2egZ6vECJ68LZrbFwIWqCEqmC4J5AyVFRv TKh2vy3dataedcM7EfXmVsTh9L1Ge6p8hVzAMjCngsd7vsTI2uoHcd0SutOx40hxFqss sQmTjzqFp6D0IyZ85gWpUAxZm4Iu5bfoj9DwV8zoN2/iBKtB13kDcAhXcF862loE+rZY uv/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=v6N5jlfsitl2YHWYye+FNBuJirmeBGPIPtul4sO82rw=; b=eI7fzPymZXEZN/cdQ9w6jDjV2NHV7X7o8+ufJ44LF6PPwRp/k4WwreMSSYzKUzZj9W MQHtgChBWnghYIlIGI9li/q87TSFttof55nJwG13caPs484aEftLucQsWHIOkJQr7shz u+xhMhuv56kkFRICbEFtNJ16p1T9/tqjWA64p1tRGc6F2KvfMUcArd9/3pNfWLqNtj5u 6QgXrgKXaXMt/q+AwpTH1zvXauZrO9KsgmgeRAb41Z/+P9I349kYuSo0jBPh9I/pa5pp 6Ln8uGcrTUo7jkxPojKS92j6gppX2oKOxlhKdmqjo3sPK9ATjJLwaSm/68uVGSkIiPGG Ijyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OCb7N4Xe; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si794263plk.532.2017.10.13.08.58.02; Fri, 13 Oct 2017 08:58:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OCb7N4Xe; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751138AbdJMP6C (ORCPT + 6 others); Fri, 13 Oct 2017 11:58:02 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:51573 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011AbdJMP6B (ORCPT ); Fri, 13 Oct 2017 11:58:01 -0400 Received: by mail-wr0-f170.google.com with SMTP id j14so1370993wre.8 for ; Fri, 13 Oct 2017 08:58:00 -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=01p1cj1B+Ofr/XXTHbjZO7Z497vs74NYTtmq1yVAjTg=; b=OCb7N4Xeyitnca8Ow0+8NmcvC8QZZGl4udvDkOYnyY0IaS8Klh77lKbOkI7ZsJXa/I cvJBBeR9RWp6uJXrg5aL1+771y0ZSZXKgrB9zUi7sHuirisGNY+RupRWbNymbWZFr8yN wqQyPui+tsDRqS+0Pd8cHE55LNkJllN0luEi0= 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=01p1cj1B+Ofr/XXTHbjZO7Z497vs74NYTtmq1yVAjTg=; b=abeAQ6bYL4C+z4Px0NAd4GsSLDZhQ81nToRl8hrnGS9pgogCmqeCfY88h8uXjdwBI2 6VKgq5UeXDA7bmzNYd2cYqio/QnIgIiZJYhJJerpsEXBJK9xdTCqzCz4lX6RrCBrS/97 /iAJ7yr0Oort4WoATfpUnyabR6lM00Q/9FkwtQeLK9PRWf4je1pzXaczqRWHMLfBEt1B c+w18bJleU9xNSOXZQTaPO57QuHGtiQIbNDx4ayt4c4cKYXaHy9Bn7YFnLeKNigXxABO a068R7/vHUyHYLtCwHknlUK9sVU8O1i+p6/eYwBA/s1l4cnzqVzXf3HBv/qV/N55nAKV kV+g== X-Gm-Message-State: AMCzsaWEDJykmfPuooaL/sJB23LCuPbP2oaUC7Upb2i/GcTLlJQl9GQI VI9n0cN8P3nxyF7BvWWK25QV6Q== X-Google-Smtp-Source: AOwi7QDPelSqq2QGLgVY+ORgQpLxPSbBHOtEW8FIaXiwEIefEZxOm5VmV19QhcF2xJAvzZGvM7uJGg== X-Received: by 10.223.163.151 with SMTP id l23mr1768579wrb.73.1507910280037; Fri, 13 Oct 2017 08:58:00 -0700 (PDT) Received: from localhost.localdomain ([154.146.29.151]) by smtp.gmail.com with ESMTPSA id l19sm1636046wre.26.2017.10.13.08.57.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 08:57:59 -0700 (PDT) From: Ard Biesheuvel To: marc.zyngier@arm.com, robin.murphy@arm.com Cc: linux-arm-kernel@lists.infradead.org, daniel.thompson@Linaro.org, leif.lindholm@linaro.org, graeme.gregory@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, devicetree@vger.kernel.org, robh+dt@kernel.org, Ard Biesheuvel Subject: [PATCH v4 3/3] drivers/irqchip: gicv3: add workaround for Synquacer pre-ITS Date: Fri, 13 Oct 2017 16:56:07 +0100 Message-Id: <20171013155607.5211-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171013155607.5211-1-ard.biesheuvel@linaro.org> References: <20171013155607.5211-1-ard.biesheuvel@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 --- Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt | 4 + arch/arm64/Kconfig | 8 ++ drivers/irqchip/irq-gic-v3-its.c | 83 +++++++++++++++++++- 3 files changed, 91 insertions(+), 4 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt b/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt index 4c29cdab0ea5..a50d348df43b 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. +Optionally, an ITS node may have a sub-node describing a so-called pre-ITS: +- compatible : Should contain "socionext,synquacer-pre-its" +- reg : Specifies the base physical address and size of the pre-ITS window + 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 c34f21c7a38e..f4321dac367a 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -83,6 +83,8 @@ struct its_baser { u32 psz; }; +struct its_device; + /* * The ITS structure - contains most of the infrastructure, with the * top-level MSI domain, the command queue, the collections, and the @@ -97,11 +99,15 @@ 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; + u64 (*get_msi_base)(struct its_device *its_dev); struct list_head its_device_list; u64 flags; u32 ite_size; u32 device_ids; int numa_node; + unsigned int msi_domain_flags; + u32 pre_its_base; /* for Socionext Synquacer */ bool is_v4; }; @@ -1095,14 +1101,19 @@ 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; + + 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_dev->its->get_msi_base(its_dev); msg->address_lo = lower_32_bits(addr); msg->address_hi = upper_32_bits(addr); @@ -2758,6 +2769,54 @@ static bool __maybe_unused its_enable_quirk_qdf2400_e0065(void *data) return true; } +static u64 its_irq_get_msi_base_pre_its(struct its_device *its_dev) +{ + struct its_node *its = its_dev->its; + + /* + * 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); +} + +static bool __maybe_unused its_enable_quirk_socionext_synquacer(void *data) +{ + struct its_node *its = data; + struct device_node *its_np = to_of_node(its->fwnode_handle); + struct device_node *np; + struct resource res; + u32 ids; + + if (!its_np) + return false; + + for_each_child_of_node(its_np, np) { + if (!of_device_is_compatible(np, "socionext,synquacer-pre-its")) + continue; + + if (of_address_to_resource(np, 0, &res)) { + pr_err("pre-ITS window unspecified!\n"); + return false; + } + + its->pre_its_base = (u32)res.start; + its->get_msi_base = its_irq_get_msi_base_pre_its; + + ids = ilog2(res.end - res.start + 1) - 2; + if (its->device_ids > ids) + its->device_ids = ids; + + /* the pre-ITS breaks isolation, so disable MSI remapping */ + its->msi_domain_flags &= ~IRQ_DOMAIN_FLAG_MSI_REMAP; + return true; + } + return false; +} + static const struct gic_quirk its_quirks[] = { #ifdef CONFIG_CAVIUM_ERRATUM_22375 { @@ -2783,6 +2842,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 { } }; @@ -2811,7 +2883,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_flags; info->ops = &its_msi_domain_ops; info->data = its; inner_domain->host_data = info; @@ -2965,6 +3037,9 @@ static int __init its_probe_one(struct resource *res, goto out_free_its; } its->cmd_write = its->cmd_base; + its->fwnode_handle = handle; + its->get_msi_base = its_irq_get_msi_base; + its->msi_domain_flags = IRQ_DOMAIN_FLAG_MSI_REMAP; its_enable_quirks(its);