Skip to content

Commit 4b4e1e1

Browse files
gzhai7lijinxia
authored andcommitted
DM: Add option of no check against ptdev reset
With '--ptdev_no_reset', DM doen not abort but warn when assign PCIe dev without reset capability. Signed-off-by: Edwin Zhai <edwin.zhai@intel.com> Acked-by: Kevin Tian <kevin.tian@intel.com>
1 parent b19d936 commit 4b4e1e1

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

devicemodel/core/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ usage(int code)
162162
" -i: ioc boot parameters\n"
163163
" --vsbl: vsbl file path\n"
164164
" --part_info: guest partition info file path\n"
165-
" --enable_trusty: enable trusty for guest\n",
165+
" --enable_trusty: enable trusty for guest\n"
166+
" --ptdev_no_reset: disable reset check for ptdev\n",
166167
progname, (int)strlen(progname), "", (int)strlen(progname), "",
167168
(int)strlen(progname), "");
168169

@@ -593,6 +594,7 @@ enum {
593594
CMD_OPT_VSBL = 1000,
594595
CMD_OPT_PART_INFO,
595596
CMD_OPT_TRUSTY_ENABLE,
597+
CMD_OPT_PTDEV_NO_RESET,
596598
};
597599

598600
static struct option long_options[] = {
@@ -629,6 +631,8 @@ static struct option long_options[] = {
629631
{"part_info", required_argument, 0, CMD_OPT_PART_INFO},
630632
{"enable_trusty", no_argument, 0,
631633
CMD_OPT_TRUSTY_ENABLE},
634+
{"ptdev_no_reset", no_argument, 0,
635+
CMD_OPT_PTDEV_NO_RESET},
632636
{0, 0, 0, 0 },
633637
};
634638

@@ -795,6 +799,9 @@ main(int argc, char *argv[])
795799
case CMD_OPT_TRUSTY_ENABLE:
796800
trusty_enabled = 1;
797801
break;
802+
case CMD_OPT_PTDEV_NO_RESET:
803+
ptdev_no_reset(true);
804+
break;
798805
case 'h':
799806
usage(0);
800807
default:

devicemodel/hw/pci/passthrough.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ static pthread_mutex_t ref_cnt_mtx = PTHREAD_MUTEX_INITIALIZER;
9191
/* Prefer MSI over INTx for ptdev */
9292
static bool prefer_msi = true;
9393

94+
/* Not check reset capability before assign ptdev.
95+
* Set false by default, that is, always check.
96+
*/
97+
static bool no_reset = false;
98+
9499
struct passthru_dev {
95100
struct pci_vdev *dev;
96101
struct pcibar bar[PCI_BARMAX + 1];
@@ -116,6 +121,11 @@ ptdev_prefer_msi(bool enable)
116121
prefer_msi = enable;
117122
}
118123

124+
void ptdev_no_reset(bool enable)
125+
{
126+
no_reset = enable;
127+
}
128+
119129
static int
120130
msi_caplen(int msgctrl)
121131
{
@@ -846,7 +856,8 @@ cfginit(struct vmctx *ctx, struct passthru_dev *ptdev, int bus,
846856
warnx("No reset capability for PCIe %x/%x/%x, "
847857
"remove it from ptdev list!!\n",
848858
bus, slot, func);
849-
return -1;
859+
if (!no_reset)
860+
return -1;
850861
}
851862
}
852863

devicemodel/include/dm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len);
4949
void *dm_gpa2hva(uint64_t gpa, size_t size);
5050
int virtio_uses_msix(void);
5151
void ptdev_prefer_msi(bool enable);
52+
void ptdev_no_reset(bool enable);
5253
#endif

0 commit comments

Comments
 (0)