From: Greg Kroah-Hartman Date: Mon, 11 Jul 2022 06:40:03 +0000 (+0200) Subject: 5.18-stable patches X-Git-Tag: v4.9.323~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48dfe30f8d299c60bb5b92ec7a0fcb069cb875eb;p=thirdparty%2Fkernel%2Fstable-queue.git 5.18-stable patches added patches: dmaengine-imx-sdma-allow-imx8m-for-imx7-fw-revs.patch dmaengine-imx-sdma-only-restart-cyclic-channel-when-enabled.patch misc-rtsx_usb-fix-use-of-dma-mapped-buffer-for-usb-bulk-transfer.patch misc-rtsx_usb-set-return-value-in-rsp_buf-alloc-err-path.patch misc-rtsx_usb-use-separate-command-and-response-buffers.patch --- diff --git a/queue-5.18/dmaengine-imx-sdma-allow-imx8m-for-imx7-fw-revs.patch b/queue-5.18/dmaengine-imx-sdma-allow-imx8m-for-imx7-fw-revs.patch new file mode 100644 index 00000000000..fe0ec9a02d3 --- /dev/null +++ b/queue-5.18/dmaengine-imx-sdma-allow-imx8m-for-imx7-fw-revs.patch @@ -0,0 +1,43 @@ +From a7cd3cf0b2e5aaacfe5e02c472bd28e98e640be7 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Mon, 6 Jun 2022 17:10:34 +0100 +Subject: dmaengine: imx-sdma: Allow imx8m for imx7 FW revs + +From: Peter Robinson + +commit a7cd3cf0b2e5aaacfe5e02c472bd28e98e640be7 upstream. + +The revision of the imx-sdma IP that is in the i.MX8M series is the +same is that as that in the i.MX7 series but the imx7d MODULE_FIRMWARE +directive is wrapped in a condiditional which means it's not defined +when built for aarch64 SOC_IMX8M platforms and hence you get the +following errors when the driver loads on imx8m devices: + +imx-sdma 302c0000.dma-controller: Direct firmware load for imx/sdma/sdma-imx7d.bin failed with error -2 +imx-sdma 302c0000.dma-controller: external firmware not found, using ROM firmware + +Add the SOC_IMX8M into the check so the firmware can load on i.MX8. + +Fixes: 1474d48bd639 ("arm64: dts: imx8mq: Add SDMA nodes") +Fixes: 941acd566b18 ("dmaengine: imx-sdma: Only check ratio on parts that support 1:1") +Signed-off-by: Peter Robinson +Cc: stable@vger.kernel.org # v5.2+ +Reviewed-by: Fabio Estevam +Link: https://lore.kernel.org/r/20220606161034.3544803-1-pbrobinson@gmail.com +Signed-off-by: Vinod Koul +Signed-off-by: Greg Kroah-Hartman +--- + drivers/dma/imx-sdma.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/dma/imx-sdma.c ++++ b/drivers/dma/imx-sdma.c +@@ -2280,7 +2280,7 @@ MODULE_DESCRIPTION("i.MX SDMA driver"); + #if IS_ENABLED(CONFIG_SOC_IMX6Q) + MODULE_FIRMWARE("imx/sdma/sdma-imx6q.bin"); + #endif +-#if IS_ENABLED(CONFIG_SOC_IMX7D) ++#if IS_ENABLED(CONFIG_SOC_IMX7D) || IS_ENABLED(CONFIG_SOC_IMX8M) + MODULE_FIRMWARE("imx/sdma/sdma-imx7d.bin"); + #endif + MODULE_LICENSE("GPL"); diff --git a/queue-5.18/dmaengine-imx-sdma-only-restart-cyclic-channel-when-enabled.patch b/queue-5.18/dmaengine-imx-sdma-only-restart-cyclic-channel-when-enabled.patch new file mode 100644 index 00000000000..2408407fa99 --- /dev/null +++ b/queue-5.18/dmaengine-imx-sdma-only-restart-cyclic-channel-when-enabled.patch @@ -0,0 +1,38 @@ +From 09f7b80fac3e588b282ad26aabd7336d7d293efd Mon Sep 17 00:00:00 2001 +From: Sascha Hauer +Date: Fri, 17 Jun 2022 13:50:42 +0200 +Subject: dmaengine: imx-sdma: only restart cyclic channel when enabled + +From: Sascha Hauer + +commit 09f7b80fac3e588b282ad26aabd7336d7d293efd upstream. + +An interrupt for a channel might be pending even after struct +dma_device::device_terminate_all has been called. In that case the +recently introduced warning message "restart cyclic channel..." triggers +and the channel will be restarted. This is not desired as the channel +has just been stopped. Only restart the channel when we still have a +descriptor set for it (which will be set to NULL in +sdma_terminate_all()). + +Fixes: 5b215c28b9235 ("dmaengine: imx-sdma: restart cyclic channel if needed") +Cc: stable@vger.kernel.org +Signed-off-by: Sascha Hauer +Link: https://lore.kernel.org/r/20220617115042.4004062-1-s.hauer@pengutronix.de +Signed-off-by: Vinod Koul +Signed-off-by: Greg Kroah-Hartman +--- + drivers/dma/imx-sdma.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/dma/imx-sdma.c ++++ b/drivers/dma/imx-sdma.c +@@ -872,7 +872,7 @@ static void sdma_update_channel_loop(str + * SDMA stops cyclic channel when DMA request triggers a channel and no SDMA + * owned buffer is available (i.e. BD_DONE was set too late). + */ +- if (!is_sdma_channel_enabled(sdmac->sdma, sdmac->channel)) { ++ if (sdmac->desc && !is_sdma_channel_enabled(sdmac->sdma, sdmac->channel)) { + dev_warn(sdmac->sdma->dev, "restart cyclic channel %d\n", sdmac->channel); + sdma_enable_channel(sdmac->sdma, sdmac->channel); + } diff --git a/queue-5.18/misc-rtsx_usb-fix-use-of-dma-mapped-buffer-for-usb-bulk-transfer.patch b/queue-5.18/misc-rtsx_usb-fix-use-of-dma-mapped-buffer-for-usb-bulk-transfer.patch new file mode 100644 index 00000000000..9798f0827fc --- /dev/null +++ b/queue-5.18/misc-rtsx_usb-fix-use-of-dma-mapped-buffer-for-usb-bulk-transfer.patch @@ -0,0 +1,86 @@ +From eb7f8e28420372787933eec079735c35034bda7d Mon Sep 17 00:00:00 2001 +From: Shuah Khan +Date: Thu, 30 Jun 2022 20:32:55 -0600 +Subject: misc: rtsx_usb: fix use of dma mapped buffer for usb bulk transfer + +From: Shuah Khan + +commit eb7f8e28420372787933eec079735c35034bda7d upstream. + +rtsx_usb driver allocates coherent dma buffer for urb transfers. +This buffer is passed to usb_bulk_msg() and usb core tries to +map already mapped buffer running into a dma mapping error. + +xhci_hcd 0000:01:00.0: rejecting DMA map of vmalloc memory +WARNING: CPU: 1 PID: 279 at include/linux/dma-mapping.h:326 usb_ hcd_map_urb_for_dma+0x7d6/0x820 + +... + +xhci_map_urb_for_dma+0x291/0x4e0 +usb_hcd_submit_urb+0x199/0x12b0 +... +usb_submit_urb+0x3b8/0x9e0 +usb_start_wait_urb+0xe3/0x2d0 +usb_bulk_msg+0x115/0x240 +rtsx_usb_transfer_data+0x185/0x1a8 [rtsx_usb] +rtsx_usb_send_cmd+0xbb/0x123 [rtsx_usb] +rtsx_usb_write_register+0x12c/0x143 [rtsx_usb] +rtsx_usb_probe+0x226/0x4b2 [rtsx_usb] + +Fix it to use kmalloc() to get DMA-able memory region instead. + +Signed-off-by: Shuah Khan +Cc: stable +Link: https://lore.kernel.org/r/667d627d502e1ba9ff4f9b94966df3299d2d3c0d.1656642167.git.skhan@linuxfoundation.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/misc/cardreader/rtsx_usb.c | 13 +++++++------ + include/linux/rtsx_usb.h | 1 - + 2 files changed, 7 insertions(+), 7 deletions(-) + +--- a/drivers/misc/cardreader/rtsx_usb.c ++++ b/drivers/misc/cardreader/rtsx_usb.c +@@ -631,8 +631,7 @@ static int rtsx_usb_probe(struct usb_int + + ucr->pusb_dev = usb_dev; + +- ucr->iobuf = usb_alloc_coherent(ucr->pusb_dev, IOBUF_SIZE, +- GFP_KERNEL, &ucr->iobuf_dma); ++ ucr->iobuf = kmalloc(IOBUF_SIZE, GFP_KERNEL); + if (!ucr->iobuf) + return -ENOMEM; + +@@ -668,8 +667,9 @@ static int rtsx_usb_probe(struct usb_int + + out_init_fail: + usb_set_intfdata(ucr->pusb_intf, NULL); +- usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf, +- ucr->iobuf_dma); ++ kfree(ucr->iobuf); ++ ucr->iobuf = NULL; ++ ucr->cmd_buf = ucr->rsp_buf = NULL; + return ret; + } + +@@ -682,8 +682,9 @@ static void rtsx_usb_disconnect(struct u + mfd_remove_devices(&intf->dev); + + usb_set_intfdata(ucr->pusb_intf, NULL); +- usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf, +- ucr->iobuf_dma); ++ kfree(ucr->iobuf); ++ ucr->iobuf = NULL; ++ ucr->cmd_buf = ucr->rsp_buf = NULL; + } + + #ifdef CONFIG_PM +--- a/include/linux/rtsx_usb.h ++++ b/include/linux/rtsx_usb.h +@@ -55,7 +55,6 @@ struct rtsx_ucr { + struct usb_interface *pusb_intf; + struct usb_sg_request current_sg; + unsigned char *iobuf; +- dma_addr_t iobuf_dma; + + struct timer_list sg_timer; + struct mutex dev_mutex; diff --git a/queue-5.18/misc-rtsx_usb-set-return-value-in-rsp_buf-alloc-err-path.patch b/queue-5.18/misc-rtsx_usb-set-return-value-in-rsp_buf-alloc-err-path.patch new file mode 100644 index 00000000000..1dcc9d48367 --- /dev/null +++ b/queue-5.18/misc-rtsx_usb-set-return-value-in-rsp_buf-alloc-err-path.patch @@ -0,0 +1,50 @@ +From 2cd37c2e72449a7add6da1183d20a6247d6db111 Mon Sep 17 00:00:00 2001 +From: Shuah Khan +Date: Fri, 1 Jul 2022 10:53:52 -0600 +Subject: misc: rtsx_usb: set return value in rsp_buf alloc err path + +From: Shuah Khan + +commit 2cd37c2e72449a7add6da1183d20a6247d6db111 upstream. + +Set return value in rsp_buf alloc error path before going to +error handling. + +drivers/misc/cardreader/rtsx_usb.c:639:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] + if (!ucr->rsp_buf) + ^~~~~~~~~~~~~ + drivers/misc/cardreader/rtsx_usb.c:678:9: note: uninitialized use occurs here + return ret; + ^~~ + drivers/misc/cardreader/rtsx_usb.c:639:2: note: remove the 'if' if its condition is always false + if (!ucr->rsp_buf) + ^~~~~~~~~~~~~~~~~~ + drivers/misc/cardreader/rtsx_usb.c:622:9: note: initialize the variable 'ret' to silence this warning + int ret; + ^ + = 0 + +Fixes: 3776c7855985 ("misc: rtsx_usb: use separate command and response buffers") +Reported-by: kernel test robot +Cc: stable +Signed-off-by: Shuah Khan +Link: https://lore.kernel.org/r/20220701165352.15687-1-skhan@linuxfoundation.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/misc/cardreader/rtsx_usb.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/misc/cardreader/rtsx_usb.c ++++ b/drivers/misc/cardreader/rtsx_usb.c +@@ -636,8 +636,10 @@ static int rtsx_usb_probe(struct usb_int + return -ENOMEM; + + ucr->rsp_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL); +- if (!ucr->rsp_buf) ++ if (!ucr->rsp_buf) { ++ ret = -ENOMEM; + goto out_free_cmd_buf; ++ } + + usb_set_intfdata(intf, ucr); + diff --git a/queue-5.18/misc-rtsx_usb-use-separate-command-and-response-buffers.patch b/queue-5.18/misc-rtsx_usb-use-separate-command-and-response-buffers.patch new file mode 100644 index 00000000000..028ac8db789 --- /dev/null +++ b/queue-5.18/misc-rtsx_usb-use-separate-command-and-response-buffers.patch @@ -0,0 +1,89 @@ +From 3776c78559853fd151be7c41e369fd076fb679d5 Mon Sep 17 00:00:00 2001 +From: Shuah Khan +Date: Thu, 30 Jun 2022 20:32:56 -0600 +Subject: misc: rtsx_usb: use separate command and response buffers + +From: Shuah Khan + +commit 3776c78559853fd151be7c41e369fd076fb679d5 upstream. + +rtsx_usb uses same buffer for command and response. There could +be a potential conflict using the same buffer for both especially +if retries and timeouts are involved. + +Use separate command and response buffers to avoid conflicts. + +Signed-off-by: Shuah Khan +Cc: stable +Link: https://lore.kernel.org/r/07e3721804ff07aaab9ef5b39a5691d0718b9ade.1656642167.git.skhan@linuxfoundation.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/misc/cardreader/rtsx_usb.c | 26 +++++++++++++++++--------- + include/linux/rtsx_usb.h | 1 - + 2 files changed, 17 insertions(+), 10 deletions(-) + +--- a/drivers/misc/cardreader/rtsx_usb.c ++++ b/drivers/misc/cardreader/rtsx_usb.c +@@ -631,15 +631,18 @@ static int rtsx_usb_probe(struct usb_int + + ucr->pusb_dev = usb_dev; + +- ucr->iobuf = kmalloc(IOBUF_SIZE, GFP_KERNEL); +- if (!ucr->iobuf) ++ ucr->cmd_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL); ++ if (!ucr->cmd_buf) + return -ENOMEM; + ++ ucr->rsp_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL); ++ if (!ucr->rsp_buf) ++ goto out_free_cmd_buf; ++ + usb_set_intfdata(intf, ucr); + + ucr->vendor_id = id->idVendor; + ucr->product_id = id->idProduct; +- ucr->cmd_buf = ucr->rsp_buf = ucr->iobuf; + + mutex_init(&ucr->dev_mutex); + +@@ -667,9 +670,11 @@ static int rtsx_usb_probe(struct usb_int + + out_init_fail: + usb_set_intfdata(ucr->pusb_intf, NULL); +- kfree(ucr->iobuf); +- ucr->iobuf = NULL; +- ucr->cmd_buf = ucr->rsp_buf = NULL; ++ kfree(ucr->rsp_buf); ++ ucr->rsp_buf = NULL; ++out_free_cmd_buf: ++ kfree(ucr->cmd_buf); ++ ucr->cmd_buf = NULL; + return ret; + } + +@@ -682,9 +687,12 @@ static void rtsx_usb_disconnect(struct u + mfd_remove_devices(&intf->dev); + + usb_set_intfdata(ucr->pusb_intf, NULL); +- kfree(ucr->iobuf); +- ucr->iobuf = NULL; +- ucr->cmd_buf = ucr->rsp_buf = NULL; ++ ++ kfree(ucr->cmd_buf); ++ ucr->cmd_buf = NULL; ++ ++ kfree(ucr->rsp_buf); ++ ucr->rsp_buf = NULL; + } + + #ifdef CONFIG_PM +--- a/include/linux/rtsx_usb.h ++++ b/include/linux/rtsx_usb.h +@@ -54,7 +54,6 @@ struct rtsx_ucr { + struct usb_device *pusb_dev; + struct usb_interface *pusb_intf; + struct usb_sg_request current_sg; +- unsigned char *iobuf; + + struct timer_list sg_timer; + struct mutex dev_mutex; diff --git a/queue-5.18/series b/queue-5.18/series index 8af1db04512..39efbd03783 100644 --- a/queue-5.18/series +++ b/queue-5.18/series @@ -95,3 +95,8 @@ i2c-cadence-unregister-the-clk-notifier-in-error-pat.patch net-sched-act_api-add-extack-to-offload_act_setup-ca.patch net-sched-act_police-add-extack-messages-for-offload.patch net-sched-act_police-allow-continue-action-offload.patch +dmaengine-imx-sdma-allow-imx8m-for-imx7-fw-revs.patch +dmaengine-imx-sdma-only-restart-cyclic-channel-when-enabled.patch +misc-rtsx_usb-fix-use-of-dma-mapped-buffer-for-usb-bulk-transfer.patch +misc-rtsx_usb-use-separate-command-and-response-buffers.patch +misc-rtsx_usb-set-return-value-in-rsp_buf-alloc-err-path.patch