From e16564cd81dcf4af430f3bcec0c0f0f27acf70db Mon Sep 17 00:00:00 2001 From: shinkosame Date: Tue, 7 May 2024 23:50:02 +0900 Subject: [PATCH] try to support linux kernel 6.7.x --- dkms.conf | 2 +- drivers/gpu/drm/i915/display/intel_dp.c | 19 ++++++++++- drivers/gpu/drm/i915/display/intel_dp_mst.c | 2 ++ drivers/gpu/drm/i915/display/intel_fb.c | 4 +++ drivers/gpu/drm/i915/gem/i915_gem_mman.c | 4 +++ drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 33 +++++++++++++++++++- drivers/gpu/drm/i915/i915_drv.h | 4 +++ drivers/gpu/drm/i915/intel_device_info.c | 5 ++- drivers/gpu/drm/i915/pxp/intel_pxp_tee.c | 14 +++++++++ 9 files changed, 83 insertions(+), 4 deletions(-) diff --git a/dkms.conf b/dkms.conf index 17dcb6fb..857e0455 100644 --- a/dkms.conf +++ b/dkms.conf @@ -8,4 +8,4 @@ BUILT_MODULE_NAME[0]="i915" DEST_MODULE_LOCATION[0]=/kernel/drivers/gpu/drm/i915 AUTOINSTALL=yes -BUILD_EXCLUSIVE_KERNEL="^(6\.[1-5]\.)" +BUILD_EXCLUSIVE_KERNEL="^(6\.[1-7]\.)" diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 21d5eeac..5a572d48 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -4536,14 +4536,21 @@ intel_dp_update_dfp(struct intel_dp *intel_dp, /* FIXME: Get rid of drm_edid_raw() */ edid = drm_edid_raw(drm_edid); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) intel_dp->dfp.max_bpc = drm_dp_downstream_max_bpc(intel_dp->dpcd, intel_dp->downstream_ports, edid); +#else + intel_dp->dfp.max_bpc = + drm_dp_downstream_max_bpc(intel_dp->dpcd, + intel_dp->downstream_ports, drm_edid); +#endif intel_dp->dfp.max_dotclock = drm_dp_downstream_max_dotclock(intel_dp->dpcd, intel_dp->downstream_ports); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) intel_dp->dfp.min_tmds_clock = drm_dp_downstream_min_tmds_clock(intel_dp->dpcd, intel_dp->downstream_ports, @@ -4552,6 +4559,16 @@ intel_dp_update_dfp(struct intel_dp *intel_dp, drm_dp_downstream_max_tmds_clock(intel_dp->dpcd, intel_dp->downstream_ports, edid); +#else + intel_dp->dfp.min_tmds_clock = + drm_dp_downstream_min_tmds_clock(intel_dp->dpcd, + intel_dp->downstream_ports, + drm_edid); + intel_dp->dfp.max_tmds_clock = + drm_dp_downstream_max_tmds_clock(intel_dp->dpcd, + intel_dp->downstream_ports, + drm_edid); +#endif intel_dp->dfp.pcon_max_frl_bw = drm_dp_get_pcon_max_frl_bw(intel_dp->dpcd, @@ -5117,7 +5134,7 @@ static const struct drm_connector_funcs intel_dp_connector_funcs = { .destroy = intel_connector_destroy, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, .atomic_duplicate_state = intel_digital_connector_duplicate_state, - .oob_hotplug_event = intel_dp_oob_hotplug_event, + .oob_hotplug_event = (void *) intel_dp_oob_hotplug_event, }; static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = { diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c index 1b0fe76f..b75a8c05 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c @@ -554,12 +554,14 @@ static void intel_mst_disable_dp(struct intel_atomic_state *state, intel_hdcp_disable(intel_mst->connector); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,5) || (LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,24) && LINUX_VERSION_CODE < KERNEL_VERSION(6,2,0) ) drm_dp_remove_payload(&intel_dp->mst_mgr, new_mst_state, old_payload, new_payload); #else drm_dp_remove_payload(&intel_dp->mst_mgr, mst_state, drm_atomic_get_mst_payload_state(mst_state, connector->port)); +#endif #endif intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state); diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index e7068fc0..5e6fcbe1 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -1112,7 +1112,11 @@ static int intel_fb_offset_to_xy(int *x, int *y, return -EINVAL; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) height = drm_framebuffer_plane_height(fb->height, fb, color_plane); +#else + height = drm_format_info_plane_height(fb->format, fb->height, color_plane); +#endif height = ALIGN(height, intel_tile_height(fb, color_plane)); /* Catch potential overflows early */ diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c index 916a4215..c5996a01 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c @@ -912,11 +912,15 @@ static struct file *mmap_singleton(struct drm_i915_private *i915) { struct file *file; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) rcu_read_lock(); file = READ_ONCE(i915->gem.mmap_singleton); if (file && !get_file_rcu(file)) file = NULL; rcu_read_unlock(); +#else + file = get_file_active(&i915->gem.mmap_singleton); +#endif if (file) return file; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c index 21476394..3f9229e0 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c @@ -284,8 +284,12 @@ unsigned long i915_gem_shrink_all(struct drm_i915_private *i915) static unsigned long i915_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) struct drm_i915_private *i915 = container_of(shrinker, struct drm_i915_private, mm.shrinker); +#else + struct drm_i915_private *i915 = shrinker->private_data; +#endif unsigned long num_objects; unsigned long count; @@ -302,9 +306,15 @@ i915_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc) if (num_objects) { unsigned long avg = 2 * count / num_objects; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) i915->mm.shrinker.batch = max((i915->mm.shrinker.batch + avg) >> 1, 128ul /* default SHRINK_BATCH */); +#else + i915->mm.shrinker->batch = + max((i915->mm.shrinker->batch + avg) >> 1, + 128ul /* default SHRINK_BATCH */); +#endif } return count; @@ -313,8 +323,12 @@ i915_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc) static unsigned long i915_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) struct drm_i915_private *i915 = container_of(shrinker, struct drm_i915_private, mm.shrinker); +#else + struct drm_i915_private *i915 = shrinker->private_data; +#endif unsigned long freed; sc->nr_scanned = 0; @@ -422,13 +436,26 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr void i915_gem_driver_register__shrinker(struct drm_i915_private *i915) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) i915->mm.shrinker.scan_objects = i915_gem_shrinker_scan; i915->mm.shrinker.count_objects = i915_gem_shrinker_count; i915->mm.shrinker.seeks = DEFAULT_SEEKS; i915->mm.shrinker.batch = 4096; drm_WARN_ON(&i915->drm, register_shrinker(&i915->mm.shrinker, "drm-i915_gem")); - +#else + i915->mm.shrinker = shrinker_alloc(0, "drm-i915_gem"); + if (!i915->mm.shrinker) { + drm_WARN_ON(&i915->drm, 1); + } else { + i915->mm.shrinker->scan_objects = i915_gem_shrinker_scan; + i915->mm.shrinker->count_objects = i915_gem_shrinker_count; + i915->mm.shrinker->batch = 4096; + i915->mm.shrinker->private_data = i915; + + shrinker_register(i915->mm.shrinker); + } +#endif i915->mm.oom_notifier.notifier_call = i915_gem_shrinker_oom; drm_WARN_ON(&i915->drm, register_oom_notifier(&i915->mm.oom_notifier)); @@ -443,7 +470,11 @@ void i915_gem_driver_unregister__shrinker(struct drm_i915_private *i915) unregister_vmap_purge_notifier(&i915->mm.vmap_notifier)); drm_WARN_ON(&i915->drm, unregister_oom_notifier(&i915->mm.oom_notifier)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) unregister_shrinker(&i915->mm.shrinker); +#else + shrinker_free(i915->mm.shrinker); +#endif } void i915_gem_shrinker_taints_mutex(struct drm_i915_private *i915, diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 6eb19699..e0414a49 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -166,7 +166,11 @@ struct i915_gem_mm { struct notifier_block oom_notifier; struct notifier_block vmap_notifier; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) struct shrinker shrinker; +#else + struct shrinker *shrinker; +#endif #ifdef CONFIG_MMU_NOTIFIER /** diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c index 254659b1..59401a51 100644 --- a/drivers/gpu/drm/i915/intel_device_info.c +++ b/drivers/gpu/drm/i915/intel_device_info.c @@ -216,6 +216,7 @@ static const u16 subplatform_g12_ids[] = { INTEL_DG2_G12_IDS(0), }; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) static const u16 subplatform_m_ids[] = { INTEL_MTL_M_IDS(0), }; @@ -223,6 +224,7 @@ static const u16 subplatform_m_ids[] = { static const u16 subplatform_p_ids[] = { INTEL_MTL_P_IDS(0), }; +#endif static bool find_devid(u16 id, const u16 *p, unsigned int num) { @@ -278,14 +280,15 @@ static void intel_device_info_subplatform_init(struct drm_i915_private *i915) } else if (find_devid(devid, subplatform_g12_ids, ARRAY_SIZE(subplatform_g12_ids))) { mask = BIT(INTEL_SUBPLATFORM_G12); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) } else if (find_devid(devid, subplatform_m_ids, ARRAY_SIZE(subplatform_m_ids))) { mask = BIT(INTEL_SUBPLATFORM_M); } else if (find_devid(devid, subplatform_p_ids, ARRAY_SIZE(subplatform_p_ids))) { mask = BIT(INTEL_SUBPLATFORM_P); +#endif } - GEM_BUG_ON(mask & ~INTEL_SUBPLATFORM_MASK); RUNTIME_INFO(i915)->platform_mask[pi] |= mask; diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c index 30326ca6..e90d6ec4 100644 --- a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c @@ -21,6 +21,10 @@ #include "intel_pxp_tee.h" #include "intel_pxp_types.h" +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,7,0) +#define PXP_TRANSPORT_TIMEOUT_MS 5000 /* 5 sec */ +#endif + static int intel_pxp_tee_io_message(struct intel_pxp *pxp, void *msg_in, u32 msg_in_size, void *msg_out, u32 msg_out_max_size, @@ -41,13 +45,23 @@ static int intel_pxp_tee_io_message(struct intel_pxp *pxp, goto unlock; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) ret = pxp_component->ops->send(pxp_component->tee_dev, msg_in, msg_in_size); +#else + ret = pxp_component->ops->send(pxp_component->tee_dev, msg_in, msg_in_size, + PXP_TRANSPORT_TIMEOUT_MS); +#endif if (ret) { drm_err(&i915->drm, "Failed to send PXP TEE message\n"); goto unlock; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0) ret = pxp_component->ops->recv(pxp_component->tee_dev, msg_out, msg_out_max_size); +#else + ret = pxp_component->ops->recv(pxp_component->tee_dev, msg_out, msg_out_max_size, + PXP_TRANSPORT_TIMEOUT_MS); +#endif if (ret < 0) { drm_err(&i915->drm, "Failed to receive PXP TEE message\n"); goto unlock;