From: Sasha Levin Date: Tue, 3 Oct 2023 00:58:34 +0000 (-0400) Subject: Fixes for 5.15 X-Git-Tag: v6.5.6~61 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=43bfd0401615611113be580589b1b6ff779594be;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.15 Signed-off-by: Sasha Levin --- diff --git a/queue-5.15/asoc-fsl-imx-pcm-rpmsg-add-sndrv_pcm_info_batch-flag.patch b/queue-5.15/asoc-fsl-imx-pcm-rpmsg-add-sndrv_pcm_info_batch-flag.patch new file mode 100644 index 00000000000..d4367a4a1d5 --- /dev/null +++ b/queue-5.15/asoc-fsl-imx-pcm-rpmsg-add-sndrv_pcm_info_batch-flag.patch @@ -0,0 +1,48 @@ +From 90474b90330a6c55545510cb91b6ef0cda3e212b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 11 Sep 2023 14:38:07 +0800 +Subject: ASoC: fsl: imx-pcm-rpmsg: Add SNDRV_PCM_INFO_BATCH flag + +From: Shengjiu Wang + +[ Upstream commit 2f9426905a63be7ccf8cd10109caf1848aa0993a ] + +The rpmsg pcm device is a device which should support +double buffering. + +Found this issue with pipewire. When there is no +SNDRV_PCM_INFO_BATCH flag in driver, the pipewire will +set headroom to be zero, and because rpmsg pcm device +don't support residue report, when the latency setting +is small, the "delay" always larger than "target" in +alsa-pcm.c, that reading next period data is not +scheduled on time. + +With SNDRV_PCM_INFO_BATCH flag in driver, the pipewire +will select a smaller period size for device, then +the task of reading next period data will be scheduled +on time. + +Signed-off-by: Shengjiu Wang +Link: https://lore.kernel.org/r/1694414287-13291-1-git-send-email-shengjiu.wang@nxp.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/fsl/imx-pcm-rpmsg.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c +index 35049043e5322..933bac7ea1864 100644 +--- a/sound/soc/fsl/imx-pcm-rpmsg.c ++++ b/sound/soc/fsl/imx-pcm-rpmsg.c +@@ -19,6 +19,7 @@ + static struct snd_pcm_hardware imx_rpmsg_pcm_hardware = { + .info = SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | ++ SNDRV_PCM_INFO_BATCH | + SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP | +-- +2.40.1 + diff --git a/queue-5.15/asoc-imx-rpmsg-set-ignore_pmdown_time-for-dai_link.patch b/queue-5.15/asoc-imx-rpmsg-set-ignore_pmdown_time-for-dai_link.patch new file mode 100644 index 00000000000..fa86bb8335b --- /dev/null +++ b/queue-5.15/asoc-imx-rpmsg-set-ignore_pmdown_time-for-dai_link.patch @@ -0,0 +1,49 @@ +From 618c2bdc30e3171e8f69dfef487a6fd657128358 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 13 Sep 2023 18:26:56 +0800 +Subject: ASoC: imx-rpmsg: Set ignore_pmdown_time for dai_link + +From: Chancel Liu + +[ Upstream commit fac58baf8fcfcd7481e8f6d60206ce2a47c1476c ] + +i.MX rpmsg sound cards work on codec slave mode. MCLK will be disabled +by CPU DAI driver in hw_free(). Some codec requires MCLK present at +power up/down sequence. So need to set ignore_pmdown_time to power down +codec immediately before MCLK is turned off. + +Take WM8962 as an example, if MCLK is disabled before DAPM power down +playback stream, FIFO error will arise in WM8962 which will have bad +impact on playback next. + +Signed-off-by: Chancel Liu +Acked-by: Shengjiu Wang +Link: https://lore.kernel.org/r/20230913102656.2966757-1-chancel.liu@nxp.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/fsl/imx-rpmsg.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c +index f96fe4ff8425b..d208b05051fd5 100644 +--- a/sound/soc/fsl/imx-rpmsg.c ++++ b/sound/soc/fsl/imx-rpmsg.c +@@ -66,6 +66,14 @@ static int imx_rpmsg_probe(struct platform_device *pdev) + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS; + ++ /* ++ * i.MX rpmsg sound cards work on codec slave mode. MCLK will be ++ * disabled by CPU DAI driver in hw_free(). Some codec requires MCLK ++ * present at power up/down sequence. So need to set ignore_pmdown_time ++ * to power down codec immediately before MCLK is turned off. ++ */ ++ data->dai.ignore_pmdown_time = 1; ++ + /* Optional codec node */ + ret = of_parse_phandle_with_fixed_args(np, "audio-codec", 0, 0, &args); + if (ret) { +-- +2.40.1 + diff --git a/queue-5.15/ata-libata-eh-do-not-clear-ata_pflag_eh_pending-in-a.patch b/queue-5.15/ata-libata-eh-do-not-clear-ata_pflag_eh_pending-in-a.patch new file mode 100644 index 00000000000..ebbdf0f08aa --- /dev/null +++ b/queue-5.15/ata-libata-eh-do-not-clear-ata_pflag_eh_pending-in-a.patch @@ -0,0 +1,123 @@ +From 04fd53e07d1542d069f91b44ce70454366b68f88 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 14 Sep 2023 00:19:16 +0200 +Subject: ata: libata-eh: do not clear ATA_PFLAG_EH_PENDING in ata_eh_reset() + +From: Niklas Cassel + +[ Upstream commit 80cc944eca4f0baa9c381d0706f3160e491437f2 ] + +ata_scsi_port_error_handler() starts off by clearing ATA_PFLAG_EH_PENDING, +before calling ap->ops->error_handler() (without holding the ap->lock). + +If an error IRQ is received while ap->ops->error_handler() is running, +the irq handler will set ATA_PFLAG_EH_PENDING. + +Once ap->ops->error_handler() returns, ata_scsi_port_error_handler() +checks if ATA_PFLAG_EH_PENDING is set, and if it is, another iteration +of ATA EH is performed. + +The problem is that ATA_PFLAG_EH_PENDING is not only cleared by +ata_scsi_port_error_handler(), it is also cleared by ata_eh_reset(). + +ata_eh_reset() is called by ap->ops->error_handler(). This additional +clearing done by ata_eh_reset() breaks the whole retry logic in +ata_scsi_port_error_handler(). Thus, if an error IRQ is received while +ap->ops->error_handler() is running, the port will currently remain +frozen and will never get re-enabled. + +The additional clearing in ata_eh_reset() was introduced in commit +1e641060c4b5 ("libata: clear eh_info on reset completion"). + +Looking at the original error report: +https://marc.info/?l=linux-ide&m=124765325828495&w=2 + +We can see the following happening: +[ 1.074659] ata3: XXX port freeze +[ 1.074700] ata3: XXX hardresetting link, stopping engine +[ 1.074746] ata3: XXX flipping SControl + +[ 1.411471] ata3: XXX irq_stat=400040 CONN|PHY +[ 1.411475] ata3: XXX port freeze + +[ 1.420049] ata3: XXX starting engine +[ 1.420096] ata3: XXX rc=0, class=1 +[ 1.420142] ata3: XXX clearing IRQs for thawing +[ 1.420188] ata3: XXX port thawed +[ 1.420234] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300) + +We are not supposed to be able to receive an error IRQ while the port is +frozen (PxIE is set to 0, i.e. all IRQs for the port are disabled). + +AHCI 1.3.1 section 10.7.1.1 First Tier (IS Register) states: +"Each bit location can be thought of as reporting a '1' if the virtual +"interrupt line" for that port is indicating it wishes to generate an +interrupt. That is, if a port has one or more interrupt status bit set, +and the enables for those status bits are set, then this bit shall be set." + +Additionally, AHCI state P:ComInit clearly shows that the state machine +will only jump to P:ComInitSetIS (which sets IS.IPS(x) to '1'), if PxIE.PCE +is set to '1'. In our case, PxIE is set to 0, so IS.IPS(x) won't get set. + +So IS.IPS(x) only gets set if PxIS and PxIE is set. + +AHCI 1.3.1 section 10.7.1.1 First Tier (IS Register) also states: +"The bits in this register are read/write clear. It is set by the level of +the virtual interrupt line being a set, and cleared by a write of '1' from +the software." + +So if IS.IPS(x) is set, you need to explicitly clear it by writing a 1 to +IS.IPS(x) for that port. + +Since PxIE is cleared, the only way to get an interrupt while the port is +frozen, is if IS.IPS(x) is set, and the only way IS.IPS(x) can be set when +the port is frozen, is if it was set before the port was frozen. + +However, since commit 737dd811a3db ("ata: libahci: clear pending interrupt +status"), we clear both PxIS and IS.IPS(x) after freezing the port, but +before the COMRESET, so the problem that commit 1e641060c4b5 ("libata: +clear eh_info on reset completion") fixed can no longer happen. + +Thus, revert commit 1e641060c4b5 ("libata: clear eh_info on reset +completion"), so that the retry logic in ata_scsi_port_error_handler() +works once again. (The retry logic is still needed, since we can still +get an error IRQ _after_ the port has been thawed, but before +ata_scsi_port_error_handler() takes the ap->lock in order to check +if ATA_PFLAG_EH_PENDING is set.) + +Signed-off-by: Niklas Cassel +Signed-off-by: Damien Le Moal +Signed-off-by: Sasha Levin +--- + drivers/ata/libata-eh.c | 13 +++---------- + 1 file changed, 3 insertions(+), 10 deletions(-) + +diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c +index 8350abc172908..8444832008703 100644 +--- a/drivers/ata/libata-eh.c ++++ b/drivers/ata/libata-eh.c +@@ -2703,18 +2703,11 @@ int ata_eh_reset(struct ata_link *link, int classify, + postreset(slave, classes); + } + +- /* +- * Some controllers can't be frozen very well and may set spurious +- * error conditions during reset. Clear accumulated error +- * information and re-thaw the port if frozen. As reset is the +- * final recovery action and we cross check link onlineness against +- * device classification later, no hotplug event is lost by this. +- */ ++ /* clear cached SError */ + spin_lock_irqsave(link->ap->lock, flags); +- memset(&link->eh_info, 0, sizeof(link->eh_info)); ++ link->eh_info.serror = 0; + if (slave) +- memset(&slave->eh_info, 0, sizeof(link->eh_info)); +- ap->pflags &= ~ATA_PFLAG_EH_PENDING; ++ slave->eh_info.serror = 0; + spin_unlock_irqrestore(link->ap->lock, flags); + + if (ap->pflags & ATA_PFLAG_FROZEN) +-- +2.40.1 + diff --git a/queue-5.15/bpf-clarify-error-expectations-from-bpf_clone_redire.patch b/queue-5.15/bpf-clarify-error-expectations-from-bpf_clone_redire.patch new file mode 100644 index 00000000000..a506609748f --- /dev/null +++ b/queue-5.15/bpf-clarify-error-expectations-from-bpf_clone_redire.patch @@ -0,0 +1,63 @@ +From 1b960d6dfb0d2e67de3e88e9b7c2299290117c06 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 11 Sep 2023 12:47:30 -0700 +Subject: bpf: Clarify error expectations from bpf_clone_redirect + +From: Stanislav Fomichev + +[ Upstream commit 7cb779a6867fea00b4209bcf6de2f178a743247d ] + +Commit 151e887d8ff9 ("veth: Fixing transmit return status for dropped +packets") exposed the fact that bpf_clone_redirect is capable of +returning raw NET_XMIT_XXX return codes. + +This is in the conflict with its UAPI doc which says the following: +"0 on success, or a negative error in case of failure." + +Update the UAPI to reflect the fact that bpf_clone_redirect can +return positive error numbers, but don't explicitly define +their meaning. + +Reported-by: Daniel Borkmann +Signed-off-by: Stanislav Fomichev +Signed-off-by: Daniel Borkmann +Link: https://lore.kernel.org/bpf/20230911194731.286342-1-sdf@google.com +Signed-off-by: Sasha Levin +--- + include/uapi/linux/bpf.h | 4 +++- + tools/include/uapi/linux/bpf.h | 4 +++- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h +index a887e582f0e78..9fb06a511250f 100644 +--- a/include/uapi/linux/bpf.h ++++ b/include/uapi/linux/bpf.h +@@ -1762,7 +1762,9 @@ union bpf_attr { + * performed again, if the helper is used in combination with + * direct packet access. + * Return +- * 0 on success, or a negative error in case of failure. ++ * 0 on success, or a negative error in case of failure. Positive ++ * error indicates a potential drop or congestion in the target ++ * device. The particular positive error codes are not defined. + * + * u64 bpf_get_current_pid_tgid(void) + * Return +diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h +index 8330e3ca8fbfb..1e3e3f16eabcb 100644 +--- a/tools/include/uapi/linux/bpf.h ++++ b/tools/include/uapi/linux/bpf.h +@@ -1762,7 +1762,9 @@ union bpf_attr { + * performed again, if the helper is used in combination with + * direct packet access. + * Return +- * 0 on success, or a negative error in case of failure. ++ * 0 on success, or a negative error in case of failure. Positive ++ * error indicates a potential drop or congestion in the target ++ * device. The particular positive error codes are not defined. + * + * u64 bpf_get_current_pid_tgid(void) + * Return +-- +2.40.1 + diff --git a/queue-5.15/btrfs-improve-error-message-after-failure-to-add-del.patch b/queue-5.15/btrfs-improve-error-message-after-failure-to-add-del.patch new file mode 100644 index 00000000000..50254fcb8a6 --- /dev/null +++ b/queue-5.15/btrfs-improve-error-message-after-failure-to-add-del.patch @@ -0,0 +1,53 @@ +From 42774ceb524b47d7ec2e1f47d71f00678184b884 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 28 Aug 2023 09:06:42 +0100 +Subject: btrfs: improve error message after failure to add delayed dir index + item + +From: Filipe Manana + +[ Upstream commit 91bfe3104b8db0310f76f2dcb6aacef24c889366 ] + +If we fail to add a delayed dir index item because there's already another +item with the same index number, we print an error message (and then BUG). +However that message isn't very helpful to debug anything because we don't +know what's the index number and what are the values of index counters in +the inode and its delayed inode (index_cnt fields of struct btrfs_inode +and struct btrfs_delayed_node). + +So update the error message to include the index number and counters. + +We actually had a recent case where this issue was hit by a syzbot report +(see the link below). + +Link: https://lore.kernel.org/linux-btrfs/00000000000036e1290603e097e0@google.com/ +Reviewed-by: Qu Wenruo +Signed-off-by: Filipe Manana +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Sasha Levin +--- + fs/btrfs/delayed-inode.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c +index e6872d65c0e25..fd951aeaeac5a 100644 +--- a/fs/btrfs/delayed-inode.c ++++ b/fs/btrfs/delayed-inode.c +@@ -1401,9 +1401,10 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans, + ret = __btrfs_add_delayed_insertion_item(delayed_node, delayed_item); + if (unlikely(ret)) { + btrfs_err(trans->fs_info, +- "err add delayed dir index item(name: %.*s) into the insertion tree of the delayed node(root id: %llu, inode id: %llu, errno: %d)", +- name_len, name, delayed_node->root->root_key.objectid, +- delayed_node->inode_id, ret); ++"error adding delayed dir index item, name: %.*s, index: %llu, root: %llu, dir: %llu, dir->index_cnt: %llu, delayed_node->index_cnt: %llu, error: %d", ++ name_len, name, index, btrfs_root_id(delayed_node->root), ++ delayed_node->inode_id, dir->index_cnt, ++ delayed_node->index_cnt, ret); + BUG(); + } + mutex_unlock(&delayed_node->mutex); +-- +2.40.1 + diff --git a/queue-5.15/dma-debug-don-t-call-__dma_entry_alloc_check_leak-un.patch b/queue-5.15/dma-debug-don-t-call-__dma_entry_alloc_check_leak-un.patch new file mode 100644 index 00000000000..a03d68c76f8 --- /dev/null +++ b/queue-5.15/dma-debug-don-t-call-__dma_entry_alloc_check_leak-un.patch @@ -0,0 +1,211 @@ +From c00deaf4f2beadd2f11c5f2df669a5f6e0cf684a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 16 Aug 2023 11:32:21 +0900 +Subject: dma-debug: don't call __dma_entry_alloc_check_leak() under + free_entries_lock + +From: Sergey Senozhatsky + +[ Upstream commit fb5a4315591dae307a65fc246ca80b5159d296e1 ] + +__dma_entry_alloc_check_leak() calls into printk -> serial console +output (qcom geni) and grabs port->lock under free_entries_lock +spin lock, which is a reverse locking dependency chain as qcom_geni +IRQ handler can call into dma-debug code and grab free_entries_lock +under port->lock. + +Move __dma_entry_alloc_check_leak() call out of free_entries_lock +scope so that we don't acquire serial console's port->lock under it. + +Trimmed-down lockdep splat: + + The existing dependency chain (in reverse order) is: + + -> #2 (free_entries_lock){-.-.}-{2:2}: + _raw_spin_lock_irqsave+0x60/0x80 + dma_entry_alloc+0x38/0x110 + debug_dma_map_page+0x60/0xf8 + dma_map_page_attrs+0x1e0/0x230 + dma_map_single_attrs.constprop.0+0x6c/0xc8 + geni_se_rx_dma_prep+0x40/0xcc + qcom_geni_serial_isr+0x310/0x510 + __handle_irq_event_percpu+0x110/0x244 + handle_irq_event_percpu+0x20/0x54 + handle_irq_event+0x50/0x88 + handle_fasteoi_irq+0xa4/0xcc + handle_irq_desc+0x28/0x40 + generic_handle_domain_irq+0x24/0x30 + gic_handle_irq+0xc4/0x148 + do_interrupt_handler+0xa4/0xb0 + el1_interrupt+0x34/0x64 + el1h_64_irq_handler+0x18/0x24 + el1h_64_irq+0x64/0x68 + arch_local_irq_enable+0x4/0x8 + ____do_softirq+0x18/0x24 + ... + + -> #1 (&port_lock_key){-.-.}-{2:2}: + _raw_spin_lock_irqsave+0x60/0x80 + qcom_geni_serial_console_write+0x184/0x1dc + console_flush_all+0x344/0x454 + console_unlock+0x94/0xf0 + vprintk_emit+0x238/0x24c + vprintk_default+0x3c/0x48 + vprintk+0xb4/0xbc + _printk+0x68/0x90 + register_console+0x230/0x38c + uart_add_one_port+0x338/0x494 + qcom_geni_serial_probe+0x390/0x424 + platform_probe+0x70/0xc0 + really_probe+0x148/0x280 + __driver_probe_device+0xfc/0x114 + driver_probe_device+0x44/0x100 + __device_attach_driver+0x64/0xdc + bus_for_each_drv+0xb0/0xd8 + __device_attach+0xe4/0x140 + device_initial_probe+0x1c/0x28 + bus_probe_device+0x44/0xb0 + device_add+0x538/0x668 + of_device_add+0x44/0x50 + of_platform_device_create_pdata+0x94/0xc8 + of_platform_bus_create+0x270/0x304 + of_platform_populate+0xac/0xc4 + devm_of_platform_populate+0x60/0xac + geni_se_probe+0x154/0x160 + platform_probe+0x70/0xc0 + ... + + -> #0 (console_owner){-...}-{0:0}: + __lock_acquire+0xdf8/0x109c + lock_acquire+0x234/0x284 + console_flush_all+0x330/0x454 + console_unlock+0x94/0xf0 + vprintk_emit+0x238/0x24c + vprintk_default+0x3c/0x48 + vprintk+0xb4/0xbc + _printk+0x68/0x90 + dma_entry_alloc+0xb4/0x110 + debug_dma_map_sg+0xdc/0x2f8 + __dma_map_sg_attrs+0xac/0xe4 + dma_map_sgtable+0x30/0x4c + get_pages+0x1d4/0x1e4 [msm] + msm_gem_pin_pages_locked+0x38/0xac [msm] + msm_gem_pin_vma_locked+0x58/0x88 [msm] + msm_ioctl_gem_submit+0xde4/0x13ac [msm] + drm_ioctl_kernel+0xe0/0x15c + drm_ioctl+0x2e8/0x3f4 + vfs_ioctl+0x30/0x50 + ... + + Chain exists of: + console_owner --> &port_lock_key --> free_entries_lock + + Possible unsafe locking scenario: + + CPU0 CPU1 + ---- ---- + lock(free_entries_lock); + lock(&port_lock_key); + lock(free_entries_lock); + lock(console_owner); + + *** DEADLOCK *** + + Call trace: + dump_backtrace+0xb4/0xf0 + show_stack+0x20/0x30 + dump_stack_lvl+0x60/0x84 + dump_stack+0x18/0x24 + print_circular_bug+0x1cc/0x234 + check_noncircular+0x78/0xac + __lock_acquire+0xdf8/0x109c + lock_acquire+0x234/0x284 + console_flush_all+0x330/0x454 + console_unlock+0x94/0xf0 + vprintk_emit+0x238/0x24c + vprintk_default+0x3c/0x48 + vprintk+0xb4/0xbc + _printk+0x68/0x90 + dma_entry_alloc+0xb4/0x110 + debug_dma_map_sg+0xdc/0x2f8 + __dma_map_sg_attrs+0xac/0xe4 + dma_map_sgtable+0x30/0x4c + get_pages+0x1d4/0x1e4 [msm] + msm_gem_pin_pages_locked+0x38/0xac [msm] + msm_gem_pin_vma_locked+0x58/0x88 [msm] + msm_ioctl_gem_submit+0xde4/0x13ac [msm] + drm_ioctl_kernel+0xe0/0x15c + drm_ioctl+0x2e8/0x3f4 + vfs_ioctl+0x30/0x50 + ... + +Reported-by: Rob Clark +Signed-off-by: Sergey Senozhatsky +Acked-by: Robin Murphy +Signed-off-by: Christoph Hellwig +Signed-off-by: Sasha Levin +--- + kernel/dma/debug.c | 20 +++++++++++++++----- + 1 file changed, 15 insertions(+), 5 deletions(-) + +diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c +index 2caafd13f8aac..1f9a8cee42241 100644 +--- a/kernel/dma/debug.c ++++ b/kernel/dma/debug.c +@@ -605,15 +605,19 @@ static struct dma_debug_entry *__dma_entry_alloc(void) + return entry; + } + +-static void __dma_entry_alloc_check_leak(void) ++/* ++ * This should be called outside of free_entries_lock scope to avoid potential ++ * deadlocks with serial consoles that use DMA. ++ */ ++static void __dma_entry_alloc_check_leak(u32 nr_entries) + { +- u32 tmp = nr_total_entries % nr_prealloc_entries; ++ u32 tmp = nr_entries % nr_prealloc_entries; + + /* Shout each time we tick over some multiple of the initial pool */ + if (tmp < DMA_DEBUG_DYNAMIC_ENTRIES) { + pr_info("dma_debug_entry pool grown to %u (%u00%%)\n", +- nr_total_entries, +- (nr_total_entries / nr_prealloc_entries)); ++ nr_entries, ++ (nr_entries / nr_prealloc_entries)); + } + } + +@@ -624,8 +628,10 @@ static void __dma_entry_alloc_check_leak(void) + */ + static struct dma_debug_entry *dma_entry_alloc(void) + { ++ bool alloc_check_leak = false; + struct dma_debug_entry *entry; + unsigned long flags; ++ u32 nr_entries; + + spin_lock_irqsave(&free_entries_lock, flags); + if (num_free_entries == 0) { +@@ -635,13 +641,17 @@ static struct dma_debug_entry *dma_entry_alloc(void) + pr_err("debugging out of memory - disabling\n"); + return NULL; + } +- __dma_entry_alloc_check_leak(); ++ alloc_check_leak = true; ++ nr_entries = nr_total_entries; + } + + entry = __dma_entry_alloc(); + + spin_unlock_irqrestore(&free_entries_lock, flags); + ++ if (alloc_check_leak) ++ __dma_entry_alloc_check_leak(nr_entries); ++ + #ifdef CONFIG_STACKTRACE + entry->stack_len = stack_trace_save(entry->stack_entries, + ARRAY_SIZE(entry->stack_entries), +-- +2.40.1 + diff --git a/queue-5.15/drm-amd-display-don-t-check-registers-if-using-aux-b.patch b/queue-5.15/drm-amd-display-don-t-check-registers-if-using-aux-b.patch new file mode 100644 index 00000000000..53a469e5a4d --- /dev/null +++ b/queue-5.15/drm-amd-display-don-t-check-registers-if-using-aux-b.patch @@ -0,0 +1,46 @@ +From f140afece033de703f7bdb007e3c7c1e0548da55 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 17 Aug 2023 14:04:26 -0400 +Subject: drm/amd/display: Don't check registers, if using AUX BL control + +From: Swapnil Patel + +[ Upstream commit f5b2c10b57615828b531bb0ae56bd6325a41167e ] + +[Why] +Currently the driver looks DCN registers to access if BL is on or not. +This check is not valid if we are using AUX based brightness control. +This causes driver to not send out "backlight off" command during power off +sequence as it already thinks it is off. + +[How] +Only check DCN registers if we aren't using AUX based brightness control. + +Reviewed-by: Wenjing Liu +Acked-by: Stylon Wang +Signed-off-by: Swapnil Patel +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +index 52142d272c868..87825818d43ec 100644 +--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c ++++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +@@ -980,7 +980,9 @@ void dce110_edp_backlight_control( + return; + } + +- if (link->panel_cntl) { ++ if (link->panel_cntl && !(link->dpcd_sink_ext_caps.bits.oled || ++ link->dpcd_sink_ext_caps.bits.hdr_aux_backlight_control == 1 || ++ link->dpcd_sink_ext_caps.bits.sdr_aux_backlight_control == 1)) { + bool is_backlight_on = link->panel_cntl->funcs->is_panel_backlight_on(link->panel_cntl); + + if ((enable && is_backlight_on) || (!enable && !is_backlight_on)) { +-- +2.40.1 + diff --git a/queue-5.15/drm-amdgpu-handle-null-atom-context-in-vbios-info-io.patch b/queue-5.15/drm-amdgpu-handle-null-atom-context-in-vbios-info-io.patch new file mode 100644 index 00000000000..3e2573a3e5e --- /dev/null +++ b/queue-5.15/drm-amdgpu-handle-null-atom-context-in-vbios-info-io.patch @@ -0,0 +1,54 @@ +From da5485cf70b60410f054705f404d98876b96212c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 5 Sep 2023 10:13:51 -0400 +Subject: drm/amdgpu: Handle null atom context in VBIOS info ioctl + +From: David Francis + +[ Upstream commit 5e7e82254270c8cf8b107451c5de01cee2f135ae ] + +On some APU systems, there is no atom context and so the +atom_context struct is null. + +Add a check to the VBIOS_INFO branch of amdgpu_info_ioctl +to handle this case, returning all zeroes. + +Reviewed-by: Alex Deucher +Signed-off-by: David Francis +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 17 +++++++++++------ + 1 file changed, 11 insertions(+), 6 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +index e8485b1f02ed6..70d49b998ee9e 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +@@ -926,12 +926,17 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) + struct atom_context *atom_context; + + atom_context = adev->mode_info.atom_context; +- memcpy(vbios_info.name, atom_context->name, sizeof(atom_context->name)); +- memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, sizeof(atom_context->vbios_pn)); +- vbios_info.version = atom_context->version; +- memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str, +- sizeof(atom_context->vbios_ver_str)); +- memcpy(vbios_info.date, atom_context->date, sizeof(atom_context->date)); ++ if (atom_context) { ++ memcpy(vbios_info.name, atom_context->name, ++ sizeof(atom_context->name)); ++ memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, ++ sizeof(atom_context->vbios_pn)); ++ vbios_info.version = atom_context->version; ++ memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str, ++ sizeof(atom_context->vbios_ver_str)); ++ memcpy(vbios_info.date, atom_context->date, ++ sizeof(atom_context->date)); ++ } + + return copy_to_user(out, &vbios_info, + min((size_t)size, sizeof(vbios_info))) ? -EFAULT : 0; +-- +2.40.1 + diff --git a/queue-5.15/fbdev-sh7760fb-depend-on-fb-y.patch b/queue-5.15/fbdev-sh7760fb-depend-on-fb-y.patch new file mode 100644 index 00000000000..8418aad63d3 --- /dev/null +++ b/queue-5.15/fbdev-sh7760fb-depend-on-fb-y.patch @@ -0,0 +1,60 @@ +From e63d116a53788a965b134f874744ea209d2db64a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 18 Sep 2023 11:03:49 +0200 +Subject: fbdev/sh7760fb: Depend on FB=y + +From: Thomas Zimmermann + +[ Upstream commit f75f71b2c418a27a7c05139bb27a0c83adf88d19 ] + +Fix linker error if FB=m about missing fb_io_read and fb_io_write. The +linker's error message suggests that this config setting has already +been broken for other symbols. + + All errors (new ones prefixed by >>): + + sh4-linux-ld: drivers/video/fbdev/sh7760fb.o: in function `sh7760fb_probe': + sh7760fb.c:(.text+0x374): undefined reference to `framebuffer_alloc' + sh4-linux-ld: sh7760fb.c:(.text+0x394): undefined reference to `fb_videomode_to_var' + sh4-linux-ld: sh7760fb.c:(.text+0x39c): undefined reference to `fb_alloc_cmap' + sh4-linux-ld: sh7760fb.c:(.text+0x3a4): undefined reference to `register_framebuffer' + sh4-linux-ld: sh7760fb.c:(.text+0x3ac): undefined reference to `fb_dealloc_cmap' + sh4-linux-ld: sh7760fb.c:(.text+0x434): undefined reference to `framebuffer_release' + sh4-linux-ld: drivers/video/fbdev/sh7760fb.o: in function `sh7760fb_remove': + sh7760fb.c:(.text+0x800): undefined reference to `unregister_framebuffer' + sh4-linux-ld: sh7760fb.c:(.text+0x804): undefined reference to `fb_dealloc_cmap' + sh4-linux-ld: sh7760fb.c:(.text+0x814): undefined reference to `framebuffer_release' + >> sh4-linux-ld: drivers/video/fbdev/sh7760fb.o:(.rodata+0xc): undefined reference to `fb_io_read' + >> sh4-linux-ld: drivers/video/fbdev/sh7760fb.o:(.rodata+0x10): undefined reference to `fb_io_write' + sh4-linux-ld: drivers/video/fbdev/sh7760fb.o:(.rodata+0x2c): undefined reference to `cfb_fillrect' + sh4-linux-ld: drivers/video/fbdev/sh7760fb.o:(.rodata+0x30): undefined reference to `cfb_copyarea' + sh4-linux-ld: drivers/video/fbdev/sh7760fb.o:(.rodata+0x34): undefined reference to `cfb_imageblit' + +Suggested-by: Randy Dunlap +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202309130632.LS04CPWu-lkp@intel.com/ +Signed-off-by: Thomas Zimmermann +Reviewed-by: Javier Martinez Canillas +Acked-by: John Paul Adrian Glaubitz +Link: https://patchwork.freedesktop.org/patch/msgid/20230918090400.13264-1-tzimmermann@suse.de +Signed-off-by: Sasha Levin +--- + drivers/video/fbdev/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig +index 26531aa194282..662524574cc33 100644 +--- a/drivers/video/fbdev/Kconfig ++++ b/drivers/video/fbdev/Kconfig +@@ -2017,7 +2017,7 @@ config FB_COBALT + + config FB_SH7760 + bool "SH7760/SH7763/SH7720/SH7721 LCDC support" +- depends on FB && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763 \ ++ depends on FB=y && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763 \ + || CPU_SUBTYPE_SH7720 || CPU_SUBTYPE_SH7721) + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA +-- +2.40.1 + diff --git a/queue-5.15/media-vb2-frame_vector.c-replace-warn_once-with-a-co.patch b/queue-5.15/media-vb2-frame_vector.c-replace-warn_once-with-a-co.patch new file mode 100644 index 00000000000..d5775bc3224 --- /dev/null +++ b/queue-5.15/media-vb2-frame_vector.c-replace-warn_once-with-a-co.patch @@ -0,0 +1,51 @@ +From 99efee0512231c576be8e4a1c774839c641e3348 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 17 Aug 2023 12:41:32 +0200 +Subject: media: vb2: frame_vector.c: replace WARN_ONCE with a comment + +From: Hans Verkuil + +[ Upstream commit 735de5caf79e06cc9fb96b1b4f4974674ae3e917 ] + +The WARN_ONCE was issued also in cases that had nothing to do with VM_IO +(e.g. if the start address was just a random value and uaccess fails with +-EFAULT). + +There are no reports of WARN_ONCE being issued for actual VM_IO cases, so +just drop it and instead add a note to the comment before the function. + +Signed-off-by: Hans Verkuil +Reviewed-by: David Hildenbrand +Reported-by: Yikebaer Aizezi +Signed-off-by: Sasha Levin +--- + drivers/media/common/videobuf2/frame_vector.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/media/common/videobuf2/frame_vector.c b/drivers/media/common/videobuf2/frame_vector.c +index 144027035892a..07ebe4424df3a 100644 +--- a/drivers/media/common/videobuf2/frame_vector.c ++++ b/drivers/media/common/videobuf2/frame_vector.c +@@ -30,6 +30,10 @@ + * different type underlying the specified range of virtual addresses. + * When the function isn't able to map a single page, it returns error. + * ++ * Note that get_vaddr_frames() cannot follow VM_IO mappings. It used ++ * to be able to do that, but that could (racily) return non-refcounted ++ * pfns. ++ * + * This function takes care of grabbing mmap_lock as necessary. + */ + int get_vaddr_frames(unsigned long start, unsigned int nr_frames, +@@ -55,8 +59,6 @@ int get_vaddr_frames(unsigned long start, unsigned int nr_frames, + if (likely(ret > 0)) + return ret; + +- /* This used to (racily) return non-refcounted pfns. Let people know */ +- WARN_ONCE(1, "get_vaddr_frames() cannot follow VM_IO mapping"); + vec->nr_frames = 0; + return ret ? ret : -EFAULT; + } +-- +2.40.1 + diff --git a/queue-5.15/ncsi-propagate-carrier-gain-loss-events-to-the-ncsi-.patch b/queue-5.15/ncsi-propagate-carrier-gain-loss-events-to-the-ncsi-.patch new file mode 100644 index 00000000000..a089a4fac5c --- /dev/null +++ b/queue-5.15/ncsi-propagate-carrier-gain-loss-events-to-the-ncsi-.patch @@ -0,0 +1,40 @@ +From e6948d2409e35991734881165c59d80cd074aea3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 15 Sep 2023 09:12:35 -0700 +Subject: ncsi: Propagate carrier gain/loss events to the NCSI controller + +From: Johnathan Mantey + +[ Upstream commit 3780bb29311eccb7a1c9641032a112eed237f7e3 ] + +Report the carrier/no-carrier state for the network interface +shared between the BMC and the passthrough channel. Without this +functionality the BMC is unable to reconfigure the NIC in the event +of a re-cabling to a different subnet. + +Signed-off-by: Johnathan Mantey +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/ncsi/ncsi-aen.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c +index 62fb1031763d1..f8854bff286cb 100644 +--- a/net/ncsi/ncsi-aen.c ++++ b/net/ncsi/ncsi-aen.c +@@ -89,6 +89,11 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp, + if ((had_link == has_link) || chained) + return 0; + ++ if (had_link) ++ netif_carrier_off(ndp->ndev.dev); ++ else ++ netif_carrier_on(ndp->ndev.dev); ++ + if (!ndp->multi_package && !nc->package->multi_channel) { + if (had_link) { + ndp->flags |= NCSI_DEV_RESHUFFLE; +-- +2.40.1 + diff --git a/queue-5.15/parisc-drivers-fix-sparse-warning.patch b/queue-5.15/parisc-drivers-fix-sparse-warning.patch new file mode 100644 index 00000000000..72d50cc9573 --- /dev/null +++ b/queue-5.15/parisc-drivers-fix-sparse-warning.patch @@ -0,0 +1,35 @@ +From 36f03bc58cedc378e595738bcb8b81b5bc4d1e83 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 31 Aug 2023 22:08:32 +0200 +Subject: parisc: drivers: Fix sparse warning + +From: Helge Deller + +[ Upstream commit b137b9d60b8add5620a06c687a71ce18776730b0 ] + +Fix "warning: directive in macro's argument list" warning. + +Signed-off-by: Helge Deller +Signed-off-by: Sasha Levin +--- + arch/parisc/kernel/drivers.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c +index e7ee0c0c91d35..8f12b9f318ae6 100644 +--- a/arch/parisc/kernel/drivers.c ++++ b/arch/parisc/kernel/drivers.c +@@ -924,9 +924,9 @@ static __init void qemu_header(void) + pr_info("#define PARISC_MODEL \"%s\"\n\n", + boot_cpu_data.pdc.sys_model_name); + ++ #define p ((unsigned long *)&boot_cpu_data.pdc.model) + pr_info("#define PARISC_PDC_MODEL 0x%lx, 0x%lx, 0x%lx, " + "0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx\n\n", +- #define p ((unsigned long *)&boot_cpu_data.pdc.model) + p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8]); + #undef p + +-- +2.40.1 + diff --git a/queue-5.15/parisc-iosapic.c-fix-sparse-warnings.patch b/queue-5.15/parisc-iosapic.c-fix-sparse-warnings.patch new file mode 100644 index 00000000000..12b5c547900 --- /dev/null +++ b/queue-5.15/parisc-iosapic.c-fix-sparse-warnings.patch @@ -0,0 +1,50 @@ +From 2dc3bf26a479a92d3f04529da52f3a41b6466c13 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 30 Aug 2023 11:59:55 +0200 +Subject: parisc: iosapic.c: Fix sparse warnings + +From: Helge Deller + +[ Upstream commit 927c6c8aa27c284a799b8c18784e37d3373af908 ] + +Signed-off-by: Helge Deller +Signed-off-by: Sasha Levin +--- + drivers/parisc/iosapic.c | 4 ++-- + drivers/parisc/iosapic_private.h | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c +index 93ea922618c3d..56562ae99f683 100644 +--- a/drivers/parisc/iosapic.c ++++ b/drivers/parisc/iosapic.c +@@ -202,9 +202,9 @@ static inline void iosapic_write(void __iomem *iosapic, unsigned int reg, u32 va + + static DEFINE_SPINLOCK(iosapic_lock); + +-static inline void iosapic_eoi(void __iomem *addr, unsigned int data) ++static inline void iosapic_eoi(__le32 __iomem *addr, __le32 data) + { +- __raw_writel(data, addr); ++ __raw_writel((__force u32)data, addr); + } + + /* +diff --git a/drivers/parisc/iosapic_private.h b/drivers/parisc/iosapic_private.h +index 73ecc657ad954..bd8ff40162b4b 100644 +--- a/drivers/parisc/iosapic_private.h ++++ b/drivers/parisc/iosapic_private.h +@@ -118,8 +118,8 @@ struct iosapic_irt { + struct vector_info { + struct iosapic_info *iosapic; /* I/O SAPIC this vector is on */ + struct irt_entry *irte; /* IRT entry */ +- u32 __iomem *eoi_addr; /* precalculate EOI reg address */ +- u32 eoi_data; /* IA64: ? PA: swapped txn_data */ ++ __le32 __iomem *eoi_addr; /* precalculate EOI reg address */ ++ __le32 eoi_data; /* IA64: ? PA: swapped txn_data */ + int txn_irq; /* virtual IRQ number for processor */ + ulong txn_addr; /* IA64: id_eid PA: partial HPA */ + u32 txn_data; /* CPU interrupt bit */ +-- +2.40.1 + diff --git a/queue-5.15/parisc-irq-make-irq_stack_union-static-to-avoid-spar.patch b/queue-5.15/parisc-irq-make-irq_stack_union-static-to-avoid-spar.patch new file mode 100644 index 00000000000..0c8a94be7c8 --- /dev/null +++ b/queue-5.15/parisc-irq-make-irq_stack_union-static-to-avoid-spar.patch @@ -0,0 +1,31 @@ +From 4bad01aca60e66114586f8b3e703240020defe52 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 31 Aug 2023 22:36:12 +0200 +Subject: parisc: irq: Make irq_stack_union static to avoid sparse warning + +From: Helge Deller + +[ Upstream commit b1bef1388c427cdad7331a9c8eb4ebbbe5b954b0 ] + +Signed-off-by: Helge Deller +Signed-off-by: Sasha Levin +--- + arch/parisc/kernel/irq.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c +index e6cc38ef69458..5d9044e65a1a6 100644 +--- a/arch/parisc/kernel/irq.c ++++ b/arch/parisc/kernel/irq.c +@@ -386,7 +386,7 @@ union irq_stack_union { + volatile unsigned int lock[1]; + }; + +-DEFINE_PER_CPU(union irq_stack_union, irq_stack_union) = { ++static DEFINE_PER_CPU(union irq_stack_union, irq_stack_union) = { + .slock = { 1,1,1,1 }, + }; + #endif +-- +2.40.1 + diff --git a/queue-5.15/parisc-sba-fix-compile-warning-wrt-list-of-sba-devic.patch b/queue-5.15/parisc-sba-fix-compile-warning-wrt-list-of-sba-devic.patch new file mode 100644 index 00000000000..68206311a0f --- /dev/null +++ b/queue-5.15/parisc-sba-fix-compile-warning-wrt-list-of-sba-devic.patch @@ -0,0 +1,50 @@ +From 18fbc9455ae743d98463c0254096ebeceb10e1ab Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 30 Aug 2023 08:10:01 +0200 +Subject: parisc: sba: Fix compile warning wrt list of SBA devices + +From: Helge Deller + +[ Upstream commit eb3255ee8f6f4691471a28fbf22db5e8901116cd ] + +Fix this makecheck warning: +drivers/parisc/sba_iommu.c:98:19: warning: symbol 'sba_list' + was not declared. Should it be static? + +Signed-off-by: Helge Deller +Signed-off-by: Sasha Levin +--- + arch/parisc/include/asm/ropes.h | 3 +++ + drivers/char/agp/parisc-agp.c | 2 -- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/arch/parisc/include/asm/ropes.h b/arch/parisc/include/asm/ropes.h +index 8e51c775c80a6..62399c7ea94a1 100644 +--- a/arch/parisc/include/asm/ropes.h ++++ b/arch/parisc/include/asm/ropes.h +@@ -86,6 +86,9 @@ struct sba_device { + struct ioc ioc[MAX_IOC]; + }; + ++/* list of SBA's in system, see drivers/parisc/sba_iommu.c */ ++extern struct sba_device *sba_list; ++ + #define ASTRO_RUNWAY_PORT 0x582 + #define IKE_MERCED_PORT 0x803 + #define REO_MERCED_PORT 0x804 +diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c +index 514f9f287a781..c6f181702b9a7 100644 +--- a/drivers/char/agp/parisc-agp.c ++++ b/drivers/char/agp/parisc-agp.c +@@ -394,8 +394,6 @@ find_quicksilver(struct device *dev, void *data) + static int __init + parisc_agp_init(void) + { +- extern struct sba_device *sba_list; +- + int err = -1; + struct parisc_device *sba = NULL, *lba = NULL; + struct lba_device *lbadev = NULL; +-- +2.40.1 + diff --git a/queue-5.15/platform-mellanox-mlxbf-bootctl-add-net-dependency-i.patch b/queue-5.15/platform-mellanox-mlxbf-bootctl-add-net-dependency-i.patch new file mode 100644 index 00000000000..46c558e86ff --- /dev/null +++ b/queue-5.15/platform-mellanox-mlxbf-bootctl-add-net-dependency-i.patch @@ -0,0 +1,40 @@ +From 78d73a796637a846b4d7440d5e6eb88cafb7b187 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 5 Sep 2023 09:32:43 -0400 +Subject: platform/mellanox: mlxbf-bootctl: add NET dependency into Kconfig + +From: David Thompson + +[ Upstream commit c2dffda1d8f7511505bbbf16ba282f2079b30089 ] + +The latest version of the mlxbf_bootctl driver utilizes +"sysfs_format_mac", and this API is only available if +NET is defined in the kernel configuration. This patch +changes the mlxbf_bootctl Kconfig to depend on NET. + +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202309031058.JvwNDBKt-lkp@intel.com/ +Reported-by: Randy Dunlap +Signed-off-by: David Thompson +Link: https://lore.kernel.org/r/20230905133243.31550-1-davthompson@nvidia.com +Signed-off-by: Hans de Goede +Signed-off-by: Sasha Levin +--- + drivers/platform/mellanox/Kconfig | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/platform/mellanox/Kconfig b/drivers/platform/mellanox/Kconfig +index edd17e1a1f88f..a57ae5cbc00a8 100644 +--- a/drivers/platform/mellanox/Kconfig ++++ b/drivers/platform/mellanox/Kconfig +@@ -48,6 +48,7 @@ config MLXBF_BOOTCTL + tristate "Mellanox BlueField Firmware Boot Control driver" + depends on ARM64 + depends on ACPI ++ depends on NET + help + The Mellanox BlueField firmware implements functionality to + request swapping the primary and alternate eMMC boot partition, +-- +2.40.1 + diff --git a/queue-5.15/powerpc-watchpoint-disable-pagefaults-when-getting-u.patch b/queue-5.15/powerpc-watchpoint-disable-pagefaults-when-getting-u.patch new file mode 100644 index 00000000000..771069c7918 --- /dev/null +++ b/queue-5.15/powerpc-watchpoint-disable-pagefaults-when-getting-u.patch @@ -0,0 +1,47 @@ +From 490751d81c2fa2dfc61d40b15e7d01596ed6465f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 29 Aug 2023 16:34:56 +1000 +Subject: powerpc/watchpoint: Disable pagefaults when getting user instruction + +From: Benjamin Gray + +[ Upstream commit 3241f260eb830d27d09cc604690ec24533fdb433 ] + +This is called in an atomic context, so is not allowed to sleep if a +user page needs to be faulted in and has nowhere it can be deferred to. +The pagefault_disabled() function is documented as preventing user +access methods from sleeping. + +In practice the page will be mapped in nearly always because we are +reading the instruction that just triggered the watchpoint trap. + +Signed-off-by: Benjamin Gray +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20230829063457.54157-3-bgray@linux.ibm.com +Signed-off-by: Sasha Levin +--- + arch/powerpc/kernel/hw_breakpoint_constraints.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/arch/powerpc/kernel/hw_breakpoint_constraints.c b/arch/powerpc/kernel/hw_breakpoint_constraints.c +index 675d1f66ab728..a541e3b755479 100644 +--- a/arch/powerpc/kernel/hw_breakpoint_constraints.c ++++ b/arch/powerpc/kernel/hw_breakpoint_constraints.c +@@ -140,8 +140,13 @@ void wp_get_instr_detail(struct pt_regs *regs, struct ppc_inst *instr, + int *type, int *size, unsigned long *ea) + { + struct instruction_op op; ++ int err; + +- if (__get_user_instr(*instr, (void __user *)regs->nip)) ++ pagefault_disable(); ++ err = __get_user_instr(*instr, (void __user *)regs->nip); ++ pagefault_enable(); ++ ++ if (err) + return; + + analyse_instr(&op, regs, *instr); +-- +2.40.1 + diff --git a/queue-5.15/powerpc-watchpoints-annotate-atomic-context-in-more-.patch b/queue-5.15/powerpc-watchpoints-annotate-atomic-context-in-more-.patch new file mode 100644 index 00000000000..51d5554d2da --- /dev/null +++ b/queue-5.15/powerpc-watchpoints-annotate-atomic-context-in-more-.patch @@ -0,0 +1,58 @@ +From 639758871e79ad4749291e976f7a08e639f7949f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 29 Aug 2023 16:34:57 +1000 +Subject: powerpc/watchpoints: Annotate atomic context in more places + +From: Benjamin Gray + +[ Upstream commit 27646b2e02b096a6936b3e3b6ba334ae20763eab ] + +It can be easy to miss that the notifier mechanism invokes the callbacks +in an atomic context, so add some comments to that effect on the two +handlers we register here. + +Signed-off-by: Benjamin Gray +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20230829063457.54157-4-bgray@linux.ibm.com +Signed-off-by: Sasha Levin +--- + arch/powerpc/kernel/hw_breakpoint.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c +index 63fec0602af22..affb03f56a7e1 100644 +--- a/arch/powerpc/kernel/hw_breakpoint.c ++++ b/arch/powerpc/kernel/hw_breakpoint.c +@@ -610,6 +610,11 @@ static void handle_p10dd1_spurious_exception(struct arch_hw_breakpoint **info, + } + } + ++/* ++ * Handle a DABR or DAWR exception. ++ * ++ * Called in atomic context. ++ */ + int hw_breakpoint_handler(struct die_args *args) + { + bool err = false; +@@ -736,6 +741,8 @@ NOKPROBE_SYMBOL(hw_breakpoint_handler); + + /* + * Handle single-step exceptions following a DABR hit. ++ * ++ * Called in atomic context. + */ + static int single_step_dabr_instruction(struct die_args *args) + { +@@ -793,6 +800,8 @@ NOKPROBE_SYMBOL(single_step_dabr_instruction); + + /* + * Handle debug exception notifications. ++ * ++ * Called in atomic context. + */ + int hw_breakpoint_exceptions_notify( + struct notifier_block *unused, unsigned long val, void *data) +-- +2.40.1 + diff --git a/queue-5.15/powerpc-watchpoints-disable-preemption-in-thread_cha.patch b/queue-5.15/powerpc-watchpoints-disable-preemption-in-thread_cha.patch new file mode 100644 index 00000000000..b7839368af2 --- /dev/null +++ b/queue-5.15/powerpc-watchpoints-disable-preemption-in-thread_cha.patch @@ -0,0 +1,58 @@ +From 5480b182f8301ba0a3fd0bda7c98448e41490584 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 29 Aug 2023 16:34:55 +1000 +Subject: powerpc/watchpoints: Disable preemption in thread_change_pc() + +From: Benjamin Gray + +[ Upstream commit cc879ab3ce39bc39f9b1d238b283f43a5f6f957d ] + +thread_change_pc() uses CPU local data, so must be protected from +swapping CPUs while it is reading the breakpoint struct. + +The error is more noticeable after 1e60f3564bad ("powerpc/watchpoints: +Track perf single step directly on the breakpoint"), which added an +unconditional __this_cpu_read() call in thread_change_pc(). However the +existing __this_cpu_read() that runs if a breakpoint does need to be +re-inserted has the same issue. + +Signed-off-by: Benjamin Gray +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20230829063457.54157-2-bgray@linux.ibm.com +Signed-off-by: Sasha Levin +--- + arch/powerpc/kernel/hw_breakpoint.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c +index 91a3be14808b1..63fec0602af22 100644 +--- a/arch/powerpc/kernel/hw_breakpoint.c ++++ b/arch/powerpc/kernel/hw_breakpoint.c +@@ -478,11 +478,13 @@ void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs) + struct arch_hw_breakpoint *info; + int i; + ++ preempt_disable(); ++ + for (i = 0; i < nr_wp_slots(); i++) { + if (unlikely(tsk->thread.last_hit_ubp[i])) + goto reset; + } +- return; ++ goto out; + + reset: + regs_set_return_msr(regs, regs->msr & ~MSR_SE); +@@ -491,6 +493,9 @@ void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs) + __set_breakpoint(i, info); + tsk->thread.last_hit_ubp[i] = NULL; + } ++ ++out: ++ preempt_enable(); + } + + static bool is_larx_stcx_instr(int type) +-- +2.40.1 + diff --git a/queue-5.15/ring-buffer-avoid-softlockup-in-ring_buffer_resize.patch b/queue-5.15/ring-buffer-avoid-softlockup-in-ring_buffer_resize.patch new file mode 100644 index 00000000000..70debf42aa6 --- /dev/null +++ b/queue-5.15/ring-buffer-avoid-softlockup-in-ring_buffer_resize.patch @@ -0,0 +1,45 @@ +From 9913ee74a5ca8a984732c73f3d824e56e1fd5090 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 6 Sep 2023 16:19:30 +0800 +Subject: ring-buffer: Avoid softlockup in ring_buffer_resize() + +From: Zheng Yejian + +[ Upstream commit f6bd2c92488c30ef53b5bd80c52f0a7eee9d545a ] + +When user resize all trace ring buffer through file 'buffer_size_kb', +then in ring_buffer_resize(), kernel allocates buffer pages for each +cpu in a loop. + +If the kernel preemption model is PREEMPT_NONE and there are many cpus +and there are many buffer pages to be allocated, it may not give up cpu +for a long time and finally cause a softlockup. + +To avoid it, call cond_resched() after each cpu buffer allocation. + +Link: https://lore.kernel.org/linux-trace-kernel/20230906081930.3939106-1-zhengyejian1@huawei.com + +Cc: +Signed-off-by: Zheng Yejian +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Sasha Levin +--- + kernel/trace/ring_buffer.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c +index db7cefd196cec..b15d72284c7f7 100644 +--- a/kernel/trace/ring_buffer.c ++++ b/kernel/trace/ring_buffer.c +@@ -2176,6 +2176,8 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, + err = -ENOMEM; + goto out_err; + } ++ ++ cond_resched(); + } + + cpus_read_lock(); +-- +2.40.1 + diff --git a/queue-5.15/ring-buffer-do-not-attempt-to-read-past-commit.patch b/queue-5.15/ring-buffer-do-not-attempt-to-read-past-commit.patch new file mode 100644 index 00000000000..282ce0a18de --- /dev/null +++ b/queue-5.15/ring-buffer-do-not-attempt-to-read-past-commit.patch @@ -0,0 +1,57 @@ +From db01d7ff7d3bd510d51304053c0eb0f1bdbffd90 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 7 Sep 2023 12:28:20 -0400 +Subject: ring-buffer: Do not attempt to read past "commit" + +From: Steven Rostedt (Google) + +[ Upstream commit 95a404bd60af6c4d9d8db01ad14fe8957ece31ca ] + +When iterating over the ring buffer while the ring buffer is active, the +writer can corrupt the reader. There's barriers to help detect this and +handle it, but that code missed the case where the last event was at the +very end of the page and has only 4 bytes left. + +The checks to detect the corruption by the writer to reads needs to see the +length of the event. If the length in the first 4 bytes is zero then the +length is stored in the second 4 bytes. But if the writer is in the process +of updating that code, there's a small window where the length in the first +4 bytes could be zero even though the length is only 4 bytes. That will +cause rb_event_length() to read the next 4 bytes which could happen to be off the +allocated page. + +To protect against this, fail immediately if the next event pointer is +less than 8 bytes from the end of the commit (last byte of data), as all +events must be a minimum of 8 bytes anyway. + +Link: https://lore.kernel.org/all/20230905141245.26470-1-Tze-nan.Wu@mediatek.com/ +Link: https://lore.kernel.org/linux-trace-kernel/20230907122820.0899019c@gandalf.local.home + +Cc: Masami Hiramatsu +Cc: Mark Rutland +Reported-by: Tze-nan Wu +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Sasha Levin +--- + kernel/trace/ring_buffer.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c +index b15d72284c7f7..69db849ae7dad 100644 +--- a/kernel/trace/ring_buffer.c ++++ b/kernel/trace/ring_buffer.c +@@ -2352,6 +2352,11 @@ rb_iter_head_event(struct ring_buffer_iter *iter) + */ + commit = rb_page_commit(iter_head_page); + smp_rmb(); ++ ++ /* An event needs to be at least 8 bytes in size */ ++ if (iter->head > commit - 8) ++ goto reset; ++ + event = __rb_page_index(iter_head_page, iter->head); + length = rb_event_length(event); + +-- +2.40.1 + diff --git a/queue-5.15/scsi-pm80xx-avoid-leaking-tags-when-processing-opc_i.patch b/queue-5.15/scsi-pm80xx-avoid-leaking-tags-when-processing-opc_i.patch new file mode 100644 index 00000000000..813d6bcb58a --- /dev/null +++ b/queue-5.15/scsi-pm80xx-avoid-leaking-tags-when-processing-opc_i.patch @@ -0,0 +1,42 @@ +From 56c5dbfdd44426a1963c8e09292ece48d68842bb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 11 Sep 2023 10:03:40 -0700 +Subject: scsi: pm80xx: Avoid leaking tags when processing + OPC_INB_SET_CONTROLLER_CONFIG command + +From: Michal Grzedzicki + +[ Upstream commit c13e7331745852d0dd7c35eabbe181cbd5b01172 ] + +Tags allocated for OPC_INB_SET_CONTROLLER_CONFIG command need to be freed +when we receive the response. + +Signed-off-by: Michal Grzedzicki +Link: https://lore.kernel.org/r/20230911170340.699533-2-mge@meta.com +Acked-by: Jack Wang +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/pm8001/pm80xx_hwi.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c +index ea305d093c871..d37b1bdb29b49 100644 +--- a/drivers/scsi/pm8001/pm80xx_hwi.c ++++ b/drivers/scsi/pm8001/pm80xx_hwi.c +@@ -3793,10 +3793,12 @@ static int mpi_set_controller_config_resp(struct pm8001_hba_info *pm8001_ha, + (struct set_ctrl_cfg_resp *)(piomb + 4); + u32 status = le32_to_cpu(pPayload->status); + u32 err_qlfr_pgcd = le32_to_cpu(pPayload->err_qlfr_pgcd); ++ u32 tag = le32_to_cpu(pPayload->tag); + + pm8001_dbg(pm8001_ha, MSG, + "SET CONTROLLER RESP: status 0x%x qlfr_pgcd 0x%x\n", + status, err_qlfr_pgcd); ++ pm8001_tag_free(pm8001_ha, tag); + + return 0; + } +-- +2.40.1 + diff --git a/queue-5.15/scsi-pm80xx-use-phy-specific-sas-address-when-sendin.patch b/queue-5.15/scsi-pm80xx-use-phy-specific-sas-address-when-sendin.patch new file mode 100644 index 00000000000..eef4dee3acc --- /dev/null +++ b/queue-5.15/scsi-pm80xx-use-phy-specific-sas-address-when-sendin.patch @@ -0,0 +1,53 @@ +From c246e2de28f80177f4cc77aac5f3adc090b92d94 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 13 Sep 2023 08:56:10 -0700 +Subject: scsi: pm80xx: Use phy-specific SAS address when sending PHY_START + command + +From: Michal Grzedzicki + +[ Upstream commit 71996bb835aed58c7ec4967be1d05190a27339ec ] + +Some cards have more than one SAS address. Using an incorrect address +causes communication issues with some devices like expanders. + +Closes: https://lore.kernel.org/linux-kernel/A57AEA84-5CA0-403E-8053-106033C73C70@fb.com/ +Signed-off-by: Michal Grzedzicki +Link: https://lore.kernel.org/r/20230913155611.3183612-1-mge@meta.com +Acked-by: Jack Wang +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/pm8001/pm8001_hwi.c | 2 +- + drivers/scsi/pm8001/pm80xx_hwi.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c +index 32fc450bf84b4..352705e023c83 100644 +--- a/drivers/scsi/pm8001/pm8001_hwi.c ++++ b/drivers/scsi/pm8001/pm8001_hwi.c +@@ -4402,7 +4402,7 @@ pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) + payload.sas_identify.dev_type = SAS_END_DEVICE; + payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL; + memcpy(payload.sas_identify.sas_addr, +- pm8001_ha->sas_addr, SAS_ADDR_SIZE); ++ &pm8001_ha->phy[phy_id].dev_sas_addr, SAS_ADDR_SIZE); + payload.sas_identify.phy_id = phy_id; + ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, + sizeof(payload), 0); +diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c +index 04746df26c6c9..ea305d093c871 100644 +--- a/drivers/scsi/pm8001/pm80xx_hwi.c ++++ b/drivers/scsi/pm8001/pm80xx_hwi.c +@@ -4814,7 +4814,7 @@ pm80xx_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) + payload.sas_identify.dev_type = SAS_END_DEVICE; + payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL; + memcpy(payload.sas_identify.sas_addr, +- &pm8001_ha->sas_addr, SAS_ADDR_SIZE); ++ &pm8001_ha->phy[phy_id].dev_sas_addr, SAS_ADDR_SIZE); + payload.sas_identify.phy_id = phy_id; + ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, + sizeof(payload), 0); +-- +2.40.1 + diff --git a/queue-5.15/scsi-qedf-add-synchronization-between-i-o-completion.patch b/queue-5.15/scsi-qedf-add-synchronization-between-i-o-completion.patch new file mode 100644 index 00000000000..2568962d194 --- /dev/null +++ b/queue-5.15/scsi-qedf-add-synchronization-between-i-o-completion.patch @@ -0,0 +1,99 @@ +From e5433a369b88af793fc2d49a6231393a2afcd4f3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 1 Sep 2023 11:36:46 +0530 +Subject: scsi: qedf: Add synchronization between I/O completions and abort + +From: Javed Hasan + +[ Upstream commit 7df0b2605489bef3f4223ad66f1f9bb8d50d4cd2 ] + +Avoid race condition between I/O completion and abort processing by +protecting the cmd_type with the rport lock. + +Signed-off-by: Javed Hasan +Signed-off-by: Saurav Kashyap +Link: https://lore.kernel.org/r/20230901060646.27885-1-skashyap@marvell.com +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/qedf/qedf_io.c | 10 ++++++++-- + drivers/scsi/qedf/qedf_main.c | 7 ++++++- + 2 files changed, 14 insertions(+), 3 deletions(-) + +diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c +index bb5761ed3f511..a1a1f4e466609 100644 +--- a/drivers/scsi/qedf/qedf_io.c ++++ b/drivers/scsi/qedf/qedf_io.c +@@ -1913,6 +1913,7 @@ int qedf_initiate_abts(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts) + goto drop_rdata_kref; + } + ++ spin_lock_irqsave(&fcport->rport_lock, flags); + if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags) || + test_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags) || + test_bit(QEDF_CMD_IN_ABORT, &io_req->flags)) { +@@ -1920,17 +1921,20 @@ int qedf_initiate_abts(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts) + "io_req xid=0x%x sc_cmd=%p already in cleanup or abort processing or already completed.\n", + io_req->xid, io_req->sc_cmd); + rc = 1; ++ spin_unlock_irqrestore(&fcport->rport_lock, flags); + goto drop_rdata_kref; + } + ++ /* Set the command type to abort */ ++ io_req->cmd_type = QEDF_ABTS; ++ spin_unlock_irqrestore(&fcport->rport_lock, flags); ++ + kref_get(&io_req->refcount); + + xid = io_req->xid; + qedf->control_requests++; + qedf->packet_aborts++; + +- /* Set the command type to abort */ +- io_req->cmd_type = QEDF_ABTS; + io_req->return_scsi_cmd_on_abts = return_scsi_cmd_on_abts; + + set_bit(QEDF_CMD_IN_ABORT, &io_req->flags); +@@ -2219,7 +2223,9 @@ int qedf_initiate_cleanup(struct qedf_ioreq *io_req, + refcount, fcport, fcport->rdata->ids.port_id); + + /* Cleanup cmds re-use the same TID as the original I/O */ ++ spin_lock_irqsave(&fcport->rport_lock, flags); + io_req->cmd_type = QEDF_CLEANUP; ++ spin_unlock_irqrestore(&fcport->rport_lock, flags); + io_req->return_scsi_cmd_on_abts = return_scsi_cmd_on_abts; + + init_completion(&io_req->cleanup_done); +diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c +index 61959dd2237fc..18380a932ab61 100644 +--- a/drivers/scsi/qedf/qedf_main.c ++++ b/drivers/scsi/qedf/qedf_main.c +@@ -2807,6 +2807,8 @@ void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe) + struct qedf_ioreq *io_req; + struct qedf_rport *fcport; + u32 comp_type; ++ u8 io_comp_type; ++ unsigned long flags; + + comp_type = (cqe->cqe_data >> FCOE_CQE_CQE_TYPE_SHIFT) & + FCOE_CQE_CQE_TYPE_MASK; +@@ -2840,11 +2842,14 @@ void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe) + return; + } + ++ spin_lock_irqsave(&fcport->rport_lock, flags); ++ io_comp_type = io_req->cmd_type; ++ spin_unlock_irqrestore(&fcport->rport_lock, flags); + + switch (comp_type) { + case FCOE_GOOD_COMPLETION_CQE_TYPE: + atomic_inc(&fcport->free_sqes); +- switch (io_req->cmd_type) { ++ switch (io_comp_type) { + case QEDF_SCSI_CMD: + qedf_scsi_completion(qedf, cqe, io_req); + break; +-- +2.40.1 + diff --git a/queue-5.15/scsi-ufs-core-move-__ufshcd_send_uic_cmd-outside-hos.patch b/queue-5.15/scsi-ufs-core-move-__ufshcd_send_uic_cmd-outside-hos.patch new file mode 100644 index 00000000000..7ca8b66b92e --- /dev/null +++ b/queue-5.15/scsi-ufs-core-move-__ufshcd_send_uic_cmd-outside-hos.patch @@ -0,0 +1,64 @@ +From 54864ce5482879abb45d4e4cc884a51790e0dcc1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Sep 2023 10:30:44 +0900 +Subject: scsi: ufs: core: Move __ufshcd_send_uic_cmd() outside host_lock + +From: Kiwoong Kim + +[ Upstream commit 2d3f59cf868b4a2dd678a96cd49bdd91411bd59f ] + +__ufshcd_send_uic_cmd() is wrapped by uic_cmd_mutex and its related +contexts are accessed within the section wrapped by uic_cmd_mutex. Thus, +wrapping with host_lock is redundant. + +Signed-off-by: Kiwoong Kim +Link: https://lore.kernel.org/r/782ba5f26f0a96e58d85dff50751787d2d2a6b2b.1693790060.git.kwmad.kim@samsung.com +Reviewed-by: Bart Van Assche +Reviewed-by: Chanwoo Lee +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/ufs/ufshcd.c | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c +index d00d263705e15..f48036f09eab5 100644 +--- a/drivers/scsi/ufs/ufshcd.c ++++ b/drivers/scsi/ufs/ufshcd.c +@@ -2309,7 +2309,6 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd, + bool completion) + { + lockdep_assert_held(&hba->uic_cmd_mutex); +- lockdep_assert_held(hba->host->host_lock); + + if (!ufshcd_ready_for_uic_cmd(hba)) { + dev_err(hba->dev, +@@ -2336,15 +2335,12 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd, + int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) + { + int ret; +- unsigned long flags; + + ufshcd_hold(hba, false); + mutex_lock(&hba->uic_cmd_mutex); + ufshcd_add_delay_before_dme_cmd(hba); + +- spin_lock_irqsave(hba->host->host_lock, flags); + ret = __ufshcd_send_uic_cmd(hba, uic_cmd, true); +- spin_unlock_irqrestore(hba->host->host_lock, flags); + if (!ret) + ret = ufshcd_wait_for_uic_cmd(hba, uic_cmd); + +@@ -3967,8 +3963,8 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) + wmb(); + reenable_intr = true; + } +- ret = __ufshcd_send_uic_cmd(hba, cmd, false); + spin_unlock_irqrestore(hba->host->host_lock, flags); ++ ret = __ufshcd_send_uic_cmd(hba, cmd, false); + if (ret) { + dev_err(hba->dev, + "pwr ctrl cmd 0x%x with mode 0x%x uic error %d\n", +-- +2.40.1 + diff --git a/queue-5.15/selftests-fix-dependency-checker-script.patch b/queue-5.15/selftests-fix-dependency-checker-script.patch new file mode 100644 index 00000000000..39cef23b86d --- /dev/null +++ b/queue-5.15/selftests-fix-dependency-checker-script.patch @@ -0,0 +1,179 @@ +From 7fd12d7d3afca8926368078e20e64fb454a03c6e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 22 Aug 2023 18:09:40 -0300 +Subject: selftests: fix dependency checker script + +From: Ricardo B. Marliere + +[ Upstream commit 5f9dd2e896a91bfca90f8463eb6808c03d535d8a ] + +This patch fixes inconsistencies in the parsing rules of the levels 1 +and 2 of the kselftest_deps.sh. It was added the levels 4 and 5 to +account for a few edge cases that are present in some tests, also some +minor identation styling have been fixed (s/ /\t/g). + +Signed-off-by: Ricardo B. Marliere +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/kselftest_deps.sh | 77 +++++++++++++++++++---- + 1 file changed, 65 insertions(+), 12 deletions(-) + +diff --git a/tools/testing/selftests/kselftest_deps.sh b/tools/testing/selftests/kselftest_deps.sh +index 00e60d6eb16bc..7e51f4a373d35 100755 +--- a/tools/testing/selftests/kselftest_deps.sh ++++ b/tools/testing/selftests/kselftest_deps.sh +@@ -46,11 +46,11 @@ fi + print_targets=0 + + while getopts "p" arg; do +- case $arg in +- p) ++ case $arg in ++ p) + print_targets=1 + shift;; +- esac ++ esac + done + + if [ $# -eq 0 ] +@@ -92,6 +92,10 @@ pass_cnt=0 + # Get all TARGETS from selftests Makefile + targets=$(egrep "^TARGETS +|^TARGETS =" Makefile | cut -d "=" -f2) + ++# Initially, in LDLIBS related lines, the dep checker needs ++# to ignore lines containing the following strings: ++filter="\$(VAR_LDLIBS)\|pkg-config\|PKG_CONFIG\|IOURING_EXTRA_LIBS" ++ + # Single test case + if [ $# -eq 2 ] + then +@@ -100,6 +104,8 @@ then + l1_test $test + l2_test $test + l3_test $test ++ l4_test $test ++ l5_test $test + + print_results $1 $2 + exit $? +@@ -113,7 +119,7 @@ fi + # Append space at the end of the list to append more tests. + + l1_tests=$(grep -r --include=Makefile "^LDLIBS" | \ +- grep -v "VAR_LDLIBS" | awk -F: '{print $1}') ++ grep -v "$filter" | awk -F: '{print $1}' | uniq) + + # Level 2: LDLIBS set dynamically. + # +@@ -126,7 +132,7 @@ l1_tests=$(grep -r --include=Makefile "^LDLIBS" | \ + # Append space at the end of the list to append more tests. + + l2_tests=$(grep -r --include=Makefile ": LDLIBS" | \ +- grep -v "VAR_LDLIBS" | awk -F: '{print $1}') ++ grep -v "$filter" | awk -F: '{print $1}' | uniq) + + # Level 3 + # memfd and others use pkg-config to find mount and fuse libs +@@ -138,11 +144,32 @@ l2_tests=$(grep -r --include=Makefile ": LDLIBS" | \ + # VAR_LDLIBS := $(shell pkg-config fuse --libs 2>/dev/null) + + l3_tests=$(grep -r --include=Makefile "^VAR_LDLIBS" | \ +- grep -v "pkg-config" | awk -F: '{print $1}') ++ grep -v "pkg-config\|PKG_CONFIG" | awk -F: '{print $1}' | uniq) + +-#echo $l1_tests +-#echo $l2_1_tests +-#echo $l3_tests ++# Level 4 ++# some tests may fall back to default using `|| echo -l` ++# if pkg-config doesn't find the libs, instead of using VAR_LDLIBS ++# as per level 3 checks. ++# e.g: ++# netfilter/Makefile ++# LDLIBS += $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo -lmnl) ++l4_tests=$(grep -r --include=Makefile "^LDLIBS" | \ ++ grep "pkg-config\|PKG_CONFIG" | awk -F: '{print $1}' | uniq) ++ ++# Level 5 ++# some tests may use IOURING_EXTRA_LIBS to add extra libs to LDLIBS, ++# which in turn may be defined in a sub-Makefile ++# e.g.: ++# mm/Makefile ++# $(OUTPUT)/gup_longterm: LDLIBS += $(IOURING_EXTRA_LIBS) ++l5_tests=$(grep -r --include=Makefile "LDLIBS +=.*\$(IOURING_EXTRA_LIBS)" | \ ++ awk -F: '{print $1}' | uniq) ++ ++#echo l1_tests $l1_tests ++#echo l2_tests $l2_tests ++#echo l3_tests $l3_tests ++#echo l4_tests $l4_tests ++#echo l5_tests $l5_tests + + all_tests + print_results $1 $2 +@@ -164,24 +191,32 @@ all_tests() + for test in $l3_tests; do + l3_test $test + done ++ ++ for test in $l4_tests; do ++ l4_test $test ++ done ++ ++ for test in $l5_tests; do ++ l5_test $test ++ done + } + + # Use same parsing used for l1_tests and pick libraries this time. + l1_test() + { + test_libs=$(grep --include=Makefile "^LDLIBS" $test | \ +- grep -v "VAR_LDLIBS" | \ ++ grep -v "$filter" | \ + sed -e 's/\:/ /' | \ + sed -e 's/+/ /' | cut -d "=" -f 2) + + check_libs $test $test_libs + } + +-# Use same parsing used for l2__tests and pick libraries this time. ++# Use same parsing used for l2_tests and pick libraries this time. + l2_test() + { + test_libs=$(grep --include=Makefile ": LDLIBS" $test | \ +- grep -v "VAR_LDLIBS" | \ ++ grep -v "$filter" | \ + sed -e 's/\:/ /' | sed -e 's/+/ /' | \ + cut -d "=" -f 2) + +@@ -197,6 +232,24 @@ l3_test() + check_libs $test $test_libs + } + ++l4_test() ++{ ++ test_libs=$(grep --include=Makefile "^VAR_LDLIBS\|^LDLIBS" $test | \ ++ grep "\(pkg-config\|PKG_CONFIG\).*|| echo " | \ ++ sed -e 's/.*|| echo //' | sed -e 's/)$//') ++ ++ check_libs $test $test_libs ++} ++ ++l5_test() ++{ ++ tests=$(find $(dirname "$test") -type f -name "*.mk") ++ test_libs=$(grep "^IOURING_EXTRA_LIBS +\?=" $tests | \ ++ cut -d "=" -f 2) ++ ++ check_libs $test $test_libs ++} ++ + check_libs() + { + +-- +2.40.1 + diff --git a/queue-5.15/selftests-ftrace-correctly-enable-event-in-instance-.patch b/queue-5.15/selftests-ftrace-correctly-enable-event-in-instance-.patch new file mode 100644 index 00000000000..089e01b7d51 --- /dev/null +++ b/queue-5.15/selftests-ftrace-correctly-enable-event-in-instance-.patch @@ -0,0 +1,51 @@ +From 6472346753efaaa77d0241cd04a0dfb73affcafe Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 26 Jun 2023 08:11:44 +0800 +Subject: selftests/ftrace: Correctly enable event in instance-event.tc + +From: Zheng Yejian + +[ Upstream commit f4e4ada586995b17f828c6d147d1800eb1471450 ] + +Function instance_set() expects to enable event 'sched_switch', so we +should set 1 to its 'enable' file. + +Testcase passed after this patch: + # ./ftracetest test.d/instances/instance-event.tc + === Ftrace unit tests === + [1] Test creation and deletion of trace instances while setting an event + [PASS] + + # of passed: 1 + # of failed: 0 + # of unresolved: 0 + # of untested: 0 + # of unsupported: 0 + # of xfailed: 0 + # of undefined(test bug): 0 + +Signed-off-by: Zheng Yejian +Acked-by: Masami Hiramatsu (Google) +Acked-by: Steven Rostedt (Google) +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + .../testing/selftests/ftrace/test.d/instances/instance-event.tc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc +index 0eb47fbb3f44d..42422e4251078 100644 +--- a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc ++++ b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc +@@ -39,7 +39,7 @@ instance_read() { + + instance_set() { + while :; do +- echo 1 > foo/events/sched/sched_switch ++ echo 1 > foo/events/sched/sched_switch/enable + done 2> /dev/null + } + +-- +2.40.1 + diff --git a/queue-5.15/series b/queue-5.15/series index 4399ee693d9..bfb1d1dc1ee 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -107,3 +107,35 @@ xtensa-boot-lib-fix-function-prototypes.patch soc-imx8m-enable-ocotp-clock-for-imx8mm-before-readi.patch gpio-pmic-eic-sprd-add-can_sleep-flag-for-pmic-eic-c.patch i2c-npcm7xx-fix-callback-completion-ordering.patch +dma-debug-don-t-call-__dma_entry_alloc_check_leak-un.patch +spi-sun6i-reduce-dma-rx-transfer-width-to-single-byt.patch +spi-sun6i-fix-race-between-dma-rx-transfer-completio.patch +parisc-sba-fix-compile-warning-wrt-list-of-sba-devic.patch +parisc-iosapic.c-fix-sparse-warnings.patch +parisc-drivers-fix-sparse-warning.patch +parisc-irq-make-irq_stack_union-static-to-avoid-spar.patch +scsi-qedf-add-synchronization-between-i-o-completion.patch +scsi-ufs-core-move-__ufshcd_send_uic_cmd-outside-hos.patch +selftests-ftrace-correctly-enable-event-in-instance-.patch +ring-buffer-avoid-softlockup-in-ring_buffer_resize.patch +btrfs-improve-error-message-after-failure-to-add-del.patch +selftests-fix-dependency-checker-script.patch +ring-buffer-do-not-attempt-to-read-past-commit.patch +platform-mellanox-mlxbf-bootctl-add-net-dependency-i.patch +drm-amd-display-don-t-check-registers-if-using-aux-b.patch +drm-amdgpu-handle-null-atom-context-in-vbios-info-io.patch +scsi-pm80xx-use-phy-specific-sas-address-when-sendin.patch +scsi-pm80xx-avoid-leaking-tags-when-processing-opc_i.patch +smb3-correct-places-where-enotsupp-is-used-instead-o.patch +ata-libata-eh-do-not-clear-ata_pflag_eh_pending-in-a.patch +spi-nxp-fspi-reset-the-flshxcr1-registers.patch +spi-stm32-add-a-delay-before-spi-disable.patch +asoc-fsl-imx-pcm-rpmsg-add-sndrv_pcm_info_batch-flag.patch +bpf-clarify-error-expectations-from-bpf_clone_redire.patch +asoc-imx-rpmsg-set-ignore_pmdown_time-for-dai_link.patch +media-vb2-frame_vector.c-replace-warn_once-with-a-co.patch +powerpc-watchpoints-disable-preemption-in-thread_cha.patch +powerpc-watchpoint-disable-pagefaults-when-getting-u.patch +powerpc-watchpoints-annotate-atomic-context-in-more-.patch +ncsi-propagate-carrier-gain-loss-events-to-the-ncsi-.patch +fbdev-sh7760fb-depend-on-fb-y.patch diff --git a/queue-5.15/smb3-correct-places-where-enotsupp-is-used-instead-o.patch b/queue-5.15/smb3-correct-places-where-enotsupp-is-used-instead-o.patch new file mode 100644 index 00000000000..921a0f42869 --- /dev/null +++ b/queue-5.15/smb3-correct-places-where-enotsupp-is-used-instead-o.patch @@ -0,0 +1,68 @@ +From ca3be5236a70195498eb53d85a9ed48ddfacdbe0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 15 Sep 2023 01:10:40 -0500 +Subject: smb3: correct places where ENOTSUPP is used instead of preferred + EOPNOTSUPP + +From: Steve French + +[ Upstream commit ebc3d4e44a7e05457825e03d0560153687265523 ] + +checkpatch flagged a few places with: + WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP +Also fixed minor typo + +Signed-off-by: Steve French +Signed-off-by: Sasha Levin +--- + fs/cifs/inode.c | 2 +- + fs/cifs/smb2ops.c | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c +index 82848412ad852..30a9a89c141bb 100644 +--- a/fs/cifs/inode.c ++++ b/fs/cifs/inode.c +@@ -2531,7 +2531,7 @@ int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start, + } + + cifsFileInfo_put(cfile); +- return -ENOTSUPP; ++ return -EOPNOTSUPP; + } + + int cifs_truncate_page(struct address_space *mapping, loff_t from) +diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c +index 560c4ababfe1a..d8ce079ba9091 100644 +--- a/fs/cifs/smb2ops.c ++++ b/fs/cifs/smb2ops.c +@@ -266,7 +266,7 @@ smb2_adjust_credits(struct TCP_Server_Info *server, + cifs_server_dbg(VFS, "request has less credits (%d) than required (%d)", + credits->value, new_val); + +- return -ENOTSUPP; ++ return -EOPNOTSUPP; + } + + spin_lock(&server->req_lock); +@@ -1308,7 +1308,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, + /* Use a fudge factor of 256 bytes in case we collide + * with a different set_EAs command. + */ +- if(CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE - ++ if (CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE - + MAX_SMB2_CLOSE_RESPONSE_SIZE - 256 < + used_len + ea_name_len + ea_value_len + 1) { + rc = -ENOSPC; +@@ -4822,7 +4822,7 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid, + + if (shdr->Command != SMB2_READ) { + cifs_server_dbg(VFS, "only big read responses are supported\n"); +- return -ENOTSUPP; ++ return -EOPNOTSUPP; + } + + if (server->ops->is_session_expired && +-- +2.40.1 + diff --git a/queue-5.15/spi-nxp-fspi-reset-the-flshxcr1-registers.patch b/queue-5.15/spi-nxp-fspi-reset-the-flshxcr1-registers.patch new file mode 100644 index 00000000000..abc354a036f --- /dev/null +++ b/queue-5.15/spi-nxp-fspi-reset-the-flshxcr1-registers.patch @@ -0,0 +1,41 @@ +From dfc448cc5ffb56df184ccc21492d5905fc651a22 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 6 Sep 2023 13:32:54 -0500 +Subject: spi: nxp-fspi: reset the FLSHxCR1 registers + +From: Han Xu + +[ Upstream commit 18495676f7886e105133f1dc06c1d5e8d5436f32 ] + +Reset the FLSHxCR1 registers to default value. ROM may set the register +value and it affects the SPI NAND normal functions. + +Signed-off-by: Han Xu +Link: https://lore.kernel.org/r/20230906183254.235847-1-han.xu@nxp.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/spi/spi-nxp-fspi.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c +index 2b0301fc971c6..23e4c30e6a60a 100644 +--- a/drivers/spi/spi-nxp-fspi.c ++++ b/drivers/spi/spi-nxp-fspi.c +@@ -1029,6 +1029,13 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f) + fspi_writel(f, FSPI_AHBCR_PREF_EN | FSPI_AHBCR_RDADDROPT, + base + FSPI_AHBCR); + ++ /* Reset the FLSHxCR1 registers. */ ++ reg = FSPI_FLSHXCR1_TCSH(0x3) | FSPI_FLSHXCR1_TCSS(0x3); ++ fspi_writel(f, reg, base + FSPI_FLSHA1CR1); ++ fspi_writel(f, reg, base + FSPI_FLSHA2CR1); ++ fspi_writel(f, reg, base + FSPI_FLSHB1CR1); ++ fspi_writel(f, reg, base + FSPI_FLSHB2CR1); ++ + /* AHB Read - Set lut sequence ID for all CS. */ + fspi_writel(f, SEQID_LUT, base + FSPI_FLSHA1CR2); + fspi_writel(f, SEQID_LUT, base + FSPI_FLSHA2CR2); +-- +2.40.1 + diff --git a/queue-5.15/spi-stm32-add-a-delay-before-spi-disable.patch b/queue-5.15/spi-stm32-add-a-delay-before-spi-disable.patch new file mode 100644 index 00000000000..bc35b36a999 --- /dev/null +++ b/queue-5.15/spi-stm32-add-a-delay-before-spi-disable.patch @@ -0,0 +1,69 @@ +From d9a962a288cc82c1b74386da24905e8f4b70d2c5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 6 Sep 2023 15:27:35 +0200 +Subject: spi: stm32: add a delay before SPI disable + +From: Valentin Caron + +[ Upstream commit 6de8a70c84ee0586fdde4e671626b9caca6aed74 ] + +As explained in errata sheet, in section "2.14.5 Truncation of SPI output +signals after EOT event": +On STM32MP1x, EOT interrupt can be thrown before the true end of +communication. + +So we add a delay of a half period to wait the real end of the +transmission. + +Link: https://www.st.com/resource/en/errata_sheet/es0539-stm32mp131x3x5x-device-errata-stmicroelectronics.pdf +Signed-off-by: Valentin Caron +Link: https://lore.kernel.org/r/20230906132735.748174-1-valentin.caron@foss.st.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/spi/spi-stm32.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c +index 3c6f201b5dd85..191baa6e45c08 100644 +--- a/drivers/spi/spi-stm32.c ++++ b/drivers/spi/spi-stm32.c +@@ -268,6 +268,7 @@ struct stm32_spi_cfg { + * @fifo_size: size of the embedded fifo in bytes + * @cur_midi: master inter-data idleness in ns + * @cur_speed: speed configured in Hz ++ * @cur_half_period: time of a half bit in us + * @cur_bpw: number of bits in a single SPI data frame + * @cur_fthlv: fifo threshold level (data frames in a single data packet) + * @cur_comm: SPI communication mode +@@ -294,6 +295,7 @@ struct stm32_spi { + + unsigned int cur_midi; + unsigned int cur_speed; ++ unsigned int cur_half_period; + unsigned int cur_bpw; + unsigned int cur_fthlv; + unsigned int cur_comm; +@@ -454,6 +456,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz, + + spi->cur_speed = spi->clk_rate / (1 << mbrdiv); + ++ spi->cur_half_period = DIV_ROUND_CLOSEST(USEC_PER_SEC, 2 * spi->cur_speed); ++ + return mbrdiv - 1; + } + +@@ -695,6 +699,10 @@ static void stm32h7_spi_disable(struct stm32_spi *spi) + return; + } + ++ /* Add a delay to make sure that transmission is ended. */ ++ if (spi->cur_half_period) ++ udelay(spi->cur_half_period); ++ + if (spi->cur_usedma && spi->dma_tx) + dmaengine_terminate_all(spi->dma_tx); + if (spi->cur_usedma && spi->dma_rx) +-- +2.40.1 + diff --git a/queue-5.15/spi-sun6i-fix-race-between-dma-rx-transfer-completio.patch b/queue-5.15/spi-sun6i-fix-race-between-dma-rx-transfer-completio.patch new file mode 100644 index 00000000000..2aed8a35256 --- /dev/null +++ b/queue-5.15/spi-sun6i-fix-race-between-dma-rx-transfer-completio.patch @@ -0,0 +1,117 @@ +From 9f680dffb96aa430392dd2b1ddb62a68f8a7f9a1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 27 Aug 2023 17:25:58 +0200 +Subject: spi: sun6i: fix race between DMA RX transfer completion and RX FIFO + drain + +From: Tobias Schramm + +[ Upstream commit 1f11f4202caf5710204d334fe63392052783876d ] + +Previously the transfer complete IRQ immediately drained to RX FIFO to +read any data remaining in FIFO to the RX buffer. This behaviour is +correct when dealing with SPI in interrupt mode. However in DMA mode the +transfer complete interrupt still fires as soon as all bytes to be +transferred have been stored in the FIFO. At that point data in the FIFO +still needs to be picked up by the DMA engine. Thus the drain procedure +and DMA engine end up racing to read from RX FIFO, corrupting any data +read. Additionally the RX buffer pointer is never adjusted according to +DMA progress in DMA mode, thus calling the RX FIFO drain procedure in DMA +mode is a bug. +Fix corruptions in DMA RX mode by draining RX FIFO only in interrupt mode. +Also wait for completion of RX DMA when in DMA mode before returning to +ensure all data has been copied to the supplied memory buffer. + +Signed-off-by: Tobias Schramm +Link: https://lore.kernel.org/r/20230827152558.5368-3-t.schramm@manjaro.org +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/spi/spi-sun6i.c | 29 ++++++++++++++++++++++++++++- + 1 file changed, 28 insertions(+), 1 deletion(-) + +diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c +index 2bfe87873edb3..d79853ba7792a 100644 +--- a/drivers/spi/spi-sun6i.c ++++ b/drivers/spi/spi-sun6i.c +@@ -95,6 +95,7 @@ struct sun6i_spi { + struct reset_control *rstc; + + struct completion done; ++ struct completion dma_rx_done; + + const u8 *tx_buf; + u8 *rx_buf; +@@ -189,6 +190,13 @@ static size_t sun6i_spi_max_transfer_size(struct spi_device *spi) + return SUN6I_MAX_XFER_SIZE - 1; + } + ++static void sun6i_spi_dma_rx_cb(void *param) ++{ ++ struct sun6i_spi *sspi = param; ++ ++ complete(&sspi->dma_rx_done); ++} ++ + static int sun6i_spi_prepare_dma(struct sun6i_spi *sspi, + struct spi_transfer *tfr) + { +@@ -213,6 +221,8 @@ static int sun6i_spi_prepare_dma(struct sun6i_spi *sspi, + DMA_PREP_INTERRUPT); + if (!rxdesc) + return -EINVAL; ++ rxdesc->callback_param = sspi; ++ rxdesc->callback = sun6i_spi_dma_rx_cb; + } + + txdesc = NULL; +@@ -268,6 +278,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master, + return -EINVAL; + + reinit_completion(&sspi->done); ++ reinit_completion(&sspi->dma_rx_done); + sspi->tx_buf = tfr->tx_buf; + sspi->rx_buf = tfr->rx_buf; + sspi->len = tfr->len; +@@ -426,6 +437,22 @@ static int sun6i_spi_transfer_one(struct spi_master *master, + start = jiffies; + timeout = wait_for_completion_timeout(&sspi->done, + msecs_to_jiffies(tx_time)); ++ ++ if (!use_dma) { ++ sun6i_spi_drain_fifo(sspi); ++ } else { ++ if (timeout && rx_len) { ++ /* ++ * Even though RX on the peripheral side has finished ++ * RX DMA might still be in flight ++ */ ++ timeout = wait_for_completion_timeout(&sspi->dma_rx_done, ++ timeout); ++ if (!timeout) ++ dev_warn(&master->dev, "RX DMA timeout\n"); ++ } ++ } ++ + end = jiffies; + if (!timeout) { + dev_warn(&master->dev, +@@ -453,7 +480,6 @@ static irqreturn_t sun6i_spi_handler(int irq, void *dev_id) + /* Transfer complete */ + if (status & SUN6I_INT_CTL_TC) { + sun6i_spi_write(sspi, SUN6I_INT_STA_REG, SUN6I_INT_CTL_TC); +- sun6i_spi_drain_fifo(sspi); + complete(&sspi->done); + return IRQ_HANDLED; + } +@@ -611,6 +637,7 @@ static int sun6i_spi_probe(struct platform_device *pdev) + } + + init_completion(&sspi->done); ++ init_completion(&sspi->dma_rx_done); + + sspi->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); + if (IS_ERR(sspi->rstc)) { +-- +2.40.1 + diff --git a/queue-5.15/spi-sun6i-reduce-dma-rx-transfer-width-to-single-byt.patch b/queue-5.15/spi-sun6i-reduce-dma-rx-transfer-width-to-single-byt.patch new file mode 100644 index 00000000000..9f7c55fb355 --- /dev/null +++ b/queue-5.15/spi-sun6i-reduce-dma-rx-transfer-width-to-single-byt.patch @@ -0,0 +1,43 @@ +From fcd1265b8f0061413801fe594bc9fe93399c8253 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 27 Aug 2023 17:25:57 +0200 +Subject: spi: sun6i: reduce DMA RX transfer width to single byte + +From: Tobias Schramm + +[ Upstream commit 171f8a49f212e87a8b04087568e1b3d132e36a18 ] + +Through empirical testing it has been determined that sometimes RX SPI +transfers with DMA enabled return corrupted data. This is down to single +or even multiple bytes lost during DMA transfer from SPI peripheral to +memory. It seems the RX FIFO within the SPI peripheral can become +confused when performing bus read accesses wider than a single byte to it +during an active SPI transfer. + +This patch reduces the width of individual DMA read accesses to the +RX FIFO to a single byte to mitigate that issue. + +Signed-off-by: Tobias Schramm +Link: https://lore.kernel.org/r/20230827152558.5368-2-t.schramm@manjaro.org +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/spi/spi-sun6i.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c +index 23ad052528dbe..2bfe87873edb3 100644 +--- a/drivers/spi/spi-sun6i.c ++++ b/drivers/spi/spi-sun6i.c +@@ -200,7 +200,7 @@ static int sun6i_spi_prepare_dma(struct sun6i_spi *sspi, + struct dma_slave_config rxconf = { + .direction = DMA_DEV_TO_MEM, + .src_addr = sspi->dma_addr_rx, +- .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, ++ .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, + .src_maxburst = 8, + }; + +-- +2.40.1 +