From patchwork Mon Sep 14 13:29:19 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: 11773773 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 B3AF7618 for ; Mon, 14 Sep 2020 13:29:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 615AA207BB for ; Mon, 14 Sep 2020 13:29:34 +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="pUG+6EgL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 615AA207BB 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 34A73900004; Mon, 14 Sep 2020 09:29:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3217D900002; Mon, 14 Sep 2020 09:29:32 -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 20FF4900004; Mon, 14 Sep 2020 09:29:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 0DCBF900002 for ; Mon, 14 Sep 2020 09:29:32 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BD5901802912B for ; Mon, 14 Sep 2020 13:29:31 +0000 (UTC) X-FDA: 77261748942.14.berry27_2610cbe27109 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 926BE18229835 for ; Mon, 14 Sep 2020 13:29:31 +0000 (UTC) X-Spam-Summary: 1,0,0,a0cc7a717dea3128,d41d8cd98f00b204,ckoenig.leichtzumerken@gmail.com,,RULES_HIT:41:152:355:379:541:800:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1540:1568:1593:1594:1676:1711:1714:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3865:3867:3871:5007:6261:6653:9413:9592:10004:10400:11026:11658:11914:12043:12109:12297:12438:12517:12519:12555:12895:13069:13311:13357:13894:14181:14394:14659:14687:14721:21080:21444:21451:21627:21666:21789:21990:30054:30064,0,RBL:209.85.208.66:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.84.100;04yfjo35zwc4zkhqhcjubgqpxpuwjopkzqeksu19m6pkcdenkms1ramn6zib44c.rmhxxhaxu495swppfhsnsa8t4fs45o51iwqrubc4oq73sbdfrn47b84ig3k9bd9.s-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: berry27_2610cbe27109 X-Filterd-Recvd-Size: 4079 Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Sep 2020 13:29:31 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id c8so17613429edv.5 for ; Mon, 14 Sep 2020 06:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ShM3ina3e3/hH7dOyVac4CL9sFVc4RQd6mh3jLnIlg0=; b=pUG+6EgLO2UPiBn6Yk4D2WmMQ/2yB7GdzCr1j99p7omOVBGUkd7OME2Fcch33BqK1h kRoISKMKO5KS64Eoe/fHBFeNwV6nFMzIKjBkMfXBmA4CS+3/ttEr8EbhVHNz9ZsbSKC+ tYgEBRJJqVRXOcxWBasjfP0giKeqzan4zln/A47HPqfQB6JFTqJfBGpbRUO/fyQwbUal UdqQUeN+a9jSnmr+R3MdQ6PbF9DaVnJ+dE5LVNIofNGl83vr4fPPxwNAhIod4K+nZZ4S S/jizlrTm17N+FilPGRnJONY9iEJiG9iXj+/8ipwpTSCARh5J35nyMCPQkiynXVYWbZ+ uZLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ShM3ina3e3/hH7dOyVac4CL9sFVc4RQd6mh3jLnIlg0=; b=ElJUe8jhcakhcrIYDAzRYYUY5xagcTqBErGbchCwV8miOZEVA1AdoZA/wpHWpxZQcB Z4VzQWl4y0Lv22XLc1Me5e0myq5PjUp+baMKeeRFE3zVvSd/ogbwkdaB5my58pfwxKYT M/0NSaoLY+JA9m83BZQ3dHgzpRopp4wAGFQReXvDl5RVT1iQRGQ4r0ZrR63sh8bcTYrA yXurA1DZPew0AxMq3g36Ffa4MmcW3jmd9kisrS9r2SgqBWmLoZsRJBsZxdw0pIZ3AJxf d3bKFWhzYK9SWhpYCwDc8/0gXPvOdTejKPhdRIlDRWSPWH3etLEZ7N2ac7RZJHWHuVIc ChLg== X-Gm-Message-State: AOAM533U30jY8g9yVQ8mFoUwiyL+b0Q8WZe/rXN/TcV4M5jAYM3r4njW fQbbHtQhJ4ncxGXiyzE+fm8= X-Google-Smtp-Source: ABdhPJxDNWaaOe6mtDbVu9uBxPuALA0/yZsLGV/qaVVWO83ofnwCuhSwypEKZj15QfAv8gcowcwWvA== X-Received: by 2002:a05:6402:17b9:: with SMTP id j25mr17411290edy.203.1600090170135; Mon, 14 Sep 2020 06:29:30 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:6179:d701:8021:da3d]) by smtp.gmail.com with ESMTPSA id d6sm9575625edm.31.2020.09.14.06.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 06:29:29 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: akpm@linux-foundation.org Cc: sumit.semwal@linaro.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/2] drm/shmem-helpers: revert "Redirect mmap for imported dma-buf" Date: Mon, 14 Sep 2020 15:29:19 +0200 Message-Id: <20200914132920.59183-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914132920.59183-1-christian.koenig@amd.com> References: <20200914132920.59183-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 926BE18229835 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001271, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This reverts commit 26d3ac3cb04d171a861952e89324e347598a347f. We need to figure out if dma_buf_mmap() is valid or not first. Signed-off-by: Christian König --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 0a952f27c184..cd727343f72b 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -594,9 +594,6 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) /* Remove the fake offset */ vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node); - if (obj->import_attach) - return dma_buf_mmap(obj->dma_buf, vma, 0); - shmem = to_drm_gem_shmem_obj(obj); ret = drm_gem_shmem_get_pages(shmem); From patchwork Mon Sep 14 13:29:20 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: 11773779 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 C89AB618 for ; Mon, 14 Sep 2020 13:29:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 70153208E4 for ; Mon, 14 Sep 2020 13:29:53 +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="LNYaV5ht" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70153208E4 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 9FFD1900007; Mon, 14 Sep 2020 09:29:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9B07A900002; Mon, 14 Sep 2020 09:29:52 -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 8C6A4900007; Mon, 14 Sep 2020 09:29:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 74335900002 for ; Mon, 14 Sep 2020 09:29:52 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1614C6EDFC for ; Mon, 14 Sep 2020 13:29:52 +0000 (UTC) X-FDA: 77261749824.17.low66_58101c227109 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 11A8A18034F4A for ; Mon, 14 Sep 2020 13:29:33 +0000 (UTC) X-Spam-Summary: 1,0,0,0c321bd2e6717b54,d41d8cd98f00b204,ckoenig.leichtzumerken@gmail.com,,RULES_HIT:41:69:152:355:379:541:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1535:1542:1593:1594:1676:1711:1730:1747:1777:1792:2393:2559:2562:2899:3138:3139:3140:3141:3142:3353:3865:3867:4250:4321:4605:5007:6261:6653:9413:10004:10400:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:12986:13894:14096:14097:14181:14394:14659:14687:14721:21080:21444:21451:21627:21666:21990:30054:30064:30069:30070,0,RBL:209.85.208.66:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.84.100;04y85x65a6oredsyit6unwgf94gmtop6yoz4anz3j4qp1h8akk587yt1x699moq.e1358w4ti3kqhub83wb9un18xwa4xkqefogyop14cnfqbimt1gs1aehmanzd4qj.4-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: low66_58101c227109 X-Filterd-Recvd-Size: 5403 Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Sep 2020 13:29:32 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id b12so17571175edz.11 for ; Mon, 14 Sep 2020 06:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2sgKFqAzyYTWFS7DpgNkPf7xuqkExWpe0vtA6hya4p8=; b=LNYaV5htN1AoGcRr3qutKAdIAJ9K2NpHJmZnCLnFDlG8+zhSr8pFBVrIVZbK7upLCy XuYIA5pbVz06HyYiXjA0CX8OrBfsP8QYVTX6yJ60VAjafiTzs3Dr1q7h1S6WN1SGAvlY UXlmfxZ5/aBJS18uzwRmNUI3/lYVMDzcdWcPZzIRtlGG2B6QiV90AnQEfAOpca3J5cuM fi/i79PCqkzlb/1pkXfPwtPFhCm+AEfUwe9iWPeCcG3ahwbSU9PfGzYe8A8PulfEuuIe /yCSNERBUwZ4Herw4m2hVxb+aHQ2rdJcpWKX6iPZoqfXgRCIkWGGqsSIIr4ud7pRIc3R 2DEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2sgKFqAzyYTWFS7DpgNkPf7xuqkExWpe0vtA6hya4p8=; b=jD/+3XSfknSkSSzzJZr8CKgpiBDkfts1Oa7a2aCWfe/UcvgeWNqTKXNO6u+8tps0VE 8zXyYFriVRFOB8HZTkr0MGu5FNEOLit5A0iqEM6IQsuLlskfy8AE2+WQ/cAsbVaw2JoX F+8OTf6Lu4ChwQ8KgtkdFDAO9M+jC+lkno2T6rJIw4fQkGMXWEFtnJSXy7gvZaJjv5lY Mc2Ry7f1ouu/7q1fWyEZDp0XIGPIlsZJqd/WzD8h70sevh63+6TiaLRKYFBkk1pAx9rA DicwjEsZt4F0CK03k60Fn80KQZa+e1wnk7Z+H+S5cIbmy1l9abA+QmSr5vKT/2vKOpJB YWSw== X-Gm-Message-State: AOAM533+UsgUIUC3m5C+id1jn4pqcOCXFSu3iKalPkKbNeZvdPWxDvOi HeQ0pcz5fcCzUIwvvAk0WhM= X-Google-Smtp-Source: ABdhPJwqz+YzShnzPAVkh+LgWPDH996EZ9R5Asg2qCZETs+L6ijZw4dfeniXkQwebJgtgDxC1+lltA== X-Received: by 2002:aa7:cad3:: with SMTP id l19mr16523629edt.352.1600090171724; Mon, 14 Sep 2020 06:29:31 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:6179:d701:8021:da3d]) by smtp.gmail.com with ESMTPSA id d6sm9575625edm.31.2020.09.14.06.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 06:29:30 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: akpm@linux-foundation.org Cc: sumit.semwal@linaro.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/2] mm: introduce vma_set_file function Date: Mon, 14 Sep 2020 15:29:20 +0200 Message-Id: <20200914132920.59183-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914132920.59183-1-christian.koenig@amd.com> References: <20200914132920.59183-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 11A8A18034F4A X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, 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. Signed-off-by: Christian König Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/dma-buf/dma-buf.c | 16 +++++----------- include/linux/mm.h | 2 ++ mm/mmap.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 1699a8e309ef..672f3525ba74 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/include/linux/mm.h b/include/linux/mm.h index 1983e08f5906..398a6fdaad1e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2688,6 +2688,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 */