From patchwork Mon Dec 24 13:20:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A4E513B5 for ; Mon, 24 Dec 2018 13:16:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85B8028AD4 for ; Mon, 24 Dec 2018 13:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 771E328B01; Mon, 24 Dec 2018 13:16:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0ECA428AD4 for ; Mon, 24 Dec 2018 13:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=XH/iOSsdcHrvToiNUWFpvguu+1Z6+Y/xIsmwRaHGcZw=; b=oAyr8VFqvdBjL5 ApiM2WEulZPN0zX1JVbkPHfb12SSD61uDlEFcxONG90uTONVHaEJG3CNv+lGVQdcjzzhDxJxcSr4f +miHMSCqwRuH45SF/js4m2e1xTGDGTtSjvZQBkYsLHt7yg3yf4apxKWp6Y2TyPOJ1EqdGgQx1F6ca SbseVdajNstHxKJrSf74+eEg0oXtBIRpkpwyye7stc+2A1oRuQEvfjm4cJKZaiN6vgfh0jaCKGUZB AQzVR3r1gb0RqAztJOPR/9EzRFB72nI3ZHlGEVYEe+qOAyo8rpFfvuzlyvUhVVsA73lFpRAWHKKMz yh/gII0ijJM/YlgoIS2Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbQ6F-0002Ya-1W; Mon, 24 Dec 2018 13:16:51 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbQ6A-0002X5-Nx; Mon, 24 Dec 2018 13:16:48 +0000 Received: by mail-pl1-x643.google.com with SMTP id g9so5593162plo.3; Mon, 24 Dec 2018 05:16:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=LP5lsofdni2cSLjgAraOzOMBqzsN96J57RYIndiS9eY=; b=qM6wO8wXOsTCCQjmN5W2bh1Yc6f8aW1WDDjGj9PbWNWc2o79ATdhag+oaoZPNPzt6K ma0RAy9eFNdLoLaz9htzWNODQWdvDKW7joEPPAdI4N9ZNw04c82tpSKjho+qWDoRBeIH N1p9vHkj4DPmaFcBQk35HegJ83jO83edL9GgOg2ErX3ZZ+XvYXqoDlEmwPT6wa3imIT0 T1nCoqL5yFy5XNreHjeoMzrX+u5MwKvIQ8ttnzIFgFzU52htaKbK9ggMZ02hlyAc4nzQ IqLSm1jXGOTu+uTZeYmteZ8VUjbr6oMUx31ohJHf9UUTLFfcMN9bGnJn5P9wRpIyKK87 nFGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=LP5lsofdni2cSLjgAraOzOMBqzsN96J57RYIndiS9eY=; b=oGc65CtSXQaeq1kmW8XkQ2/tEMSg7BtakVx8Ff9WPFq494bTgMcptNwfNFqdRvff/t rQ2C72ZYIjbb90jSXMA3ydvtaAA3920vyjNgRgU3fB8M+IqxyZaShUSA285Xmn6Dmp27 YGGrBOq01QT4w2sganLTfUVpHB1RyN6bg7b+7rPVTg1Yy3TsOWB+U2otID0PDCVmSqfu sfDFcENbRwKDI6E8a4kcfL+Feujgyw4ElBx4moNdlboNoEsHYWQm6eruFalUI0yY7muz Wn3cGxBL3PgHuhvHfNLHLkjziY0DxANObyuM2WD4GyqM/swdKZkjSSNET1LSWnNuAO1T MX+A== X-Gm-Message-State: AJcUukcIyUXljs+YwgGhbH2Lx6vU2EkDywFcvC94VXBNulU3RudaWrmM ZcTY2igEnV4xRBU/mn6FD7g= X-Google-Smtp-Source: ALg8bN7wOSrZcfXhzYNZV0rUN+/7d8bG9BYL8F6X7CbsAJiBB+mCxvpTDoGJWLYuM5s39NiTv+v4ng== X-Received: by 2002:a17:902:4025:: with SMTP id b34mr13074182pld.181.1545657395486; Mon, 24 Dec 2018 05:16:35 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id n22sm59491886pfh.166.2018.12.24.05.16.33 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:16:34 -0800 (PST) Date: Mon, 24 Dec 2018 18:50:31 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, kirill.shutemov@linux.intel.com, vbabka@suse.cz, riel@surriel.com, sfr@canb.auug.org.au, rppt@linux.vnet.ibm.com, peterz@infradead.org, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com, stefanr@s5r6.in-berlin.de, hjc@rock-chips.com, heiko@sntech.de, airlied@linux.ie, oleksandr_andrushchenko@epam.com, joro@8bytes.org, pawel@osciak.com, kyungmin.park@samsung.com, mchehab@kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com Subject: [PATCH v5 1/9] mm: Introduce new vm_insert_range API Message-ID: <20181224132031.GA22051@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181224_051646_784776_6E4AA389 X-CRM114-Status: GOOD ( 16.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xen.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, linux1394-devel@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking vm_insert_page() within a loop. As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers. vm_insert_range is the new API which will be used to map a range of kernel memory/pages to user vma. This API is tested by Heiko for Rockchip drm driver, on rk3188, rk3288, rk3328 and rk3399 with graphics. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Reviewed-by: Mike Rapoport Reviewed-by: Mauro Carvalho Chehab Tested-by: Heiko Stuebner --- include/linux/mm.h | 2 ++ mm/memory.c | 41 +++++++++++++++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 50 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index fcf9cc9..2bc399f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2506,6 +2506,8 @@ unsigned long change_prot_numa(struct vm_area_struct *vma, int remap_pfn_range(struct vm_area_struct *, unsigned long addr, unsigned long pfn, unsigned long size, pgprot_t); int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count); vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn); vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, diff --git a/mm/memory.c b/mm/memory.c index 15c417e..d44d4a8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1478,6 +1478,47 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, } /** + * vm_insert_range - insert range of kernel pages into user vma + * @vma: user vma to map to + * @addr: target user address of this page + * @pages: pointer to array of source kernel pages + * @page_count: number of pages need to insert into user vma + * + * This allows drivers to insert range of kernel pages they've allocated + * into a user vma. This is a generic function which drivers can use + * rather than using their own way of mapping range of kernel pages into + * user vma. + * + * If we fail to insert any page into the vma, the function will return + * immediately leaving any previously-inserted pages present. Callers + * from the mmap handler may immediately return the error as their caller + * will destroy the vma, removing any successfully-inserted pages. Other + * callers should make their own arrangements for calling unmap_region(). + * + * Context: Process context. Called by mmap handlers. + * Return: 0 on success and error code otherwise + */ +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count) +{ + unsigned long uaddr = addr; + int ret = 0, i; + + if (page_count > vma_pages(vma)) + return -ENXIO; + + for (i = 0; i < page_count; i++) { + ret = vm_insert_page(vma, uaddr, pages[i]); + if (ret < 0) + return ret; + uaddr += PAGE_SIZE; + } + + return ret; +} +EXPORT_SYMBOL(vm_insert_range); + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page diff --git a/mm/nommu.c b/mm/nommu.c index 749276b..d6ef5c7 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_page); +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count) +{ + return -EINVAL; +} +EXPORT_SYMBOL(vm_insert_range); + /* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty From patchwork Mon Dec 24 13:21:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7363713B5 for ; Mon, 24 Dec 2018 13:18:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60ADC28AAF for ; Mon, 24 Dec 2018 13:18:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54CB128AD4; Mon, 24 Dec 2018 13:18:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0A55F28AAF for ; Mon, 24 Dec 2018 13:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Q5eRZzflgUxPZYzm6dyV+RmY5SIqYDQONZafcycsS20=; b=qfS5IXTO5WfALB WqlYYs2WGIrqZaPDFAkJuBYqj+rdEUEzsSBfV+ZUTGvMHK5iseLgN4SfY0jtl4tcjTdvPrsnBgWSh 5XOXCrBMBtqB9G2yZn4Ul+Pb9pXbwc251f21z3NrvjJe8B4kKaaJaHxpHO5tlZq1Kv7RKKzbPVQ+X oSWiP6eXsOA8NXLy1gY0hURlRBQxY5Pzjjm80hQDNiy28+x8r3+LDCPKoSRpXOI1XK1lFLF3ZaXj6 5fx4HakpYfVbphw8Ii6hAFeIk4G298iydXN0GMbVpGuYNapUZaLqjNQCp/OKp/uZ6/aD77JRAu13k MmjsTEr7pcEyTSlBQb2A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbQ7M-00033N-Me; Mon, 24 Dec 2018 13:18:00 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbQ7J-00032F-Kk for linux-arm-kernel@lists.infradead.org; Mon, 24 Dec 2018 13:17:58 +0000 Received: by mail-pf1-x443.google.com with SMTP id h3so5812842pfg.1 for ; Mon, 24 Dec 2018 05:17:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=MMGJzHhmNthI9sRZkbXZ1iYyH2jshJ0o/VQkgO88tcs=; b=i2KO5MMxJo3/5LWrPLeNLGeva3Ne1DqGYNQmkVfffqJy/7Blwc1ZQTxF5q7/4cdbVK vIexInnWRoT/V11j7MMRf8p2pNk7N6+FKaVdWJPsVT0PJ7MRGJWCmKDRYYVgzm9PVFZR 7Kz4JADaRzoTvV+K+ajZHPtgb0txgVU5jA3CliuIeqyf9MC+6XxOOcepTV0uLQH9GDeU B5bw7Mj0iLy6LrkPqE9j4pev1wfm6d67jrKNbReUFngf1M0upuqrGUYdICcRDO0tsAEw f+JmsDBaFgTBiSI+JannbW3PzQBDJacAB8VRitF1ub03PgJ8p0gttKrXb8wKIRMKAK35 /Ikg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=MMGJzHhmNthI9sRZkbXZ1iYyH2jshJ0o/VQkgO88tcs=; b=QQAvy0W7QmWPassPfxpTbKDTM9sRBQpPFx9g0phxajbd+urhc8gilSAIcQsRAGmzMY Opi8t7xWD1+TEiEHpYKDtvK6lZ5Och6vawQ3WO0ZhsFyNj/5LcVWEU0BfqDbrkXfYyS6 PGo6bpVoQQ5/AfdOjZvRSIMlZWo/FuCN3HcSlv2Iozzemervyfg15IIQcRKaYrkpghGa XvzskYUVXdH3n5qmnkISlq3SbnxWxBxtjpN8rkDPw6j+An6qYz05aBcQgewsRw4RleFe qgHw2H671aLbOiLPAmX4DycEdM52FFGyZMNVIY7W64vOFYeqKWsZUIqVQsqZeRuugdPs Um4Q== X-Gm-Message-State: AA+aEWaB6PBnvl0muzAV4l4Cz4a/Wrqu7VyEu02g2awsOOlqNWDZS57Z 0wxNiENt/srOkmW3fBy/mFfc1Jk5 X-Google-Smtp-Source: AFSGD/UmasEKtYGJVvYE7ECLRPqA3+g1rUsYqcP4hh5vWWnPBQkurqM+K4wJcBIT4twxElNbufrYjA== X-Received: by 2002:a62:e0d8:: with SMTP id d85mr12901342pfm.214.1545657466691; Mon, 24 Dec 2018 05:17:46 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id c23sm39254231pfi.83.2018.12.24.05.17.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:17:45 -0800 (PST) Date: Mon, 24 Dec 2018 18:51:42 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com Subject: [PATCH v5 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181224132142.GA22070@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181224_051757_684664_40379F00 X-CRM114-Status: GOOD ( 14.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder --- arch/arm/mm/dma-mapping.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 661fe48..63467b6 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1582,11 +1582,12 @@ static int __arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma void *cpu_addr, dma_addr_t dma_addr, size_t size, unsigned long attrs) { - unsigned long uaddr = vma->vm_start; unsigned long usize = vma->vm_end - vma->vm_start; + unsigned long page_count = vma_pages(vma); struct page **pages = __iommu_get_pages(cpu_addr, attrs); unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; unsigned long off = vma->vm_pgoff; + int err; if (!pages) return -ENXIO; @@ -1595,18 +1596,11 @@ static int __arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma return -ENXIO; pages += off; + err = vm_insert_range(vma, vma->vm_start, pages, page_count); + if (err) + pr_err("Remapping memory failed: %d\n", err); - do { - int ret = vm_insert_page(vma, uaddr, *pages++); - if (ret) { - pr_err("Remapping memory failed: %d\n", ret); - return ret; - } - uaddr += PAGE_SIZE; - usize -= PAGE_SIZE; - } while (usize > 0); - - return 0; + return err; } static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, From patchwork Mon Dec 24 13:22:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 750D913B5 for ; Mon, 24 Dec 2018 13:18:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 635061FE8E for ; Mon, 24 Dec 2018 13:18:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57A6020246; Mon, 24 Dec 2018 13:18:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1518D1FE8E for ; Mon, 24 Dec 2018 13:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Loy8BRpAHtcpXHPkVZSW+j0QVNFil9xaFXoMXhsn+1M=; b=LbcYZGGmUbi7st D73dvz+PBi/xaQqpRUnJAIESJPPAmklmlFsX1xia+J0Gx6DrjQykeaec41Iykdfn/Iwybc0SV2GiE 4p4TQXp1dui2OawCA1oRbL+Llwh3I6rBGy5Ipq/GbhU3Rl7NH9FKIk4hqlFcPbT+0/rO+e+SJh53V 29dok2Mf7jK4MmYaN+xbfg6ODQRWd26t9oCleXKoTNfK/dAQofvOGqRCw0WRx9qkQ3w+FZcV8mzlu +15Lv6NJWWXUBMuWUHH1xfFjZ+imcqqKEw0TDwyYNd3dAuIJD2cbsoFwOAiGiPUezbWiKovR22ccA Ad0C1JS9vidBlD8Jh88w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbQ84-0003MP-Nl; Mon, 24 Dec 2018 13:18:44 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbQ82-0003Kg-0J for linux-arm-kernel@lists.infradead.org; Mon, 24 Dec 2018 13:18:43 +0000 Received: by mail-pl1-x641.google.com with SMTP id w4so5603097plz.1 for ; Mon, 24 Dec 2018 05:18:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=TD45kp+Toiz0zyzHxRUMulEByoStvt6ALI4SRmA3r7+UR6vf1Fv9a5JZlAX5TD1VXN uySrs+KKlKj6AILhcxkzINzdziuX5bcL2X/eIZv1ApoknaBxtC0iQ+dScI6QyWwvgG9A KWU48g1Gzfc82fpG+paZm07hduVR+l1LiSnXUyIrBafxPSynW7LPdl8bhdzMYq/4AeCK OdyaoSSvevrLr/uRnMFcP5ABeJIURBQ3dcRXX9+4yECKcyCXvhymfBQVwrUDrubsv/sn T+AXjPEGV5m+ZsjztLaTPuh8na33XnafrsLskOheO2KRZnyIBRfgSSuM6Pn95LfGvPeR 06SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=Y8njGoAnO4LIrU4KcOVeR1nXeHwCu2Tnb/ZkDm4IICvyrQfIip/KmO2MN3H5uoENB0 GU5plS1Fazhv3kjC6U6SBU47q7+mstqNj+zwIjQEsk/0KJgDYx5fbzstUn7gFXOiUyvq tVK9Sbjf5YejIjs5PijlKXkAKsaHmwN/sNRWwQmbY2PsE9mrF3CASM85MQovCSJPiLtY E4xEBuedIUt1MYy57MSDvLEHKwzXovpbEz3NdrSFhaIPOsgVNSwxPDQJ+hG7xKqx/qzJ LwEp3hO6X8QWGlPcFBFZOL/Hglhr9GoJx1n1F/+0kaKjefuRhbetmaLBg7iD557ekLzu Fkww== X-Gm-Message-State: AJcUukeU6ZuCuKTXoGqvViV71gh5NMSs1vfAmADoT3hCB/B04rNHy/YC e+MH4nwh8jnLVsqv9scEw9U= X-Google-Smtp-Source: ALg8bN4XK5L89IhWFZWeXxyCo+XDDhmG6v7dUoEX5qNfkascP5MGDznUdyua+AHQOE+3TD6j5/G3fA== X-Received: by 2002:a17:902:8ec8:: with SMTP id x8mr13070446plo.210.1545657511512; Mon, 24 Dec 2018 05:18:31 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id k14sm58126547pgs.52.2018.12.24.05.18.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:18:30 -0800 (PST) Date: Mon, 24 Dec 2018 18:52:27 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, stefanr@s5r6.in-berlin.de, linux@armlinux.org.uk, robin.murphy@arm.com Subject: [PATCH v5 3/9] drivers/firewire/core-iso.c: Convert to use vm_insert_range Message-ID: <20181224132227.GA22096@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181224_051842_046286_221444DB X-CRM114-Status: GOOD ( 12.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox --- drivers/firewire/core-iso.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index 35e784c..7bf28bb 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -107,19 +107,8 @@ int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer, struct vm_area_struct *vma) { - unsigned long uaddr; - int i, err; - - uaddr = vma->vm_start; - for (i = 0; i < buffer->page_count; i++) { - err = vm_insert_page(vma, uaddr, buffer->pages[i]); - if (err) - return err; - - uaddr += PAGE_SIZE; - } - - return 0; + return vm_insert_range(vma, vma->vm_start, buffer->pages, + buffer->page_count); } void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, From patchwork Mon Dec 24 13:23:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F06F13B5 for ; Mon, 24 Dec 2018 13:20:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A71C28AAF for ; Mon, 24 Dec 2018 13:20:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E23528B01; Mon, 24 Dec 2018 13:20:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 342EF28AD4 for ; Mon, 24 Dec 2018 13:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fmsOwmA8gPcIVLblLtrpN/pfiZaxhEqHQQK+cmMNA1I=; b=iAUxuDUMEvPvpQ 3sZKh7EkrAOT0QFFVCnsrd4GoyIp740VQZE+D3JW/6k8CkYHQN5dQG9q1fSEafbkQJEkPIjnQK5V1 WJXAWHD7dkMjbyxnoCpnAKrLc7KsAzpYMxZBJACMXeZb7poOfOZbjGrbsmOu+HxGiYOfCn1um6GTf snJeF69O7cXkCJawEzFQ29yM9it3SKBKZT+JhuxfnsOnRxyyd5h9b+SnwhrO/5mCxOZ/afoL7Cv+m Gt8AyyPJRKlw7tQD1BsohDanGyKA8p1N6morkxA96+/eNC4XqOE0SLcbPlqGOhlQaGpjhxTYoj6kp fLpWx+T8rS7pAFmP4pwQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbQ9O-0004BD-Bg; Mon, 24 Dec 2018 13:20:06 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbQ9J-0003fE-Ex; Mon, 24 Dec 2018 13:20:03 +0000 Received: by mail-pg1-x543.google.com with SMTP id z10so5589843pgp.7; Mon, 24 Dec 2018 05:19:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=ta45jCjTTw9h608mLSaRumjRsUxHErr+7YYhcRdk80Q=; b=bZlLJOImO/1bupplpSBgyvMTMpxNs0KKCyh9eTwdH+0uwPXfvhWmQ2pAF8DBwsk9Rh bUzZMgNq5nuyQY4GhD3gBu+bVpcBE11KxlyMH4e4GZcPAfuh33MQNhj1AdFZ3jCDGO80 pw0nh5Zx//0/hc8/8FFns4JVjWJHJEPmTg/eT1k0ZUpBl00xFnUcKdIg5f+PdxVKKQa5 FCwYRtJKVzzaeQlNqWS4BSXGJQUhPC21z/MJEvaiy2M9oJNQzcrFQKX4+e8lpIRSzbhj CXPgWhP0XbFWNCAtL9bP3cJwnXoT0RpNFDimxMCjz/XJnM+Mzti5wvF9ze4fxY1gPbV3 yV9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=ta45jCjTTw9h608mLSaRumjRsUxHErr+7YYhcRdk80Q=; b=s5TZlSSDBY7+kPANCYg4WGsJIKrnlh85jfy0mgoDjoQNGr/psZX7MuvSsFqMDzXO9j HPwnjblV1WX8QpBSvubiprR6+wmABKoTk7Avdnzu+jQX11WMgTUXNd/iAcGszG5FLQXo YAV2Bvgejw51neckdqc78p9ZSvLKl/B6jSbbDwoTHvo10Mvt3B5bA45ZHeVDWtWwj7TW HHbjDZwsNkXW0NkGjDDQw4KnHmzUIReJ01jMSzP17kZXRsEj0phVmSx2RXr1aJJsaBZG y6CJXn+W2Yi0Nb5cz3GGQ26HO5OdC3kvVkoTYivrM1hS3HmF/Q7lN1EzdYjgFEhBwqjZ gelQ== X-Gm-Message-State: AJcUukekF4dgVosd/rWtE85e2DOvLSI3vBLaOpi6x0SbRuM/K31Z9E+L 0f63PXwrTyGSJs24BtvGioIIs6XD X-Google-Smtp-Source: ALg8bN5WlOmqbcy4mwSttJzqAgLDaKxP0MsWaY4oRqlS6nY5gpEXpC5t31E85FE+ygzeYcDzQuE9IQ== X-Received: by 2002:a63:db48:: with SMTP id x8mr11898908pgi.365.1545657589149; Mon, 24 Dec 2018 05:19:49 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id s9sm42516339pgl.88.2018.12.24.05.19.47 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:19:48 -0800 (PST) Date: Mon, 24 Dec 2018 18:53:40 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, hjc@rock-chips.com, heiko@sntech.de, airlied@linux.ie, linux@armlinux.org.uk, robin.murphy@arm.com Subject: [PATCH v5 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Message-ID: <20181224132340.GA22112@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181224_052001_516095_38D8BB18 X-CRM114-Status: GOOD ( 14.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Tested-by: Heiko Stuebner Acked-by: Heiko Stuebner --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index a8db758..28458ae 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -221,26 +221,18 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj, struct vm_area_struct *vma) { struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); - unsigned int i, count = obj->size >> PAGE_SHIFT; + unsigned int count = obj->size >> PAGE_SHIFT; unsigned long user_count = vma_pages(vma); - unsigned long uaddr = vma->vm_start; unsigned long offset = vma->vm_pgoff; unsigned long end = user_count + offset; - int ret; if (user_count == 0) return -ENXIO; if (end > count) return -ENXIO; - for (i = offset; i < end; i++) { - ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]); - if (ret) - return ret; - uaddr += PAGE_SIZE; - } - - return 0; + return vm_insert_range(vma, vma->vm_start, rk_obj->pages + offset, + user_count); } static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj,