-
Notifications
You must be signed in to change notification settings - Fork 46
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
…ase should be similar
There was a problem hiding this 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.
* this statement returns the less signifance bit | ||
* to show the halted status | ||
*/ | ||
return dmaInterface->status & 0x1; |
There was a problem hiding this comment.
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/core/dma/dma_compartment.cc
Outdated
* claim the memory | ||
*/ | ||
|
||
size_t sourceClaimSize = heap_claim(dmaHeap, sourceAddress); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
* 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, |
There was a problem hiding this comment.
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.
Co-authored-by: Nathaniel Filardo <[email protected]>
Co-authored-by: Nathaniel Filardo <[email protected]>
sdk/core/dma/dma_compartment.cc
Outdated
* claim the memory | ||
*/ | ||
|
||
size_t sourceClaimSize = heap_claim(dmaHeap, sourceAddress); |
There was a problem hiding this comment.
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.
/** | ||
* Setting source and target addresses, and length fields | ||
*/ | ||
device().sourceAddress = *sourceAddress; |
There was a problem hiding this comment.
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.
…ase should be similar
Co-authored-by: Nathaniel Filardo <[email protected]>
Co-authored-by: Nathaniel Filardo <[email protected]>
I swear I hit "cancel review" to get rid of some stale notes. Sorry for the noise. |
[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