From patchwork Thu Apr 28 08:22: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: 66874 Delivered-To: patches@linaro.org Received: by 10.140.93.198 with SMTP id d64csp78216qge; Thu, 28 Apr 2016 01:22:53 -0700 (PDT) X-Received: by 10.195.13.135 with SMTP id ey7mr13722011wjd.161.1461831772074; Thu, 28 Apr 2016 01:22:52 -0700 (PDT) Return-Path: Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com. [2a00:1450:400c:c09::22b]) by mx.google.com with ESMTPS id qn6si9348208wjc.143.2016.04.28.01.22.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Apr 2016 01:22:52 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::22b as permitted sender) client-ip=2a00:1450:400c:c09::22b; 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::22b as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x22b.google.com with SMTP id e201so67080776wme.0 for ; Thu, 28 Apr 2016 01:22:51 -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=dud7nQ9ejprpDzoy0gN+YV+Mg8gIusOq/Dqia33fc9A=; b=eGXCP5AVW3wh7hI1DCiQgsyEHHLeMmlM1btZp04BYgbJ+n4TkPFYrFkjG1URGUrXG9 I/GmZtsl2nh/Qm9/hNZkBzoUEru5hJOX6xZHLKXWqBsj/Mx+zfGR0R2Ik0fBAVmJBfqe PBsQdkATUhGYu9CO0IEqwFkHxE8gzxJZAQz40= 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=dud7nQ9ejprpDzoy0gN+YV+Mg8gIusOq/Dqia33fc9A=; b=ZozU3zvv5mwdJhplyWGdcHIDGaP6EUIN+W2Pae1MjixnD517TII/cwhbSVG7obo0TE wFbffjh4D1aBJdalXyu7d3ECGmDH23kDVMs8p8zruhR6fkqakSCM79YrQJpfrp1CODOI Hk2DerXroKouNsXMeOhtVQRJPuilrIP5mSilHmYwC1BmHDg9id6UAyMMrxjqHCv6o30e v1BNtxY22hLhkSxd5euWBSLgSAREzlv1Wgi6GfOV2xvwAImlWM55INBW1Y7OBcobRniK Fh8hiohufcEUY7+Cidl1uNYyujs2nwMJ0Hll+AgSXbJF72ufOIVtljXKq3/5HxeXDn/Q pNBQ== X-Gm-Message-State: AOPr4FUoyZJvhkRFmrFb39DHvpyms2/sNbiC57MhLgTly0XhnvDF+csa6ysXGjGzD15g5mo71Eg= X-Received: by 10.28.150.211 with SMTP id y202mr14780150wmd.41.1461831771845; Thu, 28 Apr 2016 01:22:51 -0700 (PDT) Return-Path: 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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Apr 2016 01:22:50 -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 v8 8/8] genirq/msi: use the MSI doorbell's IOVA when requested Date: Thu, 28 Apr 2016 08:22:10 +0000 Message-Id: <1461831730-5575-9-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> 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 --- 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index d5f95e6..835938b 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -64,8 +64,16 @@ static int msi_compose(struct irq_data *irq_data, 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; }