adstraw commented on code in PR #12411:
URL: https://github.com/apache/tvm/pull/12411#discussion_r949035189
##########
src/runtime/hexagon/hexagon_user_dma.cc:
##########
@@ -28,55 +30,41 @@ namespace tvm {
namespace runtime {
namespace hexagon {
-int init_hexagon_user_dma() {
-#if __HEXAGON_ARCH__ >= 68
+unsigned int HexagonUserDMA::Init() {
// reset DMA engine
unsigned int status = dmpause() & DM0_STATUS_MASK;
- if (status != DM0_STATUS_IDLE) {
- return DMA_FAILURE;
- }
-#endif
- return DMA_SUCCESS;
+ return status;
}
-int hexagon_user_dma_1d_sync_helper(void* dst, void* src, uint32_t length) {
-#if __HEXAGON_ARCH__ >= 68
- static int config_dma = init_hexagon_user_dma();
- if (config_dma != DMA_SUCCESS) {
+int HexagonUserDMA::Copy(void* dst, void* src, uint32_t length) {
+ // length limited to 24 bits
+ if (length > DESC_LENGTH_MASK) {
return DMA_FAILURE;
}
- uint64_t src64 = reinterpret_cast<uint64_t>(src);
// source address limited to 32 bits
- if (src64 > DESC_SRC_MASK) {
+ uint64_t src64 = reinterpret_cast<uint64_t>(src);
+ if (!src64 || src64 > DESC_SRC_MASK) {
return DMA_FAILURE;
}
- uint64_t dst64 = reinterpret_cast<uint64_t>(dst);
// destination address limited to 32 bits
- if (dst64 > DESC_DST_MASK) {
- return DMA_FAILURE;
- }
-
- // length limited to 24 bits
- if (length > DESC_LENGTH_MASK) {
+ uint64_t dst64 = reinterpret_cast<uint64_t>(dst);
+ if (!dst64 || dst64 > DESC_DST_MASK) {
return DMA_FAILURE;
}
- uint32_t src32 = src64 & DESC_SRC_MASK;
- uint32_t dst32 = dst64 & DESC_DST_MASK;
+ uint32_t src32 = static_cast<uint32_t>(src64);
+ uint32_t dst32 = static_cast<uint32_t>(dst64);
+ // allocate new descriptor
void* dma_desc = nullptr;
-
int ret = posix_memalign(&dma_desc, DMA_DESC_2D_SIZE, DMA_DESC_2D_SIZE);
- if (ret) {
Review Comment:
Added to the backlog
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]