Skip to content

Commit 19cff35

Browse files
authored
Merge 975ad8f into c32e100
2 parents c32e100 + 975ad8f commit 19cff35

File tree

5 files changed

+126
-62
lines changed

5 files changed

+126
-62
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/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ DBD += epicspci.dbd
2020

2121
INC += devLibPCI.h
2222
INC += devLibPCIImpl.h
23+
INC += devLibPCIOSD.h
2324

2425
epicspci_SRCS += devLibPCI.c
2526
epicspci_SRCS += devLibPCIStrings.c
@@ -37,4 +38,3 @@ epicspci_LIBS += Com
3738
include $(TOP)/configure/RULES
3839
#----------------------------------------
3940
# ADD RULES AFTER THIS LINE
40-

pciApp/os/Linux/devLibPCIOSD.c

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
#include <errlog.h>
2323
#include <epicsString.h>
2424
#include <epicsThread.h>
25-
#include <epicsMutex.h>
25+
//#include <epicsMutex.h>
2626
#include <epicsEvent.h>
2727
#include <epicsInterrupt.h>
2828
#include <compilerDependencies.h>
2929

30-
31-
#include "devLibPCIImpl.h"
30+
//#include "devLibPCIImpl.h"
31+
#include "devLibPCIOSD.h"
3232

3333
/**@file devLibPCIOSD.c
3434
* @brief Userspace PCI access in Linux
@@ -82,33 +82,6 @@
8282
*
8383
* Access after init is guarded by devLock
8484
*/
85-
struct osdPCIDevice {
86-
epicsPCIDevice dev; /* "public" data */
87-
88-
/* result of mmap(), add offset before passing to user */
89-
volatile void *base[PCIBARCOUNT];
90-
/* offset from start of page to start of BAR */
91-
epicsUInt32 offset[PCIBARCOUNT];
92-
/* BAR length (w/o offset) */
93-
epicsUInt32 len[PCIBARCOUNT];
94-
volatile void *erom;
95-
epicsUInt32 eromlen;
96-
97-
epicsUInt32 displayBAR[PCIBARCOUNT]; /* Raw PCI address */
98-
epicsUInt32 displayErom;
99-
100-
int fd; /* /dev/uio# */
101-
int cfd; /* config-space descriptor */
102-
int rfd[PCIBARCOUNT];
103-
int cmode; /* config-space mode */
104-
105-
epicsMutexId devLock; /* guard access to isrs list */
106-
107-
ELLNODE node;
108-
109-
ELLLIST isrs; /* contains struct osdISR */
110-
};
111-
typedef struct osdPCIDevice osdPCIDevice;
11285

11386
#define dev2osd(dev) CONTAINER(dev, osdPCIDevice, dev)
11487

@@ -507,7 +480,7 @@ int linuxDevPCIInit(void)
507480
/* Read BAR info */
508481

509482
/* Base address */
510-
483+
511484
filename = allocPrintf(BUSBASE "resource",
512485
osd->dev.domain, osd->dev.bus, osd->dev.device, osd->dev.function);
513486
if (!filename) {
@@ -548,10 +521,10 @@ int linuxDevPCIInit(void)
548521

549522
osd->displayErom = start;
550523
osd->eromlen = (start || stop ) ? (stop - start + 1) : 0;
551-
524+
552525
fclose(file);
553526
free(filename);
554-
527+
555528
/* driver name */
556529
filename = allocPrintf(BUSBASE "driver",
557530
osd->dev.domain, osd->dev.bus, osd->dev.device, osd->dev.function);
@@ -922,6 +895,28 @@ int linuxDevPCIConnectInterrupt(
922895
return ret;
923896
}
924897

898+
static int reopen_uio(struct osdPCIDevice *osd)
899+
{
900+
int uio = find_uio_number(osd);
901+
if (uio < 0)
902+
return -1;
903+
904+
char *devname = allocPrintf("/dev/uio%u", uio);
905+
if (!devname)
906+
return -1;
907+
908+
int newfd = open(devname, O_RDWR);
909+
free(devname);
910+
if (newfd < 0)
911+
return -1;
912+
913+
if (osd->fd != -1)
914+
close(osd->fd);
915+
916+
osd->fd = newfd;
917+
return 0;
918+
}
919+
925920
static
926921
void isrThread(void* arg)
927922
{
@@ -959,18 +954,36 @@ void isrThread(void* arg)
959954
epicsInterruptUnlock(isrflag);
960955
}
961956

962-
ret=read(osd->fd, &event, sizeof(event));
963-
if (ret==-1) {
964-
switch(errno) {
965-
case EINTR: /* interrupted by a signal */
957+
ret = read(osd->fd, &event, sizeof(event));
958+
if (ret == -1) {
959+
switch (errno) {
960+
case EINTR:
966961
break;
962+
963+
case EIO:
964+
case EINVAL:
965+
case ENODEV:
966+
errlogPrintf("isrThread '%s': Device removed or UIO invalid (errno=%d: %s)\n", name, errno, strerror(errno));
967+
968+
epicsMutexMustLock(osd->devLock);
969+
if (reopen_uio(osd) == 0) {
970+
errlogPrintf("isrThread '%s': Successfully reopened UIO device\n", name);
971+
if (osd->onHotSwapHook) osd->onHotSwapHook(osd);
972+
} else {
973+
errlogPrintf("isrThread '%s': UIO reopen failed. Will retry.\n", name);
974+
}
975+
epicsMutexUnlock(osd->devLock);
976+
epicsThreadSleep(1);
977+
continue;
978+
967979
default:
968-
errlogPrintf("isrThread '%s' read error %d\n",
969-
name,errno);
970-
epicsThreadSleep(0.5);
980+
errlogPrintf("isrThread '%s': read error %d (%s)\n", name, errno, strerror(errno));
981+
epicsThreadSleep(1);
971982
}
972-
} else
973-
interrupted=1;
983+
} else {
984+
interrupted = 1;
985+
}
986+
974987

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

pciApp/os/Linux/devLibPCIOSD.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
#ifndef DEVLIBPCIOSD_H_INC
3+
#define DEVLIBPCIOSD_H_INC
4+
5+
#include <epicsMutex.h>
6+
7+
#include "devLibPCIImpl.h"
8+
9+
#ifdef __cplusplus
10+
extern "C"
11+
{
12+
#endif
13+
14+
struct osdPCIDevice
15+
{
16+
epicsPCIDevice dev; /* "public" data */
17+
18+
/* result of mmap(), add offset before passing to user */
19+
volatile void* base[PCIBARCOUNT];
20+
/* offset from start of page to start of BAR */
21+
epicsUInt32 offset[PCIBARCOUNT];
22+
/* BAR length (w/o offset) */
23+
epicsUInt32 len[PCIBARCOUNT];
24+
volatile void* erom;
25+
epicsUInt32 eromlen;
26+
27+
epicsUInt32 displayBAR[PCIBARCOUNT]; /* Raw PCI address */
28+
epicsUInt32 displayErom;
29+
30+
int fd; /* /dev/uio# */
31+
int cfd; /* config-space descriptor */
32+
int rfd[PCIBARCOUNT];
33+
int cmode; /* config-space mode */
34+
35+
epicsMutexId devLock; /* guard access to isrs list */
36+
37+
/* Optional callback invoked on PCI device hot-swap.*/
38+
void (*onHotSwapHook)(struct osdPCIDevice* dev);
39+
40+
ELLNODE node;
41+
42+
ELLLIST isrs; /* contains struct osdISR */
43+
};
44+
typedef struct osdPCIDevice osdPCIDevice;
45+
46+
#ifdef __cplusplus
47+
}
48+
#endif
49+
50+
#endif /* DEVLIBPCIOSD_H_INC */

0 commit comments

Comments
 (0)