Skip to content

Commit ab0d29e

Browse files
authored
Merge pull request #6 from sy-c/master
update from upstream v11.8.7
2 parents 037233d + 7f47f16 commit ab0d29e

39 files changed

+525
-275
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
/build_linux_x86_uio/
33
/doxygen/
44
/patches/linux_uio/uio_pci_dma.ko
5+
/patches/pda-kernel-dkms_*
6+
/*.deb
57
/build*/

CMakeLists.txt

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ execute_process(
2424
endforeach()
2525

2626
# build userspace library
27-
add_compile_options(-std=gnu99 -Wall -Wunused-result -fno-tree-vectorize)
27+
add_compile_options(-std=gnu99 -Wall -Wunused-result -fno-tree-vectorize
28+
-Wno-format-truncation)
29+
set(PDA_DEBUG_OPTIONS "-DDEBUG")
30+
add_compile_options("$<$<CONFIG:DEBUG>:${PDA_DEBUG_OPTIONS}>")
31+
2832
file(GLOB LIB_SOURCES src/*.c)
2933
add_library(pda-static STATIC ${LIB_SOURCES})
3034
add_library(pda-shared SHARED ${LIB_SOURCES})
@@ -51,23 +55,31 @@ if (${KMOD_AVAIL})
5155
endif()
5256

5357
# specify files to install
58+
set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
59+
OWNER_READ OWNER_WRITE OWNER_EXECUTE
60+
GROUP_READ GROUP_EXECUTE
61+
WORLD_READ WORLD_EXECUTE)
5462
install(TARGETS pda-static ARCHIVE DESTINATION lib)
5563
install(TARGETS pda-shared LIBRARY DESTINATION lib)
5664
install(DIRECTORY include/ DESTINATION include)
5765

58-
# build debian package - experimental
66+
# build debian package
5967
set(CPACK_GENERATOR DEB)
60-
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
61-
"CBM FLES FLIB low-level user space access library")
62-
set(CPACK_PACKAGE_NAME libpda)
63-
set(CPACK_PACKAGE_CONTACT
64-
"Jan de Cuveland <[email protected]>")
68+
set(CPACK_PACKAGE_NAME libpda${SO_VERSION})
6569
set(CPACK_PACKAGE_VERSION_MAJOR ${pda_VERSION_MAJOR})
6670
set(CPACK_PACKAGE_VERSION_MINOR ${pda_VERSION_MINOR})
6771
set(CPACK_PACKAGE_VERSION_PATCH ${pda_VERSION_PATCH})
68-
set(CPACK_STRIP_FILES TRUE)
69-
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
70-
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.15)")
72+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
73+
"Portable Driver Architecture (PDA) low-level user space library")
74+
set(CPACK_PACKAGE_CONTACT
75+
"Jan de Cuveland <[email protected]>")
76+
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/cbm-fles/pda")
77+
set(CPACK_DEBIAN_PACKAGE_SECTION libdevel)
7178
set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
72-
set(CPACK_DEBIAN_PACKAGE_SECTION libs)
79+
set(CPACK_DEBIAN_PACKAGE_RELEASE 1)
80+
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
81+
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
82+
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
83+
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
84+
set(CPACK_STRIP_FILES TRUE)
7385
include(CPack)

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ rpm: tarball
3939
make -C patches/linux_uio rpm
4040
cp ${HOME}/rpmbuild/RPMS/x86_64/pda_kadapter-`uname -r`*.rpm .
4141

42+
deb:
43+
make -C patches/linux_uio deb
44+
cp patches/pda-kernel-dkms_*.deb .
45+
4246
tarball: mrproper
4347
rm -rf libpda-`cat VERSION`.tar.gz
4448
tar -cf libpda-`cat VERSION`.tar *
@@ -68,9 +72,10 @@ clean:
6872
find . -iname 'build_*' -exec make -C {} clean \;
6973
rm -rf libpda*.tar.gz libpda*.rpm package/rpm/*.tar.gz
7074
rm -rf pda_kadapter*.rpm
75+
rm -rf pda-kernel-dkms_*.deb
7176

7277
count: mrproper
73-
wc -l `find . -iname '*.c' && find . -iname '*.h' && find . -iname '*.inc'`
78+
wc -l `find . -iname '*.c' && find . -iname '*.h' && find . -iname '*.inc'`
7479

7580
doc:
7681
doxygen doxyfile.in

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11.2.7
1+
11.8.7

arch/linux_x86_uio/bar_inc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Bar_new
129129
}
130130

131131
snprintf( workp.uio_file_path, PDA_STRING_LIMIT,
132-
"%s/%04x:%02x:%02x.%1x/bar%d",
132+
"%s/"UIO_PATH_FORMAT"/bar%d",
133133
UIO_BAR_PATH, domain_id, bus_id,
134134
device_id, function_id, number );
135135

arch/linux_x86_uio/device_operator_inc.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ PDAInit()
187187

188188
if(!isCorrectVersion("uio_pci_dma", UIO_PCI_DMA_VERSION))
189189
{
190-
DEBUG_PRINTF( PDADEBUG_ERROR, "Kernel adapter (uio_pci_dma.ko) version missmatch!\n");
190+
DEBUG_PRINTF( PDADEBUG_ERROR, "Kernel adapter (uio_pci_dma.ko) version mismatch!\n");
191191
RETURN(!PDA_SUCCESS);
192192
}
193193

@@ -223,7 +223,11 @@ DeviceOperator_new
223223
{
224224
DEBUG_PRINTF(PDADEBUG_ENTER, "");
225225

226-
PDAInit();
226+
if(PDA_SUCCESS != PDAInit())
227+
{
228+
DEBUG_PRINTF( PDADEBUG_ERROR, "PDA initialization failed!\n");
229+
RETURN(NULL);
230+
}
227231

228232
DIR *directory = NULL;
229233

@@ -317,6 +321,7 @@ DeviceOperator_new
317321
fp_vendor = NULL;
318322
if(read_chars != 6)
319323
{
324+
// TODO: This looks broken. DeviceOperator_delete -> read_chars?
320325
ERROR_EXIT( EINVAL, deviceoperatornew_return,
321326
"Read failed! (only %llu chars read)\n", DeviceOperator_delete);
322327
}
@@ -336,8 +341,10 @@ DeviceOperator_new
336341
uint8_t bus_id = 0;
337342
uint8_t device_id = 0;
338343
uint8_t function_id = 0;
339-
sscanf (directory_entry->d_name,"%4hx:%2hhx:%2hhx.%2hhx",
340-
&domain_id, &bus_id, &device_id, &function_id);
344+
if(sscanf (directory_entry->d_name,"%4hx:%2hhx:%2hhx.%1hhx",
345+
&domain_id, &bus_id, &device_id, &function_id) != 4)
346+
{ ERROR_EXIT( EINVAL, deviceoperatornew_return, "Parsing sysfs d_name failed!\n" ); }
347+
341348

342349
dev_operator->pci_devices[dev_operator->pci_devices_number] =
343350
PciDevice_new_op(directory_entry->d_name, vendor, device,

arch/linux_x86_uio/dma_buffer_inc.c

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/**
22
* @author Dominic Eschweiler <[email protected]>
3+
* @author Dirk Hutter <[email protected]>
34
*
45
* @section LICENSE
56
*
67
* Copyright (c) 2015, Dominic Eschweiler
8+
* Copyright (c) 2017, Dirk Hutter
79
* All rights reserved.
810
*
911
* Redistribution and use in source and binary forms, with or without
@@ -216,7 +218,7 @@ DMABuffer_loadSGList
216218
{ ERROR_EXIT( errno, exit, "Lookup failed!\n" ); }
217219

218220
snprintf(buffer->internal->uio_filepath_sg, PDA_STRING_LIMIT,
219-
"%s/%04x:%02x:%02x.%1x/dma/%s/sg",
221+
"%s/"UIO_PATH_FORMAT"/dma/%s/sg",
220222
UIO_BAR_PATH, domain_id, bus_id, device_id, function_id,
221223
buffer->internal->name);
222224

@@ -369,20 +371,20 @@ DMABuffer_generatePaths
369371

370372

371373
snprintf(buffer->internal->uio_filepath_request, PDA_STRING_LIMIT,
372-
"%s/%04x:%02x:%02x.%1x/dma/request",
374+
"%s/"UIO_PATH_FORMAT"/dma/request",
373375
UIO_BAR_PATH, domain_id, bus_id, device_id, function_id);
374376

375377
snprintf(buffer->internal->uio_filepath_delete, PDA_STRING_LIMIT,
376-
"%s/%04x:%02x:%02x.%1x/dma/free",
378+
"%s/"UIO_PATH_FORMAT"/dma/free",
377379
UIO_BAR_PATH, domain_id, bus_id, device_id, function_id);
378380

379381
snprintf(buffer->internal->uio_filepath_map, PDA_STRING_LIMIT,
380-
"%s/%04x:%02x:%02x.%1x/dma/%s/map",
382+
"%s/"UIO_PATH_FORMAT"/dma/%s/map",
381383
UIO_BAR_PATH, domain_id, bus_id, device_id, function_id,
382384
buffer->internal->name);
383385

384386
snprintf(buffer->internal->uio_filepath_folder, PDA_STRING_LIMIT,
385-
"%s/%04x:%02x:%02x.%1x/dma/%s/",
387+
"%s/"UIO_PATH_FORMAT"/dma/%s/",
386388
UIO_BAR_PATH, domain_id, bus_id, device_id, function_id,
387389
buffer->internal->name);
388390

@@ -442,21 +444,6 @@ DMABuffer_lockUserBuffer
442444
{
443445
DEBUG_PRINTF(PDADEBUG_ENTER, "");
444446

445-
volatile uint64_t tmp = 0;
446-
volatile uint64_t *page_pointer = 0;
447-
for
448-
(
449-
page_pointer = (uint64_t*) start;
450-
page_pointer < (uint64_t*) (start + buffer->length);
451-
page_pointer = (page_pointer + PAGE_SIZE)
452-
)
453-
{
454-
tmp = *page_pointer;
455-
*page_pointer = tmp;
456-
}
457-
458-
mlock(start, buffer->length);
459-
460447
if(mlock(start, buffer->length) != 0)
461448
{ RETURN(ERROR( errno, "Buffer locking failed!\n")); }
462449

@@ -497,7 +484,7 @@ DMABuffer_requestMemory
497484
#endif /* NUMA_AVAIL */
498485
};
499486

500-
snprintf(request.name, 1024, "%s", buffer->internal->name);
487+
snprintf(request.name, UIO_PCI_DMA_BUFFER_NAME_SIZE, "%s", buffer->internal->name);
501488

502489
buffer->internal->alloc_fd =
503490
pda_spinOpen
@@ -589,10 +576,14 @@ DMABuffer_new
589576
if( ((long unsigned int)start)%PAGE_SIZE != 0 )
590577
{ ERROR_EXIT( EINVAL, exit, "Input buffer is not page aligned!\n" ); }
591578

592-
ret += DMABuffer_generatePaths(buffer, device);
593-
ret += DMABuffer_lockUserBuffer(start, buffer);
594-
ret += DMABuffer_requestMemory(device, buffer, start);
595-
ret += DMABuffer_mapUser(buffer, start);
579+
if(DMABuffer_generatePaths(buffer, device) != PDA_SUCCESS)
580+
{ ERROR_EXIT( errno, exit, "Buffer registration generate paths failed!\n" ); }
581+
if(DMABuffer_lockUserBuffer(start, buffer) != PDA_SUCCESS)
582+
{ ERROR_EXIT( errno, exit, "Buffer registration lock buffer failed!\n" ); }
583+
if(DMABuffer_requestMemory(device, buffer, start) != PDA_SUCCESS)
584+
{ ERROR_EXIT( errno, exit, "Buffer registration request memory failed!\n" ); }
585+
if(DMABuffer_mapUser(buffer, start) != PDA_SUCCESS)
586+
{ ERROR_EXIT( errno, exit, "Buffer registration map failed!\n" ); }
596587
}
597588
break;
598589

@@ -641,12 +632,12 @@ DMABuffer_delete_not_attached_buffers(PciDevice *device)
641632

642633
char uio_file_path[PDA_STRING_LIMIT];
643634
memset(uio_file_path, 0, PDA_STRING_LIMIT);
644-
snprintf(uio_file_path, PDA_STRING_LIMIT, "%s/%04x:%02x:%02x.%1x/dma/",
635+
snprintf(uio_file_path, PDA_STRING_LIMIT, "%s/"UIO_PATH_FORMAT"/dma/",
645636
UIO_BAR_PATH, domain_id, bus_id, device_id, function_id);
646637

647638
char uio_delete_path[PDA_STRING_LIMIT];
648639
memset(uio_delete_path, 0, PDA_STRING_LIMIT);
649-
snprintf(uio_delete_path, PDA_STRING_LIMIT, "%s/%04x:%02x:%02x.%1x/dma/free",
640+
snprintf(uio_delete_path, PDA_STRING_LIMIT, "%s/"UIO_PATH_FORMAT"/dma/free",
650641
UIO_BAR_PATH, domain_id, bus_id, device_id, function_id);
651642

652643
/** Iterate over all directories inside the dma directory */
@@ -718,7 +709,7 @@ DMABuffer_check_persistant(PciDevice *device)
718709

719710
char uio_file_path[PDA_STRING_LIMIT];
720711
memset(uio_file_path, 0, PDA_STRING_LIMIT);
721-
snprintf(uio_file_path, PDA_STRING_LIMIT, "%s/%04x:%02x:%02x.%1x/dma/",
712+
snprintf(uio_file_path, PDA_STRING_LIMIT, "%s/"UIO_PATH_FORMAT"/dma/",
722713
UIO_BAR_PATH, domain_id, bus_id, device_id, function_id);
723714

724715
/** Return pointer */
@@ -1087,9 +1078,12 @@ DMABuffer_wrapMap(DMABuffer *buffer)
10871078
{ ERROR_EXIT( errno, exit, "Base allocation failed\n" ); }
10881079
else
10891080
{
1081+
#pragma GCC diagnostic push
1082+
#pragma GCC diagnostic ignored "-Wuse-after-free"
10901083
uint8_t *buffer_area_tmp = buffer_area;
10911084
free(buffer_area);
10921085
buffer_area = buffer_area_tmp;
1086+
#pragma GCC diagnostic pop
10931087
}
10941088

10951089
if(buffer->type == PDA_BUFFER_KERNEL)

arch/linux_x86_uio/pci_inc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ PciDevice_new
211211
snprintf( uio_sysfs_dir, PDA_STRING_LIMIT, "%s", UIO_DMA_SYSFS_DIR);
212212

213213
char uio_sysfs_entry[PDA_STRING_LIMIT];
214-
snprintf(uio_sysfs_entry, PDA_STRING_LIMIT, "%04d:%02d:%02d.%d",
214+
snprintf(uio_sysfs_entry, PDA_STRING_LIMIT, UIO_PATH_FORMAT,
215215
domain_id, bus_id, device_id, function_id);
216216

217217
RETURN(PciDevice_new_op(uio_sysfs_entry, "0000", "0000", domain_id, bus_id, device_id, function_id));
@@ -602,7 +602,7 @@ PciDevice_getListOfBuffers
602602

603603
char uio_file_path[PDA_STRING_LIMIT];
604604
memset(uio_file_path, 0, PDA_STRING_LIMIT);
605-
snprintf(uio_file_path, PDA_STRING_LIMIT, "%s/%04x:%02x:%02x.%1x/dma/",
605+
snprintf(uio_file_path, PDA_STRING_LIMIT, "%s/"UIO_PATH_FORMAT"/dma/",
606606
UIO_BAR_PATH, device->domain_id, device->bus_id, device->device_id, device->function_id);
607607

608608
DIR *directory = NULL;

include/pda/debug.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ typedef enum PdaDebugTypes_enum PdaDebugTypes;
8888
#ifdef DEBUG
8989

9090
#define DEBUG_PRINTF( mask, ... ) { \
91-
DebugPrintf( mask, __FILE__, __LINE__, __func__, __VA_ARGS__ ); \
91+
PdaDebugPrintf( mask, __FILE__, __LINE__, __func__, __VA_ARGS__ ); \
9292
}
9393

9494
#define RETURN( errorcode ) { \
95-
DebugPrintf(PDADEBUG_EXIT, __FILE__, __LINE__, __func__, "" ); \
95+
PdaDebugPrintf(PDADEBUG_EXIT, __FILE__, __LINE__, __func__, "" ); \
9696
return errorcode; \
9797
}
9898

9999
void
100-
DebugPrintf
100+
PdaDebugPrintf
101101
(
102102
const PdaDebugTypes mask,
103103
const char *file,
@@ -107,10 +107,10 @@ DebugPrintf
107107
...
108108
);
109109

110-
#define WARN( ... ) PDA_WarningHandler( __FILE__, __LINE__, __VA_ARGS__ );
110+
#define WARN( ... ) PdaWarningHandler( __FILE__, __LINE__, __VA_ARGS__ );
111111

112112
void
113-
PDA_WarningHandler
113+
PdaWarningHandler
114114
(
115115
const char *file,
116116
const uint64_t line,
@@ -129,17 +129,17 @@ PDA_WarningHandler
129129
#endif /*DEBUG*/
130130

131131
/*! Can be called if an unrecoverable error appeared. **/
132-
#define ERROR( errorcode, ... ) PDA_ErrorHandler( errorcode, __FILE__, __LINE__, __VA_ARGS__ );
132+
#define ERROR( errorcode, ... ) PdaErrorHandler( errorcode, __FILE__, __LINE__, __VA_ARGS__ );
133133

134134
/*! Issue an error to the debug output and jump to the goto label. **/
135135
#define ERROR_EXIT( errorcode, gotolabel, ... ) { \
136-
PDA_ErrorHandler( errorcode, __FILE__, __LINE__, __VA_ARGS__ ); \
136+
PdaErrorHandler( errorcode, __FILE__, __LINE__, __VA_ARGS__ ); \
137137
goto gotolabel; \
138138
}
139139

140140
/* @cond SHOWHIDDEN */
141141
int64_t
142-
PDA_ErrorHandler
142+
PdaErrorHandler
143143
(
144144
const int64_t errorcode,
145145
const char *file,

mk/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ install: libpda.so gendirs
3030
echo "CC=\"$(CC)\" " > $(DESTDIR)/bin/pda-config.inc
3131
echo "LDFLAGS=\"$(LDFLAGS)\" " >> $(DESTDIR)/bin/pda-config.inc
3232
echo "CFLAGS=\"$(CFLAGS)\" " >> $(DESTDIR)/bin/pda-config.inc
33-
echo "VERSION=\"$(LD_CUR):$(LD_REV):$(LD_AGE)\" " >> $(DESTDIR)/bin/pda-config.inc
33+
echo "VERSION=\"$(LD_CUR).$(LD_REV).$(LD_AGE)\" " >> $(DESTDIR)/bin/pda-config.inc
3434
@echo -= install shared stuff =-
3535
cp -r -L share/pda/* $(DESTDIR)/share/pda
3636

0 commit comments

Comments
 (0)