pci: select memory mapping from driver type
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal_pci.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <string.h>
35 #include <dirent.h>
36 #include <sys/mman.h>
37
38 #include <rte_log.h>
39 #include <rte_pci.h>
40 #include <rte_tailq.h>
41 #include <rte_eal_memconfig.h>
42 #include <rte_malloc.h>
43 #include <rte_devargs.h>
44
45 #include "rte_pci_dev_ids.h"
46 #include "eal_filesystem.h"
47 #include "eal_private.h"
48 #include "eal_pci_init.h"
49
50 /**
51  * @file
52  * PCI probing under linux
53  *
54  * This code is used to simulate a PCI probe by parsing information in sysfs.
55  * When a registered device matches a driver, it is then initialized with
56  * IGB_UIO driver (or doesn't initialize, if the device wasn't bound to it).
57  */
58
59 struct mapped_pci_res_list *pci_res_list = NULL;
60
61 /* unbind kernel driver for this device */
62 static int
63 pci_unbind_kernel_driver(struct rte_pci_device *dev)
64 {
65         int n;
66         FILE *f;
67         char filename[PATH_MAX];
68         char buf[BUFSIZ];
69         struct rte_pci_addr *loc = &dev->addr;
70
71         /* open /sys/bus/pci/devices/AAAA:BB:CC.D/driver */
72         snprintf(filename, sizeof(filename),
73                  SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/driver/unbind",
74                  loc->domain, loc->bus, loc->devid, loc->function);
75
76         f = fopen(filename, "w");
77         if (f == NULL) /* device was not bound */
78                 return 0;
79
80         n = snprintf(buf, sizeof(buf), PCI_PRI_FMT "\n",
81                      loc->domain, loc->bus, loc->devid, loc->function);
82         if ((n < 0) || (n >= (int)sizeof(buf))) {
83                 RTE_LOG(ERR, EAL, "%s(): snprintf failed\n", __func__);
84                 goto error;
85         }
86         if (fwrite(buf, n, 1, f) == 0) {
87                 RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__,
88                                 filename);
89                 goto error;
90         }
91
92         fclose(f);
93         return 0;
94
95 error:
96         fclose(f);
97         return -1;
98 }
99
100 static int
101 pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
102 {
103         int count;
104         char path[PATH_MAX];
105         char *name;
106
107         if (!filename || !dri_name)
108                 return -1;
109
110         count = readlink(filename, path, PATH_MAX);
111         if (count >= PATH_MAX)
112                 return -1;
113
114         /* For device does not have a driver */
115         if (count < 0)
116                 return 1;
117
118         path[count] = '\0';
119
120         name = strrchr(path, '/');
121         if (name) {
122                 strncpy(dri_name, name + 1, strlen(name + 1) + 1);
123                 return 0;
124         }
125
126         return -1;
127 }
128
129 void *
130 pci_find_max_end_va(void)
131 {
132         const struct rte_memseg *seg = rte_eal_get_physmem_layout();
133         const struct rte_memseg *last = seg;
134         unsigned i = 0;
135
136         for (i = 0; i < RTE_MAX_MEMSEG; i++, seg++) {
137                 if (seg->addr == NULL)
138                         break;
139
140                 if (seg->addr > last->addr)
141                         last = seg;
142
143         }
144         return RTE_PTR_ADD(last->addr, last->len);
145 }
146
147
148 /* map a particular resource from a file */
149 void *
150 pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
151                  int additional_flags)
152 {
153         void *mapaddr;
154
155         /* Map the PCI memory resource of device */
156         mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
157                         MAP_SHARED | additional_flags, fd, offset);
158         if (mapaddr == MAP_FAILED) {
159                 RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\n",
160                         __func__, fd, requested_addr,
161                         (unsigned long)size, (unsigned long)offset,
162                         strerror(errno), mapaddr);
163         } else {
164                 RTE_LOG(DEBUG, EAL, "  PCI memory mapped at %p\n", mapaddr);
165         }
166
167         return mapaddr;
168 }
169
170 /* parse the "resource" sysfs file */
171 static int
172 pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
173 {
174         FILE *f;
175         char buf[BUFSIZ];
176         union pci_resource_info {
177                 struct {
178                         char *phys_addr;
179                         char *end_addr;
180                         char *flags;
181                 };
182                 char *ptrs[PCI_RESOURCE_FMT_NVAL];
183         } res_info;
184         int i;
185         uint64_t phys_addr, end_addr, flags;
186
187         f = fopen(filename, "r");
188         if (f == NULL) {
189                 RTE_LOG(ERR, EAL, "Cannot open sysfs resource\n");
190                 return -1;
191         }
192
193         for (i = 0; i<PCI_MAX_RESOURCE; i++) {
194
195                 if (fgets(buf, sizeof(buf), f) == NULL) {
196                         RTE_LOG(ERR, EAL,
197                                 "%s(): cannot read resource\n", __func__);
198                         goto error;
199                 }
200
201                 if (rte_strsplit(buf, sizeof(buf), res_info.ptrs, 3, ' ') != 3) {
202                         RTE_LOG(ERR, EAL,
203                                 "%s(): bad resource format\n", __func__);
204                         goto error;
205                 }
206                 errno = 0;
207                 phys_addr = strtoull(res_info.phys_addr, NULL, 16);
208                 end_addr = strtoull(res_info.end_addr, NULL, 16);
209                 flags = strtoull(res_info.flags, NULL, 16);
210                 if (errno != 0) {
211                         RTE_LOG(ERR, EAL,
212                                 "%s(): bad resource format\n", __func__);
213                         goto error;
214                 }
215
216                 if (flags & IORESOURCE_MEM) {
217                         dev->mem_resource[i].phys_addr = phys_addr;
218                         dev->mem_resource[i].len = end_addr - phys_addr + 1;
219                         /* not mapped for now */
220                         dev->mem_resource[i].addr = NULL;
221                 }
222         }
223         fclose(f);
224         return 0;
225
226 error:
227         fclose(f);
228         return -1;
229 }
230
231 /* Compare two PCI device addresses. */
232 static int
233 pci_addr_comparison(struct rte_pci_addr *addr, struct rte_pci_addr *addr2)
234 {
235         uint64_t dev_addr = (addr->domain << 24) + (addr->bus << 16) + (addr->devid << 8) + addr->function;
236         uint64_t dev_addr2 = (addr2->domain << 24) + (addr2->bus << 16) + (addr2->devid << 8) + addr2->function;
237
238         if (dev_addr > dev_addr2)
239                 return 1;
240         else
241                 return 0;
242 }
243
244
245 /* Scan one pci sysfs entry, and fill the devices list from it. */
246 static int
247 pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
248              uint8_t devid, uint8_t function)
249 {
250         char filename[PATH_MAX];
251         unsigned long tmp;
252         struct rte_pci_device *dev;
253         char driver[PATH_MAX];
254         int ret;
255
256         dev = malloc(sizeof(*dev));
257         if (dev == NULL)
258                 return -1;
259
260         memset(dev, 0, sizeof(*dev));
261         dev->addr.domain = domain;
262         dev->addr.bus = bus;
263         dev->addr.devid = devid;
264         dev->addr.function = function;
265
266         /* get vendor id */
267         snprintf(filename, sizeof(filename), "%s/vendor", dirname);
268         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
269                 free(dev);
270                 return -1;
271         }
272         dev->id.vendor_id = (uint16_t)tmp;
273
274         /* get device id */
275         snprintf(filename, sizeof(filename), "%s/device", dirname);
276         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
277                 free(dev);
278                 return -1;
279         }
280         dev->id.device_id = (uint16_t)tmp;
281
282         /* get subsystem_vendor id */
283         snprintf(filename, sizeof(filename), "%s/subsystem_vendor",
284                  dirname);
285         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
286                 free(dev);
287                 return -1;
288         }
289         dev->id.subsystem_vendor_id = (uint16_t)tmp;
290
291         /* get subsystem_device id */
292         snprintf(filename, sizeof(filename), "%s/subsystem_device",
293                  dirname);
294         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
295                 free(dev);
296                 return -1;
297         }
298         dev->id.subsystem_device_id = (uint16_t)tmp;
299
300         /* get max_vfs */
301         dev->max_vfs = 0;
302         snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
303         if (!access(filename, F_OK) &&
304             eal_parse_sysfs_value(filename, &tmp) == 0)
305                 dev->max_vfs = (uint16_t)tmp;
306         else {
307                 /* for non igb_uio driver, need kernel version >= 3.8 */
308                 snprintf(filename, sizeof(filename),
309                          "%s/sriov_numvfs", dirname);
310                 if (!access(filename, F_OK) &&
311                     eal_parse_sysfs_value(filename, &tmp) == 0)
312                         dev->max_vfs = (uint16_t)tmp;
313         }
314
315         /* get numa node */
316         snprintf(filename, sizeof(filename), "%s/numa_node",
317                  dirname);
318         if (access(filename, R_OK) != 0) {
319                 /* if no NUMA support just set node to -1 */
320                 dev->numa_node = -1;
321         } else {
322                 if (eal_parse_sysfs_value(filename, &tmp) < 0) {
323                         free(dev);
324                         return -1;
325                 }
326                 dev->numa_node = tmp;
327         }
328
329         /* parse resources */
330         snprintf(filename, sizeof(filename), "%s/resource", dirname);
331         if (pci_parse_sysfs_resource(filename, dev) < 0) {
332                 RTE_LOG(ERR, EAL, "%s(): cannot parse resource\n", __func__);
333                 free(dev);
334                 return -1;
335         }
336
337         /* parse driver */
338         snprintf(filename, sizeof(filename), "%s/driver", dirname);
339         ret = pci_get_kernel_driver_by_path(filename, driver);
340         if (!ret) {
341                 if (!strcmp(driver, "vfio-pci"))
342                         dev->pt_driver = RTE_PT_VFIO;
343                 else if (!strcmp(driver, "igb_uio"))
344                         dev->pt_driver = RTE_PT_IGB_UIO;
345                 else if (!strcmp(driver, "uio_pci_generic"))
346                         dev->pt_driver = RTE_PT_UIO_GENERIC;
347                 else
348                         dev->pt_driver = RTE_PT_UNKNOWN;
349         } else if (ret < 0) {
350                 RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
351                 free(dev);
352                 return -1;
353         } else
354                 dev->pt_driver = RTE_PT_UNKNOWN;
355
356         /* device is valid, add in list (sorted) */
357         if (TAILQ_EMPTY(&pci_device_list)) {
358                 TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
359         }
360         else {
361                 struct rte_pci_device *dev2 = NULL;
362
363                 TAILQ_FOREACH(dev2, &pci_device_list, next) {
364                         if (pci_addr_comparison(&dev->addr, &dev2->addr))
365                                 continue;
366                         else {
367                                 TAILQ_INSERT_BEFORE(dev2, dev, next);
368                                 return 0;
369                         }
370                 }
371                 TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
372         }
373
374         return 0;
375 }
376
377 /*
378  * split up a pci address into its constituent parts.
379  */
380 static int
381 parse_pci_addr_format(const char *buf, int bufsize, uint16_t *domain,
382                 uint8_t *bus, uint8_t *devid, uint8_t *function)
383 {
384         /* first split on ':' */
385         union splitaddr {
386                 struct {
387                         char *domain;
388                         char *bus;
389                         char *devid;
390                         char *function;
391                 };
392                 char *str[PCI_FMT_NVAL]; /* last element-separator is "." not ":" */
393         } splitaddr;
394
395         char *buf_copy = strndup(buf, bufsize);
396         if (buf_copy == NULL)
397                 return -1;
398
399         if (rte_strsplit(buf_copy, bufsize, splitaddr.str, PCI_FMT_NVAL, ':')
400                         != PCI_FMT_NVAL - 1)
401                 goto error;
402         /* final split is on '.' between devid and function */
403         splitaddr.function = strchr(splitaddr.devid,'.');
404         if (splitaddr.function == NULL)
405                 goto error;
406         *splitaddr.function++ = '\0';
407
408         /* now convert to int values */
409         errno = 0;
410         *domain = (uint16_t)strtoul(splitaddr.domain, NULL, 16);
411         *bus = (uint8_t)strtoul(splitaddr.bus, NULL, 16);
412         *devid = (uint8_t)strtoul(splitaddr.devid, NULL, 16);
413         *function = (uint8_t)strtoul(splitaddr.function, NULL, 10);
414         if (errno != 0)
415                 goto error;
416
417         free(buf_copy); /* free the copy made with strdup */
418         return 0;
419 error:
420         free(buf_copy);
421         return -1;
422 }
423
424 /*
425  * Scan the content of the PCI bus, and the devices in the devices
426  * list
427  */
428 static int
429 pci_scan(void)
430 {
431         struct dirent *e;
432         DIR *dir;
433         char dirname[PATH_MAX];
434         uint16_t domain;
435         uint8_t bus, devid, function;
436
437         dir = opendir(SYSFS_PCI_DEVICES);
438         if (dir == NULL) {
439                 RTE_LOG(ERR, EAL, "%s(): opendir failed: %s\n",
440                         __func__, strerror(errno));
441                 return -1;
442         }
443
444         while ((e = readdir(dir)) != NULL) {
445                 if (e->d_name[0] == '.')
446                         continue;
447
448                 if (parse_pci_addr_format(e->d_name, sizeof(e->d_name), &domain,
449                                 &bus, &devid, &function) != 0)
450                         continue;
451
452                 snprintf(dirname, sizeof(dirname), "%s/%s", SYSFS_PCI_DEVICES,
453                          e->d_name);
454                 if (pci_scan_one(dirname, domain, bus, devid, function) < 0)
455                         goto error;
456         }
457         closedir(dir);
458         return 0;
459
460 error:
461         closedir(dir);
462         return -1;
463 }
464
465 #ifdef RTE_PCI_CONFIG
466 static int
467 pci_config_extended_tag(struct rte_pci_device *dev)
468 {
469         struct rte_pci_addr *loc = &dev->addr;
470         char filename[PATH_MAX];
471         char buf[BUFSIZ];
472         FILE *f;
473
474         /* not configured, let it as is */
475         if (strncmp(RTE_PCI_EXTENDED_TAG, "on", 2) != 0 &&
476                 strncmp(RTE_PCI_EXTENDED_TAG, "off", 3) != 0)
477                 return 0;
478
479         snprintf(filename, sizeof(filename),
480                 SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/" "extended_tag",
481                 loc->domain, loc->bus, loc->devid, loc->function);
482         f = fopen(filename, "rw+");
483         if (!f)
484                 return -1;
485
486         fgets(buf, sizeof(buf), f);
487         if (strncmp(RTE_PCI_EXTENDED_TAG, "on", 2) == 0) {
488                 /* enable Extended Tag*/
489                 if (strncmp(buf, "on", 2) != 0) {
490                         fseek(f, 0, SEEK_SET);
491                         fputs("on", f);
492                 }
493         } else {
494                 /* disable Extended Tag */
495                 if (strncmp(buf, "off", 3) != 0) {
496                         fseek(f, 0, SEEK_SET);
497                         fputs("off", f);
498                 }
499         }
500         fclose(f);
501
502         return 0;
503 }
504
505 static int
506 pci_config_max_read_request_size(struct rte_pci_device *dev)
507 {
508         struct rte_pci_addr *loc = &dev->addr;
509         char filename[PATH_MAX];
510         char buf[BUFSIZ], param[BUFSIZ];
511         FILE *f;
512         /* size can be 128, 256, 512, 1024, 2048, 4096 */
513         uint32_t max_size = RTE_PCI_MAX_READ_REQUEST_SIZE;
514
515         /* not configured, let it as is */
516         if (!max_size)
517                 return 0;
518
519         snprintf(filename, sizeof(filename),
520                 SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/" "max_read_request_size",
521                         loc->domain, loc->bus, loc->devid, loc->function);
522         f = fopen(filename, "rw+");
523         if (!f)
524                 return -1;
525
526         fgets(buf, sizeof(buf), f);
527         snprintf(param, sizeof(param), "%d", max_size);
528
529         /* check if the size to be set is the same as current */
530         if (strcmp(buf, param) == 0) {
531                 fclose(f);
532                 return 0;
533         }
534         fseek(f, 0, SEEK_SET);
535         fputs(param, f);
536         fclose(f);
537
538         return 0;
539 }
540
541 static void
542 pci_config_space_set(struct rte_pci_device *dev)
543 {
544         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
545                 return;
546
547         /* configure extended tag */
548         pci_config_extended_tag(dev);
549
550         /* configure max read request size */
551         pci_config_max_read_request_size(dev);
552 }
553 #endif
554
555 static int
556 pci_map_device(struct rte_pci_device *dev)
557 {
558         int ret = -1;
559
560         /* try mapping the NIC resources using VFIO if it exists */
561         switch (dev->pt_driver) {
562         case RTE_PT_VFIO:
563 #ifdef VFIO_PRESENT
564                 if (pci_vfio_is_enabled())
565                         ret = pci_vfio_map_resource(dev);
566 #endif
567                 break;
568         case RTE_PT_IGB_UIO:
569         case RTE_PT_UIO_GENERIC:
570                 /* map resources for devices that use uio */
571                 ret = pci_uio_map_resource(dev);
572                 break;
573         default:
574                 RTE_LOG(DEBUG, EAL, "  Not managed by known pt driver,"
575                         " skipped\n");
576                 ret = 1;
577                 break;
578         }
579
580         return ret;
581 }
582
583 /*
584  * If vendor/device ID match, call the devinit() function of the
585  * driver.
586  */
587 int
588 rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev)
589 {
590         int ret;
591         struct rte_pci_id *id_table;
592
593         for (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) {
594
595                 /* check if device's identifiers match the driver's ones */
596                 if (id_table->vendor_id != dev->id.vendor_id &&
597                                 id_table->vendor_id != PCI_ANY_ID)
598                         continue;
599                 if (id_table->device_id != dev->id.device_id &&
600                                 id_table->device_id != PCI_ANY_ID)
601                         continue;
602                 if (id_table->subsystem_vendor_id != dev->id.subsystem_vendor_id &&
603                                 id_table->subsystem_vendor_id != PCI_ANY_ID)
604                         continue;
605                 if (id_table->subsystem_device_id != dev->id.subsystem_device_id &&
606                                 id_table->subsystem_device_id != PCI_ANY_ID)
607                         continue;
608
609                 struct rte_pci_addr *loc = &dev->addr;
610
611                 RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
612                                 loc->domain, loc->bus, loc->devid, loc->function,
613                                 dev->numa_node);
614
615                 RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
616                                 dev->id.device_id, dr->name);
617
618                 /* no initialization when blacklisted, return without error */
619                 if (dev->devargs != NULL &&
620                         dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
621                         RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not initializing\n");
622                         return 1;
623                 }
624
625                 if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
626 #ifdef RTE_PCI_CONFIG
627                         /*
628                          * Set PCIe config space for high performance.
629                          * Return value can be ignored.
630                          */
631                         pci_config_space_set(dev);
632 #endif
633                         /* map resources for devices that use igb_uio */
634                         ret = pci_map_device(dev);
635                         if (ret != 0)
636                                 return ret;
637                 } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
638                            rte_eal_process_type() == RTE_PROC_PRIMARY) {
639                         /* unbind current driver */
640                         if (pci_unbind_kernel_driver(dev) < 0)
641                                 return -1;
642                 }
643
644                 /* reference driver structure */
645                 dev->driver = dr;
646
647                 /* call the driver devinit() function */
648                 return dr->devinit(dr, dev);
649         }
650         /* return positive value if driver is not found */
651         return 1;
652 }
653
654 /* Init the PCI EAL subsystem */
655 int
656 rte_eal_pci_init(void)
657 {
658         TAILQ_INIT(&pci_driver_list);
659         TAILQ_INIT(&pci_device_list);
660         pci_res_list = RTE_TAILQ_RESERVE_BY_IDX(RTE_TAILQ_PCI,
661                         mapped_pci_res_list);
662
663         /* for debug purposes, PCI can be disabled */
664         if (internal_config.no_pci)
665                 return 0;
666
667         if (pci_scan() < 0) {
668                 RTE_LOG(ERR, EAL, "%s(): Cannot scan PCI bus\n", __func__);
669                 return -1;
670         }
671 #ifdef VFIO_PRESENT
672         pci_vfio_enable();
673
674         if (pci_vfio_is_enabled()) {
675
676                 /* if we are primary process, create a thread to communicate with
677                  * secondary processes. the thread will use a socket to wait for
678                  * requests from secondary process to send open file descriptors,
679                  * because VFIO does not allow multiple open descriptors on a group or
680                  * VFIO container.
681                  */
682                 if (internal_config.process_type == RTE_PROC_PRIMARY &&
683                                 pci_vfio_mp_sync_setup() < 0)
684                         return -1;
685         }
686 #endif
687         return 0;
688 }