From patchwork Wed Oct 29 10:00:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yingjoe Chen X-Patchwork-Id: 39736 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A614824046 for ; Wed, 29 Oct 2014 10:07:40 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gq15sf1484010lab.2 for ; Wed, 29 Oct 2014 03:07:39 -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=TM0xLyv0h060Y20eOEC0s5WVLfkCenOoRjGAKfF8RDw=; b=fa3VYvX26Im2GnvSi/xoJS+BGKv3/GO8uY+TMwwSTT4I9HhdLQDpwJ/CJ6X1cTQXVU YJn+uRnjAMsqVrAHTdWmSAW/+hXFCIMZylLORduYphxKL707D/HGbP7bSoF0Ew/o8Adn oM2AHh7hgtbOiQwK6jBY3aIeHEMgxITPnlMQvIEpdGgaqY2tV10Nd0arIvJC2gJQaAd4 OxHBzXQ6C7XHUjRpfII+RuCjx+u4nRcsdqVj/EDMmQNwCNIlsJ8IhkpWioG5nPL0KMpr C7MWW9RweVzT64lSt7ajw84OMEeZ3F0snahjtr4nLdgo9UfR1t8aoWBqB+U9k2jfoI9W MXbw== X-Gm-Message-State: ALoCoQnIj3jkoAsbaSFkbA/EmWUJ3uYa9g1LfeyAOpzo2rqOYz7i2/+RLvFheA7rV6Qz+05rszyR X-Received: by 10.112.41.228 with SMTP id i4mr1609210lbl.0.1414577259470; Wed, 29 Oct 2014 03:07:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.42 with SMTP id k10ls161252lae.66.gmail; Wed, 29 Oct 2014 03:07:39 -0700 (PDT) X-Received: by 10.112.134.39 with SMTP id ph7mr10194991lbb.45.1414577259293; Wed, 29 Oct 2014 03:07:39 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id 1si6508906lai.41.2014.10.29.03.07.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 03:07:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id gf13so2237290lab.3 for ; Wed, 29 Oct 2014 03:07:39 -0700 (PDT) X-Received: by 10.153.8.164 with SMTP id dl4mr10213498lad.29.1414577259014; Wed, 29 Oct 2014 03:07:39 -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.112.84.229 with SMTP id c5csp629511lbz; Wed, 29 Oct 2014 03:07:38 -0700 (PDT) X-Received: by 10.70.103.102 with SMTP id fv6mr9663118pdb.92.1414577257342; Wed, 29 Oct 2014 03:07:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8si3574423pdr.201.2014.10.29.03.07.36 for ; Wed, 29 Oct 2014 03:07:37 -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 S932249AbaJ2KHe (ORCPT + 4 others); Wed, 29 Oct 2014 06:07:34 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:58717 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932102AbaJ2KHd (ORCPT ); Wed, 29 Oct 2014 06:07:33 -0400 X-Listener-Flag: 11101 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 225734655; Wed, 29 Oct 2014 18:07:27 +0800 Received: from mtksdtcf02.mediatek.inc (10.21.12.142) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.181.6; Wed, 29 Oct 2014 18:07:26 +0800 From: Yingjoe Chen To: Matthias Brugger , Thomas Gleixner , Jiang Liu , Marc Zyngier , CC: Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Russell King , Jason Cooper , Benjamin Herrenschmidt , Yingjoe Chen , Grant Likely , Boris BREZILLON , , , , , , , , , , Sascha Hauer , Olof Johansson , Arnd Bergmann Subject: [PATCH v5 1/6] irqdomain: do irq_find_mapping and set_type for hierarchy irqdomain Date: Wed, 29 Oct 2014 18:00:19 +0800 Message-ID: <1414576824-16143-2-git-send-email-yingjoe.chen@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1414576824-16143-1-git-send-email-yingjoe.chen@mediatek.com> References: <1414576824-16143-1-git-send-email-yingjoe.chen@mediatek.com> MIME-Version: 1.0 X-MTK: N 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: yingjoe.chen@mediatek.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.215.44 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: , It is possible to call irq_create_of_mapping to create/translate the same IRQ from DT for multiple times. Perform irq_find_mapping check and set_type for hierarchy irqdomain in irq_create_of_mapping() to avoid duplicate these functionality in all outer most irqdomain. Signed-off-by: Yingjoe Chen --- kernel/irq/irqdomain.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 7cc9cbb..c292603 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -478,11 +478,6 @@ unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data) return 0; } - if (irq_domain_is_hierarchy(domain)) { - virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, irq_data); - return virq <= 0 ? 0 : virq; - } - /* If domain has no translation, then we assume interrupt line */ if (domain->ops->xlate == NULL) hwirq = irq_data->args[0]; @@ -492,10 +487,24 @@ unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data) return 0; } - /* Create mapping */ - virq = irq_create_mapping(domain, hwirq); - if (!virq) - return virq; + if (irq_domain_is_hierarchy(domain)) { + /* + * If we've already configured this interrupt, + * don't do it again, or hell will break loose. + */ + virq = irq_find_mapping(domain, hwirq); + if (virq) + return virq; + + virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, irq_data); + if (virq <= 0) + return 0; + } else { + /* Create mapping */ + virq = irq_create_mapping(domain, hwirq); + if (!virq) + return virq; + } /* Set type if specified and different than the current one */ if (type != IRQ_TYPE_NONE &&