From patchwork Thu Apr 28 08:22:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 66872 Delivered-To: patches@linaro.org Received: by 10.140.93.198 with SMTP id d64csp78176qge; Thu, 28 Apr 2016 01:22:47 -0700 (PDT) X-Received: by 10.194.60.84 with SMTP id f20mr14542314wjr.57.1461831767256; Thu, 28 Apr 2016 01:22:47 -0700 (PDT) Return-Path: Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com. [2a00:1450:400c:c09::232]) by mx.google.com with ESMTPS id 81si14092350wma.1.2016.04.28.01.22.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Apr 2016 01:22:47 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::232 as permitted sender) client-ip=2a00:1450:400c:c09::232; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::232 as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x232.google.com with SMTP id a17so51926220wme.0 for ; Thu, 28 Apr 2016 01:22:47 -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=RIyfSGMapPYj8mFRsSmFGB1ucgGlVgNCjHpl+3mBxuM=; b=j0wZPC97hLo5LI3jvf28tyBr+V3Z5aLmc8oRXNCTmkH2ssulquWtb6nEFoWe3yDqAf HuKeTgeoMezozdQ9rcFz44AFCKuvl85aPFpC5xiOQzrrGOI5QJSKFe10CBxGLK0K6x05 aOe9qZdtwWRHB2BS/vgj4pNsHbHkCy8vjw7jw= 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=RIyfSGMapPYj8mFRsSmFGB1ucgGlVgNCjHpl+3mBxuM=; b=DheFAvyODtHktXoH4vKRd4OmwyIKD+LcfpklqpJQAaJnmwAIjqYA3iMTm9J6DIbf6J 7mqcVjYXy3K7RoXPkV8f9otD8QEj2xytpzMipN3JWb5CjZxcY7ebvE4n8nWyqBacStd1 V9eBxjn3gMeHe66Ws2DJGNkMpUKlxNP3AdzpnkVwSCUx2ksVYxDkVtYXgb7x/FcBdKz+ hM0w7gnnQDCSHtOP2ZRCxBuYObDOOAksIqXJ7uNU+I+zkaCCtFpuxxz36EdAorfBJq2t c02RHNwEwvXsd+TrMCtyaJcYoyUIxQlkX9HGa0xFOO0c98LFuVH9Pcpa85baUbSWxPXB DEhA== X-Gm-Message-State: AOPr4FX7y4hRbcturrXJMZPHjV9KlT5LGuv4b5kYqBUyo14U59m/VP/fAoz+9ipZBfYMMTw/nq0= X-Received: by 10.194.62.145 with SMTP id y17mr14866531wjr.109.1461831766976; Thu, 28 Apr 2016 01:22:46 -0700 (PDT) Return-Path: Received: from new-host-46.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id b124sm3568725wmb.1.2016.04.28.01.22.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Apr 2016 01:22:45 -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 Cc: patches@linaro.org, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, iommu@lists.linux-foundation.org, Jean-Philippe.Brucker@arm.com, julien.grall@arm.com Subject: [PATCH v8 6/8] irqchip/gicv2m: implement msi_doorbell_info callback Date: Thu, 28 Apr 2016 08:22:08 +0000 Message-Id: <1461831730-5575-7-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461831730-5575-1-git-send-email-eric.auger@linaro.org> References: <1461831730-5575-1-git-send-email-eric.auger@linaro.org> 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 -> v8: - gicv2m_msi_doorbell_info does not return a pointer to const - remove spurious !v2m check - add IOMMU_MMIO flag v7: creation --- drivers/irqchip/irq-gic-v2m.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 28f047c..a1ea40c 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,14 @@ static void gicv2m_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) msg->data -= v2m->spi_start; } +static inline 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); + + return &v2m->doorbell_info; +} + static struct irq_chip gicv2m_irq_chip = { .name = "GICv2m", .irq_mask = irq_chip_mask_parent, @@ -112,6 +123,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 +259,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 +312,7 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode, { int ret; struct v2m_data *v2m; + phys_addr_t __percpu *doorbell; v2m = kzalloc(sizeof(struct v2m_data), GFP_KERNEL); if (!v2m) { @@ -311,11 +325,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(phys_addr_t); + 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 = v2m->res.start; + v2m->doorbell_info.size = 4; + v2m->doorbell_info.prot = IOMMU_WRITE | IOMMU_MMIO; + 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 +385,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;