/* This can be called multiple time to change a queue configuration */ int xive_native_configure_queue(u32 vp_id, struct xive_q *q, u8 prio,
__be32 *qpage, u32 order, bool can_escalate)
{
s64 rc = 0;
__be64 qeoi_page_be;
__be32 esc_irq_be;
u64 flags, qpage_phys;
/* If there's an actual queue page, clean it */ if (order) { if (WARN_ON(!qpage)) return -EINVAL;
qpage_phys = __pa(qpage);
} else
qpage_phys = 0;
/* Initialize the rest of the fields */
q->msk = order ? ((1u << (order - 2)) - 1) : 0;
q->idx = 0;
q->toggle = 0;
rc = opal_xive_get_queue_info(vp_id, prio, NULL, NULL,
&qeoi_page_be,
&esc_irq_be,
NULL); if (rc) {
vp_err(vp_id, "Failed to get queue %d info : %lld\n", prio, rc);
rc = -EIO; goto fail;
}
q->eoi_phys = be64_to_cpu(qeoi_page_be);
/* Configure and enable the queue in HW */ for (;;) {
rc = opal_xive_set_queue_info(vp_id, prio, qpage_phys, order, flags); if (rc != OPAL_BUSY) break;
msleep(OPAL_BUSY_DELAY_MS);
} if (rc) {
vp_err(vp_id, "Failed to set queue %d info: %lld\n", prio, rc);
rc = -EIO;
} else { /* * KVM code requires all of the above to be visible before * q->qpage is set due to how it manages IPI EOIs
*/
wmb();
q->qpage = qpage;
}
fail: return rc;
}
EXPORT_SYMBOL_GPL(xive_native_configure_queue);
/* * We use the variant with no iounmap as this is called on exec * from an IPI and iounmap isn't safe
*/
__xive_native_disable_queue(get_hard_smp_processor_id(cpu), q, prio);
alloc_order = xive_alloc_order(xive_queue_shift);
free_pages((unsignedlong)q->qpage, alloc_order);
q->qpage = NULL;
}
/* * Old versions of skiboot can incorrectly return 0xffffffff to * indicate no space, fix it up here.
*/ return irq == 0xffffffff ? OPAL_RESOURCE : irq;
}
/* Allocate an IPI and populate info about it */ for (;;) {
irq = opal_xive_allocate_irq(xc->chip_id); if (irq == OPAL_BUSY) {
msleep(OPAL_BUSY_DELAY_MS); continue;
} if (irq < 0) {
pr_err("Failed to allocate IPI on CPU %d\n", cpu); return -ENXIO;
}
xc->hw_ipi = irq; break;
} return 0;
} #endif/* CONFIG_SMP */
/* Free the IPI */ if (xc->hw_ipi == XIVE_BAD_IRQ) return; for (;;) {
rc = opal_xive_free_irq(xc->hw_ipi); if (rc == OPAL_BUSY) {
msleep(OPAL_BUSY_DELAY_MS); continue;
}
xc->hw_ipi = XIVE_BAD_IRQ; break;
}
} #endif/* CONFIG_SMP */
staticvoid xive_native_shutdown(void)
{ /* Switch the XIVE to emulation mode */
opal_xive_reset(OPAL_XIVE_MODE_EMU);
}
/* * Perform an "ack" cycle on the current thread, thus * grabbing the pending active priorities and updating * the CPPR to the most favored one.
*/ staticvoid xive_native_update_pending(struct xive_cpu *xc)
{
u8 he, cppr;
u16 ack;
/* Perform the acknowledge hypervisor to register cycle */
ack = be16_to_cpu(__raw_readw(xive_tima + TM_SPC_ACK_HV_REG));
/* Synchronize subsequent queue accesses */
mb();
/* * Grab the CPPR and the "HE" field which indicates the source * of the hypervisor interrupt (if any)
*/
cppr = ack & 0xff;
he = (ack >> 8) >> 6; switch(he) { case TM_QW3_NSR_HE_NONE: /* Nothing to see here */ break; case TM_QW3_NSR_HE_PHYS: /* Physical thread interrupt */ if (cppr == 0xff) return; /* Mark the priority pending */
xc->pending_prio |= 1 << cppr;
/* * A new interrupt should never have a CPPR less favored * than our current one.
*/ if (cppr >= xc->cppr)
pr_err("CPU %d odd ack CPPR, got %d at %d\n",
smp_processor_id(), cppr, xc->cppr);
/* Update our idea of what the CPPR is */
xc->cppr = cppr; break; case TM_QW3_NSR_HE_POOL: /* HV Pool interrupt (unused) */ case TM_QW3_NSR_HE_LSI: /* Legacy FW LSI (unused) */
pr_err("CPU %d got unexpected interrupt type HE=%d\n",
smp_processor_id(), he); return;
}
}
/* Check if pool VP already active, if it is, pull it */ if (in_be32(xive_tima + TM_QW2_HV_POOL + TM_WORD2) & TM_QW2W2_VP)
in_be64(xive_tima + TM_SPC_PULL_POOL_CTX);
/* Enable the pool VP */
vp = xive_pool_vps + cpu; for (;;) {
rc = opal_xive_set_vp_info(vp, OPAL_XIVE_VP_ENABLED, 0); if (rc != OPAL_BUSY) break;
msleep(OPAL_BUSY_DELAY_MS);
} if (rc) {
pr_err("Failed to enable pool VP on CPU %d\n", cpu); return;
}
/* Grab its CAM value */
rc = opal_xive_get_vp_info(vp, NULL, &vp_cam_be, NULL, NULL); if (rc) {
pr_err("Failed to get pool VP info CPU %d\n", cpu); return;
}
vp_cam = be64_to_cpu(vp_cam_be);
/* Push it on the CPU (set LSMFB to 0xff to skip backlog scan) */
out_be32(xive_tima + TM_QW2_HV_POOL + TM_WORD0, 0xff);
out_be32(xive_tima + TM_QW2_HV_POOL + TM_WORD2, TM_QW2W2_VP | vp_cam);
}
xive_provision_cache = kmem_cache_create("xive-provision",
xive_provision_size,
xive_provision_size,
0, NULL); if (!xive_provision_cache) {
pr_err("Failed to allocate provision cache\n"); returnfalse;
} returntrue;
}
staticvoid __init xive_native_setup_pools(void)
{ /* Allocate a pool big enough */
pr_debug("Allocating VP block for pool size %u\n", nr_cpu_ids);
xive_pool_vps = xive_native_alloc_vp_block(nr_cpu_ids); if (WARN_ON(xive_pool_vps == XIVE_INVALID_VP))
pr_err("Failed to allocate pool VP, KVM might not function\n");
pr_debug("Pool VPs allocated at 0x%x for %u max CPUs\n",
xive_pool_vps, nr_cpu_ids);
}
for (i = 0; i < xive_provision_chip_count; i++) {
u32 chip = xive_provision_chips[i];
/* * XXX TODO: Try to make the allocation local to the node where * the chip resides.
*/
p = kmem_cache_alloc(xive_provision_cache, GFP_KERNEL); if (!p) {
pr_err("Failed to allocate provisioning page\n"); returnfalse;
}
kmemleak_ignore(p);
opal_xive_donate_page(chip, __pa(p));
} returntrue;
}
rc = opal_xive_get_queue_info(vp_id, prio, &qpage, &qsize,
&qeoi_page, &escalate_irq, &qflags); if (rc) {
vp_err(vp_id, "failed to get queue %d info : %lld\n", prio, rc); return -EIO;
}
if (out_qpage)
*out_qpage = be64_to_cpu(qpage); if (out_qsize)
*out_qsize = be64_to_cpu(qsize); if (out_qeoi_page)
*out_qeoi_page = be64_to_cpu(qeoi_page); if (out_escalate_irq)
*out_escalate_irq = be32_to_cpu(escalate_irq); if (out_qflags)
*out_qflags = be64_to_cpu(qflags);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.