drivers/soc/fsl/dpio/dpio-service.c
Source file repositories/reference/linux-study-clean/drivers/soc/fsl/dpio/dpio-service.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/fsl/dpio/dpio-service.c- Extension
.c- Size
- 24486 bytes
- Lines
- 899
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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.
- 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
linux/types.hlinux/fsl/mc.hsoc/fsl/dpaa2-io.hlinux/init.hlinux/module.hlinux/platform_device.hlinux/interrupt.hlinux/dma-mapping.hlinux/dim.hlinux/slab.hdpio.hqbman-portal.h
Detected Declarations
struct dpaa2_iostruct dpaa2_io_storefunction dpaa2_io_service_selectfunction dpaa2_io_dim_workfunction dpaa2_io_createfunction dpaa2_io_downfunction dpaa2_io_irqfunction dpaa2_io_get_cpufunction dpaa2_io_service_registerfunction dpaa2_io_service_deregisterfunction dpaa2_io_service_rearmfunction dpaa2_io_service_pull_fqfunction dpaa2_io_service_pull_channelfunction dpaa2_io_service_enqueue_fqfunction dpaa2_io_service_enqueue_multiple_fqfunction dpaa2_io_service_enqueue_multiple_desc_fqfunction dpaa2_io_service_enqueue_qdfunction dpaa2_io_service_releasefunction dpaa2_io_service_acquirefunction dpaa2_io_store_createfunction dpaa2_io_store_destroyfunction dpaa2_io_store_nextfunction dpaa2_io_query_fq_countfunction dpaa2_io_query_bp_countfunction dpaa2_io_set_irq_coalescingfunction dpaa2_io_get_irq_coalescingfunction dpaa2_io_set_adaptive_coalescingfunction dpaa2_io_get_adaptive_coalescingfunction dpaa2_io_update_net_dimexport dpaa2_io_service_selectexport dpaa2_io_get_cpuexport dpaa2_io_service_registerexport dpaa2_io_service_deregisterexport dpaa2_io_service_rearmexport dpaa2_io_service_pull_fqexport dpaa2_io_service_pull_channelexport dpaa2_io_service_enqueue_fqexport dpaa2_io_service_enqueue_multiple_fqexport dpaa2_io_service_enqueue_multiple_desc_fqexport dpaa2_io_service_enqueue_qdexport dpaa2_io_service_releaseexport dpaa2_io_service_acquireexport dpaa2_io_store_createexport dpaa2_io_store_destroyexport dpaa2_io_store_nextexport dpaa2_io_query_fq_countexport dpaa2_io_query_bp_countexport dpaa2_io_set_irq_coalescing
Annotated Snippet
struct dpaa2_io {
struct dpaa2_io_desc dpio_desc;
struct qbman_swp_desc swp_desc;
struct qbman_swp *swp;
struct list_head node;
/* protect against multiple management commands */
spinlock_t lock_mgmt_cmd;
/* protect notifications list */
spinlock_t lock_notifications;
struct list_head notifications;
struct device *dev;
/* Net DIM */
struct dim rx_dim;
/* protect against concurrent Net DIM updates */
spinlock_t dim_lock;
u16 event_ctr;
u64 bytes;
u64 frames;
};
struct dpaa2_io_store {
unsigned int max;
dma_addr_t paddr;
struct dpaa2_dq *vaddr;
void *alloced_addr; /* unaligned value from kmalloc() */
unsigned int idx; /* position of the next-to-be-returned entry */
struct qbman_swp *swp; /* portal used to issue VDQCR */
struct device *dev; /* device used for DMA mapping */
};
/* keep a per cpu array of DPIOs for fast access */
static struct dpaa2_io *dpio_by_cpu[NR_CPUS];
static struct list_head dpio_list = LIST_HEAD_INIT(dpio_list);
static DEFINE_SPINLOCK(dpio_list_lock);
static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d,
int cpu)
{
if (d)
return d;
if (cpu != DPAA2_IO_ANY_CPU && cpu >= num_possible_cpus())
return NULL;
/*
* If cpu == -1, choose the current cpu, with no guarantees about
* potentially being migrated away.
*/
if (cpu < 0)
cpu = raw_smp_processor_id();
/* If a specific cpu was requested, pick it up immediately */
return dpio_by_cpu[cpu];
}
static inline struct dpaa2_io *service_select(struct dpaa2_io *d)
{
if (d)
return d;
d = service_select_by_cpu(d, -1);
if (d)
return d;
spin_lock(&dpio_list_lock);
d = list_entry(dpio_list.next, struct dpaa2_io, node);
list_del(&d->node);
list_add_tail(&d->node, &dpio_list);
spin_unlock(&dpio_list_lock);
return d;
}
/**
* dpaa2_io_service_select() - return a dpaa2_io service affined to this cpu
* @cpu: the cpu id
*
* Return the affine dpaa2_io service, or NULL if there is no service affined
* to the specified cpu. If DPAA2_IO_ANY_CPU is used, return the next available
* service.
*/
struct dpaa2_io *dpaa2_io_service_select(int cpu)
{
if (cpu == DPAA2_IO_ANY_CPU)
return service_select(NULL);
return service_select_by_cpu(NULL, cpu);
}
EXPORT_SYMBOL_GPL(dpaa2_io_service_select);
Annotation
- Immediate include surface: `linux/types.h`, `linux/fsl/mc.h`, `soc/fsl/dpaa2-io.h`, `linux/init.h`, `linux/module.h`, `linux/platform_device.h`, `linux/interrupt.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct dpaa2_io`, `struct dpaa2_io_store`, `function dpaa2_io_service_select`, `function dpaa2_io_dim_work`, `function dpaa2_io_create`, `function dpaa2_io_down`, `function dpaa2_io_irq`, `function dpaa2_io_get_cpu`, `function dpaa2_io_service_register`, `function dpaa2_io_service_deregister`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: integration 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.