From patchwork Tue Apr 19 17:13:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 66126 Delivered-To: patches@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1978104qge; Tue, 19 Apr 2016 10:13:30 -0700 (PDT) X-Received: by 10.194.89.38 with SMTP id bl6mr4117245wjb.44.1461086005437; Tue, 19 Apr 2016 10:13:25 -0700 (PDT) Return-Path: Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com. [2a00:1450:400c:c09::22e]) by mx.google.com with ESMTPS id he10si1234696wjb.155.2016.04.19.10.13.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Apr 2016 10:13:25 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::22e as permitted sender) client-ip=2a00:1450:400c:c09::22e; 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::22e as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x22e.google.com with SMTP id e201so21936923wme.0 for ; Tue, 19 Apr 2016 10:13:25 -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=eUeLCUNfLmvfczX7Ir60o8iNSXQAPcMqsjj828o37ScItfFXXwYA9fuoELXAdscp5R LKAR+Fg4Ngv2kIwWB3goAKgGUqEe9fX23ooCAOseDKuPafsyYCX740UcjhWVAUTIRc97 PwRsZEn/qWst8wTKroMdQL48MspHCYoHUbHnk= 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=j9qyv39GWAFOg5u1yemy7rVmEGXJEMcotIfHV/m8snoduikfxmuHTiYR5WbM1Wt42g QiEjcgQ51UUADDMZ+qebUAvkCzpWudFnre2cHxSfGsLnZaAahzppQBU0HzysBBUxoSfB mkkZhwRt7tM6LgST20jTMdjamxJDQFlv3Kpoq/M4yDfVBv99P5tbyjlMONYRpYe1CoGJ 81asEgbkUA67AI6Id9hNlW2vCkYDXW6uCZ2NO/Nrinsj1dkIWaBEQL/W9natOnoFDFZW hF5V3KV+9Abfeu+LSpMWc4wt6yRKA3m774U3lUvr8EpDM/lU5oF/Y6YN5N85VtBcRSyz SWQQ== X-Gm-Message-State: AOPr4FXD8/O532J6qngJaYkYP+qM9EWpaDqZm00budOyDEGF3zLXFlLVsqgAibXE5l2gYjnccPQ= X-Received: by 10.28.0.69 with SMTP id 66mr24839757wma.61.1461086004892; Tue, 19 Apr 2016 10:13:24 -0700 (PDT) Return-Path: 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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Apr 2016 10:13:23 -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 v7 4/8] genirq/msi: msi_compose wrapper Date: Tue, 19 Apr 2016 17:13:06 +0000 Message-Id: <1461085990-2547-5-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> 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); }