From patchwork Thu May 3 23:47: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: 10382451 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 6E76E60318 for ; Sat, 5 May 2018 20:19:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F93D28AB5 for ; Sat, 5 May 2018 20:19:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5433928AFB; Sat, 5 May 2018 20:19:26 +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 D855F28AB5 for ; Sat, 5 May 2018 20:19:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E88D6E36B; Sat, 5 May 2018 20:10:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x241.google.com (mail-lf0-x241.google.com [IPv6:2a00:1450:4010:c07::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5420F6E2C1 for ; Thu, 3 May 2018 23:52:11 +0000 (UTC) Received: by mail-lf0-x241.google.com with SMTP id u21-v6so28444802lfu.9 for ; Thu, 03 May 2018 16:52:11 -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=/5okvNaWJV554GIwmlKK5eoC6xTUxRy0MdwYvHqN6tU=; b=hKIzlpk01EX5poyD3QzXoLWyKiNbyxFHjo/IvMvfzwo6rJW7k0dIVKicyAQmMn+dgq 7zDchBxKMZrZHEYXGG4dEyKxCPoVkCvYOy4lqx9XgIeASeF9SafTgGytqtaHsISnek9K caTD63DqC7tUy0sOTDtgkh33ow7DXy/QFgljLQEoSAGZxPkPXM41zVRLQVFRc/gKyDfp EQKGNMol1lMKUyG933m9D/pMtU4kpCZ7dP780xw7bSFUEx2mYKYK78c+L+lV+whR3Bx/ 9O8MioLMxbDST4gJP3MO1U3/Ua29fY7weTxqFKWh1NJvly8m7eVTC9gox8W0BY1mCjXW 66qA== 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=/5okvNaWJV554GIwmlKK5eoC6xTUxRy0MdwYvHqN6tU=; b=kiE1RkquXHAaieO5U2aSQ4dnuzeDux4ZYaHlv+5z0Y2wQRMcWWuWk5yZaYnTX/XEB9 ZakruXjqeFipC35/sAsOH6NlNiuqXFN71SJ9nAtetjGEn3Dmsa7+eO7KAmjBKaHQEEJB mYVX1FejLZ2YbH3irz7ZOKpde247QDc0pG6Bw1TEqXQdlFr2Un1K9F9tzjWYblLESs96 m4JZYI//BNTDCtr2MNZGNZgQM2JIKvyds87lPUtnzTOmoHGOTSvAx5sS2CjM8LoRiu9Y LRezb/EQ8h5V+89uE1ejb+q1XgMryXv+5+ud9aRDZNgT31y6pxRJXoZoXKlYmOjbjkE+ SnfQ== X-Gm-Message-State: ALQs6tCKPvUKHnYv33kFxS7YwF4BlJ2b4r/E1N28RL+aFakd/mx5uS5e yXutHckcIoNio8AyDx4kNjU= X-Google-Smtp-Source: AB8JxZpz+I76h1HXGTXtO+EgyJpLxNFg1PxzrNkUR17fTdn2GttdD1Kf7nKwh4KA8995Hn1C+ujxBQ== X-Received: by 2002:a2e:59d4:: with SMTP id g81-v6mr18259863ljf.4.1525391529846; Thu, 03 May 2018 16:52:09 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-91-130.pppoe.spdop.ru. [109.252.91.130]) by smtp.gmail.com with ESMTPSA id m6-v6sm3077153lfb.61.2018.05.03.16.52.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 16:52:09 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding Subject: [PATCH v1 3/5] drm/tegra: gr3d: Add IOMMU support Date: Fri, 4 May 2018 02:47:21 +0300 Message-Id: <20180503234723.4368-4-digetx@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180503234723.4368-1-digetx@gmail.com> References: <20180503234723.4368-1-digetx@gmail.com> X-Mailman-Approved-At: Sat, 05 May 2018 20:07:53 +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, linux-kernel@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 Attach GR3D to the displays IOMMU group in order to provide GR3D access to BO's IOVA. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/gr3d.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index 28c4ef63065b..ce5120683091 100644 --- a/drivers/gpu/drm/tegra/gr3d.c +++ b/drivers/gpu/drm/tegra/gr3d.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include "gr3d.h" struct gr3d { + struct iommu_group *group; struct tegra_drm_client client; struct host1x_channel *channel; struct clk *clk_secondary; @@ -40,7 +42,9 @@ static int gr3d_init(struct host1x_client *client) struct tegra_drm_client *drm = host1x_to_drm_client(client); struct drm_device *dev = dev_get_drvdata(client->parent); unsigned long flags = HOST1X_SYNCPT_HAS_BASE; + struct tegra_drm *tegra = dev->dev_private; struct gr3d *gr3d = to_gr3d(drm); + int err; gr3d->channel = host1x_channel_request(client->dev); if (!gr3d->channel) @@ -52,6 +56,23 @@ static int gr3d_init(struct host1x_client *client) return -ENOMEM; } + if (tegra->domain) { + gr3d->group = iommu_group_get(client->dev); + + if (gr3d->group) { + err = iommu_attach_group(tegra->domain, gr3d->group); + if (err < 0) { + dev_err(client->dev, + "failed to attach to domain: %d\n", + err); + host1x_syncpt_free(client->syncpts[0]); + host1x_channel_put(gr3d->channel); + iommu_group_put(gr3d->group); + return err; + } + } + } + return tegra_drm_register_client(dev->dev_private, drm); } @@ -59,6 +80,7 @@ static int gr3d_exit(struct host1x_client *client) { struct tegra_drm_client *drm = host1x_to_drm_client(client); struct drm_device *dev = dev_get_drvdata(client->parent); + struct tegra_drm *tegra = dev->dev_private; struct gr3d *gr3d = to_gr3d(drm); int err; @@ -69,6 +91,11 @@ static int gr3d_exit(struct host1x_client *client) host1x_syncpt_free(client->syncpts[0]); host1x_channel_put(gr3d->channel); + if (gr3d->group) { + iommu_detach_group(tegra->domain, gr3d->group); + iommu_group_put(gr3d->group); + } + return 0; }