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

initial software driver for dma #100

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft

initial software driver for dma #100

wants to merge 43 commits into from

Conversation

NazerkeT
Copy link
Contributor

[Not a candidate for actually merging yet!]

Thanks for the comments Wes! I have already checked them, however will still create a PR here for David with older version before changing/coding other pieces.

Thanks,
Best wishes

Copy link
Collaborator

@davidchisnall davidchisnall left a comment

Choose a reason for hiding this comment

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

Thanks for posting this for early review. I've left some comments inline, I hope they're helpful.

sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
Copy link
Contributor

@nwf-msr nwf-msr left a comment

Choose a reason for hiding this comment

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

This looks like a good start. Good job onboarding enough xmake and __cheri_ annotations to be dangerous. :)

Sorry if any of my comments &| questions below are misguided as a result of having spent too much time with software.

sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
* this statement returns the less signifance bit
* to show the halted status
*/
return dmaInterface->status & 0x1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you repurpose control's bottom bit rather than needing a separate status word?

sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/core/dma/dma.h Outdated Show resolved Hide resolved
sdk/core/dma/dma.h Outdated Show resolved Hide resolved
* claim the memory
*/

size_t sourceClaimSize = heap_claim(dmaHeap, sourceAddress);
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this is sufficient grounds to want a heap_claim(SObj heapCapability, void*... objects) that amortizes the compartment call overhead. Similarly for heap_free(). @davidchisnall?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That’s a good idea. In particular, the call could atomically succeed or fail, which simplifies error handling for the caller. I think we’d want to bound the maximum number of objects that can be claimed in a single operation and we can’t used variadic an across compartment calls so it would have to pass an array and a length.

* A function below claims the source and target addresses of the DMA interface.
* While, DMA is in progress, these addresses should not be freed
*/
__cheri_compartment("dma") int claim_dma(uint32_t *sourceAddress,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these (claim and free) functions are not what you mean to be exporting from the compartment. I was expecting something something more like write_conf (though probably a fusion of write_conf, write_strides, and start), I think.

To support multiple users of DMA, we probably want that "memmove_but_with_dma" call, whatever it's named, to take a Timeout for waiting on the DMA engine to become available and for it to use a futex to communicate with the engine's IRQ handler? But that's perhaps a discussion for later.

sdk/core/dma/dma.h Outdated Show resolved Hide resolved
sdk/core/dma/dma.h Outdated Show resolved Hide resolved
sdk/core/dma/dma.h Outdated Show resolved Hide resolved
sdk/core/dma/dma_compartment.cc Outdated Show resolved Hide resolved
sdk/core/dma/dma_compartment.cc Outdated Show resolved Hide resolved
* claim the memory
*/

size_t sourceClaimSize = heap_claim(dmaHeap, sourceAddress);
Copy link
Collaborator

Choose a reason for hiding this comment

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

That’s a good idea. In particular, the call could atomically succeed or fail, which simplifies error handling for the caller. I think we’d want to bound the maximum number of objects that can be claimed in a single operation and we can’t used variadic an across compartment calls so it would have to pass an array and a length.

sdk/core/dma/dma_compartment.h Outdated Show resolved Hide resolved
/**
* Setting source and target addresses, and length fields
*/
device().sourceAddress = *sourceAddress;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line looks wrong. You’re dereferencing the pointer and using whatever it happens to point to as the address. I think you want to be using the address from the capability. Same comment for the next line.

sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
sdk/include/platform/ibex/platform-dma.hh Outdated Show resolved Hide resolved
examples/10.dma_test/dma_test.cc Outdated Show resolved Hide resolved
examples/10.dma_test/dma_test.cc Outdated Show resolved Hide resolved
examples/10.dma_test/xmake.lua Show resolved Hide resolved
sdk/core/dma/dma_compartment.cc Outdated Show resolved Hide resolved
sdk/core/dma/dma_compartment.cc Outdated Show resolved Hide resolved
sdk/core/dma/dma_compartment.cc Outdated Show resolved Hide resolved
sdk/core/dma/dma_compartment.cc Outdated Show resolved Hide resolved
sdk/core/dma/dma_compartment.cc Outdated Show resolved Hide resolved
@nwf-msr
Copy link
Contributor

nwf-msr commented Aug 16, 2023

I swear I hit "cancel review" to get rid of some stale notes. Sorry for the noise.

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.

4 participants