Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/virtio/block/virtio_blk.c
Show First 20 Lines • Show All 391 Lines • ▼ Show 20 Lines | error = bus_dma_tag_create( | ||||
busdma_lock_mutex, /* lockfunc */ | busdma_lock_mutex, /* lockfunc */ | ||||
&sc->vtblk_mtx, /* lockarg */ | &sc->vtblk_mtx, /* lockarg */ | ||||
&sc->vtblk_dmat); | &sc->vtblk_dmat); | ||||
if (error) { | if (error) { | ||||
device_printf(dev, "cannot create bus dma tag\n"); | device_printf(dev, "cannot create bus dma tag\n"); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
#ifdef __powerpc__ | |||||
/* | |||||
* Virtio uses physical addresses rather than bus addresses, so we | |||||
* need to ask busdma to skip the iommu physical->bus mapping. At | |||||
* present, this is only a thing on the powerpc architectures. | |||||
*/ | |||||
bus_dma_tag_set_iommu(sc->vtblk_dmat, NULL, NULL); | |||||
#endif | |||||
error = vtblk_alloc_virtqueue(sc); | error = vtblk_alloc_virtqueue(sc); | ||||
if (error) { | if (error) { | ||||
device_printf(dev, "cannot allocate virtqueue\n"); | device_printf(dev, "cannot allocate virtqueue\n"); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
error = vtblk_request_prealloc(sc); | error = vtblk_request_prealloc(sc); | ||||
if (error) { | if (error) { | ||||
▲ Show 20 Lines • Show All 657 Lines • ▼ Show 20 Lines | if ((sc->vtblk_flags & VTBLK_FLAG_BARRIER) == 0) { | ||||
} | } | ||||
} | } | ||||
sglist_reset(sg); | sglist_reset(sg); | ||||
sglist_append(sg, &req->vbr_hdr, sizeof(struct virtio_blk_outhdr)); | sglist_append(sg, &req->vbr_hdr, sizeof(struct virtio_blk_outhdr)); | ||||
if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) { | if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) { | ||||
/* | /* | ||||
* We cast bus_addr_t to vm_paddr_t here; this isn't valid on | * We cast bus_addr_t to vm_paddr_t here; since we skip the | ||||
* all platforms, but we believe it works on all platforms | * iommu mapping (see vtblk_attach) this should be safe. | ||||
* which are supported by virtio. | |||||
*/ | */ | ||||
for (i = 0; i < nseg; i++) { | for (i = 0; i < nseg; i++) { | ||||
error = sglist_append_phys(sg, | error = sglist_append_phys(sg, | ||||
(vm_paddr_t)segs[i].ds_addr, segs[i].ds_len); | (vm_paddr_t)segs[i].ds_addr, segs[i].ds_len); | ||||
if (error || sg->sg_nseg == sg->sg_maxseg) { | if (error || sg->sg_nseg == sg->sg_maxseg) { | ||||
panic("%s: bio %p data buffer too big %d", | panic("%s: bio %p data buffer too big %d", | ||||
__func__, bp, error); | __func__, bp, error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 567 Lines • Show Last 20 Lines |