fix({akmod,dkms}-ipu6): Update patches (#4412) (#4414)

(cherry picked from commit cc558f47d5)

Co-authored-by: Gilver <rockgrub@disroot.org>
This commit is contained in:
Raboneko
2025-04-24 06:28:09 -07:00
committed by GitHub
parent 1ada146606
commit 3c6464c26f
20 changed files with 4 additions and 2021 deletions
@@ -1,88 +0,0 @@
From c451aa3f50f8a5ef26d9a36f159c3f9fb8e6ef11 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 10 Jun 2024 13:05:53 +0200
Subject: [PATCH 1/9] Makefile: Switch sensor driver symbols from
CONFIG_VIDEO_FOO to CONFIG_ICAMERA_FOO
Switch the Kconfig symbols for sensor drivers from CONFIG_VIDEO_FOO to
CONFIG_ICAMERA_FOO to avoid these still being set when they should not
because of the CONFIG_VIDEO_FOO symbols inherited from the base kernel.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Makefile | 22 +++++++++++-----------
drivers/media/i2c/Makefile | 22 +++++++++++-----------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/Makefile b/Makefile
index 49b27300a..356f5e7f3 100644
--- a/Makefile
+++ b/Makefile
@@ -81,22 +81,22 @@ else
obj-y += drivers/media/pci/intel/ipu6/psys/
endif
-export CONFIG_VIDEO_HM11B1 = m
-export CONFIG_VIDEO_OV01A1S = m
-export CONFIG_VIDEO_OV01A10 = m
-export CONFIG_VIDEO_OV02C10 = m
-export CONFIG_VIDEO_OV02E10 = m
-export CONFIG_VIDEO_HM2170 = m
-export CONFIG_VIDEO_HM2172 = m
-export CONFIG_VIDEO_HI556 = m
+export CONFIG_ICAMERA_HM11B1 = m
+export CONFIG_ICAMERA_OV01A1S = m
+export CONFIG_ICAMERA_OV01A10 = m
+export CONFIG_ICAMERA_OV02C10 = m
+export CONFIG_ICAMERA_OV02E10 = m
+export CONFIG_ICAMERA_HM2170 = m
+export CONFIG_ICAMERA_HM2172 = m
+export CONFIG_ICAMERA_HI556 = m
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true)
-export CONFIG_VIDEO_OV2740 = m
-export CONFIG_VIDEO_GC5035 = m
+export CONFIG_ICAMERA_OV2740 = m
+export CONFIG_ICAMERA_GC5035 = m
endif
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV05C10)),false)
-export CONFIG_VIDEO_OV05C10 = m
+export CONFIG_ICAMERA_OV05C10 = m
endif
obj-y += drivers/media/i2c/
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index b4fa25598..2bcc878e7 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -1,15 +1,15 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2021 Intel Corporation.
-obj-$(CONFIG_VIDEO_HM11B1) += hm11b1.o
-obj-$(CONFIG_VIDEO_GC5035) += gc5035.o
-obj-$(CONFIG_VIDEO_OV01A1S) += ov01a1s.o
-obj-$(CONFIG_VIDEO_OV01A10) += ov01a10.o
-obj-$(CONFIG_VIDEO_OV02C10) += ov02c10.o
-obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o
-obj-$(CONFIG_VIDEO_OV05C10) += ov05c10.o
-obj-$(CONFIG_VIDEO_OV2740) += ov2740.o
-obj-$(CONFIG_VIDEO_HM2170) += hm2170.o
-obj-$(CONFIG_VIDEO_HM2170) += hm2172.o
-obj-$(CONFIG_VIDEO_HI556) += hi556.o
+obj-$(CONFIG_ICAMERA_HM11B1) += hm11b1.o
+obj-$(CONFIG_ICAMERA_GC5035) += gc5035.o
+obj-$(CONFIG_ICAMERA_OV01A1S) += ov01a1s.o
+obj-$(CONFIG_ICAMERA_OV01A10) += ov01a10.o
+obj-$(CONFIG_ICAMERA_OV02C10) += ov02c10.o
+obj-$(CONFIG_ICAMERA_OV02E10) += ov02e10.o
+obj-$(CONFIG_ICAMERA_OV05C10) += ov05c10.o
+obj-$(CONFIG_ICAMERA_OV2740) += ov2740.o
+obj-$(CONFIG_ICAMERA_HM2170) += hm2170.o
+obj-$(CONFIG_ICAMERA_HM2170) += hm2172.o
+obj-$(CONFIG_ICAMERA_HI556) += hi556.o
obj-$(CONFIG_POWER_CTRL_LOGIC) += power_ctrl_logic.o
--
2.48.1
@@ -1,97 +0,0 @@
From b839b8153bd364c22811496c1753145fa475bcc8 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 10 Jun 2024 13:41:16 +0200
Subject: [PATCH 2/9] Makefile: Re-enable gc5035 compilation with kernels >=
6.8
For some reason the gc5035 driver has been disabled for kernels >= 6.8,
but it is not upstream yet.
Fix compilation with kernel >= 6.8 and re-enable the driver.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Makefile | 2 +-
drivers/media/i2c/gc5035.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 356f5e7f3..58bc10aed 100644
--- a/Makefile
+++ b/Makefile
@@ -89,10 +89,10 @@ export CONFIG_ICAMERA_OV02E10 = m
export CONFIG_ICAMERA_HM2170 = m
export CONFIG_ICAMERA_HM2172 = m
export CONFIG_ICAMERA_HI556 = m
+export CONFIG_ICAMERA_GC5035 = m
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true)
export CONFIG_ICAMERA_OV2740 = m
-export CONFIG_ICAMERA_GC5035 = m
endif
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV05C10)),false)
diff --git a/drivers/media/i2c/gc5035.c b/drivers/media/i2c/gc5035.c
index 16bbd4845..e825dfa7d 100644
--- a/drivers/media/i2c/gc5035.c
+++ b/drivers/media/i2c/gc5035.c
@@ -1497,7 +1497,11 @@ static int gc5035_set_fmt(struct v4l2_subdev *sd,
mutex_lock(&gc5035->mutex);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
*v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format;
+#else
+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+#endif
} else {
gc5035->cur_mode = mode;
h_blank = mode->hts_def - mode->width;
@@ -1522,7 +1526,11 @@ static int gc5035_get_fmt(struct v4l2_subdev *sd,
mutex_lock(&gc5035->mutex);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
fmt->format = *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
+#else
+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad);
+#endif
} else {
fmt->format.width = mode->width;
fmt->format.height = mode->height;
@@ -1714,7 +1722,9 @@ static const struct v4l2_subdev_video_ops gc5035_video_ops = {
};
static const struct v4l2_subdev_pad_ops gc5035_pad_ops = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
.init_cfg = gc5035_entity_init_cfg,
+#endif
.enum_mbus_code = gc5035_enum_mbus_code,
.enum_frame_size = gc5035_enum_frame_sizes,
.get_fmt = gc5035_get_fmt,
@@ -1730,6 +1740,12 @@ static const struct media_entity_operations gc5035_subdev_entity_ops = {
.link_validate = v4l2_subdev_link_validate,
};
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
+static const struct v4l2_subdev_internal_ops gc5035_internal_ops = {
+ .init_state = gc5035_entity_init_cfg,
+};
+#endif
+
static int gc5035_set_exposure(struct gc5035 *gc5035, u32 val)
{
u32 caltime = 0;
@@ -2091,6 +2107,9 @@ static int gc5035_probe(struct i2c_client *client)
mutex_init(&gc5035->mutex);
sd = &gc5035->subdev;
v4l2_i2c_subdev_init(sd, client, &gc5035_subdev_ops);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
+ sd->internal_ops = &gc5035_internal_ops;
+#endif
ret = gc5035_initialize_controls(gc5035);
if (ret) {
dev_err_probe(dev, ret, "Failed to initialize controls\n");
--
2.48.1
@@ -1,54 +0,0 @@
From 580d73c387405534bdef7911e0616ad66953f7ce Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 13 Jan 2025 13:11:00 +0100
Subject: [PATCH 3/9] Makefile: Do not build hi556 driver with kernels >= 6.10
The mainline kernel hi556 driver has ACPI enumeration, GPIO and clk support
since kernel 6.10, so it can be used instead of the out of tree driver.
Add a new KV_HI556 variable and stop building the hi556 driver on
kernels >= 6.10.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 58bc10aed..472fdec22 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ KV_IVSC := 6.6.0
KV_IPU_BRIDGE := 6.6.0
KV_OV2740 := 6.8.0
KV_OV05C10 := 6.8.0
+KV_HI556 := 6.10
KV_IPU6_ISYS := 6.10.0
KERNEL_SRC ?= /lib/modules/$(KERNELRELEASE)/build
@@ -88,17 +89,21 @@ export CONFIG_ICAMERA_OV02C10 = m
export CONFIG_ICAMERA_OV02E10 = m
export CONFIG_ICAMERA_HM2170 = m
export CONFIG_ICAMERA_HM2172 = m
-export CONFIG_ICAMERA_HI556 = m
export CONFIG_ICAMERA_GC5035 = m
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true)
export CONFIG_ICAMERA_OV2740 = m
endif
+# Note OV05C10 check is reversed, it is not build on too old kernels
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV05C10)),false)
export CONFIG_ICAMERA_OV05C10 = m
endif
+ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_HI556)),true)
+export CONFIG_ICAMERA_HI556 = m
+endif
+
obj-y += drivers/media/i2c/
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_IVSC)),true)
--
2.48.1
@@ -1,51 +0,0 @@
From 14d41bf82770fcab65dcf3b2eec3f95b7a963aff Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 13 Jan 2025 13:15:15 +0100
Subject: [PATCH 4/9] Makefile: Do not build ov01a10 driver with kernels >= 6.8
Since commit 47a78052db51 ("media: ov01a10: Enable runtime PM before
registering async sub-device") the mainline ov01a10 driver is fully
usable and it can be used instead of the out of tree driver.
Add a new KV_OV01A10 variable and stop building the ov01a10 driver on
kernels >= 6.8.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Makefile | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 472fdec22..7ae3be835 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ version_lt = $(shell \
KV_IVSC := 6.6.0
KV_IPU_BRIDGE := 6.6.0
KV_OV2740 := 6.8.0
+KV_OV01A10 := 6.8.0
KV_OV05C10 := 6.8.0
KV_HI556 := 6.10
KV_IPU6_ISYS := 6.10.0
@@ -84,7 +85,6 @@ endif
export CONFIG_ICAMERA_HM11B1 = m
export CONFIG_ICAMERA_OV01A1S = m
-export CONFIG_ICAMERA_OV01A10 = m
export CONFIG_ICAMERA_OV02C10 = m
export CONFIG_ICAMERA_OV02E10 = m
export CONFIG_ICAMERA_HM2170 = m
@@ -95,6 +95,10 @@ ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true)
export CONFIG_ICAMERA_OV2740 = m
endif
+ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV01A10)),true)
+export CONFIG_ICAMERA_OV01A10 = m
+endif
+
# Note OV05C10 check is reversed, it is not build on too old kernels
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV05C10)),false)
export CONFIG_ICAMERA_OV05C10 = m
--
2.48.1
@@ -1,53 +0,0 @@
From a42273020f4a2e1c633dda6f30c512db56738b67 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 14 Jan 2025 23:08:04 +0100
Subject: [PATCH 6/9] media: ipu6: Fix building with kernel 6.13
Fix building with kernel 6.13.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/media/pci/intel/ipu6/psys/ipu-psys.c | 8 ++++++++
drivers/media/pci/intel/ipu6/psys/ipu6-psys.c | 4 ++++
2 files changed, 12 insertions(+)
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
index 00e394f20..36f99a3b8 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
@@ -2681,8 +2681,16 @@ MODULE_AUTHOR("Yunliang Ding <yunliang.ding@intel.com>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Intel ipu processing system driver");
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) || IS_ENABLED(CONFIG_DRM_I915_HAS_SRIOV)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
MODULE_IMPORT_NS(DMA_BUF);
+#else
+MODULE_IMPORT_NS("DMA_BUF");
+#endif
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
MODULE_IMPORT_NS(INTEL_IPU6);
+#else
+MODULE_IMPORT_NS("INTEL_IPU6");
+#endif
#endif
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
index 53c845ba3..0c3a5ca62 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
@@ -32,7 +32,11 @@
#include "ipu6-platform-buttress-regs.h"
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
MODULE_IMPORT_NS(DMA_BUF);
+#else
+MODULE_IMPORT_NS("DMA_BUF");
+#endif
static bool early_pg_transfer;
module_param(early_pg_transfer, bool, 0664);
--
2.48.1
@@ -1,49 +0,0 @@
From 32ce53b82bef51479d49d7d68794e2b801367dd6 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Thu, 30 Jan 2025 22:20:16 +0100
Subject: [PATCH 7/9] Modify 0001-v6.10-IPU6-headers-used-by-PSYS.patch for
v6.13
Modify 0001-v6.10-IPU6-headers-used-by-PSYS.patch so that it also works
with 6.13 kernels.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch b/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
index 00fb961d2..6a465a924 100644
--- a/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
+++ b/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
@@ -52,7 +52,7 @@ index 000000000..b26c6aee1
+
+struct ipu6_bus_device {
+ struct auxiliary_device auxdev;
-+ struct auxiliary_driver *auxdrv;
++ const struct auxiliary_driver *auxdrv;
+ const struct ipu6_auxdrv_data *auxdrv_data;
+ struct list_head list;
+ void *pdata;
@@ -92,7 +92,7 @@ new file mode 100644
index 000000000..9b6f56958
--- /dev/null
+++ b/drivers/media/pci/intel/ipu6/ipu6-buttress.h
-@@ -0,0 +1,92 @@
+@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2013--2024 Intel Corporation */
+
@@ -141,7 +141,9 @@ index 000000000..9b6f56958
+struct ipu6_buttress {
+ struct mutex power_mutex, auth_mutex, cons_mutex, ipc_mutex;
+ struct ipu6_buttress_ipc cse;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
+ struct ipu6_buttress_ipc ish;
++#endif
+ struct list_head constraints;
+ u32 wdt_cached_value;
+ bool force_suspend;
--
2.48.1
@@ -1,306 +0,0 @@
From a9236f549f28811a5af0c71ce6708d1f259d0e78 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Sat, 1 Feb 2025 08:04:35 +0100
Subject: [PATCH 8/9] ipu6-psys: Adjust DMA code for ipu6-bus DMA changes in
kernels >= 6.12
Upstream commit daabc5c64703 ("media: ipu6: not override the dma_ops of
device in driver") has changed the ipu6-bus code to no longer modify
the aux device's dma_ops, instead new ipu6_dma_*() helpers were introduced
modify the psys driver to use these new helpers.
This fixes the below DMA warning, which was followed by ipu6_psys_probe()
failing due to dma_alloc_attrs() failing:
Jan 31 11:59:59 x1 kernel: ------------[ cut here ]------------
Jan 31 11:59:59 x1 kernel: WARNING: CPU: 3 PID: 8595 at kernel/dma/mapping.c:597 dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: Modules linked in: intel_ipu6_psys(OE+) rfcomm snd_seq_dummy snd_hrtimer qrtr bnep binfmt_misc vfat fat snd_soc_skl_hda_dsp snd_soc_intel_sof_board_helpers snd_sof_probes snd_soc_intel_hda_dsp_common snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component snd_soc_dmic snd_sof_pci_intel_mtl snd_sof_intel_hda_generic soundwire_intel soundwire_cadence snd_sof_intel_hda_common snd_soc_hdac_hda iwlmvm snd_sof_intel_hda_mlink snd_sof_intel_hda snd_sof_pci snd_sof_xtensa_dsp snd_sof snd_sof_utils snd_hda_ext_core mac80211 snd_soc_acpi_intel_match soundwire_generic_allocation snd_soc_acpi intel_uncore_frequency soundwire_bus intel_uncore_frequency_common x86_pkg_temp_thermal snd_soc_core intel_ipu6_isys intel_powerclamp videobuf2_dma_sg coretemp snd_compress videobuf2_memops ac97_bus videobuf2_v4l2 snd_pcm_dmaengine videobuf2_common snd_hda_intel libarc4 snd_intel_dspcfg snd_intel_sdw_acpi kvm_intel snd_hda_codec spi_nor btusb iTCO_wdt btrtl mhi_wwan_mbim intel_pmc_bxt mhi_wwan_ctrl
Jan 31 11:59:59 x1 kernel: snd_hda_core mei_gsc_proxy gpio_usbio(OE) mei_wdt i2c_usbio(OE) mtd iTCO_vendor_support intel_rapl_msr btintel snd_hwdep kvm btbcm btmtk snd_seq snd_ctl_led hid_sensor_accel_3d hid_sensor_gyro_3d iwlwifi bluetooth snd_seq_device rapl processor_thermal_device_pci intel_cstate hid_sensor_trigger think_lmi processor_thermal_device hid_sensor_iio_common processor_thermal_wt_hint industrialio_triggered_buffer intel_uncore usbio(OE) firmware_attributes_class snd_pcm wmi_bmof mhi_pci_generic kfifo_buf processor_thermal_rfim i2c_i801 mei_me cfg80211 processor_thermal_rapl thinkpad_acpi spi_intel_pci mhi industrialio thunderbolt snd_timer spi_intel mei intel_ipu6 i2c_smbus intel_rapl_common idma64 platform_profile processor_thermal_wt_req ipu_bridge rfkill processor_thermal_power_floor snd igen6_edac processor_thermal_mbox int3403_thermal soundcore soc_button_array int340x_thermal_zone intel_pmc_core intel_skl_int3472_tps68470 ov08x40(OE) tps68470_regulator v4l2_fwnode clk_tps68470 intel_vsec v4l2_async
Jan 31 11:59:59 x1 kernel: pmt_telemetry intel_skl_int3472_discrete int3400_thermal intel_hid acpi_tad pmt_class intel_skl_int3472_common acpi_pad sparse_keymap joydev acpi_thermal_rel loop nfnetlink zram lz4hc_compress lz4_compress dm_crypt xe drm_ttm_helper gpu_sched drm_suballoc_helper drm_gpuvm drm_exec hid_sensor_hub intel_ishtp_hid i915 i2c_algo_bit drm_buddy nvme ttm nvme_core drm_display_helper intel_ish_ipc video ucsi_acpi crct10dif_pclmul hid_multitouch crc32_pclmul crc32c_intel polyval_clmulni polyval_generic ghash_clmulni_intel intel_vpu sha512_ssse3 sha256_ssse3 typec_ucsi sha1_ssse3 intel_ishtp cec typec nvme_auth i2c_hid_acpi i2c_hid wmi pinctrl_meteorlake serio_raw v4l2loopback(OE) videodev mc i2c_dev fuse
Jan 31 11:59:59 x1 kernel: CPU: 3 UID: 0 PID: 8595 Comm: modprobe Tainted: G OE 6.12.10-200.fc41.x86_64 #1
Jan 31 11:59:59 x1 kernel: Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
Jan 31 11:59:59 x1 kernel: Hardware name: LENOVO 21KCSIT080/21KCSIT080, BIOS N3YET72W (1.37 ) 10/03/2024
Jan 31 11:59:59 x1 kernel: RIP: 0010:dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: Code: 4c 89 e6 48 89 df e8 94 5d 9a 00 49 89 c7 e9 62 ff ff ff 0f 0b 45 31 ff 5b 5d 4c 89 f8 41 5c 41 5d 41 5e 41 5f c3 cc cc cc cc <0f> 0b e9 0d ff ff ff 45 31 ff e9 3e ff ff ff 66 0f 1f 44 00 00 90
Jan 31 11:59:59 x1 kernel: RSP: 0018:ffffaeefe452fbc8 EFLAGS: 00010246
Jan 31 11:59:59 x1 kernel: RAX: 0000000000000000 RBX: ffff936a8de60800 RCX: 0000000000000cc0
Jan 31 11:59:59 x1 kernel: RDX: ffff936af6c65018 RSI: 0000000000002000 RDI: ffff936a8de60800
Jan 31 11:59:59 x1 kernel: RBP: ffff936a8de60800 R08: 0000000000000000 R09: ffff936af6c65000
Jan 31 11:59:59 x1 kernel: R10: ffffaeefe452fc00 R11: ffff9371bf9a17c0 R12: 0000000000002000
Jan 31 11:59:59 x1 kernel: R13: ffff936af6c65018 R14: 0000000000000000 R15: ffff936a9d9be440
Jan 31 11:59:59 x1 kernel: FS: 00007f8ff258f740(0000) GS:ffff9371bf980000(0000) knlGS:0000000000000000
Jan 31 11:59:59 x1 kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Jan 31 11:59:59 x1 kernel: CR2: 00007f2e39eee67c CR3: 000000013b884003 CR4: 0000000000f72ef0
Jan 31 11:59:59 x1 kernel: DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
Jan 31 11:59:59 x1 kernel: DR3: 0000000000000000 DR6: 00000000ffff07f0 DR7: 0000000000000400
Jan 31 11:59:59 x1 kernel: PKRU: 55555554
Jan 31 11:59:59 x1 kernel: Call Trace:
Jan 31 11:59:59 x1 kernel: <TASK>
Jan 31 11:59:59 x1 kernel: ? dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: ? __warn.cold+0x93/0xfa
Jan 31 11:59:59 x1 kernel: ? dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: ? report_bug+0xff/0x140
Jan 31 11:59:59 x1 kernel: ? handle_bug+0x58/0x90
Jan 31 11:59:59 x1 kernel: ? exc_invalid_op+0x17/0x70
Jan 31 11:59:59 x1 kernel: ? asm_exc_invalid_op+0x1a/0x20
Jan 31 11:59:59 x1 kernel: ? dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: ipu6_psys_probe+0x37d/0x4b0 [intel_ipu6_psys]
Jan 31 11:59:59 x1 kernel: ? __pfx_ipu6_psys_probe+0x10/0x10 [intel_ipu6_psys]
Jan 31 11:59:59 x1 kernel: auxiliary_bus_probe+0x46/0x80
Jan 31 11:59:59 x1 kernel: ? driver_sysfs_add+0x57/0xc0
Jan 31 11:59:59 x1 kernel: really_probe+0xdb/0x340
Jan 31 11:59:59 x1 kernel: ? pm_runtime_barrier+0x54/0x90
Jan 31 11:59:59 x1 kernel: ? __pfx___driver_attach+0x10/0x10
Jan 31 11:59:59 x1 kernel: __driver_probe_device+0x78/0x110
Jan 31 11:59:59 x1 kernel: driver_probe_device+0x1f/0xa0
Jan 31 11:59:59 x1 kernel: __driver_attach+0xba/0x1c0
Jan 31 11:59:59 x1 kernel: bus_for_each_dev+0x8c/0xe0
Jan 31 11:59:59 x1 kernel: bus_add_driver+0x142/0x220
Jan 31 11:59:59 x1 kernel: driver_register+0x72/0xd0
Jan 31 11:59:59 x1 kernel: __auxiliary_driver_register+0x6e/0xd0
Jan 31 11:59:59 x1 kernel: ? __pfx_ipu6_psys_aux_driver_init+0x10/0x10 [intel_ipu6_psys]
Jan 31 11:59:59 x1 kernel: do_one_initcall+0x58/0x310
Jan 31 11:59:59 x1 kernel: do_init_module+0x90/0x260
Jan 31 11:59:59 x1 kernel: __do_sys_init_module+0x17a/0x1b0
Jan 31 11:59:59 x1 kernel: do_syscall_64+0x82/0x160
Jan 31 11:59:59 x1 kernel: ? exc_page_fault+0x7e/0x180
Jan 31 11:59:59 x1 kernel: entry_SYSCALL_64_after_hwframe+0x76/0x7e
Jan 31 11:59:59 x1 kernel: RIP: 0033:0x7f8ff1f0228e
Jan 31 11:59:59 x1 kernel: Code: 48 8b 0d 85 3b 0f 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 49 89 ca b8 af 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 52 3b 0f 00 f7 d8 64 89 01 48
Jan 31 11:59:59 x1 kernel: RSP: 002b:00007ffdfbde11e8 EFLAGS: 00000246 ORIG_RAX: 00000000000000af
Jan 31 11:59:59 x1 kernel: RAX: ffffffffffffffda RBX: 000055a0687e9240 RCX: 00007f8ff1f0228e
Jan 31 11:59:59 x1 kernel: RDX: 000055a05859a715 RSI: 0000000000041a65 RDI: 00007f8ff13a7010
Jan 31 11:59:59 x1 kernel: RBP: 00007ffdfbde12a0 R08: 000055a0687e8010 R09: 0000000000000007
Jan 31 11:59:59 x1 kernel: R10: 0000000000000001 R11: 0000000000000246 R12: 000055a05859a715
Jan 31 11:59:59 x1 kernel: R13: 0000000000040000 R14: 000055a0687e92e0 R15: 0000000000000000
Jan 31 11:59:59 x1 kernel: </TASK>
Jan 31 11:59:59 x1 kernel: ---[ end trace 0000000000000000 ]---
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/media/pci/intel/ipu6/psys/ipu-psys.c | 64 ++++++++++++++++++-
drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c | 6 +-
drivers/media/pci/intel/ipu6/psys/ipu6-psys.c | 22 +++++--
3 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
index 36f99a3b8..7c512e5ae 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
@@ -52,6 +52,7 @@
#include "ipu-psys.h"
#include "ipu6-platform-regs.h"
#include "ipu6-fw-com.h"
+#include "ipu6-dma.h"
#endif
static bool async_fw_init;
@@ -228,9 +229,12 @@ struct ipu_psys_pg *__get_pg_buf(struct ipu_psys *psys, size_t pg_size)
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
kpg->pg = dma_alloc_attrs(&psys->adev->dev, pg_size,
&kpg->pg_dma_addr, GFP_KERNEL, 0);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
kpg->pg = dma_alloc_attrs(dev, pg_size, &kpg->pg_dma_addr,
GFP_KERNEL, 0);
+#else
+ kpg->pg = ipu6_dma_alloc(to_ipu6_bus_device(dev), pg_size,
+ &kpg->pg_dma_addr, GFP_KERNEL, 0);
#endif
if (!kpg->pg) {
kfree(kpg);
@@ -597,6 +601,7 @@ static void ipu_dma_buf_detach(struct dma_buf *dbuf,
attach->priv = NULL;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
static struct sg_table *ipu_dma_buf_map(struct dma_buf_attachment *attach,
enum dma_data_direction dir)
{
@@ -658,6 +663,50 @@ static void ipu_dma_buf_unmap(struct dma_buf_attachment *attach,
#endif
}
+#else
+
+static struct sg_table *ipu_dma_buf_map(struct dma_buf_attachment *attach,
+ enum dma_data_direction dir)
+{
+ struct ipu_dma_buf_attach *ipu_attach = attach->priv;
+ struct ipu6_bus_device *adev = to_ipu6_bus_device(attach->dev);
+ struct pci_dev *pdev = adev->isp->pdev;
+ unsigned long attrs;
+ int ret;
+
+ attrs = DMA_ATTR_SKIP_CPU_SYNC;
+ ret = dma_map_sgtable(&pdev->dev, ipu_attach->sgt, dir, attrs);
+ if (ret) {
+ dev_dbg(attach->dev, "buf map failed\n");
+ return ERR_PTR(-EIO);
+ }
+
+ ret = ipu6_dma_map_sgtable(adev, ipu_attach->sgt, dir, attrs);
+ if (ret) {
+ dma_unmap_sgtable(&pdev->dev, ipu_attach->sgt, dir, attrs);
+ return ERR_PTR(-EIO);
+ }
+
+ /*
+ * Initial cache flush to avoid writing dirty pages for buffers which
+ * are later marked as IPU_BUFFER_FLAG_NO_FLUSH.
+ */
+ ipu6_dma_sync_sgtable(adev, ipu_attach->sgt);
+
+ return ipu_attach->sgt;
+}
+
+static void ipu_dma_buf_unmap(struct dma_buf_attachment *attach,
+ struct sg_table *sgt, enum dma_data_direction dir)
+{
+ struct ipu6_bus_device *adev = to_ipu6_bus_device(attach->dev);
+ struct pci_dev *pdev = adev->isp->pdev;
+
+ ipu6_dma_unmap_sgtable(adev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);
+ dma_unmap_sgtable(&pdev->dev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);
+}
+#endif
+
static int ipu_dma_buf_mmap(struct dma_buf *dbuf, struct vm_area_struct *vma)
{
return -ENOTTY;
@@ -2371,7 +2420,12 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
kpg = kzalloc(sizeof(*kpg), GFP_KERNEL);
if (!kpg)
goto out_free_pgs;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
kpg->pg = dma_alloc_attrs(dev, IPU_PSYS_PG_MAX_SIZE,
+#else
+ kpg->pg = ipu6_dma_alloc(adev, IPU_PSYS_PG_MAX_SIZE,
+#endif
&kpg->pg_dma_addr,
GFP_KERNEL, 0);
if (!kpg->pg) {
@@ -2426,7 +2480,11 @@ out_release_fw_com:
ipu6_fw_com_release(psys->fwcom, 1);
out_free_pgs:
list_for_each_entry_safe(kpg, kpg0, &psys->pgs, list) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_free_attrs(dev, kpg->size, kpg->pg, kpg->pg_dma_addr, 0);
+#else
+ ipu6_dma_free(adev, kpg->size, kpg->pg, kpg->pg_dma_addr, 0);
+#endif
kfree(kpg);
}
@@ -2484,8 +2542,10 @@ static void ipu6_psys_remove(struct auxiliary_device *auxdev)
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
dma_free_attrs(&adev->dev, kpg->size, kpg->pg,
kpg->pg_dma_addr, 0);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_free_attrs(dev, kpg->size, kpg->pg, kpg->pg_dma_addr, 0);
+#else
+ ipu6_dma_free(psys->adev, kpg->size, kpg->pg, kpg->pg_dma_addr, 0);
#endif
kfree(kpg);
}
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c b/drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c
index 9038f69cd..5e6fb9a1b 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c
@@ -8,6 +8,7 @@
#include <asm/cacheflush.h>
#include "ipu6-ppg.h"
+#include "ipu6-dma.h"
static bool enable_suspend_resume;
module_param(enable_suspend_resume, bool, 0664);
@@ -75,9 +76,12 @@ __get_buf_set(struct ipu_psys_fh *fh, size_t buf_set_size)
kbuf_set->kaddr = dma_alloc_attrs(&fh->psys->adev->dev,
buf_set_size, &kbuf_set->dma_addr,
GFP_KERNEL, 0);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
kbuf_set->kaddr = dma_alloc_attrs(dev, buf_set_size,
&kbuf_set->dma_addr, GFP_KERNEL, 0);
+#else
+ kbuf_set->kaddr = ipu6_dma_alloc(to_ipu6_bus_device(dev), buf_set_size,
+ &kbuf_set->dma_addr, GFP_KERNEL, 0);
#endif
if (!kbuf_set->kaddr) {
kfree(kbuf_set);
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
index 0c3a5ca62..58662ea16 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
@@ -30,6 +30,7 @@
#include "ipu6-ppg.h"
#include "ipu6-platform-regs.h"
#include "ipu6-platform-buttress-regs.h"
+#include "ipu6-dma.h"
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
@@ -450,10 +451,12 @@ static struct ipu_psys_kcmd *ipu_psys_copy_cmd(struct ipu_psys_command *cmd,
kcmd->kbufs[i]->sgt->sgl,
kcmd->kbufs[i]->sgt->orig_nents,
DMA_BIDIRECTIONAL);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_sync_sg_for_device(dev, kcmd->kbufs[i]->sgt->sgl,
kcmd->kbufs[i]->sgt->orig_nents,
DMA_BIDIRECTIONAL);
+#else
+ ipu6_dma_sync_sgtable(psys->adev, kcmd->kbufs[i]->sgt);
#endif
}
@@ -1102,11 +1105,16 @@ int ipu_psys_fh_init(struct ipu_psys_fh *fh)
&kbuf_set->dma_addr,
GFP_KERNEL,
0);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
kbuf_set->kaddr = dma_alloc_attrs(dev,
IPU_PSYS_BUF_SET_MAX_SIZE,
&kbuf_set->dma_addr,
GFP_KERNEL, 0);
+#else
+ kbuf_set->kaddr = ipu6_dma_alloc(to_ipu6_bus_device(dev),
+ IPU_PSYS_BUF_SET_MAX_SIZE,
+ &kbuf_set->dma_addr,
+ GFP_KERNEL, 0);
#endif
if (!kbuf_set->kaddr) {
kfree(kbuf_set);
@@ -1124,8 +1132,11 @@ out_free_buf_sets:
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
dma_free_attrs(&psys->adev->dev,
kbuf_set->size, kbuf_set->kaddr,
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_free_attrs(dev, kbuf_set->size, kbuf_set->kaddr,
+#else
+ ipu6_dma_free(to_ipu6_bus_device(dev),
+ kbuf_set->size, kbuf_set->kaddr,
#endif
kbuf_set->dma_addr, 0);
list_del(&kbuf_set->list);
@@ -1229,8 +1240,11 @@ int ipu_psys_fh_deinit(struct ipu_psys_fh *fh)
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
dma_free_attrs(&psys->adev->dev,
kbuf_set->size, kbuf_set->kaddr,
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_free_attrs(dev, kbuf_set->size, kbuf_set->kaddr,
+#else
+ ipu6_dma_free(to_ipu6_bus_device(dev),
+ kbuf_set->size, kbuf_set->kaddr,
#endif
kbuf_set->dma_addr, 0);
list_del(&kbuf_set->list);
--
2.48.1
@@ -1,84 +0,0 @@
From 47a2e1cf89b789bbc10d3cb3b26b357404633114 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Sat, 1 Feb 2025 08:19:22 +0100
Subject: [PATCH 9/9] Add ipu6-dma.h to
0001-v6.10-IPU6-headers-used-by-PSYS.patch
Add ipu6-dma.h to 0001-v6.10-IPU6-headers-used-by-PSYS.patch,
this is necessary for the DMA code adjustments in the psys code
which were done for the ipu6-bus DMA changes in kernels >= 6.12.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
...0001-v6.10-IPU6-headers-used-by-PSYS.patch | 55 +++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch b/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
index 6a465a924..b8eeaae66 100644
--- a/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
+++ b/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
@@ -1195,6 +1195,61 @@ index 000000000..92e3c3414
+ int pkg_dir_idx, void __iomem *base, u64 *pkg_dir,
+ dma_addr_t pkg_dir_dma_addr);
+#endif /* IPU6_H */
+diff --git a/drivers/media/pci/intel/ipu6/ipu6-dma.h b/drivers/media/pci/intel/ipu6/ipu6-dma.h
+new file mode 100644
+index 000000000..b51244add
+--- /dev/null
++++ b/drivers/media/pci/intel/ipu6/ipu6-dma.h
+@@ -0,0 +1,49 @@
++/* SPDX-License-Identifier: GPL-2.0-only */
++/* Copyright (C) 2013--2024 Intel Corporation */
++
++#ifndef IPU6_DMA_H
++#define IPU6_DMA_H
++
++#include <linux/dma-map-ops.h>
++#include <linux/dma-mapping.h>
++#include <linux/iova.h>
++#include <linux/iova.h>
++#include <linux/scatterlist.h>
++#include <linux/types.h>
++
++#include "ipu6-bus.h"
++
++struct ipu6_mmu_info;
++
++struct ipu6_dma_mapping {
++ struct ipu6_mmu_info *mmu_info;
++ struct iova_domain iovad;
++};
++
++void ipu6_dma_sync_single(struct ipu6_bus_device *sys, dma_addr_t dma_handle,
++ size_t size);
++void ipu6_dma_sync_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist,
++ int nents);
++void ipu6_dma_sync_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt);
++void *ipu6_dma_alloc(struct ipu6_bus_device *sys, size_t size,
++ dma_addr_t *dma_handle, gfp_t gfp,
++ unsigned long attrs);
++void ipu6_dma_free(struct ipu6_bus_device *sys, size_t size, void *vaddr,
++ dma_addr_t dma_handle, unsigned long attrs);
++int ipu6_dma_mmap(struct ipu6_bus_device *sys, struct vm_area_struct *vma,
++ void *addr, dma_addr_t iova, size_t size,
++ unsigned long attrs);
++int ipu6_dma_map_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist,
++ int nents, enum dma_data_direction dir,
++ unsigned long attrs);
++void ipu6_dma_unmap_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist,
++ int nents, enum dma_data_direction dir,
++ unsigned long attrs);
++int ipu6_dma_map_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
++ enum dma_data_direction dir, unsigned long attrs);
++void ipu6_dma_unmap_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
++ enum dma_data_direction dir, unsigned long attrs);
++int ipu6_dma_get_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
++ void *cpu_addr, dma_addr_t handle, size_t size,
++ unsigned long attrs);
++#endif /* IPU6_DMA_H */
--
2.43.0
--
2.48.1
@@ -1,202 +0,0 @@
From c1cb2a62cd9d949fda60f5993a72ec0c44f52719 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 5 Feb 2025 13:20:21 +0100
Subject: [PATCH 10/11] psys: Do not skipping registering ipu_psys_bus for
kernels >= 6.10
The new auxbus code-paths were not registering the ipu_psys_bus used for
psys->dev.bus = &ipu_psys_bus, this was causing udev to not be able to
properly enumerate the device. For example running:
udevadm test -a add /dev/ipu-psys0
would fail with the following error:
"Failed to clone sd_device object: No such file or directory"
This udev issue in turn was causing issues with udev rules to set
permissions on /dev/ipu-psys0 not working
Fix this by:
1. Rename ipu6_psys_bus to ipu_psys_bus, there is no need for separate
names for this struct with different kernels and having the same name
allows code sharing.
2. Switching back from using module_auxiliary_driver() to using
module_init() / module_exit() codes for registering the drivers.
3. Move the now always used ipu_psys_init() and ipu_psys_exit()
out of any ifdefs blocks, so that these functions now always
(un)register the chrdev region and the ipu_psys_bus.
4. Remove the now duplicate chrdev region handling from the auxbus
ipu6_psys_probe() and ipu6_psys_remove() functions (now handled
by ipu_psys_init() and ipu_psys_exit()).
Signed-off-by: Hans de Goede
---
drivers/media/pci/intel/ipu6/psys/ipu-psys.c | 94 +++++++++-----------
1 file changed, 40 insertions(+), 54 deletions(-)
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
index 7c512e5ae..c06cd515a 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
@@ -92,7 +92,7 @@ static struct bus_type ipu_psys_bus = {
.name = IPU_PSYS_NAME,
};
#else
-static const struct bus_type ipu6_psys_bus = {
+static const struct bus_type ipu_psys_bus = {
.name = "intel-ipu6-psys",
};
#endif
@@ -2331,17 +2331,9 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
ipu_ver = adev->isp->hw_ver;
- rval = alloc_chrdev_region(&ipu_psys_dev_t, 0,
- IPU_PSYS_NUM_DEVICES, IPU6_PSYS_NAME);
- if (rval) {
- dev_err(dev, "can't alloc psys chrdev region (%d)\n",
- rval);
- return rval;
- }
-
rval = ipu6_mmu_hw_init(adev->mmu);
if (rval)
- goto out_unregister_chr_region;
+ return rval;
mutex_lock(&ipu_psys_mutex);
@@ -2453,7 +2445,7 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
goto out_free_pgs;
}
- psys->dev.bus = &ipu6_psys_bus;
+ psys->dev.bus = &ipu_psys_bus;
psys->dev.parent = dev;
psys->dev.devt = MKDEV(MAJOR(ipu_psys_dev_t), minor);
psys->dev.release = ipu_psys_dev_release;
@@ -2500,10 +2492,6 @@ out_unlock:
/* Safe to call even if the init is not called */
mutex_unlock(&ipu_psys_mutex);
ipu6_mmu_hw_cleanup(adev->mmu);
-
-out_unregister_chr_region:
- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
-
return rval;
}
#endif
@@ -2521,9 +2509,6 @@ static void ipu6_psys_remove(struct auxiliary_device *auxdev)
#endif
struct ipu_psys_pg *kpg, *kpg0;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0)
- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
-#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
#ifdef CONFIG_DEBUG_FS
if (isp->ipu_dir)
@@ -2658,38 +2643,6 @@ static struct ipu_bus_driver ipu_psys_driver = {
},
};
-static int __init ipu_psys_init(void)
-{
- int rval = alloc_chrdev_region(&ipu_psys_dev_t, 0,
- IPU_PSYS_NUM_DEVICES, IPU_PSYS_NAME);
- if (rval) {
- pr_err("can't alloc psys chrdev region (%d)\n", rval);
- return rval;
- }
-
- rval = bus_register(&ipu_psys_bus);
- if (rval) {
- pr_warn("can't register psys bus (%d)\n", rval);
- goto out_bus_register;
- }
-
- ipu_bus_register_driver(&ipu_psys_driver);
-
- return rval;
-
-out_bus_register:
- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
-
- return rval;
-}
-
-static void __exit ipu_psys_exit(void)
-{
- ipu_bus_unregister_driver(&ipu_psys_driver);
- bus_unregister(&ipu_psys_bus);
- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
-}
-
static const struct pci_device_id ipu_pci_tbl[] = {
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, IPU6_PCI_ID)},
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, IPU6SE_PCI_ID)},
@@ -2700,9 +2653,6 @@ static const struct pci_device_id ipu_pci_tbl[] = {
{0,}
};
MODULE_DEVICE_TABLE(pci, ipu_pci_tbl);
-
-module_init(ipu_psys_init);
-module_exit(ipu_psys_exit);
#else
static const struct ipu6_auxdrv_data ipu6_psys_auxdrv_data = {
.isr_threaded = psys_isr_threaded,
@@ -2727,9 +2677,45 @@ static struct auxiliary_driver ipu6_psys_aux_driver = {
.pm = &psys_pm_ops,
},
};
-module_auxiliary_driver(ipu6_psys_aux_driver);
#endif
+static int __init ipu_psys_init(void)
+{
+ int rval = alloc_chrdev_region(&ipu_psys_dev_t, 0,
+ IPU_PSYS_NUM_DEVICES, ipu_psys_bus.name);
+ if (rval) {
+ pr_err("can't alloc psys chrdev region (%d)\n", rval);
+ return rval;
+ }
+
+ rval = bus_register(&ipu_psys_bus);
+ if (rval) {
+ pr_err("can't register psys bus (%d)\n", rval);
+ unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
+ return rval;
+ }
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
+ ipu_bus_register_driver(&ipu_psys_driver);
+#else
+ auxiliary_driver_register(&ipu6_psys_aux_driver);
+#endif
+ return 0;
+}
+module_init(ipu_psys_init);
+
+static void __exit ipu_psys_exit(void)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
+ ipu_bus_unregister_driver(&ipu_psys_driver);
+#else
+ auxiliary_driver_unregister(&ipu6_psys_aux_driver);
+#endif
+ bus_unregister(&ipu_psys_bus);
+ unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
+}
+module_exit(ipu_psys_exit);
+
MODULE_AUTHOR("Antti Laakso <antti.laakso@intel.com>");
MODULE_AUTHOR("Bin Han <bin.b.han@intel.com>");
MODULE_AUTHOR("Renwei Wu <renwei.wu@intel.com>");
--
2.48.1
@@ -21,22 +21,8 @@ URL: https://github.com/intel/ipu6-drivers
Source0: https://github.com/intel/ipu6-drivers/archive/%{ipu6_commit}/ipu6-drivers-%{ipu6_shortcommit}.tar.gz
Source1: https://github.com/intel/usbio-drivers/archive/%{usbio_commit}/usbio-drivers-%{usbio_shortcommit}.tar.gz
# Patches
# https://github.com/intel/ipu6-drivers/pull/322
Patch1: 0001-Makefile-Switch-sensor-driver-symbols-from-CONFIG_VI.patch
Patch2: 0002-Makefile-Re-enable-gc5035-compilation-with-kernels-6.patch
Patch3: 0003-Makefile-Do-not-build-hi556-driver-with-kernels-6.10.patch
Patch4: 0004-Makefile-Do-not-build-ov01a10-driver-with-kernels-6..patch
# https://github.com/intel/ipu6-drivers/pull/321
Patch5: 0005-media-ipu6-Fix-out-of-tree-builds.patch
Patch6: 0006-media-ipu6-Fix-building-with-kernel-6.13.patch
Patch7: 0007-Modify-0001-v6.10-IPU6-headers-used-by-PSYS.patch-fo.patch
# https://github.com/intel/ipu6-drivers/pull/324
Patch8: 0008-ipu6-psys-Adjust-DMA-code-for-ipu6-bus-DMA-changes-i.patch
Patch9: 0009-Add-ipu6-dma.h-to-0001-v6.10-IPU6-headers-used-by-PS.patch
# https://github.com/intel/ipu6-drivers/pull/327
Patch10: 0010-psys-Do-not-skipping-registering-ipu_psys_bus-for-ke.patch
Patch11: 0011-psys-Use-cdev_device_add-for-dev-ipu-psys0.patch
# https://github.com/intel/usbio-drivers/pull/33
Patch0: 0005-media-ipu6-Fix-out-of-tree-builds.patch
Patch20: 0010-usbio-Fix-GPIO-and-I2C-driver-modaliases.patch
# https://github.com/intel/usbio-drivers/pull/34
Patch21: 0011-usbio-Fix-I2C-max-transfer-size.patch
@@ -67,17 +53,7 @@ kmodtool --target %{_target_cpu} --repo terra --kmodname %{modulename} %{?build
%setup -q -c -a 1
(cd ipu6-drivers-%{ipu6_commit}
%patch 1 -p1
%patch 2 -p1
%patch 3 -p1
%patch 4 -p1
%patch 5 -p1
%patch 6 -p1
%patch 7 -p1
%patch 8 -p1
%patch 9 -p1
%patch 10 -p1
%patch 11 -p1
%patch 0 -p1
%patch 101 -p1
patch -p1 < patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
)
@@ -1,88 +0,0 @@
From c451aa3f50f8a5ef26d9a36f159c3f9fb8e6ef11 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 10 Jun 2024 13:05:53 +0200
Subject: [PATCH 1/9] Makefile: Switch sensor driver symbols from
CONFIG_VIDEO_FOO to CONFIG_ICAMERA_FOO
Switch the Kconfig symbols for sensor drivers from CONFIG_VIDEO_FOO to
CONFIG_ICAMERA_FOO to avoid these still being set when they should not
because of the CONFIG_VIDEO_FOO symbols inherited from the base kernel.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Makefile | 22 +++++++++++-----------
drivers/media/i2c/Makefile | 22 +++++++++++-----------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/Makefile b/Makefile
index 49b27300a..356f5e7f3 100644
--- a/Makefile
+++ b/Makefile
@@ -81,22 +81,22 @@ else
obj-y += drivers/media/pci/intel/ipu6/psys/
endif
-export CONFIG_VIDEO_HM11B1 = m
-export CONFIG_VIDEO_OV01A1S = m
-export CONFIG_VIDEO_OV01A10 = m
-export CONFIG_VIDEO_OV02C10 = m
-export CONFIG_VIDEO_OV02E10 = m
-export CONFIG_VIDEO_HM2170 = m
-export CONFIG_VIDEO_HM2172 = m
-export CONFIG_VIDEO_HI556 = m
+export CONFIG_ICAMERA_HM11B1 = m
+export CONFIG_ICAMERA_OV01A1S = m
+export CONFIG_ICAMERA_OV01A10 = m
+export CONFIG_ICAMERA_OV02C10 = m
+export CONFIG_ICAMERA_OV02E10 = m
+export CONFIG_ICAMERA_HM2170 = m
+export CONFIG_ICAMERA_HM2172 = m
+export CONFIG_ICAMERA_HI556 = m
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true)
-export CONFIG_VIDEO_OV2740 = m
-export CONFIG_VIDEO_GC5035 = m
+export CONFIG_ICAMERA_OV2740 = m
+export CONFIG_ICAMERA_GC5035 = m
endif
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV05C10)),false)
-export CONFIG_VIDEO_OV05C10 = m
+export CONFIG_ICAMERA_OV05C10 = m
endif
obj-y += drivers/media/i2c/
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index b4fa25598..2bcc878e7 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -1,15 +1,15 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2021 Intel Corporation.
-obj-$(CONFIG_VIDEO_HM11B1) += hm11b1.o
-obj-$(CONFIG_VIDEO_GC5035) += gc5035.o
-obj-$(CONFIG_VIDEO_OV01A1S) += ov01a1s.o
-obj-$(CONFIG_VIDEO_OV01A10) += ov01a10.o
-obj-$(CONFIG_VIDEO_OV02C10) += ov02c10.o
-obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o
-obj-$(CONFIG_VIDEO_OV05C10) += ov05c10.o
-obj-$(CONFIG_VIDEO_OV2740) += ov2740.o
-obj-$(CONFIG_VIDEO_HM2170) += hm2170.o
-obj-$(CONFIG_VIDEO_HM2170) += hm2172.o
-obj-$(CONFIG_VIDEO_HI556) += hi556.o
+obj-$(CONFIG_ICAMERA_HM11B1) += hm11b1.o
+obj-$(CONFIG_ICAMERA_GC5035) += gc5035.o
+obj-$(CONFIG_ICAMERA_OV01A1S) += ov01a1s.o
+obj-$(CONFIG_ICAMERA_OV01A10) += ov01a10.o
+obj-$(CONFIG_ICAMERA_OV02C10) += ov02c10.o
+obj-$(CONFIG_ICAMERA_OV02E10) += ov02e10.o
+obj-$(CONFIG_ICAMERA_OV05C10) += ov05c10.o
+obj-$(CONFIG_ICAMERA_OV2740) += ov2740.o
+obj-$(CONFIG_ICAMERA_HM2170) += hm2170.o
+obj-$(CONFIG_ICAMERA_HM2170) += hm2172.o
+obj-$(CONFIG_ICAMERA_HI556) += hi556.o
obj-$(CONFIG_POWER_CTRL_LOGIC) += power_ctrl_logic.o
--
2.48.1
@@ -1,97 +0,0 @@
From b839b8153bd364c22811496c1753145fa475bcc8 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 10 Jun 2024 13:41:16 +0200
Subject: [PATCH 2/9] Makefile: Re-enable gc5035 compilation with kernels >=
6.8
For some reason the gc5035 driver has been disabled for kernels >= 6.8,
but it is not upstream yet.
Fix compilation with kernel >= 6.8 and re-enable the driver.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Makefile | 2 +-
drivers/media/i2c/gc5035.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 356f5e7f3..58bc10aed 100644
--- a/Makefile
+++ b/Makefile
@@ -89,10 +89,10 @@ export CONFIG_ICAMERA_OV02E10 = m
export CONFIG_ICAMERA_HM2170 = m
export CONFIG_ICAMERA_HM2172 = m
export CONFIG_ICAMERA_HI556 = m
+export CONFIG_ICAMERA_GC5035 = m
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true)
export CONFIG_ICAMERA_OV2740 = m
-export CONFIG_ICAMERA_GC5035 = m
endif
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV05C10)),false)
diff --git a/drivers/media/i2c/gc5035.c b/drivers/media/i2c/gc5035.c
index 16bbd4845..e825dfa7d 100644
--- a/drivers/media/i2c/gc5035.c
+++ b/drivers/media/i2c/gc5035.c
@@ -1497,7 +1497,11 @@ static int gc5035_set_fmt(struct v4l2_subdev *sd,
mutex_lock(&gc5035->mutex);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
*v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format;
+#else
+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+#endif
} else {
gc5035->cur_mode = mode;
h_blank = mode->hts_def - mode->width;
@@ -1522,7 +1526,11 @@ static int gc5035_get_fmt(struct v4l2_subdev *sd,
mutex_lock(&gc5035->mutex);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
fmt->format = *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
+#else
+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad);
+#endif
} else {
fmt->format.width = mode->width;
fmt->format.height = mode->height;
@@ -1714,7 +1722,9 @@ static const struct v4l2_subdev_video_ops gc5035_video_ops = {
};
static const struct v4l2_subdev_pad_ops gc5035_pad_ops = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
.init_cfg = gc5035_entity_init_cfg,
+#endif
.enum_mbus_code = gc5035_enum_mbus_code,
.enum_frame_size = gc5035_enum_frame_sizes,
.get_fmt = gc5035_get_fmt,
@@ -1730,6 +1740,12 @@ static const struct media_entity_operations gc5035_subdev_entity_ops = {
.link_validate = v4l2_subdev_link_validate,
};
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
+static const struct v4l2_subdev_internal_ops gc5035_internal_ops = {
+ .init_state = gc5035_entity_init_cfg,
+};
+#endif
+
static int gc5035_set_exposure(struct gc5035 *gc5035, u32 val)
{
u32 caltime = 0;
@@ -2091,6 +2107,9 @@ static int gc5035_probe(struct i2c_client *client)
mutex_init(&gc5035->mutex);
sd = &gc5035->subdev;
v4l2_i2c_subdev_init(sd, client, &gc5035_subdev_ops);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
+ sd->internal_ops = &gc5035_internal_ops;
+#endif
ret = gc5035_initialize_controls(gc5035);
if (ret) {
dev_err_probe(dev, ret, "Failed to initialize controls\n");
--
2.48.1
@@ -1,54 +0,0 @@
From 580d73c387405534bdef7911e0616ad66953f7ce Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 13 Jan 2025 13:11:00 +0100
Subject: [PATCH 3/9] Makefile: Do not build hi556 driver with kernels >= 6.10
The mainline kernel hi556 driver has ACPI enumeration, GPIO and clk support
since kernel 6.10, so it can be used instead of the out of tree driver.
Add a new KV_HI556 variable and stop building the hi556 driver on
kernels >= 6.10.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 58bc10aed..472fdec22 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ KV_IVSC := 6.6.0
KV_IPU_BRIDGE := 6.6.0
KV_OV2740 := 6.8.0
KV_OV05C10 := 6.8.0
+KV_HI556 := 6.10
KV_IPU6_ISYS := 6.10.0
KERNEL_SRC ?= /lib/modules/$(KERNELRELEASE)/build
@@ -88,17 +89,21 @@ export CONFIG_ICAMERA_OV02C10 = m
export CONFIG_ICAMERA_OV02E10 = m
export CONFIG_ICAMERA_HM2170 = m
export CONFIG_ICAMERA_HM2172 = m
-export CONFIG_ICAMERA_HI556 = m
export CONFIG_ICAMERA_GC5035 = m
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true)
export CONFIG_ICAMERA_OV2740 = m
endif
+# Note OV05C10 check is reversed, it is not build on too old kernels
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV05C10)),false)
export CONFIG_ICAMERA_OV05C10 = m
endif
+ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_HI556)),true)
+export CONFIG_ICAMERA_HI556 = m
+endif
+
obj-y += drivers/media/i2c/
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_IVSC)),true)
--
2.48.1
@@ -1,51 +0,0 @@
From 14d41bf82770fcab65dcf3b2eec3f95b7a963aff Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 13 Jan 2025 13:15:15 +0100
Subject: [PATCH 4/9] Makefile: Do not build ov01a10 driver with kernels >= 6.8
Since commit 47a78052db51 ("media: ov01a10: Enable runtime PM before
registering async sub-device") the mainline ov01a10 driver is fully
usable and it can be used instead of the out of tree driver.
Add a new KV_OV01A10 variable and stop building the ov01a10 driver on
kernels >= 6.8.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Makefile | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 472fdec22..7ae3be835 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ version_lt = $(shell \
KV_IVSC := 6.6.0
KV_IPU_BRIDGE := 6.6.0
KV_OV2740 := 6.8.0
+KV_OV01A10 := 6.8.0
KV_OV05C10 := 6.8.0
KV_HI556 := 6.10
KV_IPU6_ISYS := 6.10.0
@@ -84,7 +85,6 @@ endif
export CONFIG_ICAMERA_HM11B1 = m
export CONFIG_ICAMERA_OV01A1S = m
-export CONFIG_ICAMERA_OV01A10 = m
export CONFIG_ICAMERA_OV02C10 = m
export CONFIG_ICAMERA_OV02E10 = m
export CONFIG_ICAMERA_HM2170 = m
@@ -95,6 +95,10 @@ ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true)
export CONFIG_ICAMERA_OV2740 = m
endif
+ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV01A10)),true)
+export CONFIG_ICAMERA_OV01A10 = m
+endif
+
# Note OV05C10 check is reversed, it is not build on too old kernels
ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV05C10)),false)
export CONFIG_ICAMERA_OV05C10 = m
--
2.48.1
@@ -1,53 +0,0 @@
From a42273020f4a2e1c633dda6f30c512db56738b67 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 14 Jan 2025 23:08:04 +0100
Subject: [PATCH 6/9] media: ipu6: Fix building with kernel 6.13
Fix building with kernel 6.13.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/media/pci/intel/ipu6/psys/ipu-psys.c | 8 ++++++++
drivers/media/pci/intel/ipu6/psys/ipu6-psys.c | 4 ++++
2 files changed, 12 insertions(+)
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
index 00e394f20..36f99a3b8 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
@@ -2681,8 +2681,16 @@ MODULE_AUTHOR("Yunliang Ding <yunliang.ding@intel.com>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Intel ipu processing system driver");
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) || IS_ENABLED(CONFIG_DRM_I915_HAS_SRIOV)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
MODULE_IMPORT_NS(DMA_BUF);
+#else
+MODULE_IMPORT_NS("DMA_BUF");
+#endif
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
MODULE_IMPORT_NS(INTEL_IPU6);
+#else
+MODULE_IMPORT_NS("INTEL_IPU6");
+#endif
#endif
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
index 53c845ba3..0c3a5ca62 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
@@ -32,7 +32,11 @@
#include "ipu6-platform-buttress-regs.h"
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
MODULE_IMPORT_NS(DMA_BUF);
+#else
+MODULE_IMPORT_NS("DMA_BUF");
+#endif
static bool early_pg_transfer;
module_param(early_pg_transfer, bool, 0664);
--
2.48.1
@@ -1,49 +0,0 @@
From 32ce53b82bef51479d49d7d68794e2b801367dd6 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Thu, 30 Jan 2025 22:20:16 +0100
Subject: [PATCH 7/9] Modify 0001-v6.10-IPU6-headers-used-by-PSYS.patch for
v6.13
Modify 0001-v6.10-IPU6-headers-used-by-PSYS.patch so that it also works
with 6.13 kernels.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch b/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
index 00fb961d2..6a465a924 100644
--- a/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
+++ b/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
@@ -52,7 +52,7 @@ index 000000000..b26c6aee1
+
+struct ipu6_bus_device {
+ struct auxiliary_device auxdev;
-+ struct auxiliary_driver *auxdrv;
++ const struct auxiliary_driver *auxdrv;
+ const struct ipu6_auxdrv_data *auxdrv_data;
+ struct list_head list;
+ void *pdata;
@@ -92,7 +92,7 @@ new file mode 100644
index 000000000..9b6f56958
--- /dev/null
+++ b/drivers/media/pci/intel/ipu6/ipu6-buttress.h
-@@ -0,0 +1,92 @@
+@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2013--2024 Intel Corporation */
+
@@ -141,7 +141,9 @@ index 000000000..9b6f56958
+struct ipu6_buttress {
+ struct mutex power_mutex, auth_mutex, cons_mutex, ipc_mutex;
+ struct ipu6_buttress_ipc cse;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
+ struct ipu6_buttress_ipc ish;
++#endif
+ struct list_head constraints;
+ u32 wdt_cached_value;
+ bool force_suspend;
--
2.48.1
@@ -1,306 +0,0 @@
From a9236f549f28811a5af0c71ce6708d1f259d0e78 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Sat, 1 Feb 2025 08:04:35 +0100
Subject: [PATCH 8/9] ipu6-psys: Adjust DMA code for ipu6-bus DMA changes in
kernels >= 6.12
Upstream commit daabc5c64703 ("media: ipu6: not override the dma_ops of
device in driver") has changed the ipu6-bus code to no longer modify
the aux device's dma_ops, instead new ipu6_dma_*() helpers were introduced
modify the psys driver to use these new helpers.
This fixes the below DMA warning, which was followed by ipu6_psys_probe()
failing due to dma_alloc_attrs() failing:
Jan 31 11:59:59 x1 kernel: ------------[ cut here ]------------
Jan 31 11:59:59 x1 kernel: WARNING: CPU: 3 PID: 8595 at kernel/dma/mapping.c:597 dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: Modules linked in: intel_ipu6_psys(OE+) rfcomm snd_seq_dummy snd_hrtimer qrtr bnep binfmt_misc vfat fat snd_soc_skl_hda_dsp snd_soc_intel_sof_board_helpers snd_sof_probes snd_soc_intel_hda_dsp_common snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component snd_soc_dmic snd_sof_pci_intel_mtl snd_sof_intel_hda_generic soundwire_intel soundwire_cadence snd_sof_intel_hda_common snd_soc_hdac_hda iwlmvm snd_sof_intel_hda_mlink snd_sof_intel_hda snd_sof_pci snd_sof_xtensa_dsp snd_sof snd_sof_utils snd_hda_ext_core mac80211 snd_soc_acpi_intel_match soundwire_generic_allocation snd_soc_acpi intel_uncore_frequency soundwire_bus intel_uncore_frequency_common x86_pkg_temp_thermal snd_soc_core intel_ipu6_isys intel_powerclamp videobuf2_dma_sg coretemp snd_compress videobuf2_memops ac97_bus videobuf2_v4l2 snd_pcm_dmaengine videobuf2_common snd_hda_intel libarc4 snd_intel_dspcfg snd_intel_sdw_acpi kvm_intel snd_hda_codec spi_nor btusb iTCO_wdt btrtl mhi_wwan_mbim intel_pmc_bxt mhi_wwan_ctrl
Jan 31 11:59:59 x1 kernel: snd_hda_core mei_gsc_proxy gpio_usbio(OE) mei_wdt i2c_usbio(OE) mtd iTCO_vendor_support intel_rapl_msr btintel snd_hwdep kvm btbcm btmtk snd_seq snd_ctl_led hid_sensor_accel_3d hid_sensor_gyro_3d iwlwifi bluetooth snd_seq_device rapl processor_thermal_device_pci intel_cstate hid_sensor_trigger think_lmi processor_thermal_device hid_sensor_iio_common processor_thermal_wt_hint industrialio_triggered_buffer intel_uncore usbio(OE) firmware_attributes_class snd_pcm wmi_bmof mhi_pci_generic kfifo_buf processor_thermal_rfim i2c_i801 mei_me cfg80211 processor_thermal_rapl thinkpad_acpi spi_intel_pci mhi industrialio thunderbolt snd_timer spi_intel mei intel_ipu6 i2c_smbus intel_rapl_common idma64 platform_profile processor_thermal_wt_req ipu_bridge rfkill processor_thermal_power_floor snd igen6_edac processor_thermal_mbox int3403_thermal soundcore soc_button_array int340x_thermal_zone intel_pmc_core intel_skl_int3472_tps68470 ov08x40(OE) tps68470_regulator v4l2_fwnode clk_tps68470 intel_vsec v4l2_async
Jan 31 11:59:59 x1 kernel: pmt_telemetry intel_skl_int3472_discrete int3400_thermal intel_hid acpi_tad pmt_class intel_skl_int3472_common acpi_pad sparse_keymap joydev acpi_thermal_rel loop nfnetlink zram lz4hc_compress lz4_compress dm_crypt xe drm_ttm_helper gpu_sched drm_suballoc_helper drm_gpuvm drm_exec hid_sensor_hub intel_ishtp_hid i915 i2c_algo_bit drm_buddy nvme ttm nvme_core drm_display_helper intel_ish_ipc video ucsi_acpi crct10dif_pclmul hid_multitouch crc32_pclmul crc32c_intel polyval_clmulni polyval_generic ghash_clmulni_intel intel_vpu sha512_ssse3 sha256_ssse3 typec_ucsi sha1_ssse3 intel_ishtp cec typec nvme_auth i2c_hid_acpi i2c_hid wmi pinctrl_meteorlake serio_raw v4l2loopback(OE) videodev mc i2c_dev fuse
Jan 31 11:59:59 x1 kernel: CPU: 3 UID: 0 PID: 8595 Comm: modprobe Tainted: G OE 6.12.10-200.fc41.x86_64 #1
Jan 31 11:59:59 x1 kernel: Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
Jan 31 11:59:59 x1 kernel: Hardware name: LENOVO 21KCSIT080/21KCSIT080, BIOS N3YET72W (1.37 ) 10/03/2024
Jan 31 11:59:59 x1 kernel: RIP: 0010:dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: Code: 4c 89 e6 48 89 df e8 94 5d 9a 00 49 89 c7 e9 62 ff ff ff 0f 0b 45 31 ff 5b 5d 4c 89 f8 41 5c 41 5d 41 5e 41 5f c3 cc cc cc cc <0f> 0b e9 0d ff ff ff 45 31 ff e9 3e ff ff ff 66 0f 1f 44 00 00 90
Jan 31 11:59:59 x1 kernel: RSP: 0018:ffffaeefe452fbc8 EFLAGS: 00010246
Jan 31 11:59:59 x1 kernel: RAX: 0000000000000000 RBX: ffff936a8de60800 RCX: 0000000000000cc0
Jan 31 11:59:59 x1 kernel: RDX: ffff936af6c65018 RSI: 0000000000002000 RDI: ffff936a8de60800
Jan 31 11:59:59 x1 kernel: RBP: ffff936a8de60800 R08: 0000000000000000 R09: ffff936af6c65000
Jan 31 11:59:59 x1 kernel: R10: ffffaeefe452fc00 R11: ffff9371bf9a17c0 R12: 0000000000002000
Jan 31 11:59:59 x1 kernel: R13: ffff936af6c65018 R14: 0000000000000000 R15: ffff936a9d9be440
Jan 31 11:59:59 x1 kernel: FS: 00007f8ff258f740(0000) GS:ffff9371bf980000(0000) knlGS:0000000000000000
Jan 31 11:59:59 x1 kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Jan 31 11:59:59 x1 kernel: CR2: 00007f2e39eee67c CR3: 000000013b884003 CR4: 0000000000f72ef0
Jan 31 11:59:59 x1 kernel: DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
Jan 31 11:59:59 x1 kernel: DR3: 0000000000000000 DR6: 00000000ffff07f0 DR7: 0000000000000400
Jan 31 11:59:59 x1 kernel: PKRU: 55555554
Jan 31 11:59:59 x1 kernel: Call Trace:
Jan 31 11:59:59 x1 kernel: <TASK>
Jan 31 11:59:59 x1 kernel: ? dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: ? __warn.cold+0x93/0xfa
Jan 31 11:59:59 x1 kernel: ? dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: ? report_bug+0xff/0x140
Jan 31 11:59:59 x1 kernel: ? handle_bug+0x58/0x90
Jan 31 11:59:59 x1 kernel: ? exc_invalid_op+0x17/0x70
Jan 31 11:59:59 x1 kernel: ? asm_exc_invalid_op+0x1a/0x20
Jan 31 11:59:59 x1 kernel: ? dma_alloc_attrs+0x12b/0x140
Jan 31 11:59:59 x1 kernel: ipu6_psys_probe+0x37d/0x4b0 [intel_ipu6_psys]
Jan 31 11:59:59 x1 kernel: ? __pfx_ipu6_psys_probe+0x10/0x10 [intel_ipu6_psys]
Jan 31 11:59:59 x1 kernel: auxiliary_bus_probe+0x46/0x80
Jan 31 11:59:59 x1 kernel: ? driver_sysfs_add+0x57/0xc0
Jan 31 11:59:59 x1 kernel: really_probe+0xdb/0x340
Jan 31 11:59:59 x1 kernel: ? pm_runtime_barrier+0x54/0x90
Jan 31 11:59:59 x1 kernel: ? __pfx___driver_attach+0x10/0x10
Jan 31 11:59:59 x1 kernel: __driver_probe_device+0x78/0x110
Jan 31 11:59:59 x1 kernel: driver_probe_device+0x1f/0xa0
Jan 31 11:59:59 x1 kernel: __driver_attach+0xba/0x1c0
Jan 31 11:59:59 x1 kernel: bus_for_each_dev+0x8c/0xe0
Jan 31 11:59:59 x1 kernel: bus_add_driver+0x142/0x220
Jan 31 11:59:59 x1 kernel: driver_register+0x72/0xd0
Jan 31 11:59:59 x1 kernel: __auxiliary_driver_register+0x6e/0xd0
Jan 31 11:59:59 x1 kernel: ? __pfx_ipu6_psys_aux_driver_init+0x10/0x10 [intel_ipu6_psys]
Jan 31 11:59:59 x1 kernel: do_one_initcall+0x58/0x310
Jan 31 11:59:59 x1 kernel: do_init_module+0x90/0x260
Jan 31 11:59:59 x1 kernel: __do_sys_init_module+0x17a/0x1b0
Jan 31 11:59:59 x1 kernel: do_syscall_64+0x82/0x160
Jan 31 11:59:59 x1 kernel: ? exc_page_fault+0x7e/0x180
Jan 31 11:59:59 x1 kernel: entry_SYSCALL_64_after_hwframe+0x76/0x7e
Jan 31 11:59:59 x1 kernel: RIP: 0033:0x7f8ff1f0228e
Jan 31 11:59:59 x1 kernel: Code: 48 8b 0d 85 3b 0f 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 49 89 ca b8 af 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 52 3b 0f 00 f7 d8 64 89 01 48
Jan 31 11:59:59 x1 kernel: RSP: 002b:00007ffdfbde11e8 EFLAGS: 00000246 ORIG_RAX: 00000000000000af
Jan 31 11:59:59 x1 kernel: RAX: ffffffffffffffda RBX: 000055a0687e9240 RCX: 00007f8ff1f0228e
Jan 31 11:59:59 x1 kernel: RDX: 000055a05859a715 RSI: 0000000000041a65 RDI: 00007f8ff13a7010
Jan 31 11:59:59 x1 kernel: RBP: 00007ffdfbde12a0 R08: 000055a0687e8010 R09: 0000000000000007
Jan 31 11:59:59 x1 kernel: R10: 0000000000000001 R11: 0000000000000246 R12: 000055a05859a715
Jan 31 11:59:59 x1 kernel: R13: 0000000000040000 R14: 000055a0687e92e0 R15: 0000000000000000
Jan 31 11:59:59 x1 kernel: </TASK>
Jan 31 11:59:59 x1 kernel: ---[ end trace 0000000000000000 ]---
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/media/pci/intel/ipu6/psys/ipu-psys.c | 64 ++++++++++++++++++-
drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c | 6 +-
drivers/media/pci/intel/ipu6/psys/ipu6-psys.c | 22 +++++--
3 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
index 36f99a3b8..7c512e5ae 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
@@ -52,6 +52,7 @@
#include "ipu-psys.h"
#include "ipu6-platform-regs.h"
#include "ipu6-fw-com.h"
+#include "ipu6-dma.h"
#endif
static bool async_fw_init;
@@ -228,9 +229,12 @@ struct ipu_psys_pg *__get_pg_buf(struct ipu_psys *psys, size_t pg_size)
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
kpg->pg = dma_alloc_attrs(&psys->adev->dev, pg_size,
&kpg->pg_dma_addr, GFP_KERNEL, 0);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
kpg->pg = dma_alloc_attrs(dev, pg_size, &kpg->pg_dma_addr,
GFP_KERNEL, 0);
+#else
+ kpg->pg = ipu6_dma_alloc(to_ipu6_bus_device(dev), pg_size,
+ &kpg->pg_dma_addr, GFP_KERNEL, 0);
#endif
if (!kpg->pg) {
kfree(kpg);
@@ -597,6 +601,7 @@ static void ipu_dma_buf_detach(struct dma_buf *dbuf,
attach->priv = NULL;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
static struct sg_table *ipu_dma_buf_map(struct dma_buf_attachment *attach,
enum dma_data_direction dir)
{
@@ -658,6 +663,50 @@ static void ipu_dma_buf_unmap(struct dma_buf_attachment *attach,
#endif
}
+#else
+
+static struct sg_table *ipu_dma_buf_map(struct dma_buf_attachment *attach,
+ enum dma_data_direction dir)
+{
+ struct ipu_dma_buf_attach *ipu_attach = attach->priv;
+ struct ipu6_bus_device *adev = to_ipu6_bus_device(attach->dev);
+ struct pci_dev *pdev = adev->isp->pdev;
+ unsigned long attrs;
+ int ret;
+
+ attrs = DMA_ATTR_SKIP_CPU_SYNC;
+ ret = dma_map_sgtable(&pdev->dev, ipu_attach->sgt, dir, attrs);
+ if (ret) {
+ dev_dbg(attach->dev, "buf map failed\n");
+ return ERR_PTR(-EIO);
+ }
+
+ ret = ipu6_dma_map_sgtable(adev, ipu_attach->sgt, dir, attrs);
+ if (ret) {
+ dma_unmap_sgtable(&pdev->dev, ipu_attach->sgt, dir, attrs);
+ return ERR_PTR(-EIO);
+ }
+
+ /*
+ * Initial cache flush to avoid writing dirty pages for buffers which
+ * are later marked as IPU_BUFFER_FLAG_NO_FLUSH.
+ */
+ ipu6_dma_sync_sgtable(adev, ipu_attach->sgt);
+
+ return ipu_attach->sgt;
+}
+
+static void ipu_dma_buf_unmap(struct dma_buf_attachment *attach,
+ struct sg_table *sgt, enum dma_data_direction dir)
+{
+ struct ipu6_bus_device *adev = to_ipu6_bus_device(attach->dev);
+ struct pci_dev *pdev = adev->isp->pdev;
+
+ ipu6_dma_unmap_sgtable(adev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);
+ dma_unmap_sgtable(&pdev->dev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);
+}
+#endif
+
static int ipu_dma_buf_mmap(struct dma_buf *dbuf, struct vm_area_struct *vma)
{
return -ENOTTY;
@@ -2371,7 +2420,12 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
kpg = kzalloc(sizeof(*kpg), GFP_KERNEL);
if (!kpg)
goto out_free_pgs;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
kpg->pg = dma_alloc_attrs(dev, IPU_PSYS_PG_MAX_SIZE,
+#else
+ kpg->pg = ipu6_dma_alloc(adev, IPU_PSYS_PG_MAX_SIZE,
+#endif
&kpg->pg_dma_addr,
GFP_KERNEL, 0);
if (!kpg->pg) {
@@ -2426,7 +2480,11 @@ out_release_fw_com:
ipu6_fw_com_release(psys->fwcom, 1);
out_free_pgs:
list_for_each_entry_safe(kpg, kpg0, &psys->pgs, list) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_free_attrs(dev, kpg->size, kpg->pg, kpg->pg_dma_addr, 0);
+#else
+ ipu6_dma_free(adev, kpg->size, kpg->pg, kpg->pg_dma_addr, 0);
+#endif
kfree(kpg);
}
@@ -2484,8 +2542,10 @@ static void ipu6_psys_remove(struct auxiliary_device *auxdev)
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
dma_free_attrs(&adev->dev, kpg->size, kpg->pg,
kpg->pg_dma_addr, 0);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_free_attrs(dev, kpg->size, kpg->pg, kpg->pg_dma_addr, 0);
+#else
+ ipu6_dma_free(psys->adev, kpg->size, kpg->pg, kpg->pg_dma_addr, 0);
#endif
kfree(kpg);
}
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c b/drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c
index 9038f69cd..5e6fb9a1b 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu6-ppg.c
@@ -8,6 +8,7 @@
#include <asm/cacheflush.h>
#include "ipu6-ppg.h"
+#include "ipu6-dma.h"
static bool enable_suspend_resume;
module_param(enable_suspend_resume, bool, 0664);
@@ -75,9 +76,12 @@ __get_buf_set(struct ipu_psys_fh *fh, size_t buf_set_size)
kbuf_set->kaddr = dma_alloc_attrs(&fh->psys->adev->dev,
buf_set_size, &kbuf_set->dma_addr,
GFP_KERNEL, 0);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
kbuf_set->kaddr = dma_alloc_attrs(dev, buf_set_size,
&kbuf_set->dma_addr, GFP_KERNEL, 0);
+#else
+ kbuf_set->kaddr = ipu6_dma_alloc(to_ipu6_bus_device(dev), buf_set_size,
+ &kbuf_set->dma_addr, GFP_KERNEL, 0);
#endif
if (!kbuf_set->kaddr) {
kfree(kbuf_set);
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
index 0c3a5ca62..58662ea16 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu6-psys.c
@@ -30,6 +30,7 @@
#include "ipu6-ppg.h"
#include "ipu6-platform-regs.h"
#include "ipu6-platform-buttress-regs.h"
+#include "ipu6-dma.h"
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
@@ -450,10 +451,12 @@ static struct ipu_psys_kcmd *ipu_psys_copy_cmd(struct ipu_psys_command *cmd,
kcmd->kbufs[i]->sgt->sgl,
kcmd->kbufs[i]->sgt->orig_nents,
DMA_BIDIRECTIONAL);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_sync_sg_for_device(dev, kcmd->kbufs[i]->sgt->sgl,
kcmd->kbufs[i]->sgt->orig_nents,
DMA_BIDIRECTIONAL);
+#else
+ ipu6_dma_sync_sgtable(psys->adev, kcmd->kbufs[i]->sgt);
#endif
}
@@ -1102,11 +1105,16 @@ int ipu_psys_fh_init(struct ipu_psys_fh *fh)
&kbuf_set->dma_addr,
GFP_KERNEL,
0);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
kbuf_set->kaddr = dma_alloc_attrs(dev,
IPU_PSYS_BUF_SET_MAX_SIZE,
&kbuf_set->dma_addr,
GFP_KERNEL, 0);
+#else
+ kbuf_set->kaddr = ipu6_dma_alloc(to_ipu6_bus_device(dev),
+ IPU_PSYS_BUF_SET_MAX_SIZE,
+ &kbuf_set->dma_addr,
+ GFP_KERNEL, 0);
#endif
if (!kbuf_set->kaddr) {
kfree(kbuf_set);
@@ -1124,8 +1132,11 @@ out_free_buf_sets:
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
dma_free_attrs(&psys->adev->dev,
kbuf_set->size, kbuf_set->kaddr,
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_free_attrs(dev, kbuf_set->size, kbuf_set->kaddr,
+#else
+ ipu6_dma_free(to_ipu6_bus_device(dev),
+ kbuf_set->size, kbuf_set->kaddr,
#endif
kbuf_set->dma_addr, 0);
list_del(&kbuf_set->list);
@@ -1229,8 +1240,11 @@ int ipu_psys_fh_deinit(struct ipu_psys_fh *fh)
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
dma_free_attrs(&psys->adev->dev,
kbuf_set->size, kbuf_set->kaddr,
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
dma_free_attrs(dev, kbuf_set->size, kbuf_set->kaddr,
+#else
+ ipu6_dma_free(to_ipu6_bus_device(dev),
+ kbuf_set->size, kbuf_set->kaddr,
#endif
kbuf_set->dma_addr, 0);
list_del(&kbuf_set->list);
--
2.48.1
@@ -1,84 +0,0 @@
From 47a2e1cf89b789bbc10d3cb3b26b357404633114 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Sat, 1 Feb 2025 08:19:22 +0100
Subject: [PATCH 9/9] Add ipu6-dma.h to
0001-v6.10-IPU6-headers-used-by-PSYS.patch
Add ipu6-dma.h to 0001-v6.10-IPU6-headers-used-by-PSYS.patch,
this is necessary for the DMA code adjustments in the psys code
which were done for the ipu6-bus DMA changes in kernels >= 6.12.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
...0001-v6.10-IPU6-headers-used-by-PSYS.patch | 55 +++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch b/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
index 6a465a924..b8eeaae66 100644
--- a/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
+++ b/patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
@@ -1195,6 +1195,61 @@ index 000000000..92e3c3414
+ int pkg_dir_idx, void __iomem *base, u64 *pkg_dir,
+ dma_addr_t pkg_dir_dma_addr);
+#endif /* IPU6_H */
+diff --git a/drivers/media/pci/intel/ipu6/ipu6-dma.h b/drivers/media/pci/intel/ipu6/ipu6-dma.h
+new file mode 100644
+index 000000000..b51244add
+--- /dev/null
++++ b/drivers/media/pci/intel/ipu6/ipu6-dma.h
+@@ -0,0 +1,49 @@
++/* SPDX-License-Identifier: GPL-2.0-only */
++/* Copyright (C) 2013--2024 Intel Corporation */
++
++#ifndef IPU6_DMA_H
++#define IPU6_DMA_H
++
++#include <linux/dma-map-ops.h>
++#include <linux/dma-mapping.h>
++#include <linux/iova.h>
++#include <linux/iova.h>
++#include <linux/scatterlist.h>
++#include <linux/types.h>
++
++#include "ipu6-bus.h"
++
++struct ipu6_mmu_info;
++
++struct ipu6_dma_mapping {
++ struct ipu6_mmu_info *mmu_info;
++ struct iova_domain iovad;
++};
++
++void ipu6_dma_sync_single(struct ipu6_bus_device *sys, dma_addr_t dma_handle,
++ size_t size);
++void ipu6_dma_sync_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist,
++ int nents);
++void ipu6_dma_sync_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt);
++void *ipu6_dma_alloc(struct ipu6_bus_device *sys, size_t size,
++ dma_addr_t *dma_handle, gfp_t gfp,
++ unsigned long attrs);
++void ipu6_dma_free(struct ipu6_bus_device *sys, size_t size, void *vaddr,
++ dma_addr_t dma_handle, unsigned long attrs);
++int ipu6_dma_mmap(struct ipu6_bus_device *sys, struct vm_area_struct *vma,
++ void *addr, dma_addr_t iova, size_t size,
++ unsigned long attrs);
++int ipu6_dma_map_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist,
++ int nents, enum dma_data_direction dir,
++ unsigned long attrs);
++void ipu6_dma_unmap_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist,
++ int nents, enum dma_data_direction dir,
++ unsigned long attrs);
++int ipu6_dma_map_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
++ enum dma_data_direction dir, unsigned long attrs);
++void ipu6_dma_unmap_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
++ enum dma_data_direction dir, unsigned long attrs);
++int ipu6_dma_get_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
++ void *cpu_addr, dma_addr_t handle, size_t size,
++ unsigned long attrs);
++#endif /* IPU6_DMA_H */
--
2.43.0
--
2.48.1
@@ -1,202 +0,0 @@
From c1cb2a62cd9d949fda60f5993a72ec0c44f52719 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 5 Feb 2025 13:20:21 +0100
Subject: [PATCH 10/11] psys: Do not skipping registering ipu_psys_bus for
kernels >= 6.10
The new auxbus code-paths were not registering the ipu_psys_bus used for
psys->dev.bus = &ipu_psys_bus, this was causing udev to not be able to
properly enumerate the device. For example running:
udevadm test -a add /dev/ipu-psys0
would fail with the following error:
"Failed to clone sd_device object: No such file or directory"
This udev issue in turn was causing issues with udev rules to set
permissions on /dev/ipu-psys0 not working
Fix this by:
1. Rename ipu6_psys_bus to ipu_psys_bus, there is no need for separate
names for this struct with different kernels and having the same name
allows code sharing.
2. Switching back from using module_auxiliary_driver() to using
module_init() / module_exit() codes for registering the drivers.
3. Move the now always used ipu_psys_init() and ipu_psys_exit()
out of any ifdefs blocks, so that these functions now always
(un)register the chrdev region and the ipu_psys_bus.
4. Remove the now duplicate chrdev region handling from the auxbus
ipu6_psys_probe() and ipu6_psys_remove() functions (now handled
by ipu_psys_init() and ipu_psys_exit()).
Signed-off-by: Hans de Goede
---
drivers/media/pci/intel/ipu6/psys/ipu-psys.c | 94 +++++++++-----------
1 file changed, 40 insertions(+), 54 deletions(-)
diff --git a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
index 7c512e5ae..c06cd515a 100644
--- a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+++ b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
@@ -92,7 +92,7 @@ static struct bus_type ipu_psys_bus = {
.name = IPU_PSYS_NAME,
};
#else
-static const struct bus_type ipu6_psys_bus = {
+static const struct bus_type ipu_psys_bus = {
.name = "intel-ipu6-psys",
};
#endif
@@ -2331,17 +2331,9 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
ipu_ver = adev->isp->hw_ver;
- rval = alloc_chrdev_region(&ipu_psys_dev_t, 0,
- IPU_PSYS_NUM_DEVICES, IPU6_PSYS_NAME);
- if (rval) {
- dev_err(dev, "can't alloc psys chrdev region (%d)\n",
- rval);
- return rval;
- }
-
rval = ipu6_mmu_hw_init(adev->mmu);
if (rval)
- goto out_unregister_chr_region;
+ return rval;
mutex_lock(&ipu_psys_mutex);
@@ -2453,7 +2445,7 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
goto out_free_pgs;
}
- psys->dev.bus = &ipu6_psys_bus;
+ psys->dev.bus = &ipu_psys_bus;
psys->dev.parent = dev;
psys->dev.devt = MKDEV(MAJOR(ipu_psys_dev_t), minor);
psys->dev.release = ipu_psys_dev_release;
@@ -2500,10 +2492,6 @@ out_unlock:
/* Safe to call even if the init is not called */
mutex_unlock(&ipu_psys_mutex);
ipu6_mmu_hw_cleanup(adev->mmu);
-
-out_unregister_chr_region:
- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
-
return rval;
}
#endif
@@ -2521,9 +2509,6 @@ static void ipu6_psys_remove(struct auxiliary_device *auxdev)
#endif
struct ipu_psys_pg *kpg, *kpg0;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0)
- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
-#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
#ifdef CONFIG_DEBUG_FS
if (isp->ipu_dir)
@@ -2658,38 +2643,6 @@ static struct ipu_bus_driver ipu_psys_driver = {
},
};
-static int __init ipu_psys_init(void)
-{
- int rval = alloc_chrdev_region(&ipu_psys_dev_t, 0,
- IPU_PSYS_NUM_DEVICES, IPU_PSYS_NAME);
- if (rval) {
- pr_err("can't alloc psys chrdev region (%d)\n", rval);
- return rval;
- }
-
- rval = bus_register(&ipu_psys_bus);
- if (rval) {
- pr_warn("can't register psys bus (%d)\n", rval);
- goto out_bus_register;
- }
-
- ipu_bus_register_driver(&ipu_psys_driver);
-
- return rval;
-
-out_bus_register:
- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
-
- return rval;
-}
-
-static void __exit ipu_psys_exit(void)
-{
- ipu_bus_unregister_driver(&ipu_psys_driver);
- bus_unregister(&ipu_psys_bus);
- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
-}
-
static const struct pci_device_id ipu_pci_tbl[] = {
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, IPU6_PCI_ID)},
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, IPU6SE_PCI_ID)},
@@ -2700,9 +2653,6 @@ static const struct pci_device_id ipu_pci_tbl[] = {
{0,}
};
MODULE_DEVICE_TABLE(pci, ipu_pci_tbl);
-
-module_init(ipu_psys_init);
-module_exit(ipu_psys_exit);
#else
static const struct ipu6_auxdrv_data ipu6_psys_auxdrv_data = {
.isr_threaded = psys_isr_threaded,
@@ -2727,9 +2677,45 @@ static struct auxiliary_driver ipu6_psys_aux_driver = {
.pm = &psys_pm_ops,
},
};
-module_auxiliary_driver(ipu6_psys_aux_driver);
#endif
+static int __init ipu_psys_init(void)
+{
+ int rval = alloc_chrdev_region(&ipu_psys_dev_t, 0,
+ IPU_PSYS_NUM_DEVICES, ipu_psys_bus.name);
+ if (rval) {
+ pr_err("can't alloc psys chrdev region (%d)\n", rval);
+ return rval;
+ }
+
+ rval = bus_register(&ipu_psys_bus);
+ if (rval) {
+ pr_err("can't register psys bus (%d)\n", rval);
+ unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
+ return rval;
+ }
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
+ ipu_bus_register_driver(&ipu_psys_driver);
+#else
+ auxiliary_driver_register(&ipu6_psys_aux_driver);
+#endif
+ return 0;
+}
+module_init(ipu_psys_init);
+
+static void __exit ipu_psys_exit(void)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
+ ipu_bus_unregister_driver(&ipu_psys_driver);
+#else
+ auxiliary_driver_unregister(&ipu6_psys_aux_driver);
+#endif
+ bus_unregister(&ipu_psys_bus);
+ unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
+}
+module_exit(ipu_psys_exit);
+
MODULE_AUTHOR("Antti Laakso <antti.laakso@intel.com>");
MODULE_AUTHOR("Bin Han <bin.b.han@intel.com>");
MODULE_AUTHOR("Renwei Wu <renwei.wu@intel.com>");
--
2.48.1
@@ -20,22 +20,8 @@ Source0: https://github.com/intel/ipu6-drivers/archive/%{ipu6_commit}/ipu
Source1: https://github.com/intel/usbio-drivers/archive/%{usbio_commit}/usbio-drivers-%{usbio_shortcommit}.tar.gz
Source2: no-weak-modules.conf
# Patches
# https://github.com/intel/ipu6-drivers/pull/322
Patch1: 0001-Makefile-Switch-sensor-driver-symbols-from-CONFIG_VI.patch
Patch2: 0002-Makefile-Re-enable-gc5035-compilation-with-kernels-6.patch
Patch3: 0003-Makefile-Do-not-build-hi556-driver-with-kernels-6.10.patch
Patch4: 0004-Makefile-Do-not-build-ov01a10-driver-with-kernels-6..patch
# https://github.com/intel/ipu6-drivers/pull/321
Patch5: 0005-media-ipu6-Fix-out-of-tree-builds.patch
Patch6: 0006-media-ipu6-Fix-building-with-kernel-6.13.patch
Patch7: 0007-Modify-0001-v6.10-IPU6-headers-used-by-PSYS.patch-fo.patch
# https://github.com/intel/ipu6-drivers/pull/324
Patch8: 0008-ipu6-psys-Adjust-DMA-code-for-ipu6-bus-DMA-changes-i.patch
Patch9: 0009-Add-ipu6-dma.h-to-0001-v6.10-IPU6-headers-used-by-PS.patch
# https://github.com/intel/ipu6-drivers/pull/327
Patch10: 0010-psys-Do-not-skipping-registering-ipu_psys_bus-for-ke.patch
Patch11: 0011-psys-Use-cdev_device_add-for-dev-ipu-psys0.patch
# https://github.com/intel/usbio-drivers/pull/33
Patch0: 0005-media-ipu6-Fix-out-of-tree-builds.patch
Patch20: 0010-usbio-Fix-GPIO-and-I2C-driver-modaliases.patch
# https://github.com/intel/usbio-drivers/pull/34
Patch21: 0011-usbio-Fix-I2C-max-transfer-size.patch
@@ -56,20 +42,9 @@ This package enables the Intel IPU6 image processor.
%prep
%setup -q -c -a 1
(cd ipu6-drivers-%{ipu6_commit}
%patch 1 -p1
%patch 2 -p1
%patch 3 -p1
%patch 4 -p1
%patch 5 -p1
%patch 6 -p1
%patch 7 -p1
%patch 8 -p1
%patch 9 -p1
%patch 10 -p1
%patch 11 -p1
%patch 0 -p1
%patch 101 -p1
patch -p1 < patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
sed -i "s/^PACKAGE_VERSION=\".*\"$/PACKAGE_VERSION=\"%{version}\"/g" ./dkms.conf
)
(cd usbio-drivers-%{usbio_commit}
%patch 20 -p1