Revert "DM: reset each ptdev before assignment"

This reverts commit c12ea98d8d.
This commit is contained in:
lijinxia 2018-06-27 14:15:32 +08:00
parent eceb24ac60
commit 0648f01e55

View File

@ -37,8 +37,6 @@
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <pciaccess.h> #include <pciaccess.h>
#include <fcntl.h>
#include <unistd.h>
#include "iodev.h" #include "iodev.h"
#include "vmmapi.h" #include "vmmapi.h"
@ -810,7 +808,7 @@ cfginit(struct vmctx *ctx, struct passthru_dev *ptdev, int bus,
{ {
int irq_type = IRQ_MSI; int irq_type = IRQ_MSI;
char reset_path[60]; char reset_path[60];
int fd; FILE *f;
bzero(&ptdev->sel, sizeof(struct pcisel)); bzero(&ptdev->sel, sizeof(struct pcisel));
ptdev->sel.bus = bus; ptdev->sel.bus = bus;
@ -830,28 +828,25 @@ cfginit(struct vmctx *ctx, struct passthru_dev *ptdev, int bus,
irq_type = IRQ_INTX; irq_type = IRQ_INTX;
} }
/* If SOS kernel provides 'reset' entry in sysfs, related dev has some /* Check reset method for PCIe dev. If SOS kernel provides 'reset'
* reset capability, e.g. FLR, or secondary bus reset. We do 2 things: * entry in sysfs, related dev has some reset capability, e.g. FLR, or
* - reset each dev before passthrough to achieve valid dev state after * secondary bus reset. PCIe dev without any reset capability is
* UOS reboot * refused for passthrough.
* - refuse to passthrough PCIe dev without any reset capability
*/ */
snprintf(reset_path, 40, if (ptdev->pcie_cap) {
"/sys/bus/pci/devices/0000:%02x:%02x.%x/reset", snprintf(reset_path, 40,
bus, slot, func); "/sys/bus/pci/devices/0000:%02x:%02x.%x/reset",
bus, slot, func);
fd = open(reset_path, O_WRONLY); if ((f = fopen(reset_path, "r")))
if (fd >= 0) { fclose(f);
if (write(fd, "1", 1) < 0) else if (errno == ENOENT) {
warnx("reset dev %x/%x/%x failed!\n", warnx("No reset capability for PCIe %x/%x/%x, "
bus, slot, func); "remove it from ptdev list!!\n",
close(fd); bus, slot, func);
} else if (errno == ENOENT && ptdev->pcie_cap) { if (!no_reset)
warnx("No reset capability for PCIe %x/%x/%x, " return -1;
"remove it from ptdev list!!\n", }
bus, slot, func);
if (!no_reset)
return -1;
} }
if (cfginitbar(ctx, ptdev) != 0) { if (cfginitbar(ctx, ptdev) != 0) {