2017-09-20 22:40:25

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH 0/7] Cocci spatch "vma_pages" - v4.14-rc1

Use vma_pages function on vma object instead of explicit computation.

Found by coccinelle spatch "api/vma_pages.cocci"

Run against version v4.14-rc1

Let me know when you as a maintainer are not interested in these kind of patches.
I can exclude you by path; e.g. all findings in "drivers/scsi" will never
be reported again by this semi-automatic program runs.


2017-09-20 22:38:30

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH 5/7] MIPS: Cocci spatch "vma_pages"

Use vma_pages function on vma object instead of explicit computation.
Found by coccinelle spatch "api/vma_pages.cocci"

Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -179,7 +179,7 @@ static int mips_dma_mmap(struct device *
void *cpu_addr, dma_addr_t dma_addr, size_t size,
unsigned long attrs)
{
- unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+ unsigned long user_count = vma_pages(vma);
unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
unsigned long addr = (unsigned long)cpu_addr;
unsigned long off = vma->vm_pgoff;

2017-09-20 22:38:35

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH 6/7] KVM: PPC: Cocci spatch "vma_pages"

Use vma_pages function on vma object instead of explicit computation.
Found by coccinelle spatch "api/vma_pages.cocci"

Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -377,7 +377,7 @@ static inline int kvmppc_e500_shadow_map

start = vma->vm_pgoff;
end = start +
- ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT);
+ vma_pages(vma);

pfn = start + ((hva - vma->vm_start) >> PAGE_SHIFT);


2017-09-20 22:38:41

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH 7/7] drm/rockchip: Cocci spatch "vma_pages"

Use vma_pages function on vma object instead of explicit computation.
Found by coccinelle spatch "api/vma_pages.cocci"

Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -220,7 +220,7 @@ static int rockchip_drm_gem_object_mmap_
{
struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
unsigned int i, count = obj->size >> PAGE_SHIFT;
- unsigned long user_count = (vma->vm_end - vma->vm_start) >> 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;

2017-09-20 22:40:26

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH 1/7] ARM: dma-mapping: Cocci spatch "vma_pages"

Use vma_pages function on vma object instead of explicit computation.
Found by coccinelle spatch "api/vma_pages.cocci"

Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -846,7 +846,7 @@ static int __arm_dma_mmap(struct device
unsigned long attrs)
{
int ret;
- unsigned long nr_vma_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+ unsigned long nr_vma_pages = vma_pages(vma);
unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
unsigned long pfn = dma_to_pfn(dev, dma_addr);
unsigned long off = vma->vm_pgoff;

2017-09-20 22:40:27

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH 4/7] microblaze: Cocci spatch "vma_pages"

Use vma_pages function on vma object instead of explicit computation.
Found by coccinelle spatch "api/vma_pages.cocci"

Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c
--- a/arch/microblaze/kernel/dma.c
+++ b/arch/microblaze/kernel/dma.c
@@ -165,7 +165,7 @@ int dma_direct_mmap_coherent(struct devi
unsigned long attrs)
{
#ifdef CONFIG_MMU
- unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+ unsigned long user_count = vma_pages(vma);
unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
unsigned long off = vma->vm_pgoff;
unsigned long pfn;

2017-09-20 22:40:23

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH 3/7] metag: Cocci spatch "vma_pages"

Use vma_pages function on vma object instead of explicit computation.
Found by coccinelle spatch "api/vma_pages.cocci"

Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/arch/metag/kernel/dma.c b/arch/metag/kernel/dma.c
--- a/arch/metag/kernel/dma.c
+++ b/arch/metag/kernel/dma.c
@@ -342,7 +342,7 @@ static int metag_dma_mmap(struct device
else
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);

- user_size = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+ user_size = vma_pages(vma);

spin_lock_irqsave(&consistent_lock, flags);
c = metag_vm_region_find(&consistent_head, (unsigned long)cpu_addr);

2017-09-20 22:40:21

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH 2/7] arm64: Cocci spatch "vma_pages"

Use vma_pages function on vma object instead of explicit computation.
Found by coccinelle spatch "api/vma_pages.cocci"

Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -303,8 +303,7 @@ static int __swiotlb_mmap_pfn(struct vm_
unsigned long pfn, size_t size)
{
int ret = -ENXIO;
- unsigned long nr_vma_pages = (vma->vm_end - vma->vm_start) >>
- PAGE_SHIFT;
+ unsigned long nr_vma_pages = vma_pages(vma);
unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
unsigned long off = vma->vm_pgoff;


2017-09-21 01:02:31

by Mark yao

[permalink] [raw]
Subject: Re: [PATCH 7/7] drm/rockchip: Cocci spatch "vma_pages"

On 2017年09月21日 06:29, Thomas Meyer wrote:
> Use vma_pages function on vma object instead of explicit computation.
> Found by coccinelle spatch "api/vma_pages.cocci"
>
> Signed-off-by: Thomas Meyer <[email protected]>
> ---
Looks good for me:
Acked-by: Mark Yao <[email protected]>

>
> diff -u -p a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -220,7 +220,7 @@ static int rockchip_drm_gem_object_mmap_
> {
> struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
> unsigned int i, count = obj->size >> PAGE_SHIFT;
> - unsigned long user_count = (vma->vm_end - vma->vm_start) >> 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;
>
> _______________________________________________
> Linux-rockchip mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-rockchip
>
>
>

--
Mark Yao


2017-09-25 13:37:38

by Michal Simek

[permalink] [raw]
Subject: Re: [PATCH 4/7] microblaze: Cocci spatch "vma_pages"

On 21.9.2017 00:29, Thomas Meyer wrote:
> Use vma_pages function on vma object instead of explicit computation.
> Found by coccinelle spatch "api/vma_pages.cocci"
>
> Signed-off-by: Thomas Meyer <[email protected]>
> ---
>
> diff -u -p a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c
> --- a/arch/microblaze/kernel/dma.c
> +++ b/arch/microblaze/kernel/dma.c
> @@ -165,7 +165,7 @@ int dma_direct_mmap_coherent(struct devi
> unsigned long attrs)
> {
> #ifdef CONFIG_MMU
> - unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
> + unsigned long user_count = vma_pages(vma);
> unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
> unsigned long off = vma->vm_pgoff;
> unsigned long pfn;
>

Applied to mb/next.

Thanks,
Michal

--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: http://www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs



Attachments:
signature.asc (198.00 B)
OpenPGP digital signature

2017-09-26 05:12:46

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH 7/7] drm/rockchip: Cocci spatch "vma_pages"

On Thu, Sep 21, 2017 at 09:02:22AM +0800, Mark yao wrote:
> On 2017年09月21日 06:29, Thomas Meyer wrote:
> > Use vma_pages function on vma object instead of explicit computation.
> > Found by coccinelle spatch "api/vma_pages.cocci"
> >
> > Signed-off-by: Thomas Meyer <[email protected]>
> > ---
> Looks good for me:
> Acked-by: Mark Yao <[email protected]>

Once more a maintainer who acks a patch and doesn't push it. This is
really confusing, who exactly do you expect to handle this patch for you?

Please push to drm-misc-next (also for future patches), thanks.
-Daniel

>
> >
> > diff -u -p a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > @@ -220,7 +220,7 @@ static int rockchip_drm_gem_object_mmap_
> > {
> > struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
> > unsigned int i, count = obj->size >> PAGE_SHIFT;
> > - unsigned long user_count = (vma->vm_end - vma->vm_start) >> 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;
> >
> > _______________________________________________
> > Linux-rockchip mailing list
> > [email protected]
> > http://lists.infradead.org/mailman/listinfo/linux-rockchip
> >
> >
> >
>
> --
> Mark Yao
>
>
> _______________________________________________
> dri-devel mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

2017-09-26 06:33:23

by Mark yao

[permalink] [raw]
Subject: Re: [PATCH 7/7] drm/rockchip: Cocci spatch "vma_pages"

On 2017年09月26日 13:12, Daniel Vetter wrote:
> On Thu, Sep 21, 2017 at 09:02:22AM +0800, Mark yao wrote:
>> On 2017年09月21日 06:29, Thomas Meyer wrote:
>>> Use vma_pages function on vma object instead of explicit computation.
>>> Found by coccinelle spatch "api/vma_pages.cocci"
>>>
>>> Signed-off-by: Thomas Meyer <[email protected]>
>>> ---
>> Looks good for me:
>> Acked-by: Mark Yao <[email protected]>
> Once more a maintainer who acks a patch and doesn't push it. This is
> really confusing, who exactly do you expect to handle this patch for you?
>
> Please push to drm-misc-next (also for future patches), thanks.
> -Daniel

Hi Daniel
I Saw the patch title is "[PATCH 7/7]", I guessed it's one of a series of patches and maybe it can pushed by series.

Ok, Pushed it to drm-misc-next.

>
>>> diff -u -p a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> @@ -220,7 +220,7 @@ static int rockchip_drm_gem_object_mmap_
>>> {
>>> struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
>>> unsigned int i, count = obj->size >> PAGE_SHIFT;
>>> - unsigned long user_count = (vma->vm_end - vma->vm_start) >> 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;
>>>
>>> _______________________________________________
>>> Linux-rockchip mailing list
>>> [email protected]
>>> http://lists.infradead.org/mailman/listinfo/linux-rockchip
>>>
>>>
>>>
>> --
>> Mark Yao
>>
>>
>> _______________________________________________
>> dri-devel mailing list
>> [email protected]
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel


--
Mark Ya


2017-09-26 08:08:27

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH 7/7] drm/rockchip: Cocci spatch "vma_pages"

On Tue, Sep 26, 2017 at 02:33:07PM +0800, Mark yao wrote:
> On 2017年09月26日 13:12, Daniel Vetter wrote:
> > On Thu, Sep 21, 2017 at 09:02:22AM +0800, Mark yao wrote:
> > > On 2017年09月21日 06:29, Thomas Meyer wrote:
> > > > Use vma_pages function on vma object instead of explicit computation.
> > > > Found by coccinelle spatch "api/vma_pages.cocci"
> > > >
> > > > Signed-off-by: Thomas Meyer <[email protected]>
> > > > ---
> > > Looks good for me:
> > > Acked-by: Mark Yao <[email protected]>
> > Once more a maintainer who acks a patch and doesn't push it. This is
> > really confusing, who exactly do you expect to handle this patch for you?
> >
> > Please push to drm-misc-next (also for future patches), thanks.
> > -Daniel
>
> Hi Daniel
> I Saw the patch title is "[PATCH 7/7]", I guessed it's one of a series of patches and maybe it can pushed by series.
>
> Ok, Pushed it to drm-misc-next.

Hm right, but I only see 7/7 here. Either way, except when the author asks
for a preferred tree it's best if you just pick things up right away. And
if you're unsure, just ask instead of risking that a patch drops through
the cracks.
-Daniel

>
> >
> > > > diff -u -p a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > > > --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > > > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > > > @@ -220,7 +220,7 @@ static int rockchip_drm_gem_object_mmap_
> > > > {
> > > > struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
> > > > unsigned int i, count = obj->size >> PAGE_SHIFT;
> > > > - unsigned long user_count = (vma->vm_end - vma->vm_start) >> 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;
> > > >
> > > > _______________________________________________
> > > > Linux-rockchip mailing list
> > > > [email protected]
> > > > http://lists.infradead.org/mailman/listinfo/linux-rockchip
> > > >
> > > >
> > > >
> > > --
> > > Mark Yao
> > >
> > >
> > > _______________________________________________
> > > dri-devel mailing list
> > > [email protected]
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
> --
> Mark Ya
>
>
> _______________________________________________
> dri-devel mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

2017-09-26 09:06:50

by Mark yao

[permalink] [raw]
Subject: Re: [PATCH 7/7] drm/rockchip: Cocci spatch "vma_pages"

On 2017年09月26日 16:08, Daniel Vetter wrote:
> On Tue, Sep 26, 2017 at 02:33:07PM +0800, Mark yao wrote:
>> On 2017年09月26日 13:12, Daniel Vetter wrote:
>>> On Thu, Sep 21, 2017 at 09:02:22AM +0800, Mark yao wrote:
>>>> On 2017年09月21日 06:29, Thomas Meyer wrote:
>>>>> Use vma_pages function on vma object instead of explicit computation.
>>>>> Found by coccinelle spatch "api/vma_pages.cocci"
>>>>>
>>>>> Signed-off-by: Thomas Meyer <[email protected]>
>>>>> ---
>>>> Looks good for me:
>>>> Acked-by: Mark Yao <[email protected]>
>>> Once more a maintainer who acks a patch and doesn't push it. This is
>>> really confusing, who exactly do you expect to handle this patch for you?
>>>
>>> Please push to drm-misc-next (also for future patches), thanks.
>>> -Daniel
>> Hi Daniel
>> I Saw the patch title is "[PATCH 7/7]", I guessed it's one of a series of patches and maybe it can pushed by series.
>>
>> Ok, Pushed it to drm-misc-next.
> Hm right, but I only see 7/7 here. Either way, except when the author asks
> for a preferred tree it's best if you just pick things up right away. And
> if you're unsure, just ask instead of risking that a patch drops through
> the cracks.
> -Daniel

Okay, I'll keep it in mind next time.

Thanks
Mark

>
>>>>> diff -u -p a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>>>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>>>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>>>> @@ -220,7 +220,7 @@ static int rockchip_drm_gem_object_mmap_
>>>>> {
>>>>> struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
>>>>> unsigned int i, count = obj->size >> PAGE_SHIFT;
>>>>> - unsigned long user_count = (vma->vm_end - vma->vm_start) >> 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;
>>>>>
>>>>> _______________________________________________
>>>>> Linux-rockchip mailing list
>>>>> [email protected]
>>>>> http://lists.infradead.org/mailman/listinfo/linux-rockchip
>>>>>
>>>>>
>>>>>
>>>> --
>>>> Mark Yao
>>>>
>>>>
>>>> _______________________________________________
>>>> dri-devel mailing list
>>>> [email protected]
>>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>> --
>> Mark Ya
>>
>>
>> _______________________________________________
>> dri-devel mailing list
>> [email protected]
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel

2017-09-26 11:57:20

by Robin Murphy

[permalink] [raw]
Subject: Re: [PATCH 2/7] arm64: Cocci spatch "vma_pages"

On 20/09/17 23:29, Thomas Meyer wrote:
> Use vma_pages function on vma object instead of explicit computation.
> Found by coccinelle spatch "api/vma_pages.cocci"

Reviewed-by: Robin Murphy <[email protected]>

I guess this can be picked up independently of the other patches?

Robin.

> Signed-off-by: Thomas Meyer <[email protected]>
> ---
>
> diff -u -p a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
> --- a/arch/arm64/mm/dma-mapping.c
> +++ b/arch/arm64/mm/dma-mapping.c
> @@ -303,8 +303,7 @@ static int __swiotlb_mmap_pfn(struct vm_
> unsigned long pfn, size_t size)
> {
> int ret = -ENXIO;
> - unsigned long nr_vma_pages = (vma->vm_end - vma->vm_start) >>
> - PAGE_SHIFT;
> + unsigned long nr_vma_pages = vma_pages(vma);
> unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
> unsigned long off = vma->vm_pgoff;
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>