From patchwork Wed May 4 15:18:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 67160 Delivered-To: patches@linaro.org Received: by 10.140.92.199 with SMTP id b65csp242071qge; Wed, 4 May 2016 08:18:46 -0700 (PDT) X-Received: by 10.28.90.65 with SMTP id o62mr30497627wmb.16.1462375122071; Wed, 04 May 2016 08:18:42 -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 124si5745883wma.104.2016.05.04.08.18.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 May 2016 08:18:42 -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 e201so192652481wme.0 for ; Wed, 04 May 2016 08:18:41 -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=fjZUuqEsnFfwYh0mw1MNCyaipUik+eIZNkbkpIryaRc=; b=VPV/lb0wRzPnb/ad45RGuDDAv4Db/WieF2GvD1uZVpYWB9jDPcDYjeGBt6zIYbisvs LpVaPRTLoXC3CW6WBsN8YOLRspyYW22t0gbI8HjfHAEd5hbj90+5jbYLZiVm0abvVRiZ bnPiz3ltI8KzI9+DP5wXztA4pMA2AHMIEGqpY= 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=fjZUuqEsnFfwYh0mw1MNCyaipUik+eIZNkbkpIryaRc=; b=DymZ2iRB3OY8MGCkc8Hu8B2ix49i500IKeEwIV7NJdW3c5e9x6RY6n4iKWUY/2XFg0 Lf942BPVKWmMm7O5/VJ2bTm2UMX4tBsXWLv1FwZes5F4Cnn8OTan+XB2rZRZPmRPRFJN 4fIaLzrKJhB3GChT4rJKz6FGXsGIRGmFzFi8Fp30w+TbyKegzbIvIZsKuhh3Oa99tYnM SdStwfASquBRu7XxJZANpquFL58jQ+0qpVZVCiBU1L4xKEjo3Ctkv2m0H7RszyogwE0f uVrYmPkaxeFbTFMsVKJP+G3dWPlFhiGDTe2Fc6vkVb2gYDrlawMYieOGFpbh9sAcPHhY BO1g== X-Gm-Message-State: AOPr4FVkqLqeG/fcqp7Va4vjXlrqqND+SLStdwpNWEUo06l3JITHE9T/P6idbSIKaCvt2N4gFk0= X-Received: by 10.28.142.5 with SMTP id q5mr9559700wmd.21.1462375121843; Wed, 04 May 2016 08:18:41 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 May 2016 08:18:40 -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 8/8] genirq/msi: use the MSI doorbell's IOVA when requested Date: Wed, 4 May 2016 15:18:14 +0000 Message-Id: <1462375094-2390-9-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> 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 --- v8 -> v9: - Braces on both sides of the 'else' in msi_compose v7 -> v8: - use iommu_msi_msg_pa_to_va - add WARN_ON 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index d654524..082e6de 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -62,10 +62,18 @@ static int msi_compose(struct irq_data *irq_data, { int ret = 0; - if (erase) + if (erase) { memset(msg, 0, sizeof(*msg)); - else + } else { + struct device *dev; + ret = irq_chip_compose_msi_msg(irq_data, msg); + if (ret) + return ret; + + dev = msi_desc_to_dev(irq_data_get_msi_desc(irq_data)); + WARN_ON(iommu_msi_msg_pa_to_va(dev, msg)); + } return ret; }