From nobody Tue Feb 10 16:58:00 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E55A1EB64D7 for ; Tue, 20 Jun 2023 09:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232426AbjFTJsG (ORCPT ); Tue, 20 Jun 2023 05:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231615AbjFTJsA (ORCPT ); Tue, 20 Jun 2023 05:48:00 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D65B110C for ; Tue, 20 Jun 2023 02:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=CV0Q0 YXYgyZAqdc3fwoTj25afaXkdgqTctwzpXI/ayg=; b=EiwznZWxKXx0QkWJX0JOA 0M1QwURMCwkJ0HhdkxRSmwrH9Vdl2248xFlmfnjQ5xxW6uDwpkGWUeX7LySdvGJu vsYiowqyF1XA8k9gX+MKGsFFPUgEGJ8wgiVGsaWXZeaxvADD/1VMzYAXukNWB/YF dn/atgwcYbNqQU+GRldH1s= Received: from openarena.loongson.cn (unknown [114.242.206.180]) by zwqz-smtp-mta-g4-0 (Coremail) with SMTP id _____wAXg3CldZFkB8yiAQ--.11241S11; Tue, 20 Jun 2023 17:47:19 +0800 (CST) From: Sui Jingfeng <18949883232@163.com> To: Lucas Stach , Russell King , Christian Gmeiner , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Sui Jingfeng Subject: [PATCH v10 09/11] drm/etnaviv: Clean up etnaviv_pdev_probe() function Date: Tue, 20 Jun 2023 17:47:14 +0800 Message-Id: <20230620094716.2231414-10-18949883232@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230620094716.2231414-1-18949883232@163.com> References: <20230620094716.2231414-1-18949883232@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wAXg3CldZFkB8yiAQ--.11241S11 X-Coremail-Antispam: 1Uf129KBjvJXoWxZF4fCryUur4UCryDuw1Utrb_yoWrGrW5pF W3JayYyryDX3WYgayxAan5ZryYkF9agayFyryUK34vk345Jr9avF9YkryUAas5Jr95CF10 qr40krWUWF1rGrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jxTmhUUUUU= X-Originating-IP: [114.242.206.180] X-CM-SenderInfo: jprymkizyyjjits6il2tof0z/1tbiEwmU0WE17eMXkQABsC Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sui Jingfeng Add a dedicate function to do the DMA configuration to the virtual master. Also replace the &pdev->dev with dev. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 65 +++++++++++++++------------ 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnavi= v/etnaviv_drv.c index 47b2cdbb53e2..8907cdb8a1f8 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -54,6 +54,40 @@ static bool etnaviv_is_dma_coherent(struct device *dev) return coherent; } =20 +static int etnaviv_of_dma_configure(struct device *dev) +{ + struct device_node *first_node; + + /* + * 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(dev, DMA_BIT_MASK(40)) || + dma_set_coherent_mask(dev, DMA_BIT_MASK(32))) { + dev_err(dev, "No suitable DMA available\n"); + return -ENODEV; + } + + /* + * 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. + */ + first_node =3D etnaviv_of_first_available_node(); + if (first_node) + of_dma_configure(dev, first_node, true); + + return 0; +} + /* * etnaviv private data construction and destructions: */ @@ -664,7 +698,6 @@ static const struct component_master_ops etnaviv_master= _ops =3D { static int etnaviv_pdev_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct device_node *first_node =3D NULL; struct component_match *match =3D NULL; =20 if (!dev->platform_data) { @@ -674,10 +707,7 @@ static int etnaviv_pdev_probe(struct platform_device *= pdev) if (!of_device_is_available(core_node)) continue; =20 - if (!first_node) - first_node =3D core_node; - - drm_of_component_match_add(&pdev->dev, &match, + drm_of_component_match_add(dev, &match, component_compare_of, core_node); } } else { @@ -688,31 +718,8 @@ static int etnaviv_pdev_probe(struct platform_device *= pdev) component_match_add(dev, &match, component_compare_dev_name, names[i]); } =20 - /* - * 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"); + if (etnaviv_of_dma_configure(dev)) return -ENODEV; - } - - /* - * 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); =20 return component_master_add_with_match(dev, &etnaviv_master_ops, match); } --=20 2.25.1