diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2021-03-01 08:48:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 08:48:10 +0000 |
commit | 064071b5c73d96d626760d0f48aec234eb5da2d6 (patch) | |
tree | 26fc2b83bb56e24064c2b49d0e6cf1eec9cdeed8 /samples | |
parent | f3ae6834f058e047d44cf376c4407a1b1291fffe (diff) | |
download | libvfio-user-064071b5c73d96d626760d0f48aec234eb5da2d6.zip libvfio-user-064071b5c73d96d626760d0f48aec234eb5da2d6.tar.gz libvfio-user-064071b5c73d96d626760d0f48aec234eb5da2d6.tar.bz2 |
optionally enable DMA controller in GPIO sample (#375)
This helps debugging.
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/gpio-pci-idio-16.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/samples/gpio-pci-idio-16.c b/samples/gpio-pci-idio-16.c index 62ae031..b52eafb 100644 --- a/samples/gpio-pci-idio-16.c +++ b/samples/gpio-pci-idio-16.c @@ -125,11 +125,24 @@ migration_write_data(UNUSED vfu_ctx_t *vfu_ctx, void *buf, __u64 size, return 0; } +static void +map_dma(vfu_ctx_t *vfu_ctx UNUSED, uint64_t iova UNUSED, uint64_t len UNUSED, + uint32_t prot UNUSED) +{ +} + +static int +unmap_dma(vfu_ctx_t *vfu_ctx UNUSED, uint64_t iova UNUSED, uint64_t len UNUSED) +{ + return 0; +} + int main(int argc, char *argv[]) { int ret; bool verbose = false; + bool dma = false; char opt; struct sigaction act = { .sa_handler = _sa_handler }; vfu_ctx_t *vfu_ctx; @@ -146,13 +159,16 @@ main(int argc, char *argv[]) .write_data = &migration_write_data }; - while ((opt = getopt(argc, argv, "v")) != -1) { + while ((opt = getopt(argc, argv, "vd")) != -1) { switch (opt) { case 'v': verbose = true; break; + case 'd': + dma = true; + break; default: /* '?' */ - fprintf(stderr, "Usage: %s [-v] <socketpath>\n", argv[0]); + fprintf(stderr, "Usage: %s [-d] [-v] <socketpath>\n", argv[0]); exit(EXIT_FAILURE); } } @@ -211,6 +227,13 @@ main(int argc, char *argv[]) err(EXIT_FAILURE, "failed to setup irq counts"); } + if (dma) { + ret = vfu_setup_device_dma_cb(vfu_ctx, map_dma, unmap_dma); + if (ret < 0) { + err(EXIT_FAILURE, "failed to setup DMA"); + } + } + ret = vfu_realize_ctx(vfu_ctx); if (ret < 0) { err(EXIT_FAILURE, "failed to realize device"); |