mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-19 01:40:17 +00:00
dm: pci: reset passthrough device by default
Do reset for passthrough PCI device by default when assigning it to post-launched VM: 1. modify opt "reset" to "no_reset" -- could enable no_reset for debug only 2. remove "ptdev_no_reset" opt. It could be replaced by setting "no_reset" for each passthrough device. Tracked-On: #3465 Signed-off-by: Li Fei1 <fei1.li@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
21b405d109
commit
933e2178d0
@ -139,7 +139,7 @@ usage(int code)
|
|||||||
" %*s [-s pci] [-U uuid] [--vsbl vsbl_file_name] [--ovmf ovmf_file_path]\n"
|
" %*s [-s pci] [-U uuid] [--vsbl vsbl_file_name] [--ovmf ovmf_file_path]\n"
|
||||||
" %*s [--part_info part_info_name] [--enable_trusty] [--intr_monitor param_setting]\n"
|
" %*s [--part_info part_info_name] [--enable_trusty] [--intr_monitor param_setting]\n"
|
||||||
" %*s [--vtpm2 sock_path] [--virtio_poll interval] [--mac_seed seed_string]\n"
|
" %*s [--vtpm2 sock_path] [--virtio_poll interval] [--mac_seed seed_string]\n"
|
||||||
" %*s [--vmcfg sub_options] [--dump vm_idx] [--ptdev_no_reset] [--debugexit] \n"
|
" %*s [--vmcfg sub_options] [--dump vm_idx] [--debugexit] \n"
|
||||||
" %*s [--logger-setting param_setting] [--pm_notify_channel]\n"
|
" %*s [--logger-setting param_setting] [--pm_notify_channel]\n"
|
||||||
" %*s [--pm_by_vuart vuart_node] <vm>\n"
|
" %*s [--pm_by_vuart vuart_node] <vm>\n"
|
||||||
" -A: create ACPI tables\n"
|
" -A: create ACPI tables\n"
|
||||||
@ -166,7 +166,6 @@ usage(int code)
|
|||||||
" --ovmf: ovmf file path\n"
|
" --ovmf: ovmf file path\n"
|
||||||
" --part_info: guest partition info file path\n"
|
" --part_info: guest partition info file path\n"
|
||||||
" --enable_trusty: enable trusty for guest\n"
|
" --enable_trusty: enable trusty for guest\n"
|
||||||
" --ptdev_no_reset: disable reset check for ptdev\n"
|
|
||||||
" --debugexit: enable debug exit function\n"
|
" --debugexit: enable debug exit function\n"
|
||||||
" --intr_monitor: enable interrupt storm monitor\n"
|
" --intr_monitor: enable interrupt storm monitor\n"
|
||||||
" its params: threshold/s,probe-period(s),delay_time(ms),delay_duration(ms)\n"
|
" its params: threshold/s,probe-period(s),delay_time(ms),delay_duration(ms)\n"
|
||||||
@ -722,7 +721,6 @@ enum {
|
|||||||
CMD_OPT_TRUSTY_ENABLE,
|
CMD_OPT_TRUSTY_ENABLE,
|
||||||
CMD_OPT_VIRTIO_POLL_ENABLE,
|
CMD_OPT_VIRTIO_POLL_ENABLE,
|
||||||
CMD_OPT_MAC_SEED,
|
CMD_OPT_MAC_SEED,
|
||||||
CMD_OPT_PTDEV_NO_RESET,
|
|
||||||
CMD_OPT_DEBUGEXIT,
|
CMD_OPT_DEBUGEXIT,
|
||||||
CMD_OPT_VMCFG,
|
CMD_OPT_VMCFG,
|
||||||
CMD_OPT_DUMP,
|
CMD_OPT_DUMP,
|
||||||
@ -763,8 +761,6 @@ static struct option long_options[] = {
|
|||||||
CMD_OPT_TRUSTY_ENABLE},
|
CMD_OPT_TRUSTY_ENABLE},
|
||||||
{"virtio_poll", required_argument, 0, CMD_OPT_VIRTIO_POLL_ENABLE},
|
{"virtio_poll", required_argument, 0, CMD_OPT_VIRTIO_POLL_ENABLE},
|
||||||
{"mac_seed", required_argument, 0, CMD_OPT_MAC_SEED},
|
{"mac_seed", required_argument, 0, CMD_OPT_MAC_SEED},
|
||||||
{"ptdev_no_reset", no_argument, 0,
|
|
||||||
CMD_OPT_PTDEV_NO_RESET},
|
|
||||||
{"debugexit", no_argument, 0, CMD_OPT_DEBUGEXIT},
|
{"debugexit", no_argument, 0, CMD_OPT_DEBUGEXIT},
|
||||||
{"intr_monitor", required_argument, 0, CMD_OPT_INTR_MONITOR},
|
{"intr_monitor", required_argument, 0, CMD_OPT_INTR_MONITOR},
|
||||||
{"vtpm2", required_argument, 0, CMD_OPT_VTPM2},
|
{"vtpm2", required_argument, 0, CMD_OPT_VTPM2},
|
||||||
@ -899,9 +895,6 @@ main(int argc, char *argv[])
|
|||||||
mac_seed_str[sizeof(mac_seed_str) - 1] = '\0';
|
mac_seed_str[sizeof(mac_seed_str) - 1] = '\0';
|
||||||
mac_seed = mac_seed_str;
|
mac_seed = mac_seed_str;
|
||||||
break;
|
break;
|
||||||
case CMD_OPT_PTDEV_NO_RESET:
|
|
||||||
ptdev_no_reset(true);
|
|
||||||
break;
|
|
||||||
case CMD_OPT_DEBUGEXIT:
|
case CMD_OPT_DEBUGEXIT:
|
||||||
debugexit_enabled = true;
|
debugexit_enabled = true;
|
||||||
break;
|
break;
|
||||||
|
@ -75,11 +75,6 @@ extern uint64_t audio_nhlt_len;
|
|||||||
static int pciaccess_ref_cnt;
|
static int pciaccess_ref_cnt;
|
||||||
static pthread_mutex_t ref_cnt_mtx = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t ref_cnt_mtx = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
/* Not check reset capability before assign ptdev.
|
|
||||||
* Set false by default, that is, always check.
|
|
||||||
*/
|
|
||||||
static bool no_reset = false;
|
|
||||||
|
|
||||||
struct mmio_map {
|
struct mmio_map {
|
||||||
uint64_t gpa;
|
uint64_t gpa;
|
||||||
uint64_t hpa;
|
uint64_t hpa;
|
||||||
@ -117,11 +112,6 @@ struct passthru_dev {
|
|||||||
struct mmio_map msix_bar_mmio[2];
|
struct mmio_map msix_bar_mmio[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
void ptdev_no_reset(bool enable)
|
|
||||||
{
|
|
||||||
no_reset = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
msi_caplen(int msgctrl)
|
msi_caplen(int msgctrl)
|
||||||
{
|
{
|
||||||
@ -671,22 +661,18 @@ cfginit(struct vmctx *ctx, struct passthru_dev *ptdev, int bus,
|
|||||||
* UOS reboot
|
* UOS reboot
|
||||||
* - refuse to passthrough PCIe dev without any reset capability
|
* - refuse to passthrough PCIe dev without any reset capability
|
||||||
*/
|
*/
|
||||||
|
if (ptdev->need_reset) {
|
||||||
snprintf(reset_path, 40,
|
snprintf(reset_path, 40,
|
||||||
"/sys/bus/pci/devices/0000:%02x:%02x.%x/reset",
|
"/sys/bus/pci/devices/0000:%02x:%02x.%x/reset",
|
||||||
bus, slot, func);
|
bus, slot, func);
|
||||||
|
|
||||||
fd = open(reset_path, O_WRONLY);
|
fd = open(reset_path, O_WRONLY);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
if (ptdev->need_reset && write(fd, "1", 1) < 0)
|
if (write(fd, "1", 1) < 0)
|
||||||
warnx("reset dev %x/%x/%x failed!\n",
|
warnx("reset dev %x/%x/%x failed!\n",
|
||||||
bus, slot, func);
|
bus, slot, func);
|
||||||
close(fd);
|
close(fd);
|
||||||
} else if (errno == ENOENT && ptdev->pcie_cap) {
|
}
|
||||||
warnx("No reset capability for PCIe %x/%x/%x, "
|
|
||||||
"remove it from ptdev list!!\n",
|
|
||||||
bus, slot, func);
|
|
||||||
if (!no_reset)
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfginitbar(ctx, ptdev) != 0) {
|
if (cfginitbar(ctx, ptdev) != 0) {
|
||||||
@ -767,7 +753,7 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
struct pci_device *phys_dev;
|
struct pci_device *phys_dev;
|
||||||
char *opt;
|
char *opt;
|
||||||
bool keep_gsi = false;
|
bool keep_gsi = false;
|
||||||
bool need_reset = false;
|
bool need_reset = true;
|
||||||
|
|
||||||
ptdev = NULL;
|
ptdev = NULL;
|
||||||
error = -EINVAL;
|
error = -EINVAL;
|
||||||
@ -786,8 +772,8 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
while ((opt = strsep(&opts, ",")) != NULL) {
|
while ((opt = strsep(&opts, ",")) != NULL) {
|
||||||
if (!strncmp(opt, "keep_gsi", 8))
|
if (!strncmp(opt, "keep_gsi", 8))
|
||||||
keep_gsi = true;
|
keep_gsi = true;
|
||||||
else if (!strncmp(opt, "reset", 5))
|
else if (!strncmp(opt, "no_reset", 8))
|
||||||
need_reset = true;
|
need_reset = false;
|
||||||
else
|
else
|
||||||
warnx("Invalid passthru options:%s", opt);
|
warnx("Invalid passthru options:%s", opt);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,6 @@ int vmexit_task_switch(struct vmctx *ctx, struct vhm_request *vhm_req,
|
|||||||
void *paddr_guest2host(struct vmctx *ctx, uintptr_t gaddr, size_t len);
|
void *paddr_guest2host(struct vmctx *ctx, uintptr_t gaddr, size_t len);
|
||||||
int virtio_uses_msix(void);
|
int virtio_uses_msix(void);
|
||||||
size_t high_bios_size(void);
|
size_t high_bios_size(void);
|
||||||
void ptdev_no_reset(bool enable);
|
|
||||||
void init_debugexit(void);
|
void init_debugexit(void);
|
||||||
void deinit_debugexit(void);
|
void deinit_debugexit(void);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user