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);