RE: [PATCH] iommu/vt-d: Handle volatile descriptor status read
From: Tian, Kevin
Date: Sun Jun 16 2024 - 23:04:47 EST
> From: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
> Sent: Saturday, June 8, 2024 1:38 AM
>
> Queued invalidation wait descriptor status is volatile in that IOMMU
> hardware
> writes the data upon completion.
>
> Use READ_ONCE() to prevent compiler optimizations which ensures memory
> reads every time. As a side effect, READ_ONCE() also enforces strict types
> and
> may add an extra instruction. But it should not have negative
> performance impact since we use cpu_relax anyway and the extra time(by
> adding an instruction) may allow IOMMU HW request cacheline ownership
> easier.
I didn't get the meaning of the last sentence.
>
> e.g. gcc 12.3
> BEFORE:
> 81 38 ad de 00 00 cmpl $0x2,(%rax)
>
> AFTER (with READ_ONCE())
> 772f: 8b 00 mov (%rax),%eax
> 7731: 3d ad de 00 00 cmp $0x2,%eax //status data is 32 bit
>
> Signed-off-by: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
Do we need a fix tag here?
otherwise looks good to me:
Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>