From: David Laight <david.laight.linux@gmail.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Xu Lu <luxu.kernel@bytedance.com>,
Jessica Clarke <jrtc27@jrtc27.com>,
tjeznach@rivosinc.com, joro@8bytes.org, will@kernel.org,
robin.murphy@arm.com, alex@ghiti.fr, lihangjing@bytedance.com,
xieyongji@bytedance.com, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, iommu@lists.linux.dev
Subject: Re: [External] Re: [PATCH] iommu: riscv: Split 8-byte accesses on 32 bit I/O bus platform
Date: Tue, 1 Apr 2025 22:02:01 +0100 [thread overview]
Message-ID: <20250401220201.1fa3ec76@pumpkin> (raw)
In-Reply-To: <20250401154412.GI186258@ziepe.ca>
On Tue, 1 Apr 2025 12:44:12 -0300
Jason Gunthorpe <jgg@ziepe.ca> wrote:
> 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
It is also double-evaluating (addr).
I hope there is a lock, interleaved accesses from multiple cpu
may not work.
David
>
> Jason
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-04-01 21:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 14:42 [PATCH] iommu: riscv: Split 8-byte accesses on 32 bit I/O bus platform Xu Lu
2025-03-25 18:50 ` Jessica Clarke
2025-03-26 3:26 ` [External] " Xu Lu
2025-04-01 15:44 ` Jason Gunthorpe
2025-04-01 21:02 ` David Laight [this message]
2025-04-02 12:20 ` Xu Lu
2025-04-02 11:28 ` Robin Murphy
2025-04-02 11:58 ` [External] " Xu Lu
2025-04-02 13:00 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250401220201.1fa3ec76@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=alex@ghiti.fr \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=jrtc27@jrtc27.com \
--cc=lihangjing@bytedance.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=luxu.kernel@bytedance.com \
--cc=robin.murphy@arm.com \
--cc=tjeznach@rivosinc.com \
--cc=will@kernel.org \
--cc=xieyongji@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox