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: Eric Auger X-Patchwork-Id: 8966401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B222EBF440 for ; Thu, 28 Apr 2016 08:25:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2EAB202A1 for ; Thu, 28 Apr 2016 08:25:01 +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 48C0720295 for ; Thu, 28 Apr 2016 08:25:00 +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 1avhEh-0001Lo-Nu; Thu, 28 Apr 2016 08:23:47 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1avhE2-0000gJ-FM for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2016 08:23:07 +0000 Received: by mail-wm0-x235.google.com with SMTP id e201so67078206wme.0 for ; Thu, 28 Apr 2016 01:22:48 -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=gZbQDUrMMlUGM8UFBaWLBkgqnoUeQ878BHia5cnKjIJU/i3sY1xqQDytnZMMwPxskm cSuKQehklw2wysM6FRlF9UxZH/wstMwfetvtaDyZ6PYEvU43WP8iQpqXayK2XHZSD08P 3F88hMbYjQIhjzv45zv1Dk0zjtKwBjpZ2h9MlhcxE4mRLUIWLgiLQZTIMkKYKsg0n3gJ gqGSA6Acv09cPERWKcTw3wjgmZ13x2spleA2J3SLH3ntNxJbQuie1sWAFVTwiGMxhSt8 IW5PnI1O12wwJOotGnMzZDtX7aC8Qnm8XiD/wQFNzMNryaGuyklYopYUf8nYx18sdBny gH4w== X-Gm-Message-State: AOPr4FVaaJ3TbxRbnoGEexeMTDFYmiE5VeTrdTW0Kgl6VtkjVYtKdNESRmiqW+oVDOsvN7/8 X-Received: by 10.194.62.145 with SMTP id y17mr14866531wjr.109.1461831766976; Thu, 28 Apr 2016 01:22:46 -0700 (PDT) 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160428_012306_703171_01D54138 X-CRM114-Status: GOOD ( 16.91 ) 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 -> 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(-) 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;