From patchwork Sun Aug 19 17:04:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10570465 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 DF430139B for ; Mon, 20 Aug 2018 14:54:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE8ED295D6 for ; Mon, 20 Aug 2018 14:54:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2E21295F0; Mon, 20 Aug 2018 14:54:50 +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 7AF8F295D6 for ; Mon, 20 Aug 2018 14:54:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED81E6E247; Mon, 20 Aug 2018 14:54:48 +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 3ECF66E002 for ; Sun, 19 Aug 2018 17:04:44 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id s24-v6so7119656edr.8 for ; Sun, 19 Aug 2018 10:04:44 -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=iUhJcryqQCok0NRUbBloIlti/+MqvGEk3nAUZe3TBDc=; b=tPebs9VYgewDHjfvDZbP9USW9eE1Q+U3qXFS1nLGXQxRhx3cwFdmmf9byK3fYixLuW vsOicjsmqDSrX4L1wQprNIGJa23B+LQZ326NnjoY78QGWbIUukIJTEvKwAnp0POt4lOq 3Ztm/SvbUbKGzeQovSgncjuk6ZZt4tyj9kN623hc0oFfE7sCiRC1hzKG7mVjHX4s45jF 2thVt9i2Mg+8YEmoWSSxOVgrxJ6KhhggWWEQXDbQgab5i7/ZD80we71uGYNoLZOszaGy s+0tEMp9QbXjLAm6jSIX70PKN5hJns5nLhqnd9vV+28S7i5UBjxEu4HFFugEwkNemSMM ps+g== X-Gm-Message-State: AOUpUlGtNH7R+ys3jOoa0Ei+7aeGKQ0/91VLWHZLLX6v2yDQO1ovFkxx Y5f1YqglXYsxQGU8Y5HRfCQ= X-Google-Smtp-Source: AA+uWPz58xtl6Xh0EzC0ydWIRfBVoJXw31RWfVSWsmkMckUNTHcEWezBz//T4RmSUkuqOkEXnqajEw== X-Received: by 2002:a50:b045:: with SMTP id i63-v6mr53103056edd.18.1534698282907; Sun, 19 Aug 2018 10:04:42 -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 q17-v6sm3956603eds.78.2018.08.19.10.04.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Aug 2018 10:04:42 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Mikko Perttunen Subject: [PATCH v2] gpu: host1x: Detach Host1x from IOMMU DMA domain on arm32 Date: Sun, 19 Aug 2018 20:04:00 +0300 Message-Id: <20180819170400.8081-1-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 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 --- Changelog: v2: Correctly placed the detachment code, now Host1x is detached regardless of the firewall state. 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..c8a56c11a63a 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 (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 if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) goto skip_iommu;