Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp367205pxb; Thu, 26 Aug 2021 05:13:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCq/ghWGZq/EkqJWrgzKtFiZYjcAiJtvj5Gmrj8J3bdU7DMY5dAO7nPyHTYfYQ874OdDCN X-Received: by 2002:a02:8549:: with SMTP id g67mr3318041jai.73.1629979987110; Thu, 26 Aug 2021 05:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629979987; cv=none; d=google.com; s=arc-20160816; b=Te6GLArucN9xS1JS/Jdhy+JxIPlG8QWsRysyyj8GlopooZBnJdEIULqTQVAnMXRo+r bVgRi55k5JNrKHVc6N5oagp+KX7wUyFMDhPDuzTTOmIPeewRIQ7y+VfBy6Y75JK0cSAC WwvdzxkiACPMag1r8dDIQ2AG/fTbTf8qM7pqD6WnuBmb1QJ5+ZQPV4bCtU4KNH1ARRoB 1S2Ur+k59AOsA0n/WGQo+tKc2SDXTUyFNMi/ERVRu6az6MC3egEayPHJ7l8U7+THI9Jh YhpL72iwwTiMG/jxL1IaULhqtwfd9HQD8YHWN1eWFlNiTTW/mZq6lzr/eWKB5GiNS+zW 6qxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oRQiZA12z5278LSNc0kj7MPQsMh45a7s6hh6cYHR2NQ=; b=j9eegxOyDynJKb3/f1r7s6lkMPKgpx9ueVB3PqdyFqo57C0l9+glMDgACgCFffQdBK h0XeDnrwZ4reaM5xtYTfSGfbtZV4/ziRIpuDRCGBbEvOappa6F/+NbQpimPTVboaFEq4 jafsRMsNW0UyiBNDjRI6wZMW9MerTKEpOZov8o4nb7qpLj19h2uapKUeinUf+At9P9JP K1wSQkHQgSQmhEA/PQ2IZBs/RiAG7D/5oi4NfqaNdLuSE+vySagoBUI83xbuGasdC/Qp mTs3bxGfXHxkZ4QDM5wGDSRTOSrdRSxgN/scl+DCn1OAwsaovoLC+jpZw14MpprZ9Tps cQ+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=cVhbzjVi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o1si2575775ill.7.2021.08.26.05.12.55; Thu, 26 Aug 2021 05:13:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=cVhbzjVi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242482AbhHZMLG (ORCPT + 99 others); Thu, 26 Aug 2021 08:11:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242447AbhHZMLC (ORCPT ); Thu, 26 Aug 2021 08:11:02 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEA55C061757 for ; Thu, 26 Aug 2021 05:10:15 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id E27132224D; Thu, 26 Aug 2021 14:10:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1629979814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oRQiZA12z5278LSNc0kj7MPQsMh45a7s6hh6cYHR2NQ=; b=cVhbzjVibrZQBHsYp9/pglVYtu/clIQEjtvfDlOpVtf8nxfWMbgFoL042KAC8ZWg/jzRK7 KF0Px9NmoLRaddTcqsQy/lXYxVTWYcME1IUjED/EWCqMBsyEk7jE3VpkqyFAYwBEnHZ2+l UlmgP4k3+abGOvT1C27XQNmLhzC8hZc= From: Michael Walle To: etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: "Lukas F . Hartmann" , Marek Vasut , Lucas Stach , Russell King , Christian Gmeiner , David Airlie , Daniel Vetter , Michael Walle Subject: [PATCH 3/3] drm/etnaviv: use a 32 bit mask as coherent DMA mask Date: Thu, 26 Aug 2021 14:10:06 +0200 Message-Id: <20210826121006.685257-4-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210826121006.685257-1-michael@walle.cc> References: <20210826121006.685257-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The STLB and the first command buffer (which is used to set up the TLBs) has a 32 bit size restriction in hardware. There seems to be no way to specify addresses larger than 32 bit. Keep it simple and restict the addresses to the lower 4 GiB range for all coherent DMA memory allocations. Signed-off-by: Michael Walle --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index ff6425f6ebad..0b756ecb1bc2 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -613,8 +613,23 @@ static int etnaviv_pdev_probe(struct platform_device *pdev) component_match_add(dev, &match, compare_str, names[i]); } - pdev->dev.coherent_dma_mask = DMA_BIT_MASK(40); - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; + /* + * PTA and MTLB can have 40 bit base addresses, but + * unfortunately, an entry in the MTLB can only point to a + * 32 bit base address of a STLB. Moreover, to initialize the + * MMU we need a command buffer with a 32 bit address because + * without an MMU there is only an indentity mapping between + * the internal 32 bit addresses and the bus addresses. + * + * To make things easy, we set the dma_coherent_mask to 32 + * bit to make sure we are allocating the command buffers and + * TLBs in the lower 4 GiB address space. + */ + if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(40)) || + dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { + dev_dbg(&pdev->dev, "No suitable DMA available\n"); + return -ENODEV; + } /* * Apply the same DMA configuration to the virtual etnaviv -- 2.30.2