Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dma: dma_nxp_edma: fix for dynamic IRQ handling and support for per-channel PDs #82431

Merged
merged 8 commits into from
Dec 13, 2024

Conversation

LaurentiuM1234
Copy link
Collaborator

This series includes:

  1. A fix for drivers: dma: dma_nxp_edma: edma_start() is not isr-ok on imx8 platforms #80573.
  2. Support for per-channel power domains on QM/QXP.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Dec 2, 2024

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_nxp zephyrproject-rtos/hal_nxp@ee22de2 zephyrproject-rtos/hal_nxp@d2e2514 (master) zephyrproject-rtos/[email protected]

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

west.yml Show resolved Hide resolved
Copy link
Collaborator

@iuliana-prodan iuliana-prodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO you should move patch 6 and 7 (those about the split of imx8.dtsi into 8qm and 8qxp) in another PR.
This way that PR will be merge faster since it has no dependency on NXP HAL or anything else.

}

return false;
irq_enable(chan->irq);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You add the irq_enable() on dma_chan_filter() - which is a different function than dma_request_channel() as mentioned in the commit message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, the commit message is supposed to refer to dma_request_channel and dma_release_channel. The filter function is called as part of dma_request_channel.

return;
}

#ifdef CONFIG_NXP_IRQSTEER
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you disable the irq only for CONFIG_NXP_IRQSTEER, in other cases what happens?
Since, above, in edma_channel_filter() you enable the irq for "all".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat the way we used to do things. We used to call irq_enable() in dma_config(), resulting in irq_enable being called multiple times with no irq_disable() so the approach should be fine. There's no reference counting for non-irqstr-based SoCs.

iuliana-prodan
iuliana-prodan previously approved these changes Dec 10, 2024
@decsny decsny removed their request for review December 10, 2024 14:30
Copy link
Member

@dleach02 dleach02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking until #82811 merges.

I've merged the HAL side and updated this PR with the new SHA

@zephyrbot zephyrbot removed the DNM This PR should not be merged (Do Not Merge) label Dec 11, 2024
@LaurentiuM1234
Copy link
Collaborator Author

Rebased again and updated the description of the manifest update commit.

iuliana-prodan
iuliana-prodan previously approved these changes Dec 11, 2024
Bump up the hal_nxp revision to pull in the following patch:

dd8bc4f60e7("drivers: edma_rev2: add macro for CHn_CSR's ACTIVE bit")

Signed-off-by: Laurentiu Mihalcea <[email protected]>
The channel state transitions are currently performed at the
beginning of each of the functions that triggers them
(e.g: edma_start(), edma_stop(), etc...).  The main issue with
this approach is the fact if there's any failures after the state
transition then the channel will be in the target state without
performing the required steps for it.

For instance, during edma_config(), if any of the functions after
the state transition (the channel_change_state() call) fails
(e.g: get_transfer_type()) fails then the state of the channel
will be CONFIGURED even if not all the required steps were performed
(e.g: setting the MUX, configuring the transfer, etc...).

To fix this, split the state transition into two steps:

	1) Check if the transition is possible.
	2) Do the transition.

First step should be done before any configurations to make sure
that we should be performing them in the first place, while the
second step should be performed after all configurations, thus
guaranteeing that all the required steps for the target state were
performed before transitioning to it.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
Commit 48b98a9 ("drivers: dma: dma_nxp_edma: disable IRQs when
not needed") moved the IRQ enable operation to edma_start() and added
an IRQ disable operation in edma_stop(). This is wrong because it breaks
the DMA API contract w.r.t dma_start() being `isr-ok` on imx8qm/imx8qxp.

As such, move the IRQ enable and disable operations in
dma_request_channel() and dma_release_channel().

Note1: managing the interrupts like this is only really needed when
dealing with interrupt controllers that have a power domain associated
with it (which is the case for irqstr on imx8qm/imx8qxp).

Note2: Zephyr has no reference count for shared interrupts so disabling
a shared interrupt without checking if someone else is using it is
dangerous.

Based on the aforementioned notes, the irq_disable() operation is only
performed if irqstr is used as an interrupt controller (which is only
the case for imx8qm/imx8qxp). Otherwise, the operation isn't needed.

Fixes zephyrproject-rtos#80573.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
Make sure that channels are inactive before releasing them.
This way, there won't be any leftover interrupts needed to be
handled when disabling IRQs.

This patch introduces a new state: CHAN_STATE_RELEASING. This is mostly
useful for the per-channel PD support in which the ISR needs to check
that the channel PD is enabled before attempting to access its register
space.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
Add support for managing per-channel power domains (1 channel,
1 PD).

Signed-off-by: Laurentiu Mihalcea <[email protected]>
imx8qm and imx8qxp have a couple of differences regarding
the peripheral address spaces and how the DT nodes are
configured, which is why using a generic DTSI (nxp_imx8.dtsi)
for the both of them is not right.

One of the differences between the two, which affects Zephyr
is the fact that irqstr's address space is different. Up until
now this has been dealt with at the board level (i.e:
imx8qxp_mek_mimx8qx6_adsp.dts), which is not right as this is not
board-specific, but rather soc-specific. Additionally, this
causes the following warning during compilation:

"unit address and first address in 'reg' (0x51080000) don't
match for /interrupt-controller@510a0000"

To fix this, add two new DTSIs: nxp_imx8qm and nxp_imx8qxp.
Each board (i.e: imx8qm_mek and imx8qxp_mek) will have to include
the DTSI for their soc instead of the generic DTSI (i.e: nxp_imx8).

Signed-off-by: Laurentiu Mihalcea <[email protected]>
This has no address space and doesn't belong between peripheral
nodes. Move it up the DTSI for better visibility. No functional
change.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
Add power domains for EDMA0's channels 6, 7, 14, and 15.
For QM these are identified as IMX_SC_R_DMA_2_*, while
for QXP thy are identified as IMX_SC_R_DMA_0_*.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
Copy link
Member

@dleach02 dleach02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependency merged

@kartben kartben merged commit 3651725 into zephyrproject-rtos:main Dec 13, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: DMA Direct Memory Access area: Xtensa Xtensa Architecture manifest manifest-hal_nxp platform: NXP Drivers NXP Semiconductors, drivers platform: NXP MPU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants