for (i = 0; i < page_count; i++) {
buffer->pages[i] = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); if (buffer->pages[i] == NULL) break;
}
buffer->page_count = i; if (i < page_count) {
fw_iso_buffer_destroy(buffer, NULL); return -ENOMEM;
}
return 0;
}
int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, struct fw_card *card, enum dma_data_direction direction)
{
dma_addr_t address; int i;
buffer->direction = direction;
for (i = 0; i < buffer->page_count; i++) {
address = dma_map_page(card->device, buffer->pages[i],
0, PAGE_SIZE, direction); if (dma_mapping_error(card->device, address)) break;
set_page_private(buffer->pages[i], address);
}
buffer->page_count_mapped = i; if (i < buffer->page_count) return -ENOMEM;
return 0;
}
int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, int page_count, enum dma_data_direction direction)
{ int ret;
ret = fw_iso_buffer_alloc(buffer, page_count); if (ret < 0) return ret;
ret = fw_iso_buffer_map_dma(buffer, card, direction); if (ret < 0)
fw_iso_buffer_destroy(buffer, card);
for (i = 0; i < buffer->page_count_mapped; i++) {
address = page_private(buffer->pages[i]);
dma_unmap_page(card->device, address,
PAGE_SIZE, buffer->direction);
} for (i = 0; i < buffer->page_count; i++)
__free_page(buffer->pages[i]);
/** * fw_iso_context_flush_completions() - process isochronous context in current process context. * @ctx: the isochronous context * * Process the isochronous context in the current process context. The registered callback function * is called when a queued packet buffer with the interrupt flag is completed, either after * transmission in the IT context or after being filled in the IR context. Additionally, the * callback function is also called for the packet buffer completed at last. Furthermore, the * callback function is called as well when the header buffer in the context becomes full. If it is * required to process the context asynchronously, fw_iso_context_schedule_flush_completions() is * available instead. * * Context: Process context. May sleep due to disable_work_sync().
*/ int fw_iso_context_flush_completions(struct fw_iso_context *ctx)
{ int err;
// Avoid dead lock due to programming mistake. if (WARN_ON_ONCE(current_work() == &ctx->work)) return 0;
err = ctx->card->driver->stop_iso(ctx);
cancel_work_sync(&ctx->work);
return err;
}
EXPORT_SYMBOL(fw_iso_context_stop);
/* * Isochronous bus resource management (channels, bandwidth), client side
*/
staticint manage_bandwidth(struct fw_card *card, int irm_id, int generation, int bandwidth, bool allocate)
{ inttry, new, old = allocate ? BANDWIDTH_AVAILABLE_INITIAL : 0;
__be32 data[2];
/* * On a 1394a IRM with low contention, try < 1 is enough. * On a 1394-1995 IRM, we need at least try < 2. * Let's just do try < 5.
*/ for (try = 0; try < 5; try++) { new = allocate ? old - bandwidth : old + bandwidth; if (new < 0 || new > BANDWIDTH_AVAILABLE_INITIAL) return -EBUSY;
/** * fw_iso_resource_manage() - Allocate or deallocate a channel and/or bandwidth * @card: card interface for this action * @generation: bus generation * @channels_mask: bitmask for channel allocation * @channel: pointer for returning channel allocation result * @bandwidth: pointer for returning bandwidth allocation result * @allocate: whether to allocate (true) or deallocate (false) * * In parameters: card, generation, channels_mask, bandwidth, allocate * Out parameters: channel, bandwidth * * This function blocks (sleeps) during communication with the IRM. * * Allocates or deallocates at most one channel out of channels_mask. * channels_mask is a bitfield with MSB for channel 63 and LSB for channel 0. * (Note, the IRM's CHANNELS_AVAILABLE is a big-endian bitfield with MSB for * channel 0 and LSB for channel 63.) * Allocates or deallocates as many bandwidth allocation units as specified. * * Returns channel < 0 if no channel was allocated or deallocated. * Returns bandwidth = 0 if no bandwidth was allocated or deallocated. * * If generation is stale, deallocations succeed but allocations fail with * channel = -EAGAIN. * * If channel allocation fails, no bandwidth will be allocated either. * If bandwidth allocation fails, no channel will be allocated either. * But deallocations of channel and bandwidth are tried independently * of each other's success.
*/ void fw_iso_resource_manage(struct fw_card *card, int generation,
u64 channels_mask, int *channel, int *bandwidth, bool allocate)
{
u32 channels_hi = channels_mask; /* channels 31...0 */
u32 channels_lo = channels_mask >> 32; /* channels 63...32 */ int irm_id, ret, c = -EINVAL;
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.