From patchwork Thu Nov 6 14:20:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 40294 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E181924237 for ; Thu, 6 Nov 2014 14:18:33 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id n15sf722911lbi.2 for ; Thu, 06 Nov 2014 06:18:32 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Tt/Vi9zp59pAjnThcCKVcZCF2l9tS4dOMv+W8kMZfRI=; b=ba4/9VVlrsdsv+kXQYjNHPp9c/FuXihIGEUtfpm5UZM69t9tXTGa1hm5ZRngsgJe9t 5xlTTThRSUrggJhGKsFtRcDxpbcv9quvtDikWtnszhyyHIajCen1dncW9xX8cDEuJEFd /oXyEtjGW+QvODs81YPTKuF+GPXlsQ4WF9/D2DXAAFKYzWjCaz05ZV3pHhO2FXkipTbJ xWHSdTTK4KdG71XWMPQTiXxdhvJeRSjENLn70BQl9d+9s0EUXQkbF4Lbee+YU/g/k22C EbkfR58Pshhpuy8B7cdQJuw5Nu/hCHpq2U1pllFiaRzDk/XhS6DvEjWC4j990Dxd71MF jwSw== X-Gm-Message-State: ALoCoQl2Lpf0BxyVvXxGqWINpl/Wki/Aq5YLIg8Y3dF8OndiwPlDLtu2JMY/UizRX/WNjQxZo5u8 X-Received: by 10.181.27.135 with SMTP id jg7mr2026137wid.5.1415283512822; Thu, 06 Nov 2014 06:18:32 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.228.140 with SMTP id si12ls89145lac.25.gmail; Thu, 06 Nov 2014 06:18:32 -0800 (PST) X-Received: by 10.152.203.164 with SMTP id kr4mr5271250lac.31.1415283512397; Thu, 06 Nov 2014 06:18:32 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id n1si11754982lbc.10.2014.11.06.06.18.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Nov 2014 06:18:32 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id l4so990023lbv.12 for ; Thu, 06 Nov 2014 06:18:32 -0800 (PST) X-Received: by 10.112.77.74 with SMTP id q10mr5303248lbw.66.1415283511942; Thu, 06 Nov 2014 06:18:31 -0800 (PST) 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.184.201 with SMTP id ew9csp50211lbc; Thu, 6 Nov 2014 06:18:31 -0800 (PST) X-Received: by 10.70.45.40 with SMTP id j8mr4777432pdm.130.1415283510172; Thu, 06 Nov 2014 06:18:30 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nk11si5927841pdb.213.2014.11.06.06.18.29 for ; Thu, 06 Nov 2014 06:18:30 -0800 (PST) Received-SPF: none (google.com: linux-kernel-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 S1751401AbaKFOSN (ORCPT + 25 others); Thu, 6 Nov 2014 09:18:13 -0500 Received: from mga14.intel.com ([192.55.52.115]:48414 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750936AbaKFOSB (ORCPT ); Thu, 6 Nov 2014 09:18:01 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 06 Nov 2014 06:11:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,326,1413270000"; d="scan'208";a="618221442" Received: from gerry-dev.bj.intel.com ([10.238.158.52]) by fmsmga001.fm.intel.com with ESMTP; 06 Nov 2014 06:17:51 -0800 From: Jiang Liu To: Benjamin Herrenschmidt , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "Rafael J. Wysocki" , Bjorn Helgaas , Randy Dunlap , Yinghai Lu , Borislav Petkov , Grant Likely , Marc Zyngier , Yingjoe Chen , Matthias Brugger Cc: Konrad Rzeszutek Wilk , Andrew Morton , Tony Luck , Joerg Roedel , Greg Kroah-Hartman , x86@kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jiang Liu Subject: [Patch Part2 v5 02/31] irqdomain: Do irq_find_mapping and set_type for hierarchy irqdomain in case OF Date: Thu, 6 Nov 2014 22:20:15 +0800 Message-Id: <1415283644-2559-3-git-send-email-jiang.liu@linux.intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1415283644-2559-1-git-send-email-jiang.liu@linux.intel.com> References: <1415283644-2559-1-git-send-email-jiang.liu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linux-kernel-owner@vger.kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.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: Yingjoe Chen 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 Signed-off-by: Jiang Liu --- 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 610891e63844..4811bee1b8a7 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 &&