From patchwork Wed Apr 25 10:10:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10362199 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 21787601D3 for ; Wed, 25 Apr 2018 10:11:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 130D128DF9 for ; Wed, 25 Apr 2018 10:11:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 077E528F46; Wed, 25 Apr 2018 10:11:04 +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 BA98128DF9 for ; Wed, 25 Apr 2018 10:11:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 029AA6E585; Wed, 25 Apr 2018 10:11:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id D08BD6E57B; Wed, 25 Apr 2018 10:10:55 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id j4so6149721wme.1; Wed, 25 Apr 2018 03:10:55 -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=BZ/+M7dwWWWi95l7kWkfJAioJt/Z3s/bWBOFto6zt9b45ZNEjaHqqanhhUdYIA4TS8 38LPpUsunN0egQTFn8YuEMJQdPw0BXV6N1Qj2xPJR3b6v8/fPXcU0M2E5qzSiHB+/xJT cjPYgJG1TLdNStxYBar/sON3U4NkaVb/YbeD8yeYkzI0Qqd2+E5tgFCltrk+JxzanqmC DZ1I497ZkIB2Q6nY9oOycCGmrcffp7reo5Zo93nNrCG+jY4jYyaNGZhuSQQxRUwv8DjR fXdOCQSDCzJFPoezCcfiaeReZcLaQMiEk08w9t8AqzrSCv7vkdTKSbFwvD6QVHIIN5iB eLfw== 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=XSzURH8N2A2kGYxD24CE4ROGHLVmn69afKJrq+3z7GeVm8Kd/KvvjSf7rqCTz7ph7/ U3G2RH5QvlZKQeXB6yy6D42N7SDFTiIUOTeMgIR0/gxzGtbbAbxIfK6H3J0Gxq6bvfI7 AKTFSKe5zJpvtGueOqb9iSOhgEyFDY6B7mkT+fmB9RU66MbclaQHRQedPX1yT1oUKvnN CfEy0Co7ZEwNkCRAOxq4S0PevLLaJLaUYMZVPm7MCcHwSeJj/rWdkRrLS7tgeAvDUrb8 UclRaL8BWb0pdxXNMPjsFa5Mu5XvR/KXAqMBJyo68ify4MUjC3d9hje4QC8iEKwUYxGW e4Og== X-Gm-Message-State: ALQs6tDqToj4KRA01QWgV1ySyE1Jv+DVdkRXip2N7wK4qjw1lYAqMY4k p/HanBoQ0C4m9UA4mERrfBE= X-Google-Smtp-Source: AIpwx498Wx/0oi4zO70Kv7ecV2STzAzQTfIJSbmbYiNr3IxfKMYxXNfSwgpHaUwHRSCfzh2fGwyxrA== X-Received: by 10.28.60.194 with SMTP id j185mr14780065wma.159.1524651054474; Wed, 25 Apr 2018 03:10:54 -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 l15-v6sm15980699wrb.85.2018.04.25.03.10.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Apr 2018 03:10:53 -0700 (PDT) From: Thierry Reding To: Christoph Hellwig , Joerg Roedel Subject: [PATCH v2 2/5] dma-mapping: Introduce dma_iommu_detach_device() API Date: Wed, 25 Apr 2018 12:10:48 +0200 Message-Id: <20180425101051.15349-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425101051.15349-1-thierry.reding@gmail.com> References: <20180425101051.15349-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, Russell King , 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)