[U-Boot] virt to phys mapping function

In trying to get 36-bit physical working on 85xx I ran into an issue with the NAND driver. Its given a virtual address and trying to match it to which chipselect it maps to. The assumption in the code is that we have a 1:1 mapping and clearly that may not be true w/36-bit phys.
So it seems we need a virt_to_phys() function. However there are a few questions I have about this:
1. what should the prototype of this function look like:
phys_addr_t virt_to_phys (void * addr);
or
int virt_to_phys(void *p, phys_addr_t *addr);
I think the vast majority of implementations will be just 1:1 mapping, however there is a question in a dynamic mapping case of how to report back not finding a mapping.
2. what impact is there on existing use on:
cpu/mips/au1x00_eth.c: fifo_tx[next_tx].addr = (virt_to_phys(packet))| TX_DMA_ENABLE; cpu/mips/au1x00_eth.c: fifo_rx[next_rx].addr = (virt_to_phys(NetRxPackets[next_rx]))|RX_DMA_ENABLE; cpu/mips/au1x00_eth.c: fifo_tx[i].addr = virt_to_phys(&txbuf[0]); cpu/mips/au1x00_eth.c: fifo_rx[i].addr = (virt_to_phys(NetRxPackets[i]))|RX_DMA_ENABLE;
- k

Dear Kumar,
In message A9E2917C-2AE1-4666-95F7-5F771055EABB@kernel.crashing.org you wrote:
- what should the prototype of this function look like:
phys_addr_t virt_to_phys (void * addr);
That's what I'd prefer, especially since it can be easily resolved (for example, by an empty macro) where not really needed.
int virt_to_phys(void *p, phys_addr_t *addr);
I think the vast majority of implementations will be just 1:1 mapping,
That's what I think, too.
however there is a question in a dynamic mapping case of how to report back not finding a mapping.
Return "(phys_addr_t)(~0)" ?
- what impact is there on existing use on:
cpu/mips/au1x00_eth.c: fifo_tx[next_tx].addr = (virt_to_phys(packet))| TX_DMA_ENABLE; cpu/mips/au1x00_eth.c: fifo_rx[next_rx].addr = (virt_to_phys(NetRxPackets[next_rx]))|RX_DMA_ENABLE; cpu/mips/au1x00_eth.c: fifo_tx[i].addr = virt_to_phys(&txbuf[0]); cpu/mips/au1x00_eth.c: fifo_rx[i].addr = (virt_to_phys(NetRxPackets[i]))|RX_DMA_ENABLE;
They have to be checked and fixed, like all other uses of virt_to_phys and eventually __virt_to_phys, too.
Best regards,
Wolfgang Denk
participants (2)
-
Kumar Gala
-
Wolfgang Denk