From patchwork Fri Feb 1 13:28:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10792767 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 E46C8922 for ; Fri, 1 Feb 2019 13:29:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D44BE2FAD2 for ; Fri, 1 Feb 2019 13:29:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7D7531409; Fri, 1 Feb 2019 13:29:01 +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 8262F31084 for ; Fri, 1 Feb 2019 13:29:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 264FE6EE49; Fri, 1 Feb 2019 13:28:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 12E2F6EE47 for ; Fri, 1 Feb 2019 13:28:52 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id b4so179771wrq.10 for ; Fri, 01 Feb 2019 05:28:51 -0800 (PST) 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=H6oxxYeF69Pq45FSTtSVXJ7NZYF5O9gE4IxYJVdAZDA=; b=kor6/h432PUEVlglJJUteimzsr9TyVc0E4tBf4TFnSjtzatNoBs8/nkLy3I8vYXhaT n7ls25M79hI4rC0v14PVv9eJzbXRRVvUVDPsedRIvaneG5hGaDhyKSQ68lFaIAObrzyL RzGXUESKksRD4Z4uP+YmU2/t6cwTtffbWlPnxRv0hafaoPY7T2DFBrC/zxrhqV8Bysm2 7ZD3e9Ypa8OcgXSziM5g+WFrwGm6wP0rko2u8rhrkwHWTDoJAfDQKluryTlL+PRXMHyL X3vlNQde/0pec3McHAKnq9funQYI5gzHY2q/aNXTzsCM2dMeRzEvNVQQ3mA6zWohBlmQ ChXA== X-Gm-Message-State: AJcUukdxFx9vsHIfs8kCdpOMz70lvb/lVJO3vlnfA7Jf2/c8IIvkhEUY oiXxfs9Fj8nkrhtLGysWxwhhGlxzaRk= X-Google-Smtp-Source: ALg8bN6gGfZkja8X3orQ4WQB+1XtEYJuV+sv3tz/pCTdzrf9YaMs9U7wNoNJ9yH5Z0PFkgEtWLmxxA== X-Received: by 2002:a5d:6988:: with SMTP id g8mr37073193wru.33.1549027728934; Fri, 01 Feb 2019 05:28:48 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id b13sm5597369wrn.28.2019.02.01.05.28.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Feb 2019 05:28:48 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH v3 06/16] gpu: host1x: Restrict IOVA space to DMA mask Date: Fri, 1 Feb 2019 14:28:27 +0100 Message-Id: <20190201132837.12327-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190201132837.12327-1-thierry.reding@gmail.com> References: <20190201132837.12327-1-thierry.reding@gmail.com> MIME-Version: 1.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, Mikko Perttunen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding On Tegra186 and later, the ARM SMMU provides an input address space that is 48 bits wide. However, memory clients can only address up to 40 bits. If the geometry is used as-is, allocations of IOVA space can end up in a region that is not addressable by the memory clients. To fix this, restrict the IOVA space to the DMA mask of the host1x device. Signed-off-by: Thierry Reding Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko --- drivers/gpu/host1x/dev.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 4c044ee54fe6..544b67f2b3ff 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -283,6 +283,8 @@ static int host1x_probe(struct platform_device *pdev) host->group = iommu_group_get(&pdev->dev); if (host->group) { struct iommu_domain_geometry *geometry; + u64 mask = dma_get_mask(host->dev); + dma_addr_t start, end; unsigned long order; err = iova_cache_get(); @@ -310,11 +312,12 @@ static int host1x_probe(struct platform_device *pdev) } geometry = &host->domain->geometry; + start = geometry->aperture_start & mask; + end = geometry->aperture_end & mask; order = __ffs(host->domain->pgsize_bitmap); - init_iova_domain(&host->iova, 1UL << order, - geometry->aperture_start >> order); - host->iova_end = geometry->aperture_end; + init_iova_domain(&host->iova, 1UL << order, start >> order); + host->iova_end = end; } skip_iommu: