From patchwork Tue Apr 19 17:13: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: 66130 Delivered-To: patches@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1978182qge; Tue, 19 Apr 2016 10:13:40 -0700 (PDT) X-Received: by 10.28.60.134 with SMTP id j128mr4792124wma.71.1461086012811; Tue, 19 Apr 2016 10:13:32 -0700 (PDT) Return-Path: Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com. [2a00:1450:400c:c09::230]) by mx.google.com with ESMTPS id wh1si1248994wjb.106.2016.04.19.10.13.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Apr 2016 10:13:32 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::230 as permitted sender) client-ip=2a00:1450:400c:c09::230; 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::230 as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x230.google.com with SMTP id u206so41056617wme.1 for ; Tue, 19 Apr 2016 10:13:32 -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=4iGeRqRFv3abGXTu1J2oCsW26GPGRrVEh092TD8ngjk=; b=U5FGb9P2ypLukF3tqz5zTcM8fogxjROXKtsJebhcoHCAvB7+1MyuorVvf9uNpbi4nd SB8HCvjo/6acJaRU2zlmy25sHnjlnCQXZQjdeV16UaMNN4pyAkmJ8+hVLwzGEk378Wcx 3or9utEtgFdglXUDYaqsBcCUxj6iTFjS1r5c0= 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=4iGeRqRFv3abGXTu1J2oCsW26GPGRrVEh092TD8ngjk=; b=MIQO811uFfzWQngeiQxj/H6WwGccPFQyHseUE9LqMg3/dyhOu822eyfQ1yd+HQcMgr /Fe5UZcH4jM4H2u/zxP2ZZMnf5mCLv3DwZLNObgjzv5Sq+rroqZqaaEkUsA0sY66nfLr IwRWmKw86qhCrLqWr9ditpPbJTk/5Bw9YjaXSpZ5A8sDOaeKzlWy2jbIT1ZnmrOzMAcC c2cUZm1uEVbrrCwW6prENq2ip5Ym9siv5q1mhhj92RNlV7c4YX/wB4qIOsZmNHHbxjtl UAWJ0ICfNgOdotg2IvFbxQ+ioYbLRUOFQkwYOWZtZWxTe8+Bg1cn+8phw3Zl7v0/fo4v zC4w== X-Gm-Message-State: AOPr4FW6ENur9EzU+ciBZVKUaAl3uMyca++6JS5WspTSttP6ZCKpcZbNpqMdnFxDEsI9QI1thoE= X-Received: by 10.194.234.101 with SMTP id ud5mr4162199wjc.34.1461086012554; Tue, 19 Apr 2016 10:13:32 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Apr 2016 10:13:31 -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 8/8] genirq/msi: use the MSI doorbell's IOVA when requested Date: Tue, 19 Apr 2016 17:13:10 +0000 Message-Id: <1461085990-2547-9-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> On MSI message composition we now use the MSI doorbell's IOVA in place of the doorbell's PA in case the device is upstream to an IOMMU that requires MSI addresses to be mapped. The doorbell's allocation and mapping happened on an early stage (pci_enable_msi). Signed-off-by: Eric Auger --- v6 -> v7: - allocation/mapping is done at an earlier stage. We now just perform the iova lookup. So it is safe now to be called in a code that cannot sleep. iommu_msi_set_doorbell_iova is moved in the dma-reserved-iommu API: I think it cleans things up with respect to various #ifdef CONFIGS. v5: - use macros to increase the readability - add comments - fix a typo that caused a compilation error if CONFIG_IOMMU_API is not set --- kernel/irq/msi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index e45907e..0ebb2d8 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -19,6 +19,7 @@ /* Temparory solution for building, will be removed later */ #include +#include struct msi_desc *alloc_msi_entry(struct device *dev) { @@ -64,8 +65,12 @@ static int msi_compose(struct irq_data *irq_data, if (erase) memset(msg, 0, sizeof(*msg)); - else + else { ret = irq_chip_compose_msi_msg(irq_data, msg); + if (ret) + return ret; + iommu_msi_mapping_translate_msg(irq_data, msg); + } return ret; }