From patchwork Sun Jun 23 17:37:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11011903 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 B90F6112C for ; Sun, 23 Jun 2019 18:32:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABA5528A89 for ; Sun, 23 Jun 2019 18:32:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A046B28A91; Sun, 23 Jun 2019 18:32:28 +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 5A62328A89 for ; Sun, 23 Jun 2019 18:32:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DC62F89932; Sun, 23 Jun 2019 18:32:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9687E89824 for ; Sun, 23 Jun 2019 17:38:01 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id s15so12120976qtk.9 for ; Sun, 23 Jun 2019 10:38:01 -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:mime-version :content-transfer-encoding; bh=AJTlfv60mIEZXwta292fwI2V+CViZ4EgWCofxKK0NGs=; b=EUw1hzzfX12J47byoBV3yznSq14sBRMJj9gXouRFf2FyU+uHRrgFMW1AMYwoegHQq7 h7QQ5Enae/Aj8GHThFNbpuyXLvDXOroBiPubRVwZRUHJyNL8KOni4s73w9nqNUkcb4Pz 09JOOMusTsUJZzmYyjcFCKyfp273DOox4z36LmEac83tE2t2NKt/6vs2RmPQeIaldsE+ kUq1XEeEzx299utr/4IG7rRHJAMtKGeadX7kF5izHPsGlEt6qtzxHsuYRSvuMA/O0nOr JZ47lhumBnP0ZAg/WDBTCcisxRYKdYoU0Zq1Bi7yycIy9VtfGnB7KEsFjlz4B7eoqo3s 0h1A== X-Gm-Message-State: APjAAAUn3ytnj7tgUI/WtzSJRg85HekaS3xypAlhqxisrlLmQseKVvJI smdEzf5eOUvNDdFpJhdtQbY= X-Google-Smtp-Source: APXvYqwH+yYOfjzCW3mL/GB1bTYbCEj4p34EhH/Z+ZuKtywHkF9tf6qNfNiRq4tv8gn+Hit+u1OaYg== X-Received: by 2002:a0c:8a26:: with SMTP id 35mr53756993qvt.158.1561311480668; Sun, 23 Jun 2019 10:38:00 -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.37.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Jun 2019 10:38:00 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding Subject: [PATCH v1 1/3] gpu: host1x: Remove implicit IOMMU backing on client's registration Date: Sun, 23 Jun 2019 20:37:41 +0300 Message-Id: <20190623173743.24088-1-digetx@gmail.com> X-Mailer: git-send-email 2.22.0 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:mime-version :content-transfer-encoding; bh=AJTlfv60mIEZXwta292fwI2V+CViZ4EgWCofxKK0NGs=; b=iHScT30IUVlaqkLW9FzbhYmfsFdewA8sA9/jGO9fvv1CFkFaapyfjhYtPMDxpx7WzW peqA+Lbd+lGEDDlqc6bhpxo2vtxdqvAwXeMOqsDC2yrpiAkRZjv2rcfPUkk2fjeKgEty szZyXIM8vQcvDG6q7WfuEpa176sKGTPoGYenic5rMIk3Tgbw5tirSkXh0MgHcgK2gnfR yN6aB0oK2XUHb+7RdXbtjOaUTw1695sjBrVwyUu1wpwri23zr5KCh2FEwx+UmHNTrjxI u+lknBsrwiTYVIenkHVmcRK4yo1NQt5uk/PGhOZs00HokqYuB889l04tD33hRIM6SMh6 LuTA== 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 On ARM32 we don't want any of the clients device to be backed by the implicit domain, simply because we can't afford such a waste on older Tegra SoCs that have very few domains available in total. The recent IOMMU support addition for the Video Decoder hardware uncovered the problem that an unfortunate drivers probe order results in the DRM driver probe failure if CONFIG_ARM_DMA_USE_IOMMU=y due to a shortage of IOMMU domains caused by the implicit backing. The host1x_client_register() is a common function that is invoked by all of the relevant DRM drivers during theirs probe and hence it is convenient to remove the implicit backing there, resolving the problem. Signed-off-by: Dmitry Osipenko --- drivers/gpu/host1x/bus.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 742aa9ff21b8..559df3974afb 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -14,6 +14,10 @@ #include "bus.h" #include "dev.h" +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) +#include +#endif + static DEFINE_MUTEX(clients_lock); static LIST_HEAD(clients); @@ -710,6 +714,21 @@ int host1x_client_register(struct host1x_client *client) struct host1x *host1x; int err; +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) + /* + * The client's driver could be backed by implicit IOMMU mapping + * and we don't want to have that because all of current Tegra + * drivers are managing IOMMU by themselves. This is a convenient + * place for unmapping of the implicit mapping because this function + * is called by all host1x drivers during theirs probe. + */ + if (client->dev->archdata.mapping) { + struct dma_iommu_mapping *mapping = + to_dma_iommu_mapping(client->dev); + arm_iommu_detach_device(client->dev); + arm_iommu_release_mapping(mapping); + } +#endif mutex_lock(&devices_lock); list_for_each_entry(host1x, &devices, list) { From patchwork Sun Jun 23 17:37:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11011901 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 DC242112C for ; Sun, 23 Jun 2019 18:32:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFC3B28A89 for ; Sun, 23 Jun 2019 18:32:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3E3128A91; Sun, 23 Jun 2019 18:32:23 +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 679E428A89 for ; Sun, 23 Jun 2019 18:32:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D5C98993B; Sun, 23 Jun 2019 18:32:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0739589824 for ; Sun, 23 Jun 2019 17:38:03 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id x18so8074555qkn.13 for ; Sun, 23 Jun 2019 10:38:02 -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=Taorv013lx4BF1e9mQ5frJv1zsMiL53dKrJ0Mfj3qx4=; b=p+BrCcgepgBZetK7XdMKyp/QMzIt+1huDcDwy8tmak+RpJVZo5B6lcn/7h+abFtJf9 MWslEh8RoVVnsxw9dkQJx/T6cyabqxavlF1lS90a4ZJa7M30Dt4EX4pBanVDOn5n7AV3 YNCEsJ0A1x9ja2PnDcnkhHIliNwaaJp4djT0TX8BMnaOaREDin/IhKk+YJeeUTXFGiKf Edf4aw2AjeQHHx+zi5V46F5jWMOJ2R5cGsE54o8jtaMQ69cOhvRZ1gf9VcShDHodFV3K zUHzegiwQvOM131w0scU2d08B+KfeZFJS/1J1SH86CkS0uQq1yUpBTBwHVEi9h5Va+Ji VVtw== X-Gm-Message-State: APjAAAVhz5QMKH+qomCkjIa1EHtgSHVBA/ezS3klQSnQX5zqO54U7K+f T+VP1hVdUjuMb+W0My9X3WM= X-Google-Smtp-Source: APXvYqyxoVySJ+bjh9dacS0w0vip5Vr0BkFtivb56+vWtspFfCp3xLiTPe3jL8pbW162KCckP1ophg== X-Received: by 2002:a37:8145:: with SMTP id c66mr13276625qkd.459.1561311482169; Sun, 23 Jun 2019 10:38:02 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Jun 2019 10:38:01 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding Subject: [PATCH v1 2/3] drm/tegra: Fix 2d and 3d clients detaching from IOMMU domain Date: Sun, 23 Jun 2019 20:37:42 +0300 Message-Id: <20190623173743.24088-2-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=Taorv013lx4BF1e9mQ5frJv1zsMiL53dKrJ0Mfj3qx4=; b=i0qExktDOvmtUHmy+8LfQWIfsj+7c/KfuWryEMjvL850aOttg1UgB4u3YdMMiw6tUQ oUr4Uzh0mo3H0NXiw6CXiEGEqW8wY/v2soaQTvK4xSpUQ8J4AEpCfTotUDFGu6C7+2Qz FZRRfFHY50qwNhnwXZzX7GfNq4mSzAbYFAU+If4/4d2zgZwYzAyD5KTykp9ImlnylfYC Rs5ShfPEJstSCDPIknItVC/6+brEZJvUNqc7Jd1tKMk3N+zyfXTctTbBp7UezxgMJqX+ cOSs0iEkUS/vmtde81cuHxxvPItAWeZIg0DsZWbWnOrczrXMVyYyDxdrt17f7umQn5tC /UVQ== 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 This should should fire up on the DRM's driver module re-loader because there won't be enough available domains on older Tegra SoCs. Cc: stable Fixes: 0c407de5ed1a ("drm/tegra: Refactor IOMMU attach/detach") Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/dc.c | 4 ++-- drivers/gpu/drm/tegra/drm.c | 9 ++++++--- drivers/gpu/drm/tegra/drm.h | 3 ++- drivers/gpu/drm/tegra/gr2d.c | 4 ++-- drivers/gpu/drm/tegra/gr3d.c | 4 ++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index fa505baaaabc..c1b885444d90 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -2388,7 +2388,7 @@ static int tegra_dc_init(struct host1x_client *client) if (!IS_ERR(primary)) drm_plane_cleanup(primary); - host1x_client_iommu_detach(client, dc->group); + host1x_client_iommu_detach(client, dc->group, true); host1x_syncpt_free(dc->syncpt); return err; @@ -2412,7 +2412,7 @@ static int tegra_dc_exit(struct host1x_client *client) return err; } - host1x_client_iommu_detach(client, dc->group); + host1x_client_iommu_detach(client, dc->group, true); host1x_syncpt_free(dc->syncpt); return 0; diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index d2080bd7d392..f94441457c64 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1120,15 +1120,18 @@ struct iommu_group *host1x_client_iommu_attach(struct host1x_client *client, } void host1x_client_iommu_detach(struct host1x_client *client, - struct iommu_group *group) + struct iommu_group *group, + bool shared) { struct drm_device *drm = dev_get_drvdata(client->parent); struct tegra_drm *tegra = drm->dev_private; if (group) { - if (group == tegra->group) { + if (!shared || group == tegra->group) { iommu_detach_group(tegra->domain, group); - tegra->group = NULL; + + if (group == tegra->group) + tegra->group = NULL; } iommu_group_put(group); diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index 488f36f00bd8..9f1a3d6f3406 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -107,7 +107,8 @@ int tegra_drm_unregister_client(struct tegra_drm *tegra, struct iommu_group *host1x_client_iommu_attach(struct host1x_client *client, bool shared); void host1x_client_iommu_detach(struct host1x_client *client, - struct iommu_group *group); + struct iommu_group *group, + bool shared); int tegra_drm_init(struct tegra_drm *tegra, struct drm_device *drm); int tegra_drm_exit(struct tegra_drm *tegra); diff --git a/drivers/gpu/drm/tegra/gr2d.c b/drivers/gpu/drm/tegra/gr2d.c index 673059fd2fcb..c486e0a05c9d 100644 --- a/drivers/gpu/drm/tegra/gr2d.c +++ b/drivers/gpu/drm/tegra/gr2d.c @@ -69,7 +69,7 @@ static int gr2d_init(struct host1x_client *client) return 0; detach: - host1x_client_iommu_detach(client, gr2d->group); + host1x_client_iommu_detach(client, gr2d->group, false); free: host1x_syncpt_free(client->syncpts[0]); put: @@ -89,7 +89,7 @@ static int gr2d_exit(struct host1x_client *client) if (err < 0) return err; - host1x_client_iommu_detach(client, gr2d->group); + host1x_client_iommu_detach(client, gr2d->group, false); host1x_syncpt_free(client->syncpts[0]); host1x_channel_put(gr2d->channel); diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index 4778ae999668..591bafe455e0 100644 --- a/drivers/gpu/drm/tegra/gr3d.c +++ b/drivers/gpu/drm/tegra/gr3d.c @@ -79,7 +79,7 @@ static int gr3d_init(struct host1x_client *client) return 0; detach: - host1x_client_iommu_detach(client, gr3d->group); + host1x_client_iommu_detach(client, gr3d->group, false); free: host1x_syncpt_free(client->syncpts[0]); put: @@ -98,7 +98,7 @@ static int gr3d_exit(struct host1x_client *client) if (err < 0) return err; - host1x_client_iommu_detach(client, gr3d->group); + host1x_client_iommu_detach(client, gr3d->group, false); host1x_syncpt_free(client->syncpts[0]); host1x_channel_put(gr3d->channel); 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; }