Skip to content

Commit 123ea3a

Browse files
authored
Merge b277eef into c32e100
2 parents c32e100 + b277eef commit 123ea3a

File tree

3 files changed

+75
-31
lines changed

3 files changed

+75
-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/os/Linux/devLibPCIOSD.c

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ struct osdPCIDevice {
104104

105105
epicsMutexId devLock; /* guard access to isrs list */
106106

107+
//Optional callback invoked on PCI device hot-swap.
108+
void (*onHotSwapHook)(struct osdPCIDevice* dev);
109+
107110
ELLNODE node;
108111

109112
ELLLIST isrs; /* contains struct osdISR */
@@ -507,7 +510,7 @@ int linuxDevPCIInit(void)
507510
/* Read BAR info */
508511

509512
/* Base address */
510-
513+
511514
filename = allocPrintf(BUSBASE "resource",
512515
osd->dev.domain, osd->dev.bus, osd->dev.device, osd->dev.function);
513516
if (!filename) {
@@ -548,10 +551,10 @@ int linuxDevPCIInit(void)
548551

549552
osd->displayErom = start;
550553
osd->eromlen = (start || stop ) ? (stop - start + 1) : 0;
551-
554+
552555
fclose(file);
553556
free(filename);
554-
557+
555558
/* driver name */
556559
filename = allocPrintf(BUSBASE "driver",
557560
osd->dev.domain, osd->dev.bus, osd->dev.device, osd->dev.function);
@@ -922,6 +925,28 @@ int linuxDevPCIConnectInterrupt(
922925
return ret;
923926
}
924927

928+
static int reopen_uio(struct osdPCIDevice *osd)
929+
{
930+
int uio = find_uio_number(osd);
931+
if (uio < 0)
932+
return -1;
933+
934+
char *devname = allocPrintf("/dev/uio%u", uio);
935+
if (!devname)
936+
return -1;
937+
938+
int newfd = open(devname, O_RDWR);
939+
free(devname);
940+
if (newfd < 0)
941+
return -1;
942+
943+
if (osd->fd != -1)
944+
close(osd->fd);
945+
946+
osd->fd = newfd;
947+
return 0;
948+
}
949+
925950
static
926951
void isrThread(void* arg)
927952
{
@@ -959,18 +984,36 @@ void isrThread(void* arg)
959984
epicsInterruptUnlock(isrflag);
960985
}
961986

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

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

0 commit comments

Comments
 (0)