mirror of
https://github.com/ipxe/ipxe
synced 2026-05-18 10:00:30 +03:00
[uaccess] Remove user_to_phys() and phys_to_user()
Remove the intermediate concept of a user pointer from physical address conversions, leaving virt_to_phys() and phys_to_virt() as the directly implemented functions. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -428,7 +428,7 @@ static int srp_cmd ( struct srp_device *srpdev,
|
||||
cmd->data_buffer_formats |= SRP_CMD_DO_FMT_DIRECT;
|
||||
data_out = iob_put ( iobuf, sizeof ( *data_out ) );
|
||||
data_out->address =
|
||||
cpu_to_be64 ( user_to_phys ( command->data_out, 0 ) );
|
||||
cpu_to_be64 ( virt_to_phys ( command->data_out ) );
|
||||
data_out->handle = ntohl ( srpdev->memory_handle );
|
||||
data_out->len = ntohl ( command->data_out_len );
|
||||
}
|
||||
@@ -438,7 +438,7 @@ static int srp_cmd ( struct srp_device *srpdev,
|
||||
cmd->data_buffer_formats |= SRP_CMD_DI_FMT_DIRECT;
|
||||
data_in = iob_put ( iobuf, sizeof ( *data_in ) );
|
||||
data_in->address =
|
||||
cpu_to_be64 ( user_to_phys ( command->data_in, 0 ) );
|
||||
cpu_to_be64 ( virt_to_phys ( command->data_in ) );
|
||||
data_in->handle = ntohl ( srpdev->memory_handle );
|
||||
data_in->len = ntohl ( command->data_in_len );
|
||||
}
|
||||
|
||||
@@ -2079,7 +2079,7 @@ static int arbel_start_firmware ( struct arbel *arbel ) {
|
||||
} else {
|
||||
assert ( arbel->firmware_len == fw_len );
|
||||
}
|
||||
fw_base = user_to_phys ( arbel->firmware_area, 0 );
|
||||
fw_base = virt_to_phys ( arbel->firmware_area );
|
||||
DBGC ( arbel, "Arbel %p firmware area at [%08lx,%08lx)\n",
|
||||
arbel, fw_base, ( fw_base + fw_len ) );
|
||||
if ( ( rc = arbel_map_vpm ( arbel, arbel_cmd_map_fa,
|
||||
@@ -2452,7 +2452,7 @@ static int arbel_alloc_icm ( struct arbel *arbel,
|
||||
assert ( arbel->icm_len == icm_len );
|
||||
assert ( arbel->icm_aux_len == icm_aux_len );
|
||||
}
|
||||
icm_phys = user_to_phys ( arbel->icm, 0 );
|
||||
icm_phys = virt_to_phys ( arbel->icm );
|
||||
|
||||
/* Allocate doorbell UAR */
|
||||
arbel->db_rec = malloc_phys ( ARBEL_PAGE_SIZE, ARBEL_PAGE_SIZE );
|
||||
|
||||
@@ -486,8 +486,8 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages
|
||||
for ( i = 0 , j = MANAGE_PAGES_PSA_OFFSET; i < pas_num; ++i ,++j,
|
||||
next_page_addr += GOLAN_PAGE_SIZE ) {
|
||||
addr = next_page_addr;
|
||||
if (GOLAN_PAGE_MASK & user_to_phys(addr, 0)) {
|
||||
DBGC (golan ,"Addr not Page alligned [%lx]\n", user_to_phys(addr, 0));
|
||||
if (GOLAN_PAGE_MASK & virt_to_phys(addr)) {
|
||||
DBGC (golan ,"Addr not Page alligned [%lx]\n", virt_to_phys(addr));
|
||||
}
|
||||
mailbox->mblock.data[j] = USR_2_BE64_BUS(addr);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
#define VIRT_2_BE64_BUS( addr ) cpu_to_be64(((unsigned long long )virt_to_bus(addr)))
|
||||
#define BE64_BUS_2_VIRT( addr ) bus_to_virt(be64_to_cpu(addr))
|
||||
#define USR_2_BE64_BUS( addr ) cpu_to_be64(((unsigned long long )user_to_phys(addr, 0)))
|
||||
#define BE64_BUS_2_USR( addr ) be64_to_cpu(phys_to_user(addr))
|
||||
#define USR_2_BE64_BUS( addr ) cpu_to_be64(((unsigned long long )virt_to_phys(addr)))
|
||||
#define BE64_BUS_2_USR( addr ) be64_to_cpu(phys_to_virt(addr))
|
||||
|
||||
#define GET_INBOX(golan, idx) (&(((struct mbox *)(golan->mboxes.inbox))[idx]))
|
||||
#define GET_OUTBOX(golan, idx) (&(((struct mbox *)(golan->mboxes.outbox))[idx]))
|
||||
|
||||
@@ -2382,7 +2382,7 @@ static int hermon_start_firmware ( struct hermon *hermon ) {
|
||||
} else {
|
||||
assert ( hermon->firmware_len == fw_len );
|
||||
}
|
||||
fw_base = user_to_phys ( hermon->firmware_area, 0 );
|
||||
fw_base = virt_to_phys ( hermon->firmware_area );
|
||||
DBGC ( hermon, "Hermon %p firmware area at physical [%08lx,%08lx)\n",
|
||||
hermon, fw_base, ( fw_base + fw_len ) );
|
||||
if ( ( rc = hermon_map_vpm ( hermon, hermon_cmd_map_fa,
|
||||
@@ -2752,7 +2752,7 @@ static int hermon_map_icm ( struct hermon *hermon,
|
||||
assert ( hermon->icm_len == icm_len );
|
||||
assert ( hermon->icm_aux_len == icm_aux_len );
|
||||
}
|
||||
icm_phys = user_to_phys ( hermon->icm, 0 );
|
||||
icm_phys = virt_to_phys ( hermon->icm );
|
||||
|
||||
/* Map ICM auxiliary area */
|
||||
DBGC ( hermon, "Hermon %p mapping ICM AUX => %08lx\n",
|
||||
|
||||
@@ -406,7 +406,7 @@ static int exanic_open ( struct net_device *netdev ) {
|
||||
port->rx_cons = 0;
|
||||
|
||||
/* Map receive region */
|
||||
exanic_write_base ( phys_to_bus ( user_to_phys ( port->rx, 0 ) ),
|
||||
exanic_write_base ( phys_to_bus ( virt_to_phys ( port->rx ) ),
|
||||
( port->regs + EXANIC_PORT_RX_BASE ) );
|
||||
|
||||
/* Enable promiscuous mode */
|
||||
@@ -729,8 +729,8 @@ static int exanic_probe_port ( struct exanic *exanic, struct device *dev,
|
||||
DBGC ( port, "EXANIC %s port %d TX [%#05zx,%#05zx) TXF %#02x RX "
|
||||
"[%#lx,%#lx)\n", netdev->name, index, port->tx_offset,
|
||||
( port->tx_offset + tx_len ), port->txf_slot,
|
||||
user_to_phys ( port->rx, 0 ),
|
||||
user_to_phys ( port->rx, EXANIC_RX_LEN ) );
|
||||
virt_to_phys ( port->rx ),
|
||||
( virt_to_phys ( port->rx ) + EXANIC_RX_LEN ) );
|
||||
|
||||
/* Set initial link state */
|
||||
exanic_check_link ( netdev );
|
||||
|
||||
+12
-15
@@ -521,14 +521,14 @@ static int gve_deconfigure ( struct gve_nic *gve ) {
|
||||
static int gve_register ( struct gve_nic *gve, struct gve_qpl *qpl ) {
|
||||
struct gve_pages *pages = &gve->scratch.buf->pages;
|
||||
union gve_admin_command *cmd;
|
||||
physaddr_t addr;
|
||||
void *addr;
|
||||
unsigned int i;
|
||||
int rc;
|
||||
|
||||
/* Build page address list */
|
||||
for ( i = 0 ; i < qpl->count ; i++ ) {
|
||||
addr = user_to_phys ( qpl->data, ( i * GVE_PAGE_SIZE ) );
|
||||
pages->addr[i] = cpu_to_be64 ( dma_phys ( &qpl->map, addr ) );
|
||||
addr = ( qpl->data + ( i * GVE_PAGE_SIZE ) );
|
||||
pages->addr[i] = cpu_to_be64 ( dma ( &qpl->map, addr ) );
|
||||
}
|
||||
|
||||
/* Construct request */
|
||||
@@ -575,11 +575,10 @@ static void gve_create_tx_param ( struct gve_queue *queue,
|
||||
union gve_admin_command *cmd ) {
|
||||
struct gve_admin_create_tx *create = &cmd->create_tx;
|
||||
const struct gve_queue_type *type = queue->type;
|
||||
physaddr_t desc = user_to_phys ( queue->desc, 0 );
|
||||
|
||||
/* Construct request parameters */
|
||||
create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) );
|
||||
create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) );
|
||||
create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) );
|
||||
create->qpl_id = cpu_to_be32 ( type->qpl );
|
||||
create->notify_id = cpu_to_be32 ( type->irq );
|
||||
}
|
||||
@@ -594,14 +593,12 @@ static void gve_create_rx_param ( struct gve_queue *queue,
|
||||
union gve_admin_command *cmd ) {
|
||||
struct gve_admin_create_rx *create = &cmd->create_rx;
|
||||
const struct gve_queue_type *type = queue->type;
|
||||
physaddr_t desc = user_to_phys ( queue->desc, 0 );
|
||||
physaddr_t cmplt = user_to_phys ( queue->cmplt, 0 );
|
||||
|
||||
/* Construct request parameters */
|
||||
create->notify_id = cpu_to_be32 ( type->irq );
|
||||
create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) );
|
||||
create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) );
|
||||
create->cmplt = cpu_to_be64 ( dma_phys ( &queue->cmplt_map, cmplt ) );
|
||||
create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) );
|
||||
create->cmplt = cpu_to_be64 ( dma ( &queue->cmplt_map, queue->cmplt ));
|
||||
create->qpl_id = cpu_to_be32 ( type->qpl );
|
||||
create->bufsz = cpu_to_be16 ( GVE_BUF_SIZE );
|
||||
}
|
||||
@@ -760,8 +757,8 @@ static int gve_alloc_qpl ( struct gve_nic *gve, struct gve_qpl *qpl,
|
||||
return -ENOMEM;
|
||||
|
||||
DBGC ( gve, "GVE %p QPL %#08x at [%08lx,%08lx)\n",
|
||||
gve, qpl->id, user_to_phys ( qpl->data, 0 ),
|
||||
user_to_phys ( qpl->data, len ) );
|
||||
gve, qpl->id, virt_to_phys ( qpl->data ),
|
||||
( virt_to_phys ( qpl->data ) + len ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -883,8 +880,8 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) {
|
||||
goto err_desc;
|
||||
}
|
||||
DBGC ( gve, "GVE %p %s descriptors at [%08lx,%08lx)\n",
|
||||
gve, type->name, user_to_phys ( queue->desc, 0 ),
|
||||
user_to_phys ( queue->desc, desc_len ) );
|
||||
gve, type->name, virt_to_phys ( queue->desc ),
|
||||
( virt_to_phys ( queue->desc ) + desc_len ) );
|
||||
|
||||
/* Allocate completions */
|
||||
if ( cmplt_len ) {
|
||||
@@ -895,8 +892,8 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) {
|
||||
goto err_cmplt;
|
||||
}
|
||||
DBGC ( gve, "GVE %p %s completions at [%08lx,%08lx)\n",
|
||||
gve, type->name, user_to_phys ( queue->cmplt, 0 ),
|
||||
user_to_phys ( queue->cmplt, cmplt_len ) );
|
||||
gve, type->name, virt_to_phys ( queue->cmplt ),
|
||||
( virt_to_phys ( queue->cmplt ) + cmplt_len ) );
|
||||
}
|
||||
|
||||
/* Allocate queue resources */
|
||||
|
||||
+11
-10
@@ -118,14 +118,14 @@ static int txnic_create_sq ( struct txnic *vnic ) {
|
||||
writeq ( TXNIC_QS_SQ_CFG_RESET, ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) );
|
||||
|
||||
/* Configure and enable send queue */
|
||||
writeq ( user_to_phys ( vnic->sq.sqe, 0 ),
|
||||
writeq ( virt_to_phys ( vnic->sq.sqe ),
|
||||
( vnic->regs + TXNIC_QS_SQ_BASE(0) ) );
|
||||
writeq ( ( TXNIC_QS_SQ_CFG_ENA | TXNIC_QS_SQ_CFG_QSIZE_1K ),
|
||||
( vnic->regs + TXNIC_QS_SQ_CFG(0) ) );
|
||||
|
||||
DBGC ( vnic, "TXNIC %s SQ at [%08lx,%08lx)\n",
|
||||
vnic->name, user_to_phys ( vnic->sq.sqe, 0 ),
|
||||
user_to_phys ( vnic->sq.sqe, TXNIC_SQ_SIZE ) );
|
||||
vnic->name, virt_to_phys ( vnic->sq.sqe ),
|
||||
( virt_to_phys ( vnic->sq.sqe ) + TXNIC_SQ_SIZE ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ static int txnic_create_rq ( struct txnic *vnic ) {
|
||||
( vnic->regs + TXNIC_QS_RBDR_CFG(0) ) );
|
||||
|
||||
/* Configure and enable receive buffer descriptor ring */
|
||||
writeq ( user_to_phys ( vnic->rq.rqe, 0 ),
|
||||
writeq ( virt_to_phys ( vnic->rq.rqe ),
|
||||
( vnic->regs + TXNIC_QS_RBDR_BASE(0) ) );
|
||||
writeq ( ( TXNIC_QS_RBDR_CFG_ENA | TXNIC_QS_RBDR_CFG_QSIZE_8K |
|
||||
TXNIC_QS_RBDR_CFG_LINES ( TXNIC_RQE_SIZE /
|
||||
@@ -288,8 +288,8 @@ static int txnic_create_rq ( struct txnic *vnic ) {
|
||||
writeq ( TXNIC_QS_RQ_CFG_ENA, ( vnic->regs + TXNIC_QS_RQ_CFG(0) ) );
|
||||
|
||||
DBGC ( vnic, "TXNIC %s RQ at [%08lx,%08lx)\n",
|
||||
vnic->name, user_to_phys ( vnic->rq.rqe, 0 ),
|
||||
user_to_phys ( vnic->rq.rqe, TXNIC_RQ_SIZE ) );
|
||||
vnic->name, virt_to_phys ( vnic->rq.rqe ),
|
||||
( virt_to_phys ( vnic->rq.rqe ) + TXNIC_RQ_SIZE ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -463,14 +463,14 @@ static int txnic_create_cq ( struct txnic *vnic ) {
|
||||
writeq ( TXNIC_QS_CQ_CFG_RESET, ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) );
|
||||
|
||||
/* Configure and enable completion queue */
|
||||
writeq ( user_to_phys ( vnic->cq.cqe, 0 ),
|
||||
writeq ( virt_to_phys ( vnic->cq.cqe ),
|
||||
( vnic->regs + TXNIC_QS_CQ_BASE(0) ) );
|
||||
writeq ( ( TXNIC_QS_CQ_CFG_ENA | TXNIC_QS_CQ_CFG_QSIZE_256 ),
|
||||
( vnic->regs + TXNIC_QS_CQ_CFG(0) ) );
|
||||
|
||||
DBGC ( vnic, "TXNIC %s CQ at [%08lx,%08lx)\n",
|
||||
vnic->name, user_to_phys ( vnic->cq.cqe, 0 ),
|
||||
user_to_phys ( vnic->cq.cqe, TXNIC_CQ_SIZE ) );
|
||||
vnic->name, virt_to_phys ( vnic->cq.cqe ),
|
||||
( virt_to_phys ( vnic->cq.cqe ) + TXNIC_CQ_SIZE ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -559,7 +559,8 @@ static void txnic_poll_cq ( struct txnic *vnic ) {
|
||||
default:
|
||||
DBGC ( vnic, "TXNIC %s unknown completion type %d\n",
|
||||
vnic->name, cqe.common.cqe_type );
|
||||
DBGC_HDA ( vnic, user_to_phys ( vnic->cq.cqe, offset ),
|
||||
DBGC_HDA ( vnic,
|
||||
( virt_to_phys ( vnic->cq.cqe ) + offset ),
|
||||
&cqe, sizeof ( cqe ) );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1014,8 +1014,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) {
|
||||
}
|
||||
|
||||
/* Populate scratchpad array */
|
||||
addr = dma_phys ( &scratch->buffer_map,
|
||||
user_to_phys ( scratch->buffer, 0 ) );
|
||||
addr = dma ( &scratch->buffer_map, scratch->buffer );
|
||||
for ( i = 0 ; i < scratch->count ; i++ ) {
|
||||
scratch->array[i] = cpu_to_le64 ( addr );
|
||||
addr += xhci->pagesize;
|
||||
@@ -1027,8 +1026,8 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) {
|
||||
scratch->array ) );
|
||||
|
||||
DBGC2 ( xhci, "XHCI %s scratchpad [%08lx,%08lx) array [%08lx,%08lx)\n",
|
||||
xhci->name, user_to_phys ( scratch->buffer, 0 ),
|
||||
user_to_phys ( scratch->buffer, buffer_len ),
|
||||
xhci->name, virt_to_phys ( scratch->buffer ),
|
||||
( virt_to_phys ( scratch->buffer ) + buffer_len ),
|
||||
virt_to_phys ( scratch->array ),
|
||||
( virt_to_phys ( scratch->array ) + array_len ) );
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user