From patchwork Thu Sep 27 13:13:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 11758 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8820023EFD for ; Thu, 27 Sep 2012 13:14:25 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 179D8A1877C for ; Thu, 27 Sep 2012 13:14:24 +0000 (UTC) Received: by ieje10 with SMTP id e10so4106129iej.11 for ; Thu, 27 Sep 2012 06:14:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=EHSGWeNzkw4JOfz17WuuPY9XU3lzCNUx/x/b6XgNfOQ=; b=i3trekcDBRRG0DErXi/f8TD4o+t+EGPDVJ65QXRobyLFp6W1Cj+VEA7raObc0kSYyh cfrKi8rEQJ+fsONgfovJHSzcrFxe6ReFieMCpK0DOMMica5ckHY+xLZP3ReKsqg7KJxu uk5BsxTWMYTGIN5owdLKlRC5+CdqBWQHi77D3nVfEyCLy7o2MAgLlvuotlOPsG2eTDjo lgQAmwZglGtOqjL3RBsQCNL4Z4DHl4rqbSyOgB4L1xr3YaL89K8snPa4yitiiOJ55e86 89cFrtqqT9Rs6KDpU6SPB3feyfRy8er7iVDXdJTdvPindZYqmWIwcFT3mMjbrKIzaGtL 9Mvg== Received: by 10.50.0.193 with SMTP id 1mr3578434igg.0.1348751664318; Thu, 27 Sep 2012 06:14:24 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp414829igc; Thu, 27 Sep 2012 06:14:22 -0700 (PDT) Received: by 10.14.193.129 with SMTP id k1mr5855444een.13.1348751661922; Thu, 27 Sep 2012 06:14:21 -0700 (PDT) Received: from eu1sys200aog112.obsmtp.com (eu1sys200aog112.obsmtp.com [207.126.144.133]) by mx.google.com with SMTP id m5si5180354een.63.2012.09.27.06.14.07 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 06:14:21 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.133; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKUGRRGnBAPzTOsXliZWWv30EfEi21+dYm@postini.com; Thu, 27 Sep 2012 13:14:21 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 6CE52A4; Thu, 27 Sep 2012 13:05:40 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id EB092E99; Thu, 27 Sep 2012 13:13:54 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 26E6424C2FB; Thu, 27 Sep 2012 15:13:47 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 27 Sep 2012 15:13:54 +0200 From: Linus Walleij To: , Cc: Stephen Warren , Anmar Oueja , Linus Walleij , Rob Herring , Thomas Gleixner , Grant Likely , Russell King , Lee Jones Subject: [PATCH 2/4] irqdomain: augment add_simple() to allocate descs Date: Thu, 27 Sep 2012 15:13:45 +0200 Message-ID: <1348751625-17420-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQko42c5D7W2RzIll89kIBfiqXjePN1TTpG5epplt2IS2wc1kiar2uSagUBO2HiV0YMdpN/0 From: Linus Walleij Currently we rely on all IRQ chip instances to dynamically allocate their IRQ descriptors unless they use the linear IRQ domain. So for irqdomain_add_legacy() and irqdomain_add_simple() the caller need to make sure that descriptors are allocated. Let's slightly augment the yet unused irqdomain_add_simple() to also allocate descriptors as a means to simplify usage and avoid code duplication throughout the kernel. We warn if descriptors cannot be allocated, e.g. if a platform has the bad habit of hogging descriptors at boot time. Cc: Rob Herring Cc: Thomas Gleixner Cc: Grant Likely Cc: Russell King Cc: Lee Jones Signed-off-by: Linus Walleij --- Rob/Grant/Thomas if you ACK this I will take it through the pinctrl tree since I introduce its only user right there. --- kernel/irq/irqdomain.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 49a7772..a0655b6 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -148,7 +148,8 @@ static unsigned int irq_domain_legacy_revmap(struct irq_domain *domain, * @host_data: Controller private data pointer * * Allocates a legacy irq_domain if irq_base is positive or a linear - * domain otherwise. + * domain otherwise. For the legacy domain, IRQ descriptors will also + * be allocated. * * This is intended to implement the expected behaviour for most * interrupt controllers which is that a linear mapping should @@ -162,11 +163,21 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node, const struct irq_domain_ops *ops, void *host_data) { - if (first_irq > 0) - return irq_domain_add_legacy(of_node, size, first_irq, 0, + if (first_irq > 0) { + int irq_base; + + irq_base = irq_alloc_descs(first_irq, 0, size, numa_node_id()); + if (irq_base < 0) { + WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", + first_irq); + irq_base = first_irq; + } + return irq_domain_add_legacy(of_node, size, irq_base, 0, ops, host_data); - else - return irq_domain_add_linear(of_node, size, ops, host_data); + } + + /* A linear domain is the default */ + return irq_domain_add_linear(of_node, size, ops, host_data); } /**