[SeaBIOS] [PATCH 1/2] Add QEMU fw_cfg DMA interface
Kevin O'Connor
kevin at koconnor.net
Thu Aug 6 18:59:38 CET 2015
On Thu, Aug 06, 2015 at 06:15:57PM +0200, Laszlo Ersek wrote:
> On 08/06/15 14:35, Stefan Hajnoczi wrote:
> > On Thu, Aug 6, 2015 at 12:02 PM, Marc Marí <markmb at redhat.com> wrote:
> >> + if (qemu_cfg_dma_enabled()) {
> >> + QemuCfgDmaAccess access;
> >> +
> >> + access.address = (u64)(u32)buf;
> >> + access.length = len;
> >> + access.control = QEMU_CFG_DMA_CTL_READ;
> >> +
> >> + /*
> >> + * The out is done before the write of the variables on memory. This
> >> + * causes misread on the QEMU side.
> >> + */
> >> + barrier();
> >> +
> >> + outl((u32)&access, PORT_QEMU_CFG_DMA_ADDR);
> >
> > I thought PORT_QEMU_CFG_DMA_ADDR is a 64-bit register according to the
> > spec you posted?
> >
> >> + while(access.length != 0 && !(access.control & QEMU_CFG_DMA_CTL_ERROR));
> >
> > Either the field accesses need to be marked volatile, or a barrier is
> > needed to force the compiler to reload these register from memory each
> > iteration of the loop.
>
> Better yet, I would recommend declaring (and here, also defining)
> "access" as "volatile".
>
> volatile QemuCfgDmaAccess access;
I'd prefer to avoid volatile for the reasons described at:
https://www.kernel.org/doc/Documentation/volatile-considered-harmful.txt
I think barrier() and yield() are what we want - in particular, we
really do want to yield() while busy so that interrupts and other code
can continue to run.
-Kevin
More information about the SeaBIOS
mailing list