History log of /src/sys/dev/virtio/block/virtio_blk.c (Results 1 – 25 of 295)
Revision Date Author Comments
# c8c37141 03-Mar-2026 Sarah Walker <sarah.walker2@arm.com>

virtio_blk: Use bus_dma for command/ack buffer allocations

While the majority of virtio platforms will be fully coherent, some may
require cache maintenance or other specific device memory handling

virtio_blk: Use bus_dma for command/ack buffer allocations

While the majority of virtio platforms will be fully coherent, some may
require cache maintenance or other specific device memory handling (eg for
secure partitioning). Using bus_dma allows for these usecases.

The virtio buffers are marked as coherent; this should ensure that sync
calls are no-ops in the common cases.

Reviewed by: andrew, br
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D54960

show more ...


# cbc2e346 23-Jun-2025 Andrew Turner <andrew@FreeBSD.org>

virtio_blk: Limit use of indirect descriptors

Pass 0 as the number of indirect descriptors when they are not
supported.

This fixes an issue on the Arm FVP model where we don't negotiate
them, howev

virtio_blk: Limit use of indirect descriptors

Pass 0 as the number of indirect descriptors when they are not
supported.

This fixes an issue on the Arm FVP model where we don't negotiate
them, however pass a number of segments greater than
VIRTIO_MAX_INDIRECT. This leads to virtqueue_alloc failing and
virtio_blk failing to attach.

Reviewed by: Harry Moulton <harry.moulton@arm.com>
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D50909

show more ...


# dec24dbb 27-May-2025 Robert Wing <rew@FreeBSD.org>

diskinfo: print attachment field for virtio_blk devices

PR: 286280
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D50489


# b1dd0670 04-Jul-2024 Mark Johnston <markj@FreeBSD.org>

vtblk: Invoke busdma completion callbacks when polling

vtblk_poll_request() is used for kernel dumps and for fetching the block
device's identifier string during device probing. In the latter case,

vtblk: Invoke busdma completion callbacks when polling

vtblk_poll_request() is used for kernel dumps and for fetching the block
device's identifier string during device probing. In the latter case,
it was not calling bus_dmamap_sync() after completing the I/O, but this
is required in general.

Thus:
- Factor out per-request code from vtblk_queue_completed().
- Use it in vtblk_poll_request() once virtqueue_poll() finishes.
- While here, assert that virtqueue_poll() returns the request that we
expect.

Reported by: KMSAN
Fixes: 782105f7c898 ("vtblk: Use busdma")
Reviewed by: cperciva, imp
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D45665

show more ...


# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remov

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix

show more ...


# 180c0240 18-Sep-2023 Mina Galić <freebsd@igalic.co>

virtio: remove virtio_alloc_virtqueues' flags arg

Summary:
the flags argument is unused.
Its initial design idea has been superceded by the addition of
virtio_setup_intr and related APIs.

Sponsored

virtio: remove virtio_alloc_virtqueues' flags arg

Summary:
the flags argument is unused.
Its initial design idea has been superceded by the addition of
virtio_setup_intr and related APIs.

Sponsored by: The FreeBSD Foundation

Reviewers: bryanv

Reviewed By: bryanv

Subscribers: cognet, imp

Differential Revision: https://reviews.freebsd.org/D41850

show more ...


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

show more ...


# 6f514145 09-Jan-2023 Mitchell Horne <mhorne@FreeBSD.org>

vtblk: secondary fix for dumping

The code paths while dumping do not got through busdma. As such,
safeguard against calling bus_dmamap_sync() with a NULL map. The x86
implementation tolerates this b

vtblk: secondary fix for dumping

The code paths while dumping do not got through busdma. As such,
safeguard against calling bus_dmamap_sync() with a NULL map. The x86
implementation tolerates this but others do not, resulting in a
NULL dereference panic when dumping to a vtblk device on arm64, riscv,
etc.

Fixes: 782105f7c898 ("vtblk: Use busdma")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37990

show more ...


# 9af32ef5 28-Dec-2022 Colin Percival <cperciva@FreeBSD.org>

vtblk: Bypass iommu on powerpc

Virtio operates with physical addresses, while busdma is designed to
map these to produce bus addresses. On most supported platforms,
these two are interchangeable; o

vtblk: Bypass iommu on powerpc

Virtio operates with physical addresses, while busdma is designed to
map these to produce bus addresses. On most supported platforms,
these two are interchangeable; on powerpc platforms, they are not.

When on powerpc, set an IOMMU of NULL, which causes the powerpc busdma
code to bypass the iommu mapping; this leaves us with the physical
buffer addresses which the virtio host expects to see.

Tested by: alfredo
Fixes: 782105f7c898 ("vtblk: Use busdma")
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D37891

show more ...


# 75549de7 03-Nov-2022 Colin Percival <cperciva@FreeBSD.org>

vtblk: Fix dumping

Now that vtblk uses busdma, it keeps important information inside its
request structures. The functions used for kernel dumps synthesize
their own request structures rather than

vtblk: Fix dumping

Now that vtblk uses busdma, it keeps important information inside its
request structures. The functions used for kernel dumps synthesize
their own request structures rather than using structures initialized
with the necessary bits for busdma.

Add busdma-bypass paths. Since dumping writes contiguous blocks of
physical memory, vtblk doesn't need busdma in that case.

Reported by: glebius
Tested by: glebius
Differential Revision: https://reviews.freebsd.org/D37243

show more ...


# 782105f7 21-Sep-2022 Colin Percival <cperciva@FreeBSD.org>

vtblk: Use busdma

We assume that bus addresses from busdma are the same thing as
"physical" addresses in the Virtio specification; this seems to
be true for the platforms on which Virtio is currentl

vtblk: Use busdma

We assume that bus addresses from busdma are the same thing as
"physical" addresses in the Virtio specification; this seems to
be true for the platforms on which Virtio is currently supported.

For block devices which are limited to a single data segment per
I/O, we request PAGE_SIZE alignment from busdma; this is necessary
in order to support unaligned I/Os from userland, which may cross
a boundary between two non-physically-contiguous pages. On devices
which support more data segments per I/O, we retain the existing
behaviour of limiting I/Os to (max data segs - 1) * PAGE_SIZE.

Reviewed by: bryanv
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D36667

show more ...


# 3a8aff9d 18-Sep-2022 Colin Percival <cperciva@FreeBSD.org>

vtblk: Include pointer to softc in request

No functional change intended.

Reviewed by: bryanv, imp
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/

vtblk: Include pointer to softc in request

No functional change intended.

Reviewed by: bryanv, imp
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D36666

show more ...


# cc25cfc9 18-Sep-2022 Colin Percival <cperciva@FreeBSD.org>

vtblk: Requeue inside vtblk_request_execute

Most virtio_blk requests are launched from vtblk_startio; prior to this
commit, if vtblk_request_execute failed (e.g. due to a lack of space on
the virtio

vtblk: Requeue inside vtblk_request_execute

Most virtio_blk requests are launched from vtblk_startio; prior to this
commit, if vtblk_request_execute failed (e.g. due to a lack of space on
the virtio queue) vtblk_startio would requeue the request to be
reattempted later.

Add a flag "vbr_requeue_on_error" to requests and perform the requeuing
from inside vtblk_request_execute instead.

No functional change intended.

Reviewed by: bryanv, imp
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D36665

show more ...


# 86f8f5cc 18-Sep-2022 Colin Percival <cperciva@FreeBSD.org>

vtblk: Make vtblk_request_execute return void.

The error, if any, now gets stashed in the request structure. (Step 1
of reworking this driver to use busdma.)

No functional change intended.

Review

vtblk: Make vtblk_request_execute return void.

The error, if any, now gets stashed in the request structure. (Step 1
of reworking this driver to use busdma.)

No functional change intended.

Reviewed by: bryanv, imp
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D36664

show more ...


# 489ba222 13-May-2022 Mitchell Horne <mhorne@FreeBSD.org>

kerneldump: remove physical argument from d_dumper

The physical address argument is essentially ignored by every dumper
method. In addition, the dump routines don't actually pass a real
address; eve

kerneldump: remove physical argument from d_dumper

The physical address argument is essentially ignored by every dumper
method. In addition, the dump routines don't actually pass a real
address; every call to dump_append() passes a value of zero for
physical.

Reviewed by: markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35173

show more ...


# 5c4c96d3 06-May-2022 John Baldwin <jhb@FreeBSD.org>

virtio: Remove unused devclass arguments to DRIVER_MODULE.


# 710c0556 11-Aug-2021 Mark Johnston <markj@FreeBSD.org>

virtio: Add KMSAN hooks for network and block devices

This ensures that host-written data is marked as initialized.

Sponsored by: The FreeBSD Foundation


# 4e1e1d66 05-May-2021 Ka Ho Ng <khng@FreeBSD.org>

virtio_blk: Fix issuing T_GET_ID before DRIVER_OK status

DRIVER_OK status is set after device_attach() succeeds. For now postpone
disk_create to attach_completed() method.

MFC after: 2 weeks
Sponso

virtio_blk: Fix issuing T_GET_ID before DRIVER_OK status

DRIVER_OK status is set after device_attach() succeeds. For now postpone
disk_create to attach_completed() method.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Reviewed by: grehan
Approved by: lwhsu (mentor)
Differential Revision: https://reviews.freebsd.org/D30049

show more ...


# 633218ee 21-Jan-2021 Jessica Clarke <jrtc27@FreeBSD.org>

virtio: Reduce boilerplate for device driver module definitions

Rather than have every device register itself for both virtio_pci and
virtio_mmio, provide a VIRTIO_DRIVER_MODULE wrapper to declare b

virtio: Reduce boilerplate for device driver module definitions

Rather than have every device register itself for both virtio_pci and
virtio_mmio, provide a VIRTIO_DRIVER_MODULE wrapper to declare both,
merge VIRTIO_SIMPLE_PNPTABLE with VIRTIO_SIMPLE_PNPINFO and make the
latter register for both buses. This also has the benefit of abstracting
away the available transports and their names.

Reviewed by: bryanv
Differential Revision: https://reviews.freebsd.org/D28073

show more ...


# e6cc42f1 19-Jan-2021 Bryan Venteicher <bryanv@FreeBSD.org>

virtio: Handle possible failure of virtio_finalize_features()

Try to standardize how drivers negotiate feature and the
function names

Reviewed by: grehan (mentor)
Differential Revision: https://rev

virtio: Handle possible failure of virtio_finalize_features()

Try to standardize how drivers negotiate feature and the
function names

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27930

show more ...


# 149ab110 19-Jan-2021 Bryan Venteicher <bryanv@FreeBSD.org>

virtio_blk: Use DISKFLAG_WRITE_PROTECT for RO disks

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27905


# d7f979be 19-Jan-2021 Bryan Venteicher <bryanv@FreeBSD.org>

virtio_blk: Add modern (V1) support

Rework the header file changes from 2cc8a52 to use our
canonical upstream, Linux.

geom_disk already checks DISKFLAG_CANDELETE for BIO_DELETE
so remove an unneces

virtio_blk: Add modern (V1) support

Rework the header file changes from 2cc8a52 to use our
canonical upstream, Linux.

geom_disk already checks DISKFLAG_CANDELETE for BIO_DELETE
so remove an unnecessary check.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27902

show more ...


# cd853791 28-Nov-2020 Konstantin Belousov <kib@FreeBSD.org>

Make MAXPHYS tunable. Bump MAXPHYS to 1M.

Replace MAXPHYS by runtime variable maxphys. It is initialized from
MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys.

Make b_pag

Make MAXPHYS tunable. Bump MAXPHYS to 1M.

Replace MAXPHYS by runtime variable maxphys. It is initialized from
MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys.

Make b_pages[] array in struct buf flexible. Size b_pages[] for buffer
cache buffers exactly to atop(maxbcachebuf) (currently it is sized to
atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1.
The +1 for pbufs allow several pbuf consumers, among them vmapbuf(),
to use unaligned buffers still sized to maxphys, esp. when such
buffers come from userspace (*). Overall, we save significant amount
of otherwise wasted memory in b_pages[] for buffer cache buffers,
while bumping MAXPHYS to desired high value.

Eliminate all direct uses of the MAXPHYS constant in kernel and driver
sources, except a place which initialize maxphys. Some random (and
arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted
straight. Some drivers, which use MAXPHYS to size embeded structures,
get private MAXPHYS-like constant; their convertion is out of scope
for this work.

Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs,
dev/siis, where either submitted by, or based on changes by mav.

Suggested by: mav (*)
Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions)
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27225

show more ...


# 068dbf36 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

virtio: clean up empty lines in .c and .h files


12345678910>>...12