Re: [External] Re: [PATCH] iommu: riscv: Split 8-byte accesses on 32 bit I/O bus platform
From: Jason Gunthorpe
Date: Tue Apr 01 2025 - 11:44:44 EST
On Wed, Mar 26, 2025 at 11:26:07AM +0800, Xu Lu wrote:
> Hi Jessica,
>
> > Is such a platform conformant to the specification?
>
> We have talked about this before [1]. I think the IOMMU spec does not
> mandate the implementation of 8-byte access functionality. The related
> sentences are listed below:
>
> "The 8-byte IOMMU registers are defined in such a way that software
> can perform two individual 4-byte accesses, or hardware can perform
> two independent 4-byte transactions resulting from an 8-byte access,
> to the high and low halves of the register, in that order, as long as
> the register semantics, with regard to side-effects, are respected
> between the two software accesses, or two hardware transactions,
> respectively."
I think the commit message should explain an anyalsis that the code is
safe against the mentioned side effects due to ordering.
And a comment should explain this:
+#define riscv_iommu_writeq(iommu, addr, val) \
+ ((addr == RISCV_IOMMU_REG_IOHPMCYCLES) ? \
+ lo_hi_writeq_relaxed((val), (iommu)->reg + (addr)) : \
+ hi_lo_writeq_relaxed((val), (iommu)->reg + (addr)))
As the naive reading of the above spec paragraph doesn't seem like
there are exceptions or why one register has to be the opposite order.
Also missing () around addr
Jason