From: Marek Szyprowski <m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
To: ritesh.harjani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
catalin.marinas-5wv7dgnIgG8@public.gmane.org
Cc: mp.vikram-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Will.Deacon-5wv7dgnIgG8@public.gmane.org,
laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH v2] arm: dma-iommu: Clean up redundant variable
Date: Tue, 20 May 2014 15:06:37 +0200 [thread overview]
Message-ID: <537B535D.1090303@samsung.com> (raw)
In-Reply-To: <1400560379-1502-1-git-send-email-ritesh.harjani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Hello,
On 2014-05-20 06:32, ritesh.harjani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
> From: Ritesh Harjani <ritesh.harjani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> mapping->size can be derived from mapping->bits << PAGE_SHIFT
> which makes mapping->size as redundant.
>
> Clean this up.
>
> Signed-off-by: Ritesh Harjani <ritesh.harjani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Reported-by: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
Thanks for this cleanup. I will add it to my tree.
> ---
> arch/arm/include/asm/dma-iommu.h | 1 -
> arch/arm/mm/dma-mapping.c | 11 ++++++-----
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h
> index eec0a12..8e3fcb9 100644
> --- a/arch/arm/include/asm/dma-iommu.h
> +++ b/arch/arm/include/asm/dma-iommu.h
> @@ -18,7 +18,6 @@ struct dma_iommu_mapping {
> unsigned int extensions;
> size_t bitmap_size; /* size of a single bitmap */
> size_t bits; /* per bitmap */
> - unsigned int size; /* per bitmap */
> dma_addr_t base;
>
> spinlock_t lock;
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 6b00be1..3d43c41 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1074,6 +1074,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
> unsigned int order = get_order(size);
> unsigned int align = 0;
> unsigned int count, start;
> + size_t mapping_size = mapping->bits << PAGE_SHIFT;
> unsigned long flags;
> dma_addr_t iova;
> int i;
> @@ -1119,7 +1120,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
> }
> spin_unlock_irqrestore(&mapping->lock, flags);
>
> - iova = mapping->base + (mapping->size * i);
> + iova = mapping->base + (mapping_size * i);
> iova += start << PAGE_SHIFT;
>
> return iova;
> @@ -1129,6 +1130,7 @@ static inline void __free_iova(struct dma_iommu_mapping *mapping,
> dma_addr_t addr, size_t size)
> {
> unsigned int start, count;
> + size_t mapping_size = mapping->bits << PAGE_SHIFT;
> unsigned long flags;
> dma_addr_t bitmap_base;
> u32 bitmap_index;
> @@ -1136,14 +1138,14 @@ static inline void __free_iova(struct dma_iommu_mapping *mapping,
> if (!size)
> return;
>
> - bitmap_index = (u32) (addr - mapping->base) / (u32) mapping->size;
> + bitmap_index = (u32) (addr - mapping->base) / (u32) mapping_size;
> BUG_ON(addr < mapping->base || bitmap_index > mapping->extensions);
>
> - bitmap_base = mapping->base + mapping->size * bitmap_index;
> + bitmap_base = mapping->base + mapping_size * bitmap_index;
>
> start = (addr - bitmap_base) >> PAGE_SHIFT;
>
> - if (addr + size > bitmap_base + mapping->size) {
> + if (addr + size > bitmap_base + mapping_size) {
> /*
> * The address range to be freed reaches into the iova
> * range of the next bitmap. This should not happen as
> @@ -1964,7 +1966,6 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size)
> mapping->extensions = extensions;
> mapping->base = base;
> mapping->bits = BITS_PER_BYTE * bitmap_size;
> - mapping->size = mapping->bits << PAGE_SHIFT;
>
> spin_lock_init(&mapping->lock);
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
WARNING: multiple messages have this Message-ID (diff)
From: m.szyprowski@samsung.com (Marek Szyprowski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] arm: dma-iommu: Clean up redundant variable
Date: Tue, 20 May 2014 15:06:37 +0200 [thread overview]
Message-ID: <537B535D.1090303@samsung.com> (raw)
In-Reply-To: <1400560379-1502-1-git-send-email-ritesh.harjani@gmail.com>
Hello,
On 2014-05-20 06:32, ritesh.harjani at gmail.com wrote:
> From: Ritesh Harjani <ritesh.harjani@gmail.com>
>
> mapping->size can be derived from mapping->bits << PAGE_SHIFT
> which makes mapping->size as redundant.
>
> Clean this up.
>
> Signed-off-by: Ritesh Harjani <ritesh.harjani@gmail.com>
> Reported-by: Will Deacon <will.deacon@arm.com>
Thanks for this cleanup. I will add it to my tree.
> ---
> arch/arm/include/asm/dma-iommu.h | 1 -
> arch/arm/mm/dma-mapping.c | 11 ++++++-----
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h
> index eec0a12..8e3fcb9 100644
> --- a/arch/arm/include/asm/dma-iommu.h
> +++ b/arch/arm/include/asm/dma-iommu.h
> @@ -18,7 +18,6 @@ struct dma_iommu_mapping {
> unsigned int extensions;
> size_t bitmap_size; /* size of a single bitmap */
> size_t bits; /* per bitmap */
> - unsigned int size; /* per bitmap */
> dma_addr_t base;
>
> spinlock_t lock;
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 6b00be1..3d43c41 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1074,6 +1074,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
> unsigned int order = get_order(size);
> unsigned int align = 0;
> unsigned int count, start;
> + size_t mapping_size = mapping->bits << PAGE_SHIFT;
> unsigned long flags;
> dma_addr_t iova;
> int i;
> @@ -1119,7 +1120,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
> }
> spin_unlock_irqrestore(&mapping->lock, flags);
>
> - iova = mapping->base + (mapping->size * i);
> + iova = mapping->base + (mapping_size * i);
> iova += start << PAGE_SHIFT;
>
> return iova;
> @@ -1129,6 +1130,7 @@ static inline void __free_iova(struct dma_iommu_mapping *mapping,
> dma_addr_t addr, size_t size)
> {
> unsigned int start, count;
> + size_t mapping_size = mapping->bits << PAGE_SHIFT;
> unsigned long flags;
> dma_addr_t bitmap_base;
> u32 bitmap_index;
> @@ -1136,14 +1138,14 @@ static inline void __free_iova(struct dma_iommu_mapping *mapping,
> if (!size)
> return;
>
> - bitmap_index = (u32) (addr - mapping->base) / (u32) mapping->size;
> + bitmap_index = (u32) (addr - mapping->base) / (u32) mapping_size;
> BUG_ON(addr < mapping->base || bitmap_index > mapping->extensions);
>
> - bitmap_base = mapping->base + mapping->size * bitmap_index;
> + bitmap_base = mapping->base + mapping_size * bitmap_index;
>
> start = (addr - bitmap_base) >> PAGE_SHIFT;
>
> - if (addr + size > bitmap_base + mapping->size) {
> + if (addr + size > bitmap_base + mapping_size) {
> /*
> * The address range to be freed reaches into the iova
> * range of the next bitmap. This should not happen as
> @@ -1964,7 +1966,6 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size)
> mapping->extensions = extensions;
> mapping->base = base;
> mapping->bits = BITS_PER_BYTE * bitmap_size;
> - mapping->size = mapping->bits << PAGE_SHIFT;
>
> spin_lock_init(&mapping->lock);
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
next prev parent reply other threads:[~2014-05-20 13:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 4:32 [PATCH v2] arm: dma-iommu: Clean up redundant variable ritesh.harjani
2014-05-20 4:32 ` ritesh.harjani at gmail.com
[not found] ` <1400560379-1502-1-git-send-email-ritesh.harjani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-20 13:06 ` Marek Szyprowski [this message]
2014-05-20 13:06 ` Marek Szyprowski
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=537B535D.1090303@samsung.com \
--to=m.szyprowski-sze3o3uu22jbdgjk7y7tuq@public.gmane.org \
--cc=Will.Deacon-5wv7dgnIgG8@public.gmane.org \
--cc=catalin.marinas-5wv7dgnIgG8@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=mp.vikram-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=ritesh.harjani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.