From patchwork Mon Oct 14 12:50:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11188701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DB061575 for ; Mon, 14 Oct 2019 12:51:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 85D6721835 for ; Mon, 14 Oct 2019 12:51:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85D6721835 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77A896E2C0; Mon, 14 Oct 2019 12:51:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id 383656E2C0 for ; Mon, 14 Oct 2019 12:51:12 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id p7so17157896wmp.4 for ; Mon, 14 Oct 2019 05:51:12 -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=B5fuJB7QmtV9h7aBVewhTK71Ks0pgNS4kdo609/xFbo=; b=LLREryzL7B+3EGPYryJAuGJsjaOKnIOKd7PGEeOHWpielP9nrp526ZW927GsmRFGfl turZlTP5kxZSM1XlboGA3BcmXQisqAeiKw/HN/38qti2QriSs86Q88l7CG3Dmh7TpjRZ eRMWa5n1rJN1dLaF9BngI2xvVTFtcUC2qh6uBbbf9iSwdCLWVWERodBc+QS+rA+z6MeH WYymjXJXG90Jwlcbur8j95DGM3EKRO7ODEwk+OJHNtjfuIKZwGMFCzJNVnIljvVdNgaT T0jE84jDsn7sF/I8g9Odkq8hl+OXRomaru8SOcGgGGtpyZNuFbBSy5ulFhowRbCkB2Ti kpyg== X-Gm-Message-State: APjAAAXsQacAOCWVOYaBy+edKkE1Pd6N97VJ5250n60mipQcIxGhYeu+ Xlc1Lkko5LNhM466hSGURWs= X-Google-Smtp-Source: APXvYqxCDvHffZXht1XHuIbS0QlRApgWVwhVUWF+hNratzEVbOVK6iZZnoRmz0hhM8KUZR4o03xguA== X-Received: by 2002:a1c:1dc9:: with SMTP id d192mr15685966wmd.51.1571057470705; Mon, 14 Oct 2019 05:51:10 -0700 (PDT) Received: from localhost (p2E5BE2CE.dip0.t-ipconnect.de. [46.91.226.206]) by smtp.gmail.com with ESMTPSA id a192sm16440048wma.1.2019.10.14.05.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 05:51:09 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH 09/14] drm/tegra: vic: Use common IOMMU attach/detach code Date: Mon, 14 Oct 2019 14:50:44 +0200 Message-Id: <20191014125049.425101-10-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191014125049.425101-1-thierry.reding@gmail.com> References: <20191014125049.425101-1-thierry.reding@gmail.com> MIME-Version: 1.0 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=B5fuJB7QmtV9h7aBVewhTK71Ks0pgNS4kdo609/xFbo=; b=uD7vU7d6OrpaUKwtuchmc0iH50x9zTlPXy7BcOJu4sWXI/SQQ2woE6sEm/DEqC7p1n t5RF6Jo+hCWPcJVl5l8AhEWEcVivkgdqVVEgZl1TPZtN2Kx/S4HwH+tkhkBRiTDZxPyo VYa2q0F7wCEf3x4dgzkS2OLKnCm22IAZEqDJEZNO+3Yp35cLQQwGwJGDk03BmvH3MKXi tuXsqzpUDTXvjtqu7+i3CkiuEV084bh/2vQxvncSjNbE0v+Pc1mwcPAyhhxY+zWcSod1 syAETGIUdShjefqAwdh5yi085uQ/gOMEIyVZiu+dn1vJIkF8VN+cLxY1fdsa+4Fwokub 5FgA== 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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding Reuse common code to attach to or detach from an IOMMU domain. Signed-off-by: Thierry Reding --- 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 d60e479cde92..e4b17c7ce708 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -34,7 +34,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(vic->dev, "failed to attach to domain: %d\n", err); + return err; } vic->channel = host1x_channel_request(client); @@ -229,8 +224,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); return err; } @@ -238,7 +232,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); @@ -253,11 +246,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); return 0; }