drivers/firewire/core-iso.c
Source file repositories/reference/linux-study-clean/drivers/firewire/core-iso.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firewire/core-iso.c- Extension
.c- Size
- 12948 bytes
- Lines
- 460
- Domain
- Driver Families
- Bucket
- drivers/firewire
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma-mapping.hlinux/errno.hlinux/firewire.hlinux/firewire-constants.hlinux/kernel.hlinux/mm.hlinux/slab.hlinux/spinlock.hlinux/vmalloc.hlinux/export.hasm/byteorder.hcore.htrace/events/firewire.h
Detected Declarations
function Copyrightfunction fw_iso_buffer_map_dmafunction fw_iso_buffer_initfunction fw_iso_buffer_destroyfunction fw_iso_buffer_lookupfunction fw_iso_context_destroyfunction fw_iso_context_startfunction fw_iso_context_set_channelsfunction fw_iso_context_queuefunction fw_iso_context_queue_flushfunction fw_iso_context_flush_completionsfunction fw_iso_context_stopfunction managementfunction manage_channelfunction deallocate_channelfunction fw_iso_resource_manageexport fw_iso_buffer_initexport fw_iso_buffer_destroyexport __fw_iso_context_createexport fw_iso_context_destroyexport fw_iso_context_startexport fw_iso_context_queueexport fw_iso_context_queue_flushexport fw_iso_context_flush_completionsexport fw_iso_context_stopexport fw_iso_resource_manage
Annotated Snippet
if (retry) {
retry--;
channel--;
} else {
ret = -EIO;
}
}
}
return ret;
}
static void deallocate_channel(struct fw_card *card, int irm_id,
int generation, int channel)
{
u32 mask;
u64 offset;
mask = channel < 32 ? 1 << channel : 1 << (channel - 32);
offset = channel < 32 ? CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_HI :
CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_LO;
manage_channel(card, irm_id, generation, mask, offset, false);
}
/**
* 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;
scoped_guard(spinlock_irq, &card->lock)
irm_id = card->irm_node->node_id;
if (channels_hi)
c = manage_channel(card, irm_id, generation, channels_hi,
CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_HI,
allocate);
if (channels_lo && c < 0) {
c = manage_channel(card, irm_id, generation, channels_lo,
CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_LO,
allocate);
if (c >= 0)
c += 32;
}
*channel = c;
if (allocate && channels_mask != 0 && c < 0)
*bandwidth = 0;
if (*bandwidth == 0)
return;
ret = manage_bandwidth(card, irm_id, generation, *bandwidth, allocate);
if (ret < 0)
*bandwidth = 0;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/errno.h`, `linux/firewire.h`, `linux/firewire-constants.h`, `linux/kernel.h`, `linux/mm.h`, `linux/slab.h`, `linux/spinlock.h`.
- Detected declarations: `function Copyright`, `function fw_iso_buffer_map_dma`, `function fw_iso_buffer_init`, `function fw_iso_buffer_destroy`, `function fw_iso_buffer_lookup`, `function fw_iso_context_destroy`, `function fw_iso_context_start`, `function fw_iso_context_set_channels`, `function fw_iso_context_queue`, `function fw_iso_context_queue_flush`.
- Atlas domain: Driver Families / drivers/firewire.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.