All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcmu: Fix flushing cmd entry dcache page
@ 2017-06-30  8:14 lixiubo
  2017-06-30 23:18 ` Mike Christie
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: lixiubo @ 2017-06-30  8:14 UTC (permalink / raw)
  To: nab, mchristi; +Cc: linux-scsi, target-devel, Xiubo Li

From: Xiubo Li <lixiubo@cmss.chinamobile.com>

When feeding the tcmu's cmd ring, we need to flush the dcache page
for the cmd entry to make sure these kernel stores are visible to
user space mappings of that page.

For the none PAD cmd entry, this will be flushed at the end of the
tcmu_queue_cmd_ring().

Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
---
 drivers/target/target_core_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 203bff1..930800c 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -699,21 +699,21 @@ static inline size_t tcmu_cmd_get_cmd_size(struct tcmu_cmd *tcmu_cmd,
 		size_t pad_size = head_to_end(cmd_head, udev->cmdr_size);
 
 		entry = (void *) mb + CMDR_OFF + cmd_head;
-		tcmu_flush_dcache_range(entry, sizeof(*entry));
 		tcmu_hdr_set_op(&entry->hdr.len_op, TCMU_OP_PAD);
 		tcmu_hdr_set_len(&entry->hdr.len_op, pad_size);
 		entry->hdr.cmd_id = 0; /* not used for PAD */
 		entry->hdr.kflags = 0;
 		entry->hdr.uflags = 0;
+		tcmu_flush_dcache_range(entry, sizeof(*entry));
 
 		UPDATE_HEAD(mb->cmd_head, pad_size, udev->cmdr_size);
+		tcmu_flush_dcache_range(mb, sizeof(*mb));
 
 		cmd_head = mb->cmd_head % udev->cmdr_size; /* UAM */
 		WARN_ON(cmd_head != 0);
 	}
 
 	entry = (void *) mb + CMDR_OFF + cmd_head;
-	tcmu_flush_dcache_range(entry, sizeof(*entry));
 	tcmu_hdr_set_op(&entry->hdr.len_op, TCMU_OP_CMD);
 	entry->hdr.cmd_id = tcmu_cmd->cmd_id;
 	entry->hdr.kflags = 0;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tcmu: Fix flushing cmd entry dcache page
  2017-06-30  8:14 [PATCH] tcmu: Fix flushing cmd entry dcache page lixiubo
@ 2017-06-30 23:18 ` Mike Christie
  2017-07-01 23:31 ` Mike Christie
  2017-07-03  5:36 ` Nicholas A. Bellinger
  2 siblings, 0 replies; 4+ messages in thread
From: Mike Christie @ 2017-06-30 23:18 UTC (permalink / raw)
  To: lixiubo, nab; +Cc: linux-scsi, target-devel

On 06/30/2017 03:14 AM, lixiubo@cmss.chinamobile.com wrote:
> From: Xiubo Li <lixiubo@cmss.chinamobile.com>
> 
> When feeding the tcmu's cmd ring, we need to flush the dcache page
> for the cmd entry to make sure these kernel stores are visible to
> user space mappings of that page.
> 
> For the none PAD cmd entry, this will be flushed at the end of the
> tcmu_queue_cmd_ring().
> 
> Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
> ---
>  drivers/target/target_core_user.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 203bff1..930800c 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -699,21 +699,21 @@ static inline size_t tcmu_cmd_get_cmd_size(struct tcmu_cmd *tcmu_cmd,
>  		size_t pad_size = head_to_end(cmd_head, udev->cmdr_size);
>  
>  		entry = (void *) mb + CMDR_OFF + cmd_head;
> -		tcmu_flush_dcache_range(entry, sizeof(*entry));


I think this patch looks ok. What was the reason for removing this and
the one at the bottom of the patch? Is it not needed because we are not
reading anything from the entry that could have been touched by userspace?

>  		tcmu_hdr_set_op(&entry->hdr.len_op, TCMU_OP_PAD);
>  		tcmu_hdr_set_len(&entry->hdr.len_op, pad_size);
>  		entry->hdr.cmd_id = 0; /* not used for PAD */
>  		entry->hdr.kflags = 0;
>  		entry->hdr.uflags = 0;
> +		tcmu_flush_dcache_range(entry, sizeof(*entry));
>  
>  		UPDATE_HEAD(mb->cmd_head, pad_size, udev->cmdr_size);
> +		tcmu_flush_dcache_range(mb, sizeof(*mb));
>  
>  		cmd_head = mb->cmd_head % udev->cmdr_size; /* UAM */
>  		WARN_ON(cmd_head != 0);
>  	}
>  
>  	entry = (void *) mb + CMDR_OFF + cmd_head;
> -	tcmu_flush_dcache_range(entry, sizeof(*entry));
>  	tcmu_hdr_set_op(&entry->hdr.len_op, TCMU_OP_CMD);
>  	entry->hdr.cmd_id = tcmu_cmd->cmd_id;
>  	entry->hdr.kflags = 0;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tcmu: Fix flushing cmd entry dcache page
  2017-06-30  8:14 [PATCH] tcmu: Fix flushing cmd entry dcache page lixiubo
  2017-06-30 23:18 ` Mike Christie
@ 2017-07-01 23:31 ` Mike Christie
  2017-07-03  5:36 ` Nicholas A. Bellinger
  2 siblings, 0 replies; 4+ messages in thread
From: Mike Christie @ 2017-07-01 23:31 UTC (permalink / raw)
  To: lixiubo, nab; +Cc: linux-scsi, target-devel

On 06/30/2017 03:14 AM, lixiubo@cmss.chinamobile.com wrote:
> From: Xiubo Li <lixiubo@cmss.chinamobile.com>
> 
> When feeding the tcmu's cmd ring, we need to flush the dcache page
> for the cmd entry to make sure these kernel stores are visible to
> user space mappings of that page.
> 
> For the none PAD cmd entry, this will be flushed at the end of the
> tcmu_queue_cmd_ring().
> 
> Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
> ---
>  drivers/target/target_core_user.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 203bff1..930800c 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -699,21 +699,21 @@ static inline size_t tcmu_cmd_get_cmd_size(struct tcmu_cmd *tcmu_cmd,
>  		size_t pad_size = head_to_end(cmd_head, udev->cmdr_size);
>  
>  		entry = (void *) mb + CMDR_OFF + cmd_head;
> -		tcmu_flush_dcache_range(entry, sizeof(*entry));
>  		tcmu_hdr_set_op(&entry->hdr.len_op, TCMU_OP_PAD);
>  		tcmu_hdr_set_len(&entry->hdr.len_op, pad_size);
>  		entry->hdr.cmd_id = 0; /* not used for PAD */
>  		entry->hdr.kflags = 0;
>  		entry->hdr.uflags = 0;
> +		tcmu_flush_dcache_range(entry, sizeof(*entry));
>  
>  		UPDATE_HEAD(mb->cmd_head, pad_size, udev->cmdr_size);
> +		tcmu_flush_dcache_range(mb, sizeof(*mb));
>  
>  		cmd_head = mb->cmd_head % udev->cmdr_size; /* UAM */
>  		WARN_ON(cmd_head != 0);
>  	}
>  
>  	entry = (void *) mb + CMDR_OFF + cmd_head;
> -	tcmu_flush_dcache_range(entry, sizeof(*entry));
>  	tcmu_hdr_set_op(&entry->hdr.len_op, TCMU_OP_CMD);
>  	entry->hdr.cmd_id = tcmu_cmd->cmd_id;
>  	entry->hdr.kflags = 0;
> 

Looks ok to me.

Reviewed-by: Mike Christie <mchristi@redhat.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tcmu: Fix flushing cmd entry dcache page
  2017-06-30  8:14 [PATCH] tcmu: Fix flushing cmd entry dcache page lixiubo
  2017-06-30 23:18 ` Mike Christie
  2017-07-01 23:31 ` Mike Christie
@ 2017-07-03  5:36 ` Nicholas A. Bellinger
  2 siblings, 0 replies; 4+ messages in thread
From: Nicholas A. Bellinger @ 2017-07-03  5:36 UTC (permalink / raw)
  To: lixiubo; +Cc: mchristi, linux-scsi, target-devel

On Fri, 2017-06-30 at 16:14 +0800, lixiubo@cmss.chinamobile.com wrote:
> From: Xiubo Li <lixiubo@cmss.chinamobile.com>
> 
> When feeding the tcmu's cmd ring, we need to flush the dcache page
> for the cmd entry to make sure these kernel stores are visible to
> user space mappings of that page.
> 
> For the none PAD cmd entry, this will be flushed at the end of the
> tcmu_queue_cmd_ring().
> 
> Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
> ---
>  drivers/target/target_core_user.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied.

Thanks Xiubo + MNC.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-03  5:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-30  8:14 [PATCH] tcmu: Fix flushing cmd entry dcache page lixiubo
2017-06-30 23:18 ` Mike Christie
2017-07-01 23:31 ` Mike Christie
2017-07-03  5:36 ` Nicholas A. Bellinger

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.