From patchwork Sun Jun 23 17:37:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11011909 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 CE617112C for ; Sun, 23 Jun 2019 18:32:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C295F28A89 for ; Sun, 23 Jun 2019 18:32:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B717028A91; Sun, 23 Jun 2019 18:32:33 +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 6DF3428A89 for ; Sun, 23 Jun 2019 18:32:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72D2289958; Sun, 23 Jun 2019 18:32:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73B1F89824 for ; Sun, 23 Jun 2019 17:38:04 +0000 (UTC) Received: by mail-qt1-x841.google.com with SMTP id j19so12134531qtr.12 for ; Sun, 23 Jun 2019 10:38:04 -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:mime-version:content-transfer-encoding; bh=pU2ySpgeuPIDehUiqqbX8/63SN6HD4vkGtCiMTUdjZo=; b=ObjDXojGXASm0V4FlCTn3ZIV8pbsTj8HvkL+U1IEswQRNhnqEu5MOTmVLxcSHsrNN5 QohfZ2N6PamTPlYs/zi9GE5BS+TCdr9aNDBWTxtw3pj8PdYM6eaxT7bgUd2YYnoY0T/d Lr4EmizE/v67J8PpUPP8+6rB0fcXS5bN5fCBNoKw5wLcOJ4BAXN2mxXOPxYWqfi/KwaQ rn8cbiJRJc4+6PObu1WeZOx43EhSSgVjPglFJLqG69su2+8kqkAfFwZnmgAEbMBup2Vk 4u+ASYpZT4zU2mPSLFSIGTtktKdGejAp+DheVsVfiHcXOPcAc5ibH6S9C6fXy2Qd7seA wA1Q== X-Gm-Message-State: APjAAAUYG310YOTuhPhv51RoXkymnlcCL2NPXV1GqhyksVPanTNgCWgI YUzIywLCk1sjDUX0Sv9zZu8= X-Google-Smtp-Source: APXvYqyTZWTsrXwrIZibYOusfJL78o9yLKMY/cHHOd0dx04WanYQvMb/lt5vUtmyvIHDzHPgAtqQ5w== X-Received: by 2002:a0c:818f:: with SMTP id 15mr26657878qvd.162.1561311483688; Sun, 23 Jun 2019 10:38:03 -0700 (PDT) Received: from localhost.localdomain (ppp91-79-162-197.pppoe.mtu-net.ru. [91.79.162.197]) by smtp.gmail.com with ESMTPSA id c55sm5342498qtk.53.2019.06.23.10.38.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Jun 2019 10:38:03 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding Subject: [PATCH v1 3/3] drm/tegra: vic: Use common helpers to attach/detach from IOMMU domain Date: Sun, 23 Jun 2019 20:37:43 +0300 Message-Id: <20190623173743.24088-3-digetx@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190623173743.24088-1-digetx@gmail.com> References: <20190623173743.24088-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sun, 23 Jun 2019 18:32:00 +0000 X-Mailman-Original-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 :mime-version:content-transfer-encoding; bh=pU2ySpgeuPIDehUiqqbX8/63SN6HD4vkGtCiMTUdjZo=; b=kkueY8ivVKNH+tWI8+mgANJNDQk80xpHteXLuYEKu+lR1WYRUseu4LuAVB74j8fXqW Y5zo0vxu/p5xBjvtGK649WCz5M2jPoI6k94WYGaW3yAY0BMF52cvGkRZ0IkQGHuM9e7m 9Z6fA559SeuiSSw7YCjb0X9vuW6H1T5miQZI0qiL6zEWwu5PqvD3zxmuppBGc5qACIIi /8cwmppSsalGvtm2Seork2xRsAcdcWQ3562Y8ObQtIPomQ0dXP7dcb7RwXyT/1VgAZC6 jSgz1FJmJoR7AX+pmdBVZnDaA4OUwPp+YCc4TYAI3+nuL9cwOo8nTR/k+hcuXxtjJ2sE o1tQ== 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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We now have helpers for the domain's attachment, let's use them. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/vic.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index 982ce37ecde1..baa00da780d0 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -36,7 +36,7 @@ struct vic { void __iomem *regs; struct tegra_drm_client client; struct host1x_channel *channel; - struct iommu_domain *domain; + struct iommu_group *group; struct device *dev; struct clk *clk; struct reset_control *rst; @@ -183,21 +183,16 @@ static const struct falcon_ops vic_falcon_ops = { static int vic_init(struct host1x_client *client) { struct tegra_drm_client *drm = host1x_to_drm_client(client); - struct iommu_group *group = iommu_group_get(client->dev); struct drm_device *dev = dev_get_drvdata(client->parent); struct tegra_drm *tegra = dev->dev_private; struct vic *vic = to_vic(drm); int err; - if (group && tegra->domain) { - err = iommu_attach_group(tegra->domain, group); - if (err < 0) { - dev_err(vic->dev, "failed to attach to domain: %d\n", - err); - return err; - } - - vic->domain = tegra->domain; + vic->group = host1x_client_iommu_attach(client, false); + if (IS_ERR(vic->group)) { + err = PTR_ERR(vic->group); + dev_err(client->dev, "failed to attach to domain: %d\n", err); + return err; } vic->channel = host1x_channel_request(client->dev); @@ -223,8 +218,7 @@ static int vic_init(struct host1x_client *client) free_channel: host1x_channel_put(vic->channel); detach: - if (group && tegra->domain) - iommu_detach_group(tegra->domain, group); + host1x_client_iommu_detach(client, vic->group, false); return err; } @@ -232,7 +226,6 @@ static int vic_init(struct host1x_client *client) static int vic_exit(struct host1x_client *client) { struct tegra_drm_client *drm = host1x_to_drm_client(client); - struct iommu_group *group = iommu_group_get(client->dev); struct drm_device *dev = dev_get_drvdata(client->parent); struct tegra_drm *tegra = dev->dev_private; struct vic *vic = to_vic(drm); @@ -244,11 +237,7 @@ static int vic_exit(struct host1x_client *client) host1x_syncpt_free(client->syncpts[0]); host1x_channel_put(vic->channel); - - if (vic->domain) { - iommu_detach_group(vic->domain, group); - vic->domain = NULL; - } + host1x_client_iommu_detach(client, vic->group, false); return 0; }