From patchwork Thu Aug 30 00:12:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10581271 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 054CC14BD for ; Thu, 30 Aug 2018 07:39:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E94D72B74E for ; Thu, 30 Aug 2018 07:39:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC0CE2B752; Thu, 30 Aug 2018 07:39:25 +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 937502B74E for ; Thu, 30 Aug 2018 07:39:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D211A6E6C5; Thu, 30 Aug 2018 07:39:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 568E46E667 for ; Thu, 30 Aug 2018 00:13:35 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id h4-v6so5218660edi.6 for ; Wed, 29 Aug 2018 17:13:35 -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; bh=Vqv1EpIyyMhKsXkr7xoWcWfNorNTKszF+ev3eD/OQ8U=; b=E2xucbqtETbRSLbpJGTJ79kA5Uo7QF21iFh55e/gJQNY3E9diS3oHgl3B3CRfWEzXO yG+310UM0wLnH1ZjuqyQjBxaBO6VAnee5gCAVwKBNB7WNUJ0vLRQOcUZzIjqE8H/ll44 yN2RUmZTyD3EITCEqlwfgcjK5aux6lKckCDFX3xA5LLp1gM9MjPJDDzmECfq9C60lEfX Wyg1Uil640hy1qXAj0CVP6bjl6kTAdG0fVNFOc0JJecL3eg4XmMFdPmxMsDKAhZHOyJP WlmzJn1V5Y6hqu3Iho77kJjKW70HXBL5dNs1tMc9Tvp9EGwC5KR3Y6S8+3spmJWMTukQ JszQ== X-Gm-Message-State: APzg51B8l5kQQ/VmOj+U8ulKYxamESL8smtyKxpMm5tNbZsR8nvLzXdm pcBchGpBTGWucgYRVX78jPQ= X-Google-Smtp-Source: ANB0VdbnQUDzKPImaroYZAftnU7oHhK1iU+rLqhiEWS+a5iw14gIrcRzMJheMEgOpoRGAX/2HNnjAg== X-Received: by 2002:a50:8046:: with SMTP id 64-v6mr9983142eda.227.1535588014105; Wed, 29 Aug 2018 17:13:34 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id e38-v6sm2521745eda.74.2018.08.29.17.13.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 17:13:33 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Mikko Perttunen Subject: [PATCH v3] gpu: host1x: Detach Host1x from IOMMU DMA domain on arm32 Date: Thu, 30 Aug 2018 03:12:47 +0300 Message-Id: <20180830001247.29257-1-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 X-Mailman-Approved-At: Thu, 30 Aug 2018 07:39:21 +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. Signed-off-by: Dmitry Osipenko Reviewed-by: Mikko Perttunen --- Changelog: v2: Correctly placed the detachment code, now Host1x is detached regardless of the firewall state. v3: Compiles now. drivers/gpu/host1x/dev.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index d88073e7d22d..de6bc4e7fa23 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" @@ -217,7 +221,14 @@ static int host1x_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to get reset: %d\n", err); return err; } - +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) + if (host->dev->archdata.mapping) { + struct dma_iommu_mapping *mapping = + to_dma_iommu_mapping(host->dev); + arm_iommu_detach_device(host->dev); + arm_iommu_release_mapping(mapping); + } +#endif if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) goto skip_iommu;