From: Souptick Joarder <jrdr.linux@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
Michal Hocko <mhocko@suse.com>,
Russell King - ARM Linux <linux@armlinux.org.uk>,
robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com,
Kees Cook <keescook@chromium.org>,
Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-kernel@vger.kernel.org, Linux-MM <linux-mm@kvack.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range
Date: Fri, 25 Jan 2019 11:54:13 +0530 [thread overview]
Message-ID: <CAFqt6zZx9qxx_Xv=n-PY45OvS7E8ZBq+ZqaeEKfsaCirwaASSg@mail.gmail.com> (raw)
In-Reply-To: <20190111150801.GA2714@jordon-HP-15-Notebook-PC>
On Fri, Jan 11, 2019 at 8:33 PM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
> Convert to use vm_insert_range() to map range of kernel
> memory to user vma.
>
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Any comment on this patch ?
> ---
> arch/arm/mm/dma-mapping.c | 22 ++++++----------------
> 1 file changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 78de138..5334391 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1582,31 +1582,21 @@ 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;
> 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;
>
> - if (off >= nr_pages || (usize >> PAGE_SHIFT) > nr_pages - off)
> + if (vma->vm_pgoff >= nr_pages)
> return -ENXIO;
>
> - pages += off;
> -
> - 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);
> + err = vm_insert_range(vma, pages, nr_pages);
> + if (err)
> + pr_err("Remapping memory failed: %d\n", err);
>
> - return 0;
> + return err;
> }
> static int arm_iommu_mmap_attrs(struct device *dev,
> struct vm_area_struct *vma, void *cpu_addr,
> --
> 1.9.1
>
next prev parent reply other threads:[~2019-01-25 6:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 15:08 [PATCH 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Souptick Joarder
2019-01-25 6:24 ` Souptick Joarder [this message]
2019-01-30 9:59 ` Souptick Joarder
-- strict thread matches above, loose matches on Subject: below --
2018-11-15 15:46 Souptick Joarder
2018-11-26 5:37 ` Souptick Joarder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFqt6zZx9qxx_Xv=n-PY45OvS7E8ZBq+ZqaeEKfsaCirwaASSg@mail.gmail.com' \
--to=jrdr.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=m.szyprowski@samsung.com \
--cc=mhocko@suse.com \
--cc=robin.murphy@arm.com \
--cc=treding@nvidia.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).