Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbreak build on FreeBSD #220

Merged
merged 8 commits into from
Feb 11, 2024
Merged

Unbreak build on FreeBSD #220

merged 8 commits into from
Feb 11, 2024

Conversation

jbeich
Copy link
Contributor

@jbeich jbeich commented Jul 3, 2023

Runtime is untested as I lack an NVIDIA GPU. See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264027

jbeich added 7 commits July 3, 2023 21:30
src/direct/direct-export-buf.c:10:10: fatal error: 'sys/sysmacros.h' file not found
 #include <sys/sysmacros.h>
          ^~~~~~~~~~~~~~~~~
src/export-buf.c:11:10: fatal error: 'sys/sysmacros.h' file not found
 #include <sys/sysmacros.h>
          ^~~~~~~~~~~~~~~~~
src/direct/nv-driver.c:46:30: error: use of undeclared identifier '_IOC_READ'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_RM_ALLOC, size), &alloc);
                             ^
src/direct/nv-driver.c:46:40: error: use of undeclared identifier '_IOC_WRITE'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_RM_ALLOC, size), &alloc);
                                       ^
src/direct/nv-driver.c:80:30: error: use of undeclared identifier '_IOC_READ'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_RM_FREE, sizeof(NVOS00_PARAMETERS)), &freeParams);
                             ^
src/direct/nv-driver.c:80:40: error: use of undeclared identifier '_IOC_WRITE'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_RM_FREE, sizeof(NVOS00_PARAMETERS)), &freeParams);
                                       ^
src/direct/nv-driver.c:100:30: error: use of undeclared identifier '_IOC_READ'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_RM_CONTROL, sizeof(NVOS54_PARAMETERS)), &control);
                             ^
src/direct/nv-driver.c:100:40: error: use of undeclared identifier '_IOC_WRITE'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_RM_CONTROL, sizeof(NVOS54_PARAMETERS)), &control);
                                       ^
src/direct/nv-driver.c:138:30: error: use of undeclared identifier '_IOC_READ'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_ATTACH_GPUS_TO_FD, sizeof(gpu)), &gpu);
                             ^
src/direct/nv-driver.c:138:40: error: use of undeclared identifier '_IOC_WRITE'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_ATTACH_GPUS_TO_FD, sizeof(gpu)), &gpu);
                                       ^
src/direct/nv-driver.c:170:30: error: use of undeclared identifier '_IOC_READ'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_CHECK_VERSION_STR, sizeof(obj)), &obj);
                             ^
src/direct/nv-driver.c:170:40: error: use of undeclared identifier '_IOC_WRITE'
    int ret = ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_CHECK_VERSION_STR, sizeof(obj)), &obj);
                                       ^
src/direct/nv-driver.c:183:34: error: use of undeclared identifier '_IOC_READ'
    int ret = ioctl(nv0_fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_REGISTER_FD, sizeof(int)), &nvctl_fd);
                                 ^
src/direct/nv-driver.c:183:44: error: use of undeclared identifier '_IOC_WRITE'
    int ret = ioctl(nv0_fd, _IOC(_IOC_READ|_IOC_WRITE, NV_IOCTL_MAGIC, NV_ESC_REGISTER_FD, sizeof(int)), &nvctl_fd);
                                           ^
src/hevc.c:237:90: error: use of undeclared identifier '__compar_d_fn_t'
    qsort_r(ppc->RefPicSetStCurrBefore, ppc->NumPocStCurrBefore, sizeof(unsigned char), (__compar_d_fn_t) sortFuncRev, ppc->PicOrderCntVal);
                                                                                         ^
src/hevc.c:238:88: error: use of undeclared identifier '__compar_d_fn_t'
    qsort_r(ppc->RefPicSetStCurrAfter, ppc->NumPocStCurrAfter, sizeof(unsigned char), (__compar_d_fn_t) sortFunc, ppc->PicOrderCntVal);
                                                                                       ^
src/hevc.c:241:120: error: incompatible pointer types passing 'int [16]' to parameter of type 'int (*)(void *, const void *, const void *)' [-Werror,-Wincompatible-pointer-types]
    qsort_r(ppc->RefPicSetStCurrBefore, ppc->NumPocStCurrBefore, sizeof(unsigned char), (__compar_d_fn_t) sortFuncRev, ppc->PicOrderCntVal);
                                                                                                                       ^~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:308:12: note: passing argument to parameter here
            int (*)(void *, const void *, const void *));
                  ^
src/hevc.c:242:115: error: incompatible pointer types passing 'int [16]' to parameter of type 'int (*)(void *, const void *, const void *)' [-Werror,-Wincompatible-pointer-types]
    qsort_r(ppc->RefPicSetStCurrAfter, ppc->NumPocStCurrAfter, sizeof(unsigned char), (__compar_d_fn_t) sortFunc, ppc->PicOrderCntVal);
                                                                                                                  ^~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:308:12: note: passing argument to parameter here
            int (*)(void *, const void *, const void *));
                  ^
src/vabackend.c:302:15: warning: call to undeclared function 'pthread_timedjoin_np'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    int ret = pthread_timedjoin_np(nvCtx->resolveThread, NULL, &timeout);
              ^
src/vabackend.c:174:98: warning: call to undeclared function 'gettid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    fprintf(LOG_OUTPUT, "%10ld.%09ld [%d-%d] %s:%4d %24s %s\n", tp.tv_sec, tp.tv_nsec, getpid(), gettid(), filename, line, function, formattedMessage);
                                                                                                 ^
ld: error: undefined symbol: gettid
>>> referenced by vabackend.c:182 (src/vabackend.c:182)
>>>               nvidia_drv_video.so.p/src_vabackend.c.o:(logger)

See also https://github.com/intel/libva/blob/2.18.0/va/va_trace.c#L72-L91
src/vabackend.c:183:65: error: format specifies type 'long' but the argument has type 'time_t' (aka 'int') [-Werror,-Wformat]
    fprintf(LOG_OUTPUT, "%10ld.%09ld [%d-%d] %s:%4d %24s %s\n", tp.tv_sec, tp.tv_nsec, getpid(), gettid(), filename, line, function, formattedMessage);
                         ~~~~~                                  ^~~~~~~~~
                         %10d
@elFarto
Copy link
Owner

elFarto commented Jul 8, 2023

Thanks for the patch, however I'm not entirely certain this driver can actually work on freebsd, since it relies on DMA-BUF, which is a Linux only feature, AFAIK.

Without having someone test this patch on freebsd with NVIDIA hardware, I'm not sure it's worth accepting this patch in.

@jbeich
Copy link
Contributor Author

jbeich commented Jul 8, 2023

relies on DMA-BUF, which is a Linux only feature, AFAIK.

DragonFly, FreeBSD (also), NetBSD reimplemented DMA-BUF under BSD license when porting MIT-licensed Linux DRM drivers. DMA-BUF with NVIDIA on FreeBSD requires nvidia-drm.ko.

@elFarto elFarto marked this pull request as ready for review February 11, 2024 11:00
@elFarto elFarto merged commit a28ffbb into elFarto:master Feb 11, 2024
2 checks passed
@elFarto
Copy link
Owner

elFarto commented Feb 11, 2024

Thanks for the patch. I've decided to merge it in as it's fairly self contained. Not sure it'll actually work though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants