Skip to content

Commit

Permalink
i915 module: build with linux-6.1 to linux-6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zhtengw committed Apr 25, 2023
1 parent 23e385c commit 092d1cf
Show file tree
Hide file tree
Showing 28 changed files with 8,660 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ EXTRA_CFLAGS += -DCONFIG_PM -DCONFIG_DEBUG_FS -DCONFIG_PNP -DCONFIG_PROC_FS \
-DCONFIG_X86 -DCONFIG_ACPI -DCONFIG_DRM_FBDEV_EMULATION \
-DCONFIG_PMIC_OPREGION -DCONFIG_SWIOTLB -DCONFIG_DRM_I915_PXP

KBUILD_MODPOST_WARN = 1

# core driver code
i915-y += i915_driver.o \
i915_drm_client.o \
i915_config.o \
i915_getparam.o \
i915_hwmon.o \
i915_ioctl.o \
i915_irq.o \
i915_mitigations.o \
Expand Down Expand Up @@ -242,9 +244,6 @@ iov-y += \
gt/iov/intel_iov_sysfs.o
i915-y += $(iov-y)

# graphics hardware monitoring (HWMON) support
i915-$(CONFIG_HWMON) += i915_hwmon.o

# modesetting core code
i915-y += \
display/hsw_ips.o \
Expand Down Expand Up @@ -408,6 +407,7 @@ i915-y := $(addprefix $(DRMD)i915/,$(i915-y))
# structs and declarations and so forth that we need for the backport to build.

LINUXINCLUDE := \
-I$(INC_INCPATH)/ \
-I$(INC_INCPATH)/trace \
-I$(KBUILD_EXTMOD)/drivers/gpu/drm/i915 \
$(LINUXINCLUDE)
Expand Down
23 changes: 23 additions & 0 deletions drivers/gpu/drm/i915/display/intel_dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/string_helpers.h>
#include <linux/timekeeping.h>
#include <linux/types.h>
#include <linux/version.h>

#include <asm/byteorder.h>

Expand Down Expand Up @@ -4823,10 +4824,19 @@ intel_dp_force(struct drm_connector *connector)
static int intel_dp_get_modes(struct drm_connector *connector)
{
struct intel_connector *intel_connector = to_intel_connector(connector);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
int num_modes;

/* drm_edid_connector_update() done in ->detect() or ->force() */
num_modes = drm_edid_connector_add_modes(connector);
#else
const struct edid *edid;
int num_modes = 0;

edid = drm_edid_raw(intel_connector->detect_edid);
if (edid)
num_modes = intel_connector_update_modes(connector, edid);
#endif

/* Also add fixed mode, which may or may not be present in EDID */
if (intel_dp_is_edp(intel_attached_dp(intel_connector)))
Expand Down Expand Up @@ -5272,6 +5282,9 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
bool has_dpcd;
const struct drm_edid *drm_edid;
#if !(LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0))
const struct edid *edid;
#endif

if (!intel_dp_is_edp(intel_dp))
return true;
Expand Down Expand Up @@ -5328,12 +5341,22 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
connector->base.id, connector->name);
}
if (drm_edid) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
if (drm_edid_connector_update(connector, drm_edid) ||
!drm_edid_connector_add_modes(connector)) {
drm_edid_connector_update(connector, NULL);
drm_edid_free(drm_edid);
drm_edid = ERR_PTR(-EINVAL);
}
#else
edid = drm_edid_raw(drm_edid);
if (drm_add_edid_modes(connector, edid)) {
drm_connector_update_edid_property(connector, edid);
} else {
drm_edid_free(drm_edid);
drm_edid = ERR_PTR(-EINVAL);
}
#endif
} else {
drm_edid = ERR_PTR(-ENOENT);
}
Expand Down
15 changes: 15 additions & 0 deletions drivers/gpu/drm/i915/display/intel_fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ static int intelfb_dirty(struct drm_fb_helper *helper, struct drm_clip_rect *cli

static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
.fb_probe = intelfb_create,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0)
.fb_dirty = intelfb_dirty,
#endif
};

static void intel_fbdev_destroy(struct intel_fbdev *ifbdev)
Expand Down Expand Up @@ -551,10 +553,19 @@ int intel_fbdev_init(struct drm_device *dev)
return -ENOMEM;

mutex_init(&ifbdev->hpd_lock);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
drm_fb_helper_prepare(dev, &ifbdev->helper, 32, &intel_fb_helper_funcs);

if (intel_fbdev_init_bios(dev, ifbdev))
ifbdev->helper.preferred_bpp = ifbdev->preferred_bpp;
else
ifbdev->preferred_bpp = ifbdev->helper.preferred_bpp;
#else
drm_fb_helper_prepare(dev, &ifbdev->helper, &intel_fb_helper_funcs);

if (!intel_fbdev_init_bios(dev, ifbdev))
ifbdev->preferred_bpp = 32;
#endif

ret = drm_fb_helper_init(dev, &ifbdev->helper);
if (ret) {
Expand All @@ -573,8 +584,12 @@ static void intel_fbdev_initial_config(void *data, async_cookie_t cookie)
struct intel_fbdev *ifbdev = data;

/* Due to peculiar init order wrt to hpd handling this is separate. */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
if (drm_fb_helper_initial_config(&ifbdev->helper))
#else
if (drm_fb_helper_initial_config(&ifbdev->helper,
ifbdev->preferred_bpp))
#endif
intel_fbdev_unregister(to_i915(ifbdev->helper.dev));
}

Expand Down
11 changes: 11 additions & 0 deletions drivers/gpu/drm/i915/display/intel_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/string_helpers.h>
#include <linux/version.h>

#include <drm/display/drm_hdcp_helper.h>
#include <drm/display/drm_hdmi_helper.h>
Expand Down Expand Up @@ -2544,8 +2545,18 @@ intel_hdmi_force(struct drm_connector *connector)

static int intel_hdmi_get_modes(struct drm_connector *connector)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
/* drm_edid_connector_update() done in ->detect() or ->force() */
return drm_edid_connector_add_modes(connector);
#else
const struct edid *edid;

edid = drm_edid_raw(to_intel_connector(connector)->detect_edid);
if (edid == NULL)
return 0;

return intel_connector_update_modes(connector, edid);
#endif
}

static struct i2c_adapter *
Expand Down
15 changes: 15 additions & 0 deletions drivers/gpu/drm/i915/display/intel_lvds.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,14 @@ static int intel_lvds_get_modes(struct drm_connector *_connector)

/* Use panel fixed edid if we have one */
if (!IS_ERR_OR_NULL(fixed_edid)) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
drm_edid_connector_update(&connector->base, fixed_edid);

return drm_edid_connector_add_modes(&connector->base);
#else
struct edid *edid = drm_edid_raw(fixed_edid);
return drm_add_edid_modes(&connector->base, edid);
#endif
}

return intel_panel_get_modes(connector);
Expand Down Expand Up @@ -958,12 +963,22 @@ void intel_lvds_init(struct drm_i915_private *i915)
intel_gmbus_get_adapter(i915, pin));
}
if (drm_edid) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
if (drm_edid_connector_update(&connector->base, drm_edid) ||
!drm_edid_connector_add_modes(&connector->base)) {
drm_edid_connector_update(&connector->base, NULL);
drm_edid_free(drm_edid);
drm_edid = ERR_PTR(-EINVAL);
}
#else
const struct edid *edid = drm_edid_raw(drm_edid);
if (drm_add_edid_modes(&connector->base, edid)) {
drm_connector_update_edid_property(&connector->base, edid);
} else {
drm_edid_free(drm_edid);
drm_edid = ERR_PTR(-EINVAL);
}
#endif
} else {
drm_edid = ERR_PTR(-ENOENT);
}
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/display/intel_opregion.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/firmware.h>
#include <linux/version.h>
#include <acpi/video.h>

#include <drm/drm_edid.h>
Expand Down Expand Up @@ -1122,7 +1123,11 @@ const struct drm_edid *intel_opregion_get_edid(struct intel_connector *intel_con

drm_edid = drm_edid_alloc(edid, len);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0)
if (!drm_edid_valid(drm_edid)) {
#else
if (!drm_edid_is_valid(drm_edid_raw(drm_edid))) {
#endif
drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox #5)\n");
drm_edid_free(drm_edid);
drm_edid = NULL;
Expand Down
8 changes: 8 additions & 0 deletions drivers/gpu/drm/i915/display/intel_tv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1905,10 +1905,18 @@ static void intel_tv_add_properties(struct drm_connector *connector)

tv_format_names[i] = tv_modes[i].name;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
drm_mode_create_tv_properties_legacy(&i915->drm, i, tv_format_names);
#else
drm_mode_create_tv_properties(&i915->drm, i, tv_format_names);
#endif

drm_object_attach_property(&connector->base,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
i915->drm.mode_config.legacy_tv_mode_property,
#else
i915->drm.mode_config.tv_mode_property,
#endif
conn_state->tv.mode);
drm_object_attach_property(&connector->base,
i915->drm.mode_config.tv_left_margin_property,
Expand Down
8 changes: 8 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_mman.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,11 @@ int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma)
i915_gem_object_put(obj);
return -EINVAL;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
vm_flags_clear(vma, VM_MAYWRITE);
#else
vma->vm_flags &= ~VM_MAYWRITE;
#endif
}

anon = mmap_singleton(to_i915(dev));
Expand All @@ -993,7 +997,11 @@ int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma)
return PTR_ERR(anon);
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
vm_flags_set(vma, VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_IO);
#else
vma->vm_flags |= VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_IO;
#endif

/*
* We keep the ref on mmo->obj, not vm_file, but we require
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_object_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
#define __I915_GEM_OBJECT_TYPES_H__

#include <linux/mmu_notifier.h>
#include <linux/version.h>

#include <drm/drm_gem.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
#include <drm/ttm/ttm_bo.h>
#else
#include <drm/ttm/ttm_bo_api.h>
#endif
#include <uapi/drm/i915_drm.h>

#include "i915_active.h"
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_ttm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
#include <linux/shmem_fs.h>
#include <linux/version.h>

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
#include <drm/ttm/ttm_placement.h>
#include <drm/ttm/ttm_tt.h>
#else
#include <drm/ttm/ttm_bo_driver.h>
#include <drm/ttm/ttm_placement.h>
#endif
#include <drm/drm_buddy.h>

#include "i915_drv.h"
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
* Copyright © 2021 Intel Corporation
*/

#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
#include <drm/ttm/ttm_tt.h>
#else
#include <drm/ttm/ttm_bo_driver.h>
#endif

#include "i915_deps.h"
#include "i915_drv.h"
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/gt/intel_engine_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include "intel_ring.h"
#include "uc/intel_guc_submission.h"

#ifndef CONFIG_DRM_I915_PREEMPT_TIMEOUT_COMPUTE
#define CONFIG_DRM_I915_PREEMPT_TIMEOUT_COMPUTE 7500
#endif
/* Haswell does have the CXT_SIZE register however it does not appear to be
* valid. Now, docs explain in dwords what is in the context object. The full
* size is 70720 bytes, however, the power context and execlist context will
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/i915_deps.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@

#include <linux/dma-fence.h>
#include <linux/slab.h>
#include <linux/version.h>

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
#include <drm/ttm/ttm_bo.h>
#else
#include <drm/ttm/ttm_bo_api.h>
#endif

#include "i915_deps.h"

Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/pci.h>
#include <linux/dma-buf.h>
#include <linux/mman.h>
#include <linux/version.h>

#include <drm/drm_cache.h>
#include <drm/drm_vma_manager.h>
Expand Down Expand Up @@ -1109,7 +1110,11 @@ void i915_gem_drain_freed_objects(struct drm_i915_private *i915)
{
while (atomic_read(&i915->mm.free_count)) {
flush_work(&i915->mm.free_work);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
drain_workqueue(i915->bdev.wq);
#else
flush_delayed_work(&i915->bdev.wq);
#endif
rcu_barrier();
}
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/i915/i915_scatterlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
i915_refct_sgt_init(rsgt, size);
st = &rsgt->table;
/* restricted by sg_alloc_table */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0)
if (WARN_ON(overflows_type(PFN_UP(res->size), unsigned int))) {
#else
if (WARN_ON(overflows_type(res->num_pages, unsigned int))) {
#endif
i915_refct_sgt_put(rsgt);
return ERR_PTR(-E2BIG);
}
Expand Down
Loading

0 comments on commit 092d1cf

Please sign in to comment.