Skip to content

Commit

Permalink
vfio/quirks: Add quirk reset callback
Browse files Browse the repository at this point in the history
Quirks can be self modifying, provide a hook to allow them to cleanup
on device reset if desired.

Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Alex Williamson <[email protected]>
  • Loading branch information
awilliam committed Jun 5, 2018
1 parent bcf3c3d commit 469d02d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hw/vfio/pci-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,21 @@ void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr)
/*
* Reset quirks
*/
void vfio_quirk_reset(VFIOPCIDevice *vdev)
{
int i;

for (i = 0; i < PCI_ROM_SLOT; i++) {
VFIOQuirk *quirk;
VFIOBAR *bar = &vdev->bars[i];

QLIST_FOREACH(quirk, &bar->quirks, next) {
if (quirk->reset) {
quirk->reset(vdev, quirk);
}
}
}
}

/*
* AMD Radeon PCI config reset, based on Linux:
Expand Down
2 changes: 2 additions & 0 deletions hw/vfio/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,8 @@ static void vfio_pci_post_reset(VFIOPCIDevice *vdev)
vdev->vbasedev.name, nr);
}
}

vfio_quirk_reset(vdev);
}

static bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name)
Expand Down
2 changes: 2 additions & 0 deletions hw/vfio/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef struct VFIOQuirk {
void *data;
int nr_mem;
MemoryRegion *mem;
void (*reset)(struct VFIOPCIDevice *vdev, struct VFIOQuirk *quirk);
} VFIOQuirk;

typedef struct VFIOBAR {
Expand Down Expand Up @@ -167,6 +168,7 @@ void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr);
void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr);
void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev);
int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp);
void vfio_quirk_reset(VFIOPCIDevice *vdev);

extern const PropertyInfo qdev_prop_nv_gpudirect_clique;

Expand Down

0 comments on commit 469d02d

Please sign in to comment.