/** * ishtp_cl_alloc_dma_buf() - Allocate DMA RX and TX buffer * @dev: ishtp device * * Allocate RX and TX DMA buffer once during bus setup. * It allocates 1MB, RX and TX DMA buffer, which are divided * into slots.
*/ void ishtp_cl_alloc_dma_buf(struct ishtp_device *dev)
{
dma_addr_t h;
if (dev->ishtp_host_dma_rx_buf)
dev->ishtp_host_dma_rx_buf_phys = h;
}
/** * ishtp_cl_free_dma_buf() - Free DMA RX and TX buffer * @dev: ishtp device * * Free DMA buffer when all clients are released. This is * only happens during error path in ISH built in driver * model
*/ void ishtp_cl_free_dma_buf(struct ishtp_device *dev)
{
dma_addr_t h;
if (dev->ishtp_host_dma_tx_buf) {
h = dev->ishtp_host_dma_tx_buf_phys;
dma_free_coherent(dev->devc, dev->ishtp_host_dma_tx_buf_size,
dev->ishtp_host_dma_tx_buf, h);
}
if (dev->ishtp_host_dma_rx_buf) {
h = dev->ishtp_host_dma_rx_buf_phys;
dma_free_coherent(dev->devc, dev->ishtp_host_dma_rx_buf_size,
dev->ishtp_host_dma_rx_buf, h);
}
/* * ishtp_cl_get_dma_send_buf() - Get a DMA memory slot * @dev: ishtp device * @size: Size of memory to get * * Find and return free address of "size" bytes in dma tx buffer. * the function will mark this address as "in-used" memory. * * Return: NULL when no free buffer else a buffer to copy
*/ void *ishtp_cl_get_dma_send_buf(struct ishtp_device *dev,
uint32_t size)
{ unsignedlong flags; int i, j, free; /* additional slot is needed if there is rem */ int required_slots = (size / DMA_SLOT_SIZE)
+ 1 * (size % DMA_SLOT_SIZE != 0);
if (!dev->ishtp_dma_tx_map) {
dev_err(dev->devc, "Fail to allocate Tx map\n"); return NULL;
}
spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags); for (i = 0; i <= (dev->ishtp_dma_num_slots - required_slots); i++) {
free = 1; for (j = 0; j < required_slots; j++) if (dev->ishtp_dma_tx_map[i+j]) {
free = 0;
i += j; break;
} if (free) { /* mark memory as "caught" */ for (j = 0; j < required_slots; j++)
dev->ishtp_dma_tx_map[i+j] = 1;
spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags); return (i * DMA_SLOT_SIZE) +
(unsignedchar *)dev->ishtp_host_dma_tx_buf;
}
}
spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags);
dev_err(dev->devc, "No free DMA buffer to send msg\n"); return NULL;
}
/* * ishtp_cl_release_dma_acked_mem() - Release DMA memory slot * @dev: ishtp device * @msg_addr: message address of slot * @size: Size of memory to get * * Release_dma_acked_mem - returnes the acked memory to free list. * (from msg_addr, size bytes long)
*/ void ishtp_cl_release_dma_acked_mem(struct ishtp_device *dev, void *msg_addr,
uint8_t size)
{ unsignedlong flags; int acked_slots = (size / DMA_SLOT_SIZE)
+ 1 * (size % DMA_SLOT_SIZE != 0); int i, j;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.