From patchwork Tue Apr 19 17:13:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8882071 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 0B6949F39D for ; Tue, 19 Apr 2016 17:16:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 125BE2026D for ; Tue, 19 Apr 2016 17:16:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FE55202BE for ; Tue, 19 Apr 2016 17:16:01 +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 1asZET-000636-0p; Tue, 19 Apr 2016 17:14:37 +0000 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1asZDi-0005Ix-2M for linux-arm-kernel@lists.infradead.org; Tue, 19 Apr 2016 17:13:51 +0000 Received: by mail-wm0-x22e.google.com with SMTP id n3so41298873wmn.0 for ; Tue, 19 Apr 2016 10:13:29 -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=dofcHsSfZYXvgtcgCsbzKTOqxUuSIqGrMQpmvsuRCpc=; b=DL1cZZUdmCE2DnBL5Q3usuudIWnMQ+QGBye48Y83rUMQqVg1bUEPqa8qtV50F99K8A HbAS5ZlPXEgZME6hDqJ9F+JnfIyxjUjOnJNZ56u0qB2Bm/4A/PXvF/pd00XDr3h7N+pp tfAByJDP1H7zHrauxGv7FgA4J1VtzR2sXmh6U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dofcHsSfZYXvgtcgCsbzKTOqxUuSIqGrMQpmvsuRCpc=; b=er6XC3Cvz9/fe8KX+tB1vrciI81OHDuIYZ1m5mLbl1ikDEwqAw14NIGyBMEKMwf8vA gwdZCWqnwFXsaRpvABWII4WeWT0ASveSiJCZbU4x8Yn/F1yx4IlZYLUYQLRJn2i5eJ0Z Mx4Tj+LzhhFQ9BYOlu7AP6SCo+rR4E1/liAkSpkATX/tqpjTxJSe7LKbXum7j7tobFUX q76hiJYzBBunP/rGQquIWn8y/WRc1o5eq+u9eN7gZokr2rfb9FIlDcI/ZKm+rE3D7wGq wIIllnsEq7knfhJgyED2ejOg954kI50BQ/tM0na/ZZ3xmE5jfd4KKmEGQzf5xKqEo7iP JKBg== X-Gm-Message-State: AOPr4FXYAJG3Bms22h5askTHn9MJSEQgnKo7DClLGCCkbPVfo6yph7zrpP0QHO3jhCtUTLvh X-Received: by 10.28.148.19 with SMTP id w19mr4789753wmd.10.1461086008521; Tue, 19 Apr 2016 10:13:28 -0700 (PDT) Received: from new-host-34.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id gr4sm1243604wjd.23.2016.04.19.10.13.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Apr 2016 10:13:27 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 6/8] irqchip/gicv2m: implement msi_doorbell_info callback Date: Tue, 19 Apr 2016 17:13:08 +0000 Message-Id: <1461085990-2547-7-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461085990-2547-1-git-send-email-eric.auger@linaro.org> References: <1461085990-2547-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160419_101350_316095_624404EF X-CRM114-Status: GOOD ( 17.23 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: julien.grall@arm.com, patches@linaro.org, Jean-Philippe.Brucker@arm.com, p.fedin@samsung.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, iommu@lists.linux-foundation.org, pranav.sawargaonkar@gmail.com 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=-5.1 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 This patch implements the msi_doorbell_info callback in the gicv2m driver. The driver now is able to return its doorbell characteristics (base, size, prot). A single doorbell is exposed. This will allow the msi layer to iommu_map this doorbell when requested. Signed-off-by: Eric Auger --- v7: creation --- drivers/irqchip/irq-gic-v2m.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 28f047c..54690b9 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include /* * MSI_TYPER: @@ -64,6 +66,7 @@ struct v2m_data { u32 nr_spis; /* The number of SPIs for MSIs */ unsigned long *bm; /* MSI vector bitmap */ u32 flags; /* v2m flags for specific implementation */ + struct irq_chip_msi_doorbell_info doorbell_info; }; static void gicv2m_mask_msi_irq(struct irq_data *d) @@ -105,6 +108,16 @@ static void gicv2m_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) msg->data -= v2m->spi_start; } +static const struct irq_chip_msi_doorbell_info * +gicv2m_msi_doorbell_info(struct irq_data *data) +{ + struct v2m_data *v2m = irq_data_get_irq_chip_data(data); + + if (!v2m) + return NULL; + return (const struct irq_chip_msi_doorbell_info *)(&v2m->doorbell_info); +} + static struct irq_chip gicv2m_irq_chip = { .name = "GICv2m", .irq_mask = irq_chip_mask_parent, @@ -112,6 +125,7 @@ static struct irq_chip gicv2m_irq_chip = { .irq_eoi = irq_chip_eoi_parent, .irq_set_affinity = irq_chip_set_affinity_parent, .irq_compose_msi_msg = gicv2m_compose_msi_msg, + .msi_doorbell_info = gicv2m_msi_doorbell_info, }; static int gicv2m_irq_gic_domain_alloc(struct irq_domain *domain, @@ -247,6 +261,7 @@ static void gicv2m_teardown(void) list_for_each_entry_safe(v2m, tmp, &v2m_nodes, entry) { list_del(&v2m->entry); + free_percpu(v2m->doorbell_info.percpu_doorbells); kfree(v2m->bm); iounmap(v2m->base); of_node_put(to_of_node(v2m->fwnode)); @@ -299,6 +314,7 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode, { int ret; struct v2m_data *v2m; + struct irq_chip_msi_doorbell __percpu *doorbell; v2m = kzalloc(sizeof(struct v2m_data), GFP_KERNEL); if (!v2m) { @@ -311,11 +327,23 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode, memcpy(&v2m->res, res, sizeof(struct resource)); + v2m->doorbell_info.percpu_doorbells = + alloc_percpu(struct irq_chip_msi_doorbell); + if (WARN_ON(!v2m->doorbell_info.percpu_doorbells)) { + ret = -ENOMEM; + goto err_free_v2m; + } + doorbell = per_cpu_ptr(v2m->doorbell_info.percpu_doorbells, 0); + doorbell->base = v2m->res.start; + doorbell->size = 4; + doorbell->prot = IOMMU_WRITE; + v2m->doorbell_info.nb_doorbells = 1; + v2m->base = ioremap(v2m->res.start, resource_size(&v2m->res)); if (!v2m->base) { pr_err("Failed to map GICv2m resource\n"); ret = -ENOMEM; - goto err_free_v2m; + goto err_free_v2m_doorbells; } if (spi_start && nr_spis) { @@ -359,6 +387,8 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode, err_iounmap: iounmap(v2m->base); +err_free_v2m_doorbells: + free_percpu(v2m->doorbell_info.percpu_doorbells); err_free_v2m: kfree(v2m); return ret;