From patchwork Wed Apr 25 09:18:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10361981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51D8F60546 for ; Wed, 25 Apr 2018 09:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4276528EC3 for ; Wed, 25 Apr 2018 09:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36BBA28EC5; Wed, 25 Apr 2018 09:18:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E072228EC3 for ; Wed, 25 Apr 2018 09:18:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CAB196E1F6; Wed, 25 Apr 2018 09:18:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 76B3E6E1B4; Wed, 25 Apr 2018 09:18:20 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id w3-v6so52571795wrg.2; Wed, 25 Apr 2018 02:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eoEBYV4LClR/ih0qxrb+pfqsbbEI+K72dso7GWT16IQ=; b=UaR5T7nzlRX7EIJytjKs0MEEkrRRmSKgzhwP/am7vXg232KNzA3qNkblt6pmSYbcuk tX089x29/7abdM40/31YDpP0y4GlGIYQcnZwXb8oczsUK9/f6q6AAjfcSfZpMwEMeClh 1okb/xrh2fDI/e6tFLeiHXPcTDzmwCsihd1OqnP7X0kW0JSoFX+Q97lf3XDoYvDtuJl2 kRgaKvAHYZJ+rFnnJRWOtiveqNg5YQACuoNpnSassveSS4pYguBS9KD6c4HLj2NaptoU PctTKoiWDHOmqhxJEPE6fcsKt4e6t24ZsspTyJcWzaaeiueOXA6WKe7qyR9mFHQmgiF2 6Sxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eoEBYV4LClR/ih0qxrb+pfqsbbEI+K72dso7GWT16IQ=; b=SIcBi1icx+3ONXK3boRe3yMD6SiBbyj12v8iYe0ctT+eJundEIgDp6BKplyWzX0hWx kmy87fLsfG5kkF+6z278W+iAVpbGfkmGZA7r1drsXm4QblePgyUCilTWHggvm1Oy8rxl 8NrTA+xj42SXN855vIw4WUhYv2diFJ3lCN/H7S8btFlSMfAxsaZElIq0beUYt9bK+abC iv37FbS6fAa9bk/2YG3iB2B6bgM9bMiffOCD3SPVf7q2gtLZD8XaFh+cObzb5L2w85h0 8rg6QizQVds8pfcX3LAAFjWSz59sZZNEvP3cEUH+IV7zjsAfE+WRRqNZ0S/JnHRipkl1 vbJA== X-Gm-Message-State: ALQs6tCmPq7Z7hq1skEbBWLlzioOsygnCv11mJZilsvFgX7pm6h/qVmW 0ysyXWp99fGDnDGXaSvCe3E= X-Google-Smtp-Source: AIpwx49WSIZCcWEadMdFzcFlH4/ZagncU0mxTxxSCYG6naMmNlD1oFq+RH1h3r6MIKtx7xbf/brbVA== X-Received: by 2002:adf:e791:: with SMTP id n17-v6mr19864396wrm.225.1524647898880; Wed, 25 Apr 2018 02:18:18 -0700 (PDT) Received: from localhost (p200300E41F041C0032947E635CB49D15.dip0.t-ipconnect.de. [2003:e4:1f04:1c00:3294:7e63:5cb4:9d15]) by smtp.gmail.com with ESMTPSA id m17-v6sm15570397wrh.3.2018.04.25.02.18.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Apr 2018 02:18:18 -0700 (PDT) From: Thierry Reding To: Christoph Hellwig , Joerg Roedel Subject: [PATCH 2/4] dma-mapping: Introduce dma_iommu_detach_device() API Date: Wed, 25 Apr 2018 11:18:13 +0200 Message-Id: <20180425091815.16264-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425091815.16264-1-thierry.reding@gmail.com> References: <20180425091815.16264-1-thierry.reding@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding The dma_iommu_detach_device() API can be used by drivers to forcibly detach a device from an IOMMU that architecture code might have attached to. This is useful for drivers that need explicit control over the IOMMU using the IOMMU API directly. Signed-off-by: Thierry Reding --- drivers/base/dma-mapping.c | 8 ++++++++ include/linux/dma-mapping.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c index d82566d6e237..18ddf32b10c9 100644 --- a/drivers/base/dma-mapping.c +++ b/drivers/base/dma-mapping.c @@ -366,3 +366,11 @@ void dma_deconfigure(struct device *dev) of_dma_deconfigure(dev); acpi_dma_deconfigure(dev); } + +void dma_iommu_detach_device(struct device *dev) +{ +#ifdef arch_iommu_detach_device + arch_iommu_detach_device(dev); +#endif +} +EXPORT_SYMBOL(dma_iommu_detach_device); diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index f8ab1c0f589e..732191a2c64e 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -671,6 +671,8 @@ static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, static inline void arch_teardown_dma_ops(struct device *dev) { } #endif +extern void dma_iommu_detach_device(struct device *dev); + static inline unsigned int dma_get_max_seg_size(struct device *dev) { if (dev->dma_parms && dev->dma_parms->max_segment_size)