71
71
72
72
extern uint64_t audio_nhlt_len ;
73
73
74
- /* TODO: Add support for IO BAR of PTDev */
75
- static int iofd = -1 ;
76
-
77
74
/* reference count for libpciaccess init/deinit */
78
75
static int pciaccess_ref_cnt ;
79
76
static pthread_mutex_t ref_cnt_mtx = PTHREAD_MUTEX_INITIALIZER ;
@@ -404,8 +401,6 @@ init_msix_table(struct vmctx *ctx, struct passthru_dev *ptdev, uint64_t base)
404
401
uint16_t virt_bdf = PCI_BDF (dev -> bus , dev -> slot , dev -> func );
405
402
struct ic_ptdev_irq ptirq ;
406
403
407
- assert (ptdev_msix_table_bar (ptdev ) >= 0 && ptdev_msix_pba_bar (ptdev ) >= 0 );
408
-
409
404
b = ptdev -> sel .bus ;
410
405
s = ptdev -> sel .dev ;
411
406
f = ptdev -> sel .func ;
@@ -626,7 +621,11 @@ cfginitbar(struct vmctx *ctx, struct passthru_dev *ptdev)
626
621
*/
627
622
if (bartype == PCIBAR_MEM64 ) {
628
623
i ++ ;
629
- assert (i <= PCI_BARMAX );
624
+ if (i > PCI_BARMAX ) {
625
+ warnx ("BAR count out of range\n" );
626
+ return -1 ;
627
+ }
628
+
630
629
ptdev -> bar [i ].type = PCIBAR_MEMHI64 ;
631
630
}
632
631
}
@@ -1073,21 +1072,14 @@ passthru_write(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
1073
1072
uint64_t offset , int size , uint64_t value )
1074
1073
{
1075
1074
struct passthru_dev * ptdev ;
1076
- struct iodev_pio_req pio ;
1077
1075
1078
1076
ptdev = dev -> arg ;
1079
1077
1080
1078
if (baridx == ptdev_msix_table_bar (ptdev )) {
1081
1079
msix_table_write (ptdev , offset , size , value );
1082
1080
} else {
1083
- assert (dev -> bar [baridx ].type == PCIBAR_IO );
1084
- bzero (& pio , sizeof (struct iodev_pio_req ));
1085
- pio .access = IODEV_PIO_WRITE ;
1086
- pio .port = ptdev -> bar [baridx ].addr + offset ;
1087
- pio .width = size ;
1088
- pio .val = value ;
1089
-
1090
- (void )ioctl (iofd , IODEV_PIO , & pio );
1081
+ /* TODO: Add support for IO BAR of PTDev */
1082
+ warnx ("Passthru: PIO write not supported, ignored\n" );
1091
1083
}
1092
1084
}
1093
1085
@@ -1096,24 +1088,16 @@ passthru_read(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
1096
1088
uint64_t offset , int size )
1097
1089
{
1098
1090
struct passthru_dev * ptdev ;
1099
- struct iodev_pio_req pio ;
1100
1091
uint64_t val ;
1101
1092
1102
1093
ptdev = dev -> arg ;
1103
1094
1104
1095
if (baridx == ptdev_msix_table_bar (ptdev )) {
1105
1096
val = msix_table_read (ptdev , offset , size );
1106
1097
} else {
1107
- assert (dev -> bar [baridx ].type == PCIBAR_IO );
1108
- bzero (& pio , sizeof (struct iodev_pio_req ));
1109
- pio .access = IODEV_PIO_READ ;
1110
- pio .port = ptdev -> bar [baridx ].addr + offset ;
1111
- pio .width = size ;
1112
- pio .val = 0 ;
1113
-
1114
- (void )ioctl (iofd , IODEV_PIO , & pio );
1115
-
1116
- val = pio .val ;
1098
+ /* TODO: Add support for IO BAR of PTDev */
1099
+ warnx ("Passthru: PIO read not supported\n" );
1100
+ val = (uint64_t )(-1 );
1117
1101
}
1118
1102
1119
1103
return val ;
0 commit comments