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: Eric Auger X-Patchwork-Id: 9015991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4A5A29F39D for ; Wed, 4 May 2016 15:21:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7014D203AE for ; Wed, 4 May 2016 15:21:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 981B6203A0 for ; Wed, 4 May 2016 15:21:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1axyb7-0002dT-62; Wed, 04 May 2016 15:20:21 +0000 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1axyZr-0000B5-LF for linux-arm-kernel@lists.infradead.org; Wed, 04 May 2016 15:19:05 +0000 Received: by mail-wm0-x22e.google.com with SMTP id g17so100245065wme.1 for ; Wed, 04 May 2016 08:18:43 -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=UcKNtCKtMPQ2VZp7PObEwuOAiEN1GAsHrNP7OUjweMjTHzyCSYe/vqTjQcJlURSmVK gEnAwrUI0hhofGX0cUjPo735/vV+XbWcIoTRonyQC+umisswn5TB5FMzep9tzPOuAe30 f8mA2LLwYfx0opH0Z3v0vaYxQ2rj9W1WpaoHUqzMAvwWfnFN8uY3acHQUSW/VrAskr/x S0dZ5YNbFZx1RU41Zs9cuOmjaLjD0HTdma2Qeq9Cjdd7XXrq2oavvBB3a44R+U6kBaHk BzzuHIB2/epbrlAH6MGpY7cbS3JawqHCoKBrcy7nAQB0OXK2KXhNoboG7+G9l6IZohQA TJ4g== X-Gm-Message-State: AOPr4FWLL9WV8K/SHC6aTFsPr34Oo7nQU+Q6Fgy4utdCS041PqkkItSZRx+YBU5em0bxrj20 X-Received: by 10.28.142.5 with SMTP id q5mr9559700wmd.21.1462375121843; Wed, 04 May 2016 08:18:41 -0700 (PDT) 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160504_081904_022259_32019A12 X-CRM114-Status: GOOD ( 15.99 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: julien.grall@arm.com, patches@linaro.org, Jean-Philippe.Brucker@arm.com, p.fedin@samsung.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, iommu@lists.linux-foundation.org, pranav.sawargaonkar@gmail.com, yehuday@marvell.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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; }