From patchwork Mon May 14 10:13:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10397833 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 888B0601E7 for ; Mon, 14 May 2018 10:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 741602015F for ; Mon, 14 May 2018 10:13:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68E9226222; Mon, 14 May 2018 10:13:08 +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 D24A82015F for ; Mon, 14 May 2018 10:13:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E7ED8958E; Mon, 14 May 2018 10:13:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD8BC8958E for ; Mon, 14 May 2018 10:13:04 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id h5-v6so11679403wrm.4 for ; Mon, 14 May 2018 03:13:04 -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; bh=T84Q7oilBTrj1zLwmDDgXtHMzvILxtZ1gaNKzfxYkPM=; b=epF1F7B6KaUDR2A/Vjqfi/mxqLKwR9D5EDclGszQICXehgppSdQivAs1iRE1BpvIPO UxaXYnfh9P3MnFinW35KhUzDXJRF11UMbpJWV8pMvNUBVBtuCgCYjZ5EN7N9rp8xf74S IgdNOanbARCrfVaMdSDVjNMtb4JoxDj9F9OFa1XOlPwbFrgVgkPk5txNxJCV75oOoZPM BL2dJtNdmqmiLMbdv3E/tfJ15jbyk4OKnM2eHdbKEB6+tB53K+0AgNIQCxKVkXOCPxPk LzFkMOF+0eBAMriwuff0mS8X63URjQ206NgmaGAVB7yn4H/s5au6cMGwuhyAOh1WyLvZ 5CBQ== 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; bh=T84Q7oilBTrj1zLwmDDgXtHMzvILxtZ1gaNKzfxYkPM=; b=PVDLOBox9wooEJb8pA/ebN16i2YRO59/gkrAJrJH8+DMF9aZrm5ytc7ZnUMqFXB7i7 /tK9o7togKH+JavnN2rjGQod6UPAFa+bgpjD9mD6Ti6wdwYD8jDuZKg6HgXTBfgwpwDN H8QYdx1Z08sLS6kmKyP3wEpkVuGaL28YNm7kdz2ccvRXiX84sVR5oCFMsgTBkm6m30MB RphLTvQZvrFGerstiwSuzXlyAOONh4SkUYvh2w+lFnaH9gOHH0dQB+VXjF6BrmcYztTp c9iFSwcCs88y6L8gUCtDQH0qFGoQLeTX0GRZnsDish7RcwtdJCGkXpkLqwiZPuVV4pga sY2Q== X-Gm-Message-State: ALKqPweuoMV+TOvO36WWPsR2FmBWwjasREbKrLfNyQ2R2lHOJlxm1rQy TOcVaS4f1+wvSxveIZal/3yF5Q== X-Google-Smtp-Source: AB8JxZrjkulNmIcQviehMWr683jR2fEQ+IqEm2fRMK4f4jLykTgYo7rGTsq2rlBYXUZuvMTsaSQ/rg== X-Received: by 2002:adf:9a54:: with SMTP id z78-v6mr6249652wrb.235.1526292783274; Mon, 14 May 2018 03:13:03 -0700 (PDT) Received: from localhost (p200300E41F19FC00D958180F3872A5C5.dip0.t-ipconnect.de. [2003:e4:1f19:fc00:d958:180f:3872:a5c5]) by smtp.gmail.com with ESMTPSA id u35-v6sm13434211wrc.29.2018.05.14.03.13.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 03:13:02 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH] gpu: host1x: Acquire a reference to the IOVA cache Date: Mon, 14 May 2018 12:13:01 +0200 Message-Id: <20180514101301.32188-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.17.0 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, Dmitry Osipenko , 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 From: Thierry Reding The IOVA API uses a memory cache to allocate IOVA nodes from. To make sure that this cache is available, obtain a reference to it and release the reference when the cache is no longer needed. On 64-bit ARM this is hidden by the fact that the DMA mapping API gets that reference and never releases it. On 32-bit ARM, this is papered over by the Tegra DRM driver (the sole user of the host1x API requiring the cache) acquiring a reference to the IOVA cache for its own purposes. However, there may be additional users of this API in the future, so fix this upfront to avoid surprises. Fixes: 404bfb78daf3 ("gpu: host1x: Add IOMMU support") Signed-off-by: Thierry Reding Reviewed-by: Dmitry Osipenko --- drivers/gpu/host1x/dev.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 03db71173f5d..f1d5f76e9c33 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -223,10 +223,14 @@ static int host1x_probe(struct platform_device *pdev) struct iommu_domain_geometry *geometry; unsigned long order; + err = iova_cache_get(); + if (err < 0) + goto put_group; + host->domain = iommu_domain_alloc(&platform_bus_type); if (!host->domain) { err = -ENOMEM; - goto put_group; + goto put_cache; } err = iommu_attach_group(host->domain, host->group); @@ -234,6 +238,7 @@ static int host1x_probe(struct platform_device *pdev) if (err == -ENODEV) { iommu_domain_free(host->domain); host->domain = NULL; + iova_cache_put(); iommu_group_put(host->group); host->group = NULL; goto skip_iommu; @@ -308,6 +313,9 @@ static int host1x_probe(struct platform_device *pdev) fail_free_domain: if (host->domain) iommu_domain_free(host->domain); +put_cache: + if (host->group) + iova_cache_put(); put_group: iommu_group_put(host->group); @@ -328,6 +336,7 @@ static int host1x_remove(struct platform_device *pdev) put_iova_domain(&host->iova); iommu_detach_group(host->domain, host->group); iommu_domain_free(host->domain); + iova_cache_put(); iommu_group_put(host->group); }