Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp646585imu; Fri, 7 Dec 2018 06:50:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/XHlctPoQrr/82oBhfQ+9P4iW5loLqI4qQZR/pUK1OW2Bvw/Hvv3KFpftVI6EtFH3FC70y1 X-Received: by 2002:a62:6e07:: with SMTP id j7mr2581937pfc.135.1544194210388; Fri, 07 Dec 2018 06:50:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544194210; cv=none; d=google.com; s=arc-20160816; b=feHqeiUYMUj10CgTT5USdvJxIQDzs9X1T6ScBKsZi/Iaj9HbZ0jJf4rRRA3qwlnnO3 NvY1YmeXTUomBMhAmexVSzWU4tUXZt64v25NcmErv9GLGFJqO9N5CJtUif+r6N99asBU nRD01XOuvK+ypwvyWnvJpX3v17M3fqqZFZ9LYhWk6M/mppjuujG1Mtf4MFGaEmFz+e7g aIDy5t05hropljhpMV9QmgxcLef9GxAnfgoIhEroJ6uDmpmZTSijoqsrOtKbNpLLaQgi 5iNdy4X9JiOYlXw/qZ84wi0jrGi7xdV0oo1e9XgNKIr+yTVL91GoNOgi3PJlxlo6UIxi lz7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=AkB0bsiH0OvOq6MNya7nH1YWvCNDfiGzj5SyoEeldGQ=; b=HrDrevnMxWQDWvQSuw8F+VFsRDnbb4JL0eVHxRA1aX+4UaRd4G376t3PBT9NgnEwC5 Vvpx4I/kvEZ0kzeRRi2V7wdp8V07eKdQiFbONikm/KH5pvD2auGjzNLhNySY5v5Q14XX Meg7PkKSDNUdwBImSP6qJTK3XI+dk1092GPm8AvabAHsVc580bTvI1jzx8UlYuNNR6Xz WiEJby+37+bHywzfu+YYP5KhMQoeymS1BizT4sqLgnBCeJh8HZVTrUELJBlNlRYEeAdb dpDkSr0ZOLjo2cmZpOBxTo7etDASwjcRnLAPTJaa7nSpwTqUZFNKLJlaObo60+Qdrcu/ KO2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=tIeIdANy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h91si3085233pld.411.2018.12.07.06.49.54; Fri, 07 Dec 2018 06:50:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=tIeIdANy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726137AbeLGOtD (ORCPT + 99 others); Fri, 7 Dec 2018 09:49:03 -0500 Received: from casper.infradead.org ([85.118.1.10]:36596 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbeLGOtD (ORCPT ); Fri, 7 Dec 2018 09:49:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To:From:Date:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AkB0bsiH0OvOq6MNya7nH1YWvCNDfiGzj5SyoEeldGQ=; b=tIeIdANyloOtPQhMGwbkZjnk4o yiwuxXqJljA5vEXK9Ao4obGg3E8W4tKWnpRTW6F5dHsR0LgJRVJ/ntAT1bvSshkvHvOZF11l8mTFo Pjw0WyyPc51uayUcbxLZiUDXyEW6ATkYEkc5tiHo3lRiwlojBxCQtIcR7ePMNzxxv6i2ieTSwUdeP 1I+7uw3uw6msN98Vx2d5aoMu2JIdecaIhlKTWsDhMgQz37oeSpHOAW1ugqcV0fh3qly57zUcjj1qa MRg2QzypqZz/mxnolaJCWKCIcjzID+2nT35B5dQfouNmvSmL2i0QaBSWT5ELbqaQsd0U54Lvev+ic sqY0W4Cg==; Received: from [179.95.33.236] (helo=coco.lan) by casper.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVHR2-0005dK-Oj; Fri, 07 Dec 2018 14:48:57 +0000 Date: Fri, 7 Dec 2018 12:48:51 -0200 From: Mauro Carvalho Chehab To: Souptick Joarder Cc: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, pawel@osciak.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181207124851.3eef28a0@coco.lan> In-Reply-To: <20181206184438.GA31370@jordon-HP-15-Notebook-PC> References: <20181206184438.GA31370@jordon-HP-15-Notebook-PC> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, 7 Dec 2018 00:14:38 +0530 Souptick Joarder escreveu: > Convert to use vm_insert_range to map range of kernel memory > to user vma. > > Signed-off-by: Souptick Joarder > Reviewed-by: Matthew Wilcox > Acked-by: Marek Szyprowski It probably makes sense to apply it via mm tree, together with patch 1. So: Acked-by: Mauro Carvalho Chehab > --- > drivers/media/common/videobuf2/videobuf2-dma-sg.c | 23 +++++++---------------- > 1 file changed, 7 insertions(+), 16 deletions(-) > > diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c > index 015e737..898adef 100644 > --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c > +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c > @@ -328,28 +328,19 @@ static unsigned int vb2_dma_sg_num_users(void *buf_priv) > static int vb2_dma_sg_mmap(void *buf_priv, struct vm_area_struct *vma) > { > struct vb2_dma_sg_buf *buf = buf_priv; > - unsigned long uaddr = vma->vm_start; > - unsigned long usize = vma->vm_end - vma->vm_start; > - int i = 0; > + unsigned long page_count = vma_pages(vma); > + int err; > > if (!buf) { > printk(KERN_ERR "No memory to map\n"); > return -EINVAL; > } > > - do { > - int ret; > - > - ret = vm_insert_page(vma, uaddr, buf->pages[i++]); > - if (ret) { > - printk(KERN_ERR "Remapping memory, error: %d\n", ret); > - return ret; > - } > - > - uaddr += PAGE_SIZE; > - usize -= PAGE_SIZE; > - } while (usize > 0); > - > + err = vm_insert_range(vma, vma->vm_start, buf->pages, page_count); > + if (err) { > + printk(KERN_ERR "Remapping memory, error: %d\n", err); > + return err; > + } > > /* > * Use common vm_area operations to track buffer refcount. Thanks, Mauro