arch/powerpc/platforms/pseries/vio.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pseries/vio.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/pseries/vio.c- Extension
.c- Size
- 49614 bytes
- Lines
- 1734
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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
linux/cpu.hlinux/types.hlinux/delay.hlinux/stat.hlinux/sysfs.hlinux/device.hlinux/init.hlinux/slab.hlinux/console.hlinux/export.hlinux/mm.hlinux/dma-map-ops.hlinux/kobject.hlinux/kexec.hlinux/of_irq.hasm/iommu.hasm/dma.hasm/vio.hasm/prom.hasm/firmware.hasm/tce.hasm/page.hasm/hvcall.hasm/machdep.h
Detected Declarations
struct vio_cmo_poolstruct vio_cmo_dev_entryfunction vio_cmo_num_OF_devsfunction for_each_child_of_nodefunction vio_cmo_allocfunction vio_cmo_deallocfunction vio_cmo_entitlement_updatefunction list_for_each_entryfunction vio_cmo_balancefunction list_for_each_entryfunction vio_dma_iommu_free_coherentfunction vio_dma_iommu_map_physfunction vio_dma_iommu_unmap_physfunction vio_dma_iommu_map_sgfunction vio_dma_iommu_unmap_sgfunction vio_cmo_set_dev_desiredfunction vio_cmo_bus_probefunction vio_cmo_bus_removefunction vio_cmo_set_dma_opsfunction vio_cmo_bus_initfunction cmo_allocs_failed_showfunction cmo_allocs_failed_storefunction cmo_desired_storefunction cmo_high_showfunction cmo_high_storefunction vio_cmo_sysfs_initfunction vio_cmo_set_dev_desiredfunction vio_cmo_bus_removefunction Optionfunction vio_bus_probefunction vio_bus_removefunction vio_bus_shutdownfunction __vio_register_driverfunction vio_unregister_driverfunction vio_dev_releasefunction vio_bus_scan_register_devicesfunction vio_bus_initfunction vio_device_initfunction name_showfunction devspec_showfunction modalias_showfunction vio_unregister_devicefunction vio_bus_matchfunction vio_hotplugfunction vio_enable_interruptsfunction vio_disable_interruptsfunction vio_initexport vio_cmo_entitlement_update
Annotated Snippet
static ssize_t cmo_bus_##name##_show(const struct bus_type *bt, char *buf) \
{ \
return sysfs_emit(buf, "%lu\n", vio_cmo.name); \
} \
static struct bus_attribute bus_attr_cmo_bus_##name = \
__ATTR(cmo_##name, S_IRUGO, cmo_bus_##name##_show, NULL)
#define viobus_cmo_pool_rd_attr(name, var) \
static ssize_t \
cmo_##name##_##var##_show(const struct bus_type *bt, char *buf) \
{ \
return sysfs_emit(buf, "%lu\n", vio_cmo.name.var); \
} \
static BUS_ATTR_RO(cmo_##name##_##var)
viobus_cmo_rd_attr(entitled);
viobus_cmo_rd_attr(spare);
viobus_cmo_rd_attr(min);
viobus_cmo_rd_attr(desired);
viobus_cmo_rd_attr(curr);
viobus_cmo_pool_rd_attr(reserve, size);
viobus_cmo_pool_rd_attr(excess, size);
viobus_cmo_pool_rd_attr(excess, free);
static ssize_t cmo_high_show(const struct bus_type *bt, char *buf)
{
return sysfs_emit(buf, "%lu\n", vio_cmo.high);
}
static ssize_t cmo_high_store(const struct bus_type *bt, const char *buf,
size_t count)
{
unsigned long flags;
spin_lock_irqsave(&vio_cmo.lock, flags);
vio_cmo.high = vio_cmo.curr;
spin_unlock_irqrestore(&vio_cmo.lock, flags);
return count;
}
static BUS_ATTR_RW(cmo_high);
static struct attribute *vio_bus_attrs[] = {
&bus_attr_cmo_bus_entitled.attr,
&bus_attr_cmo_bus_spare.attr,
&bus_attr_cmo_bus_min.attr,
&bus_attr_cmo_bus_desired.attr,
&bus_attr_cmo_bus_curr.attr,
&bus_attr_cmo_high.attr,
&bus_attr_cmo_reserve_size.attr,
&bus_attr_cmo_excess_size.attr,
&bus_attr_cmo_excess_free.attr,
NULL,
};
ATTRIBUTE_GROUPS(vio_bus);
static void __init vio_cmo_sysfs_init(void) { }
#else /* CONFIG_PPC_SMLPAR */
int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {}
static int vio_cmo_bus_probe(struct vio_dev *viodev) { return 0; }
static void vio_cmo_bus_remove(struct vio_dev *viodev) {}
static void vio_cmo_set_dma_ops(struct vio_dev *viodev) {}
static void vio_cmo_bus_init(void) {}
static void __init vio_cmo_sysfs_init(void) { }
#endif /* CONFIG_PPC_SMLPAR */
EXPORT_SYMBOL(vio_cmo_entitlement_update);
EXPORT_SYMBOL(vio_cmo_set_dev_desired);
/*
* Platform Facilities Option (PFO) support
*/
/**
* vio_h_cop_sync - Perform a synchronous PFO co-processor operation
*
* @vdev - Pointer to a struct vio_dev for device
* @op - Pointer to a struct vio_pfo_op for the operation parameters
*
* Calls the hypervisor to synchronously perform the PFO operation
* described in @op. In the case of a busy response from the hypervisor,
* the operation will be re-submitted indefinitely unless a non-zero timeout
* is specified or an error occurs. The timeout places a limit on when to
* stop re-submitting a operation, the total time can be exceeded if an
* operation is in progress.
*
* If op->hcall_ret is not NULL, this will be set to the return from the
* last h_cop_op call or it will be 0 if an error not involving the h_call
* was encountered.
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/types.h`, `linux/delay.h`, `linux/stat.h`, `linux/sysfs.h`, `linux/device.h`, `linux/init.h`, `linux/slab.h`.
- Detected declarations: `struct vio_cmo_pool`, `struct vio_cmo_dev_entry`, `function vio_cmo_num_OF_devs`, `function for_each_child_of_node`, `function vio_cmo_alloc`, `function vio_cmo_dealloc`, `function vio_cmo_entitlement_update`, `function list_for_each_entry`, `function vio_cmo_balance`, `function list_for_each_entry`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.