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=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 C45E8C43467 for ; Fri, 9 Oct 2020 07:40:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DA41022282 for ; Fri, 9 Oct 2020 07:40:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="Re2HuNR4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA41022282 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CC9086B006C; Fri, 9 Oct 2020 03:40:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7AAA6B006E; Fri, 9 Oct 2020 03:40:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B41706B0070; Fri, 9 Oct 2020 03:40:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 885E26B006C for ; Fri, 9 Oct 2020 03:40:52 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 181311EE6 for ; Fri, 9 Oct 2020 07:40:52 +0000 (UTC) X-FDA: 77351590344.26.sock79_560477d271de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id E69EF1804B660 for ; Fri, 9 Oct 2020 07:40:51 +0000 (UTC) X-HE-Tag: sock79_560477d271de X-Filterd-Recvd-Size: 7543 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 9 Oct 2020 07:40:51 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id f21so8790025wml.3 for ; Fri, 09 Oct 2020 00:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Y3zs5MyaJjxQczfNdG639aNsJL9caNjvPlFIB7wLkR4=; b=Re2HuNR4YnSz2NNNx0wCdYgdO3XvW6JJk1F7OiVGrn7H8vssSl0sr4fDhbdmRek7Ob J7NoAQOhGdhrEZhb81ooLcdoy9d15p/ullIXVzaI4OqRYddo1OdWO05Kov+w+RPBeDG+ RLewmnU6pYoax9iu9ChjqA0AFepC7dSXIWdc0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=Y3zs5MyaJjxQczfNdG639aNsJL9caNjvPlFIB7wLkR4=; b=AHEOm66s2lDqdZMRkRHF0+Tr1KGx5zIOVpxNv56kVEVONsqSChtOhDuoKbN2o+IdR+ XdwvaXzr+v03Fu3JIDQgXXKSUnf/sagXhrY2epJV7qRhNX8/a2LoLMpKbrZpoT+01oG/ Ei7gR5Tt446HTIusDGYDk3JQwyG57blOJto0jqGkUgWRPUNjoWV23HboVo52guJlKIIr +kfiBFHkO7zJcm4KZ2aK7K0NxWU0BCDI1zGWZsUBZ3WDxC9A0sSDCLELtHCpmX7GPSzQ Z495mP08piHgLgEz7XhcrETXwreqtmt+8eibrxt1csEeelL00wVP/7xmoIevQiwbHyXI QQzA== X-Gm-Message-State: AOAM532c9DbV5lSVh9HH6GIbjA6uy8NrSEJqADx+JZLJ1c/mVZ8tGwNw yE1SnM+DoyDXlYfxzYE+oXWY7g== X-Google-Smtp-Source: ABdhPJzEZVjAyzHt2mUFBrus7xHA9Fz2PHmYxtWRjXFp1GdZ9Yug82fj27NzQMq9vnHe30s/bBamAQ== X-Received: by 2002:a7b:c92c:: with SMTP id h12mr12070681wml.134.1602229250051; Fri, 09 Oct 2020 00:40:50 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id n3sm10383741wmn.28.2020.10.09.00.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 00:40:49 -0700 (PDT) Date: Fri, 9 Oct 2020 09:40:47 +0200 From: Daniel Vetter To: christian.koenig@amd.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, chris@chris-wilson.co.uk, airlied@redhat.com, akpm@linux-foundation.org, sumit.semwal@linaro.org Subject: Re: [PATCH 2/4] drm/prime: document that use the page array is deprecated Message-ID: <20201009074047.GM438822@phenom.ffwll.local> Mail-Followup-To: christian.koenig@amd.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, chris@chris-wilson.co.uk, airlied@redhat.com, akpm@linux-foundation.org, sumit.semwal@linaro.org References: <20201008112342.9394-1-christian.koenig@amd.com> <20201008112342.9394-2-christian.koenig@amd.com> <20201008140914.GF438822@phenom.ffwll.local> <20201008141419.GH438822@phenom.ffwll.local> <6cc96549-2724-6849-0f38-0de60ed6989c@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <6cc96549-2724-6849-0f38-0de60ed6989c@gmail.com> X-Operating-System: Linux phenom 5.7.0-1-amd64 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Oct 09, 2020 at 09:36:41AM +0200, Christian K=F6nig wrote: > Am 08.10.20 um 16:14 schrieb Daniel Vetter: > > On Thu, Oct 08, 2020 at 04:09:14PM +0200, Daniel Vetter wrote: > > > On Thu, Oct 08, 2020 at 01:23:40PM +0200, Christian K=F6nig wrote: > > > > We have reoccurring requests on this so better document that > > > > this approach doesn't work and dma_buf_mmap() needs to be used in= stead. > > > >=20 > > > > Signed-off-by: Christian K=F6nig > > > > --- > > > > drivers/gpu/drm/drm_prime.c | 7 ++++++- > > > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > >=20 > > > > diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_pr= ime.c > > > > index 4910c446db83..16fa2bfc271e 100644 > > > > --- a/drivers/gpu/drm/drm_prime.c > > > > +++ b/drivers/gpu/drm/drm_prime.c > > > > @@ -956,7 +956,7 @@ EXPORT_SYMBOL(drm_gem_prime_import); > > > > /** > > > > * drm_prime_sg_to_page_addr_arrays - convert an sg table into = a page array > > > > * @sgt: scatter-gather table to convert > > > > - * @pages: optional array of page pointers to store the page arr= ay in > > > > + * @pages: deprecated array of page pointers to store the page a= rray in > > > > * @addrs: optional array to store the dma bus address of each = page > > > > * @max_entries: size of both the passed-in arrays > > > > * > > > > @@ -965,6 +965,11 @@ EXPORT_SYMBOL(drm_gem_prime_import); > > > > * > > > > * Drivers can use this in their &drm_driver.gem_prime_import_s= g_table > > > > * implementation. > > > > + * > > > > + * Specifying the pages array is deprecated and strongly discour= aged for new > > > > + * drivers. The pages array is only useful for page faults and t= hose can > > > > + * corrupt fields in the struct page if they are not handled by = the exporting > > > > + * driver. > > > > */ > > > I'd make this a _lot_ stronger: Aside from amdgpu and radeon all dr= ivers > > > using this only need it for the pages array. Imo just open-code the= sg > > > table walking loop in amdgpu/radeon (it's really not much code), an= d then > > > drop the dma_addr_t parameter from this function here (it's set to = NULL by > > > everyone else). > > >=20 > > > And then deprecate this entire function here with a big warning tha= t a) > > > dma_buf_map_attachment is allowed to leave the struct page pointers= NULL > > > and b) this breaks mmap, users must call dma_buf_mmap instead. > > >=20 > > > Also maybe make it an uppercase DEPRECATED or something like that := -) > > OK I just realized I missed nouveau. That would be 3 places where we = need > > to stuff the dma_addr_t list into something ttm can take. Still feels > > better than this half-deprecated function kludge ... >=20 > Mhm, I don't see a reason why nouveau would need the struct page either= . >=20 > How about we split that up into two function? >=20 > One for converting the sg_table into a linear dma_addr array. >=20 > And one for converting the sg_table into a linear struct page array wit= h a > __deprecated attribute on it? Yeah makes sense, since converting ttm to just use sgt iterations directl= y everywhere is probably a bit too much. Maybe keep that converter in ttm code, since outside of ttm the rough consensus is to converge on sgt for handling buffers. Well, for those drivers not stuck on struct page arrays :-) -Daniel >=20 > Christian. >=20 > > -Daniel > >=20 > > > -Daniel > > >=20 > > > > int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, stru= ct page **pages, > > > > dma_addr_t *addrs, int max_entries) > > > > --=20 > > > > 2.17.1 > > > >=20 > > > --=20 > > > Daniel Vetter > > > Software Engineer, Intel Corporation > > > http://blog.ffwll.ch >=20 > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch