From patchwork Fri Dec 20 13:29:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11305429 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E86946C1 for ; Fri, 20 Dec 2019 13:29:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CEDB3206DA for ; Fri, 20 Dec 2019 13:29:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEDB3206DA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iiIKr-0005ZT-Ae; Fri, 20 Dec 2019 13:28:53 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iiIKq-0005ZJ-0g for xen-devel@lists.xenproject.org; Fri, 20 Dec 2019 13:28:52 +0000 X-Inumbo-ID: a8fcf2b8-232c-11ea-9359-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a8fcf2b8-232c-11ea-9359-12813bfff9fa; Fri, 20 Dec 2019 13:28:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A216FAE3A; Fri, 20 Dec 2019 13:28:50 +0000 (UTC) From: Jan Beulich To: "xen-devel@lists.xenproject.org" References: <20efd995-9346-4b0c-f927-ad1152f6ccfe@suse.com> Message-ID: <50db8c1f-aef2-2e68-926b-1ff0cdd934fa@suse.com> Date: Fri, 20 Dec 2019 14:29:20 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20efd995-9346-4b0c-f927-ad1152f6ccfe@suse.com> Content-Language: en-US Subject: [Xen-devel] [PATCH 2/6] x86/IRQ: move and rename __do_IRQ_guest() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This is for it to be next to do_IRQ(). Beyond the actual code movement this - drops the leading underscores, - passes in desc and vector, rather than irq, - flips the order of two ASSERT()s, - changes i and sp to unsigned int, - restricts the scope of d and sp, - corrects style. Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1144,64 +1144,6 @@ static void irq_guest_eoi_timer_fn(void spin_unlock_irq(&desc->lock); } -static void __do_IRQ_guest(int irq) -{ - struct irq_desc *desc = irq_to_desc(irq); - irq_guest_action_t *action = (irq_guest_action_t *)desc->action; - struct domain *d; - int i, sp; - struct pending_eoi *peoi = this_cpu(pending_eoi); - unsigned int vector = (u8)get_irq_regs()->entry_vector; - - if ( unlikely(action->nr_guests == 0) ) - { - /* An interrupt may slip through while freeing an ACKTYPE_EOI irq. */ - ASSERT(action->ack_type == ACKTYPE_EOI); - ASSERT(desc->status & IRQ_DISABLED); - if ( desc->handler->end ) - desc->handler->end(desc, vector); - return; - } - - /* - * Stop the timer as soon as we're certain we'll set it again further down, - * to prevent the current timeout (if any) to needlessly expire. - */ - if ( action->ack_type != ACKTYPE_NONE ) - stop_timer(&action->eoi_timer); - - if ( action->ack_type == ACKTYPE_EOI ) - { - sp = pending_eoi_sp(peoi); - ASSERT((sp == 0) || (peoi[sp-1].vector < vector)); - ASSERT(sp < (NR_DYNAMIC_VECTORS-1)); - peoi[sp].irq = irq; - peoi[sp].vector = vector; - peoi[sp].ready = 0; - pending_eoi_sp(peoi) = sp+1; - cpumask_set_cpu(smp_processor_id(), action->cpu_eoi_map); - } - - for ( i = 0; i < action->nr_guests; i++ ) - { - struct pirq *pirq; - - d = action->guest[i]; - pirq = pirq_info(d, domain_irq_to_pirq(d, irq)); - if ( (action->ack_type != ACKTYPE_NONE) && - !test_and_set_bool(pirq->masked) ) - action->in_flight++; - if ( !is_hvm_domain(d) || !hvm_do_IRQ_dpci(d, pirq) ) - send_guest_pirq(d, pirq); - } - - if ( action->ack_type != ACKTYPE_NONE ) - { - migrate_timer(&action->eoi_timer, smp_processor_id()); - set_timer(&action->eoi_timer, NOW() + MILLISECS(1)); - } -} - /* * Retrieve Xen irq-descriptor corresponding to a domain-specific irq. * The descriptor is returned locked. This function is safe against changes @@ -1870,6 +1812,62 @@ static bool pirq_guest_force_unbind(stru return bound; } +static void do_IRQ_guest(struct irq_desc *desc, unsigned int vector) +{ + irq_guest_action_t *action = (irq_guest_action_t *)desc->action; + unsigned int i; + struct pending_eoi *peoi = this_cpu(pending_eoi); + + if ( unlikely(!action->nr_guests) ) + { + /* An interrupt may slip through while freeing an ACKTYPE_EOI irq. */ + ASSERT(action->ack_type == ACKTYPE_EOI); + ASSERT(desc->status & IRQ_DISABLED); + if ( desc->handler->end ) + desc->handler->end(desc, vector); + return; + } + + /* + * Stop the timer as soon as we're certain we'll set it again further down, + * to prevent the current timeout (if any) to needlessly expire. + */ + if ( action->ack_type != ACKTYPE_NONE ) + stop_timer(&action->eoi_timer); + + if ( action->ack_type == ACKTYPE_EOI ) + { + unsigned int sp = pending_eoi_sp(peoi); + + ASSERT(sp < (NR_DYNAMIC_VECTORS - 1)); + ASSERT(!sp || (peoi[sp - 1].vector < vector)); + peoi[sp].irq = desc->irq; + peoi[sp].vector = vector; + peoi[sp].ready = 0; + pending_eoi_sp(peoi) = sp + 1; + cpumask_set_cpu(smp_processor_id(), action->cpu_eoi_map); + } + + for ( i = 0; i < action->nr_guests; i++ ) + { + struct domain *d = action->guest[i]; + struct pirq *pirq; + + pirq = pirq_info(d, domain_irq_to_pirq(d, desc->irq)); + if ( (action->ack_type != ACKTYPE_NONE) && + !test_and_set_bool(pirq->masked) ) + action->in_flight++; + if ( !is_hvm_domain(d) || !hvm_do_IRQ_dpci(d, pirq) ) + send_guest_pirq(d, pirq); + } + + if ( action->ack_type != ACKTYPE_NONE ) + { + migrate_timer(&action->eoi_timer, smp_processor_id()); + set_timer(&action->eoi_timer, NOW() + MILLISECS(1)); + } +} + void do_IRQ(struct cpu_user_regs *regs) { struct irqaction *action; @@ -1954,7 +1952,7 @@ void do_IRQ(struct cpu_user_regs *regs) } tsc_in = tb_init_done ? get_cycles() : 0; - __do_IRQ_guest(irq); + do_IRQ_guest(desc, vector); TRACE_3D(TRC_HW_IRQ_HANDLED, irq, tsc_in, get_cycles()); goto out_no_end; }