Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 736675 - =x11-drivers/nvidia-drivers-450.57-r1 - .../work/kernel/nvidia-uvm/uvm8_va_range.h:758:5: error: implicit declaration of function ‘smp_read_barrier_depends’ [-Werror=implicit-function-declaration]
Summary: =x11-drivers/nvidia-drivers-450.57-r1 - .../work/kernel/nvidia-uvm/uvm8_va_ra...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: David Seifert
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-11 02:11 UTC by brookebasile
Modified: 2021-03-02 21:59 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,335.94 KB, text/plain)
2020-08-11 02:11 UTC, brookebasile
Details

Note You need to log in before you can comment on or make changes to this bug.
Description brookebasile 2020-08-11 02:11:02 UTC
Created attachment 654083 [details]
build.log

Emerging =x11-drivers/nvidia-drivers-450.57-r1 fails to emerge on a fresh install; Makefile error 1, "some warnings being treated as errors"

emerge -pqv

[ebuild  N    ] x11-drivers/nvidia-drivers-450.57-r1  USE="X driver kms libglvnd multilib tools -compat -gtk3 -static-libs -uvm -wayland" ABI_X86="32 (64) (-x32)" 

emerge --info 

Portage 3.0.2 (python 3.7.8-final-0, default/linux/amd64/17.1/desktop, gcc-9.3.0, glibc-2.31-r6, 5.8.0-x86_64+ x86_64)
=================================================================
System uname: Linux-5.8.0-x86_64+-x86_64-Intel-R-_Core-TM-_i7-9750H_CPU_@_2.60GHz-with-gentoo-2.7
KiB Mem:    14007324 total,  10333432 free
KiB Swap:   16777212 total,  16777212 free
Timestamp of repository gentoo: Mon, 10 Aug 2020 22:05:01 +0000
Head commit of repository gentoo: ee1fe67c7a6787db20b3fac5c6cc34b44db20fa0
sh bash 5.0_p18
ld GNU ld (Gentoo 2.33.1 p2) 2.33.1
app-shells/bash:          5.0_p18::gentoo
dev-lang/perl:            5.30.3-r1::gentoo
dev-lang/python:          2.7.18-r1::gentoo, 3.7.8-r2::gentoo, 3.8.5::gentoo, 3.9.0_beta5::gentoo
dev-util/cmake:           3.18.1::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.2::gentoo
sys-devel/binutils:       2.33.1-r1::gentoo, 2.34-r2::gentoo
sys-devel/gcc:            9.3.0-r1::gentoo, 10.2.0::gentoo
sys-devel/gcc-config:     2.3.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.8::gentoo (virtual/os-headers)
sys-libs/glibc:           2.31-r6::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-extra-opts: 

matrix
    location: /var/lib/layman/matrix
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -Wall"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -Wall"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-march=native -O2 -Wall"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -Wall"
GENTOO_MIRRORS="ftp://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ https://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ http://www.gtlib.gatech.edu/pub/gentoo rsync://rsync.gtlib.gatech.edu/gentoo https://gentoo.osuosl.org/ http://gentoo.osuosl.org/ https://mirrors.rit.edu/gentoo/ http://mirrors.rit.edu/gentoo/ ftp://mirrors.rit.edu/gentoo/ rsync://mirrors.rit.edu/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j8"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac aalib acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cdr cjk cli crypt cups dbus djvu dri dts dvd dvdr elogind emboss encode exif fcitx4 ffmpeg flac fontconfig fortran ftp gdbm gif git gpm gtk hddtemp iconv icu imagemagick imap ipv6 jpeg lcms ldap libnotify libtirpc lm-sensors mad matroska mbox mng mp3 mp4 mpeg mplayer mtp multilib musepack ncurses nls nptl offensive ogg opengl openmp opus pam pango pcre pdf pmcia png policykit ppds pulseaudio qt5 raw readline sdl seccomp sound spell split-usr ssl startup-notification svg tcpd theora threads tiff truetype udev udisks unicode upower usb vaapi vnc vorbis vulkan webp wifi wxwidgets x264 xattr xcb xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python3_7" RUBY_TARGETS="ruby25" USERLAND="GNU" VIDEO_CARDS="intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Ionen Wolkens 2020-08-11 03:10:53 UTC
This issue was also brought up on the forums (albeit no solution as of the writing of this), posting given a lot of info was given and could be a useful reference.
https://forums.gentoo.org/viewtopic-t-1117385.html
Comment 2 brookebasile 2020-08-12 18:52:37 UTC
Did some more digging into this, it looks like this error is likely the culprit: 

In file included from /var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-uvm/uvm8_global.c:31:
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-uvm/uvm8_va_range.h: In function ‘uvm_va_range_block’:
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-uvm/uvm8_va_range.h:758:5: error: implicit declaration of function ‘smp_read_barrier_depends’ [-Werror=implicit-function-declaration]
  758 |     smp_read_barrier_depends();
      |     ^~~~~~~~~~~~~~~~~~~~~~~~

Checked the header files in uvm8_va_range.h and couldn't find a declaration of smp_read_barrier_depends() anywhere.  Specifically, nv-kref.h includes <asm/barrier.h>, which shows no declaration of smp_read_barrier_depends in 5.8.0 kernel.  

Did some more digging from there and I found this LKML reference citing that smp_read_barrier_depends() macros have been removed from the kernel: 
https://lore.kernel.org/lkml/20200710165203.31284-11-will@kernel.org/

Not sure if they are aware of this upstream, I'm a newbie to kernel hacking so sorry if any of this was already obvious :)
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2020-08-12 19:09:13 UTC
I guess you do not have CONFIG_MEMBARRIER set.
Comment 4 brookebasile 2020-08-12 19:29:29 UTC
(In reply to Jeroen Roovers from comment #3)
> I guess you do not have CONFIG_MEMBARRIER set.

I just checked and it is enabled in my kernel config.
Comment 5 je_fro@yahoo.com 2020-08-13 05:31:16 UTC
Same here: # grep CONFIG_MEMBARRIER /usr/src/linux/.config
CONFIG_MEMBARRIER=y
Comment 6 brookebasile 2020-08-13 15:51:22 UTC
So it looks like nvidia is using a lot of functions that were deprecated in the last 1-2 months. 

I went ahead and removed the use of smp_read_barrier_depends() entirely, as according to this LKML email:
https://lore.kernel.org/lkml/20200710165203.31284-6-will@kernel.org/
READ_ONCE() can be used to provide dependency ordering (via its call to __READ_ONCE). 
The locations in the code that relied on smp_read_barrier_depends() utilize atomic_long_read(), which is a wrapper around atomic64_read(), which uses READ_ONCE():

// kernel/nvidia-uvm/uvm8_va_range.h:
static uvm_va_block_t *uvm_va_range_block(uvm_va_range_t *va_range, size_t index)
{
    uvm_va_block_t *block;
    UVM_ASSERT(va_range->type == UVM_VA_RANGE_TYPE_MANAGED);
    UVM_ASSERT(index < uvm_va_range_num_blocks(va_range));
    block = (uvm_va_block_t *)atomic_long_read(&va_range->blocks[index]);

    // Later accesses in this thread will read state out of block, potentially
    // as soon as the block pointer is updated by another thread. We have to
    // make sure that any initialization of this block by the creating thread is
    // visible to later accesses in this thread, which requires a data
    // dependency barrier.
    smp_read_barrier_depends();
    return block;
}

// kernel/nvidia-uvm/uvm8_tools.c:
static uvm_tools_event_tracker_t *tools_event_tracker(struct file *filp)
{
    long event_tracker = atomic_long_read((atomic_long_t *)&filp->private_data);

    smp_read_barrier_depends();
    return (uvm_tools_event_tracker_t *)event_tracker;
}

// asm-generic/atomic-long.h:
static __always_inline long
atomic_long_read(const atomic_long_t *v)
{
         return atomic64_read(v);
}

// asm/atomic.h
#define atomic64_read(v)        READ_ONCE((v)->counter)

So I thought it would be OK to just remove the references to smp_read_barrier_depends() based on the rework of READ_ONCE() described in the above LKML email.

That built fine, however, more errors popped up after moving past that stage of the compilation: 

In file included from /var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-gem-nvkms-memory.h:30,
                 from /var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-fb.h:38,
                 from /var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-drv.c:27:
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-gem.h: In function ‘nv_drm_gem_object_unreference_unlocked’:
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-gem.h:99:5: error: implicit declaration of function ‘drm_gem_object_put_unlocked’; did you mean ‘drm_gem_object_put_locke ’? [-Werror=implicit-function-declaration]
   99 |     drm_gem_object_put_unlocked(&nv_gem->base);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     drm_gem_object_put_locked

Git grep shows drm_gem_object_put_locked is deprecated:

// drm/drm_drv.h
330         /**
331          * @gem_free_object_unlocked: deconstructor for drm_gem_objects
332          *
333          * This is deprecated and should not be used by new drivers. Use
334          * &drm_gem_object_funcs.free instead.
335          */

/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-drv.c:722:6: error: ‘struct drm_driver’ has no member named ‘gem_free_object’; did you mean ‘gem_open_object’?
  722 |     .gem_free_object        = nv_drm_gem_free,
      |      ^~~~~~~~~~~~~~~
      |      gem_open_object
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-drv.c:722:31: error: initialization of ‘const struct drm_ioctl_desc *’ from incompatible pointer type ‘void (*)(struct drm_gem_object *)’ [-Werror=incompatible-pointer-types]
  722 |     .gem_free_object        = nv_drm_gem_free,
      |                               ^~~~~~~~~~~~~~~

***

Same here:

// drm/drm_drv.h
330         /**
331          * @gem_free_object_unlocked: deconstructor for drm_gem_objects
332          *
333          * This is deprecated and should not be used by new drivers. Use
334          * &drm_gem_object_funcs.free instead.
335          */

***

/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-modeset/nv-kthread-q.o
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-utils.c: In function ‘nvkms_display_mode_to_drm_mode’:
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-utils.c:106:9: error: ‘struct drm_display_mode’ has no member named ‘vrefresh’
  106 |     mode->vrefresh    = (displayMode->timings.refreshRate + 500) / 1000; /* In Hz */
      |         ^~

/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-utils.c: In function ‘drm_mode_to_nvkms_display_mode’:
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-utils.c:162:36: error: ‘const struct drm_display_mode’ has no member named ‘vrefresh’
  162 |     dst->timings.refreshRate  = src->vrefresh * 1000;

mode->vrefresh is also deprecated, see 0425662fdf05: drm: Nuke mode->vrefresh

According to this patch (https://lore.kernel.org/lkml/20200811182107.6515-1-sumit.semwal@linaro.org/t/#u):

v4: Since "0425662fdf05: drm: Nuke mode->vrefresh", we have to calculate
    vrefresh on demand. Update for it.

***

And this error:

/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-drv.c:722:31: note: (near initialization for ‘nv_drm_driver.ioctls’)
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-drv.c: In function ‘nv_drm_update_drm_driver_features’:
/var/tmp/portage/x11-drivers/nvidia-drivers-450.57-r1/work/kernel/nvidia-drm/nvidia-drm-drv.c:784:36: error: assignment to ‘void (*)(struct drm_device *, struct drm_file *, bool)’ {aka ‘void (*)(struct drm_device *, struct drm_file *, _Bool)’} from incompatible pointer type ‘int (*)(struct drm_device *, struct drm_file *, bool)’ {aka ‘int (*)(struct drm_device *, struct drm_file *, _Bool)’} [-Werror=incompatible-pointer-types]
  784 |     nv_drm_driver.master_set       = nv_drm_master_set;

***

So it seems like they're using a lot of macros/functions that have been deprecated, I'm not sure if they're aware of this upstream...?
Comment 7 Francois Chenier 2020-10-13 08:29:50 UTC
This is a snippet of code I`m using to build nvidia-drivers-390 on kernel 5.9.
NV_SMP_READ_BARRIER_DEPENDS_PRESENT macro check if smp_read_barrier_depends() is defined otherwise it just use smp_rmb() as replacement function call.
Assuming the kernel is compiled with CONFIG_SMP=y, smp_rmb() is defined in <asm-generic/barrier.c> for the latest kernels.

So far, so good, my patched nvidia-drivers-390 works like a charm with the latest kernels.

*****
diff --git a/kernel/nvidia-uvm/uvm8_tools.c b/kernel/nvidia-uvm/uvm8_tools.c
--- a/kernel/nvidia-uvm/uvm8_tools.c
+++ b/kernel/nvidia-uvm/uvm8_tools.c
@@ -190,11 +190,15 @@ static NV_STATUS tools_update_status(uvm_va_space_t *va_space);
 
 static uvm_tools_event_tracker_t *tools_event_tracker(struct file *filp)
 {
     long event_tracker = atomic_long_read((atomic_long_t *)&filp->private_data);
 
+#if defined(NV_SMP_READ_BARRIER_DEPENDS_PRESENT)
     smp_read_barrier_depends();
+#else
+    smp_rmb();
+#endif
     return (uvm_tools_event_tracker_t *)event_tracker;
 }
 
 static bool tracker_is_queue(uvm_tools_event_tracker_t *event_tracker)
 {
*****
Comment 8 David Seifert gentoo-dev 2020-11-18 18:41:21 UTC
Is this still relevant on the latest drivers? I dont get any issues
Comment 9 Ionen Wolkens 2021-03-02 21:59:04 UTC
(In reply to David Seifert from comment #8)
> Is this still relevant on the latest drivers? I dont get any issues
Had a look at drivers and bits regarding smp_read_barrier_depends changed. Only used in 1 place (instead of two), and guarded by a #ifdef. Fairly convinced this is obsolete.