Skip to content

Commit 308ff99

Browse files
authored
Merge ace8238 into c32e100
2 parents c32e100 + ace8238 commit 308ff99

File tree

4 files changed

+84
-31
lines changed

4 files changed

+84
-31
lines changed

.github/workflows/ci-scripts-build.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,68 +39,69 @@ jobs:
3939
fail-fast: false
4040
matrix:
4141
include:
42-
- os: ubuntu-20.04
42+
- os: ubuntu-22.04
4343
cmp: gcc
4444
configuration: default
4545
base: "7.0"
4646
wine: "64"
4747

48-
- os: ubuntu-20.04
48+
- os: ubuntu-22.04
4949
cmp: gcc
5050
configuration: static
5151
base: "7.0"
5252

53-
- os: ubuntu-20.04
53+
- os: ubuntu-22.04
5454
cmp: gcc
5555
configuration: default
5656
base: "3.15"
5757

58-
- os: ubuntu-20.04
58+
- os: ubuntu-22.04
5959
cmp: gcc
6060
configuration: default
6161
base: "3.14"
6262

63-
- os: ubuntu-20.04
63+
- os: ubuntu-22.04
6464
cmp: gcc
6565
configuration: static
6666
base: "7.0"
6767
extra: "CMD_CXXFLAGS=-std=c++11"
6868

69-
- os: ubuntu-20.04
69+
- os: ubuntu-22.04
7070
cmp: clang
7171
configuration: default
7272
base: "7.0"
7373
extra: "CMD_CXXFLAGS=-std=c++11"
7474

75-
- os: ubuntu-20.04
76-
cmp: gcc
77-
configuration: default
78-
base: "7.0"
79-
rtems: "4.10"
75+
# It requires more debugging:
76+
# - os: ubuntu-22.04
77+
# cmp: gcc
78+
# configuration: default
79+
# base: "7.0"
80+
# rtems: "4.10"
8081

81-
- os: ubuntu-20.04
82+
- os: ubuntu-22.04
8283
cmp: gcc
8384
configuration: default
8485
base: "7.0"
8586
rtems: "4.9"
8687

87-
- os: ubuntu-20.04
88-
cmp: gcc-8
89-
utoolchain: "8"
88+
- os: ubuntu-22.04
89+
cmp: gcc-9
90+
utoolchain: "9"
9091
configuration: default
9192
base: "7.0"
9293

93-
- os: ubuntu-20.04
94+
- os: ubuntu-22.04
9495
cmp: clang
9596
configuration: default
9697
base: "7.0"
9798

9899
steps:
99-
- uses: actions/checkout@v2
100+
- uses: actions/checkout@v3
100101
with:
101102
submodules: true
102103
- name: Cache Dependencies
103-
uses: actions/cache@v2
104+
uses: actions/cache@v3
104105
with:
105106
path: ~/.cache
106107
key: ${{ matrix.base }}/${{ matrix.os }}/${{ matrix.cmp }}/${{ matrix.configuration }}/${{ matrix.wine }}${{ matrix.rtems }}/${{ matrix.extra }}

configure/CONFIG_DEVLIB2_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
DEVLIB2_MAJOR_VERSION = 2
2-
DEVLIB2_MINOR_VERSION = 12
2+
DEVLIB2_MINOR_VERSION = 13

pciApp/devLibPCI.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,16 @@ int devPCIDisableInterrupt(const epicsPCIDevice *dev);
451451
epicsShareFunc
452452
const char* devPCIDeviceClassToString(int classId);
453453

454+
/**
455+
* @brief Optional callback invoked on PCI device hot-swap.
456+
*
457+
* This function pointer may be set to a custom handler that will be called
458+
* when a PCI device is successfully reopened (e.g. after hot-swap).
459+
*
460+
* @param name Identifier or name of the reopened PCI device.
461+
*/
462+
epicsShareExtern void (*devPCIonHotSwapHook)(const char*);
463+
454464
#ifdef __cplusplus
455465
} /* extern "C" */
456466
#endif

pciApp/os/Linux/devLibPCIOSD.c

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ int linuxDevPCIInit(void)
507507
/* Read BAR info */
508508

509509
/* Base address */
510-
510+
511511
filename = allocPrintf(BUSBASE "resource",
512512
osd->dev.domain, osd->dev.bus, osd->dev.device, osd->dev.function);
513513
if (!filename) {
@@ -548,10 +548,10 @@ int linuxDevPCIInit(void)
548548

549549
osd->displayErom = start;
550550
osd->eromlen = (start || stop ) ? (stop - start + 1) : 0;
551-
551+
552552
fclose(file);
553553
free(filename);
554-
554+
555555
/* driver name */
556556
filename = allocPrintf(BUSBASE "driver",
557557
osd->dev.domain, osd->dev.bus, osd->dev.device, osd->dev.function);
@@ -922,6 +922,30 @@ int linuxDevPCIConnectInterrupt(
922922
return ret;
923923
}
924924

925+
static int reopen_uio(struct osdPCIDevice *osd)
926+
{
927+
int uio = find_uio_number(osd);
928+
if (uio < 0)
929+
return -1;
930+
931+
char *devname = allocPrintf("/dev/uio%u", uio);
932+
if (!devname)
933+
return -1;
934+
935+
int newfd = open(devname, O_RDWR);
936+
free(devname);
937+
if (newfd < 0)
938+
return -1;
939+
940+
if (osd->fd != -1)
941+
close(osd->fd);
942+
943+
osd->fd = newfd;
944+
return 0;
945+
}
946+
947+
epicsShareDef void (*devPCIonHotSwapHook)(const char* name) = NULL;
948+
925949
static
926950
void isrThread(void* arg)
927951
{
@@ -959,18 +983,36 @@ void isrThread(void* arg)
959983
epicsInterruptUnlock(isrflag);
960984
}
961985

962-
ret=read(osd->fd, &event, sizeof(event));
963-
if (ret==-1) {
964-
switch(errno) {
965-
case EINTR: /* interrupted by a signal */
986+
ret = read(osd->fd, &event, sizeof(event));
987+
if (ret == -1) {
988+
switch (errno) {
989+
case EINTR:
966990
break;
991+
992+
case EIO:
993+
case EINVAL:
994+
case ENODEV:
995+
errlogPrintf("isrThread '%s': Device removed or UIO invalid (errno=%d: %s)\n", name, errno, strerror(errno));
996+
997+
epicsMutexMustLock(osd->devLock);
998+
if (reopen_uio(osd) == 0) {
999+
errlogPrintf("isrThread '%s': Successfully reopened UIO device\n", name);
1000+
if (devPCIonHotSwapHook) devPCIonHotSwapHook(name);
1001+
} else {
1002+
errlogPrintf("isrThread '%s': UIO reopen failed. Will retry.\n", name);
1003+
}
1004+
epicsMutexUnlock(osd->devLock);
1005+
epicsThreadSleep(1);
1006+
continue;
1007+
9671008
default:
968-
errlogPrintf("isrThread '%s' read error %d\n",
969-
name,errno);
970-
epicsThreadSleep(0.5);
1009+
errlogPrintf("isrThread '%s': read error %d (%s)\n", name, errno, strerror(errno));
1010+
epicsThreadSleep(1);
9711011
}
972-
} else
973-
interrupted=1;
1012+
} else {
1013+
interrupted = 1;
1014+
}
1015+
9741016

9751017
if (next!=event && next!=0) {
9761018
errlogPrintf("isrThread '%s' missed %d events\n",

0 commit comments

Comments
 (0)