From patchwork Thu Jun 12 11:53:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan R X-Patchwork-Id: 31815 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A89F320AE6 for ; Thu, 12 Jun 2014 11:56:27 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id dc16sf3488927qab.1 for ; Thu, 12 Jun 2014 04:56:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=SfSx+aEhSIlxhuQPz8qH6/THzw9Nv5G4KiKKHVnz68M=; b=AsIjRyiXzxCeUTTyvKuuaNpQM7/CAKVyqTjbrMXqdNLyeD5lebqp6hfo7pYw/6AGpg QIEVnuO6PxZEGTDkwFVcotWGSZeoVKCR8puCM+OaF6XYGmytuGarx17DyiENRTWwojua qcj7CGWL2yOH7vZGppuM9wionNTyCUXaAND51jlJygqcd/m6VU3qhNxLLclG3p+Ahz4O i4FP7KElJcJKg8HH788bsAuwVPZQFcgXERnIEpkeHsi4zD+YdZ8nToWlCmSeufEgxiQb vzpD9p4dEkeX69zJs7NspM8pt4y57N04+hoeKuppuNCZHGsHr94/w40JeIuas0Om+RaQ aHqw== X-Gm-Message-State: ALoCoQlAyLUik/tEChl1sFtVYrpPwEpTD5WaZNRSJiPbGmi5nfeJNLHa7akY9qUl1zIwp2LRATf9 X-Received: by 10.224.70.10 with SMTP id b10mr748500qaj.8.1402574187544; Thu, 12 Jun 2014 04:56:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.33 with SMTP id e30ls3136753qge.89.gmail; Thu, 12 Jun 2014 04:56:26 -0700 (PDT) X-Received: by 10.58.152.234 with SMTP id vb10mr22466423veb.21.1402574186660; Thu, 12 Jun 2014 04:56:26 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id sy10si233361veb.103.2014.06.12.04.56.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Jun 2014 04:56:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id il7so645375vcb.26 for ; Thu, 12 Jun 2014 04:56:26 -0700 (PDT) X-Received: by 10.220.12.66 with SMTP id w2mr43626530vcw.15.1402574186544; Thu, 12 Jun 2014 04:56:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp397107vcb; Thu, 12 Jun 2014 04:56:26 -0700 (PDT) X-Received: by 10.66.141.76 with SMTP id rm12mr20976636pab.138.1402574185824; Thu, 12 Jun 2014 04:56:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj1si41362013pbb.77.2014.06.12.04.56.25; Thu, 12 Jun 2014 04:56:25 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933472AbaFLL4L (ORCPT + 8 others); Thu, 12 Jun 2014 07:56:11 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:32772 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933471AbaFLL4I (ORCPT ); Thu, 12 Jun 2014 07:56:08 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5CBtXuX025191; Thu, 12 Jun 2014 06:55:33 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5CBtXPi029157; Thu, 12 Jun 2014 06:55:33 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Thu, 12 Jun 2014 06:55:32 -0500 Received: from uda0393807.india.ti.com. (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5CBtEbp008910; Thu, 12 Jun 2014 06:55:27 -0500 From: Sricharan R To: , , , CC: , , , , , , , Subject: [PATCH V2 02/19] irqchip: crossbar: check for premapped crossbar before allocating Date: Thu, 12 Jun 2014 17:23:10 +0530 Message-ID: <1402574007-13987-3-git-send-email-r.sricharan@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1402574007-13987-1-git-send-email-r.sricharan@ti.com> References: <1402574007-13987-1-git-send-email-r.sricharan@ti.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: r.sricharan@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Nishanth Menon If irq_of_parse_and_map is executed twice, the same crossbar is mapped to two different GIC interrupts. This is completely undesirable. Instead, check if the requested crossbar event is pre-allocated and provide that GIC mapping back to caller if already allocated. Signed-off-by: Nishanth Menon Signed-off-by: Sricharan R Signed-off-by: Tony Lindgren --- drivers/irqchip/irq-crossbar.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/irqchip/irq-crossbar.c b/drivers/irqchip/irq-crossbar.c index 20105bc..51d4b87 100644 --- a/drivers/irqchip/irq-crossbar.c +++ b/drivers/irqchip/irq-crossbar.c @@ -51,6 +51,17 @@ static inline void crossbar_writeb(int irq_no, int cb_no) writeb(cb_no, cb->crossbar_base + cb->register_offsets[irq_no]); } +static inline int get_prev_map_irq(int cb_no) +{ + int i; + + for (i = 0; i < cb->int_max; i++) + if (cb->irq_map[i] == cb_no) + return i; + + return -ENODEV; +} + static inline int allocate_free_irq(int cb_no) { int i; @@ -88,11 +99,16 @@ static int crossbar_domain_xlate(struct irq_domain *d, { unsigned long ret; + ret = get_prev_map_irq(intspec[1]); + if (!IS_ERR_VALUE(ret)) + goto found; + ret = allocate_free_irq(intspec[1]); if (IS_ERR_VALUE(ret)) return ret; +found: *out_hwirq = ret + GIC_IRQ_START; return 0; }