Commit Graph

5929 Commits

Author SHA1 Message Date
Jason Liu
ffcb081b1e This is the 6.6.21 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmXoglwACgkQONu9yGCS
 aT4b5Q/+NTo9lSsob4MeA31IdXx/zxHSQKnREAGN5A4pevI6HJbnqJO6jQxZ2FKk
 2uB51Xjw/vhaQOljnNpkrCLrZBKoh/BuodxS7oYjYfDyba+DCoFMkqBtav9ZzlcF
 JcoPOOm4lEvTOozs/3ulmWx+ZZC1pnZt5JEmUTjL17AHdZUlugDg49WiZlEm3Le9
 ApmBN1t9VJz64wHsmbjgXiPUVb76I08knCBv/No1hrJmemK4Gn9lZn3WAIiSsWvp
 Dk4bzHmLleHbIW3EKc5VS1Jhp+m3/gGDP6Z4bN0B9HLu2qc8HT91rpC+giLzwIv2
 L1G8j9a5nyQEPropN+EUsJSzk0iez6o9DrSEDj2XmgPnxB0wsTwrmZvPjaU6M03Z
 QLMgFbiveeDSHjvt9RZvrIAMklW6PjZqaX4ZMvHxGJvvayFfaEQCb40/KwppvdiX
 C/U3fT3L0RdSRu/V/k+W/a8O65EJ/5ZLd3G/RNSiWhy/uZoSpfbSLADo/zUXqNc3
 bxSpVv7NAfA/riZlAeN/WXq2eZd0pQYF4BLK4UEJ2muPs2ZA42D3bGg19TgNRAgs
 mAovy5Liuj/iTsi9hXGymrMNp4plbM/Sie9qs+rwNJBXrYctkNPOAiR9ng381dX2
 1Icy4uek50/CqWocxTtblp8ch+dT68AKPZzkjB0RCvjneWVc2LI=
 =hAft
 -----END PGP SIGNATURE-----

Merge tag 'v6.6.21' into lf-6.6.y

This is the 6.6.21 stable release

* tag 'v6.6.21': (143 commits)
  Linux 6.6.21
  drm/nouveau: don't fini scheduler before entity flush
  selftests: mptcp: rm subflow with v4/v4mapped addr
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

 Conflicts:
	drivers/dma/fsl-edma-common.c
	drivers/dma/fsl-qdma.c
	drivers/net/ethernet/freescale/fman/fman_memac.c
	drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
2024-03-13 14:24:30 +08:00
Jason Liu
8eb8dd316c This is the 6.6.20 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmXjYIIACgkQONu9yGCS
 aT5mvw/9GnG2BWbZp9BgVzBnT00CXnIpiGlsoSU0I0Uiso3XqpNYBu7jIZ+vmsqz
 3H2bpkToEwJgg40I+w3iRaY84FWJZtl6HWtXydVQghQzXdA7qSuKBmbqQdUGKqZq
 Uqy7SFabkqQmlmF+RX1tYsgj7Vg3tqThERLUKQRhZIRa+Xek6Izi16RKEXcBNoXv
 vN+Q6AJ6vgjzHdw/UndsTH48bA/NofLlGapf7ZRGaSO7vY6bO5N23Xeg8gBIUh3M
 RHYf0ubKOvOw6LfZrE8BAbLd9Om2IHRAwHTqvDUNaIOl6y7exwCCIMK2lDdlzQ3W
 7gug4HzlQjVz93OtL8MjLnfINOO7en65gyqvwit9N7O7nJKvuIMtt5vVam+h4ikB
 xF/QmFj95GNeRLwBmOJxOS89KyC8BrjE3PfYtL1mUO9joH8vZBccon6WIV7C2u5M
 d+0UglxC4lNTJ3s3FcnrzEKCn5YaE8WvFYQX0xvFQL3GWGDkyrNaafqoz19a8yd2
 ndf3xUh5QKYWI2UGhqV6FdfYC9BolEh/niMKrJYCEJ6BroO3nzh1L8keC+MHbJwp
 Yuu9FCT+vNDKfR/HQwUhUGX/3wyBKb8jqzDXUB2s4FLPUSBX+/RAso13FWua1TGd
 E432ZXaobuUx3+kHsqB+0dc99QVblnMFMPEoM4ye3lYHzq8PDJ0=
 =7IL4
 -----END PGP SIGNATURE-----

Merge tag 'v6.6.20' into lf-6.6.y

This is the 6.6.20 stable release

* tag 'v6.6.20': (3154 commits)
  Linux 6.6.20
  fs/ntfs3: fix build without CONFIG_NTFS3_LZX_XPRESS
  Linux 6.6.19
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

 Conflicts:
	arch/arm64/boot/dts/freescale/imx8mm.dtsi
	arch/arm64/boot/dts/freescale/imx8mq.dtsi
	drivers/clk/imx/clk-imx8qxp.c
	drivers/dma/fsl-edma.c
	drivers/firmware/arm_scmi/perf.c
	drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
	drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
	drivers/net/ethernet/freescale/fec_main.c
	drivers/scsi/scsi_error.c
	drivers/spi/spi-imx.c
	sound/soc/fsl/fsl_sai.c
2024-03-11 14:59:44 +08:00
Fenghua Yu
5e3022ea42 dmaengine: idxd: Ensure safe user copy of completion record
[ Upstream commit d3ea125df3 ]

If CONFIG_HARDENED_USERCOPY is enabled, copying completion record from
event log cache to user triggers a kernel bug.

[ 1987.159822] usercopy: Kernel memory exposure attempt detected from SLUB object 'dsa0' (offset 74, size 31)!
[ 1987.170845] ------------[ cut here ]------------
[ 1987.176086] kernel BUG at mm/usercopy.c:102!
[ 1987.180946] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
[ 1987.186866] CPU: 17 PID: 528 Comm: kworker/17:1 Not tainted 6.8.0-rc2+ #5
[ 1987.194537] Hardware name: Intel Corporation AvenueCity/AvenueCity, BIOS BHSDCRB1.86B.2492.D03.2307181620 07/18/2023
[ 1987.206405] Workqueue: wq0.0 idxd_evl_fault_work [idxd]
[ 1987.212338] RIP: 0010:usercopy_abort+0x72/0x90
[ 1987.217381] Code: 58 65 9c 50 48 c7 c2 17 85 61 9c 57 48 c7 c7 98 fd 6b 9c 48 0f 44 d6 48 c7 c6 b3 08 62 9c 4c 89 d1 49 0f 44 f3 e8 1e 2e d5 ff <0f> 0b 49 c7 c1 9e 42 61 9c 4c 89 cf 4d 89 c8 eb a9 66 66 2e 0f 1f
[ 1987.238505] RSP: 0018:ff62f5cf20607d60 EFLAGS: 00010246
[ 1987.244423] RAX: 000000000000005f RBX: 000000000000001f RCX: 0000000000000000
[ 1987.252480] RDX: 0000000000000000 RSI: ffffffff9c61429e RDI: 00000000ffffffff
[ 1987.260538] RBP: ff62f5cf20607d78 R08: ff2a6a89ef3fffe8 R09: 00000000fffeffff
[ 1987.268595] R10: ff2a6a89eed00000 R11: 0000000000000003 R12: ff2a66934849c89a
[ 1987.276652] R13: 0000000000000001 R14: ff2a66934849c8b9 R15: ff2a66934849c899
[ 1987.284710] FS:  0000000000000000(0000) GS:ff2a66b22fe40000(0000) knlGS:0000000000000000
[ 1987.293850] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1987.300355] CR2: 00007fe291a37000 CR3: 000000010fbd4005 CR4: 0000000000f71ef0
[ 1987.308413] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1987.316470] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400
[ 1987.324527] PKRU: 55555554
[ 1987.327622] Call Trace:
[ 1987.330424]  <TASK>
[ 1987.332826]  ? show_regs+0x6e/0x80
[ 1987.336703]  ? die+0x3c/0xa0
[ 1987.339988]  ? do_trap+0xd4/0xf0
[ 1987.343662]  ? do_error_trap+0x75/0xa0
[ 1987.347922]  ? usercopy_abort+0x72/0x90
[ 1987.352277]  ? exc_invalid_op+0x57/0x80
[ 1987.356634]  ? usercopy_abort+0x72/0x90
[ 1987.360988]  ? asm_exc_invalid_op+0x1f/0x30
[ 1987.365734]  ? usercopy_abort+0x72/0x90
[ 1987.370088]  __check_heap_object+0xb7/0xd0
[ 1987.374739]  __check_object_size+0x175/0x2d0
[ 1987.379588]  idxd_copy_cr+0xa9/0x130 [idxd]
[ 1987.384341]  idxd_evl_fault_work+0x127/0x390 [idxd]
[ 1987.389878]  process_one_work+0x13e/0x300
[ 1987.394435]  ? __pfx_worker_thread+0x10/0x10
[ 1987.399284]  worker_thread+0x2f7/0x420
[ 1987.403544]  ? _raw_spin_unlock_irqrestore+0x2b/0x50
[ 1987.409171]  ? __pfx_worker_thread+0x10/0x10
[ 1987.414019]  kthread+0x107/0x140
[ 1987.417693]  ? __pfx_kthread+0x10/0x10
[ 1987.421954]  ret_from_fork+0x3d/0x60
[ 1987.426019]  ? __pfx_kthread+0x10/0x10
[ 1987.430281]  ret_from_fork_asm+0x1b/0x30
[ 1987.434744]  </TASK>

The issue arises because event log cache is created using
kmem_cache_create() which is not suitable for user copy.

Fix the issue by creating event log cache with
kmem_cache_create_usercopy(), ensuring safe user copy.

Fixes: c2f156bf16 ("dmaengine: idxd: create kmem cache for event log fault items")
Reported-by: Tony Zhu <tony.zhu@intel.com>
Tested-by: Tony Zhu <tony.zhu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Lijun Pan <lijun.pan@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20240209191412.1050270-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-06 14:48:43 +00:00
Fenghua Yu
4d6e793eac dmaengine: idxd: Remove shadow Event Log head stored in idxd
[ Upstream commit ecec7c9f29 ]

head is defined in idxd->evl as a shadow of head in the EVLSTATUS register.
There are two issues related to the shadow head:

1. Mismatch between the shadow head and the state of the EVLSTATUS
   register:
   If Event Log is supported, upon completion of the Enable Device command,
   the Event Log head in the variable idxd->evl->head should be cleared to
   match the state of the EVLSTATUS register. But the variable is not reset
   currently, leading mismatch between the variable and the register state.
   The mismatch causes incorrect processing of Event Log entries.

2. Unnecessary shadow head definition:
   The shadow head is unnecessary as head can be read directly from the
   EVLSTATUS register. Reading head from the register incurs no additional
   cost because event log head and tail are always read together and
   tail is already read directly from the register as required by hardware.

Remove the shadow Event Log head stored in idxd->evl to address the
mentioned issues.

Fixes: 244da66cda ("dmaengine: idxd: setup event log configuration")
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20240215024931.1739621-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-06 14:48:43 +00:00
Kory Maincent
d24fe6d5a1 dmaengine: dw-edma: eDMA: Add sync read before starting the DMA transfer in remote setup
[ Upstream commit bbcc1c83f3 ]

The Linked list element and pointer are not stored in the same memory as
the eDMA controller register. If the doorbell register is toggled before
the full write of the linked list a race condition error will occur.
In remote setup we can only use a readl to the memory to assure the full
write has occurred.

Fixes: 7e4b8a4fbe ("dmaengine: Add Synopsys eDMA IP version 0 support")
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://lore.kernel.org/r/20240129-b4-feature_hdma_mainline-v7-6-8e8c1acb7a46@bootlin.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-06 14:48:43 +00:00
Kory Maincent
227ef58a9b dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup
[ Upstream commit 712a92a481 ]

The Linked list element and pointer are not stored in the same memory as
the HDMA controller register. If the doorbell register is toggled before
the full write of the linked list a race condition error will occur.
In remote setup we can only use a readl to the memory to assure the full
write has occurred.

Fixes: e74c39573d ("dmaengine: dw-edma: Add support for native HDMA")
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://lore.kernel.org/r/20240129-b4-feature_hdma_mainline-v7-5-8e8c1acb7a46@bootlin.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-06 14:48:43 +00:00
Kory Maincent
55501b7359 dmaengine: dw-edma: Add HDMA remote interrupt configuration
[ Upstream commit e2f6a57890 ]

Only the local interruption was configured, remote interrupt was left
behind. This patch fix it by setting stop and abort remote interrupts when
the DW_EDMA_CHIP_LOCAL flag is not set.

Fixes: e74c39573d ("dmaengine: dw-edma: Add support for native HDMA")
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20240129-b4-feature_hdma_mainline-v7-4-8e8c1acb7a46@bootlin.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-06 14:48:43 +00:00
Kory Maincent
3fa3dfcabf dmaengine: dw-edma: HDMA_V0_REMOTEL_STOP_INT_EN typo fix
[ Upstream commit 930a8a015d ]

Fix "HDMA_V0_REMOTEL_STOP_INT_EN" typo error

Fixes: e74c39573d ("dmaengine: dw-edma: Add support for native HDMA")
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://lore.kernel.org/r/20240129-b4-feature_hdma_mainline-v7-3-8e8c1acb7a46@bootlin.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-06 14:48:43 +00:00
Kory Maincent
8b5657ac34 dmaengine: dw-edma: Fix wrong interrupt bit set for HDMA
[ Upstream commit 7b52ba8616 ]

Instead of setting HDMA_V0_LOCAL_ABORT_INT_EN bit, HDMA_V0_LOCAL_STOP_INT_EN
bit got set twice, due to which the abort interrupt is not getting generated for
HDMA. Fix it by setting the correct interrupt enable bit.

Fixes: e74c39573d ("dmaengine: dw-edma: Add support for native HDMA")
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://lore.kernel.org/r/20240129-b4-feature_hdma_mainline-v7-2-8e8c1acb7a46@bootlin.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-06 14:48:43 +00:00
Kory Maincent
3adea99aa7 dmaengine: dw-edma: Fix the ch_count hdma callback
[ Upstream commit cd665bfc75 ]

The current check of ch_en enabled to know the maximum number of available
hardware channels is wrong as it check the number of ch_en register set
but all of them are unset at probe. This register is set at the
dw_hdma_v0_core_start function which is run lately before a DMA transfer.

The HDMA IP have no way to know the number of hardware channels available
like the eDMA IP, then let set it to maximum channels and let the platform
set the right number of channels.

Fixes: e74c39573d ("dmaengine: dw-edma: Add support for native HDMA")
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://lore.kernel.org/r/20240129-b4-feature_hdma_mainline-v7-1-8e8c1acb7a46@bootlin.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-06 14:48:43 +00:00
Curtis Klein
a69c8bbb94 dmaengine: fsl-qdma: init irq after reg initialization
commit 87a39071e0 upstream.

Initialize the qDMA irqs after the registers are configured so that
interrupts that may have been pending from a primary kernel don't get
processed by the irq handler before it is ready to and cause panic with
the following trace:

  Call trace:
   fsl_qdma_queue_handler+0xf8/0x3e8
   __handle_irq_event_percpu+0x78/0x2b0
   handle_irq_event_percpu+0x1c/0x68
   handle_irq_event+0x44/0x78
   handle_fasteoi_irq+0xc8/0x178
   generic_handle_irq+0x24/0x38
   __handle_domain_irq+0x90/0x100
   gic_handle_irq+0x5c/0xb8
   el1_irq+0xb8/0x180
   _raw_spin_unlock_irqrestore+0x14/0x40
   __setup_irq+0x4bc/0x798
   request_threaded_irq+0xd8/0x190
   devm_request_threaded_irq+0x74/0xe8
   fsl_qdma_probe+0x4d4/0xca8
   platform_drv_probe+0x50/0xa0
   really_probe+0xe0/0x3f8
   driver_probe_device+0x64/0x130
   device_driver_attach+0x6c/0x78
   __driver_attach+0xbc/0x158
   bus_for_each_dev+0x5c/0x98
   driver_attach+0x20/0x28
   bus_add_driver+0x158/0x220
   driver_register+0x60/0x110
   __platform_driver_register+0x44/0x50
   fsl_qdma_driver_init+0x18/0x20
   do_one_initcall+0x48/0x258
   kernel_init_freeable+0x1a4/0x23c
   kernel_init+0x10/0xf8
   ret_from_fork+0x10/0x18

Cc: stable@vger.kernel.org
Fixes: b092529e0a ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs")
Signed-off-by: Curtis Klein <curtis.klein@hpe.com>
Signed-off-by: Yi Zhao <yi.zhao@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20240201220406.440145-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-06 14:48:41 +00:00
Joy Zou
91b001fb0b dmaengine: fsl-edma: correct calculation of 'nbytes' in multi-fifo scenario
commit 9ba17defd9 upstream.

The 'nbytes' should be equivalent to burst * width in audio multi-fifo
setups. Given that the FIFO width is fixed at 32 bits, adjusts the burst
size for multi-fifo configurations to match the slave maxburst in the
configuration.

Cc: stable@vger.kernel.org
Fixes: 72f5801a4e ("dmaengine: fsl-edma: integrate v3 support")
Signed-off-by: Joy Zou <joy.zou@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20240131163318.360315-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-06 14:48:41 +00:00
Tadeusz Struk
4e0fe154be dmaengine: ptdma: use consistent DMA masks
commit df2515a179 upstream.

The PTDMA driver sets DMA masks in two different places for the same
device inconsistently. First call is in pt_pci_probe(), where it uses
48bit mask. The second call is in pt_dmaengine_register(), where it
uses a 64bit mask. Using 64bit dma mask causes IO_PAGE_FAULT errors
on DMA transfers between main memory and other devices.
Without the extra call it works fine. Additionally the second call
doesn't check the return value so it can silently fail.
Remove the superfluous dma_set_mask() call and only use 48bit mask.

Cc: stable@vger.kernel.org
Fixes: b0b4a6b105 ("dmaengine: ptdma: register PTDMA controller as a DMA resource")
Reviewed-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Tadeusz Struk <tstruk@gigaio.com>
Link: https://lore.kernel.org/r/20240222163053.13842-1-tstruk@gigaio.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-06 14:48:40 +00:00
Peng Ma
5b696e9c38 dmaengine: fsl-qdma: fix SoC may hang on 16 byte unaligned read
commit 9d739bccf2 upstream.

There is chip (ls1028a) errata:

The SoC may hang on 16 byte unaligned read transactions by QDMA.

Unaligned read transactions initiated by QDMA may stall in the NOC
(Network On-Chip), causing a deadlock condition. Stalled transactions will
trigger completion timeouts in PCIe controller.

Workaround:
Enable prefetch by setting the source descriptor prefetchable bit
( SD[PF] = 1 ).

Implement this workaround.

Cc: stable@vger.kernel.org
Fixes: b092529e0a ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs")
Signed-off-by: Peng Ma <peng.ma@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20240201215007.439503-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-06 14:48:40 +00:00
Kunwu Chan
7b24760f3a dmaengine: ti: edma: Add some null pointer checks to the edma_probe
[ Upstream commit 6e2276203a ]

devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful
by checking the pointer validity.

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Link: https://lore.kernel.org/r/20240118031929.192192-1-chentao@kylinos.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-01 13:34:50 +01:00
Vinod Koul
22dced37d9 dmaengine: dw-edma: increase size of 'name' in debugfs code
[ Upstream commit cb95a4fa50 ]

We seem to have hit warnings of 'output may be truncated' which is fixed
by increasing the size of 'name'

drivers/dma/dw-edma/dw-hdma-v0-debugfs.c: In function ‘dw_hdma_v0_debugfs_on’:
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:125:50: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=]
  125 |                 snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
      |                                                  ^~

drivers/dma/dw-edma/dw-hdma-v0-debugfs.c: In function ‘dw_hdma_v0_debugfs_on’:
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:142:50: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=]
  142 |                 snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
      |                                                  ^~
drivers/dma/dw-edma/dw-edma-v0-debugfs.c: In function ‘dw_edma_debugfs_regs_wr’:
drivers/dma/dw-edma/dw-edma-v0-debugfs.c:193:50: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=]
  193 |                 snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
      |                                                  ^~

Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-01 13:34:48 +01:00
Vinod Koul
9f11992462 dmaengine: fsl-qdma: increase size of 'irq_name'
[ Upstream commit 6386f6c995 ]

We seem to have hit warnings of 'output may be truncated' which is fixed
by increasing the size of 'irq_name'

drivers/dma/fsl-qdma.c: In function ‘fsl_qdma_irq_init’:
drivers/dma/fsl-qdma.c:824:46: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Werror=format-overflow=]
  824 |                 sprintf(irq_name, "qdma-queue%d", i);
      |                                              ^~
drivers/dma/fsl-qdma.c:824:35: note: directive argument in the range [-2147483641, 2147483646]
  824 |                 sprintf(irq_name, "qdma-queue%d", i);
      |                                   ^~~~~~~~~~~~~~
drivers/dma/fsl-qdma.c:824:17: note: ‘sprintf’ output between 12 and 22 bytes into a destination of size 20
  824 |                 sprintf(irq_name, "qdma-queue%d", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-01 13:34:48 +01:00
Vinod Koul
6e400d6b96 dmaengine: shdma: increase size of 'dev_id'
[ Upstream commit 4042902408 ]

We seem to have hit warnings of 'output may be truncated' which is fixed
by increasing the size of 'dev_id'

drivers/dma/sh/shdmac.c: In function ‘sh_dmae_probe’:
drivers/dma/sh/shdmac.c:541:34: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
  541 |                          "sh-dmae%d.%d", pdev->id, id);
      |                                  ^~
In function ‘sh_dmae_chan_probe’,
    inlined from ‘sh_dmae_probe’ at drivers/dma/sh/shdmac.c:845:9:
drivers/dma/sh/shdmac.c:541:26: note: directive argument in the range [0, 2147483647]
  541 |                          "sh-dmae%d.%d", pdev->id, id);
      |                          ^~~~~~~~~~~~~~
drivers/dma/sh/shdmac.c:541:26: note: directive argument in the range [0, 19]
drivers/dma/sh/shdmac.c:540:17: note: ‘snprintf’ output between 11 and 21 bytes into a destination of size 16
  540 |                 snprintf(sh_chan->dev_id, sizeof(sh_chan->dev_id),
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  541 |                          "sh-dmae%d.%d", pdev->id, id);
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-01 13:34:48 +01:00
Hector Martin
43ee59fa01 dmaengine: apple-admac: Keep upper bits of REG_BUS_WIDTH
[ Upstream commit 306f5df81f ]

For RX channels, REG_BUS_WIDTH seems to default to a value of 0xf00, and
macOS preserves the upper bits when setting the configuration in the
lower ones. If we reset the upper bits to 0, this causes framing errors
on suspend/resume (the data stream "tears" and channels get swapped
around). Keeping the upper bits untouched, like the macOS driver does,
fixes this issue.

Signed-off-by: Hector Martin <marcan@marcan.st>
Reviewed-by: Martin Povišer <povik+lin@cutebit.org>
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20231029170704.82238-1-povik+lin@cutebit.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-01 13:34:47 +01:00
Christophe JAILLET
5cd8a51517 dmaengine: fsl-qdma: Fix a memory leak related to the queue command DMA
[ Upstream commit 3aa58cb513 ]

This dma_alloc_coherent() is undone neither in the remove function, nor in
the error handling path of fsl_qdma_probe().

Switch to the managed version to fix both issues.

Fixes: b092529e0a ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/7f66aa14f59d32b13672dde28602b47deb294e1f.1704621515.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-16 19:10:42 +01:00
Christophe JAILLET
df6a1dc71c dmaengine: fsl-qdma: Fix a memory leak related to the status queue DMA
[ Upstream commit 968bc1d720 ]

This dma_alloc_coherent() is undone in the remove function, but not in the
error handling path of fsl_qdma_probe().

Switch to the managed version to fix the issue in the probe and simplify
the remove function.

Fixes: b092529e0a ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/a0ef5d0f5a47381617ef339df776ddc68ce48173.1704621515.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-16 19:10:42 +01:00
Jai Luthra
43ad9840c1 dmaengine: ti: k3-udma: Report short packet errors
[ Upstream commit bc9847c9ba ]

Propagate the TR response status to the device using BCDMA
split-channels. For example CSI-RX driver should be able to check if a
frame was not transferred completely (short packet) and needs to be
discarded.

Fixes: 25dcb5dd7b ("dmaengine: ti: New driver for K3 UDMA")
Signed-off-by: Jai Luthra <j-luthra@ti.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Link: https://lore.kernel.org/r/20240103-tr_resp_err-v1-1-2fdf6d48ab92@ti.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-16 19:10:42 +01:00
Guanhua Gao
f24ba6f9f7 dmaengine: fsl-dpaa2-qdma: Fix the size of dma pools
[ Upstream commit b73e43dcd7 ]

In case of long format of qDMA command descriptor, there are one frame
descriptor, three entries in the frame list and two data entries. So the
size of dma_pool_create for these three fields should be the same with
the total size of entries respectively, or the contents may be overwritten
by the next allocated descriptor.

Fixes: 7fdf9b05c7 ("dmaengine: fsl-dpaa2-qdma: Add NXP dpaa2 qDMA controller driver for Layerscape SoCs")
Signed-off-by: Guanhua Gao <guanhua.gao@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20240118162917.2951450-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-16 19:10:42 +01:00
Rex Zhang
e23d6ba502 dmaengine: idxd: Move dma_free_coherent() out of spinlocked context
[ Upstream commit e271c0ba3f ]

Task may be rescheduled within dma_free_coherent(). So dma_free_coherent()
can't be called between spin_lock() and spin_unlock() to avoid Call Trace:
    Call Trace:
    <TASK>
    dump_stack_lvl+0x37/0x50
    __might_resched+0x16a/0x1c0
    vunmap+0x2c/0x70
    __iommu_dma_free+0x96/0x100
    idxd_device_evl_free+0xd5/0x100 [idxd]
    device_release_driver_internal+0x197/0x200
    unbind_store+0xa1/0xb0
    kernfs_fop_write_iter+0x120/0x1c0
    vfs_write+0x2d3/0x400
    ksys_write+0x63/0xe0
    do_syscall_64+0x44/0xa0
    entry_SYSCALL_64_after_hwframe+0x6e/0xd8
Move it out of the context.

Fixes: 244da66cda ("dmaengine: idxd: setup event log configuration")
Signed-off-by: Rex Zhang <rex.zhang@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
Link: https://lore.kernel.org/r/20231212022158.358619-2-rex.zhang@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-31 16:18:47 -08:00
Amelie Delaunay
7f0ccfad20 dmaengine: fix NULL pointer in channel unregistration function
[ Upstream commit f5c24d9451 ]

__dma_async_device_channel_register() can fail. In case of failure,
chan->local is freed (with free_percpu()), and chan->local is nullified.
When dma_async_device_unregister() is called (because of managed API or
intentionally by DMA controller driver), channels are unconditionally
unregistered, leading to this NULL pointer:
[    1.318693] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000d0
[...]
[    1.484499] Call trace:
[    1.486930]  device_del+0x40/0x394
[    1.490314]  device_unregister+0x20/0x7c
[    1.494220]  __dma_async_device_channel_unregister+0x68/0xc0

Look at dma_async_device_register() function error path, channel device
unregistration is done only if chan->local is not NULL.

Then add the same condition at the beginning of
__dma_async_device_channel_unregister() function, to avoid NULL pointer
issue whatever the API used to reach this function.

Fixes: d2fb0a0438 ("dmaengine: break out channel registration")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20231213160452.2598073-1-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-31 16:18:47 -08:00
Frank Li
3dc9e1c7e0 dmaengine: fsl-edma: fix eDMAv4 channel allocation issue
[ Upstream commit dc51b4442d ]

The eDMAv4 channel mux has a limitation where certain requests must use
even channels, while others must use odd numbers.

Add two flags (ARGS_EVEN_CH and ARGS_ODD_CH) to reflect this limitation.
The device tree source (dts) files need to be updated accordingly.

This issue was identified by the following commit:
commit a725990557 ("arm64: dts: imx93: Fix the dmas entries order")

Reverting channel orders triggered this problem.

Fixes: 72f5801a4e ("dmaengine: fsl-edma: integrate v3 support")
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20231114154824.3617255-2-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-31 16:18:47 -08:00
Yang Yingliang
4438606768 dmaengine: fsl-edma: fix wrong pointer check in fsl_edma3_attach_pd()
[ Upstream commit bffa7218dc ]

device_link_add() returns NULL pointer not PTR_ERR() when it fails,
so replace the IS_ERR() check with NULL pointer check.

Fixes: 72f5801a4e ("dmaengine: fsl-edma: integrate v3 support")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20231129090000.841440-1-yangyingliang@huaweicloud.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:59 +01:00
Guanjun
7734bb3810 dmaengine: idxd: Protect int_handle field in hw descriptor
[ Upstream commit 778dfacc90 ]

The int_handle field in hw descriptor should also be protected
by wmb() before possibly triggering a DMA read.

Fixes: eb0cf33a91 (dmaengine: idxd: move interrupt handle assignment)
Signed-off-by: Guanjun <guanjun@linux.alibaba.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Lijun Pan <lijun.pan@intel.com>
Link: https://lore.kernel.org/r/20231211053704.2725417-2-guanjun@linux.alibaba.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:59 +01:00
Xiaolei Wang
634d43a2da dmaengine: fsl-edma: Add judgment on enabling round robin arbitration
[ Upstream commit 3448397a47 ]

Add judgment on enabling round robin arbitration to avoid
exceptions if this function is not supported.

Call trace:
 fsl_edma_resume_early+0x1d4/0x208
 dpm_run_callback+0xd4/0x304
 device_resume_early+0xb0/0x208
 dpm_resume_early+0x224/0x528
 suspend_devices_and_enter+0x3e4/0xd00
 pm_suspend+0x3c4/0x910
 state_store+0x90/0x124
 kobj_attr_store+0x48/0x64
 sysfs_kf_write+0x84/0xb4
 kernfs_fop_write_iter+0x19c/0x264
 vfs_write+0x664/0x858
 ksys_write+0xc8/0x180
 __arm64_sys_write+0x44/0x58
 invoke_syscall+0x5c/0x178
 el0_svc_common.constprop.0+0x11c/0x14c
 do_el0_svc+0x30/0x40
 el0_svc+0x58/0xa8
 el0t_64_sync_handler+0xc0/0xc4
 el0t_64_sync+0x190/0x194

Fixes: 72f5801a4e ("dmaengine: fsl-edma: integrate v3 support")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20231113225713.1892643-3-xiaolei.wang@windriver.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:57 +01:00
Xiaolei Wang
df9e537122 dmaengine: fsl-edma: Do not suspend and resume the masked dma channel when the system is sleeping
[ Upstream commit 2838a89765 ]

Some channels may be masked. When the system is suspended,
if these masked channels are not filtered out, this will
lead to null pointer operations and system crash:

Unable to handle kernel NULL pointer dereference at virtual address
Mem abort info:
ESR = 0x0000000096000004
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x04: level 0 translation fault
Data abort info:
ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
CM = 0, WnR = 0, TnD = 0, TagAccess = 0
GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=0000000894300000
[00000000000002a0] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
Modules linked in:
CPU: 1 PID: 989 Comm: sh Tainted: G B 6.6.0-16203-g557fb7a3ec4c-dirty #70
Hardware name: Freescale i.MX8QM MEK (DT)
pstate: 400000c5 (nZcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
  pc: fsl_edma_disable_request+0x3c/0x78
  lr: fsl_edma_disable_request+0x3c/0x78
  sp:ffff800089ae7690
  x29: ffff800089ae7690 x28: ffff000807ab5440 x27: ffff000807ab5830
  x26: 0000000000000008 x25: 0000000000000278 x24: 0000000000000001
  23: ffff000807ab4328 x22: 0000000000000000 x21: 0000000000000009
  x20: ffff800082616940 x19: 0000000000000000 x18: 0000000000000000
  x17: 3d3d3d3d3d3d3d3d x16: 3d3d3d3d3d3d3d3d x15: 3d3d3d3d3d3d3d3d
  x14: 3d3d3d3d3d3d3d3d x13: 3d3d3d3d3d3d3d3d x12: 1ffff00010d45724
  x11: ffff700010d45724 x10: dfff800000000000 x9: dfff800000000000
  x8: 00008fffef2ba8dc x7: 0000000000000001 x6: ffff800086a2b927
  x5: ffff800086a2b920 x4: ffff700010d45725 x3: ffff8000800d5bbc
  x2 : 0000000000000000 x1 : ffff000800c1d880 x0 : 0000000000000001
  Call trace:
   fsl_edma_disable_request+0x3c/0x78
   fsl_edma_suspend_late+0x128/0x12c
  dpm_run_callback+0xd4/0x304
   __device_suspend_late+0xd0/0x240
  dpm_suspend_late+0x174/0x59c
  suspend_devices_and_enter+0x194/0xd00
  pm_suspend+0x3c4/0x910

Fixes: 72f5801a4e ("dmaengine: fsl-edma: integrate v3 support")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Link: https://lore.kernel.org/r/20231113225713.1892643-2-xiaolei.wang@windriver.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:57 +01:00
Jai Luthra
2bd6f21648 dmaengine: ti: k3-psil-am62a: Fix SPI PDMA data
[ Upstream commit be37542afb ]

AM62Ax has 3 SPI channels where each channel has 4x TX and 4x RX
threads. Also fix the thread numbers to match what the firmware expects
according to the PSI-L device description.

Link: http://downloads.ti.com/tisci/esd/latest/5_soc_doc/am62ax/psil_cfg.html [1]
Fixes: aac6db7e24 ("dmaengine: ti: k3-psil-am62a: Add AM62Ax PSIL and PDMA data")
Signed-off-by: Jai Luthra <j-luthra@ti.com>
Link: https://lore.kernel.org/r/20231123-psil_fix-v1-1-6604d80819be@ti.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:57 +01:00
Ronald Wahl
6c9e7caeb2 dmaengine: ti: k3-psil-am62: Fix SPI PDMA data
[ Upstream commit 744f5e7b69 ]

AM62x has 3 SPI channels where each channel has 4 TX and 4 RX threads.
This also fixes the thread numbers.

Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com>
Fixes: 5ac6bfb587 ("dmaengine: ti: k3-psil: Add AM62x PSIL and PDMA data")
Reviewed-by: Jai Luthra <j-luthra@ti.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Link: https://lore.kernel.org/r/20231030190113.16782-1-rwahl@gmx.de
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:56 +01:00
Frank Li
ed50e07d6a dmaengine: fsl-edma: fix DMA channel leak in eDMAv4
commit 4ee632c82d upstream.

Allocate channel count consistently increases due to a missing source ID
(srcid) cleanup in the fsl_edma_free_chan_resources() function at imx93
eDMAv4.

Reset 'srcid' at fsl_edma_free_chan_resources().

Cc: stable@vger.kernel.org
Fixes: 72f5801a4e ("dmaengine: fsl-edma: integrate v3 support")
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20231127214325.2477247-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-12-20 17:02:02 +01:00
Amelie Delaunay
9127515bf9 dmaengine: stm32-dma: avoid bitfield overflow assertion
commit 54bed6bafa upstream.

stm32_dma_get_burst() returns a negative error for invalid input, which
gets turned into a large u32 value in stm32_dma_prep_dma_memcpy() that
in turn triggers an assertion because it does not fit into a two-bit field:
drivers/dma/stm32-dma.c: In function 'stm32_dma_prep_dma_memcpy':
include/linux/compiler_types.h:354:38: error: call to '__compiletime_assert_282' declared with attribute error: FIELD_PREP: value too large for the field
     _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                                         ^
   include/linux/compiler_types.h:335:4: note: in definition of macro '__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler_types.h:354:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
    #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                        ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:68:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?  \
      ^~~~~~~~~~~~~~~~
   include/linux/bitfield.h:114:3: note: in expansion of macro '__BF_FIELD_CHECK'
      __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
      ^~~~~~~~~~~~~~~~
   drivers/dma/stm32-dma.c:1237:4: note: in expansion of macro 'FIELD_PREP'
       FIELD_PREP(STM32_DMA_SCR_PBURST_MASK, dma_burst) |
       ^~~~~~~~~~

As an easy workaround, assume the error can happen, so try to handle this
by failing stm32_dma_prep_dma_memcpy() before the assertion. It replicates
what is done in stm32_dma_set_xfer_param() where stm32_dma_get_burst() is
also used.

Fixes: 1c32d6c37c ("dmaengine: stm32-dma: use bitfield helpers")
Fixes: a2b6103b7a ("dmaengine: stm32-dma: Improve memory burst management")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202311060135.Q9eMnpCL-lkp@intel.com/
Link: https://lore.kernel.org/r/20231106134832.1470305-1-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-12-20 17:02:02 +01:00
Jason Liu
f75d905095 Merge tag 'v6.6.3' into lf-6.6.y
This is the 6.6.3 stable release

* tag 'v6.6.3': (526 commits)
  Linux 6.6.3
  drm/amd/display: Change the DMCUB mailbox memory location from FB to inbox
  drm/amd/display: Clear dpcd_sink_ext_caps if not set
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

 Conflicts:
	arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi
	drivers/usb/dwc3/core.c
2023-11-30 09:41:12 -06:00
Jason Liu
6d09067baf Merge tag 'v6.6.2' into lf-6.6.y
This is the 6.6.2 stable release

* tag 'v6.6.2': (634 commits)
  Linux 6.6.2
  btrfs: make found_logical_ret parameter mandatory for function queue_scrub_stripe()
  btrfs: use u64 for buffer sizes in the tree search ioctls
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

Conflicts:
	drivers/clk/imx/clk-imx8mq.c
	drivers/clk/imx/clk-imx8qxp.c
	drivers/media/i2c/ov5640.c
	drivers/misc/pci_endpoint_test.c
2023-11-30 09:40:58 -06:00
Alain Volmat
d356d3379d dmaengine: stm32-mdma: correct desc prep when channel running
commit 03f25d53b1 upstream.

In case of the prep descriptor while the channel is already running, the
CCR register value stored into the channel could already have its EN bit
set.  This would lead to a bad transfer since, at start transfer time,
enabling the channel while other registers aren't yet properly set.
To avoid this, ensure to mask the CCR_EN bit when storing the ccr value
into the mdma channel structure.

Fixes: a4ffb13c89 ("dmaengine: Add STM32 MDMA driver")
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
Tested-by: Alain Volmat <alain.volmat@foss.st.com>
Link: https://lore.kernel.org/r/20231009082450.452877-1-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:05 +00:00
Dong Aisheng
06fec01db7 Merge branch 'pxp/next' into next
* pxp/next: (51 commits)
  LF-9755 dma: pxp_dma_v3: fix typo causing function break
  LF-9509: dma: pxp_dma_v3: fix dereference after null check issue
  LF-9435: dma: pxp_dma_v3: fix dereference after null check
  LF-8978: dma: pxp: fix fetch/store engine low performance issue
  LF-9276 media: mxc: pxp_v4l2: fix flickering issue found on special stream
  ...
2023-11-22 17:04:57 +08:00
Dong Aisheng
8629225fea Merge remote-tracking branch 'origin/dma/sdma' into dma/next
* origin/dma/sdma: (11 commits)
  LF-9861: dmaengine: imx-sdma: Fix audio p2p test on imx8m
  LF-8851: dmaengine: imx-sdma: sdma driver code optimization
  MLK-25266: dmaengine: imx-sdma: add i2c dma support
  LF-301: dmaengine: imx-sdma: Add once more loading firmware
  dmaengine: imx-sdma: Add pm_ops to support suspend & resume
  ...
2023-11-22 17:04:13 +08:00
Dong Aisheng
7c6037e2e4 Merge remote-tracking branch 'origin/dma/qdma' into dma/next
* origin/dma/qdma: (7 commits)
  dmaengine: fsl-dpaa2-qdma: Fix dpdmai unbind call trace issue
  LF-4727 dmaengine: fix qdma test failed
  LF-2780: dma: fsl-qdma: fix coverity issue: Dereference after null check
  fsl-qdma: Init irq after reg initialization
  dmaengine: fsl-dpaa2-qdma: Update DPDMAI interfaces
  ...
2023-11-22 17:04:13 +08:00
Dong Aisheng
b09d13f2da Merge remote-tracking branch 'origin/dma/mxsdma' into dma/next
* origin/dma/mxsdma:
  MA-19046-2 dma: mxs-dma: Turn MXS_DMA as tristate
  MA-19046-1 dma: mxs-dma: Add module license and description
  LF-251-2: dma: mxs-dma: switch from dma_coherent to dma_pool
  LF-251-1: dma: mxs-dma: enable runtime PM for mxs-dma
  MLK-19897: dma: mxs-dma: filter out the unrelated dma channels
2023-11-22 17:04:13 +08:00
Dong Aisheng
f47b97ebfd Merge remote-tracking branch 'origin/dma/edma' into dma/next
* origin/dma/edma: (31 commits)
  LF-10579-02: dmaengine: fsl-edma-v3: add imx95 edma support
  LF-10579-01: dt-bindings: dma: fsl-edma-v3: update binding for imx95
  LF-8690-2: dmaengine: fsl-edma-v3: support edma src id check if using ch_mux
  LF-8690-1: dt-bindings: dma: fsl-edma-v3: optimize binding doc
  dmaengine: fsl-edma-v3: set the max CITER 0x7fff instead of 0x3fff
  ...
2023-11-22 17:04:13 +08:00
Christophe JAILLET
ca2294c127 dmaengine: pxa_dma: Remove an erroneous BUG_ON() in pxad_free_desc()
[ Upstream commit 83c761f568 ]

If pxad_alloc_desc() fails on the first dma_pool_alloc() call, then
sw_desc->nb_desc is zero.
In such a case pxad_free_desc() is called and it will BUG_ON().

Remove this erroneous BUG_ON().

It is also useless, because if "sw_desc->nb_desc == 0", then, on the first
iteration of the for loop, i is -1 and the loop will not be executed.
(both i and sw_desc->nb_desc are 'int')

Fixes: a57e16cf03 ("dmaengine: pxa: add pxa dmaengine driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/c8fc5563c9593c914fde41f0f7d1489a21b45a9a.1696676782.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:26 +01:00
Dan Carpenter
c6dcf5a29f dmaengine: ti: edma: handle irq_of_parse_and_map() errors
[ Upstream commit 14f6d31791 ]

Zero is not a valid IRQ for in-kernel code and the irq_of_parse_and_map()
function returns zero on error.  So this check for valid IRQs should only
accept values > 0.

Fixes: 2b6b3b7420 ("ARM/dmaengine: edma: Merge the two drivers under drivers/dma/")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Link: https://lore.kernel.org/r/f15cb6a7-8449-4f79-98b6-34072f04edbc@moroto.mountain
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:26 +01:00
Fenghua Yu
11b67ef29c dmaengine: idxd: Register dsa_bus_type before registering idxd sub-drivers
[ Upstream commit 88928addee ]

idxd sub-drivers belong to bus dsa_bus_type. Thus, dsa_bus_type must be
registered in dsa bus init before idxd drivers can be registered.

But the order is wrong when both idxd and idxd_bus are builtin drivers.
In this case, idxd driver is compiled and linked before idxd_bus driver.
Since the initcall order is determined by the link order, idxd sub-drivers
are registered in idxd initcall before dsa_bus_type is registered
in idxd_bus initcall. idxd initcall fails:

[   21.562803] calling  idxd_init_module+0x0/0x110 @ 1
[   21.570761] Driver 'idxd' was unable to register with bus_type 'dsa' because the bus was not initialized.
[   21.586475] initcall idxd_init_module+0x0/0x110 returned -22 after 15717 usecs
[   21.597178] calling  dsa_bus_init+0x0/0x20 @ 1

To fix the issue, compile and link idxd_bus driver before idxd driver
to ensure the right registration order.

Fixes: d9e5481fca ("dmaengine: dsa: move dsa_bus_type out of idxd driver to standalone")
Reported-by: Michael Prinke <michael.prinke@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Lijun Pan <lijun.pan@intel.com>
Tested-by: Lijun Pan <lijun.pan@intel.com>
Link: https://lore.kernel.org/r/20230924162232.1409454-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:25 +01:00
Joy Zou
9e34c0115e LF-10579-02: dmaengine: fsl-edma-v3: add imx95 edma support
There are three edma controller one edma-v3 and two edma-v5 on A core.
The edma-v5 is similar with edma-v4.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-11-17 14:51:28 +08:00
Joy Zou
14f92316be LF-8690-2: dmaengine: fsl-edma-v3: support edma src id check if using ch_mux
Support edma src id check in order to make sure ch_mux uniqueness.

The dma_spec->args[0] passes src id. The src id is equal to the chanid,
if the sdma controller channel allocation is fixed. This case doesn't
need to check src id because repeated src id will fail when it requests
channel.

The src id isn't related to chanid if the sdma controller channel
allocation is dynamic. So need check src id, and write the srcid to the
ch_mux register.

This patch checks the src id if it's using. It can avoid setting the same
srcid in different ch_mux.

Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:33 +08:00
Joy Zou
c911e8b3e0 dmaengine: fsl-edma-v3: set the max CITER 0x7fff instead of 0x3fff
When playback 48KHz, 16 bit, 8 channel audio, period size can’t
be set >= 1024, otherwise it will fail with “cannot set hw params:
Invalid argument”.

For the case 1024 frames period size, 8 channel, 16bit case, The
period size in byte = 1024 * 2 * 8 = 16384 bytes. The edma driver
dma_set_max_seg_size(fsl_edma3->dma_dev.dev, 0x3fff), it will limit
the period size to be 16383 bytes.

There are two purposes of adding dma_set_max_seg_size. On the one
hand, it limits the size of memcpy by software trigger. On the other
hand , it can avoids the outs of bounds of CITER register. The CITER
is equal to data_len / nbytes. The nbytes is depend on dma client
addr_width * burst, the min value of the nbytes is one. The max value
of the CITER bit0-14 is 0x7fff when the minor loop channel linking
is disable by default.

I think the driver sets 0x3fff by mistake, So we set the max CITER
0x7fff as max_seg_size. The i.MX[8ulp/8qm/93] which has eDMA3/4 all
share same settings 0x7fff. However, if your period data len exceed
0x7fff, it still fail.

Signed-off-by: Joy Zou <joy.zou@nxp.com>
Acked-by: Dong Aisheng <aisheng.dong@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 18:43:33 +08:00
Shengjiu Wang
81986e1a1a LF-5686: dmaengine: fsl-edma-v3: release descriptor before synchronize
With the case that device_pause() is called, but device_terminate_all()
isn't called before device_synchronize(), the channel descriptor
is not released, which cause next instance can't device_issue_pending()
correctly.

Call the fsl_edma3_terminate_all() if the status is DMA_PAUSED in
device_synchronize() to handle this issue.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:33 +08:00
Joy Zou
e9a3543359 LF-6923-2: dmaengine: fsl-edma-v3: change dual fifo into multi fifo
In some case, the audio may need to support more than two fifoes.
The function of multiple fifo are added by Chancel Liu submit. So
the edma driver has supported multiple fifo for audio, I find the
variable name dual fifo is not match with multiple fifo function.

This patch only optimize the variable name that change dual fifo
into multi fifo.

Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:33 +08:00
Joy Zou
0eeb0ae1f5 LF-6207-1: dmaengine: fsl-edma-v3: support edma-v3 and edma-v4 for imx93
Add edma-v3 AHB and edma-v4 AXI support for imx93.

The edma AHB support 31 channels. Channels and peripherals are
one-to-one corresponding. The edma AXI support 64 channels.
Channels are dynamically allocated.

Add fsl_edma3_engine struct member bus_axi in order to differentiate
edma AHB and AXI. Add fsl_edma3_engine struct member dmaclk and
fsl_edma3_drvdata struct member has_chclk due to the all channels
share edma clocks. It's different from 8ulp that each channel have
its own clock. Add fsl_edma3_engine struct member has_chmux because
the edma AHB not support Channel Multiplexor Configuration.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:33 +08:00
Shengjiu Wang
fb2e0cbcfb LF-6705: dmaengine: fsl-edma-v3: Fix residue issue with MLOFF exist
The nbytes in vtcd only have 10 valid bits with MLOFF exist case,
so can't use whole 30bits for nbytes, which cause issue with micfil
case.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Chancel Liu <chancel.liu@nxp.com>
2023-10-30 18:43:33 +08:00
Robin Gong
4484818c79 MLK-25533-1: dmaengine: fsl-edma-v3: add support for i.mx8ulp
Add has_pd into drvdata to support i.mx8ulp which has no dma
power domain feature.

Add edma mp in dts since i.mx8ulp may need it, while scfw will
touch MP in scfw, but now we just map it without any touching.

There are clocks for every channel and dmamux for choosing the source id
from dts on i.mx8ulp.
Note: dma_spec->args[0] is changed to source/event id on i.mx8ulp, not
channel id on i.mx8qm/qxp since any channel could be freely configured by
dmamux to any source/event on i.mx8ulp.

Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
(cherry picked from commit 87ee321a52)
2023-10-30 18:43:33 +08:00
Robin Gong
7b3e511999 MLK-24825-2: dmaengine: fsl-edma: checking ACTIVE bit for channel stop
Checking ACTIVE bit to ensure channel stop indeed, otherwise, there is risk
that illegal memory touch after channel not stopped with buffer freed.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit 48cea8ae90)
2023-10-30 18:43:33 +08:00
Stoica Cosmin-Stefan
ec82535fb0 LF-631-4: dmaengine: fsl-edma: Add support for S32V234
S32V234 eDMA has two transmission IRQs assigned per channels 0-15 and
16-31, instead of one, like VF610/LS1028A, or 16, like i.MX 7ULP, which is
why this platform needs a custom IRQ initialization function.

Signed-off-by: Stoica Cosmin-Stefan <cosmin.stoica@nxp.com>
Signed-off-by: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Acked-by: Robin Gong <yibin.gong@nxp.com>
2023-10-30 18:43:32 +08:00
Stefan-Gabriel Mirea
4ba5793653 LF-631-1: dmaengine: fsl-edma: Store and free interrupts uniformly
To prepare the eDMA driver for S32V234 support, the "DMA transfer complete"
interrupt lines need to be freed (and therefore stored) in a uniform way.

After this commit, fsl_edma2_irq_init() will no longer accept an arbitrary
number of interrupts in the device tree, but only a pre-established number
of 17 interrupts, as the documentation (fsl-edma.txt) requires.

Signed-off-by: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Acked-by: Robin Gong <yibin.gong@nxp.com>
2023-10-30 18:43:32 +08:00
Fugang Duan
b27afde218 dmaengine: fsl-edma: calculate the real count for slave sg
Calculate the rela count for current slave sg after eDMA stop.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2023-10-30 18:43:32 +08:00
Robin Gong
399674dd26 MLK-17094-1: dmaengine: fsl-edma-v3: add suspend/resume to restore back channel registers
Add suspend to save channel registers and resume to restore them back since
edmav3 may powered off in suspend.

Reviewed-by: S.j. Wang <shengjiu.wang@nxp.com>
Reviewed-by: Andy Duan <fugang.duan@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2023-10-30 18:43:32 +08:00
Joy Zou
8a600d8bef MLK-21443: dmaengine: fsl-edma-v3: clear pending irq before request irq
edma interrupt maybe happened during reboot or watchdog reset, meanwhile
gic never power down on i.mx8QM/QXP, thus the unexpect irq will come in
once edma driver request irq at probe phase. Unfortunately, at that time
that edma channel's power domain which power-up by customer driver such
as audio/uart driver may not be ready, so kernel panic triggered once
touch such edma registers which still not power up in interrupt handler.

This patch move request irq from probe to alloc dma channel so that edma
channel's power domain has already been powered, besides, clear meaningless
interrupt before request irq.

Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:32 +08:00
Joy Zou
3e0f2b83ba MLK-15330-1: dmaengine: fsl-edma-v3: add dual fifo support
There is Audio dual fifo cause that fill fifo one by one and
loop back after every minor loop:
 -- fill the first 32bit width fifo
 -- fill the next 32bit width fifo
 -- +MLOFF signed offset after the above two FIFOs filled
 -- loop back to the first step to handle the next minor loop.

edma has dual fifo mode feature for audio cyclic. Besides dual fifo,
there is also multiple fifo use case. In this patch MLOFF field of
TCD register is modified to support multiple fifo. Correspondingly,
the burst should be set to the suitable value. For example it is set
to the number of channels if there is 1 channel in per fifo.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:32 +08:00
Joy Zou
7a735437dd MLK-14610-1: dmaengine: fsl-edma-v3: add fsl-edma-v3 driver support
Add edma-v3 driver on i.mx8qm.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:32 +08:00
Dong Aisheng
17508933c5 Revert fsl-edma to the version of next-20230804
The working on the verification of upstream edma driver is still in progress.
Let's use the local version first for the rebase.

Revert "dmaengine: fsl-edma: integrate v3 support"

This reverts commit 72f5801a4e.

Revert "dmaengine: fsl-edma: move tcd into struct fsl_dma_chan"

This reverts commit 7536f8b371.

Revert "dmaengine: fsl-edma: refactor chan_name setup and safety"

This reverts commit 9b05554c5c.

Revert "dmaengine: fsl-edma: move clearing of register interrupt into setup_irq function"

This reverts commit f5b3ba52f3.

Revert "dmaengine: fsl-edma: refactor using devm_clk_get_enabled"

This reverts commit a9903de3aa.

Revert "dmaengine: fsl-edma: simply ATTR_DSIZE and ATTR_SSIZE by using ffs()"

This reverts commit ee2dda0646.

Revert "dmaengine: fsl-edma: move common IRQ handler to common.c"

This reverts commit 79434f9b97.

Revert "dmaengine: fsl-edma: Remove enum edma_version"

This reverts commit c26e611433.

Revert "dmaengine: fsl-edma: transition from bool fields to bitmask flags in drvdata"

This reverts commit 9e006b2439.

Revert "dmaengine: fsl-edma: clean up EXPORT_SYMBOL_GPL in fsl-edma-common.c"

This reverts commit 66aac8ea0a.
2023-10-30 18:43:14 +08:00
Dong Aisheng
9d7e24bcc7 Revert "dmaengine: fsl-edma: fix all channels requested when call fsl_edma3_xlate()"
This reverts commit 3fa53518ad.
2023-10-30 18:37:06 +08:00
Dong Aisheng
628a38f8a6 Revert "dmaengine: fsl-dma: fix DMA error when enabling sg if 'DONE' bit is set"
This reverts commit 3c67c5236f.
2023-10-30 18:30:58 +08:00
Dong Aisheng
2e1d3cf25b Revert "dmaengine: fsl-edma: fix edma4 channel enable failure on second attempt"
This reverts commit 3f4b82167a.
2023-10-30 18:30:53 +08:00
Robby Cai
768e074352 LF-9755 dma: pxp_dma_v3: fix typo causing function break
Fix typo introduced from the commit 9a06b8f28f ("LF-9509: dma: pxp_dma_v3:
fix dereference after null check issue") which causes pxp timeout when run
epdc test on MX8ULP EVK ('/unit_tests/Display/mxc_epdc_v2_fb_test.out').

...
[  223.598322] pxp_dispatch_thread: task is timeout
[  223.630619] imx_epdc_v2_fb 2db30000.epdc: PxP operation failed due to timeout
[  223.637898] imx_epdc_v2_fb 2db30000.epdc: Unable to complete PxP update task: pre_prcoess.
Change back to non-inverted RGB565
...

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
(cherry picked from commit a069b2188d)
2023-10-30 16:08:22 +08:00
Guoniu.zhou
cc893c8ad4 LF-9509: dma: pxp_dma_v3: fix dereference after null check issue
In pxp_is_v3(), it call pxp->devdata, but it out of null check for
pxp->devdata, so maybe refer null data when lut_transform is true.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
(cherry picked from commit 9a06b8f28f)
2023-10-30 16:08:22 +08:00
Guoniu.zhou
c0f1bf72b5 LF-9435: dma: pxp_dma_v3: fix dereference after null check
Fix dereference after null check issue reported by coverity(CID:25701409)

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
(cherry picked from commit 8af5982325)
2023-10-30 16:08:22 +08:00
Guoniu.zhou
61f86d18d5 LF-8978: dma: pxp: fix fetch/store engine low performance issue
When pxp read pixel data by fetch engine and output by store engine.
The performance is very low, about 50Mpixel/s when the bytes of both
read and write burst are the default value 8. While increase both
read and write burst bytes to 64, the performance will be improved
to about 125Mpixel/s.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
(cherry picked from commit 519de8586c)
2023-10-30 16:08:22 +08:00
Julien Vuillaumier
2cb0e42acd MGS-7088: dma: pxp: add generic dma-buf cache coherency management
PXP_IOC_FLUSH_PHYMEM ioctl implements support for cache coherency
of buffers previously allocated by the PXP driver using
PXP_IOC_GET_PHYMEM ioctl, hence associated to its PXP driver
handle.

This change adds the option to handle dma coherency on a dma-buf
issued by a generic exporter.
Handle associated to buffers allocated by PXP driver can not be null.
Therefore null handle is used by implementation as criteria to fall
back onto the dma-buf file descriptor passed in arguments, keeping
the backward compatibility.

Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
5367f9ac34 MLK-25315: dma: pxp: add monochrome mode support for PS engine
When input format of PS engine is monochrome, such as Y8 or Y4,
the low 16 bits of PS_VBUF are used as the U/V data in the data
path instead of sourcing U/V data from external buffers. In this
case it represents a fixed value for U/V data.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
1930d2433d LF-6841: dma: pxp: fix pxp timeout issue when run g2d samples test
When run g2d sample test, pxp will report timeout issue. The reason
is that BGRA32 format is used in the case and driver will select AS
engine as input source. But from PXP datasheet, As can't do a simple
copy operation since it usually need to co-work with PS engine which
mean the output pixel value will determined by both AS and PS, such
as raster operation "AS OR PS" which usually used in legacy blending
operation. So add this workaround to fix this issue.

Reproduce steps:
/opt/g2d_samples/g2d_wayland_shm_test

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
ba8c267758 LF-8022: dma: pxp: fix Coverity Issue
Fix Coverity issue 25910920 about dereference after null check

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
bc0d76fae8 LF-6441-06: dma: pxp: add workaround to support RGB with alpha for PS engine
PS engine doesn't support RGB format with alpha channel, so it will discard
alpha value in RGBA/ARGB when PXP carry data from source to destination. The
workaround enable ALPHA_A porter_duff and use source blend mode, so it will
keep the alpha component as same in source buffer.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
27e3f85366 LF-6441-05: dma: pxp: fix pxp convert YUV to ABGR32 with rotation issue
The case is that source buffer is YUYV format and need to convert it
to ABGR32 and do rotation operation. But it will fail due to the reason
as bellow:

Driver will select PS as input engine according to input format(YUYV)
and OUT engine will be used as output engine since PS can't work with
STORE engine, but OUT engine don't support ABGR32 format.

When do rotation operation, ROTATION2(iMX93 reference manual) will be
selected first, but it only can work with fetch engine due to PXP's
limitation(TKT0603343), so driver need to clean it and select ROTATION1
engine to do the rotation operation.

This patch fix this issue by adding ABGR32 format for OUT engine and
selecting ROTATION1 for PS/AS engine

Reproduce steps as bellow and run on iMX93 platform:
/opt/g2d_samples/g2d_basic_test

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
043bb6ba0f LF-6441-04: dma: pxp: enable 16x16 block size for fetch engine by default
PXP block size is selected as 16x16 pixels by default in order to request
data more efficient. So driver also need to set each module which support
block size to 16x16. This patch is used to set input fetch engine block
size to 16x16.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
713cc4dbf6 LF-6441-03: dma: pxp: fill fetch engine active size when user miss them
Fill input fetch engine upper left X-coordinate(in pixels) of the active
surface of the total input memory by frame boundary size when user don't
configure them.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
4027f887ff LF-6441-02: dma: pxp: enable input fetch arbitration bit for iMX93 platform
Enable input fetch engine arbitration bit for iMX93 platform when use its
two channel simultaneously since only one AXI bus interface is connected
to PXP fetch engine channel in order to balance system performance. For
other platform which use PXP don't have this design, so set arbitration
bit as platform data and only enable it for iMX93 platform(TKT0601126).

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
8fdebcad90 LF-6441-01: dma: pxp: remove unnecessary modules in PXP pipeline
The selected modules by user case in PXP pipeline will be configured
and enabled in pxp_2d_task_config() , so don't need to enable unused
modules and re-enable the used modules in pxp_start()

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
3f978fdaf9 LF-8372: dma: pxp/v3: fix U/V offset calculation issue when crop enabled
The offset of U/V relative to Y buffer address base in PS engine is
wrong when format is multi-plane YUV format and crop enabled. So
correct it.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Robby Cai
60bb62a13f LF-8222 dma: pxp: fix build error for pxp_device
../drivers/dma/pxp/pxp_device.c: In function 'pxp_dmabuf_ops_map':
../drivers/dma/pxp/pxp_device.c:666:40: error: 'struct dma_buf' has no member named 'lock'
  666 | struct mutex *lock = &db_attach->dmabuf->lock;
      |                                        ^~
../drivers/dma/pxp/pxp_device.c:666:15: warning: unused variable 'lock' [-Wunused-variable]
  666 | struct mutex *lock = &db_attach->dmabuf->lock;
      |               ^~~~

Remove internal dma-buf lock as it's removed in new framework and dma-buf reservation
is guaranteed to be locked by importers during the mapping operations.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Guoniu.zhou <guoniu.zhou@nxp.com>
2023-10-30 16:08:21 +08:00
Jindong Yue
8c40cd2dab MA-19811-3 dma: pxp: Support building pxp driver as module
Change defconfig as tristate type, and export
register/unregister API symbols.

Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Change-Id: If457ca1fd5433a34ab82f750e3a298af9d71f234
2023-10-30 16:08:21 +08:00
Guoniu.zhou
53ba277269 LF-7334: dma: pxp: v3: fix kernel dump issue when enable debug output
Kernel will dump when enable debug output in PXP driver with iMX93 platform.
The root cause is that PXP in iMX93 remove LUT related register compared
with other PXP version, so access non exist register in PXP will trigger
bus error signal to system. The solution is to mark these registers as
optional and skip them when run iMX93 PXP.

Hardware name: NXP i.MX93 11X11 EVK board (DT)
pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : dump_pxp_reg+0xc8/0xec
lr : dump_pxp_reg+0xe0/0xec
sp : ffff800009e3b660
x29: ffff800009e3b660 x28: 00000000fffffffa x27: ffff80000973f2d8
x26: 0000000000000001 x25: 0000000000000070 x24: ffff0000047040e0
x23: ffff80000973ee60 x22: ffff8000096d5638 x21: ffff800009e3bb28
x20: ffff000004704080 x19: ffff800009e3ba08 x18: 0000000000000008
x17: 3030303030303078 x16: 30203a5d3039315b x15: ffff800009dbcb59
x14: 0000000000000000 x13: ffff800009c41f78 x12: 0000000000000420
x11: 0000000000000160 x10: ffff800009c41f78 x9 : ffff800009c41f78
x8 : 00000000ffffefff x7 : ffff800009c99f78 x6 : ffff800009c99f78
x5 : ffff80000a790240 x4 : 0000000000000240 x3 : 0000000000000000
x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000004080000
Call trace:
 dump_pxp_reg+0xc8/0xec
 pxp_probe+0x31c/0x9e4
 platform_probe+0x68/0xe0
 really_probe.part.0+0x9c/0x30c
 __driver_probe_device+0x98/0x144
 driver_probe_device+0x44/0x15c
 __driver_attach+0x80/0x18c
 bus_for_each_dev+0x70/0xd0
 driver_attach+0x24/0x30
 bus_add_driver+0x108/0x1fc
 driver_register+0x78/0x130
 __platform_driver_register+0x28/0x34
 pxp_init+0x1c/0x28
 do_one_initcall+0x50/0x1b0
 kernel_init_freeable+0x20c/0x290
 kernel_init+0x24/0x12c
 ret_from_fork+0x10/0x20
 Code: d65f03c0 f9400e85 b9400264 8b2440a5 (b94000a5)
 ---[ end trace b6e6cc2fe83edf8f ]---
 Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
1a06109b34 LF-6806: dma: pxp: workaround for PXP when do RGB to gray color conversion
CSC2 engine in PXP has IC bug(TKT272216) and fixed after 7D PXP version.
Driver update new CSC coefficient provided by PXP IP owner(MLK-25625-02).
But when run e-ink case, it can't do clear operation after applying the
patch. We don't know reason until now, so add a temporary patch to fix it
and will remove after finding the root cause.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
3e0af81f1c LF-6741: dma: pxp: fix coverity issue: Uninitialized scalar variable
Fix coverity issue: 22322873 Uninitialized scalar variable

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
4240caef4b LF-6743: dma: pxp: fix coverity issue: dereference before null check
Fix coverity issue 22322872: dereference before null check

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Li Yang
3ee1522c44 dma: pxp_device: Replace dma-buf-map with iosys-map
Since upstream commit 7938f421816 ("dma-buf-map: Rename to iosys-map")
the dma-buf-map names need to be updated.

Signed-off-by: Li Yang <leoyang.li@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
f21d626cdd LF-6244-06: dma: pxp: add PXP support for iMX93 platform
Add PXP support for iMX93 platform

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
d3361bfc50 LF-6244-03: dma: pxp: config block size to 16x16 for primary path
Select block size to 16x16 pixel blocks for PXP primary path in order
to improve PXP performance

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
84cef45c10 LF-6244-02: dma: pxp: config block size to 16x16 for fetch and store engine
Config block size to 16x16 for input fetch and store engine in order to
improve PXP performance

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
93b78fa77c LF-6244-01: dma: pxp: config write burst size to 64 bytes
Config write burst size to 64 bytes in order to improve PXP performance

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
776f92e9f1 MLK-25625-02: dma: pxp_v3: correct csc2 coefficient
Correct csc2 coefficient due to PXP issue(TKT272216). It apply to PXP
version after than iMX7D

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Tested-by: Jared Hu <jared.hu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
50758a54b2 MLK-25625-01: dma: pxp_v3: expose multi address settting for multi-plane format
In current pxp driver, U and V address are caculated by driver when input/output
format is multi-plane format, such as NV12. But for some cases, user space want
to set U and V address by themself, so expose multi address settting for the case

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Tested-by: Jared Hu <jared.hu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Robby Cai
75c385c034 LF-5942-2 media: pxp_device: Fix build warning with clang
CC      drivers/dma/pxp/pxp_device.o
drivers/dma/pxp/pxp_device.c:358:8: warning: implicit conversion from enumeration type
'enum dma_data_direction' to different enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
                                                 DMA_TO_DEVICE,

To reproduce the warnings:
1) Install clang 12:
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 12

2) Build kernel with clang:
export PATH=/usr/lib/llvm-12/bin/:$PATH  LLVM=1
make ARCH=arm64 imx_v8_defconfig
make ARCH=arm64

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 16:08:20 +08:00
Robby Cai
ca5c6c2c68 LF-5942-1 dma: pxp_v3: fix build warning with clang
drivers/dma/pxp/pxp_dma_v3.c:7769:15: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
                if ((output == enode->adjvex)) {
                     ~~~~~~~^~~~~~~~~~~~~~~~
drivers/dma/pxp/pxp_dma_v3.c:7769:15: note: remove extraneous parentheses around the comparison to silence this warning
                if ((output == enode->adjvex)) {
                    ~       ^               ~
drivers/dma/pxp/pxp_dma_v3.c:7769:15: note: use '=' to turn this equality comparison into an assignment
                if ((output == enode->adjvex)) {

To reproduce the warnings:
1) Install clang 12:
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 12

2) Build kernel with clang:
export PATH=/usr/lib/llvm-12/bin/:$PATH  LLVM=1
make ARCH=arm64 imx_v8_defconfig
make ARCH=arm64

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 16:08:20 +08:00
Robby Cai
ee98bc2ca3 LF-5061 dma: pxp_v3: Fix Coverity Issue 17888794:Out-of-bounds access
Fixed together with LF-5068, just make the coverity checking system no complain.
actually there's no potential issue for out-of-bounds access.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
bae2ea06e1 LF-4550: dma: pxp: fix -Wimplicit-fallthrough build warning issue
In linux-nxp repo, -Wimplicit-fallthrough is set to 5, so it causes
warning for /* fall through */ in switch case statement. So the patch
is used to fix it

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
608692314d MLK-25707-01: dma: pxp_v3: add software restart for iMX8ULP
When pxp driver probe, it will do software reset and reconfigure
operation. For iMX8ULP, power domain will be turned off in runtime
suspend and the status will be missed, so need to do software reset
and reconfigure operation again. But for other platform, such as 7D,
it's not necessary.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
f69da07357 MLK-25591-04: uapi: linux: fix segmentation fault when run pxp lib unit test
Fix segmentation fault when run pxp lib unit test on iMX8ULP platform

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by  : Robby.Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
610925eade MLK-25591-06: dma: pxp_v3: Add PXP driver support for iMX8ULP
Add PXP driver support for iMX8ULP platform

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by  : Robby.Cai <robby.cai@nxp.com>
2023-10-30 16:08:19 +08:00