From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87047C433FE for ; Wed, 9 Dec 2020 08:32:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 36D5C23B87 for ; Wed, 9 Dec 2020 08:32:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36D5C23B87 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=crapouillou.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF4116E9D5; Wed, 9 Dec 2020 08:32:18 +0000 (UTC) Received: from aposti.net (aposti.net [89.234.176.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC6836E954 for ; Tue, 8 Dec 2020 14:00:38 +0000 (UTC) Date: Tue, 08 Dec 2020 14:00:22 +0000 From: Paul Cercueil Subject: Re: [PATCH 3/5] drm: Add and export =?UTF-8?Q?function=0D=0A?= drm_gem_cma_mmap_noncoherent To: Christoph Hellwig Message-Id: In-Reply-To: References: <20201102220651.22069-1-paul@crapouillou.net> <20201102220651.22069-4-paul@crapouillou.net> <20201103185058.GA20134@infradead.org> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 09 Dec 2020 08:32:01 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-kernel@vger.kernel.org, od@zcrc.me, dri-devel@lists.freedesktop.org, Thomas Zimmermann Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Christoph, Le mar. 3 nov. 2020 =E0 19:13, Paul Cercueil a = =E9crit : > Hi Christoph, > = > Le mar. 3 nov. 2020 =E0 18:50, Christoph Hellwig a = > =E9crit : >> On Mon, Nov 02, 2020 at 10:06:49PM +0000, Paul Cercueil wrote: >>> This function can be used by drivers that need to mmap dumb buffers >>> created with non-coherent backing memory. >>> = >>> Signed-off-by: Paul Cercueil >>> --- >>> drivers/gpu/drm/drm_gem_cma_helper.c | 39 = >>> =7F=7F++++++++++++++++++++++++++++ >>> include/drm/drm_gem_cma_helper.h | 2 ++ >>> 2 files changed, 41 insertions(+) >>> = >>> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c = >>> =7F=7Fb/drivers/gpu/drm/drm_gem_cma_helper.c >>> index 3bdd67795e20..4ed63f4896bd 100644 >>> --- a/drivers/gpu/drm/drm_gem_cma_helper.c >>> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c >>> @@ -387,6 +387,45 @@ int drm_gem_cma_mmap(struct file *filp, = >>> struct =7F=7Fvm_area_struct *vma) >>> } >>> EXPORT_SYMBOL_GPL(drm_gem_cma_mmap); >>> = >>> +/** >>> + * drm_gem_cma_mmap_noncoherent - memory-map a CMA GEM object with >>> + * non-coherent cache attribute >>> + * @filp: file object >>> + * @vma: VMA for the area to be mapped >>> + * >>> + * Just like drm_gem_cma_mmap, but for a GEM object backed by = >>> =7F=7Fnon-coherent >>> + * memory. >>> + * >>> + * Returns: >>> + * 0 on success or a negative error code on failure. >>> + */ >>> +int drm_gem_cma_mmap_noncoherent(struct file *filp, struct = >>> =7F=7Fvm_area_struct *vma) >>> +{ >>> + struct drm_gem_cma_object *cma_obj; >>> + int ret; >>> + >>> + ret =3D drm_gem_mmap(filp, vma); >>> + if (ret) >>> + return ret; >>> + >>> + cma_obj =3D to_drm_gem_cma_obj(vma->vm_private_data); >>> + >>> + /* >>> + * Clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and = >>> =7F=7Fset the >>> + * vm_pgoff (used as a fake buffer offset by DRM) to 0 as we = >>> want =7F=7Fto map >>> + * the whole buffer. >>> + */ >>> + vma->vm_flags &=3D ~VM_PFNMAP; >>> + vma->vm_pgoff =3D 0; >>> + vma->vm_page_prot =3D vm_get_page_prot(vma->vm_flags); >>> + >>> + return remap_pfn_range(vma, vma->vm_start, >>> + cma_obj->paddr >> PAGE_SHIFT, >>> + vma->vm_end - vma->vm_start, >>> + vma->vm_page_prot); >> = >> Per patch 1 cma_obj->paddr is the dma address, while remap_pfn_range >> expects a physical address. This does not work. > = > Ok, what would be the correct way to mmap_noncoherent? Waiting for your input here :) Cheers, -Paul _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel