drivers/remoteproc/remoteproc_core.c
Source file repositories/reference/linux-study-clean/drivers/remoteproc/remoteproc_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/remoteproc/remoteproc_core.c- Extension
.c- Size
- 73442 bytes
- Lines
- 2785
- Domain
- Driver Families
- Bucket
- drivers/remoteproc
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
asm/byteorder.hlinux/delay.hlinux/device.hlinux/dma-mapping.hlinux/elf.hlinux/firmware.hlinux/idr.hlinux/iommu.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/of_platform.hlinux/panic_notifier.hlinux/platform_device.hlinux/rculist.hlinux/remoteproc.hlinux/slab.hlinux/string.hlinux/virtio_ring.hremoteproc_internal.h
Detected Declarations
struct rproc_rsc_cb_datafunction rproc_iommu_faultfunction rproc_enable_iommufunction rproc_disable_iommufunction rproc_va_to_pafunction rproc_da_to_vafunction list_for_each_entryfunction rproc_find_carveout_by_namefunction list_for_each_entryfunction rproc_check_carveout_dafunction rproc_alloc_vringfunction rproc_parse_vringfunction rproc_free_vringfunction rproc_stopfunction rproc_add_rvdevfunction rproc_remove_rvdevfunction rproc_handle_vdevfunction rproc_handle_tracefunction rproc_handle_devmemfunction rproc_alloc_carveoutfunction rproc_release_carveoutfunction rproc_handle_carveoutfunction rproc_add_carveoutfunction rproc_mem_entry_initfunction rproc_of_resm_mem_entry_initfunction rproc_of_parse_firmwarefunction rproc_handle_rsc_entryfunction rproc_handle_resourcesfunction rproc_prepare_subdevicesfunction list_for_each_entryfunction rproc_start_subdevicesfunction list_for_each_entryfunction rproc_stop_subdevicesfunction list_for_each_entry_reversefunction rproc_unprepare_subdevicesfunction list_for_each_entry_reversefunction rproc_alloc_registered_carveoutsfunction list_for_each_entry_safefunction rproc_resource_cleanupfunction rproc_startfunction __rproc_attachfunction rproc_fw_bootfunction rproc_set_rsc_tablefunction rproc_reset_rsc_table_on_stopfunction rproc_reset_rsc_table_on_detachfunction rproc_reset_rsc_table_on_stopfunction rproc_attachfunction processor
Annotated Snippet
struct device_driver *driver;
struct device_node *np;
np = of_find_node_by_phandle(phandle);
if (!np)
return NULL;
rcu_read_lock();
list_for_each_entry_rcu(r, &rproc_list, node) {
if (r->dev.parent && device_match_of_node(r->dev.parent, np)) {
/* prevent underlying implementation from being removed */
/*
* If the remoteproc's parent has a driver, the
* remoteproc is not part of a cluster and we can use
* that driver.
*/
driver = r->dev.parent->driver;
/*
* If the remoteproc's parent does not have a driver,
* look for the driver associated with the cluster.
*/
if (!driver) {
if (r->dev.parent->parent)
driver = r->dev.parent->parent->driver;
if (!driver)
break;
}
if (!try_module_get(driver->owner)) {
dev_err(&r->dev, "can't get owner\n");
break;
}
rproc = r;
get_device(&rproc->dev);
break;
}
}
rcu_read_unlock();
of_node_put(np);
return rproc;
}
#else
struct rproc *rproc_get_by_phandle(phandle phandle)
{
return NULL;
}
#endif
EXPORT_SYMBOL(rproc_get_by_phandle);
/**
* rproc_set_firmware() - assign a new firmware
* @rproc: rproc handle to which the new firmware is being assigned
* @fw_name: new firmware name to be assigned
*
* This function allows remoteproc drivers or clients to configure a custom
* firmware name that is different from the default name used during remoteproc
* registration. The function does not trigger a remote processor boot,
* only sets the firmware name used for a subsequent boot. This function
* should also be called only when the remote processor is offline.
*
* This allows either the userspace to configure a different name through
* sysfs or a kernel-level remoteproc or a remoteproc client driver to set
* a specific firmware when it is controlling the boot and shutdown of the
* remote processor.
*
* Return: 0 on success or a negative value upon failure
*/
int rproc_set_firmware(struct rproc *rproc, const char *fw_name)
{
struct device *dev;
int ret, len;
char *p;
if (!rproc || !fw_name)
return -EINVAL;
dev = rproc->dev.parent;
ret = mutex_lock_interruptible(&rproc->lock);
if (ret) {
dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret);
return -EINVAL;
}
if (rproc->state != RPROC_OFFLINE) {
Annotation
- Immediate include surface: `asm/byteorder.h`, `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/elf.h`, `linux/firmware.h`, `linux/idr.h`, `linux/iommu.h`.
- Detected declarations: `struct rproc_rsc_cb_data`, `function rproc_iommu_fault`, `function rproc_enable_iommu`, `function rproc_disable_iommu`, `function rproc_va_to_pa`, `function rproc_da_to_va`, `function list_for_each_entry`, `function rproc_find_carveout_by_name`, `function list_for_each_entry`, `function rproc_check_carveout_da`.
- Atlas domain: Driver Families / drivers/remoteproc.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.