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.

Dependency Surface

Detected Declarations

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

Implementation Notes