From patchwork Thu Oct 8 11:23:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11822659 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C19C6CA for ; Thu, 8 Oct 2020 11:23:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E43632145D for ; Thu, 8 Oct 2020 11:23:48 +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="RRd5pSd2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E43632145D 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 C23CA6B0062; Thu, 8 Oct 2020 07:23:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD40A6B0068; Thu, 8 Oct 2020 07:23:47 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9D4B6B006C; Thu, 8 Oct 2020 07:23:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0075.hostedemail.com [216.40.44.75]) by kanga.kvack.org (Postfix) with ESMTP id 7C9886B0062 for ; Thu, 8 Oct 2020 07:23:47 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F22A11EE6 for ; Thu, 8 Oct 2020 11:23:46 +0000 (UTC) X-FDA: 77348523252.02.seat45_0918288271d7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id CFAED1018ADDC for ; Thu, 8 Oct 2020 11:23:46 +0000 (UTC) X-Spam-Summary: 1,0,0,2ed219b39c6041c7,d41d8cd98f00b204,ckoenig.leichtzumerken@gmail.com,,RULES_HIT:2:41:69:152:355:379:541:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1381:1437:1515:1516:1518:1535:1593:1594:1605:1676:1730:1747:1777:1792:1801:2393:2559:2562:2899:3138:3139:3140:3141:3142:3865:3866:3867:3870:4049:4120:4250:4321:4605:5007:6119:6261:6653:9413:10004:11026:11473:11657:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12679:12895:12986:13894:14096:14097:14394:14659:14687:21080:21444:21451:21627:21666:21990:30054:30064:30069:30070,0,RBL:209.85.218.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yfme9wboo6yi9bmm35dq94bj817ocihkzshags34qp1h8akk8sks5kjxra1du.6ad9bpgs5atjq337jtr7111xqppn86pf8eih5kjkuqe5e885q59jcsscnffp5em.w-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: seat45_0918288271d7 X-Filterd-Recvd-Size: 9750 Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Thu, 8 Oct 2020 11:23:46 +0000 (UTC) Received: by mail-ej1-f65.google.com with SMTP id u21so7580851eja.2 for ; Thu, 08 Oct 2020 04:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=g5slpzPB5zKh1WzF1mxgqBWxGWWJNpTg+Z0FPcFsWtg=; b=RRd5pSd2IwREt4izuuLm8dVSSb/OhWaKv4Raq6h8J84S8I+NOIk/xh7iDBib7SdVO1 2ueWE41eulixX+/eFqp9ZdPonlVOYP7vpnvg802TdM2IYrhe3+2KBB4nbruPLk0Xxtms AF183RMBIsiZWFiVzRtlol7CmehCFswX4QkfHebY6Q3g0rlF+KK9zWW9TErlt+9CMsQv EC5RBtQRAWZ8p+3RYRrOitr6nk8N3Nellvqnel9wyIFDKmQrTAebnwpD8611fPlcjMcp TqtvVtAolzV5vWZG41B13APAK1geRMi1CW/ESBxBymQ8ltP/zBX0D1F1HOmMGWORjPqV rATg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=g5slpzPB5zKh1WzF1mxgqBWxGWWJNpTg+Z0FPcFsWtg=; b=igcGXzbHwkPE+WpdoQWbpDX6F7pyRbqgIQYGtVaF3tkFcLEmlYK5NGGko71/VMaEbP BybP96SaBs/OEC3eyiAGRMD8KBjq0wBZyzAwR5EVQGpBUMWJwBF7fkCVQ4JtQNETGkd5 1yC5aFeUkZtPDg36cch5wCcTG78oablnuaAj3kuHa+Sjoktfm2hqXdZOV7+G567xgcEr S4KkBiTyrvxPni2H0DlBF+kzT7TYPA3Ej+u9sntDQS3U5IR7mGh+Cz3xW20UcW6HDQ+C ijBmHEnB3MPq8xfgqUVSU8DrhRX1+9cmbmnNBmA1MxODl5hxVa+Usama0sYUcimK1mJ5 b+Cw== X-Gm-Message-State: AOAM530uaUXLu6SaWGW/bwSfah/bXTtqSmgLvGKrK+job07vgjlSfczH pzf8v9mOOp/RmwsvDc/IYcVS/KJWeqY= X-Google-Smtp-Source: ABdhPJxL+c3qJ91ehT1z0omwcR8U0j/1R6BZHCRub4+KUwONUqk/Q7OikaBhK2zqj3mk6LY7IhEcXA== X-Received: by 2002:a17:906:2b85:: with SMTP id m5mr8624058ejg.143.1602156224656; Thu, 08 Oct 2020 04:23:44 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:4c64:a9a0:5e0:905a]) by smtp.gmail.com with ESMTPSA id i20sm3529030edv.96.2020.10.08.04.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 04:23:44 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= 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, daniel@ffwll.ch, sumit.semwal@linaro.org Subject: [PATCH 1/4] mm: introduce vma_set_file function v2 Date: Thu, 8 Oct 2020 13:23:39 +0200 Message-Id: <20201008112342.9394-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 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: Add the new vma_set_file() function to allow changing vma->vm_file with the necessary refcount dance. v2: add more users of this. Signed-off-by: Christian König Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/dma-buf/dma-buf.c | 16 +++++----------- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 4 +--- drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 3 +-- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 4 ++-- drivers/gpu/drm/msm/msm_gem.c | 4 +--- drivers/gpu/drm/omapdrm/omap_gem.c | 3 +-- drivers/gpu/drm/vgem/vgem_drv.c | 3 +-- drivers/staging/android/ashmem.c | 5 ++--- include/linux/mm.h | 2 ++ mm/mmap.c | 16 ++++++++++++++++ 10 files changed, 32 insertions(+), 28 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index a6ba4d598f0e..e4316aa7e0f4 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1163,20 +1163,14 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma, return -EINVAL; /* readjust the vma */ - get_file(dmabuf->file); - oldfile = vma->vm_file; - vma->vm_file = dmabuf->file; + oldfile = vma_set_file(vma, dmabuf->file); vma->vm_pgoff = pgoff; ret = dmabuf->ops->mmap(dmabuf, vma); - if (ret) { - /* restore old parameters on failure */ - vma->vm_file = oldfile; - fput(dmabuf->file); - } else { - if (oldfile) - fput(oldfile); - } + /* restore old parameters on failure */ + if (ret) + vma_set_file(vma, oldfile); + return ret; } diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index 312e9d58d5a7..10ce267c0947 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -145,10 +145,8 @@ static int etnaviv_gem_mmap_obj(struct etnaviv_gem_object *etnaviv_obj, * address_space (so unmap_mapping_range does what we want, * in particular in the case of mmap'd dmabufs) */ - fput(vma->vm_file); - get_file(etnaviv_obj->base.filp); vma->vm_pgoff = 0; - vma->vm_file = etnaviv_obj->base.filp; + vma_set_file(vma, etnaviv_obj->base.filp); vma->vm_page_prot = vm_page_prot; } diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c index fec0e1e3dc3e..8ce4c9e28b87 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c @@ -119,8 +119,7 @@ static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct * if (ret) return ret; - fput(vma->vm_file); - vma->vm_file = get_file(obj->base.filp); + vma_set_file(vma, obj->base.filp); return 0; } diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c index 3d69e51f3e4d..c9d5f1a38af3 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c @@ -893,8 +893,8 @@ int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma) * requires avoiding extraneous references to their filp, hence why * we prefer to use an anonymous file for their mmaps. */ - fput(vma->vm_file); - vma->vm_file = anon; + vma_set_file(vma, anon); + fput(anon); switch (mmo->mmap_type) { case I915_MMAP_TYPE_WC: diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index de915ff6f4b4..a71f42870d5e 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -223,10 +223,8 @@ int msm_gem_mmap_obj(struct drm_gem_object *obj, * address_space (so unmap_mapping_range does what we want, * in particular in the case of mmap'd dmabufs) */ - fput(vma->vm_file); - get_file(obj->filp); vma->vm_pgoff = 0; - vma->vm_file = obj->filp; + vma_set_file(vma, obj->filp); vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); } diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 979d53a93c2b..0d4542ff1d7d 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -564,9 +564,8 @@ int omap_gem_mmap_obj(struct drm_gem_object *obj, * address_space (so unmap_mapping_range does what we want, * in particular in the case of mmap'd dmabufs) */ - fput(vma->vm_file); vma->vm_pgoff = 0; - vma->vm_file = get_file(obj->filp); + vma_set_file(vma, obj->filp); vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); } diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c index fa54a6d1403d..ea0eecae5153 100644 --- a/drivers/gpu/drm/vgem/vgem_drv.c +++ b/drivers/gpu/drm/vgem/vgem_drv.c @@ -397,8 +397,7 @@ static int vgem_prime_mmap(struct drm_gem_object *obj, if (ret) return ret; - fput(vma->vm_file); - vma->vm_file = get_file(obj->filp); + vma_set_file(vma, obj->filp); vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 10b4be1f3e78..a51dc089896e 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -450,9 +450,8 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) vma_set_anonymous(vma); } - if (vma->vm_file) - fput(vma->vm_file); - vma->vm_file = asma->file; + vma_set_file(vma, asma->file); + fput(asma->file); out: mutex_unlock(&ashmem_mutex); diff --git a/include/linux/mm.h b/include/linux/mm.h index ca6e6a81576b..a558602afe1b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2693,6 +2693,8 @@ static inline void vma_set_page_prot(struct vm_area_struct *vma) } #endif +struct file *vma_set_file(struct vm_area_struct *vma, struct file *file); + #ifdef CONFIG_NUMA_BALANCING unsigned long change_prot_numa(struct vm_area_struct *vma, unsigned long start, unsigned long end); diff --git a/mm/mmap.c b/mm/mmap.c index 40248d84ad5f..d3c3c510f643 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -136,6 +136,22 @@ void vma_set_page_prot(struct vm_area_struct *vma) WRITE_ONCE(vma->vm_page_prot, vm_page_prot); } +/* + * Change backing file, only valid to use during initial VMA setup. + */ +struct file *vma_set_file(struct vm_area_struct *vma, struct file *file) +{ + if (file) + get_file(file); + + swap(vma->vm_file, file); + + if (file) + fput(file); + + return file; +} + /* * Requires inode->i_mapping->i_mmap_rwsem */ From patchwork Thu Oct 8 11:23:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11822661 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39BBA6CA for ; Thu, 8 Oct 2020 11:23:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DEC8221527 for ; Thu, 8 Oct 2020 11:23:50 +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="Cf1RVSf2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEC8221527 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 71D396B0068; Thu, 8 Oct 2020 07:23:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 67D2D6B006C; Thu, 8 Oct 2020 07:23:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51DEB6B0070; Thu, 8 Oct 2020 07:23:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0054.hostedemail.com [216.40.44.54]) by kanga.kvack.org (Postfix) with ESMTP id 1D7126B0068 for ; Thu, 8 Oct 2020 07:23:48 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B6F55181AE865 for ; Thu, 8 Oct 2020 11:23:47 +0000 (UTC) X-FDA: 77348523294.22.wind13_3e13502271d7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 968C018038E60 for ; Thu, 8 Oct 2020 11:23:47 +0000 (UTC) X-Spam-Summary: 1,0,0,4535747bb750a62b,d41d8cd98f00b204,ckoenig.leichtzumerken@gmail.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1534:1541:1593:1594:1676:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3874:5007:6261:6653:7875:7903:8603:9413:10004:10400:11026:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:13069:13311:13357:13894:14096:14097:14181:14394:14659:14687:14721:21080:21433:21444:21451:21627:21666:21740:30003:30054:30064,0,RBL:209.85.208.67:@gmail.com:.lbl8.mailshell.net-62.18.84.100 66.100.201.100;04ygqtiw35baagyt1j1b7kx94f7zropiqw1pupsi3kzaiyketjke18emoa4pesw.om6xaxnin586kw1b5geaf9a379ieufasis6m9n61d1kx65wqtq4htsbyewf7fzq.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: wind13_3e13502271d7 X-Filterd-Recvd-Size: 4758 Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Thu, 8 Oct 2020 11:23:47 +0000 (UTC) Received: by mail-ed1-f67.google.com with SMTP id v19so5426776edx.9 for ; Thu, 08 Oct 2020 04:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JsjjPHzjofiTjxIZU4zLpu7KElZkR0RdFNQVI4MgOuI=; b=Cf1RVSf2Wd5WKqBEQe/s36QG8XPfHBaG2UWWLmc7AROqUPPPQzryQaYWEUL3oqek8t bJAWEG3kKcAlgth9M38k2B/Nt+MG9IFqUTNhiYyms9eyVbvr8NcfwpPUj/XllhPiA0lR CEOK7HNJLYHG2ro7ZcBAavoxQL+en5L6fLiIqlSMlj8iywTFoAQE8nxzlrsyLbgjMxpi aofcNv/eTwnrxMk1doVKqyCl2Lzj63kYoISdf1LGyZfeO4qxt1PCfDKoVBAEDuVy+NFE Aa5I9mDCi/xhlOeDfBYRqyWBA93TrkNz+9HNhzXjHl+Z5vLOKICpcpqiYFyy5VDMaDh4 4ZPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JsjjPHzjofiTjxIZU4zLpu7KElZkR0RdFNQVI4MgOuI=; b=NTHmdCpZPVA1Wgc3uJ1zyW2nHWWVYD2CvoeW330hv+/9Hgyohvh5ikK9PoL5tJsfdf 6ArQ0NnORGJBFKXp9bDW5n2pY8ANwojjLY21nRLnSJYEJzm4TH4ymbMd/z/KaUaoB4fm YMPjr4XxMf2Qu1vF8XqSGDjpMLM0z32ZfECbk1SUtjJdvxBMJjgtcT7JsGIyKaFWEpFx p3RpTk2j0eszDLq/TAaYeuEv/iBXcUx77qYIevEy3Cl7JgXZtFowuSABYFVlejLZlF34 O0X3oXgMIl9U1E6KFikwO1n944oqAKfMlLRw1rtkvZskfE9AzdUTC9QfDWL/rrX/oJdN tKvA== X-Gm-Message-State: AOAM531btxfNXuPAq/j/4mpyC+THrZdnu4JaELf8TIfhYeKHyR8F3kX7 j3rX+GrpTFUlckZJzI7MguaIE3QutcE= X-Google-Smtp-Source: ABdhPJwDRyJHE6THipTubGPFIEhicDT26J0ZkLEqMYptkgqx4YSyy8HXoku93odOoEECNMopX74sdQ== X-Received: by 2002:aa7:c7c2:: with SMTP id o2mr8673537eds.366.1602156225590; Thu, 08 Oct 2020 04:23:45 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:4c64:a9a0:5e0:905a]) by smtp.gmail.com with ESMTPSA id i20sm3529030edv.96.2020.10.08.04.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 04:23:45 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= 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, daniel@ffwll.ch, sumit.semwal@linaro.org Subject: [PATCH 2/4] drm/prime: document that use the page array is deprecated Date: Thu, 8 Oct 2020 13:23:40 +0200 Message-Id: <20201008112342.9394-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008112342.9394-1-christian.koenig@amd.com> References: <20201008112342.9394-1-christian.koenig@amd.com> MIME-Version: 1.0 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: We have reoccurring requests on this so better document that this approach doesn't work and dma_buf_mmap() needs to be used instead. Signed-off-by: Christian König --- 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 page array * @sgt: scatter-gather table to convert - * @pages: optional array of page pointers to store the page array in + * @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_table * 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. */ int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, dma_addr_t *addrs, int max_entries) From patchwork Thu Oct 8 11:23:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11822663 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24F666CA for ; Thu, 8 Oct 2020 11:23:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C9444217BA for ; Thu, 8 Oct 2020 11:23:52 +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="N72ShT07" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9444217BA 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 2FD786B006C; Thu, 8 Oct 2020 07:23:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 289556B0070; Thu, 8 Oct 2020 07:23:49 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15082900002; Thu, 8 Oct 2020 07:23:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id DE6E06B006C for ; Thu, 8 Oct 2020 07:23:48 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7D847180AD806 for ; Thu, 8 Oct 2020 11:23:48 +0000 (UTC) X-FDA: 77348523336.06.glass91_4402d41271d7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 5A7A01003DB0A for ; Thu, 8 Oct 2020 11:23:48 +0000 (UTC) X-Spam-Summary: 1,0,0,c74d6df2b40b220d,d41d8cd98f00b204,ckoenig.leichtzumerken@gmail.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1381:1515:1516:1518:1534:1541:1593:1594:1676:1711:1714:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3351:3871:3876:5007:6261:6653:9413:10004:10400:11026:11657:11658:11914:12043:12048:12114:12296:12297:12438:12517:12519:12555:12895:13069:13311:13357:13894:14096:14097:14181:14394:14659:14687:14721:21080:21444:21451:21627:21666:21987:21990:30054:30064,0,RBL:209.85.218.66:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yf1r4hyrs75qefo8ukua35puk61oceqphwuqi9uxuosktkwskhfn1i7pcnwez.wjw78ywqym5huzk7m79niczphijx8pbs7njkcazb49sw153pnaj8kgcc7a71nt3.w-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: glass91_4402d41271d7 X-Filterd-Recvd-Size: 4436 Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Thu, 8 Oct 2020 11:23:47 +0000 (UTC) Received: by mail-ej1-f66.google.com with SMTP id ce10so7565591ejc.5 for ; Thu, 08 Oct 2020 04:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MkTgctKmN/+akcDLdg3dMFFDd8/FeV1m0XEzLiveir0=; b=N72ShT079eXQazlnE4442KsEjcieKGhUZ1afEO0IPorQavbqRU0ZxaG0ZRbxEyqGem Zx47TfD8/NAi6oQnUr7c9xV4sr2Q0DfHH0IQWtuJrGMGMWlcNSrD9Vqi3XLo1gbyiyAW DP9j8NEPbHN6ejO8Hh3Ike4eC8QhwNR3CK51RSGGTQNvIr6Cny38/8E7l1YYGbh7xtfj VfXDQxkNCUpazWHChb3RD62Au5iMbkOGIAv/dqXajlxntP8EdKjWnrjIth9+YtsGYOzo x80XrVVy20COvcFAhhLqdMyinw9dPHAw8BaZ5cq0nj8eZKj7sGLu9I04HzAvT1pG5zPs jorQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MkTgctKmN/+akcDLdg3dMFFDd8/FeV1m0XEzLiveir0=; b=fsoaEJLb7tTNeN0cDavKHtylKOUtyuyiKZ68lYfKTswH55VZ/Tqj2c7QYIAgAbagos U7SAMDfQN31XQPIkxg12f9jgNy131bCVron+9aLi0B2k6qdpiPWph8CiEdECFQ5L6h7B 74D4PAUseRGDCrgYrqOPbVhyS3JI2sMjCJPRDJcDeAqzZR6+sdIZF3DU0DAlHLsVaT+U 1kfk9GUOOQ7Y/hF8fhKq3bf9HHyRP75jNOoxTQWR08g1EvX9p0sIIxs+KIqd8UjV7Eu9 dV5GR7VyBrkq2TEedxnaHjqDoKtZopszGyNAPXJl+5XRRI4wn0ZG1P8aSmAh5YBbs0hz sqkQ== X-Gm-Message-State: AOAM5330Nu2pJHo/Wgs0eWJ6sJwL6oppYRuJRPPYf+hpWILn0+BE0Qbl Jz2i7qMScxAZleDqmYGlCl625YJYf9Y= X-Google-Smtp-Source: ABdhPJydc6wMYfotM6Ls7zhjsrHFWLvCwnPy4prHIfnBFnQVlWjXOhRunGbHJon/G6KJb7Y66ZUIsg== X-Received: by 2002:a17:906:7d7:: with SMTP id m23mr8424563ejc.47.1602156226681; Thu, 08 Oct 2020 04:23:46 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:4c64:a9a0:5e0:905a]) by smtp.gmail.com with ESMTPSA id i20sm3529030edv.96.2020.10.08.04.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 04:23:46 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= 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, daniel@ffwll.ch, sumit.semwal@linaro.org Subject: [PATCH 3/4] drm/radeon: stop using pages with drm_prime_sg_to_page_addr_arrays Date: Thu, 8 Oct 2020 13:23:41 +0200 Message-Id: <20201008112342.9394-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008112342.9394-1-christian.koenig@amd.com> References: <20201008112342.9394-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000011, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This is deprecated. Signed-off-by: Christian König --- drivers/gpu/drm/radeon/radeon_ttm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 63e38b05a5bc..4b92cdbcd29b 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -474,8 +474,8 @@ static int radeon_ttm_tt_pin_userptr(struct ttm_bo_device *bdev, struct ttm_tt * if (r) goto release_sg; - drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages, - gtt->ttm.dma_address, ttm->num_pages); + drm_prime_sg_to_page_addr_arrays(ttm->sg, NULL, gtt->ttm.dma_address, + ttm->num_pages); return 0; @@ -642,8 +642,9 @@ static int radeon_ttm_tt_populate(struct ttm_bo_device *bdev, } if (slave && ttm->sg) { - drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages, - gtt->ttm.dma_address, ttm->num_pages); + drm_prime_sg_to_page_addr_arrays(ttm->sg, NULL, + gtt->ttm.dma_address, + ttm->num_pages); ttm_tt_set_populated(ttm); return 0; } From patchwork Thu Oct 8 11:23:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11822667 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AC996CA for ; Thu, 8 Oct 2020 11:23:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BF8022145D for ; Thu, 8 Oct 2020 11:23:54 +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="oQGX/WsE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF8022145D 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 EE5856B0070; Thu, 8 Oct 2020 07:23:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E984A6B0071; Thu, 8 Oct 2020 07:23:49 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5BE46B0072; Thu, 8 Oct 2020 07:23:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id A803C6B0070 for ; Thu, 8 Oct 2020 07:23:49 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 479A11EE6 for ; Thu, 8 Oct 2020 11:23:49 +0000 (UTC) X-FDA: 77348523378.13.tent93_1208514271d7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 23F6218140B67 for ; Thu, 8 Oct 2020 11:23:49 +0000 (UTC) X-Spam-Summary: 1,0,0,a0d5def3d0a8cb0a,d41d8cd98f00b204,ckoenig.leichtzumerken@gmail.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1534:1541:1593:1594:1676:1711:1714:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3350:3866:3867:3868:3871:4250:4321:5007:6261:6653:9413:10004:10400:11026:11657:11658:11914:12043:12048:12114:12297:12438:12517:12519:12555:12895:12986:13069:13311:13357:13894:14096:14097:14181:14394:14659:14687:14721:21080:21433:21444:21451:21627:21666:21987:21990:30054:30064,0,RBL:209.85.208.66:@gmail.com:.lbl8.mailshell.net-62.18.84.100 66.100.201.100;04yr4jjecmegu9fb6g1q896jqfmzkoczyw5yk6qfp5csehfduwirg57zp8kb8us.1ja4wps5icgn45cmpinth8usgdsi3a47f7m8455goq4qpso16bnrnyyeckx38qe.k-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: tent93_1208514271d7 X-Filterd-Recvd-Size: 4421 Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 8 Oct 2020 11:23:48 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id x1so5457137eds.1 for ; Thu, 08 Oct 2020 04:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aQ0/dy64GNY6E3PqMvkOeCw7tku1OiiEuNnrmc12zf0=; b=oQGX/WsERCpgW2PogHIJy5UBog3JDnWJXgvx4OWfsN9DG11XTYcsi8LkNCKGUswsVJ I/ov2amMxLnqIS7y4T22v9Dpr4t+K5E5otszIUDv8ceaAoz9l1kOIpoAtfRbN0cW9vxW XoO6hAvzi/rD1B5/9Tib6A+YWTA/+ziwvMiiPNhRgQbJPSQ4i7ZPrHay6IredJCY7ywU oCXJOIQM3zfmTvuY/V4JGrac322do81ACOrYW/hQtAvN3pDSoZ8MvC7G8Yt1SQd6rg++ FljU/RLi97GP7ZDzZTA8xdONUTEzhdw0OqO//PQqjZc4QERaSl6M+ThTNtf645yCZnqg FSwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aQ0/dy64GNY6E3PqMvkOeCw7tku1OiiEuNnrmc12zf0=; b=C2/O5R0Hsz9lfdc3cyT133XYox708n3szwnx2kMIBhUStlJefL6JZd9V+KKgBPwe9X /qE+fOnzmPYTr142Gkr+5C3jxiWFM3NGKYGBtoOMYaL8O+kVlLmIh1lll//+q0dsI9Zt MjExGTADwuUpOP+RPx8DAykLVmzNlKj5Caj26mG0YlSXuqwKRpTyrmmVaOy7TENy6B5l hbaKEiW9zX1k0VtxbetFl+saB4J046wTp4pRS4hI8LT+G7HPsYLC6f7QuyOvePW1KO/b RNKl6dgFTYAespmUFEV1BGbRxRgzPrNEHuj5I1XP5qkDAzBBA4r0W7dQzojyd3MuFW57 GHQw== X-Gm-Message-State: AOAM531h9paWEY8hS3FpTFjBIEfQVzKz+r81TNbv/6+2c0rH4M8+nTld oD19aSE3r+3fCtpb6RT+y/NZD2hPakc= X-Google-Smtp-Source: ABdhPJyiM0N9wnzLQ1YaVSJXHnbIsEHI6Q6KUCzWN69nNbgBewaYrw2PtECQxiDDM9OMzbILYW8xFw== X-Received: by 2002:a05:6402:396:: with SMTP id o22mr8312612edv.361.1602156227564; Thu, 08 Oct 2020 04:23:47 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:4c64:a9a0:5e0:905a]) by smtp.gmail.com with ESMTPSA id i20sm3529030edv.96.2020.10.08.04.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 04:23:47 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= 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, daniel@ffwll.ch, sumit.semwal@linaro.org Subject: [PATCH 4/4] drm/amdgpu: stop using pages with drm_prime_sg_to_page_addr_arrays Date: Thu, 8 Oct 2020 13:23:42 +0200 Message-Id: <20201008112342.9394-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008112342.9394-1-christian.koenig@amd.com> References: <20201008112342.9394-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000906, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This is deprecated. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 399961035ae6..ac463e706b19 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1011,8 +1011,8 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_bo_device *bdev, goto release_sg; /* convert SG to linear array of pages and dma addresses */ - drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages, - gtt->ttm.dma_address, ttm->num_pages); + drm_prime_sg_to_page_addr_arrays(ttm->sg, NULL, gtt->ttm.dma_address, + ttm->num_pages); return 0; @@ -1345,7 +1345,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_bo_device *bdev, ttm->sg = sgt; } - drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages, + drm_prime_sg_to_page_addr_arrays(ttm->sg, NULL, gtt->ttm.dma_address, ttm->num_pages); ttm_tt_set_populated(ttm);