From f309ac43c03db97112701de13ff61d6a5f675b03 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 22 Feb 2018 11:14:26 +0100 Subject: [PATCH 1/3] nvidiactl: Use a function for generic mxgfx link --- nvidiactl/nvidiactl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nvidiactl/nvidiactl b/nvidiactl/nvidiactl index 2ea5265..e2fd418 100755 --- a/nvidiactl/nvidiactl +++ b/nvidiactl/nvidiactl @@ -1,5 +1,10 @@ #!/bin/bash +set_generic_mxgfx_link () { + rm -f /node/usr_share_mxgfx + ln -sf /usr/share/mxgfx-generic /node/usr_share_mxgfx +} + PCIIDHINT_DIR=/usr/share/nvidia/pciidhints kver=$(uname -r) @@ -11,8 +16,7 @@ nvver=${nvidiacards[0]} if [ -z ${nvver} ] ; then echo >&2 "WARNING: no nvidia card found.." - rm -f /node/usr_share_mxgfx - ln -sf /usr/share/mxgfx-generic /node/usr_share_mxgfx + set_generic_mxgfx_link exit 0 fi From 9c4b957d2061963fba4f0ceb0bc4504d825d0488 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 22 Feb 2018 12:20:54 +0100 Subject: [PATCH 2/3] nvidiactl: Pass legacy cards to nouveau driver --- nvidiactl/nvidiactl | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/nvidiactl/nvidiactl b/nvidiactl/nvidiactl index e2fd418..da3ba6d 100755 --- a/nvidiactl/nvidiactl +++ b/nvidiactl/nvidiactl @@ -5,6 +5,13 @@ set_generic_mxgfx_link () { ln -sf /usr/share/mxgfx-generic /node/usr_share_mxgfx } + +if [ -d /sys/module/nouveau ] ; then + echo >&2 "NOTE: nouveau driver loaded already, using 'mxgfx-generic'." + set_generic_mxgfx_link + exit 0 +fi + PCIIDHINT_DIR=/usr/share/nvidia/pciidhints kver=$(uname -r) @@ -13,7 +20,6 @@ nvidiacards=( $(lspci -n | grep " 0300: 10de:" | cut -d ' ' -f 3) ) nvver=${nvidiacards[0]} - if [ -z ${nvver} ] ; then echo >&2 "WARNING: no nvidia card found.." set_generic_mxgfx_link @@ -22,22 +28,20 @@ fi pciids="${PCIIDHINT_DIR}/${kver}-${nvver} ${PCIIDHINT_DIR}/${nvver}" - -leglvl="current" - for leglvlhint in ${pciids} ; do if [ -h "${leglvlhint}" ] ; then - leglvl=$(readlink ${leglvlhint}) - break + set_generic_mxgfx_link + test -e /lib/modules/${kver}/kernel/drivers/gpu/drm/nouveau/nouveau.ko && \ + echo >&2 "NOTE: legacy nvidia card found, loading nouveau .." && \ + modprobe nouveau && \ + exit 0 + + echo >&2 "ERROR: nouveau module not available, choose a newer kernel!" + exit 1 fi done -nvlink=/usr/share/nvidia/kernel/${kver}/${leglvl} - -if [ ! -h ${nvlink} ] ; then - echo >&2 "WARNING: ${nvlink} is not a link (to nvversion) trying current.." - nvlink=/usr/share/nvidia/kernel/${kver}/current -fi +nvlink=/usr/share/nvidia/kernel/${kver}/current if [ ! -h ${nvlink} ] ; then echo >&2 "WARNING: ${nvlink} is not a link (to nvversion) .." @@ -46,7 +50,7 @@ fi nvver=$(readlink ${nvlink}) -#echo "kver=${kver} leglvl=${leglvl} nvver=${nvver}" +#echo "kver=${kver} nvver=${nvver}" # lrwxrwxrwx 1 root system 27 Feb 11 15:39 /node/usr_share_mxgfx -> /usr/share/nvidia/260.19.21 From f60aab1d2c8721c664afc8e15c9d202e7f41d1bd Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 22 Feb 2018 12:24:15 +0100 Subject: [PATCH 3/3] nvidiactl: Straighten indent --- nvidiactl/nvidiactl | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/nvidiactl/nvidiactl b/nvidiactl/nvidiactl index da3ba6d..2d6f3f5 100755 --- a/nvidiactl/nvidiactl +++ b/nvidiactl/nvidiactl @@ -7,9 +7,9 @@ set_generic_mxgfx_link () { if [ -d /sys/module/nouveau ] ; then - echo >&2 "NOTE: nouveau driver loaded already, using 'mxgfx-generic'." - set_generic_mxgfx_link - exit 0 + echo >&2 "NOTE: nouveau driver loaded already, using 'mxgfx-generic'." + set_generic_mxgfx_link + exit 0 fi PCIIDHINT_DIR=/usr/share/nvidia/pciidhints @@ -21,31 +21,31 @@ nvidiacards=( $(lspci -n | grep " 0300: 10de:" | cut -d ' ' -f 3) ) nvver=${nvidiacards[0]} if [ -z ${nvver} ] ; then - echo >&2 "WARNING: no nvidia card found.." - set_generic_mxgfx_link - exit 0 + echo >&2 "WARNING: no nvidia card found.." + set_generic_mxgfx_link + exit 0 fi pciids="${PCIIDHINT_DIR}/${kver}-${nvver} ${PCIIDHINT_DIR}/${nvver}" for leglvlhint in ${pciids} ; do - if [ -h "${leglvlhint}" ] ; then - set_generic_mxgfx_link - test -e /lib/modules/${kver}/kernel/drivers/gpu/drm/nouveau/nouveau.ko && \ - echo >&2 "NOTE: legacy nvidia card found, loading nouveau .." && \ - modprobe nouveau && \ - exit 0 - - echo >&2 "ERROR: nouveau module not available, choose a newer kernel!" - exit 1 - fi + if [ -h "${leglvlhint}" ] ; then + set_generic_mxgfx_link + test -e /lib/modules/${kver}/kernel/drivers/gpu/drm/nouveau/nouveau.ko && \ + echo >&2 "NOTE: legacy nvidia card found, loading nouveau .." && \ + modprobe nouveau && \ + exit 0 + + echo >&2 "ERROR: nouveau module not available, choose a newer kernel!" + exit 1 + fi done nvlink=/usr/share/nvidia/kernel/${kver}/current if [ ! -h ${nvlink} ] ; then - echo >&2 "WARNING: ${nvlink} is not a link (to nvversion) .." - exit 1 + echo >&2 "WARNING: ${nvlink} is not a link (to nvversion) .." + exit 1 fi nvver=$(readlink ${nvlink}) @@ -85,4 +85,5 @@ if [ ! -z $N ]; then test -e ${nvlink}/nvidia-modeset.ko && insmod ${nvlink}/nvidia-modeset.ko test -e ${nvlink}/nvidia-drm.ko && insmod ${nvlink}/nvidia-drm.ko fi + exit 0