From patchwork Wed May 4 15:18:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 67156 Delivered-To: patches@linaro.org Received: by 10.140.92.199 with SMTP id b65csp241985qge; Wed, 4 May 2016 08:18:36 -0700 (PDT) X-Received: by 10.28.29.147 with SMTP id d141mr31773639wmd.91.1462375113242; Wed, 04 May 2016 08:18:33 -0700 (PDT) Return-Path: Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com. [2a00:1450:400c:c09::233]) by mx.google.com with ESMTPS id o3si5463828wjl.163.2016.05.04.08.18.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 May 2016 08:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::233 as permitted sender) client-ip=2a00:1450:400c:c09::233; 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::233 as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x233.google.com with SMTP id a17so100413527wme.0 for ; Wed, 04 May 2016 08:18:33 -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=WnGmw/X7Tn9wxWIaC0wUbZxTr3aQpO5YeDYhJaEUSR4=; b=FU7UGjNGcmjS7JSCLOZOy3P1gWuBYv6O3KB+suWBYXNf5TTnWwQg7tG+Ap+sfNk275 6wsRoGjD5nLJ8tktbBlY5sUx7im32pJdFRQkNCWzEPKac19bAQ0DZ1sWAJ5LdQuyI0pT CNRr2P13OESA393hT3viTksmc7P3qEbglNnVU= 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=WnGmw/X7Tn9wxWIaC0wUbZxTr3aQpO5YeDYhJaEUSR4=; b=IGfoQR97Xr4CxUFQHFLet7C0Dqzw9B9hZ993CWsQylxvbuJbyDGep91mEeS2cddZ1d oT7jNxh/AiVVAICLKjxkvGwIP+b7YZ3iJm7J8rEeEOouuRiKdG535FpGFH/Gv1HwRZG8 6R6zTxG+z85hzwUMYyU+Iln3qHrocNsxylLnWZSjhTNETR5hv78w8lKafT/ZDNOfL4D8 g7+0e860yOrRDpvWV9AizM6jn5aXADkAqV8s/plM2egmNq+tedCfDZwNGO6SFwZJIDPc 8sTHAeTa+i802w2qe7hRNcRC9vUrqf+3YENAcCr/QLp4GMAdWQ0Tr17W0YkXWps9nISQ ZGVQ== X-Gm-Message-State: AOPr4FUvHrxpRiPzjRaBW+9bVp6JdUSc5/h27kcp24pNaj0x75IG9J3iE6+udkJqoQfl28Q3CBo= X-Received: by 10.28.41.65 with SMTP id p62mr8850411wmp.15.1462375112881; Wed, 04 May 2016 08:18:32 -0700 (PDT) Return-Path: Received: from new-host-57.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id c4sm4773821wjm.24.2016.05.04.08.18.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 May 2016 08:18:30 -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, yehuday@marvell.com Subject: [PATCH v9 4/8] genirq/msi: msi_compose wrapper Date: Wed, 4 May 2016 15:18:10 +0000 Message-Id: <1462375094-2390-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462375094-2390-1-git-send-email-eric.auger@linaro.org> References: <1462375094-2390-1-git-send-email-eric.auger@linaro.org> Currently the MSI message is composed by directly calling irq_chip_compose_msi_msg and erased by setting the memory to zero. On some platforms, we will need to complexify this composition to properly handle MSI emission through IOMMU. Also we will need to track when the MSI message is erased. We propose to introduce a common wrapper for actual composition and erasure, msi_compose. Signed-off-by: Eric Auger --- v4 -> v5: - just introduce the msi-compose wrapper without adding new functionalities v3 -> v4: - that code was formely in irq-gic-common.c "irqchip/gicv2m/v3-its-pci-msi: IOMMU map the MSI frame when needed" also the [un]mapping was done in irq_write_msi_msg; now done on compose v2 -> v3: - protect iova/addr manipulation with CONFIG_ARCH_DMA_ADDR_T_64BIT and CONFIG_PHYS_ADDR_T_64BIT - only expose gic_pci_msi_domain_write_msg in case CONFIG_IOMMU_API & CONFIG_PCI_MSI_IRQ_DOMAIN are set. - gic_set/unset_msi_addr duly become static --- kernel/irq/msi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) -- 1.9.1 diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 9b0ba4a..72bf4d6 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -55,6 +55,19 @@ static inline void irq_chip_write_msi_msg(struct irq_data *data, data->chip->irq_write_msi_msg(data, msg); } +static int msi_compose(struct irq_data *irq_data, + struct msi_msg *msg, bool erase) +{ + int ret = 0; + + if (erase) + memset(msg, 0, sizeof(*msg)); + else + ret = irq_chip_compose_msi_msg(irq_data, msg); + + return ret; +} + /** * msi_domain_set_affinity - Generic affinity setter function for MSI domains * @irq_data: The irq data associated to the interrupt @@ -73,7 +86,7 @@ int msi_domain_set_affinity(struct irq_data *irq_data, ret = parent->chip->irq_set_affinity(parent, mask, force); if (ret >= 0 && ret != IRQ_SET_MASK_OK_DONE) { - BUG_ON(irq_chip_compose_msi_msg(irq_data, &msg)); + BUG_ON(msi_compose(irq_data, &msg, false)); irq_chip_write_msi_msg(irq_data, &msg); } @@ -85,7 +98,7 @@ static void msi_domain_activate(struct irq_domain *domain, { struct msi_msg msg; - BUG_ON(irq_chip_compose_msi_msg(irq_data, &msg)); + BUG_ON(msi_compose(irq_data, &msg, false)); irq_chip_write_msi_msg(irq_data, &msg); } @@ -94,7 +107,7 @@ static void msi_domain_deactivate(struct irq_domain *domain, { struct msi_msg msg; - memset(&msg, 0, sizeof(msg)); + msi_compose(irq_data, &msg, true); irq_chip_write_msi_msg(irq_data, &msg); }