Re: [PATCH] add delay between port write and port read
From: Will Deacon (will.deacon@xxxxxxx)
Date: Wed Feb 27 2019 - 12:26:27 EST
On Wed, Feb 27, 2019 at 12:12:51PM -0500, Mikulas Patocka wrote:
> On Tue, 26 Feb 2019, Linus Torvalds wrote:
> > Does anybody see any worries with the "just move the mb() earlier in
> > the ioread functions" model?
> > Linus
> It used to be like that and it worked.
> Then, commits cd0e00c106722eca40b38ebf11cf134c01901086 and
> 92d7223a74235054f2aa7227d207d9c57f84dca0 came.
> These commits claim that they changed the code to be consistent with the
> specification (now we have barrier after ioread and before iowrite). But
> they broke serial port and RTC on my Alpha machine.
I suppose you might need the mb() before *and* after the I/O access in the
read case. The idea with readX()/ioreadX() is that you should be able to
do something like:
status = ioread8(STATUS_REG);
if (status & RX_DMA_COMPLETE)
memcpy(mem_buf, dma_buf, size);
and rely on the DMA'd data being read out of the buffer.