aboutsummaryrefslogtreecommitdiffstats
diff options
-rw-r--r--queue-5.15/media-uvcvideo-rollback-non-processed-entities-on-error.patch116
-rw-r--r--queue-5.15/pci-hv-do-not-set-pci_command_memory-to-reduce-vm-boot-time.patch63
-rw-r--r--queue-5.15/series2
3 files changed, 181 insertions, 0 deletions
diff --git a/queue-5.15/media-uvcvideo-rollback-non-processed-entities-on-error.patch b/queue-5.15/media-uvcvideo-rollback-non-processed-entities-on-error.patch
new file mode 100644
index 0000000000..fb1f2585bf
--- /dev/null
+++ b/queue-5.15/media-uvcvideo-rollback-non-processed-entities-on-error.patch
@@ -0,0 +1,116 @@
+From a70705d3c020d0d5c3ab6a5cc93e011ac35e7d48 Mon Sep 17 00:00:00 2001
+From: Ricardo Ribalda <ribalda@chromium.org>
+Date: Mon, 24 Feb 2025 10:34:55 +0000
+Subject: media: uvcvideo: Rollback non processed entities on error
+
+From: Ricardo Ribalda <ribalda@chromium.org>
+
+commit a70705d3c020d0d5c3ab6a5cc93e011ac35e7d48 upstream.
+
+If we fail to commit an entity, we need to restore the
+UVC_CTRL_DATA_BACKUP for the other uncommitted entities. Otherwise the
+control cache and the device would be out of sync.
+
+Cc: stable@kernel.org
+Fixes: b4012002f3a3 ("[media] uvcvideo: Add support for control events")
+Reported-by: Hans de Goede <hdegoede@redhat.com>
+Closes: https://lore.kernel.org/linux-media/fe845e04-9fde-46ee-9763-a6f00867929a@redhat.com/
+Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
+Message-ID: <20250224-uvc-data-backup-v2-3-de993ed9823b@chromium.org>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
+Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/usb/uvc/uvc_ctrl.c | 40 +++++++++++++++++++++++++--------------
+ 1 file changed, 26 insertions(+), 14 deletions(-)
+
+--- a/drivers/media/usb/uvc/uvc_ctrl.c
++++ b/drivers/media/usb/uvc/uvc_ctrl.c
+@@ -1697,7 +1697,7 @@ static int uvc_ctrl_commit_entity(struct
+ unsigned int processed_ctrls = 0;
+ struct uvc_control *ctrl;
+ unsigned int i;
+- int ret;
++ int ret = 0;
+
+ if (entity == NULL)
+ return 0;
+@@ -1725,8 +1725,6 @@ static int uvc_ctrl_commit_entity(struct
+ dev->intfnum, ctrl->info.selector,
+ uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
+ ctrl->info.size);
+- else
+- ret = 0;
+
+ if (!ret)
+ processed_ctrls++;
+@@ -1738,17 +1736,24 @@ static int uvc_ctrl_commit_entity(struct
+
+ ctrl->dirty = 0;
+
+- if (ret < 0) {
++ if (!rollback && handle && !ret &&
++ ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
++ uvc_ctrl_set_handle(handle, ctrl, handle);
++
++ if (ret < 0 && !rollback) {
+ if (err_ctrl)
+ *err_ctrl = ctrl;
+- return ret;
++ /*
++ * If we fail to set a control, we need to rollback
++ * the next ones.
++ */
++ rollback = 1;
+ }
+-
+- if (!rollback && handle &&
+- ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
+- uvc_ctrl_set_handle(handle, ctrl, handle);
+ }
+
++ if (ret)
++ return ret;
++
+ return processed_ctrls;
+ }
+
+@@ -1779,7 +1784,8 @@ int __uvc_ctrl_commit(struct uvc_fh *han
+ struct uvc_video_chain *chain = handle->chain;
+ struct uvc_control *err_ctrl;
+ struct uvc_entity *entity;
+- int ret = 0;
++ int ret_out = 0;
++ int ret;
+
+ /* Find the control. */
+ list_for_each_entry(entity, &chain->entities, chain) {
+@@ -1790,17 +1796,23 @@ int __uvc_ctrl_commit(struct uvc_fh *han
+ ctrls->error_idx =
+ uvc_ctrl_find_ctrl_idx(entity, ctrls,
+ err_ctrl);
+- goto done;
++ /*
++ * When we fail to commit an entity, we need to
++ * restore the UVC_CTRL_DATA_BACKUP for all the
++ * controls in the other entities, otherwise our cache
++ * and the hardware will be out of sync.
++ */
++ rollback = 1;
++
++ ret_out = ret;
+ } else if (ret > 0 && !rollback) {
+ uvc_ctrl_send_events(handle, entity,
+ ctrls->controls, ctrls->count);
+ }
+ }
+
+- ret = 0;
+-done:
+ mutex_unlock(&chain->ctrl_mutex);
+- return ret;
++ return ret_out;
+ }
+
+ int uvc_ctrl_get(struct uvc_video_chain *chain,
diff --git a/queue-5.15/pci-hv-do-not-set-pci_command_memory-to-reduce-vm-boot-time.patch b/queue-5.15/pci-hv-do-not-set-pci_command_memory-to-reduce-vm-boot-time.patch
new file mode 100644
index 0000000000..d44eee20a1
--- /dev/null
+++ b/queue-5.15/pci-hv-do-not-set-pci_command_memory-to-reduce-vm-boot-time.patch
@@ -0,0 +1,63 @@
+From 23e118a48acf7be223e57d98e98da8ac5a4071ac Mon Sep 17 00:00:00 2001
+From: Dexuan Cui <decui@microsoft.com>
+Date: Mon, 2 May 2022 00:42:55 -0700
+Subject: PCI: hv: Do not set PCI_COMMAND_MEMORY to reduce VM boot time
+
+From: Dexuan Cui <decui@microsoft.com>
+
+commit 23e118a48acf7be223e57d98e98da8ac5a4071ac upstream.
+
+Currently when the pci-hyperv driver finishes probing and initializing the
+PCI device, it sets the PCI_COMMAND_MEMORY bit; later when the PCI device
+is registered to the core PCI subsystem, the core PCI driver's BAR detection
+and initialization code toggles the bit multiple times, and each toggling of
+the bit causes the hypervisor to unmap/map the virtual BARs from/to the
+physical BARs, which can be slow if the BAR sizes are huge, e.g., a Linux VM
+with 14 GPU devices has to spend more than 3 minutes on BAR detection and
+initialization, causing a long boot time.
+
+Reduce the boot time by not setting the PCI_COMMAND_MEMORY bit when we
+register the PCI device (there is no need to have it set in the first place).
+The bit stays off till the PCI device driver calls pci_enable_device().
+With this change, the boot time of such a 14-GPU VM is reduced by almost
+3 minutes.
+
+Link: https://lore.kernel.org/lkml/20220419220007.26550-1-decui@microsoft.com/
+Tested-by: Boqun Feng (Microsoft) <boqun.feng@gmail.com>
+Signed-off-by: Dexuan Cui <decui@microsoft.com>
+Reviewed-by: Michael Kelley <mikelley@microsoft.com>
+Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
+Cc: Jake Oshins <jakeo@microsoft.com>
+Link: https://lore.kernel.org/r/20220502074255.16901-1-decui@microsoft.com
+Signed-off-by: Wei Liu <wei.liu@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/pci/controller/pci-hyperv.c | 17 +++++++++++------
+ 1 file changed, 11 insertions(+), 6 deletions(-)
+
+--- a/drivers/pci/controller/pci-hyperv.c
++++ b/drivers/pci/controller/pci-hyperv.c
+@@ -1882,12 +1882,17 @@ static void prepopulate_bars(struct hv_p
+ }
+ }
+ if (high_size <= 1 && low_size <= 1) {
+- /* Set the memory enable bit. */
+- _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2,
+- &command);
+- command |= PCI_COMMAND_MEMORY;
+- _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2,
+- command);
++ /*
++ * No need to set the PCI_COMMAND_MEMORY bit as
++ * the core PCI driver doesn't require the bit
++ * to be pre-set. Actually here we intentionally
++ * keep the bit off so that the PCI BAR probing
++ * in the core PCI driver doesn't cause Hyper-V
++ * to unnecessarily unmap/map the virtual BARs
++ * from/to the physical BARs multiple times.
++ * This reduces the VM boot time significantly
++ * if the BAR sizes are huge.
++ */
+ break;
+ }
+ }
diff --git a/queue-5.15/series b/queue-5.15/series
index a52e1dafc9..92c1aec35b 100644
--- a/queue-5.15/series
+++ b/queue-5.15/series
@@ -87,3 +87,5 @@ drm-bridge-cdns-dsi-fix-connecting-to-next-bridge.patch
drm-bridge-cdns-dsi-check-return-value-when-getting-default-phy-config.patch
drm-bridge-cdns-dsi-wait-for-clk-and-data-lanes-to-be-ready.patch
drm-amd-display-add-null-pointer-check-for-get_first_active_display.patch
+pci-hv-do-not-set-pci_command_memory-to-reduce-vm-boot-time.patch
+media-uvcvideo-rollback-non-processed-entities-on-error.patch