svn commit: r298476 - head/sys/riscv/htif
Ruslan Bukin
br at FreeBSD.org
Fri Apr 22 15:12:06 UTC 2016
Author: br
Date: Fri Apr 22 15:12:05 2016
New Revision: 298476
URL: https://svnweb.freebsd.org/changeset/base/298476
Log:
Add memory barriers (fence instructions) so the data wrotten by hardware
to physical address now can be read by VA.
This fixes operation on Rocket Core (FPGA).
Sponsored by: DARPA, AFRL
Sponsored by: HEIF5
Modified:
head/sys/riscv/htif/htif_block.c
Modified: head/sys/riscv/htif/htif_block.c
==============================================================================
--- head/sys/riscv/htif/htif_block.c Fri Apr 22 15:08:50 2016 (r298475)
+++ head/sys/riscv/htif/htif_block.c Fri Apr 22 15:12:05 2016 (r298476)
@@ -115,6 +115,7 @@ htif_blk_intr(void *arg, uint64_t entry)
data = HTIF_DEV_DATA(entry);
if (sc->curtag == data) {
+ wmb();
sc->cmd_done = 1;
wakeup(&sc->intr_chan);
} else {
@@ -198,6 +199,7 @@ htif_blk_task(void *arg)
{
struct htif_blk_request req __aligned(HTIF_ALIGN);
struct htif_blk_softc *sc;
+ uint64_t req_paddr;
struct bio *bp;
uint64_t paddr;
uint64_t cmd;
@@ -217,11 +219,13 @@ htif_blk_task(void *arg)
if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) {
HTIF_BLK_LOCK(sc);
+ rmb();
req.offset = (bp->bio_pblkno * sc->disk->d_sectorsize);
req.size = bp->bio_bcount;
paddr = vtophys(bp->bio_data);
KASSERT(paddr != 0, ("paddr is 0"));
req.addr = paddr;
+ sc->curtag++;
req.tag = sc->curtag;
cmd = sc->index;
@@ -230,9 +234,9 @@ htif_blk_task(void *arg)
cmd |= (HTIF_CMD_READ << HTIF_CMD_SHIFT);
else
cmd |= (HTIF_CMD_WRITE << HTIF_CMD_SHIFT);
- paddr = vtophys(&req);
- KASSERT(paddr != 0, ("paddr is 0"));
- cmd |= paddr;
+ req_paddr = vtophys(&req);
+ KASSERT(req_paddr != 0, ("req_paddr is 0"));
+ cmd |= req_paddr;
sc->cmd_done = 0;
htif_command(cmd);
More information about the svn-src-head
mailing list