Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7530977rwd; Tue, 6 Jun 2023 12:07:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Sl6zWl4Rl52Omibubvbr5TkamYJN8a7ogutIcmTBYMTPMuBcOSqQYDRQBWLWRzb4GuXsq X-Received: by 2002:a05:6358:ce16:b0:129:d05e:48cb with SMTP id gt22-20020a056358ce1600b00129d05e48cbmr579478rwb.31.1686078424144; Tue, 06 Jun 2023 12:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686078424; cv=none; d=google.com; s=arc-20160816; b=m4vDf7MrjUVxG697c9oFxue8lNd1iM2BQTukp9GggjtbkU40kBbHyiDe2x3TW4WoVP VRIX716tOjulNsexzhQwTH0vig2jtEP2DRmvE1r8C6b4+uN524t3xj2RxaFnEIZY9Bk/ Z9i7obpY6de9NuYMO4onjHEzpzs3osmNCT99waJaC18AmTTaICTYUr1//8K5MhAh9FlH wcxDvYTsodfK0+17gtXEphLb0fKi1TAnMCF8QVFERURkstcJMF4ZspiZdgyEDSrgeO8G 1wsrPI/p6fifVfHxCR2/wWdm/+XLiXdCxdg8PdLUyfrzeFOG/uV9MPAmvsU+0g+Mrg+X vxYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=ceC3cs5twkuX5SKliuD/yr3pwCeIrlfDQKM/emIBmtk=; b=mdUQl5xFM2yzoAgoP5NC0XtWiNV9t0IikhY1R5oBYtJBzzoXWM1gZu8WtnxZEGf3dK 3tPNo+ejtAZaXHmAbwEsWJtKirXHXX0Tvmwh1Pk7BWIFbq+bVCDAaDiUnl3GIlufw7S+ tycPi/HYWM73n4ofpACJEQeHbp05mqUEu/vm4rfAtDdkt22/mDYnGMFECfHAy41lmVbs IV4HYhjcd2/zMspfnkf0OSXRCUOkPWLoCB3ECMf1A74vQYJ67bmBVba4W97BDxC1NhOO PJMzLae9BfbPy6XMBSV8mAM7vGLIn76LAcgeTDjvjgx+Dm0z1Osd/HBcTwySe+gE/jpX VwRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jc5KjSXv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1-20020a63cf01000000b0053087bce16esi7491524pgg.830.2023.06.06.12.06.51; Tue, 06 Jun 2023 12:07:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jc5KjSXv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbjFFTBM (ORCPT + 99 others); Tue, 6 Jun 2023 15:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238964AbjFFTBJ (ORCPT ); Tue, 6 Jun 2023 15:01:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0601495 for ; Tue, 6 Jun 2023 12:01:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8E9FD635B5 for ; Tue, 6 Jun 2023 19:01:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB594C433EF; Tue, 6 Jun 2023 19:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686078063; bh=8VSP6X5HdznLbwQMYErzABqaXfaxZIW755OS+DXUrX0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Jc5KjSXvQdpp345q2PX36NiZZ/vb4vcpz8ysOTPRNM4mjZFJ+oos/O2ps7jrZTvBP jSAA9yYobIgs5OmhViLvRkVIjz8izi3zcTYQmRpPjXq0doKpN/v8x+3BsmgyVluN3+ EQgXHGed04Uqq1hXXJxrtwG4B/Z1i4OoECdfdZJwDePA/m0k6UfKk9BKcv4YhNzO3T DTp2/96VG1pKXwRvWVfOzey0hlwagGlcRRCmloZY5/g2HyVZ0cNHQy9VouEHgYhW1H nJS+P0Nn89MlC8i/xA73J/6+toJBfuuL8Wgs9ZHartLOISG4nVRblkmQtEjKMSVJaJ CnqJT76hZA9YA== Date: Tue, 6 Jun 2023 14:01:02 -0500 From: Bjorn Helgaas To: Sui Jingfeng Cc: Sui Jingfeng <15330273260@189.cn>, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, Bjorn Helgaas Subject: Re: [PATCH v7 7/7] drm/etnaviv: add support for the dma coherent device Message-ID: <20230606190102.GA1134540@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <234586a0-995c-b4c4-3b7b-35afeea1a797@loongson.cn> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 07, 2023 at 02:43:27AM +0800, Sui Jingfeng wrote: > On 2023/6/7 00:56, Bjorn Helgaas wrote: > > On Sat, Jun 03, 2023 at 06:59:43PM +0800, Sui Jingfeng wrote: > > > From: Sui Jingfeng > > > > > > Loongson CPUs maintain cache coherency by hardware, which means that the > > > data in the CPU cache is identical to the data in main system memory. As > > > for the peripheral device, most of Loongson chips chose to define the > > > peripherals as DMA coherent by default, device drivers do not need to > > > maintain the coherency between a processor and an I/O device manually. > > ... > > I guess the only way to discover this coherency attribute is via the > > DT "vivante,gc" property? Seems a little weird but I'm really not a > > DT person. > > I'm not sure it is *only*, but it is very convenient to achieve such a thing > with DT. I don't know if this is a property of the PCI device, or a property of the system as a whole. I asked because PCI devices should be self-describing (the Device/Vendor ID should be enough to identify the correct driver, and the driver should know how to learn anything else it needs to know about the device from PCI config space) and should not require extra DT properties. But if this is a CPU or system property, you probably have to use a firmware interface like DT or ACPI. > > > +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c > > > @@ -8,6 +8,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > It looks like this #include might not be needed? > > No, the dev_is_dma_coherent() function is declared and defined in > dma-map-ops.h. if remove it, gcc will complain: > > drivers/gpu/drm/etnaviv/etnaviv_drv.c: In function > ‘etnaviv_is_dma_coherent’: > drivers/gpu/drm/etnaviv/etnaviv_drv.c:56:14: error: implicit declaration of > function ‘dev_is_dma_coherent’; did you mean ‘etnaviv_is_dma_coherent’? > [-Werror=implicit-function-declaration] >    56 |   coherent = dev_is_dma_coherent(dev); >       |              ^~~~~~~~~~~~~~~~~~~ Of course, but that warning is for etnaviv_drv.c, not for etnaviv_gpu.c. So etnaviv_drv.c needs to include dma-map-ops.h, but I don't think etnaviv_gpu.c does. I removed this #include from etnaviv_gpu.c and it still built without errors. > > You're only adding a > > new reference to priv->dma_coherent, which looks like it was added to > > etnaviv_drv.h.