From patchwork Fri Oct 2 17:53:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11814365 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 D3236618 for ; Fri, 2 Oct 2020 17:53:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96914208C7 for ; Fri, 2 Oct 2020 17:53:45 +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="GdOd/VH/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96914208C7 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 E59336B005D; Fri, 2 Oct 2020 13:53:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DE0D26B0062; Fri, 2 Oct 2020 13:53:44 -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 CA8F46B0068; Fri, 2 Oct 2020 13:53:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id 9B6E16B005D for ; Fri, 2 Oct 2020 13:53:44 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4699B1EF1 for ; Fri, 2 Oct 2020 17:53:44 +0000 (UTC) X-FDA: 77327733168.22.death96_541087f271a6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 1D1A218038E60 for ; Fri, 2 Oct 2020 17:53:44 +0000 (UTC) X-Spam-Summary: 1,0,0,6b6350560747ebe2,d41d8cd98f00b204,daniel.vetter@ffwll.ch,,RULES_HIT:2:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1431:1437:1515:1535:1606:1730:1747:1777:1792:1801:2196:2198:2199:2200:2393:2559:2562:2897:3138:3139:3140:3141:3142:3355:3865:3866:3867:3871:3872:3874:4119:4321:4385:4605:5007:6117:6261:6653:6742:6743:7514:7903:8603:9036:10004:11026:11473:11657:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:12986:13846:13894:14096:14394:21080:21324:21444:21451:21627:21773:21795:21990:30003:30034:30051:30054:30064,0,RBL:209.85.128.65:@ffwll.ch:.lbl8.mailshell.net-66.201.201.201 62.14.0.100;04y8apq7ua537e79ofos6c6zd5eatycz3a71kex95pew8zbpwxdbyokwo6feq7k.phgeungep1h1w7qjqebpa35fg47ec4w5bgshttyr4pz7d7xpegwhrsuo6j7a9y9.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:117,LUA_SUMMARY:none X-HE-Tag: death96_541087f271a6 X-Filterd-Recvd-Size: 8390 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Fri, 2 Oct 2020 17:53:43 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id w2so2495320wmi.1 for ; Fri, 02 Oct 2020 10:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4Ic9kLI7iEmx4fzg6K/MGmVs8Kbr/xz3cK5mQ8gVn9M=; b=GdOd/VH/FT5eF5Gfj5Q1p9o3Vy+IUnorHd0BlnwOL9uxqZXuqaW6hM5SPvXVoCliFo bYTAnUT5U/MmyPZiyzSRP+mItblvHt3dnKeVQamNmGl1Wkstvlwhpe9QI+eMQwsUSnFG vCIrvzCfJM5d8ZpALwF1YBf+lWT2Rg+eoosfY= 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:mime-version :content-transfer-encoding; bh=4Ic9kLI7iEmx4fzg6K/MGmVs8Kbr/xz3cK5mQ8gVn9M=; b=UYok959U8RFmftkgdkp4FP3I1lY9VvqFmFele7qQ6PPxIxQQ885rA3k3Ir1yL05pEl IIUHqLqljPqjmR6mZHHeLGKz2xWihlprG78srScr2VQQYTX5GWnMMhPcKdYWfwR5Gq41 +7t5KOnS3lxU/wdhjuzOyxbQ0E2QPmyiGo+SkPQaiODVhNWpzsBkFo9drJOEX5rsFbVh 8rE8mQkIk1IB0vlqq4orn1m/ElGHl2eiSEhPoLvlvTMmZn3IV/31MvgEgf6DzrrbhA/1 q/qHl9158xHKgBxRsh3jP5U9VvL0k3qShlqOymTX5g5IjtNCNgNwD0bM+k8klbSnhs0S 8w+g== X-Gm-Message-State: AOAM532GrasvTBc+CdYDhU2tp88Ks80HRr0eSIfq+e8TL83v+tYlK9CS hcCZDvje1LcFic+d9f7zOUjoag== X-Google-Smtp-Source: ABdhPJx4N0mByTSrMhoszno9AheTX2LZ7oZ+iqT+Q3TvlZQuWl0+xgzy8x8+JKsZ5hS5NTaTlr3Xeg== X-Received: by 2002:a7b:cf1a:: with SMTP id l26mr4030327wmg.164.1601661221643; Fri, 02 Oct 2020 10:53:41 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id m10sm2585429wmc.9.2020.10.02.10.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 10:53:40 -0700 (PDT) From: Daniel Vetter To: DRI Development Cc: LKML , Daniel Vetter , Daniel Vetter , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Kukjin Kim , Krzysztof Kozlowski , Pawel Osciak , Marek Szyprowski , Tomasz Figa , Andrew Morton , Oded Gabbay , Omer Shpigelman , Tomer Tayar , Greg Kroah-Hartman , Pawel Piskorski , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-media@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/2] mm/frame-vec: Drop gup_flags from get_vaddr_frames() Date: Fri, 2 Oct 2020 19:53:02 +0200 Message-Id: <20201002175303.390363-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.28.0 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: FOLL_WRITE | FOLL_FORCE is really the only reasonable thing to do for simple dma device that can't guarantee write protection. Which is also what all the callers are using. So just simplify this. Signed-off-by: Daniel Vetter Cc: Inki Dae Cc: Joonyoung Shim Cc: Seung-Woo Kim Cc: Kyungmin Park Cc: Kukjin Kim Cc: Krzysztof Kozlowski Cc: Pawel Osciak Cc: Marek Szyprowski Cc: Tomasz Figa Cc: Andrew Morton Cc: Oded Gabbay Cc: Omer Shpigelman Cc: Tomer Tayar Cc: Greg Kroah-Hartman Cc: Pawel Piskorski Cc: linux-arm-kernel@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org Cc: linux-media@vger.kernel.org Cc: linux-mm@kvack.org Acked-by: Tomasz Figa Acked-by: Oded Gabbay --- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 3 +-- drivers/media/common/videobuf2/videobuf2-memops.c | 3 +-- drivers/misc/habanalabs/common/memory.c | 3 +-- include/linux/mm.h | 2 +- mm/frame_vector.c | 4 ++-- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index 967a5cdc120e..ac452842bab3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -480,8 +480,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct g2d_data *g2d, goto err_free; } - ret = get_vaddr_frames(start, npages, FOLL_FORCE | FOLL_WRITE, - g2d_userptr->vec); + ret = get_vaddr_frames(start, npages, g2d_userptr->vec); if (ret != npages) { DRM_DEV_ERROR(g2d->dev, "failed to get user pages from userptr.\n"); diff --git a/drivers/media/common/videobuf2/videobuf2-memops.c b/drivers/media/common/videobuf2/videobuf2-memops.c index 6e9e05153f4e..9dd6c27162f4 100644 --- a/drivers/media/common/videobuf2/videobuf2-memops.c +++ b/drivers/media/common/videobuf2/videobuf2-memops.c @@ -40,7 +40,6 @@ struct frame_vector *vb2_create_framevec(unsigned long start, unsigned long first, last; unsigned long nr; struct frame_vector *vec; - unsigned int flags = FOLL_FORCE | FOLL_WRITE; first = start >> PAGE_SHIFT; last = (start + length - 1) >> PAGE_SHIFT; @@ -48,7 +47,7 @@ struct frame_vector *vb2_create_framevec(unsigned long start, vec = frame_vector_create(nr); if (!vec) return ERR_PTR(-ENOMEM); - ret = get_vaddr_frames(start & PAGE_MASK, nr, flags, vec); + ret = get_vaddr_frames(start & PAGE_MASK, nr, vec); if (ret < 0) goto out_destroy; /* We accept only complete set of PFNs */ diff --git a/drivers/misc/habanalabs/common/memory.c b/drivers/misc/habanalabs/common/memory.c index 5ff4688683fd..43b10aee8150 100644 --- a/drivers/misc/habanalabs/common/memory.c +++ b/drivers/misc/habanalabs/common/memory.c @@ -1287,8 +1287,7 @@ static int get_user_memory(struct hl_device *hdev, u64 addr, u64 size, return -ENOMEM; } - rc = get_vaddr_frames(start, npages, FOLL_FORCE | FOLL_WRITE, - userptr->vec); + rc = get_vaddr_frames(start, npages, userptr->vec); if (rc != npages) { dev_err(hdev->dev, diff --git a/include/linux/mm.h b/include/linux/mm.h index 16b799a0522c..7d14aa2780d2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1757,7 +1757,7 @@ struct frame_vector { struct frame_vector *frame_vector_create(unsigned int nr_frames); void frame_vector_destroy(struct frame_vector *vec); int get_vaddr_frames(unsigned long start, unsigned int nr_pfns, - unsigned int gup_flags, struct frame_vector *vec); + struct frame_vector *vec); void put_vaddr_frames(struct frame_vector *vec); int frame_vector_to_pages(struct frame_vector *vec); void frame_vector_to_pfns(struct frame_vector *vec); diff --git a/mm/frame_vector.c b/mm/frame_vector.c index 10f82d5643b6..5d34c9047e9c 100644 --- a/mm/frame_vector.c +++ b/mm/frame_vector.c @@ -12,7 +12,6 @@ * get_vaddr_frames() - map virtual addresses to pfns * @start: starting user address * @nr_frames: number of pages / pfns from start to map - * @gup_flags: flags modifying lookup behaviour * @vec: structure which receives pages / pfns of the addresses mapped. * It should have space for at least nr_frames entries. * @@ -32,10 +31,11 @@ * This function takes care of grabbing mmap_lock as necessary. */ int get_vaddr_frames(unsigned long start, unsigned int nr_frames, - unsigned int gup_flags, struct frame_vector *vec) + struct frame_vector *vec) { struct mm_struct *mm = current->mm; struct vm_area_struct *vma; + unsigned int gup_flags = FOLL_WRITE | FOLL_FORCE; int ret = 0; int err; int locked;