]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 6.1
authorSasha Levin <sashal@kernel.org>
Thu, 24 Jul 2025 14:15:04 +0000 (10:15 -0400)
committerSasha Levin <sashal@kernel.org>
Thu, 24 Jul 2025 14:15:04 +0000 (10:15 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-6.1/iio-adc-ad7949-use-spi_is_bpw_supported.patch [new file with mode: 0644]
queue-6.1/interconnect-qcom-sc7280-add-missing-num_links-to-xm.patch [new file with mode: 0644]
queue-6.1/rdma-core-rate-limit-gid-cache-warning-messages.patch [new file with mode: 0644]
queue-6.1/regmap-fix-potential-memory-leak-of-regmap_bus.patch [new file with mode: 0644]
queue-6.1/regulator-core-fix-null-dereference-on-unbind-due-to.patch [new file with mode: 0644]
queue-6.1/series
queue-6.1/staging-vc04_services-drop-vchiq_error-usage.patch [new file with mode: 0644]
queue-6.1/staging-vc04_services-drop-vchiq_retry-usage.patch [new file with mode: 0644]
queue-6.1/staging-vc04_services-drop-vchiq_success-usage.patch [new file with mode: 0644]
queue-6.1/staging-vchiq_arm-make-vchiq_shutdown-never-fail.patch [new file with mode: 0644]
queue-6.1/x86-hyperv-fix-usage-of-cpu_online_mask-to-get-valid.patch [new file with mode: 0644]

diff --git a/queue-6.1/iio-adc-ad7949-use-spi_is_bpw_supported.patch b/queue-6.1/iio-adc-ad7949-use-spi_is_bpw_supported.patch
new file mode 100644 (file)
index 0000000..8a170ea
--- /dev/null
@@ -0,0 +1,55 @@
+From 9a69a249048bfcaae2ebb687202f220615d4b0ef Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 11 Jun 2025 10:04:58 -0500
+Subject: iio: adc: ad7949: use spi_is_bpw_supported()
+
+From: David Lechner <dlechner@baylibre.com>
+
+[ Upstream commit 7b86482632788acd48d7b9ee1867f5ad3a32ccbb ]
+
+Use spi_is_bpw_supported() instead of directly accessing spi->controller
+->bits_per_word_mask. bits_per_word_mask may be 0, which implies that
+8-bits-per-word is supported. spi_is_bpw_supported() takes this into
+account while spi_ctrl_mask == SPI_BPW_MASK(8) does not.
+
+Fixes: 0b2a740b424e ("iio: adc: ad7949: enable use with non 14/16-bit controllers")
+Closes: https://lore.kernel.org/linux-spi/c8b8a963-6cef-4c9b-bfef-dab2b7bd0b0f@sirena.org.uk/
+Signed-off-by: David Lechner <dlechner@baylibre.com>
+Reviewed-by: Andy Shevchenko <andy@kernel.org>
+Link: https://patch.msgid.link/20250611-iio-adc-ad7949-use-spi_is_bpw_supported-v1-1-c4e15bfd326e@baylibre.com
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iio/adc/ad7949.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/iio/adc/ad7949.c b/drivers/iio/adc/ad7949.c
+index edd0c3a35ab73..202561cad4012 100644
+--- a/drivers/iio/adc/ad7949.c
++++ b/drivers/iio/adc/ad7949.c
+@@ -308,7 +308,6 @@ static void ad7949_disable_reg(void *reg)
+ static int ad7949_spi_probe(struct spi_device *spi)
+ {
+-      u32 spi_ctrl_mask = spi->controller->bits_per_word_mask;
+       struct device *dev = &spi->dev;
+       const struct ad7949_adc_spec *spec;
+       struct ad7949_adc_chip *ad7949_adc;
+@@ -337,11 +336,11 @@ static int ad7949_spi_probe(struct spi_device *spi)
+       ad7949_adc->resolution = spec->resolution;
+       /* Set SPI bits per word */
+-      if (spi_ctrl_mask & SPI_BPW_MASK(ad7949_adc->resolution)) {
++      if (spi_is_bpw_supported(spi, ad7949_adc->resolution)) {
+               spi->bits_per_word = ad7949_adc->resolution;
+-      } else if (spi_ctrl_mask == SPI_BPW_MASK(16)) {
++      } else if (spi_is_bpw_supported(spi, 16)) {
+               spi->bits_per_word = 16;
+-      } else if (spi_ctrl_mask == SPI_BPW_MASK(8)) {
++      } else if (spi_is_bpw_supported(spi, 8)) {
+               spi->bits_per_word = 8;
+       } else {
+               dev_err(dev, "unable to find common BPW with spi controller\n");
+-- 
+2.39.5
+
diff --git a/queue-6.1/interconnect-qcom-sc7280-add-missing-num_links-to-xm.patch b/queue-6.1/interconnect-qcom-sc7280-add-missing-num_links-to-xm.patch
new file mode 100644 (file)
index 0000000..37d3403
--- /dev/null
@@ -0,0 +1,36 @@
+From d9d08adb31f4f7e136ccf7a9d1c6cc98ffdf63a6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 13 Jun 2025 22:53:38 +0800
+Subject: interconnect: qcom: sc7280: Add missing num_links to xm_pcie3_1 node
+
+From: Xilin Wu <sophon@radxa.com>
+
+[ Upstream commit 886a94f008dd1a1702ee66dd035c266f70fd9e90 ]
+
+This allows adding interconnect paths for PCIe 1 in device tree later.
+
+Fixes: 46bdcac533cc ("interconnect: qcom: Add SC7280 interconnect provider driver")
+Signed-off-by: Xilin Wu <sophon@radxa.com>
+Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
+Link: https://lore.kernel.org/r/20250613-sc7280-icc-pcie1-fix-v1-1-0b09813e3b09@radxa.com
+Signed-off-by: Georgi Djakov <djakov@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/interconnect/qcom/sc7280.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/interconnect/qcom/sc7280.c b/drivers/interconnect/qcom/sc7280.c
+index 3c39edd21b6ca..79794d8fd711f 100644
+--- a/drivers/interconnect/qcom/sc7280.c
++++ b/drivers/interconnect/qcom/sc7280.c
+@@ -164,6 +164,7 @@ static struct qcom_icc_node xm_pcie3_1 = {
+       .id = SC7280_MASTER_PCIE_1,
+       .channels = 1,
+       .buswidth = 8,
++      .num_links = 1,
+       .links = { SC7280_SLAVE_ANOC_PCIE_GEM_NOC },
+ };
+-- 
+2.39.5
+
diff --git a/queue-6.1/rdma-core-rate-limit-gid-cache-warning-messages.patch b/queue-6.1/rdma-core-rate-limit-gid-cache-warning-messages.patch
new file mode 100644 (file)
index 0000000..3dbdeae
--- /dev/null
@@ -0,0 +1,44 @@
+From 009c7071587e7cd88dfae015b4ee0481919a7cf9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 16 Jun 2025 11:26:21 +0300
+Subject: RDMA/core: Rate limit GID cache warning messages
+
+From: Maor Gottlieb <maorg@nvidia.com>
+
+[ Upstream commit 333e4d79316c9ed5877d7aac8b8ed22efc74e96d ]
+
+The GID cache warning messages can flood the kernel log when there are
+multiple failed attempts to add GIDs. This can happen when creating many
+virtual interfaces without having enough space for their GIDs in the GID
+table.
+
+Change pr_warn to pr_warn_ratelimited to prevent log flooding while still
+maintaining visibility of the issue.
+
+Link: https://patch.msgid.link/r/fd45ed4a1078e743f498b234c3ae816610ba1b18.1750062357.git.leon@kernel.org
+Signed-off-by: Maor Gottlieb <maorg@nvidia.com>
+Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
+Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/core/cache.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
+index 873988e5c5280..0023aad0e7e43 100644
+--- a/drivers/infiniband/core/cache.c
++++ b/drivers/infiniband/core/cache.c
+@@ -582,8 +582,8 @@ static int __ib_cache_gid_add(struct ib_device *ib_dev, u32 port,
+ out_unlock:
+       mutex_unlock(&table->lock);
+       if (ret)
+-              pr_warn("%s: unable to add gid %pI6 error=%d\n",
+-                      __func__, gid->raw, ret);
++              pr_warn_ratelimited("%s: unable to add gid %pI6 error=%d\n",
++                                  __func__, gid->raw, ret);
+       return ret;
+ }
+-- 
+2.39.5
+
diff --git a/queue-6.1/regmap-fix-potential-memory-leak-of-regmap_bus.patch b/queue-6.1/regmap-fix-potential-memory-leak-of-regmap_bus.patch
new file mode 100644 (file)
index 0000000..8b3cf6d
--- /dev/null
@@ -0,0 +1,44 @@
+From 4d9b97585499b97d1a2a5abb73e9f10fe0b846e8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 26 Jun 2025 22:58:21 +0530
+Subject: regmap: fix potential memory leak of regmap_bus
+
+From: Abdun Nihaal <abdun.nihaal@gmail.com>
+
+[ Upstream commit c871c199accb39d0f4cb941ad0dccabfc21e9214 ]
+
+When __regmap_init() is called from __regmap_init_i2c() and
+__regmap_init_spi() (and their devm versions), the bus argument
+obtained from regmap_get_i2c_bus() and regmap_get_spi_bus(), may be
+allocated using kmemdup() to support quirks. In those cases, the
+bus->free_on_exit field is set to true.
+
+However, inside __regmap_init(), buf is not freed on any error path.
+This could lead to a memory leak of regmap_bus when __regmap_init()
+fails. Fix that by freeing bus on error path when free_on_exit is set.
+
+Fixes: ea030ca68819 ("regmap-i2c: Set regmap max raw r/w from quirks")
+Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
+Link: https://patch.msgid.link/20250626172823.18725-1-abdun.nihaal@gmail.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/base/regmap/regmap.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
+index f0e314abcafc5..168532931c86d 100644
+--- a/drivers/base/regmap/regmap.c
++++ b/drivers/base/regmap/regmap.c
+@@ -1266,6 +1266,8 @@ struct regmap *__regmap_init(struct device *dev,
+ err_map:
+       kfree(map);
+ err:
++      if (bus && bus->free_on_exit)
++              kfree(bus);
+       return ERR_PTR(ret);
+ }
+ EXPORT_SYMBOL_GPL(__regmap_init);
+-- 
+2.39.5
+
diff --git a/queue-6.1/regulator-core-fix-null-dereference-on-unbind-due-to.patch b/queue-6.1/regulator-core-fix-null-dereference-on-unbind-due-to.patch
new file mode 100644 (file)
index 0000000..2d7b2aa
--- /dev/null
@@ -0,0 +1,44 @@
+From 38de75e4e619e6ba8bb25bce3c54037110f3a852 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 26 Jun 2025 08:38:09 +0000
+Subject: regulator: core: fix NULL dereference on unbind due to stale coupling
+ data
+
+From: Alessandro Carminati <acarmina@redhat.com>
+
+[ Upstream commit ca46946a482238b0cdea459fb82fc837fb36260e ]
+
+Failing to reset coupling_desc.n_coupled after freeing coupled_rdevs can
+lead to NULL pointer dereference when regulators are accessed post-unbind.
+
+This can happen during runtime PM or other regulator operations that rely
+on coupling metadata.
+
+For example, on ridesx4, unbinding the 'reg-dummy' platform device triggers
+a panic in regulator_lock_recursive() due to stale coupling state.
+
+Ensure n_coupled is set to 0 to prevent access to invalid pointers.
+
+Signed-off-by: Alessandro Carminati <acarmina@redhat.com>
+Link: https://patch.msgid.link/20250626083809.314842-1-acarmina@redhat.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/regulator/core.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
+index 29c9171e923a2..7e6ff7e72784b 100644
+--- a/drivers/regulator/core.c
++++ b/drivers/regulator/core.c
+@@ -5423,6 +5423,7 @@ static void regulator_remove_coupling(struct regulator_dev *rdev)
+                                ERR_PTR(err));
+       }
++      rdev->coupling_desc.n_coupled = 0;
+       kfree(rdev->coupling_desc.coupled_rdevs);
+       rdev->coupling_desc.coupled_rdevs = NULL;
+ }
+-- 
+2.39.5
+
index c2589e0824d7d574161927b3151e150d52398f71..d565e2c949bb1fed550479967f910749be302cf7 100644 (file)
@@ -1 +1,11 @@
 input-gpio-keys-fix-a-sleep-while-atomic-with-preempt_rt.patch
+regulator-core-fix-null-dereference-on-unbind-due-to.patch
+rdma-core-rate-limit-gid-cache-warning-messages.patch
+interconnect-qcom-sc7280-add-missing-num_links-to-xm.patch
+iio-adc-ad7949-use-spi_is_bpw_supported.patch
+regmap-fix-potential-memory-leak-of-regmap_bus.patch
+x86-hyperv-fix-usage-of-cpu_online_mask-to-get-valid.patch
+staging-vc04_services-drop-vchiq_success-usage.patch
+staging-vc04_services-drop-vchiq_error-usage.patch
+staging-vc04_services-drop-vchiq_retry-usage.patch
+staging-vchiq_arm-make-vchiq_shutdown-never-fail.patch
diff --git a/queue-6.1/staging-vc04_services-drop-vchiq_error-usage.patch b/queue-6.1/staging-vc04_services-drop-vchiq_error-usage.patch
new file mode 100644 (file)
index 0000000..c59a0ab
--- /dev/null
@@ -0,0 +1,386 @@
+From 7408e4f14fad34159fe8ae3a2ccd241a58c42be6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 23 Dec 2022 17:54:00 +0530
+Subject: staging: vc04_services: Drop VCHIQ_ERROR usage
+
+From: Umang Jain <umang.jain@ideasonboard.com>
+
+[ Upstream commit ab73dc85328195c10a55b8f0fbc5b0e2749c628a ]
+
+Drop the usage of VCHIQ_ERROR vchiq_status enum type. Replace it with
+-EINVAL to report the error in most cases, -ENOMEM for out-of-memory
+errors and -EHOSTDOWN for service shutdown.
+
+This patch acts as intermediatory to address the TODO item:
+    * Get rid of custom function return values
+for vc04_services/interface.
+
+Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
+Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
+Link: https://lore.kernel.org/r/20221223122404.170585-4-umang.jain@ideasonboard.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: f2b8ebfb8670 ("staging: vchiq_arm: Make vchiq_shutdown never fail")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../include/linux/raspberrypi/vchiq.h         |  1 -
+ .../interface/vchiq_arm/vchiq_arm.c           | 24 +++++-----
+ .../interface/vchiq_arm/vchiq_core.c          | 44 +++++++++----------
+ .../interface/vchiq_arm/vchiq_dev.c           |  6 +--
+ 4 files changed, 37 insertions(+), 38 deletions(-)
+
+diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h
+index ce73930d71d1a..842bec937bd90 100644
+--- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h
++++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h
+@@ -18,7 +18,6 @@ enum vchiq_reason {
+ };
+ enum vchiq_status {
+-      VCHIQ_ERROR   = -1,
+       VCHIQ_RETRY   = 1
+ };
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+index f27f5a1a23e2f..d0b08ed078670 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+@@ -496,7 +496,7 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
+       vchiq_slot_zero = vchiq_init_slots(slot_mem, slot_mem_size);
+       if (!vchiq_slot_zero)
+-              return -EINVAL;
++              return -ENOMEM;
+       vchiq_slot_zero->platform_data[VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX] =
+               (int)slot_phys + slot_mem_size;
+@@ -782,7 +782,7 @@ vchiq_add_service(struct vchiq_instance *instance,
+               *phandle = service->handle;
+               status = 0;
+       } else {
+-              status = VCHIQ_ERROR;
++              status = -EINVAL;
+       }
+       vchiq_log_trace(vchiq_core_log_level, "%s(%p): returning %d", __func__, instance, status);
+@@ -795,7 +795,7 @@ vchiq_open_service(struct vchiq_instance *instance,
+                  const struct vchiq_service_params_kernel *params,
+                  unsigned int *phandle)
+ {
+-      enum vchiq_status   status = VCHIQ_ERROR;
++      int status = -EINVAL;
+       struct vchiq_state   *state = instance->state;
+       struct vchiq_service *service = NULL;
+@@ -842,7 +842,7 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const
+                                                             VCHIQ_BULK_TRANSMIT);
+                       break;
+               default:
+-                      return VCHIQ_ERROR;
++                      return -EINVAL;
+               }
+               /*
+@@ -879,7 +879,7 @@ enum vchiq_status vchiq_bulk_receive(struct vchiq_instance *instance, unsigned i
+                                                             VCHIQ_BULK_RECEIVE);
+                       break;
+               default:
+-                      return VCHIQ_ERROR;
++                      return -EINVAL;
+               }
+               /*
+@@ -907,7 +907,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
+       service = find_service_by_handle(instance, handle);
+       if (!service)
+-              return VCHIQ_ERROR;
++              return -EINVAL;
+       vchiq_service_put(service);
+@@ -941,7 +941,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
+               waiter = kzalloc(sizeof(*waiter), GFP_KERNEL);
+               if (!waiter) {
+                       vchiq_log_error(vchiq_core_log_level, "%s - out of memory", __func__);
+-                      return VCHIQ_ERROR;
++                      return -ENOMEM;
+               }
+       }
+@@ -1114,7 +1114,7 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason,
+                               vchiq_log_info(vchiq_arm_log_level, "%s closing", __func__);
+                               DEBUG_TRACE(SERVICE_CALLBACK_LINE);
+                               vchiq_service_put(service);
+-                              return VCHIQ_ERROR;
++                              return -EINVAL;
+                       }
+                       DEBUG_TRACE(SERVICE_CALLBACK_LINE);
+                       spin_lock(&msg_queue_spinlock);
+@@ -1577,7 +1577,7 @@ vchiq_instance_set_trace(struct vchiq_instance *instance, int trace)
+ enum vchiq_status
+ vchiq_use_service(struct vchiq_instance *instance, unsigned int handle)
+ {
+-      enum vchiq_status ret = VCHIQ_ERROR;
++      int ret = -EINVAL;
+       struct vchiq_service *service = find_service_by_handle(instance, handle);
+       if (service) {
+@@ -1591,7 +1591,7 @@ EXPORT_SYMBOL(vchiq_use_service);
+ enum vchiq_status
+ vchiq_release_service(struct vchiq_instance *instance, unsigned int handle)
+ {
+-      enum vchiq_status ret = VCHIQ_ERROR;
++      int ret = -EINVAL;
+       struct vchiq_service *service = find_service_by_handle(instance, handle);
+       if (service) {
+@@ -1686,7 +1686,7 @@ enum vchiq_status
+ vchiq_check_service(struct vchiq_service *service)
+ {
+       struct vchiq_arm_state *arm_state;
+-      enum vchiq_status ret = VCHIQ_ERROR;
++      int ret = -EINVAL;
+       if (!service || !service->state)
+               goto out;
+@@ -1698,7 +1698,7 @@ vchiq_check_service(struct vchiq_service *service)
+               ret = 0;
+       read_unlock_bh(&arm_state->susp_res_lock);
+-      if (ret == VCHIQ_ERROR) {
++      if (ret) {
+               vchiq_log_error(vchiq_susp_log_level,
+                               "%s ERROR - %c%c%c%c:%d service count %d, state count %d", __func__,
+                               VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), service->client_id,
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+index 9c4523d04bdbb..e60f294fdb682 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+@@ -467,14 +467,14 @@ static inline enum vchiq_status
+ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason,
+                     struct vchiq_header *header, void *bulk_userdata)
+ {
+-      enum vchiq_status status;
++      int status;
+       vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %pK, %pK)",
+                       service->state->id, service->localport, reason_names[reason],
+                       header, bulk_userdata);
+       status = service->base.callback(service->instance, reason, header, service->handle,
+                                       bulk_userdata);
+-      if (status == VCHIQ_ERROR) {
++      if (status && (status != VCHIQ_RETRY)) {
+               vchiq_log_warning(vchiq_core_log_level,
+                                 "%d: ignoring ERROR from callback to service %x",
+                                 service->state->id, service->handle);
+@@ -930,7 +930,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
+               if (!service) {
+                       WARN(1, "%s: service is NULL\n", __func__);
+                       mutex_unlock(&state->slot_mutex);
+-                      return VCHIQ_ERROR;
++                      return -EINVAL;
+               }
+               WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK |
+@@ -939,7 +939,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
+               if (service->closing) {
+                       /* The service has been closed */
+                       mutex_unlock(&state->slot_mutex);
+-                      return VCHIQ_ERROR;
++                      return -EHOSTDOWN;
+               }
+               quota = &state->service_quotas[service->localport];
+@@ -989,13 +989,13 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
+                       if (wait_for_completion_interruptible(&quota->quota_event))
+                               return VCHIQ_RETRY;
+                       if (service->closing)
+-                              return VCHIQ_ERROR;
++                              return -EHOSTDOWN;
+                       if (mutex_lock_killable(&state->slot_mutex))
+                               return VCHIQ_RETRY;
+                       if (service->srvstate != VCHIQ_SRVSTATE_OPEN) {
+                               /* The service has been closed */
+                               mutex_unlock(&state->slot_mutex);
+-                              return VCHIQ_ERROR;
++                              return -EHOSTDOWN;
+                       }
+                       spin_lock(&quota_spinlock);
+                       tx_end_index = SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos + stride - 1);
+@@ -1037,7 +1037,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
+               if (callback_result < 0) {
+                       mutex_unlock(&state->slot_mutex);
+                       VCHIQ_SERVICE_STATS_INC(service, error_count);
+-                      return VCHIQ_ERROR;
++                      return -EINVAL;
+               }
+               if (SRVTRACE_ENABLED(service,
+@@ -1185,7 +1185,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service,
+       if (callback_result < 0) {
+               mutex_unlock(&state->slot_mutex);
+               VCHIQ_SERVICE_STATS_INC(service, error_count);
+-              return VCHIQ_ERROR;
++              return -EINVAL;
+       }
+       if (service) {
+@@ -2520,7 +2520,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id)
+                                       service->state->id,
+                                       srvstate_names[service->srvstate],
+                                       kref_read(&service->ref_count));
+-              status = VCHIQ_ERROR;
++              status = -EINVAL;
+               VCHIQ_SERVICE_STATS_INC(service, error_count);
+               vchiq_release_service_internal(service);
+       }
+@@ -2638,7 +2638,7 @@ close_service_complete(struct vchiq_service *service, int failstate)
+               vchiq_log_error(vchiq_core_log_level, "%s(%x) called in state %s", __func__,
+                               service->handle, srvstate_names[service->srvstate]);
+               WARN(1, "%s in unexpected state\n", __func__);
+-              return VCHIQ_ERROR;
++              return -EINVAL;
+       }
+       status = make_service_callback(service, VCHIQ_SERVICE_CLOSED, NULL, NULL);
+@@ -2695,7 +2695,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd)
+                                       __func__, srvstate_names[service->srvstate]);
+               } else if (is_server) {
+                       if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) {
+-                              status = VCHIQ_ERROR;
++                              status = -EINVAL;
+                       } else {
+                               service->client_id = 0;
+                               service->remoteport = VCHIQ_PORT_FREE;
+@@ -2886,7 +2886,7 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle)
+       int status = 0;
+       if (!service)
+-              return VCHIQ_ERROR;
++              return -EINVAL;
+       vchiq_log_info(vchiq_core_log_level, "%d: close_service:%d",
+                      service->state->id, service->localport);
+@@ -2895,7 +2895,7 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle)
+           (service->srvstate == VCHIQ_SRVSTATE_LISTENING) ||
+           (service->srvstate == VCHIQ_SRVSTATE_HIDDEN)) {
+               vchiq_service_put(service);
+-              return VCHIQ_ERROR;
++              return -EINVAL;
+       }
+       mark_service_closing(service);
+@@ -2928,7 +2928,7 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle)
+       if (!status &&
+           (service->srvstate != VCHIQ_SRVSTATE_FREE) &&
+           (service->srvstate != VCHIQ_SRVSTATE_LISTENING))
+-              status = VCHIQ_ERROR;
++              status = -EINVAL;
+       vchiq_service_put(service);
+@@ -2944,14 +2944,14 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle)
+       int status = 0;
+       if (!service)
+-              return VCHIQ_ERROR;
++              return -EINVAL;
+       vchiq_log_info(vchiq_core_log_level, "%d: remove_service:%d",
+                      service->state->id, service->localport);
+       if (service->srvstate == VCHIQ_SRVSTATE_FREE) {
+               vchiq_service_put(service);
+-              return VCHIQ_ERROR;
++              return -EINVAL;
+       }
+       mark_service_closing(service);
+@@ -2987,7 +2987,7 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle)
+       }
+       if (!status && (service->srvstate != VCHIQ_SRVSTATE_FREE))
+-              status = VCHIQ_ERROR;
++              status = -EINVAL;
+       vchiq_service_put(service);
+@@ -3014,7 +3014,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
+       const char dir_char = (dir == VCHIQ_BULK_TRANSMIT) ? 't' : 'r';
+       const int dir_msgtype = (dir == VCHIQ_BULK_TRANSMIT) ?
+               VCHIQ_MSG_BULK_TX : VCHIQ_MSG_BULK_RX;
+-      enum vchiq_status status = VCHIQ_ERROR;
++      int status = -EINVAL;
+       int payload[2];
+       if (!service)
+@@ -3141,7 +3141,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
+               if (wait_for_completion_interruptible(&bulk_waiter->event))
+                       status = VCHIQ_RETRY;
+               else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED)
+-                      status = VCHIQ_ERROR;
++                      status = -EINVAL;
+       }
+       return status;
+@@ -3167,7 +3167,7 @@ vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle,
+                   size_t size)
+ {
+       struct vchiq_service *service = find_service_by_handle(instance, handle);
+-      enum vchiq_status status = VCHIQ_ERROR;
++      int status = -EINVAL;
+       int data_id;
+       if (!service)
+@@ -3198,7 +3198,7 @@ vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle,
+                                           copy_callback, context, size, 1);
+               break;
+       default:
+-              status = VCHIQ_ERROR;
++              status = -EINVAL;
+               break;
+       }
+@@ -3278,7 +3278,7 @@ release_message_sync(struct vchiq_state *state, struct vchiq_header *header)
+ enum vchiq_status
+ vchiq_get_peer_version(struct vchiq_instance *instance, unsigned int handle, short *peer_version)
+ {
+-      enum vchiq_status status = VCHIQ_ERROR;
++      int status = -EINVAL;
+       struct vchiq_service *service = find_service_by_handle(instance, handle);
+       if (!service)
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
+index d9c4d550412e4..df274192937e5 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
+@@ -130,7 +130,7 @@ vchiq_ioc_queue_message(struct vchiq_instance *instance, unsigned int handle,
+       status = vchiq_queue_message(instance, handle, vchiq_ioc_copy_element_data,
+                                    &context, total_size);
+-      if (status == VCHIQ_ERROR)
++      if (status == -EINVAL)
+               return -EIO;
+       else if (status == VCHIQ_RETRY)
+               return -EINTR;
+@@ -364,7 +364,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
+       vchiq_service_put(service);
+       if (ret)
+               return ret;
+-      else if (status == VCHIQ_ERROR)
++      else if (status == -EINVAL)
+               return -EIO;
+       else if (status == VCHIQ_RETRY)
+               return -EINTR;
+@@ -862,7 +862,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+               vchiq_service_put(service);
+       if (ret == 0) {
+-              if (status == VCHIQ_ERROR)
++              if (status == -EINVAL)
+                       ret = -EIO;
+               else if (status == VCHIQ_RETRY)
+                       ret = -EINTR;
+-- 
+2.39.5
+
diff --git a/queue-6.1/staging-vc04_services-drop-vchiq_retry-usage.patch b/queue-6.1/staging-vc04_services-drop-vchiq_retry-usage.patch
new file mode 100644 (file)
index 0000000..5a48bcd
--- /dev/null
@@ -0,0 +1,486 @@
+From 3e5010c3bdf676c095a1ecb8ba2a8e9490a47a6e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 23 Dec 2022 17:54:01 +0530
+Subject: staging: vc04_services: Drop VCHIQ_RETRY usage
+
+From: Umang Jain <umang.jain@ideasonboard.com>
+
+[ Upstream commit 82a9eb4a3561e1d6d408754f5516af7a59019df2 ]
+
+Drop the usage of VCHIQ_RETRY vchiq_status enum type in most of the
+places and replace it with -EAGAIN. The exception to this replacement
+is vchiq_send_remote_use() and vchiq_send_remote_use_active() which will
+be addressed in the subsequent commit.
+
+This patch acts as intermediatory to address the TODO item:
+    * Get rid of custom function return values
+for vc04_services/interface.
+
+Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
+Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
+Link: https://lore.kernel.org/r/20221223122404.170585-5-umang.jain@ideasonboard.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: f2b8ebfb8670 ("staging: vchiq_arm: Make vchiq_shutdown never fail")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../interface/vchiq_arm/vchiq_arm.c           | 18 ++---
+ .../interface/vchiq_arm/vchiq_core.c          | 76 +++++++++----------
+ .../interface/vchiq_arm/vchiq_dev.c           | 12 +--
+ 3 files changed, 53 insertions(+), 53 deletions(-)
+
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+index d0b08ed078670..44ab7ea42fc85 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+@@ -715,7 +715,7 @@ enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance)
+       struct vchiq_state *state = instance->state;
+       if (mutex_lock_killable(&state->mutex))
+-              return VCHIQ_RETRY;
++              return -EAGAIN;
+       /* Remove all services */
+       vchiq_shutdown_internal(state, instance);
+@@ -743,7 +743,7 @@ enum vchiq_status vchiq_connect(struct vchiq_instance *instance)
+       if (mutex_lock_killable(&state->mutex)) {
+               vchiq_log_trace(vchiq_core_log_level, "%s: call to mutex_lock failed", __func__);
+-              status = VCHIQ_RETRY;
++              status = -EAGAIN;
+               goto failed;
+       }
+       status = vchiq_connect_internal(state, instance);
+@@ -846,11 +846,11 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const
+               }
+               /*
+-               * vchiq_*_bulk_transfer() may return VCHIQ_RETRY, so we need
++               * vchiq_*_bulk_transfer() may return -EAGAIN, so we need
+                * to implement a retry mechanism since this function is
+                * supposed to block until queued
+                */
+-              if (status != VCHIQ_RETRY)
++              if (status != -EAGAIN)
+                       break;
+               msleep(1);
+@@ -883,11 +883,11 @@ enum vchiq_status vchiq_bulk_receive(struct vchiq_instance *instance, unsigned i
+               }
+               /*
+-               * vchiq_*_bulk_transfer() may return VCHIQ_RETRY, so we need
++               * vchiq_*_bulk_transfer() may return -EAGAIN, so we need
+                * to implement a retry mechanism since this function is
+                * supposed to block until queued
+                */
+-              if (status != VCHIQ_RETRY)
++              if (status != -EAGAIN)
+                       break;
+               msleep(1);
+@@ -948,7 +948,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
+       status = vchiq_bulk_transfer(instance, handle, data, NULL, size,
+                                    &waiter->bulk_waiter,
+                                    VCHIQ_BULK_MODE_BLOCKING, dir);
+-      if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) {
++      if ((status != -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) {
+               struct vchiq_bulk *bulk = waiter->bulk_waiter.bulk;
+               if (bulk) {
+@@ -988,7 +988,7 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason,
+               DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT);
+               if (wait_for_completion_interruptible(&instance->remove_event)) {
+                       vchiq_log_info(vchiq_arm_log_level, "service_callback interrupted");
+-                      return VCHIQ_RETRY;
++                      return -EAGAIN;
+               } else if (instance->closing) {
+                       vchiq_log_info(vchiq_arm_log_level, "service_callback closing");
+                       return 0;
+@@ -1109,7 +1109,7 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason,
+                               vchiq_log_info(vchiq_arm_log_level, "%s interrupted", __func__);
+                               DEBUG_TRACE(SERVICE_CALLBACK_LINE);
+                               vchiq_service_put(service);
+-                              return VCHIQ_RETRY;
++                              return -EAGAIN;
+                       } else if (instance->closing) {
+                               vchiq_log_info(vchiq_arm_log_level, "%s closing", __func__);
+                               DEBUG_TRACE(SERVICE_CALLBACK_LINE);
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+index e60f294fdb682..da85f9d165c70 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+@@ -474,7 +474,7 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason,
+                       header, bulk_userdata);
+       status = service->base.callback(service->instance, reason, header, service->handle,
+                                       bulk_userdata);
+-      if (status && (status != VCHIQ_RETRY)) {
++      if (status && (status != -EAGAIN)) {
+               vchiq_log_warning(vchiq_core_log_level,
+                                 "%d: ignoring ERROR from callback to service %x",
+                                 service->state->id, service->handle);
+@@ -922,7 +922,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
+       if (!(flags & QMFLAGS_NO_MUTEX_LOCK) &&
+           mutex_lock_killable(&state->slot_mutex))
+-              return VCHIQ_RETRY;
++              return -EAGAIN;
+       if (type == VCHIQ_MSG_DATA) {
+               int tx_end_index;
+@@ -963,7 +963,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
+                       mutex_unlock(&state->slot_mutex);
+                       if (wait_for_completion_interruptible(&state->data_quota_event))
+-                              return VCHIQ_RETRY;
++                              return -EAGAIN;
+                       mutex_lock(&state->slot_mutex);
+                       spin_lock(&quota_spinlock);
+@@ -987,11 +987,11 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
+                       VCHIQ_SERVICE_STATS_INC(service, quota_stalls);
+                       mutex_unlock(&state->slot_mutex);
+                       if (wait_for_completion_interruptible(&quota->quota_event))
+-                              return VCHIQ_RETRY;
++                              return -EAGAIN;
+                       if (service->closing)
+                               return -EHOSTDOWN;
+                       if (mutex_lock_killable(&state->slot_mutex))
+-                              return VCHIQ_RETRY;
++                              return -EAGAIN;
+                       if (service->srvstate != VCHIQ_SRVSTATE_OPEN) {
+                               /* The service has been closed */
+                               mutex_unlock(&state->slot_mutex);
+@@ -1015,7 +1015,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
+                */
+               if (!(flags & QMFLAGS_NO_MUTEX_LOCK))
+                       mutex_unlock(&state->slot_mutex);
+-              return VCHIQ_RETRY;
++              return -EAGAIN;
+       }
+       if (type == VCHIQ_MSG_DATA) {
+@@ -1154,7 +1154,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service,
+       if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_RESUME &&
+           mutex_lock_killable(&state->sync_mutex))
+-              return VCHIQ_RETRY;
++              return -EAGAIN;
+       remote_event_wait(&state->sync_release_event, &local->sync_release);
+@@ -1348,7 +1348,7 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
+                                               get_bulk_reason(bulk);
+                               status = make_service_callback(service, reason, NULL,
+                                                              bulk->userdata);
+-                              if (status == VCHIQ_RETRY)
++                              if (status == -EAGAIN)
+                                       break;
+                       }
+               }
+@@ -1359,7 +1359,7 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
+       if (!retry_poll)
+               status = 0;
+-      if (status == VCHIQ_RETRY)
++      if (status == -EAGAIN)
+               request_poll(service->state, service, (queue == &service->bulk_tx) ?
+                            VCHIQ_POLL_TXNOTIFY : VCHIQ_POLL_RXNOTIFY);
+@@ -1526,14 +1526,14 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header)
+               /* Acknowledge the OPEN */
+               if (service->sync) {
+                       if (queue_message_sync(state, NULL, openack_id, memcpy_copy_callback,
+-                                             &ack_payload, sizeof(ack_payload), 0) == VCHIQ_RETRY)
++                                             &ack_payload, sizeof(ack_payload), 0) == -EAGAIN)
+                               goto bail_not_ready;
+                       /* The service is now open */
+                       set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC);
+               } else {
+                       if (queue_message(state, NULL, openack_id, memcpy_copy_callback,
+-                                        &ack_payload, sizeof(ack_payload), 0) == VCHIQ_RETRY)
++                                        &ack_payload, sizeof(ack_payload), 0) == -EAGAIN)
+                               goto bail_not_ready;
+                       /* The service is now open */
+@@ -1548,7 +1548,7 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header)
+ fail_open:
+       /* No available service, or an invalid request - send a CLOSE */
+       if (queue_message(state, NULL, MAKE_CLOSE(0, VCHIQ_MSG_SRCPORT(msgid)),
+-                        NULL, NULL, 0, 0) == VCHIQ_RETRY)
++                        NULL, NULL, 0, 0) == -EAGAIN)
+               goto bail_not_ready;
+       return 1;
+@@ -1687,7 +1687,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
+               mark_service_closing_internal(service, 1);
+-              if (vchiq_close_service_internal(service, CLOSE_RECVD) == VCHIQ_RETRY)
++              if (vchiq_close_service_internal(service, CLOSE_RECVD) == -EAGAIN)
+                       goto bail_not_ready;
+               vchiq_log_info(vchiq_core_log_level, "Close Service %c%c%c%c s:%u d:%d",
+@@ -1704,7 +1704,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
+                       claim_slot(state->rx_info);
+                       DEBUG_TRACE(PARSE_LINE);
+                       if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header,
+-                                                NULL) == VCHIQ_RETRY) {
++                                                NULL) == -EAGAIN) {
+                               DEBUG_TRACE(PARSE_LINE);
+                               goto bail_not_ready;
+                       }
+@@ -1802,7 +1802,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
+               if (state->conn_state != VCHIQ_CONNSTATE_PAUSE_SENT) {
+                       /* Send a PAUSE in response */
+                       if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0,
+-                                        QMFLAGS_NO_MUTEX_UNLOCK) == VCHIQ_RETRY)
++                                        QMFLAGS_NO_MUTEX_UNLOCK) == -EAGAIN)
+                               goto bail_not_ready;
+               }
+               /* At this point slot_mutex is held */
+@@ -1919,7 +1919,7 @@ handle_poll(struct vchiq_state *state)
+       case VCHIQ_CONNSTATE_PAUSING:
+               if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0,
+-                                QMFLAGS_NO_MUTEX_UNLOCK) != VCHIQ_RETRY) {
++                                QMFLAGS_NO_MUTEX_UNLOCK) != -EAGAIN) {
+                       vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSE_SENT);
+               } else {
+                       /* Retry later */
+@@ -1929,7 +1929,7 @@ handle_poll(struct vchiq_state *state)
+       case VCHIQ_CONNSTATE_RESUMING:
+               if (queue_message(state, NULL, MAKE_RESUME, NULL, NULL, 0,
+-                                QMFLAGS_NO_MUTEX_LOCK) != VCHIQ_RETRY) {
++                                QMFLAGS_NO_MUTEX_LOCK) != -EAGAIN) {
+                       vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED);
+               } else {
+                       /*
+@@ -2085,9 +2085,9 @@ sync_func(void *v)
+                       if ((service->remoteport == remoteport) &&
+                           (service->srvstate == VCHIQ_SRVSTATE_OPENSYNC)) {
+                               if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header,
+-                                                        NULL) == VCHIQ_RETRY)
++                                                        NULL) == -EAGAIN)
+                                       vchiq_log_error(vchiq_sync_log_level,
+-                                                      "synchronous callback to service %d returns VCHIQ_RETRY",
++                                                      "synchronous callback to service %d returns -EAGAIN",
+                                                       localport);
+                       }
+                       break;
+@@ -2510,7 +2510,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id)
+       /* Wait for the ACK/NAK */
+       if (wait_for_completion_interruptible(&service->remove_event)) {
+-              status = VCHIQ_RETRY;
++              status = -EAGAIN;
+               vchiq_release_service_internal(service);
+       } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) &&
+                  (service->srvstate != VCHIQ_SRVSTATE_OPENSYNC)) {
+@@ -2643,7 +2643,7 @@ close_service_complete(struct vchiq_service *service, int failstate)
+       status = make_service_callback(service, VCHIQ_SERVICE_CLOSED, NULL, NULL);
+-      if (status != VCHIQ_RETRY) {
++      if (status != -EAGAIN) {
+               int uc = service->service_use_count;
+               int i;
+               /* Complete the close process */
+@@ -2724,7 +2724,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd)
+       case VCHIQ_SRVSTATE_OPEN:
+               if (close_recvd) {
+                       if (!do_abort_bulks(service))
+-                              status = VCHIQ_RETRY;
++                              status = -EAGAIN;
+               }
+               release_service_messages(service);
+@@ -2763,7 +2763,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd)
+                       break;
+               if (!do_abort_bulks(service)) {
+-                      status = VCHIQ_RETRY;
++                      status = -EAGAIN;
+                       break;
+               }
+@@ -2847,15 +2847,15 @@ vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instanc
+       if (state->conn_state == VCHIQ_CONNSTATE_DISCONNECTED) {
+               if (queue_message(state, NULL, MAKE_CONNECT, NULL, NULL, 0,
+-                                QMFLAGS_IS_BLOCKING) == VCHIQ_RETRY)
+-                      return VCHIQ_RETRY;
++                                QMFLAGS_IS_BLOCKING) == -EAGAIN)
++                      return -EAGAIN;
+               vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTING);
+       }
+       if (state->conn_state == VCHIQ_CONNSTATE_CONNECTING) {
+               if (wait_for_completion_interruptible(&state->connect))
+-                      return VCHIQ_RETRY;
++                      return -EAGAIN;
+               vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED);
+               complete(&state->connect);
+@@ -2902,7 +2902,7 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle)
+       if (current == service->state->slot_handler_thread) {
+               status = vchiq_close_service_internal(service, NO_CLOSE_RECVD);
+-              WARN_ON(status == VCHIQ_RETRY);
++              WARN_ON(status == -EAGAIN);
+       } else {
+               /* Mark the service for termination by the slot handler */
+               request_poll(service->state, service, VCHIQ_POLL_TERMINATE);
+@@ -2910,7 +2910,7 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle)
+       while (1) {
+               if (wait_for_completion_interruptible(&service->remove_event)) {
+-                      status = VCHIQ_RETRY;
++                      status = -EAGAIN;
+                       break;
+               }
+@@ -2965,14 +2965,14 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle)
+               service->public_fourcc = VCHIQ_FOURCC_INVALID;
+               status = vchiq_close_service_internal(service, NO_CLOSE_RECVD);
+-              WARN_ON(status == VCHIQ_RETRY);
++              WARN_ON(status == -EAGAIN);
+       } else {
+               /* Mark the service for removal by the slot handler */
+               request_poll(service->state, service, VCHIQ_POLL_REMOVE);
+       }
+       while (1) {
+               if (wait_for_completion_interruptible(&service->remove_event)) {
+-                      status = VCHIQ_RETRY;
++                      status = -EAGAIN;
+                       break;
+               }
+@@ -2996,7 +2996,7 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle)
+ /*
+  * This function may be called by kernel threads or user threads.
+- * User threads may receive VCHIQ_RETRY to indicate that a signal has been
++ * User threads may receive -EAGAIN to indicate that a signal has been
+  * received and the call should be retried after being returned to user
+  * context.
+  * When called in blocking mode, the userdata field points to a bulk_waiter
+@@ -3053,7 +3053,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
+               &service->bulk_tx : &service->bulk_rx;
+       if (mutex_lock_killable(&service->bulk_mutex)) {
+-              status = VCHIQ_RETRY;
++              status = -EAGAIN;
+               goto error_exit;
+       }
+@@ -3062,11 +3062,11 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
+               do {
+                       mutex_unlock(&service->bulk_mutex);
+                       if (wait_for_completion_interruptible(&service->bulk_remove_event)) {
+-                              status = VCHIQ_RETRY;
++                              status = -EAGAIN;
+                               goto error_exit;
+                       }
+                       if (mutex_lock_killable(&service->bulk_mutex)) {
+-                              status = VCHIQ_RETRY;
++                              status = -EAGAIN;
+                               goto error_exit;
+                       }
+               } while (queue->local_insert == queue->remove +
+@@ -3099,7 +3099,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
+        * claim it here to ensure that isn't happening
+        */
+       if (mutex_lock_killable(&state->slot_mutex)) {
+-              status = VCHIQ_RETRY;
++              status = -EAGAIN;
+               goto cancel_bulk_error_exit;
+       }
+@@ -3139,7 +3139,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
+       if (bulk_waiter) {
+               bulk_waiter->bulk = bulk;
+               if (wait_for_completion_interruptible(&bulk_waiter->event))
+-                      status = VCHIQ_RETRY;
++                      status = -EAGAIN;
+               else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED)
+                       status = -EINVAL;
+       }
+@@ -3219,11 +3219,11 @@ int vchiq_queue_kernel_message(struct vchiq_instance *instance, unsigned int han
+                                            data, size);
+               /*
+-               * vchiq_queue_message() may return VCHIQ_RETRY, so we need to
++               * vchiq_queue_message() may return -EAGAIN, so we need to
+                * implement a retry mechanism since this function is supposed
+                * to block until queued
+                */
+-              if (status != VCHIQ_RETRY)
++              if (status != -EAGAIN)
+                       break;
+               msleep(1);
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
+index df274192937e5..841e1a535642a 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
+@@ -132,7 +132,7 @@ vchiq_ioc_queue_message(struct vchiq_instance *instance, unsigned int handle,
+       if (status == -EINVAL)
+               return -EIO;
+-      else if (status == VCHIQ_RETRY)
++      else if (status == -EAGAIN)
+               return -EINTR;
+       return 0;
+ }
+@@ -192,7 +192,7 @@ static int vchiq_ioc_create_service(struct vchiq_instance *instance,
+               status = vchiq_open_service_internal(service, instance->pid);
+               if (status) {
+                       vchiq_remove_service(instance, service->handle);
+-                      return (status == VCHIQ_RETRY) ?
++                      return (status == -EAGAIN) ?
+                               -EINTR : -EIO;
+               }
+       }
+@@ -338,7 +338,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
+               goto out;
+       }
+-      if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) ||
++      if ((status != -EAGAIN) || fatal_signal_pending(current) ||
+           !waiter->bulk_waiter.bulk) {
+               if (waiter->bulk_waiter.bulk) {
+                       /* Cancel the signal when the transfer completes. */
+@@ -366,7 +366,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
+               return ret;
+       else if (status == -EINVAL)
+               return -EIO;
+-      else if (status == VCHIQ_RETRY)
++      else if (status == -EAGAIN)
+               return -EINTR;
+       return 0;
+ }
+@@ -686,7 +686,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+                */
+               if (user_service->close_pending &&
+                   wait_for_completion_interruptible(&user_service->close_event))
+-                      status = VCHIQ_RETRY;
++                      status = -EAGAIN;
+               break;
+       }
+@@ -864,7 +864,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+       if (ret == 0) {
+               if (status == -EINVAL)
+                       ret = -EIO;
+-              else if (status == VCHIQ_RETRY)
++              else if (status == -EAGAIN)
+                       ret = -EINTR;
+       }
+-- 
+2.39.5
+
diff --git a/queue-6.1/staging-vc04_services-drop-vchiq_success-usage.patch b/queue-6.1/staging-vc04_services-drop-vchiq_success-usage.patch
new file mode 100644 (file)
index 0000000..7d1dac8
--- /dev/null
@@ -0,0 +1,553 @@
+From a1a58d11c54de91f16452238fc19bd03e38613dd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 23 Dec 2022 17:53:59 +0530
+Subject: staging: vc04_services: Drop VCHIQ_SUCCESS usage
+
+From: Umang Jain <umang.jain@ideasonboard.com>
+
+[ Upstream commit 3414994ba840425b313853a47d581dd5c6c2d300 ]
+
+Drop the usage of VCHIQ_SUCCESS vchiq_status enum type. Replace it with
+0 to report the success status.
+
+This patch acts as intermediatory to address the TODO item:
+       * Get rid of custom function return values
+for vc04_services/interface.
+
+Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
+Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
+Link: https://lore.kernel.org/r/20221223122404.170585-3-umang.jain@ideasonboard.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: f2b8ebfb8670 ("staging: vchiq_arm: Make vchiq_shutdown never fail")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../bcm2835-audio/bcm2835-vchiq.c             |  4 +-
+ .../include/linux/raspberrypi/vchiq.h         |  1 -
+ .../interface/vchiq_arm/vchiq_arm.c           | 36 ++++++-------
+ .../interface/vchiq_arm/vchiq_core.c          | 54 +++++++++----------
+ .../interface/vchiq_arm/vchiq_dev.c           | 18 +++----
+ .../vc04_services/vchiq-mmal/mmal-vchiq.c     |  4 +-
+ 6 files changed, 57 insertions(+), 60 deletions(-)
+
+diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
+index f4c2c9506d863..2a5a43e7ff295 100644
+--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
++++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
+@@ -101,7 +101,7 @@ static enum vchiq_status audio_vchi_callback(struct vchiq_instance *vchiq_instan
+       struct vc_audio_msg *m;
+       if (reason != VCHIQ_MESSAGE_AVAILABLE)
+-              return VCHIQ_SUCCESS;
++              return 0;
+       m = (void *)header->data;
+       if (m->type == VC_AUDIO_MSG_TYPE_RESULT) {
+@@ -119,7 +119,7 @@ static enum vchiq_status audio_vchi_callback(struct vchiq_instance *vchiq_instan
+       }
+       vchiq_release_message(vchiq_instance, instance->service_handle, header);
+-      return VCHIQ_SUCCESS;
++      return 0;
+ }
+ static int
+diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h
+index 690ab7165b2c1..ce73930d71d1a 100644
+--- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h
++++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h
+@@ -19,7 +19,6 @@ enum vchiq_reason {
+ enum vchiq_status {
+       VCHIQ_ERROR   = -1,
+-      VCHIQ_SUCCESS = 0,
+       VCHIQ_RETRY   = 1
+ };
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+index 456a9508fb911..f27f5a1a23e2f 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+@@ -711,7 +711,7 @@ void free_bulk_waiter(struct vchiq_instance *instance)
+ enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance)
+ {
+-      enum vchiq_status status = VCHIQ_SUCCESS;
++      int status = 0;
+       struct vchiq_state *state = instance->state;
+       if (mutex_lock_killable(&state->mutex))
+@@ -748,7 +748,7 @@ enum vchiq_status vchiq_connect(struct vchiq_instance *instance)
+       }
+       status = vchiq_connect_internal(state, instance);
+-      if (status == VCHIQ_SUCCESS)
++      if (!status)
+               instance->connected = 1;
+       mutex_unlock(&state->mutex);
+@@ -780,7 +780,7 @@ vchiq_add_service(struct vchiq_instance *instance,
+       if (service) {
+               *phandle = service->handle;
+-              status = VCHIQ_SUCCESS;
++              status = 0;
+       } else {
+               status = VCHIQ_ERROR;
+       }
+@@ -809,7 +809,7 @@ vchiq_open_service(struct vchiq_instance *instance,
+       if (service) {
+               *phandle = service->handle;
+               status = vchiq_open_service_internal(service, current->pid);
+-              if (status != VCHIQ_SUCCESS) {
++              if (status) {
+                       vchiq_remove_service(instance, service->handle);
+                       *phandle = VCHIQ_SERVICE_HANDLE_INVALID;
+               }
+@@ -991,7 +991,7 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason,
+                       return VCHIQ_RETRY;
+               } else if (instance->closing) {
+                       vchiq_log_info(vchiq_arm_log_level, "service_callback closing");
+-                      return VCHIQ_SUCCESS;
++                      return 0;
+               }
+               DEBUG_TRACE(SERVICE_CALLBACK_LINE);
+       }
+@@ -1028,7 +1028,7 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason,
+       complete(&instance->insert_event);
+-      return VCHIQ_SUCCESS;
++      return 0;
+ }
+ enum vchiq_status
+@@ -1053,14 +1053,14 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason,
+       service = handle_to_service(instance, handle);
+       if (WARN_ON(!service)) {
+               rcu_read_unlock();
+-              return VCHIQ_SUCCESS;
++              return 0;
+       }
+       user_service = (struct user_service *)service->base.userdata;
+       if (!instance || instance->closing) {
+               rcu_read_unlock();
+-              return VCHIQ_SUCCESS;
++              return 0;
+       }
+       /*
+@@ -1097,7 +1097,7 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason,
+                               DEBUG_TRACE(SERVICE_CALLBACK_LINE);
+                               status = add_completion(instance, reason, NULL, user_service,
+                                                       bulk_userdata);
+-                              if (status != VCHIQ_SUCCESS) {
++                              if (status) {
+                                       DEBUG_TRACE(SERVICE_CALLBACK_LINE);
+                                       vchiq_service_put(service);
+                                       return status;
+@@ -1145,7 +1145,7 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason,
+       vchiq_service_put(service);
+       if (skip_completion)
+-              return VCHIQ_SUCCESS;
++              return 0;
+       return add_completion(instance, reason, header, user_service,
+               bulk_userdata);
+@@ -1337,14 +1337,14 @@ vchiq_keepalive_thread_func(void *v)
+       }
+       status = vchiq_connect(instance);
+-      if (status != VCHIQ_SUCCESS) {
++      if (status) {
+               vchiq_log_error(vchiq_susp_log_level, "%s vchiq_connect failed %d", __func__,
+                               status);
+               goto shutdown;
+       }
+       status = vchiq_add_service(instance, &params, &ka_handle);
+-      if (status != VCHIQ_SUCCESS) {
++      if (status) {
+               vchiq_log_error(vchiq_susp_log_level, "%s vchiq_open_service failed %d", __func__,
+                               status);
+               goto shutdown;
+@@ -1373,14 +1373,14 @@ vchiq_keepalive_thread_func(void *v)
+               while (uc--) {
+                       atomic_inc(&arm_state->ka_use_ack_count);
+                       status = vchiq_use_service(instance, ka_handle);
+-                      if (status != VCHIQ_SUCCESS) {
++                      if (status) {
+                               vchiq_log_error(vchiq_susp_log_level,
+                                               "%s vchiq_use_service error %d", __func__, status);
+                       }
+               }
+               while (rc--) {
+                       status = vchiq_release_service(instance, ka_handle);
+-                      if (status != VCHIQ_SUCCESS) {
++                      if (status) {
+                               vchiq_log_error(vchiq_susp_log_level,
+                                               "%s vchiq_release_service error %d", __func__,
+                                               status);
+@@ -1433,13 +1433,13 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service,
+       write_unlock_bh(&arm_state->susp_res_lock);
+       if (!ret) {
+-              enum vchiq_status status = VCHIQ_SUCCESS;
++              int status = 0;
+               long ack_cnt = atomic_xchg(&arm_state->ka_use_ack_count, 0);
+-              while (ack_cnt && (status == VCHIQ_SUCCESS)) {
++              while (ack_cnt && !status) {
+                       /* Send the use notify to videocore */
+                       status = vchiq_send_remote_use_active(state);
+-                      if (status == VCHIQ_SUCCESS)
++                      if (!status)
+                               ack_cnt--;
+                       else
+                               atomic_add(ack_cnt, &arm_state->ka_use_ack_count);
+@@ -1695,7 +1695,7 @@ vchiq_check_service(struct vchiq_service *service)
+       read_lock_bh(&arm_state->susp_res_lock);
+       if (service->service_use_count)
+-              ret = VCHIQ_SUCCESS;
++              ret = 0;
+       read_unlock_bh(&arm_state->susp_res_lock);
+       if (ret == VCHIQ_ERROR) {
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+index 45ed30bfdbf56..9c4523d04bdbb 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+@@ -478,7 +478,7 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason,
+               vchiq_log_warning(vchiq_core_log_level,
+                                 "%d: ignoring ERROR from callback to service %x",
+                                 service->state->id, service->handle);
+-              status = VCHIQ_SUCCESS;
++              status = 0;
+       }
+       if (reason != VCHIQ_MESSAGE_AVAILABLE)
+@@ -1135,7 +1135,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
+       remote_event_signal(&state->remote->trigger);
+-      return VCHIQ_SUCCESS;
++      return 0;
+ }
+ /* Called by the slot handler and application threads */
+@@ -1223,7 +1223,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service,
+       if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_PAUSE)
+               mutex_unlock(&state->sync_mutex);
+-      return VCHIQ_SUCCESS;
++      return 0;
+ }
+ static inline void
+@@ -1303,7 +1303,7 @@ static enum vchiq_status
+ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
+            int retry_poll)
+ {
+-      enum vchiq_status status = VCHIQ_SUCCESS;
++      int status = 0;
+       vchiq_log_trace(vchiq_core_log_level, "%d: nb:%d %cx - p=%x rn=%x r=%x", service->state->id,
+                       service->localport, (queue == &service->bulk_tx) ? 't' : 'r',
+@@ -1357,7 +1357,7 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
+               complete(&service->bulk_remove_event);
+       }
+       if (!retry_poll)
+-              status = VCHIQ_SUCCESS;
++              status = 0;
+       if (status == VCHIQ_RETRY)
+               request_poll(service->state, service, (queue == &service->bulk_tx) ?
+@@ -1398,13 +1398,12 @@ poll_services_of_group(struct vchiq_state *state, int group)
+                        */
+                       service->public_fourcc = VCHIQ_FOURCC_INVALID;
+-                      if (vchiq_close_service_internal(service, NO_CLOSE_RECVD) !=
+-                                                       VCHIQ_SUCCESS)
++                      if (vchiq_close_service_internal(service, NO_CLOSE_RECVD))
+                               request_poll(state, service, VCHIQ_POLL_REMOVE);
+               } else if (service_flags & BIT(VCHIQ_POLL_TERMINATE)) {
+                       vchiq_log_info(vchiq_core_log_level, "%d: ps - terminate %d<->%d",
+                                      state->id, service->localport, service->remoteport);
+-                      if (vchiq_close_service_internal(service, NO_CLOSE_RECVD) != VCHIQ_SUCCESS)
++                      if (vchiq_close_service_internal(service, NO_CLOSE_RECVD))
+                               request_poll(state, service, VCHIQ_POLL_TERMINATE);
+               }
+               if (service_flags & BIT(VCHIQ_POLL_TXNOTIFY))
+@@ -2495,7 +2494,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id)
+               service->version,
+               service->version_min
+       };
+-      enum vchiq_status status = VCHIQ_SUCCESS;
++      int status = 0;
+       service->client_id = client_id;
+       vchiq_use_service_internal(service);
+@@ -2506,7 +2505,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id)
+                              sizeof(payload),
+                              QMFLAGS_IS_BLOCKING);
+-      if (status != VCHIQ_SUCCESS)
++      if (status)
+               return status;
+       /* Wait for the ACK/NAK */
+@@ -2602,11 +2601,11 @@ do_abort_bulks(struct vchiq_service *service)
+       mutex_unlock(&service->bulk_mutex);
+       status = notify_bulks(service, &service->bulk_tx, NO_RETRY_POLL);
+-      if (status != VCHIQ_SUCCESS)
++      if (status)
+               return 0;
+       status = notify_bulks(service, &service->bulk_rx, NO_RETRY_POLL);
+-      return (status == VCHIQ_SUCCESS);
++      return !status;
+ }
+ static enum vchiq_status
+@@ -2678,7 +2677,7 @@ enum vchiq_status
+ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd)
+ {
+       struct vchiq_state *state = service->state;
+-      enum vchiq_status status = VCHIQ_SUCCESS;
++      int status = 0;
+       int is_server = (service->public_fourcc != VCHIQ_FOURCC_INVALID);
+       int close_id = MAKE_CLOSE(service->localport,
+                                 VCHIQ_MSG_DSTPORT(service->remoteport));
+@@ -2730,11 +2729,11 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd)
+               release_service_messages(service);
+-              if (status == VCHIQ_SUCCESS)
++              if (!status)
+                       status = queue_message(state, service, close_id, NULL,
+                                              NULL, 0, QMFLAGS_NO_MUTEX_UNLOCK);
+-              if (status != VCHIQ_SUCCESS) {
++              if (status) {
+                       if (service->srvstate == VCHIQ_SRVSTATE_OPENSYNC)
+                               mutex_unlock(&state->sync_mutex);
+                       break;
+@@ -2768,7 +2767,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd)
+                       break;
+               }
+-              if (status == VCHIQ_SUCCESS)
++              if (!status)
+                       status = close_service_complete(service, VCHIQ_SRVSTATE_CLOSERECVD);
+               break;
+@@ -2862,7 +2861,7 @@ vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instanc
+               complete(&state->connect);
+       }
+-      return VCHIQ_SUCCESS;
++      return 0;
+ }
+ void
+@@ -2884,7 +2883,7 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle)
+ {
+       /* Unregister the service */
+       struct vchiq_service *service = find_service_by_handle(instance, handle);
+-      enum vchiq_status status = VCHIQ_SUCCESS;
++      int status = 0;
+       if (!service)
+               return VCHIQ_ERROR;
+@@ -2926,7 +2925,7 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle)
+                                 srvstate_names[service->srvstate]);
+       }
+-      if ((status == VCHIQ_SUCCESS) &&
++      if (!status &&
+           (service->srvstate != VCHIQ_SRVSTATE_FREE) &&
+           (service->srvstate != VCHIQ_SRVSTATE_LISTENING))
+               status = VCHIQ_ERROR;
+@@ -2942,7 +2941,7 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle)
+ {
+       /* Unregister the service */
+       struct vchiq_service *service = find_service_by_handle(instance, handle);
+-      enum vchiq_status status = VCHIQ_SUCCESS;
++      int status = 0;
+       if (!service)
+               return VCHIQ_ERROR;
+@@ -2987,8 +2986,7 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle)
+                                 srvstate_names[service->srvstate]);
+       }
+-      if ((status == VCHIQ_SUCCESS) &&
+-          (service->srvstate != VCHIQ_SRVSTATE_FREE))
++      if (!status && (service->srvstate != VCHIQ_SRVSTATE_FREE))
+               status = VCHIQ_ERROR;
+       vchiq_service_put(service);
+@@ -3028,7 +3026,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
+       if (!offset && !uoffset)
+               goto error_exit;
+-      if (vchiq_check_service(service) != VCHIQ_SUCCESS)
++      if (vchiq_check_service(service))
+               goto error_exit;
+       switch (mode) {
+@@ -3121,7 +3119,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
+                              QMFLAGS_IS_BLOCKING |
+                              QMFLAGS_NO_MUTEX_LOCK |
+                              QMFLAGS_NO_MUTEX_UNLOCK);
+-      if (status != VCHIQ_SUCCESS)
++      if (status)
+               goto unlock_both_error_exit;
+       queue->local_insert++;
+@@ -3136,7 +3134,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
+ waiting:
+       vchiq_service_put(service);
+-      status = VCHIQ_SUCCESS;
++      status = 0;
+       if (bulk_waiter) {
+               bulk_waiter->bulk = bulk;
+@@ -3175,7 +3173,7 @@ vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle,
+       if (!service)
+               goto error_exit;
+-      if (vchiq_check_service(service) != VCHIQ_SUCCESS)
++      if (vchiq_check_service(service))
+               goto error_exit;
+       if (!size) {
+@@ -3286,14 +3284,14 @@ vchiq_get_peer_version(struct vchiq_instance *instance, unsigned int handle, sho
+       if (!service)
+               goto exit;
+-      if (vchiq_check_service(service) != VCHIQ_SUCCESS)
++      if (vchiq_check_service(service))
+               goto exit;
+       if (!peer_version)
+               goto exit;
+       *peer_version = service->peer_version;
+-      status = VCHIQ_SUCCESS;
++      status = 0;
+ exit:
+       if (service)
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
+index 7e297494437e1..d9c4d550412e4 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
+@@ -112,7 +112,7 @@ vchiq_ioc_queue_message(struct vchiq_instance *instance, unsigned int handle,
+                       struct vchiq_element *elements, unsigned long count)
+ {
+       struct vchiq_io_copy_callback_context context;
+-      enum vchiq_status status = VCHIQ_SUCCESS;
++      int status = 0;
+       unsigned long i;
+       size_t total_size = 0;
+@@ -142,7 +142,7 @@ static int vchiq_ioc_create_service(struct vchiq_instance *instance,
+ {
+       struct user_service *user_service = NULL;
+       struct vchiq_service *service;
+-      enum vchiq_status status = VCHIQ_SUCCESS;
++      int status = 0;
+       struct vchiq_service_params_kernel params;
+       int srvstate;
+@@ -190,7 +190,7 @@ static int vchiq_ioc_create_service(struct vchiq_instance *instance,
+       if (args->is_open) {
+               status = vchiq_open_service_internal(service, instance->pid);
+-              if (status != VCHIQ_SUCCESS) {
++              if (status) {
+                       vchiq_remove_service(instance, service->handle);
+                       return (status == VCHIQ_RETRY) ?
+                               -EINTR : -EIO;
+@@ -577,7 +577,7 @@ static long
+ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+ {
+       struct vchiq_instance *instance = file->private_data;
+-      enum vchiq_status status = VCHIQ_SUCCESS;
++      int status = 0;
+       struct vchiq_service *service = NULL;
+       long ret = 0;
+       int i, rc;
+@@ -598,12 +598,12 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+                                                          instance, &i))) {
+                       status = vchiq_remove_service(instance, service->handle);
+                       vchiq_service_put(service);
+-                      if (status != VCHIQ_SUCCESS)
++                      if (status)
+                               break;
+               }
+               service = NULL;
+-              if (status == VCHIQ_SUCCESS) {
++              if (!status) {
+                       /* Wake the completion thread and ask it to exit */
+                       instance->closing = 1;
+                       complete(&instance->insert_event);
+@@ -627,7 +627,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+               status = vchiq_connect_internal(instance->state, instance);
+               mutex_unlock(&instance->state->mutex);
+-              if (status == VCHIQ_SUCCESS)
++              if (!status)
+                       instance->connected = 1;
+               else
+                       vchiq_log_error(vchiq_arm_log_level,
+@@ -675,7 +675,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+                       status = (cmd == VCHIQ_IOC_CLOSE_SERVICE) ?
+                                vchiq_close_service(instance, service->handle) :
+                                vchiq_remove_service(instance, service->handle);
+-                      if (status != VCHIQ_SUCCESS)
++                      if (status)
+                               break;
+               }
+@@ -868,7 +868,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+                       ret = -EINTR;
+       }
+-      if ((status == VCHIQ_SUCCESS) && (ret < 0) && (ret != -EINTR) && (ret != -EWOULDBLOCK))
++      if (!status && (ret < 0) && (ret != -EINTR) && (ret != -EWOULDBLOCK))
+               vchiq_log_info(vchiq_arm_log_level,
+                              "  ioctl instance %pK, cmd %s -> status %d, %ld",
+                              instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ?
+diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+index 90eb4c5936f38..e6dea0c8eecd2 100644
+--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
++++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+@@ -560,7 +560,7 @@ static enum vchiq_status service_callback(struct vchiq_instance *vchiq_instance,
+       if (!instance) {
+               pr_err("Message callback passed NULL instance\n");
+-              return VCHIQ_SUCCESS;
++              return 0;
+       }
+       switch (reason) {
+@@ -644,7 +644,7 @@ static enum vchiq_status service_callback(struct vchiq_instance *vchiq_instance,
+               break;
+       }
+-      return VCHIQ_SUCCESS;
++      return 0;
+ }
+ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance,
+-- 
+2.39.5
+
diff --git a/queue-6.1/staging-vchiq_arm-make-vchiq_shutdown-never-fail.patch b/queue-6.1/staging-vchiq_arm-make-vchiq_shutdown-never-fail.patch
new file mode 100644 (file)
index 0000000..4939f20
--- /dev/null
@@ -0,0 +1,40 @@
+From 7475cd547e942efc8ad2914d12a5dfa4678426ea Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 15 Jul 2025 18:11:08 +0200
+Subject: staging: vchiq_arm: Make vchiq_shutdown never fail
+
+From: Stefan Wahren <wahrenst@gmx.net>
+
+[ Upstream commit f2b8ebfb867011ddbefbdf7b04ad62626cbc2afd ]
+
+Most of the users of vchiq_shutdown ignore the return value,
+which is bad because this could lead to resource leaks.
+So instead of changing all calls to vchiq_shutdown, it's easier
+to make vchiq_shutdown never fail.
+
+Fixes: 71bad7f08641 ("staging: add bcm2708 vchiq driver")
+Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
+Link: https://lore.kernel.org/r/20250715161108.3411-4-wahrenst@gmx.net
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+index 44ab7ea42fc85..3fafc94deb476 100644
+--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+@@ -714,8 +714,7 @@ enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance)
+       int status = 0;
+       struct vchiq_state *state = instance->state;
+-      if (mutex_lock_killable(&state->mutex))
+-              return -EAGAIN;
++      mutex_lock(&state->mutex);
+       /* Remove all services */
+       vchiq_shutdown_internal(state, instance);
+-- 
+2.39.5
+
diff --git a/queue-6.1/x86-hyperv-fix-usage-of-cpu_online_mask-to-get-valid.patch b/queue-6.1/x86-hyperv-fix-usage-of-cpu_online_mask-to-get-valid.patch
new file mode 100644 (file)
index 0000000..a8dd7cb
--- /dev/null
@@ -0,0 +1,56 @@
+From 9c530c695d4fc9e9ec3d62aaa27e2c9ed9ea2bc8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 3 Jul 2025 15:44:34 -0700
+Subject: x86/hyperv: Fix usage of cpu_online_mask to get valid cpu
+
+From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
+
+[ Upstream commit bb169f80ed5a156ec3405e0e49c6b8e9ae264718 ]
+
+Accessing cpu_online_mask here is problematic because the cpus read lock
+is not held in this context.
+
+However, cpu_online_mask isn't needed here since the effective affinity
+mask is guaranteed to be valid in this callback. So, just use
+cpumask_first() to get the cpu instead of ANDing it with cpus_online_mask
+unnecessarily.
+
+Fixes: e39397d1fd68 ("x86/hyperv: implement an MSI domain for root partition")
+Reported-by: Michael Kelley <mhklinux@outlook.com>
+Closes: https://lore.kernel.org/linux-hyperv/SN6PR02MB4157639630F8AD2D8FD8F52FD475A@SN6PR02MB4157.namprd02.prod.outlook.com/
+Suggested-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
+Reviewed-by: Michael Kelley <mhklinux@outlook.com>
+Link: https://lore.kernel.org/r/1751582677-30930-4-git-send-email-nunodasneves@linux.microsoft.com
+Signed-off-by: Wei Liu <wei.liu@kernel.org>
+Message-ID: <1751582677-30930-4-git-send-email-nunodasneves@linux.microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/x86/hyperv/irqdomain.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/arch/x86/hyperv/irqdomain.c b/arch/x86/hyperv/irqdomain.c
+index 42c70d28ef272..865ae4be233b3 100644
+--- a/arch/x86/hyperv/irqdomain.c
++++ b/arch/x86/hyperv/irqdomain.c
+@@ -192,7 +192,6 @@ static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
+       struct pci_dev *dev;
+       struct hv_interrupt_entry out_entry, *stored_entry;
+       struct irq_cfg *cfg = irqd_cfg(data);
+-      const cpumask_t *affinity;
+       int cpu;
+       u64 status;
+@@ -204,8 +203,7 @@ static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
+               return;
+       }
+-      affinity = irq_data_get_effective_affinity_mask(data);
+-      cpu = cpumask_first_and(affinity, cpu_online_mask);
++      cpu = cpumask_first(irq_data_get_effective_affinity_mask(data));
+       if (data->chip_data) {
+               /*
+-- 
+2.39.5
+