Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp365842pxb; Thu, 26 Aug 2021 05:11:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4e0fZsoiAEa+lR0BRo/epjXShux4cbdyGDg9xaGgu4M3cGy0cNWi095bC3cmm9j40x4Lr X-Received: by 2002:a6b:296:: with SMTP id 144mr2723102ioc.114.1629979874381; Thu, 26 Aug 2021 05:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629979874; cv=none; d=google.com; s=arc-20160816; b=geoJg2I/R/sB5LH+ThC56lPX86qCqj6GOwfbbitetPpH1hRavpFUr+uIyOjYsyGQIx LNY1M248OSW4C3mXLCUQOn6IXssNoqzT2mdbBbLNUcLIoh3l8I5Sjk54UIRBY9lE9Lqk wG+5oMC+XkW9sTS+GXEgT1tREPlUzCH8U+iZimrypm4t3KTL1UQAeMwjRBKIl8UCrioy zVbwkKIkyIY+scpNh7XJk6h9IeYQZ9TUh1dDKXnAQM3DWdRXF+FMT97SnZ9pXHY8xMol oUC1nPM55pSS8pWANBnfcd6TUmpmLvo1nqj2NvA3UPngYsQQm9lK+21JZAntnHUU0ZQC 42IA== 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=niYNgQZFFX4h1KJxNUvDocP9d3R8SkyAI9p9cuLyy7g=; b=cjyTHfKvKoECtxpVmL80IJbZ3AAkixuvoLUeHjbZvTeANdH8MsY/Q/HIkX5vZxrN0C 7dx5K2Fk3hPHB4mF5FkyFtEUQ/w4S3RAyDHiFi14kcfhjI/DSTpfvlBvCF7bN8deqdO2 CyTG8vMDPpW+LYhZouPx4FWnrBRBjIpHdFVji9NCBVGUgk9NRXAmVXvvZq6P6YJznZFm 5MHPtgKsKKO0hUO29c4O23tQCDuwlleM2iPECojVvDd4onNfmbIT3oIzMmoiQhuKC4+J L/js7zghykJ1bPFvfGiXkD1O7vekB3EQlqDXKEgl0OMoP+ugYY+X2I4IoFL2eS1jo036 gbuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=FOw9ikDR; 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 a10si2663791ios.4.2021.08.26.05.11.02; Thu, 26 Aug 2021 05:11:14 -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=FOw9ikDR; 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 S242453AbhHZMLD (ORCPT + 99 others); Thu, 26 Aug 2021 08:11:03 -0400 Received: from ssl.serverraum.org ([176.9.125.105]:56735 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236119AbhHZMLB (ORCPT ); Thu, 26 Aug 2021 08:11:01 -0400 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 6ACD122249; 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=1629979813; 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=niYNgQZFFX4h1KJxNUvDocP9d3R8SkyAI9p9cuLyy7g=; b=FOw9ikDR/mMI5CtoWs4+wtymhqglQR+/EY6rrfLuZPnfXuEMyTXMNGLW8mni2RSEw38w2e q0exi144/r71Qn8vyERX1vwftkfQA1Chx9u3GAQPg8adiQ/F15eLwRNpgsrFnuvNfXHCbt heIarGhVMTaTJWfmw8MHBEOruTLwp3I= 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 2/3] drm/etnaviv: fix dma configuration of the virtual device Date: Thu, 26 Aug 2021 14:10:05 +0200 Message-Id: <20210826121006.685257-3-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 DMA configuration of the virtual device is inherited from the first actual etnaviv device. Unfortunately, this doesn't work with an IOMMU: [ 5.191008] Failed to set up IOMMU for device (null); retaining platform DMA ops This is because there is no associated iommu_group with the device. The group is set in iommu_group_add_device() which is eventually called by device_add() via the platform bus: device_add() blocking_notifier_call_chain() iommu_bus_notifier() iommu_probe_device() __iommu_probe_device() iommu_group_get_for_dev() iommu_group_add_device() Move of_dma_configure() into the probe function, which is called after device_add(). Normally, the platform code will already call it itself if .of_node is set. Unfortunately, this isn't the case here. Also move the dma mask assignemnts to probe() to keep all DMA related settings together. Signed-off-by: Michael Walle --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 2509b3e85709..ff6425f6ebad 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -589,6 +589,7 @@ static int compare_str(struct device *dev, void *data) static int etnaviv_pdev_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct device_node *first_node = NULL; struct component_match *match = NULL; if (!dev->platform_data) { @@ -598,6 +599,9 @@ static int etnaviv_pdev_probe(struct platform_device *pdev) if (!of_device_is_available(core_node)) continue; + if (!first_node) + first_node = core_node; + drm_of_component_match_add(&pdev->dev, &match, compare_of, core_node); } @@ -609,6 +613,17 @@ 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; + + /* + * Apply the same DMA configuration to the virtual etnaviv + * device as the GPU we found. This assumes that all Vivante + * GPUs in the system share the same DMA constraints. + */ + if (first_node) + of_dma_configure(&pdev->dev, first_node, true); + return component_master_add_with_match(dev, &etnaviv_master_ops, match); } @@ -659,15 +674,6 @@ static int __init etnaviv_init(void) of_node_put(np); goto unregister_platform_driver; } - pdev->dev.coherent_dma_mask = DMA_BIT_MASK(40); - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - - /* - * Apply the same DMA configuration to the virtual etnaviv - * device as the GPU we found. This assumes that all Vivante - * GPUs in the system share the same DMA constraints. - */ - of_dma_configure(&pdev->dev, np, true); ret = platform_device_add(pdev); if (ret) { -- 2.30.2