[PATCH] xen/arm: its: only clean cache when sending ITS command

Daisuke Nishimura posted 1 patch 6 days, 18 hours ago
There is a newer version of this series
xen/arch/arm/gic-v3-its.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] xen/arm: its: only clean cache when sending ITS command
Posted by Daisuke Nishimura 6 days, 18 hours ago
From: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

There is no need to invalidate cache entry because we just wrote that
memory. So it is guaranteed that cache entry is valid.

But we need to clean (flush) cache line to be sure that ITS sees
command written into the memory.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Signed-off-by: Daisuke Nishimura <nishimura@valinux.co.jp>
---
(cherry picked from commit fe7142bca56b5c8c8109f581444f89ae09b7544f xen-troops)
---
 xen/arch/arm/gic-v3-its.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
index 325835b0ad..dc44666233 100644
--- a/xen/arch/arm/gic-v3-its.c
+++ b/xen/arch/arm/gic-v3-its.c
@@ -207,8 +207,7 @@ static int its_send_command(struct host_its *hw_its, const void *its_cmd)
 
     memcpy(hw_its->cmd_buf + writep, its_cmd, ITS_CMD_SIZE);
     if ( hw_its->flags & HOST_ITS_FLUSH_CMD_QUEUE )
-        clean_and_invalidate_dcache_va_range(hw_its->cmd_buf + writep,
-                                             ITS_CMD_SIZE);
+        clean_dcache_va_range(hw_its->cmd_buf + writep, ITS_CMD_SIZE);
     else
         dsb(ishst);
 
-- 
2.43.0
Re: [PATCH] xen/arm: its: only clean cache when sending ITS command
Posted by Orzel, Michal 6 days, 14 hours ago

On 17-Nov-26 04:32, Daisuke Nishimura wrote:
> From: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> 
> There is no need to invalidate cache entry because we just wrote that
> memory. So it is guaranteed that cache entry is valid.
I don't think this is a good rationale. What makes invalidation not
needed here is that the CPU is the only writer and the ITS the only
reader of this buffer, so the cached data cannot be stale. Invalidation
would be needed if a device wrote a buffer that the CPU later reads.

> 
> But we need to clean (flush) cache line to be sure that ITS sees
flush means clean+invalidate, which is what you drop, so please drop "flush" word.

> command written into the memory.
> 
> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> Signed-off-by: Daisuke Nishimura <nishimura@valinux.co.jp>
With that:
Reviewed-by: Michal Orzel <michal.orzel@amd.com>

~Michal
Re: [PATCH] xen/arm: its: only clean cache when sending ITS command
Posted by Daisuke Nishimura 5 days, 22 hours ago
Hi, Orzel.

Thank you for your review and comment.
I'll update the commit message based on your comment,
and resend the patch.

Daisuke Nishimura

On Tue, 17 Nov 2026 08:45:27 +0100
"Orzel, Michal" <michal.orzel@amd.com> wrote:

> 
> 
> On 17-Nov-26 04:32, Daisuke Nishimura wrote:
> > From: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> > 
> > There is no need to invalidate cache entry because we just wrote
> > that memory. So it is guaranteed that cache entry is valid.
> I don't think this is a good rationale. What makes invalidation not
> needed here is that the CPU is the only writer and the ITS the only
> reader of this buffer, so the cached data cannot be stale.
> Invalidation would be needed if a device wrote a buffer that the CPU
> later reads.
> 
> > 
> > But we need to clean (flush) cache line to be sure that ITS sees
> flush means clean+invalidate, which is what you drop, so please drop
> "flush" word.
> 
> > command written into the memory.
> > 
> > Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> > Signed-off-by: Daisuke Nishimura <nishimura@valinux.co.jp>
> With that:
> Reviewed-by: Michal Orzel <michal.orzel@amd.com>
> 
> ~Michal
>
[PATCH v2] xen/arm: its: only clean cache when sending ITS command
Posted by Daisuke Nishimura 5 days, 20 hours ago
From: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

There is no need to invalidate the cache entry because the CPU is the only
writer and the ITS is the only reader of this buffer, so it is guaranteed
that the cached data cannot be stale.

However, we still need to clean the cache line to be sure that ITS sees
the command written into memory.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Signed-off-by: Daisuke Nishimura <nishimura@valinux.co.jp>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
---
(cherry picked from commit fe7142bca56b5c8c8109f581444f89ae09b7544f xen-troops)

v2: Update the commit message.
---
 xen/arch/arm/gic-v3-its.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
index 325835b0ad..dc44666233 100644
--- a/xen/arch/arm/gic-v3-its.c
+++ b/xen/arch/arm/gic-v3-its.c
@@ -207,8 +207,7 @@ static int its_send_command(struct host_its *hw_its, const void *its_cmd)
 
     memcpy(hw_its->cmd_buf + writep, its_cmd, ITS_CMD_SIZE);
     if ( hw_its->flags & HOST_ITS_FLUSH_CMD_QUEUE )
-        clean_and_invalidate_dcache_va_range(hw_its->cmd_buf + writep,
-                                             ITS_CMD_SIZE);
+        clean_dcache_va_range(hw_its->cmd_buf + writep, ITS_CMD_SIZE);
     else
         dsb(ishst);
 
-- 
2.43.0