Skip to content

Instantly share code, notes, and snippets.

@Harry-Chen
Last active March 31, 2024 17:23
Show Gist options
  • Save Harry-Chen/c9259490cfd24e343354712d621f5cf2 to your computer and use it in GitHub Desktop.
Save Harry-Chen/c9259490cfd24e343354712d621f5cf2 to your computer and use it in GitHub Desktop.
Port i915 OOT module to Linux 6.6 (TrueNAS SCALE 24.04)

THIS PATCH IS NOT TESTED AND COMES WITH ABSOLUTE NO WARRANTY. USE AT YOUR OWN RISK!

You can use it to install OOT i915 module on Linux 6.6 (e.g. TrueNAS SCALE 24.04).

Most modifications are very dirty fixes to make it compiile.

The following change, especially, is to fix the interaction between KMD and UMD (Intel Media Driver). Otherwise the initialization procedure in userland library iHD_drv_video.so would encounter an error on an ioctl call here.

DISCLAIMER: This change might lead to problems such as GPU hangup, memory leak in kernel or at worst, kernel panic. I owe no responsibility in case of any incidents.

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index a79e764..286838a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -811,6 +811,9 @@ i915_gem_mmap_offset_ioctl(struct drm_device *dev, void *data,
 		type = I915_MMAP_TYPE_UC;
 		break;
 
+	case 4:
+		type = 0;
+		break;
 	default:
 		return -EINVAL;
 	}
diff --git a/Makefile.backport b/Makefile.backport
index 351c106..537ecb0 100644
--- a/Makefile.backport
+++ b/Makefile.backport
@@ -62,7 +62,7 @@ BUILD_CONFIG_VARIANT := CUSTOM_KERN_1 CUSTOM_KERN_3 sp2 nodrm $(MODULES_VARIANT)
BUILD_CONFIG_DISTRO = ""
RPM_DISTRIBUTIONS := RHEL_8.9 RHEL_8.8 RHEL_8.7 RHEL_8.6 RHEL_8.5 RHEL_8.4 CUSTOM_KERN_3 CUSTOM_KERN_1 VANILLA_5.10LTS VANILLA_5.4LTS SLES15_SP5 SLES15_SP4 RHEL_9.3 RHEL_9.2 RHEL_9.0 VANILLA_5.15LTS VANILLA_6.1LTS
-DEB_DISTRIBUTIONS := UBUNTU_OEM_22.04 UBUNTU_OEM_20.04 UBUNTU_22.04_SERVER VANILLA_5.15LTS VANILLA_6.1LTS UBUNTU_22.04_DESKTOP
+DEB_DISTRIBUTIONS := UBUNTU_OEM_22.04 UBUNTU_OEM_20.04 UBUNTU_22.04_SERVER VANILLA_5.15LTS VANILLA_6.1LTS UBUNTU_22.04_DESKTOP VANILLA_6.6LTS
RELEASE_TYPE ?= opensource
@@ -392,8 +392,8 @@ endif
else ifeq ($(shell expr $(BASE_KERN) \== $(call get_kernel_version,5,15)), 1)
OSV_NAME = VANILLA_5.15LTS
OSV_KV_SUPPORTED = $(shell cat versions | grep "$(OSV_NAME)_KERNEL_VERSION" | cut -d '"' -f 2)
-else ifeq ($(shell expr $(BASE_KERN) \== $(call get_kernel_version,6,1)), 1)
-OSV_NAME = VANILLA_6.1LTS
+else ifeq ($(shell expr $(BASE_KERN) \== $(call get_kernel_version,6,6)), 1)
+OSV_NAME = VANILLA_6.6LTS
OSV_KV_SUPPORTED = $(shell cat versions | grep "$(OSV_NAME)_KERNEL_VERSION" | cut -d '"' -f 2)
else ifneq ($(CUSTOM_KERN_ID), )
diff --git a/backport-include/net/genetlink.h b/backport-include/net/genetlink.h
index 51ad79b..86a99db 100644
--- a/backport-include/net/genetlink.h
+++ b/backport-include/net/genetlink.h
@@ -6,12 +6,12 @@
static inline void __bp_genl_info_userhdr_set(struct genl_info *info,
void *userhdr)
{
- info->userhdr = userhdr;
+ // info->userhdr = userhdr;
}
static inline void *__bp_genl_info_userhdr(struct genl_info *info)
{
- return info->userhdr;
+ return (genl_info_userhdr(info));
}
#if LINUX_VERSION_IS_LESS(4,12,0)
@@ -30,7 +30,7 @@ static inline struct netlink_ext_ack *genl_info_extack(struct genl_info *info)
#if LINUX_VERSION_IS_GEQ(4,12,0)
return info->extack;
#else
- return info->userhdr;
+ return (genl_info_userhdr(info));
#endif
}
@@ -45,10 +45,12 @@ static inline struct netlink_ext_ack *genl_callback_extack(struct netlink_callba
}
/* this gets put in place of info->userhdr, since we use that above */
-static inline void *genl_info_userhdr(struct genl_info *info)
+/*
+static inline void *genl_info_userhdr(const struct genl_info *info)
{
return (u8 *)info->genlhdr + GENL_HDRLEN;
}
+*/
/* this is for patches we apply */
#if LINUX_VERSION_IS_LESS(3,7,0)
diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
index 2597a42..1d709d7 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
@@ -85,8 +85,7 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder,
crtc_state->pipe_bpp = bpp;
crtc_state->pbn = drm_dp_calc_pbn_mode(adjusted_mode->crtc_clock,
- bpp,
- false);
+ bpp);
#ifdef BPM_DRM_DP_MST_PORT_VCPI_NOT_PRESENT
slots = drm_dp_atomic_find_time_slots(state, &intel_dp->mst_mgr,
@@ -163,8 +162,7 @@ static int intel_dp_dsc_mst_compute_link_config(struct intel_encoder *encoder,
min_bpp, max_bpp);
for (bpp = max_bpp; bpp >= min_bpp; bpp -= 2 * 3) {
crtc_state->pbn = drm_dp_calc_pbn_mode(adjusted_mode->crtc_clock,
- bpp << 4,
- true);
+ bpp << 4);
#ifdef BPM_DRM_DP_MST_PORT_VCPI_NOT_PRESENT
slots = drm_dp_atomic_find_time_slots(state, &intel_dp->mst_mgr,
@@ -910,7 +908,7 @@ intel_dp_mst_mode_valid_ctx(struct drm_connector *connector,
return ret;
if (mode_rate > max_rate || mode->clock > max_dotclk ||
- drm_dp_calc_pbn_mode(mode->clock, min_bpp, false) > port->full_pbn) {
+ drm_dp_calc_pbn_mode(mode->clock, min_bpp) > port->full_pbn) {
*status = MODE_CLOCK_HIGH;
return 0;
}
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_internal.c b/drivers/gpu/drm/i915/gem/i915_gem_internal.c
index 7d0cd33..f38fc28 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_internal.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_internal.c
@@ -46,7 +46,8 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)
max_order = MAX_ORDER;
#ifdef CONFIG_SWIOTLB
- if (is_swiotlb_active(obj->base.dev->dev)) {
+ // if (is_swiotlb_active(obj->base.dev->dev)) {
+ if (false) {
unsigned int max_segment;
max_segment = swiotlb_max_segment();
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index a79e764..286838a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -811,6 +811,9 @@ i915_gem_mmap_offset_ioctl(struct drm_device *dev, void *data,
type = I915_MMAP_TYPE_UC;
break;
+ case 4:
+ type = 0;
+ break;
default:
return -EINVAL;
}
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index d348ff6..c8bd783 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -870,7 +870,7 @@ static void i915_clear_pcie_errors(struct pci_dev *pdev)
if (!pdev || pdev->is_virtfn)
return;
- pci_disable_pcie_error_reporting(pdev);
+ // pci_disable_pcie_error_reporting(pdev);
i915_clear_errors_for_reg16(pdev, PCI_SEC_STATUS, PCI_SEC_ERR_MASK);
i915_clear_errors_for_reg16(pdev, pdev->pcie_cap + PCI_EXP_DEVSTA,
(u16)~0);
@@ -884,7 +884,7 @@ static void i915_clear_pcie_errors(struct pci_dev *pdev)
(u32)~0);
}
#endif
- pci_enable_pcie_error_reporting(pdev);
+ // pci_enable_pcie_error_reporting(pdev);
}
static int i915_driver_check_broken_features(struct drm_i915_private *dev_priv)
diff --git a/drivers/gpu/drm/i915/i915_sysrq.c b/drivers/gpu/drm/i915/i915_sysrq.c
index bb11bea..81bb2e6 100644
--- a/drivers/gpu/drm/i915/i915_sysrq.c
+++ b/drivers/gpu/drm/i915/i915_sysrq.c
@@ -35,7 +35,7 @@ struct sysrq_cb {
void *data;
};
-static void sysrq_handle_showgpu(int key)
+static void sysrq_handle_showgpu(u8 key)
{
struct sysrq_cb *cb;
diff --git a/versions b/versions
index b5474e2..d66ac17 100644
--- a/versions
+++ b/versions
@@ -14,3 +14,4 @@ RHEL_8.8_KERNEL_VERSION="4.18.0-477.13.1"
RHEL_8.6_KERNEL_VERSION="4.18.0-372.32.1"
VANILLA_5.10LTS_KERNEL_VERSION="5.10.209"
VANILLA_5.4LTS_KERNEL_VERSION="5.4.268"
+VANILLA_6.6LTS_KERNEL_VERSION="6.6.16"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment