やるきなし

2019/03/07 22:16 / Linux 4.20.13 -> 5.0.0

5.0が出たので.configがどう変更されるのか見てみた.以下 - は削除されたもの,+ は追加されたもの.汎用指向の環境.Btrfs だと swap file が使えなかった(禁止されていた)のだが,Btrfs: support swap filesにより復活.

DKMS

案の定 nvidia-kernel-dkms (390.87-8~deb9u1) と nvidia-legacy-340xx-kernel-dkms (340.107-2~bpo9+1) が compile できない.broadcom-sta-dkms は今回試さず.エラーは以下のようなもの(抜粋).

/var/lib/dkms/nvidia-current/390.87/build/nvidia/os-interface.c:434:5: error: implicit declaration of function ‘do_gettimeofday’ [-Werror=implicit-function-declaration]
     do_gettimeofday(&tm);
     ^~~~~~~~~~~~~~~
/var/lib/dkms/nvidia-current/390.87/build/nvidia-drm/nvidia-drm-gem.h:82:5: error: implicit declaration of function ‘drm_gem_object_unreference_unlocked’ [-Werror=implicit-function-declaration]
     drm_gem_object_unreference_unlocked(&nv_gem->base);

do_gettimeofday は適当に関数を用意して,DRMについては以下のとおり置換で対応.

-drm_gem_object_unreference_unlocked(object);
+drm_gem_object_put_unlocked(object);

-drm_gem_object_unreference(object);
+drm_gem_object_put(object);

-drm_framebuffer_reference(object);
+drm_framebuffer_get(object);

-drm_framebuffer_unreference(object);
+drm_framebuffer_put(object);

-drm_dev_unref(object);
+drm_dev_put(object);

以下 nvidia-kernel-dkms (390.87-8~deb9u1) の patch.conftest.shNV_DRM_DEV_UNREF_PRESENT が define されなくなるので,逆に else の方を修正(drm_dev_free は更に古い I/F).とりあえず stable の package ベースでやり過ごすためだけのパッチ.

--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -1893,4 +1893,13 @@ static inline NvU64 nv_expand_nvlink_addr(NvU64 addr47)
 #include <linux/backlight.h>
 #endif
 
+static inline void do_gettimeofday(struct timeval *tv)
+{
+    struct timespec64 now;
+
+    ktime_get_real_ts64(&now);
+    tv->tv_sec = now.tv_sec;
+    tv->tv_usec = now.tv_nsec/1000;
+}
+
 #endif  /* _NV_LINUX_H_ */
diff --git a/nvidia-drm/nvidia-drm-gem.h b/nvidia-drm/nvidia-drm-gem.h
index f5964e2..a9f057d 100644
--- a/nvidia-drm/nvidia-drm-gem.h
+++ b/nvidia-drm/nvidia-drm-gem.h
@@ -79,7 +79,7 @@ static inline int nv_drm_gem_handle_create_drop_reference(
 
     /* drop reference from allocate - handle holds it now */
 
-    drm_gem_object_unreference_unlocked(&nv_gem->base);
+    drm_gem_object_put_unlocked(&nv_gem->base);
 
     return ret;
 }
@@ -153,13 +153,13 @@ static inline struct nv_drm_gem_object *nv_drm_gem_object_lookup(
 static inline void
 nv_drm_gem_object_unreference_unlocked(struct nv_drm_gem_object *nv_gem)
 {
-    drm_gem_object_unreference_unlocked(&nv_gem->base);
+    drm_gem_object_put_unlocked(&nv_gem->base);
 }
 
 static inline void
 nv_drm_gem_object_unreference(struct nv_drm_gem_object *nv_gem)
 {
-    drm_gem_object_unreference(&nv_gem->base);
+    drm_gem_object_put(&nv_gem->base);
 }
 
 static inline int nv_drm_gem_handle_create(struct drm_file *filp,
diff --git a/nvidia-drm/nvidia-drm-helper.c b/nvidia-drm/nvidia-drm-helper.c
index 4ccf819..429f346 100644
--- a/nvidia-drm/nvidia-drm-helper.c
+++ b/nvidia-drm/nvidia-drm-helper.c
@@ -149,12 +149,12 @@ void nv_drm_atomic_clean_old_fb(struct drm_device *dev,
         if (ret == 0) {
             struct drm_framebuffer *new_fb = plane->state->fb;
             if (new_fb)
-                drm_framebuffer_reference(new_fb);
+                drm_framebuffer_get(new_fb);
             plane->fb = new_fb;
             plane->crtc = plane->state->crtc;
 
             if (plane->old_fb)
-                drm_framebuffer_unreference(plane->old_fb);
+                drm_framebuffer_put(plane->old_fb);
        }
        plane->old_fb = NULL;
    }
diff --git a/nvidia-drm/nvidia-drm-helper.h b/nvidia-drm/nvidia-drm-helper.h
index ab61c7e..e002d7c 100644
--- a/nvidia-drm/nvidia-drm-helper.h
+++ b/nvidia-drm/nvidia-drm-helper.h
@@ -39,7 +39,7 @@ static inline void nv_drm_dev_free(struct drm_device *dev)
 #if defined(NV_DRM_DEV_UNREF_PRESENT)
     drm_dev_unref(dev);
 #else
-    drm_dev_free(dev);
+    drm_dev_put(dev);
 #endif
 }
 
diff --git a/nvidia-drm/nvidia-drm-linux.c b/nvidia-drm/nvidia-drm-linux.c
index 333bfe1..d3614b9 100644
--- a/nvidia-drm/nvidia-drm-linux.c
+++ b/nvidia-drm/nvidia-drm-linux.c
@@ -156,6 +156,15 @@ void nv_drm_vunmap(void *address)
     vunmap(address);
 }
 
+static inline void do_gettimeofday(struct timeval *tv)
+{
+    struct timespec64 now;
+
+    ktime_get_real_ts64(&now);
+    tv->tv_sec = now.tv_sec;
+    tv->tv_usec = now.tv_nsec/1000;
+}
+
 uint64_t nv_drm_get_time_usec(void)
 {
     struct timeval tv;
diff --git a/nvidia-modeset/nvidia-modeset-linux.c b/nvidia-modeset/nvidia-modeset-linux.c
index 6f51178..07c207e 100644
--- a/nvidia-modeset/nvidia-modeset-linux.c
+++ b/nvidia-modeset/nvidia-modeset-linux.c
@@ -208,6 +208,15 @@ void NVKMS_API_CALL nvkms_usleep(NvU64 usec)
     }
 }
 
+static inline void do_gettimeofday(struct timeval *tv)
+{
+    struct timespec64 now;
+
+    ktime_get_real_ts64(&now);
+    tv->tv_sec = now.tv_sec;
+    tv->tv_usec = now.tv_nsec/1000;
+}
+
 NvU64 NVKMS_API_CALL nvkms_get_usec(void)
 {
     struct timeval tv;

以下 nvidia-legacy-340xx-kernel-dkms (340.107-2~bpo9+1) 向け patch.

--- a/nv-drm.c
+++ b/nv-drm.c
@@ -252,7 +252,7 @@ RM_STATUS NV_API_CALL nv_alloc_os_descriptor_handle(
         goto done;
     }
 
-    drm_gem_object_unreference_unlocked(&nv_obj->base);
+    drm_gem_object_put_unlocked(&nv_obj->base);
 
     status = RM_OK;
 
diff --git a/os-interface.c b/os-interface.c
index 7e3d362..f1ca725 100644
--- a/os-interface.c
+++ b/os-interface.c
@@ -433,6 +433,15 @@ void NV_API_CALL os_free_mem(void *address)
 *
 *****************************************************************************/
 
+static inline void do_gettimeofday(struct timeval *tv)
+{
+   struct timespec64 now;
+
+   ktime_get_real_ts64(&now);
+   tv->tv_sec = now.tv_sec;
+   tv->tv_usec = now.tv_nsec/1000;
+}
+
 RM_STATUS NV_API_CALL os_get_current_time(
     NvU32 *seconds,
     NvU32 *useconds
diff --git a/uvm/nvidia_uvm_lite.c b/uvm/nvidia_uvm_lite.c
index 19e3b36..9f1a479 100644
--- a/uvm/nvidia_uvm_lite.c
+++ b/uvm/nvidia_uvm_lite.c
@@ -2008,6 +2008,15 @@ void umvlite_destroy_per_process_gpu_resources(UvmGpuUuid *gpuUuidStruct)
 // Function to check for ECC errors and returns true if an ECC DBE error
 // has happened.
 //
+static inline void do_gettimeofday(struct timeval *tv)
+{
+   struct timespec64 now;
+
+   ktime_get_real_ts64(&now);
+   tv->tv_sec = now.tv_sec;
+   tv->tv_usec = now.tv_nsec/1000;
+}
+
 static RM_STATUS _check_ecc_errors(UvmGpuMigrationTracking *pMigTracker,
                                     NvBool *pIsEccErrorSet)
 {

ともに Linux 5.0 より前の version で動かすことは考えていない.

Related articles