From patchwork Sun Aug 19 14:24:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10570459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BFCB5A4 for ; Mon, 20 Aug 2018 14:54:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D4DD295C5 for ; Mon, 20 Aug 2018 14:54:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11D53295D6; Mon, 20 Aug 2018 14:54:41 +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.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 7C022295C5 for ; Mon, 20 Aug 2018 14:54:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D5DFA89DEC; Mon, 20 Aug 2018 14:54:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3C7DA89D61 for ; Sun, 19 Aug 2018 14:25:09 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id l15-v6so9648707lji.6 for ; Sun, 19 Aug 2018 07:25:09 -0700 (PDT) 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=dSWFZZnAIjJ7wonM5pHJw4jEEkslEJxFsKPb2frf9Gc=; b=WRJ2DpY7I8vk3Hf0F3orp46HCiv6y3KaL0ZD/gM80Jseb6Oh2M//sQInNNyTvpAjrO Yr5DM3nLS5yU0OKhSL7uuKBkwI/FbPmFPTwhCzZau2Y6ktbqgwQeEfcb9jY/Kz9Unudr B3xZKqW/pBXGbuOWI9m4kZK1e47udlNZTe8rEgR8XmSniZqyiQBMgPaGz52wKearU0J4 StK/BpjeTUSIvpVOZ2DH7e3sW6YbMG8jHUkweFoL1BFMyT23+BTsxQH3a09Xs6QAwOHS 5vXWZ8m55c/As8SfSSZPNvQ+9vlA4K8FcjwlIM//FyUVkanOTjUXZzlVvc35LuaGxJSS o9PQ== X-Gm-Message-State: AOUpUlGMpb3N8yxKGomjCq8GBSG7O0tvHxxJm0DSAoIobLH3qREOu9+8 DObis6pCJ/cmo9mAT8GcCUU= X-Google-Smtp-Source: AA+uWPyTLhBZzOOUK65+JxDrk42/NypYwu+xkRiNRiMrOZQ4CbV+2vd/PToN3JB9cmH9qNR5ltwUGw== X-Received: by 2002:a2e:21d5:: with SMTP id h82-v6mr12374965lji.46.1534688707688; Sun, 19 Aug 2018 07:25:07 -0700 (PDT) Received: from localhost.localdomain ([109.252.90.13]) by smtp.gmail.com with ESMTPSA id p88-v6sm1185618ljp.90.2018.08.19.07.25.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Aug 2018 07:25:07 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Mikko Perttunen Subject: [PATCH v1] gpu: host1x: Detach Host1x from IOMMU DMA domain on arm32 Date: Sun, 19 Aug 2018 17:24:21 +0300 Message-Id: <20180819142421.22567-2-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180819142421.22567-1-digetx@gmail.com> References: <20180819142421.22567-1-digetx@gmail.com> X-Mailman-Approved-At: Mon, 20 Aug 2018 14:54:32 +0000 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: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Host1x is getting attached to an implicit IOMMU DMA domain if CONFIG_ARM_DMA_USE_IOMMU=y. Since Host1x driver manages IOMMU by itself, Host1x device must be detached from the implicit domain using arch-specific IOMMU-API. Note that this works only for arm32 and not for arm64, which will remain broken if CONFIG_IOMMU_DMA is enabled. Signed-off-by: Dmitry Osipenko --- drivers/gpu/host1x/dev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index d88073e7d22d..47624f20718d 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -29,6 +29,10 @@ #include #undef CREATE_TRACE_POINTS +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) +#include +#endif + #include "bus.h" #include "channel.h" #include "debug.h" @@ -236,6 +240,14 @@ static int host1x_probe(struct platform_device *pdev) goto put_cache; } +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) + if (pdev->dev->archdata.mapping) { + struct dma_iommu_mapping *mapping = + to_dma_iommu_mapping(pdev->dev); + arm_iommu_detach_device(pdev->dev); + arm_iommu_release_mapping(mapping); + } +#endif err = iommu_attach_group(host->domain, host->group); if (err) { if (err == -ENODEV) {