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=-11.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 17C75C43457 for ; Fri, 9 Oct 2020 07:36:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 74DC622269 for ; Fri, 9 Oct 2020 07:36:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kIGXTJl/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74DC622269 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C130F6B0068; Fri, 9 Oct 2020 03:36:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE8C26B006C; Fri, 9 Oct 2020 03:36:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B273C6B006E; Fri, 9 Oct 2020 03:36:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id 86CED6B0068 for ; Fri, 9 Oct 2020 03:36:45 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 054F5180AD80F for ; Fri, 9 Oct 2020 07:36:45 +0000 (UTC) X-FDA: 77351579970.28.story41_2b02e9e271de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id D74616C05 for ; Fri, 9 Oct 2020 07:36:44 +0000 (UTC) X-HE-Tag: story41_2b02e9e271de X-Filterd-Recvd-Size: 6655 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 9 Oct 2020 07:36:44 +0000 (UTC) Received: by mail-ej1-f67.google.com with SMTP id h24so11682034ejg.9 for ; Fri, 09 Oct 2020 00:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=KDyUTK8HE57boREsu/kkQV3gAaTaD15LV09WfHJl7QA=; b=kIGXTJl/kOjQKxmgRI69WHaqY7wqG2Iftx5wG5g2WhEIYTHKNVtTW0rZIYWWs4UDho DM2mbQx2xiJ0y3D0Py2Dsju2CITpUnRITmBmsIJrS4mTjp5L5oEgPHYvtwRpHreYFZWs YQ0GFatuSc7Ed2uFiNpB8CotQXhkN7tvSToTlnE+UsFez1BjvKcNuqrfN2kv80c+LHI+ tsonF8erzFyfkOUt8NqnsJZLxO0ZL4mzCChcWxnQQrqU2nMKDLWF0PGAygmnFsu8t0+O l4x1RBptHp5dY4jISuBlzc9/4LH1UZnUbJHu8lenU1eHd56zkQX0xo8cM2jccYBXTble 0jZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=KDyUTK8HE57boREsu/kkQV3gAaTaD15LV09WfHJl7QA=; b=rKwleAcl0QmJHsdHhyRWh/kpu3TZz56G3ShLwl53EF+CltcvuQPu+zZgHHAL98YdGJ BEeacw1YOPSFSfZ2PnhT92Xw2aoPbyhdCSlIarsuiMa+E0PydW/Xoo4OemmCfhjxZpHC oXsq6izQ0mNQFRFLf489Ij0Ffsel377kA3H3OQaUP4lfuiVowhrhi62UodyOsdkC/jt6 vYNszdLGcCK910gx/IqJrCzO3d149CGcRKSuDGM8nHHOTx8Eow9AKmawQK/m4qmgsDl5 RVIJdnyfG7P6Bef8BwG1AP2g6XY7QQ9NkNVExc3SKtH6oqD+w3Hk3Wm3aijIperYbi7G +ewQ== X-Gm-Message-State: AOAM531hEE0iH0EH6IKDULu8ZUyCADN8LWdMSfMaH7WRQNMJHdzAner+ D3KX2UVuLDsoeMuk3qFUKZgIh/cGi+E= X-Google-Smtp-Source: ABdhPJwmLU0/zFy/biwCWPdlbly4yd8EXZvqkIyBmFwrU0xdwElcWIp7GYrCCXyxceMhCvEZZAAqtw== X-Received: by 2002:a17:906:68c4:: with SMTP id y4mr13159828ejr.197.1602229003288; Fri, 09 Oct 2020 00:36:43 -0700 (PDT) Received: from ?IPv6:2a02:908:1252:fb60:be8a:bd56:1f94:86e7? ([2a02:908:1252:fb60:be8a:bd56:1f94:86e7]) by smtp.gmail.com with ESMTPSA id w25sm5360262ejy.123.2020.10.09.00.36.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Oct 2020 00:36:42 -0700 (PDT) Reply-To: christian.koenig@amd.com Subject: Re: [PATCH 2/4] drm/prime: document that use the page array is deprecated To: 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> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <6cc96549-2724-6849-0f38-0de60ed6989c@gmail.com> Date: Fri, 9 Oct 2020 09:36:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201008141419.GH438822@phenom.ffwll.local> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US 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: 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=C3=B6nig wrote: >>> We have reoccurring requests on this so better document that >>> this approach doesn't work and dma_buf_mmap() needs to be used instea= d. >>> >>> Signed-off-by: Christian K=C3=B6nig >>> --- >>> drivers/gpu/drm/drm_prime.c | 7 ++++++- >>> 1 file changed, 6 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.= 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 pa= ge array >>> * @sgt: scatter-gather table to convert >>> - * @pages: optional array of page pointers to store the page array i= n >>> + * @pages: deprecated array of page pointers to store the page array= 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_sg_ta= ble >>> * implementation. >>> + * >>> + * Specifying the pages array is deprecated and strongly discouraged= for new >>> + * drivers. The pages array is only useful for page faults and those= 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 drive= rs >> 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), and t= hen >> drop the dma_addr_t parameter from this function here (it's set to NUL= L by >> everyone else). >> >> And then deprecate this entire function here with a big warning that a= ) >> dma_buf_map_attachment is allowed to leave the struct page pointers NU= LL >> and b) this breaks mmap, users must call dma_buf_mmap instead. >> >> 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 ne= ed > to stuff the dma_addr_t list into something ttm can take. Still feels > better than this half-deprecated function kludge ... Mhm, I don't see a reason why nouveau would need the struct page either. How about we split that up into two function? One for converting the sg_table into a linear dma_addr array. And one for converting the sg_table into a linear struct page array with=20 a __deprecated attribute on it? Christian. > -Daniel > >> -Daniel >> >>> int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct p= age **pages, >>> dma_addr_t *addrs, int max_entries) >>> --=20 >>> 2.17.1 >>> >> --=20 >> Daniel Vetter >> Software Engineer, Intel Corporation >> http://blog.ffwll.ch