Skip to content

Commit

Permalink
Merge pull request #168 from shenwii/6.7.x
Browse files Browse the repository at this point in the history
Try to support linux kernel 6.7.x
  • Loading branch information
strongtz authored May 8, 2024
2 parents 19a8abe + e16564c commit 3d7a1b3
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dkms.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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]\.)"
19 changes: 18 additions & 1 deletion drivers/gpu/drm/i915/display/intel_dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/i915/display/intel_dp_mst.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/i915/display/intel_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_mman.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
33 changes: 32 additions & 1 deletion drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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));

Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/i915/i915_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand Down
5 changes: 4 additions & 1 deletion drivers/gpu/drm/i915/intel_device_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,15 @@ 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),
};

static const u16 subplatform_p_ids[] = {
INTEL_MTL_P_IDS(0),
};
#endif

static bool find_devid(u16 id, const u16 *p, unsigned int num)
{
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 3d7a1b3

Please sign in to comment.