Skip to content

drivers: imx: Dummy DMA driver - #1838

Merged
jajanusz merged 5 commits into
thesofproject:masterfrom
paulstelian97:topic/imx/dummydma
Oct 11, 2019
Merged

jajanusz merged 5 commits into
thesofproject:masterfrom
paulstelian97:topic/imx/dummydma

Conversation

@paulstelian97

Copy link
Copy Markdown
Collaborator

For the communication between host and DSP a dummy DMA driver which
simply does memcpy is sufficient (given that a sizeable amount of
physical memory is shared)

This commit holds the initial implementation of the dummy DMA driver.

Signed-off-by: Paul Olaru paul.olaru@nxp.com

@paulstelian97
paulstelian97 force-pushed the topic/imx/dummydma branch 2 times, most recently from c6d0a22 to 3c52432 Compare September 17, 2019 13:34
Comment thread src/drivers/imx/dummy-dma.c Outdated
@paulstelian97

Copy link
Copy Markdown
Collaborator Author

Remaining Checkpatch warnings are probably benign (long messages making lines too long and that one usage of memcpy which comes from the design of the driver). Otherwise, unless there is another issue this should be mergeable.

@jajanusz

Copy link
Copy Markdown
Contributor

@paulstelian97 Yea WARNING: line over 80 characters is result of outdated checkpatch, it was lifted in kernel's checkpatch - if last argument is string literal it can have over 80chars, so feel free to ignore that one. But please fix the one that recommends to use memcpy_s instead of memcpy.

@paulstelian97

paulstelian97 commented Sep 18, 2019 •

Copy link
Copy Markdown
Collaborator Author

@paulstelian97 Yea WARNING: line over 80 characters is result of outdated checkpatch, it was lifted in kernel's checkpatch - if last argument is string literal it can have over 80chars, so feel free to ignore that one. But please fix the one that recommends to use memcpy_s instead of memcpy.

I'd argue that one is hard to actually fix in a semantically meaningful way. I don't have anything other than the elem itself. So I should just do something like assert(!memcpy_s(dest, size, src, size)) or the like? Just to make Checkpatch happy? (It doesn't introduce any actual safety)

@paulstelian97
paulstelian97 force-pushed the topic/imx/dummydma branch 2 times, most recently from 9ed1ae9 to b30629b Compare September 18, 2019 12:34
@paulstelian97

Copy link
Copy Markdown
Collaborator Author

Pushed, also noticed I forgot to remove the "[DO NOT MERGE]" tag from this one.

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The dummy driver looks like generic code that may be useful for similar platforms so should probably be drivers/generic directory ?
Also need more commit message on your first patch and the dummy driver could do with more comments explaining what it's doing and why. A top level description in the comments would be good too explaining the sue case since it may not be obvious.

@paulstelian97

Copy link
Copy Markdown
Collaborator Author

The dummy driver looks like generic code that may be useful for similar platforms so should probably be drivers/generic directory ?

Will do. For the moment the i.MX platform is the only one where this can be used (on the current Intel ones the DSP cannot directly access host memory, can it?)

Also need more commit message on your first patch and the dummy driver could do with more comments explaining what it's doing and why. A top level description in the comments would be good too explaining the sue case since it may not be obvious.

For the first patch it isn't actually very obvious even to me but I needed to add it because otherwise I couldn't get actual, physical host addresses with HOST_PTABLE disabled (the descriptor would just put NULL as the first host address and I'd have no means to get the real one). The patch is actually larger than it should have been because it includes fixing some compile errors that show up by enabling that config. Any suggestions?

For the driver itself, I will think about it and will do.

Comment thread src/drivers/imx/dummy-dma.c Outdated
Comment thread src/drivers/imx/dummy-dma.c Outdated
Comment thread src/drivers/Kconfig Outdated
Comment thread src/drivers/imx/dummy-dma.c Outdated
Comment thread src/drivers/imx/dummy-dma.c Outdated
Comment thread src/drivers/imx/dummy-dma.c Outdated
Comment thread src/drivers/imx/dummy-dma.c Outdated
Comment thread src/drivers/imx/dummy-dma.c Outdated
Comment thread src/drivers/imx/dummy-dma.c Outdated
Comment thread src/drivers/Kconfig Outdated
Comment thread src/drivers/imx/ipc.c Outdated
Comment thread src/drivers/imx/ipc.c Outdated
Comment thread src/drivers/imx/ipc.c Outdated
@paulstelian97
paulstelian97 force-pushed the topic/imx/dummydma branch 3 times, most recently from 7f51f12 to b41fd4e Compare October 8, 2019 15:01
@dbaluta

dbaluta commented Oct 8, 2019

Copy link
Copy Markdown
Collaborator

@paulstelian97 this is in a good shape. We need one more review to push it.

@tlauda @jajanusz @plbossart @groncarolo @jlacla

@paulstelian97
paulstelian97 removed the request for review from libinyang October 8, 2019 15:29

@tlauda tlauda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small nitpick + copy size, which I think is important. Also checkpatch is complaining.

Comment thread src/drivers/imx/dummy-dma.c Outdated
Comment thread src/drivers/imx/dummy-dma.c Outdated
@paulstelian97
paulstelian97 force-pushed the topic/imx/dummydma branch 2 times, most recently from ba8fdad to c759beb Compare October 9, 2019 15:33
Paul Olaru added 5 commits October 10, 2019 17:06
Enabling this config option changes the way the SG elems are generated,
such that the host addresses in the elems are actual, physical
addresses.

This is required by the Dummy DMA driver, which can only operate with
said physical addresses.

This commit enables the config option and fixes compile errors which
appeared after this enabling.

Signed-off-by: Paul Olaru <paul.olaru@nxp.com>
The dummy DMA is a software-based DMA which acts as a host DMA. This
one can be implemented in software alone because all host physical
address space (at least the RAM portion) is accessible directly from
the DSP on this platform.

The driver works by taking the physical addresses for both the source
and destination addresses from the elems. This works because no paging
is enabled on the DSP side, and because the page tables interpretation
allows these elements to actually have physical addresses on the host
side. Given these addresses, the copy itself is done synchronously on
the DSP within a memcpy_s call.

Signed-off-by: Paul Olaru <paul.olaru@nxp.com>
This is to optimize memory consumption from this driver. With 32
channels we would have needed a memory block >1024 bytes in size to
allocate the dma_chan_data array. However 16 channels (which means
allocating a smaller block) should be enough for everyone.

Signed-off-by: Paul Olaru <paul.olaru@nxp.com>
This driver can apply to any platform with the buffers in shared memory,
not just to i.MX.

Signed-off-by: Paul Olaru <paul.olaru@nxp.com>
This config option also encapsulates a required dependency on
HOST_PTABLE.

Signed-off-by: Paul Olaru <paul.olaru@nxp.com>
@dbaluta

dbaluta commented Oct 11, 2019

Copy link
Copy Markdown
Collaborator

@lgirdwood @tlauda this is working well for us now. I think we fixed all the comments reported.

@jajanusz
jajanusz dismissed lgirdwood’s stale review October 11, 2019 12:20

Stale review, changes have been applied

@jajanusz

Copy link
Copy Markdown
Contributor

Checkpatch errors safe to ignore - 80 chars limit doesn't apply for literals in kernel (we should update our checkpatch to match it)

@jajanusz
jajanusz merged commit 51a6c9c into thesofproject:master Oct 11, 2019
@paulstelian97
paulstelian97 deleted the topic/imx/dummydma branch October 23, 2019 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants