From 530a275036587954368574589e0aacaffa96590b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 27 Oct 2022 12:33:03 +0200 Subject: [PATCH] 4.14-stable patches added patches: acpi-video-force-backlight-native-for-more-tongfang-devices.patch media-v4l2-mem2mem-apply-dst_queue_off_base-on-mmap-buffers-across-ioctls.patch --- ...ght-native-for-more-tongfang-devices.patch | 118 +++++++++++++++ ...f_base-on-mmap-buffers-across-ioctls.patch | 141 ++++++++++++++++++ queue-4.14/series | 2 + 3 files changed, 261 insertions(+) create mode 100644 queue-4.14/acpi-video-force-backlight-native-for-more-tongfang-devices.patch create mode 100644 queue-4.14/media-v4l2-mem2mem-apply-dst_queue_off_base-on-mmap-buffers-across-ioctls.patch diff --git a/queue-4.14/acpi-video-force-backlight-native-for-more-tongfang-devices.patch b/queue-4.14/acpi-video-force-backlight-native-for-more-tongfang-devices.patch new file mode 100644 index 00000000000..96be72a361f --- /dev/null +++ b/queue-4.14/acpi-video-force-backlight-native-for-more-tongfang-devices.patch @@ -0,0 +1,118 @@ +From wse@tuxedocomputers.com Thu Oct 27 12:25:48 2022 +From: Werner Sembach +Date: Wed, 26 Oct 2022 17:22:46 +0200 +Subject: [PATCH v3] ACPI: video: Force backlight native for more TongFang devices +To: stable@vger.kernel.org +Cc: hdegoede@redhat.com, daniel@ffwll.ch, airlied@redhat.com, lenb@kernel.org, rafael.j.wysocki@intel.com +Message-ID: <20221026152246.24990-1-wse@tuxedocomputers.com> + +From: Werner Sembach + +commit 3dbc80a3e4c55c4a5b89ef207bed7b7de36157b4 upstream. + +This commit is very different from the upstream commit! It fixes the same +issue by adding more quirks, rather then the general fix from the 6.1 +kernel, because the general fix from the 6.1 kernel is part of a larger +refactoring of the backlight code which is not suitable for the stable +series. + +As described in "ACPI: video: Drop NL5x?U, PF4NU1F and PF5?U?? +acpi_backlight=native quirks" (10212754a0d2) the upstream commit "ACPI: +video: Make backlight class device registration a separate step (v2)" +(3dbc80a3e4c5) makes these quirks unnecessary. However as mentioned in this +bugtracker ticket https://bugzilla.kernel.org/show_bug.cgi?id=215683#c17 +the upstream fix is part of a larger patchset that is overall too complex +for stable. + +The TongFang GKxNRxx, GMxNGxx, GMxZGxx, and GMxRGxx / TUXEDO +Stellaris/Polaris Gen 1-4, have the same problem as the Clevo NL5xRU and +NL5xNU / TUXEDO Aura 15 Gen1 and Gen2: +They have a working native and video interface for screen backlight. +However the default detection mechanism first registers the video interface +before unregistering it again and switching to the native interface during +boot. This results in a dangling SBIOS request for backlight change for +some reason, causing the backlight to switch to ~2% once per boot on the +first power cord connect or disconnect event. Setting the native interface +explicitly circumvents this buggy behaviour by avoiding the unregistering +process. + +Reviewed-by: Hans de Goede +Signed-off-by: Werner Sembach +Signed-off-by: Greg Kroah-Hartman +--- + drivers/acpi/video_detect.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 64 insertions(+) + +--- a/drivers/acpi/video_detect.c ++++ b/drivers/acpi/video_detect.c +@@ -448,6 +448,70 @@ static const struct dmi_system_id video_ + }, + }, + /* ++ * More Tongfang devices with the same issue as the Clevo NL5xRU and ++ * NL5xNU/TUXEDO Aura 15 Gen1 and Gen2. See the description above. ++ */ ++ { ++ .callback = video_detect_force_native, ++ .ident = "TongFang GKxNRxx", ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "GKxNRxx"), ++ }, ++ }, ++ { ++ .callback = video_detect_force_native, ++ .ident = "TongFang GKxNRxx", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), ++ DMI_MATCH(DMI_BOARD_NAME, "POLARIS1501A1650TI"), ++ }, ++ }, ++ { ++ .callback = video_detect_force_native, ++ .ident = "TongFang GKxNRxx", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), ++ DMI_MATCH(DMI_BOARD_NAME, "POLARIS1501A2060"), ++ }, ++ }, ++ { ++ .callback = video_detect_force_native, ++ .ident = "TongFang GKxNRxx", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), ++ DMI_MATCH(DMI_BOARD_NAME, "POLARIS1701A1650TI"), ++ }, ++ }, ++ { ++ .callback = video_detect_force_native, ++ .ident = "TongFang GKxNRxx", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), ++ DMI_MATCH(DMI_BOARD_NAME, "POLARIS1701A2060"), ++ }, ++ }, ++ { ++ .callback = video_detect_force_native, ++ .ident = "TongFang GMxNGxx", ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "GMxNGxx"), ++ }, ++ }, ++ { ++ .callback = video_detect_force_native, ++ .ident = "TongFang GMxZGxx", ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "GMxZGxx"), ++ }, ++ }, ++ { ++ .callback = video_detect_force_native, ++ .ident = "TongFang GMxRGxx", ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "GMxRGxx"), ++ }, ++ }, ++ /* + * Desktops which falsely report a backlight and which our heuristics + * for this do not catch. + */ diff --git a/queue-4.14/media-v4l2-mem2mem-apply-dst_queue_off_base-on-mmap-buffers-across-ioctls.patch b/queue-4.14/media-v4l2-mem2mem-apply-dst_queue_off_base-on-mmap-buffers-across-ioctls.patch new file mode 100644 index 00000000000..1330164ca82 --- /dev/null +++ b/queue-4.14/media-v4l2-mem2mem-apply-dst_queue_off_base-on-mmap-buffers-across-ioctls.patch @@ -0,0 +1,141 @@ +From 8310ca94075e784bbb06593cd6c068ee6b6e4ca6 Mon Sep 17 00:00:00 2001 +From: Chen-Yu Tsai +Date: Thu, 9 Dec 2021 17:38:03 +0100 +Subject: media: v4l2-mem2mem: Apply DST_QUEUE_OFF_BASE on MMAP buffers across ioctls + +From: Chen-Yu Tsai + +commit 8310ca94075e784bbb06593cd6c068ee6b6e4ca6 upstream. + +DST_QUEUE_OFF_BASE is applied to offset/mem_offset on MMAP capture buffers +only for the VIDIOC_QUERYBUF ioctl, while the userspace fields (including +offset/mem_offset) are filled in for VIDIOC_{QUERY,PREPARE,Q,DQ}BUF +ioctls. This leads to differences in the values presented to userspace. +If userspace attempts to mmap the capture buffer directly using values +from DQBUF, it will fail. + +Move the code that applies the magic offset into a helper, and call +that helper from all four ioctl entry points. + +[hverkuil: drop unnecessary '= 0' in v4l2_m2m_querybuf() for ret] + +Fixes: 7f98639def42 ("V4L/DVB: add memory-to-memory device helper framework for videobuf") +Fixes: 908a0d7c588e ("[media] v4l: mem2mem: port to videobuf2") +Signed-off-by: Chen-Yu Tsai +Signed-off-by: Hans Verkuil +Signed-off-by: Mauro Carvalho Chehab +[OP: adjusted return logic for 4.14] +Signed-off-by: Ovidiu Panait +Signed-off-by: Greg Kroah-Hartman +--- + drivers/media/v4l2-core/v4l2-mem2mem.c | 62 +++++++++++++++++++++++---------- + 1 file changed, 45 insertions(+), 17 deletions(-) + +--- a/drivers/media/v4l2-core/v4l2-mem2mem.c ++++ b/drivers/media/v4l2-core/v4l2-mem2mem.c +@@ -358,19 +358,14 @@ int v4l2_m2m_reqbufs(struct file *file, + } + EXPORT_SYMBOL_GPL(v4l2_m2m_reqbufs); + +-int v4l2_m2m_querybuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, +- struct v4l2_buffer *buf) ++static void v4l2_m2m_adjust_mem_offset(struct vb2_queue *vq, ++ struct v4l2_buffer *buf) + { +- struct vb2_queue *vq; +- int ret = 0; +- unsigned int i; +- +- vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); +- ret = vb2_querybuf(vq, buf); +- + /* Adjust MMAP memory offsets for the CAPTURE queue */ + if (buf->memory == V4L2_MEMORY_MMAP && !V4L2_TYPE_IS_OUTPUT(vq->type)) { + if (V4L2_TYPE_IS_MULTIPLANAR(vq->type)) { ++ unsigned int i; ++ + for (i = 0; i < buf->length; ++i) + buf->m.planes[i].m.mem_offset + += DST_QUEUE_OFF_BASE; +@@ -378,8 +373,23 @@ int v4l2_m2m_querybuf(struct file *file, + buf->m.offset += DST_QUEUE_OFF_BASE; + } + } ++} ++ ++int v4l2_m2m_querybuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, ++ struct v4l2_buffer *buf) ++{ ++ struct vb2_queue *vq; ++ int ret; + +- return ret; ++ vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); ++ ret = vb2_querybuf(vq, buf); ++ if (ret) ++ return ret; ++ ++ /* Adjust MMAP memory offsets for the CAPTURE queue */ ++ v4l2_m2m_adjust_mem_offset(vq, buf); ++ ++ return 0; + } + EXPORT_SYMBOL_GPL(v4l2_m2m_querybuf); + +@@ -391,10 +401,15 @@ int v4l2_m2m_qbuf(struct file *file, str + + vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); + ret = vb2_qbuf(vq, buf); +- if (!ret) +- v4l2_m2m_try_schedule(m2m_ctx); ++ if (ret) ++ return ret; ++ ++ /* Adjust MMAP memory offsets for the CAPTURE queue */ ++ v4l2_m2m_adjust_mem_offset(vq, buf); ++ ++ v4l2_m2m_try_schedule(m2m_ctx); + +- return ret; ++ return 0; + } + EXPORT_SYMBOL_GPL(v4l2_m2m_qbuf); + +@@ -402,9 +417,17 @@ int v4l2_m2m_dqbuf(struct file *file, st + struct v4l2_buffer *buf) + { + struct vb2_queue *vq; ++ int ret; + + vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); +- return vb2_dqbuf(vq, buf, file->f_flags & O_NONBLOCK); ++ ret = vb2_dqbuf(vq, buf, file->f_flags & O_NONBLOCK); ++ if (ret) ++ return ret; ++ ++ /* Adjust MMAP memory offsets for the CAPTURE queue */ ++ v4l2_m2m_adjust_mem_offset(vq, buf); ++ ++ return 0; + } + EXPORT_SYMBOL_GPL(v4l2_m2m_dqbuf); + +@@ -416,10 +439,15 @@ int v4l2_m2m_prepare_buf(struct file *fi + + vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); + ret = vb2_prepare_buf(vq, buf); +- if (!ret) +- v4l2_m2m_try_schedule(m2m_ctx); ++ if (ret) ++ return ret; ++ ++ /* Adjust MMAP memory offsets for the CAPTURE queue */ ++ v4l2_m2m_adjust_mem_offset(vq, buf); ++ ++ v4l2_m2m_try_schedule(m2m_ctx); + +- return ret; ++ return 0; + } + EXPORT_SYMBOL_GPL(v4l2_m2m_prepare_buf); + diff --git a/queue-4.14/series b/queue-4.14/series index 25c1371a5e8..2d9d47a5474 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -12,3 +12,5 @@ hid-magicmouse-do-not-set-btn_mouse-on-double-report.patch net-atm-fix-proc_mpc_write-incorrect-return-value.patch net-hns-fix-possible-memory-leak-in-hnae_ae_register.patch iommu-vt-d-clean-up-si_domain-in-the-init_dmars-erro.patch +media-v4l2-mem2mem-apply-dst_queue_off_base-on-mmap-buffers-across-ioctls.patch +acpi-video-force-backlight-native-for-more-tongfang-devices.patch -- 2.47.3