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: 912829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="epF1F7B6"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40kxNL0L55z9ry1 for ; Mon, 14 May 2018 20:13:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752172AbeENKNF (ORCPT ); Mon, 14 May 2018 06:13:05 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:45199 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752060AbeENKNE (ORCPT ); Mon, 14 May 2018 06:13:04 -0400 Received: by mail-wr0-f196.google.com with SMTP id p5-v6so11662179wre.12 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=aavQPutszoqTL0LZN84M+PVDzpsB5cizkVxOqnoVR5/gJhK+9eQVShWbxO8qCUsEZd WURBvW6RxMkBy/KvopvOz3d9oqAnS0SAiF5m+6NLmLvJIn7KOpbZozMPOBJnz2KFHqV/ 5aHBt3nJi7XRp0n79GlpEpQ04xXVAkOQ2rWTooLSwPNI3mB9tJsgvV2fngKWLT2pGcwN Q49z5TT4i1+btq6vvShX9WrqSM0MsfV7qq2A5CC2LrnSsZO4yMaqtPvIsr12AQ56r6g4 uWO22s2TKmjFnOqC5OcBP+Lc+kW5+UVfoDQII0UCUJb2URtO882lphT+6Bk7F9X+61kx 3GbA== X-Gm-Message-State: ALKqPwcrf6K1naExxpbwaELqD4yvlSO1rrvyew7/QCysracS2CiskRvj C7qknK7AFHDOm4jMtG36c4s= 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 Cc: Dmitry Osipenko , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org 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 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org 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); }