Skip to content

Commit 006d8fd

Browse files
Adding dealy after thr slot_reset
1 parent a37c083 commit 006d8fd

File tree

1 file changed

+56
-3
lines changed

1 file changed

+56
-3
lines changed

vfio-spapr-eeh-test.c

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ int main(int argc, char **argv)
255255
perror("");
256256
}
257257

258+
/* Check the PE state */
259+
pe_op.op = VFIO_EEH_PE_GET_STATE;
260+
ret = ioctl(container, VFIO_EEH_PE_OP, &pe_op);
261+
if(ret < 0) {
262+
perror("");
263+
}
264+
printf("VFIO_EEH_PE_STATE initial state of PE %x ", ret);
265+
258266
//pci read config
259267
printf("\ndump configuration space registers\n");
260268
pret = pread(device, buf, 512, pcidev.regs[VFIO_PCI_CONFIG_REGION_INDEX].offset);
@@ -264,8 +272,8 @@ int main(int argc, char **argv)
264272
}
265273
else
266274
{
267-
for(i=0; i<10; i++)
268-
printf("%x \n",buf[i]);
275+
for(i=0; i<10; i++)
276+
printf("%d. 0x%X \n",i,buf[i]);
269277
}
270278

271279
/* dump some 32bit MMIO registers */
@@ -282,13 +290,17 @@ int main(int argc, char **argv)
282290
pe_op.err.func = EEH_ERR_FUNC_LD_MEM_ADDR;
283291
pe_op.err.addr = 0ul;
284292
pe_op.err.mask = 0ul;
293+
/*
285294
pret = ioctl(container, VFIO_EEH_PE_OP, &pe_op);
286295
if(pret < 0) {
287296
perror("");
288297
printf("VFIO_EEH_PE_INJECT_ERR failed , buf out : %s \n", path);
289298
return pret;
290299
}
300+
*/
291301

302+
printf("inject error \n");
303+
fgetc(stdin);
292304

293305
pe_op.op = VFIO_EEH_PE_GET_STATE;
294306
ret = ioctl(container, VFIO_EEH_PE_OP, &pe_op);
@@ -344,6 +356,21 @@ int main(int argc, char **argv)
344356
*/
345357
pe_op.op = VFIO_EEH_PE_RESET_HOT;
346358
ioctl(container, VFIO_EEH_PE_OP, &pe_op);
359+
printf("slot VFIO_EEH_PE_RESET_HOT initiated\n");
360+
pe_op.op = VFIO_EEH_PE_GET_STATE;
361+
i = 5 ;
362+
while (i--)
363+
{
364+
ret = ioctl(container, VFIO_EEH_PE_OP, &pe_op);
365+
if( ret < 0) {
366+
perror("");
367+
}
368+
printf("\t.");
369+
sleep(5);
370+
}
371+
372+
printf("\nVFIO_EEH_PE_GET_STATE %d\n",ret);
373+
347374
pe_op.op = VFIO_EEH_PE_RESET_DEACTIVATE;
348375
ioctl(container, VFIO_EEH_PE_OP, &pe_op);
349376

@@ -352,12 +379,38 @@ int main(int argc, char **argv)
352379
ret = ioctl(container, VFIO_EEH_PE_OP, &pe_op);
353380
if(!ret) {
354381
printf("Success\n");
355-
printf("Press any key to exit\n");
356382
} else {
357383
printf("VFIO_EEH_PE_CONFIGURE failed \n");
358384
}
385+
/* verify the PE state in operational */
386+
pe_op.op = VFIO_EEH_PE_GET_STATE;
387+
ret = ioctl(container, VFIO_EEH_PE_OP, &pe_op);
388+
if( ret < 0) {
389+
perror("");
390+
}
391+
printf("VFIO_EEH_PE_GET_STATE %d \n",ret);
392+
393+
//pci read config
394+
printf("\ndump configuration space registers\n");
395+
pret = pread(device, buf, 512, pcidev.regs[VFIO_PCI_CONFIG_REGION_INDEX].offset);
396+
if(pret < 0)
397+
{
398+
perror("read onfig: ");
399+
}
400+
else
401+
{
402+
for(i=0; i<10; i++)
403+
printf("%d. 0x%X \n",i,buf[i]);
404+
}
405+
406+
/* read MMIO */
407+
for(i = 0; i < 0x10; i+=0x4 )
408+
printf("MMIO register offset 0x%X value 0x%X \n",i, read_u32(&pcidev, i));
409+
359410

411+
printf("Press any key to exit\n");
360412
fgetc(stdin);
361413

414+
ioctl(device, VFIO_DEVICE_RESET);
362415
return 0;
363416
}

0 commit comments

Comments
 (0)