* [PATCH] target: use offset_in_page macro
@ 2015-11-25 13:49 Geliang Tang
2015-11-25 13:59 ` Sagi Grimberg
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Geliang Tang @ 2015-11-25 13:49 UTC (permalink / raw)
To: Nicholas A. Bellinger, Dan Carpenter, Bart Van Assche
Cc: Geliang Tang, linux-scsi, target-devel, linux-kernel
Use offset_in_page macro instead of (addr & ~PAGE_MASK).
Signed-off-by: Geliang Tang <geliangtang@163.com>
---
drivers/target/target_core_user.c | 2 +-
drivers/target/tcm_fc/tfc_io.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 937cebf..d5477c0 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -194,7 +194,7 @@ static struct tcmu_cmd *tcmu_alloc_cmd(struct se_cmd *se_cmd)
static inline void tcmu_flush_dcache_range(void *vaddr, size_t size)
{
- unsigned long offset = (unsigned long) vaddr & ~PAGE_MASK;
+ unsigned long offset = offset_in_page(vaddr);
size = round_up(size+offset, PAGE_SIZE);
vaddr -= offset;
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
index 847c1aa..6f7c65a 100644
--- a/drivers/target/tcm_fc/tfc_io.c
+++ b/drivers/target/tcm_fc/tfc_io.c
@@ -154,9 +154,9 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
BUG_ON(!page);
from = kmap_atomic(page + (mem_off >> PAGE_SHIFT));
page_addr = from;
- from += mem_off & ~PAGE_MASK;
+ from += offset_in_page(mem_off);
tlen = min(tlen, (size_t)(PAGE_SIZE -
- (mem_off & ~PAGE_MASK)));
+ offset_in_page(mem_off)));
memcpy(to, from, tlen);
kunmap_atomic(page_addr);
to += tlen;
@@ -314,9 +314,9 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
to = kmap_atomic(page + (mem_off >> PAGE_SHIFT));
page_addr = to;
- to += mem_off & ~PAGE_MASK;
+ to += offset_in_page(mem_off);
tlen = min(tlen, (size_t)(PAGE_SIZE -
- (mem_off & ~PAGE_MASK)));
+ offset_in_page(mem_off)));
memcpy(to, from, tlen);
kunmap_atomic(page_addr);
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] target: use offset_in_page macro
2015-11-25 13:49 [PATCH] target: use offset_in_page macro Geliang Tang
@ 2015-11-25 13:59 ` Sagi Grimberg
2015-11-25 14:00 ` Johannes Thumshirn
2015-11-30 0:27 ` Nicholas A. Bellinger
2 siblings, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2015-11-25 13:59 UTC (permalink / raw)
To: Geliang Tang, Nicholas A. Bellinger, Dan Carpenter,
Bart Van Assche
Cc: linux-scsi, target-devel, linux-kernel
Looks fine,
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] target: use offset_in_page macro
2015-11-25 13:49 [PATCH] target: use offset_in_page macro Geliang Tang
2015-11-25 13:59 ` Sagi Grimberg
@ 2015-11-25 14:00 ` Johannes Thumshirn
2015-11-30 0:27 ` Nicholas A. Bellinger
2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2015-11-25 14:00 UTC (permalink / raw)
To: Geliang Tang, Nicholas A. Bellinger, Dan Carpenter,
Bart Van Assche
Cc: linux-scsi, target-devel, linux-kernel
On Wed, 2015-11-25 at 21:49 +0800, Geliang Tang wrote:
> Use offset_in_page macro instead of (addr & ~PAGE_MASK).
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
> drivers/target/target_core_user.c | 2 +-
> drivers/target/tcm_fc/tfc_io.c | 8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/target/target_core_user.c
> b/drivers/target/target_core_user.c
> index 937cebf..d5477c0 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -194,7 +194,7 @@ static struct tcmu_cmd *tcmu_alloc_cmd(struct se_cmd
> *se_cmd)
>
> static inline void tcmu_flush_dcache_range(void *vaddr, size_t size)
> {
> - unsigned long offset = (unsigned long) vaddr & ~PAGE_MASK;
> + unsigned long offset = offset_in_page(vaddr);
>
> size = round_up(size+offset, PAGE_SIZE);
> vaddr -= offset;
> diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
> index 847c1aa..6f7c65a 100644
> --- a/drivers/target/tcm_fc/tfc_io.c
> +++ b/drivers/target/tcm_fc/tfc_io.c
> @@ -154,9 +154,9 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
> BUG_ON(!page);
> from = kmap_atomic(page + (mem_off >> PAGE_SHIFT));
> page_addr = from;
> - from += mem_off & ~PAGE_MASK;
> + from += offset_in_page(mem_off);
> tlen = min(tlen, (size_t)(PAGE_SIZE -
> - (mem_off & ~PAGE_MASK)));
> + offset_in_page(mem_off)));
> memcpy(to, from, tlen);
> kunmap_atomic(page_addr);
> to += tlen;
> @@ -314,9 +314,9 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct
> fc_frame *fp)
>
> to = kmap_atomic(page + (mem_off >> PAGE_SHIFT));
> page_addr = to;
> - to += mem_off & ~PAGE_MASK;
> + to += offset_in_page(mem_off);
> tlen = min(tlen, (size_t)(PAGE_SIZE -
> - (mem_off & ~PAGE_MASK)));
> + offset_in_page(mem_off)));
> memcpy(to, from, tlen);
> kunmap_atomic(page_addr);
>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] target: use offset_in_page macro
2015-11-25 13:49 [PATCH] target: use offset_in_page macro Geliang Tang
2015-11-25 13:59 ` Sagi Grimberg
2015-11-25 14:00 ` Johannes Thumshirn
@ 2015-11-30 0:27 ` Nicholas A. Bellinger
2 siblings, 0 replies; 4+ messages in thread
From: Nicholas A. Bellinger @ 2015-11-30 0:27 UTC (permalink / raw)
To: Geliang Tang
Cc: Dan Carpenter, Bart Van Assche, linux-scsi, target-devel,
linux-kernel
Hi Geliang,
On Wed, 2015-11-25 at 21:49 +0800, Geliang Tang wrote:
> Use offset_in_page macro instead of (addr & ~PAGE_MASK).
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
> drivers/target/target_core_user.c | 2 +-
> drivers/target/tcm_fc/tfc_io.c | 8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 937cebf..d5477c0 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -194,7 +194,7 @@ static struct tcmu_cmd *tcmu_alloc_cmd(struct se_cmd *se_cmd)
>
> static inline void tcmu_flush_dcache_range(void *vaddr, size_t size)
> {
> - unsigned long offset = (unsigned long) vaddr & ~PAGE_MASK;
> + unsigned long offset = offset_in_page(vaddr);
>
> size = round_up(size+offset, PAGE_SIZE);
> vaddr -= offset;
> diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
> index 847c1aa..6f7c65a 100644
> --- a/drivers/target/tcm_fc/tfc_io.c
> +++ b/drivers/target/tcm_fc/tfc_io.c
> @@ -154,9 +154,9 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
> BUG_ON(!page);
> from = kmap_atomic(page + (mem_off >> PAGE_SHIFT));
> page_addr = from;
> - from += mem_off & ~PAGE_MASK;
> + from += offset_in_page(mem_off);
> tlen = min(tlen, (size_t)(PAGE_SIZE -
> - (mem_off & ~PAGE_MASK)));
> + offset_in_page(mem_off)));
> memcpy(to, from, tlen);
> kunmap_atomic(page_addr);
> to += tlen;
> @@ -314,9 +314,9 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
>
> to = kmap_atomic(page + (mem_off >> PAGE_SHIFT));
> page_addr = to;
> - to += mem_off & ~PAGE_MASK;
> + to += offset_in_page(mem_off);
> tlen = min(tlen, (size_t)(PAGE_SIZE -
> - (mem_off & ~PAGE_MASK)));
> + offset_in_page(mem_off)));
> memcpy(to, from, tlen);
> kunmap_atomic(page_addr);
>
Applied to target-pending/for-next.
Thank you,
--nab
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-30 0:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-25 13:49 [PATCH] target: use offset_in_page macro Geliang Tang
2015-11-25 13:59 ` Sagi Grimberg
2015-11-25 14:00 ` Johannes Thumshirn
2015-11-30 0:27 ` Nicholas A. Bellinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox