diff options
author | Tomasz Moń <desowin@gmail.com> | 2021-07-07 18:48:24 +0200 |
---|---|---|
committer | Tomasz Moń <desowin@gmail.com> | 2021-07-07 18:48:24 +0200 |
commit | bce6771730d88f52fbb2e756bda457b0ce35d36b (patch) | |
tree | 22e6ef311db110f0d126fdd76ee50af3d1611ea1 | |
parent | 7f638e54eeee25399c38d404882e1c943626c36a (diff) | |
download | rockbox-bce6771730d88f52fbb2e756bda457b0ce35d36b.tar.gz rockbox-bce6771730d88f52fbb2e756bda457b0ce35d36b.zip |
Sansa Connect: Reduce USB RX buffers from 129 to 2
Reducing number of fake RX buffers saves a bit more than 127 KiB RAM.
Fix compilation with CPPI logging enabled.
Change-Id: If1ad3a6fc251e284caaac78c2406a58f3d6547bb
-rw-r--r-- | firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.c | 47 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.h | 4 |
2 files changed, 27 insertions, 24 deletions
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.c b/firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.c index 93477bed9e..1ce6e4a640 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.c | |||
@@ -27,9 +27,12 @@ | |||
27 | #include "system.h" | 27 | #include "system.h" |
28 | #include "kernel.h" | 28 | #include "kernel.h" |
29 | #include "panic.h" | 29 | #include "panic.h" |
30 | #include "logf.h" | ||
31 | #include "tnetv105_usb_drv.h" | 30 | #include "tnetv105_usb_drv.h" |
32 | #include "tnetv105_cppi.h" | 31 | #include "tnetv105_cppi.h" |
32 | #if USB_CPPI_LOGGING | ||
33 | #define LOGF_ENABLE | ||
34 | #endif | ||
35 | #include "logf.h" | ||
33 | 36 | ||
34 | /* This file is pretty much directly copied from the Sansa Connect | 37 | /* This file is pretty much directly copied from the Sansa Connect |
35 | * Linux kernel source code. This is because the functionality is | 38 | * Linux kernel source code. This is because the functionality is |
@@ -71,11 +74,11 @@ static uint8_t ch0_rx_buf[CPPI_DMA_RX_BUF_SIZE]; | |||
71 | static uint8_t ch1_rx_buf[CPPI_DMA_RX_BUF_SIZE]; | 74 | static uint8_t ch1_rx_buf[CPPI_DMA_RX_BUF_SIZE]; |
72 | 75 | ||
73 | #if USB_CPPI_LOGGING | 76 | #if USB_CPPI_LOGGING |
74 | #define cppi_log_event0(msg) usb_log_event(msg, LOG_EVENT_D0, 0, 0, 0, 0) | 77 | #define cppi_log_event0(msg) logf(msg) |
75 | #define cppi_log_event1(msg, data0) usb_log_event(msg, LOG_EVENT_D1, data0, 0, 0, 0) | 78 | #define cppi_log_event1(msg, data0) logf(msg " %lx", (uint32_t)data0) |
76 | #define cppi_log_event2(msg, data0, data1) usb_log_event(msg, LOG_EVENT_D2, data0, data1, 0, 0) | 79 | #define cppi_log_event2(msg, data0, data1) logf(msg " %lx %lx", (uint32_t)data0, (uint32_t)data1) |
77 | #define cppi_log_event3(msg, data0, data1, data2) usb_log_event(msg, LOG_EVENT_D3, data0, data1, data2, 0) | 80 | #define cppi_log_event3(msg, data0, data1, data2) logf(msg " %lx %lx %lx", (uint32_t)data0, (uint32_t)data1, (uint32_t)data2) |
78 | #define cppi_log_event4(msg, data0, data1, data2, data3) usb_log_event(msg, LOG_EVENT_D4, data0, data1, data2, data3) | 81 | #define cppi_log_event4(msg, data0, data1, data2, data3) logf(msg " %lx %lx %lx %lx", (uint32_t)data0, (uint32_t)data1, (uint32_t)data2, (uint32_t)data3) |
79 | #else | 82 | #else |
80 | #define cppi_log_event0(x) | 83 | #define cppi_log_event0(x) |
81 | #define cppi_log_event1(x, y) | 84 | #define cppi_log_event1(x, y) |
@@ -439,7 +442,7 @@ void tnetv_cppi_dump_info(struct cppi_info *cppi) | |||
439 | cppi_rcb *rcb; | 442 | cppi_rcb *rcb; |
440 | 443 | ||
441 | logf("CPPI struct:\n"); | 444 | logf("CPPI struct:\n"); |
442 | logf("Buf mem: %x Buf size: %d int: %x %x\n\n", (uint32_t) cppi->dma_mem, cppi->dma_size, tnetv_usb_reg_read(TNETV_USB_RX_INT_STATUS), tnetv_usb_reg_read(DM320_VLYNQ_INTST)); | 445 | logf("Buf mem: %lx Buf size: %d int: %lx %lx\n\n", (uint32_t) cppi->dma_mem, cppi->dma_size, tnetv_usb_reg_read(TNETV_USB_RX_INT_STATUS), tnetv_usb_reg_read(VL_INTST)); |
443 | 446 | ||
444 | for (ch = 0; ch < CPPI_NUM_CHANNELS; ch++) | 447 | for (ch = 0; ch < CPPI_NUM_CHANNELS; ch++) |
445 | { | 448 | { |
@@ -447,9 +450,9 @@ void tnetv_cppi_dump_info(struct cppi_info *cppi) | |||
447 | pTxCtl = &cppi->tx_ctl[ch]; | 450 | pTxCtl = &cppi->tx_ctl[ch]; |
448 | 451 | ||
449 | logf("ch: %d\n", ch); | 452 | logf("ch: %d\n", ch); |
450 | logf(" rx_numbufs: %d active %d free_buf_cnt %d\n", pRxCtl->RxNumBuffers, pRxCtl->RxActive, tnetv_usb_reg_read(TNETV_USB_RX_FREE_BUF_CNT(ch))); | 453 | logf(" rx_numbufs: %d active %ld free_buf_cnt %ld\n", pRxCtl->RxNumBuffers, pRxCtl->RxActive, tnetv_usb_reg_read(TNETV_USB_RX_FREE_BUF_CNT(ch))); |
451 | logf(" q_cnt %d head %x tail %x\n", pRxCtl->RxActQueueCount, (uint32_t) pRxCtl->RxActQueueHead, (uint32_t) pRxCtl->RxActQueueTail); | 454 | logf(" q_cnt %ld head %lx tail %lx\n", pRxCtl->RxActQueueCount, (uint32_t) pRxCtl->RxActQueueHead, (uint32_t) pRxCtl->RxActQueueTail); |
452 | logf(" fake_head: %x fake_tail: %x\n", (uint32_t) pRxCtl->RxFakeRcvHead, (uint32_t) pRxCtl->RxFakeRcvTail); | 455 | logf(" fake_head: %lx fake_tail: %lx\n", (uint32_t) pRxCtl->RxFakeRcvHead, (uint32_t) pRxCtl->RxFakeRcvTail); |
453 | 456 | ||
454 | rcb = (cppi_rcb *) pRxCtl->RcbStart; | 457 | rcb = (cppi_rcb *) pRxCtl->RcbStart; |
455 | do | 458 | do |
@@ -457,16 +460,16 @@ void tnetv_cppi_dump_info(struct cppi_info *cppi) | |||
457 | if (!rcb) | 460 | if (!rcb) |
458 | break; | 461 | break; |
459 | 462 | ||
460 | logf(" Rcb: %x\n", (uint32_t) rcb); | 463 | logf(" Rcb: %lx\n", (uint32_t) rcb); |
461 | logf(" HNext %x BufPtr %x Off_BLen %x mode %x\n", rcb->HNext, rcb->BufPtr, rcb->Off_BLen, rcb->mode); | 464 | logf(" HNext %lx BufPtr %lx Off_BLen %lx mode %lx\n", rcb->HNext, rcb->BufPtr, rcb->Off_BLen, rcb->mode); |
462 | logf(" Next %x Eop %x dma_handle %x fake_bytes %x\n", (uint32_t) rcb->Next, (uint32_t) rcb->Eop, rcb->dma_handle, rcb->fake_bytes); | 465 | logf(" Next %lx Eop %lx dma_handle %lx fake_bytes %lx\n", (uint32_t) rcb->Next, (uint32_t) rcb->Eop, rcb->dma_handle, rcb->fake_bytes); |
463 | rcb = rcb->Next; | 466 | rcb = rcb->Next; |
464 | 467 | ||
465 | } while (rcb && rcb != (cppi_rcb *) pRxCtl->RcbStart); | 468 | } while (rcb && rcb != (cppi_rcb *) pRxCtl->RcbStart); |
466 | 469 | ||
467 | logf("\n"); | 470 | logf("\n"); |
468 | logf(" tx_numbufs: %d active %d\n", pTxCtl->TxNumBuffers, pTxCtl->TxActive); | 471 | logf(" tx_numbufs: %d active %ld\n", pTxCtl->TxNumBuffers, pTxCtl->TxActive); |
469 | logf(" q_cnt %d head %x tail %x\n", pTxCtl->TxActQueueCount, (uint32_t) pTxCtl->TxActQueueHead, (uint32_t) pTxCtl->TxActQueueTail); | 472 | logf(" q_cnt %ld head %lx tail %lx\n", pTxCtl->TxActQueueCount, (uint32_t) pTxCtl->TxActQueueHead, (uint32_t) pTxCtl->TxActQueueTail); |
470 | 473 | ||
471 | tcb = (cppi_tcb *) pTxCtl->TcbPool; | 474 | tcb = (cppi_tcb *) pTxCtl->TcbPool; |
472 | do | 475 | do |
@@ -474,9 +477,9 @@ void tnetv_cppi_dump_info(struct cppi_info *cppi) | |||
474 | if (!tcb) | 477 | if (!tcb) |
475 | break; | 478 | break; |
476 | 479 | ||
477 | logf(" Tcb (pool): %x\n", (uint32_t) tcb); | 480 | logf(" Tcb (pool): %lx\n", (uint32_t) tcb); |
478 | logf(" HNext %x BufPtr %x Off_BLen %x mode %x\n", tcb->HNext, tcb->BufPtr, tcb->Off_BLen, tcb->mode); | 481 | logf(" HNext %lx BufPtr %lx Off_BLen %lx mode %lx\n", tcb->HNext, tcb->BufPtr, tcb->Off_BLen, tcb->mode); |
479 | logf(" Next %x Eop %x dma_handle %x\n", (uint32_t) tcb->Next, (uint32_t) tcb->Eop, tcb->dma_handle); | 482 | logf(" Next %lx Eop %lx dma_handle %lx\n", (uint32_t) tcb->Next, (uint32_t) tcb->Eop, tcb->dma_handle); |
480 | tcb = tcb->Next; | 483 | tcb = tcb->Next; |
481 | 484 | ||
482 | } while (tcb && tcb != (cppi_tcb *) pTxCtl->TcbPool); | 485 | } while (tcb && tcb != (cppi_tcb *) pTxCtl->TcbPool); |
@@ -487,9 +490,9 @@ void tnetv_cppi_dump_info(struct cppi_info *cppi) | |||
487 | if (!tcb) | 490 | if (!tcb) |
488 | break; | 491 | break; |
489 | 492 | ||
490 | logf(" Tcb (act): %x\n", (uint32_t) tcb); | 493 | logf(" Tcb (act): %lx\n", (uint32_t) tcb); |
491 | logf(" HNext %x BufPtr %x Off_BLen %x mode %x\n", tcb->HNext, tcb->BufPtr, tcb->Off_BLen, tcb->mode); | 494 | logf(" HNext %lx BufPtr %lx Off_BLen %lx mode %lx\n", tcb->HNext, tcb->BufPtr, tcb->Off_BLen, tcb->mode); |
492 | logf(" Next %x Eop %x dma_handle %x\n", (uint32_t) tcb->Next, (uint32_t) tcb->Eop, tcb->dma_handle); | 495 | logf(" Next %lx Eop %lx dma_handle %lx\n", (uint32_t) tcb->Next, (uint32_t) tcb->Eop, tcb->dma_handle); |
493 | tcb = tcb->Next; | 496 | tcb = tcb->Next; |
494 | 497 | ||
495 | } while (tcb && tcb != (cppi_tcb *) pTxCtl->TxActQueueTail); | 498 | } while (tcb && tcb != (cppi_tcb *) pTxCtl->TxActQueueTail); |
@@ -556,7 +559,7 @@ int tnetv_cppi_rx_int_recv(struct cppi_info *cppi, int ch, int *buf_size, void * | |||
556 | CurrentRcb = pRxCtl->RxFakeRcvHead; | 559 | CurrentRcb = pRxCtl->RxFakeRcvHead; |
557 | if (!CurrentRcb) | 560 | if (!CurrentRcb) |
558 | { | 561 | { |
559 | cppi_log_event2("[cppi] rx_int recv: nothing in q", tnetv_usb_reg_read(TNETV_USB_RX_INT_STATUS), tnetv_usb_reg_read(DM320_VLYNQ_INTST)); | 562 | cppi_log_event2("[cppi] rx_int recv: nothing in q", tnetv_usb_reg_read(TNETV_USB_RX_INT_STATUS), tnetv_usb_reg_read(VL_INTST)); |
560 | return -1; | 563 | return -1; |
561 | } | 564 | } |
562 | 565 | ||
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.h b/firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.h index 9d0ac37cd0..b240f9593d 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.h +++ b/firmware/target/arm/tms320dm320/sansa-connect/tnetv105_cppi.h | |||
@@ -26,11 +26,11 @@ | |||
26 | #define TNETV105_CPPI_H | 26 | #define TNETV105_CPPI_H |
27 | 27 | ||
28 | #include <stdint.h> | 28 | #include <stdint.h> |
29 | #include "errno.h" | ||
29 | 30 | ||
30 | typedef uint32_t dma_addr_t; | 31 | typedef uint32_t dma_addr_t; |
31 | #define USB_CPPI_LOGGING 0 | 32 | #define USB_CPPI_LOGGING 0 |
32 | #define EAGAIN 11 /* Try again */ | 33 | #define CPPI_RX_NUM_BUFS 2 |
33 | #define CPPI_RX_NUM_BUFS 129 | ||
34 | #define CPPI_INFO_MEM_SIZE (2 * CPPI_RX_NUM_BUFS * sizeof(cppi_rcb) + 4 * 2 * sizeof(cppi_tcb)) | 34 | #define CPPI_INFO_MEM_SIZE (2 * CPPI_RX_NUM_BUFS * sizeof(cppi_rcb) + 4 * 2 * sizeof(cppi_tcb)) |
35 | 35 | ||
36 | #define CPPI_NUM_CHANNELS 4 | 36 | #define CPPI_NUM_CHANNELS 4 |