cpm_uart: make dpram allocation actually work
PATCH 1/1 cpm_uart: make dpram allocation actually work
Hi Marcelo
While the idea of allocating console buffers from dpram is sound, the initial implementation didn't actually work :)
The following patch fixes it (tested and booted on 2.6.13-rc4).
Regards
Pantelis
--------------------------------------------------------------
drivers/serial/cpm_uart/cpm_uart_core.c +24 -15
@@ -70,6 +70,20 @@ static void cpm_uart_initbd(struct uart_/**************************************************************/ +static inline unsigned long cpu2cpm_addr (void *addr) +{ +if ((unsigned long )addr >=CPM_ADDR ) +return (unsigned long )addr; +return virt_to_bus (addr); +} + +static inline void *cpm2cpu_addr (unsigned long addr) +{ +if (addr >=CPM_ADDR ) +return (void *)addr; +return bus_to_virt (addr); +} +/* * Check, if transmit buffers are processed */
@@ -243,7 +257,7 @@ static void cpm_uart_int_rx(struct uart_ }/* get pointer */ - cp = (unsigned char *)bus_to_virt (bdp->cbd_bufaddr); + cp =cpm2cpu_addr (bdp->cbd_bufaddr);/* loop through the buffer */ while (i-- >0 ) {
@@ -569,7 +583,8 @@ static int cpm_uart_tx_pump(struct uart_/* Pick next descriptor and fill from buffer */ bdp = pinfo->tx_cur; - p =bus_to_virt (bdp->cbd_bufaddr); + p =cpm2cpu_addr (bdp->cbd_bufaddr); + *p++ = xmit->buf[xmit->tail]; bdp->cbd_datlen =1 ; bdp->cbd_sc |=BD_SC_READY ;
@@ -595,7 +610,7 @@ static int cpm_uart_tx_pump(struct uart_while (!(bdp->cbd_sc &BD_SC_READY ) && (xmit->tail != xmit->head)) { count =0 ; - p =bus_to_virt (bdp->cbd_bufaddr); + p =cpm2cpu_addr (bdp->cbd_bufaddr);while (count < pinfo->tx_fifosize) { *p++ = xmit->buf[xmit->tail]; xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 );
@@ -643,12 +658,12 @@ static void cpm_uart_initbd(struct uart_ mem_addr = pinfo->mem_addr; bdp = pinfo->rx_cur = pinfo->rx_bd_base;for (i =0 ; i < (pinfo->rx_nrfifos -1 ); i++, bdp++) { - bdp->cbd_bufaddr =virt_to_bus (mem_addr); + bdp->cbd_bufaddr =cpu2cpm_addr (mem_addr); bdp->cbd_sc =BD_SC_EMPTY |BD_SC_INTRPT ; mem_addr += pinfo->rx_fifosize; } - bdp->cbd_bufaddr =virt_to_bus (mem_addr); + bdp->cbd_bufaddr =cpu2cpm_addr (mem_addr); bdp->cbd_sc =BD_SC_WRAP |BD_SC_EMPTY |BD_SC_INTRPT ;/* Set the physical address of the host memory
@@ -658,12 +673,12 @@ static void cpm_uart_initbd(struct uart_ mem_addr = pinfo->mem_addr +L1_CACHE_ALIGN (pinfo->rx_nrfifos * pinfo->rx_fifosize); bdp = pinfo->tx_cur = pinfo->tx_bd_base;for (i =0 ; i < (pinfo->tx_nrfifos -1 ); i++, bdp++) { - bdp->cbd_bufaddr =virt_to_bus (mem_addr); + bdp->cbd_bufaddr =cpu2cpm_addr (mem_addr); bdp->cbd_sc =BD_SC_INTRPT ; mem_addr += pinfo->tx_fifosize; } - bdp->cbd_bufaddr =virt_to_bus (mem_addr); + bdp->cbd_bufaddr =cpu2cpm_addr (mem_addr); bdp->cbd_sc =BD_SC_WRAP |BD_SC_INTRPT ; }
@@ -983,10 +998,7 @@ static void cpm_uart_console_write(struc* If the buffer address is in the CPM DPRAM, don't * convert it. */ -if ((uint) (bdp->cbd_bufaddr) > (uint )CPM_ADDR ) - cp = (unsigned char *) (bdp->cbd_bufaddr); -else - cp =bus_to_virt (bdp->cbd_bufaddr); + cp =cpm2cpu_addr (bdp->cbd_bufaddr); *cp = *s;
@@ -1003,10 +1015,7 @@ static void cpm_uart_console_write(strucwhile ((bdp->cbd_sc &BD_SC_READY ) !=0 ) ; -if ((uint) (bdp->cbd_bufaddr) > (uint )CPM_ADDR ) - cp = (unsigned char *) (bdp->cbd_bufaddr); -else - cp =bus_to_virt (bdp->cbd_bufaddr); + cp =cpm2cpu_addr (bdp->cbd_bufaddr); *cp =13 ; bdp->cbd_datlen =1 ;
drivers/serial/cpm_uart/cpm_uart_cpm1.c +2 -0
@@ -185,6 +185,8 @@ int cpm_uart_allocbuf(struct uart_cpm_po memsz =L1_CACHE_ALIGN (pinfo->rx_nrfifos * pinfo->rx_fifosize) +L1_CACHE_ALIGN (pinfo->tx_nrfifos * pinfo->tx_fifosize);if (is_con) { +/* was hostalloc but changed cause it blows away the */ +/* large tlb mapping when pinning the kernel area */ mem_addr = (u8 *)cpm_dpram_addr (cpm_dpalloc (memsz,8 )); dma_addr =0 ; }else
Quoted 6 lines · Pantelis Antoniou
Hi Marcelo
While the idea of allocating console buffers from dpram is sound, the initial implementation didn't actually work :)
The following patch fixes it (tested and booted on 2.6.13-rc4).
OK thanks Panto.
Despite my limited knowledge here, Vitaly's merged patch looks fine.
I suppose someone (Kumar?) is going to send it upstream now?
Quoted 7 lines · Marcelo Tosatti
Quoted 5 lines · Pantelis Antoniou
Hi Marcelo
While the idea of allocating console buffers from dpram is sound, the initial implementation didn't actually work :)
Quoted 8 lines
Quoted 2 lines
The following patch fixes it (tested and booted on 2.6.13-rc4).
OK thanks Panto.
Despite my limited knowledge here, Vitaly's merged patch looks fine.
I suppose someone (Kumar?) is going to send it upstream now?
I plan on this, after we test it on 8560.
- kumar