From patchwork Fri Jan 24 16:43:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 23687 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 643CC203C5 for ; Fri, 24 Jan 2014 16:44:02 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf8157015pab.7 for ; Fri, 24 Jan 2014 08:44:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=VdC77sRHlEzs0x0xL7GzfQvfshF8EMZo2t9FVrPfKUg=; b=eggQA8FhlUhYe4EUqUgqxLp28jNQBox33Ijb4ggdB9pYZem+dgK6HRjRQLPRZwhOu9 +aFtVp1zUe+QM9vvAtcy32tCqMVJKJF9RaJb+EvVXMOllupIBzSeUSR4kyVFXwtNW/Na 5UlptAwQ12AfsxuOXioYd0g+S0ykY8enEeohaseBHEULuBAsY6Y9yatcBiord116rHoG LbOpbqHiJ56L2iISIQcYInQbyu8DnuhwIdpebwRjuc6ERa7OXt832LjkZ0QNeXttKgQm 6O3CXA6MN6Y1eBqjXKTi1QcHnY7vq6AH62D+GvFSewu9DVSUL0zKarv2TEcSP2a2T5bk M8bw== X-Gm-Message-State: ALoCoQkYz9Qb6uuv4fB1RqLXrvY/qUI1h8KToyRVOMVY2ULOPiKyHnida9nPDW/7UCxahR7yzPmP X-Received: by 10.66.66.196 with SMTP id h4mr5334026pat.22.1390581840301; Fri, 24 Jan 2014 08:44:00 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.129 with SMTP id g1ls708794qge.69.gmail; Fri, 24 Jan 2014 08:44:00 -0800 (PST) X-Received: by 10.220.98.204 with SMTP id r12mr94457vcn.48.1390581840097; Fri, 24 Jan 2014 08:44:00 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id f7si799773vcz.132.2014.01.24.08.44.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 Jan 2014 08:44:00 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id oy12so2141025veb.9 for ; Fri, 24 Jan 2014 08:44:00 -0800 (PST) X-Received: by 10.58.24.196 with SMTP id w4mr86000vef.48.1390581840019; Fri, 24 Jan 2014 08:44:00 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp115789vcz; Fri, 24 Jan 2014 08:43:59 -0800 (PST) X-Received: by 10.15.93.203 with SMTP id w51mr13618577eez.33.1390581839023; Fri, 24 Jan 2014 08:43:59 -0800 (PST) Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by mx.google.com with ESMTPS id l2si3201142een.104.2014.01.24.08.43.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 Jan 2014 08:43:59 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.44 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.44; Received: by mail-ee0-f44.google.com with SMTP id c13so1067695eek.31 for ; Fri, 24 Jan 2014 08:43:58 -0800 (PST) X-Received: by 10.14.184.66 with SMTP id r42mr8914108eem.86.1390581838546; Fri, 24 Jan 2014 08:43:58 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id k41sm5521285eey.0.2014.01.24.08.43.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Jan 2014 08:43:57 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, tim@xen.org, stefano.stabellini@citrix.com, Julien Grall , Keir Fraser Subject: [PATCH for-4.5 7/8] xen/irq: Handle multiple action per IRQ Date: Fri, 24 Jan 2014 16:43:41 +0000 Message-Id: <1390581822-32624-8-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1390581822-32624-1-git-send-email-julien.grall@linaro.org> References: <1390581822-32624-1-git-send-email-julien.grall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On ARM, it may happen (eg ARM SMMU) to setup multiple handler for the same interrupt. Signed-off-by: Julien Grall CC: Keir Fraser --- xen/arch/arm/gic.c | 48 ++++++++++++++++++++++++++++++++++++++++-------- xen/arch/arm/irq.c | 6 +++++- xen/include/xen/irq.h | 1 + 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index ebd2b5f..8ba1de3 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -534,32 +534,64 @@ void release_dt_irq(const struct dt_irq *irq, const void *dev_id) { struct irq_desc *desc; unsigned long flags; - struct irqaction *action; + struct irqaction *action, **action_ptr; desc = irq_to_desc(irq->irq); spin_lock_irqsave(&desc->lock,flags); desc->handler->shutdown(desc); action = desc->action; - desc->action = NULL; - desc->status &= ~IRQ_GUEST; + + action_ptr = &desc->action; + for ( ;; ) + { + action = *action_ptr; + + if ( !action ) + { + printk(XENLOG_WARNING "Trying to free already-free IRQ %u\n", + irq->irq); + return; + } + + if ( action->dev_id == dev_id ) + break; + + action_ptr = &action->next; + } + + /* Found it - remove it from the action list */ + *action_ptr = action->next; + + /* If this was the list action, shut down the IRQ */ + if ( !desc->action ) + { + desc->handler->shutdown(desc); + desc->status &= ~IRQ_GUEST; + } spin_unlock_irqrestore(&desc->lock,flags); /* Wait to make sure it's not being used on another CPU */ do { smp_mb(); } while ( desc->status & IRQ_INPROGRESS ); - if (action && action->free_on_release) + if ( action && action->free_on_release ) xfree(action); } static int __setup_irq(struct irq_desc *desc, unsigned int irq, struct irqaction *new) { - if ( desc->action != NULL ) - return -EBUSY; + struct irqaction *action = desc->action; + + ASSERT(new != NULL); + + /* Check that dev_id is correctly filled if we have multiple action */ + if ( action != NULL && ( action->dev_id == NULL || new->dev_id == NULL ) ) + return -EINVAL; - desc->action = new; + new->next = desc->action; + desc->action = new; dsb(); return 0; @@ -610,7 +642,7 @@ int __init setup_dt_irq(const struct dt_irq *irq, struct irqaction *new) rc = __setup_irq(desc, irq->irq, new); - if ( !rc ) + if ( !rc && disabled ) desc->handler->startup(desc); spin_unlock_irqrestore(&desc->lock, flags); diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 3e326b0..edf0404 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -179,7 +179,11 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq) { desc->status &= ~IRQ_PENDING; spin_unlock_irq(&desc->lock); - action->handler(irq, action->dev_id, regs); + do + { + action->handler(irq, action->dev_id, regs); + action = action->next; + } while ( action ); spin_lock_irq(&desc->lock); } diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h index f2e6215..54314b8 100644 --- a/xen/include/xen/irq.h +++ b/xen/include/xen/irq.h @@ -11,6 +11,7 @@ struct irqaction { void (*handler)(int, void *, struct cpu_user_regs *); + struct irqaction *next; const char *name; void *dev_id; bool_t free_on_release;