Exemple #1
0
int
xpmem_alloc_seg_signal(struct xpmem_segment * seg)
{
    int irq;
    int vector, host_vector;
    int apic_id;

    /* Request irq */
    irq = xpmem_request_irq(xpmem_irq_fn, (void *)seg->segid);
    if (irq < 0) 
        return irq;

    /* Get IDT vector */
    vector = xpmem_irq_to_vector(irq);
    if (vector < 0) {
        xpmem_release_irq(irq, (void *)seg->segid);
        return vector;
    }

    /* Get hardware IDT vector from host */
    host_vector = xpmem_request_host_vector(vector);

    /* Get hardware apic ID for logical cpu 0*/
    apic_id = xpmem_get_host_apic_id(0);
    if (apic_id < 0) {
        xpmem_release_host_vector(host_vector);
        xpmem_release_irq(irq, (void *)seg->segid);
        return apic_id;
    }

    /* Save sigid in seg structure */
    seg->sig.irq     = irq;
    seg->sig.vector  = host_vector;
    seg->sig.apic_id = apic_id;

    return 0;
}
Exemple #2
0
void
xpmem_free_seg_signal(struct xpmem_segment * seg)
{
    int status = 0;

    spin_lock(&(seg->lock));
    if (seg->flags & XPMEM_FLAG_SIGNALLABLE) {
        status = 1;
        seg->flags &= ~XPMEM_FLAG_SIGNALLABLE;
    } 
    spin_unlock(&(seg->lock));

    if (status) {
        /* Release host IDT vector */
        xpmem_release_host_vector(seg->sig.vector);

        /* Release the irq */
        xpmem_release_irq(seg->sig.irq, (void *)seg->segid);
    }
}
Exemple #3
0
int
xpmem_free_seg_signal(struct xpmem_segment * seg)
{
    int status = -1;
    unsigned long flags;

    spin_lock_irqsave(&(seg->lock), flags);
    if (seg->flags & XPMEM_FLAG_SIGNALLABLE) {
        status = 0;
        seg->flags &= ~XPMEM_FLAG_SIGNALLABLE;
    } 
    spin_unlock_irqrestore(&(seg->lock), flags);

    if (status)
	return status;

    /* Release host IDT vector */
    xpmem_release_host_vector(seg->sig.vector);

    /* Release the irq */
    xpmem_release_irq(seg->sig.irq, (void *)seg->segid);

    return 0;
}