sound/firewire/iso-resources.c
Source file repositories/reference/linux-study-clean/sound/firewire/iso-resources.c
File Facts
- System
- Linux kernel
- Corpus path
sound/firewire/iso-resources.c- Extension
.c- Size
- 6489 bytes
- Lines
- 227
- Domain
- Driver Families
- Bucket
- sound/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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/firewire.hlinux/firewire-constants.hlinux/export.hlinux/jiffies.hlinux/mutex.hlinux/sched.hlinux/spinlock.hiso-resources.h
Detected Declarations
function Copyrightfunction fw_iso_resources_destroyfunction packet_bandwidthfunction current_bandwidth_overheadfunction wait_isoch_resource_delay_after_bus_resetfunction fw_iso_resources_updatefunction scoped_guardfunction fw_iso_resources_updatefunction scoped_guardfunction fw_iso_resources_freeexport fw_iso_resources_initexport fw_iso_resources_destroyexport fw_iso_resources_allocateexport fw_iso_resources_updateexport fw_iso_resources_free
Annotated Snippet
if (channel >= 0) {
r->channel = channel;
r->allocated = true;
} else {
if (channel == -EBUSY)
dev_err(&r->unit->device,
"isochronous resources exhausted\n");
else
dev_err(&r->unit->device,
"isochronous resource allocation failed\n");
}
}
return channel;
}
EXPORT_SYMBOL(fw_iso_resources_allocate);
/**
* fw_iso_resources_update - update resource allocations after a bus reset
* @r: the resource manager
*
* This function must be called from the driver's .update handler to reallocate
* any resources that were allocated before the bus reset. It is safe to call
* this function if no resources are currently allocated.
*
* Returns a negative error code on failure. If this happens, the caller must
* stop streaming.
*/
int fw_iso_resources_update(struct fw_iso_resources *r)
{
struct fw_card *card = fw_parent_device(r->unit)->card;
int bandwidth, channel;
guard(mutex)(&r->mutex);
if (!r->allocated)
return 0;
scoped_guard(spinlock_irq, &card->lock) {
r->generation = card->generation;
r->bandwidth_overhead = current_bandwidth_overhead(card);
}
bandwidth = r->bandwidth + r->bandwidth_overhead;
fw_iso_resource_manage(card, r->generation, 1uLL << r->channel,
&channel, &bandwidth, true);
/*
* When another bus reset happens, pretend that the allocation
* succeeded; we will try again for the new generation later.
*/
if (channel < 0 && channel != -EAGAIN) {
r->allocated = false;
if (channel == -EBUSY)
dev_err(&r->unit->device,
"isochronous resources exhausted\n");
else
dev_err(&r->unit->device,
"isochronous resource allocation failed\n");
}
return channel;
}
EXPORT_SYMBOL(fw_iso_resources_update);
/**
* fw_iso_resources_free - frees allocated resources
* @r: the resource manager
*
* This function deallocates the channel and bandwidth, if allocated.
*/
void fw_iso_resources_free(struct fw_iso_resources *r)
{
struct fw_card *card;
int bandwidth, channel;
/* Not initialized. */
if (r->unit == NULL)
return;
card = fw_parent_device(r->unit)->card;
guard(mutex)(&r->mutex);
if (r->allocated) {
bandwidth = r->bandwidth + r->bandwidth_overhead;
fw_iso_resource_manage(card, r->generation, 1uLL << r->channel,
&channel, &bandwidth, false);
if (channel < 0)
dev_err(&r->unit->device,
"isochronous resource deallocation failed\n");
Annotation
- Immediate include surface: `linux/device.h`, `linux/firewire.h`, `linux/firewire-constants.h`, `linux/export.h`, `linux/jiffies.h`, `linux/mutex.h`, `linux/sched.h`, `linux/spinlock.h`.
- Detected declarations: `function Copyright`, `function fw_iso_resources_destroy`, `function packet_bandwidth`, `function current_bandwidth_overhead`, `function wait_isoch_resource_delay_after_bus_reset`, `function fw_iso_resources_update`, `function scoped_guard`, `function fw_iso_resources_update`, `function scoped_guard`, `function fw_iso_resources_free`.
- Atlas domain: Driver Families / sound/firewire.
- Implementation status: integration implementation candidate.
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.