From patchwork Thu Sep 7 11:42:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 111891 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp682453qge; Thu, 7 Sep 2017 04:45:47 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4YePE04SfVkeL0T+o20rSlx80iJ8XQW3aQK1txVS03LSQCP/zi1HkJ0kHeFsp83fFG5XwF X-Received: by 10.98.144.210 with SMTP id q79mr2351452pfk.331.1504784747551; Thu, 07 Sep 2017 04:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504784747; cv=none; d=google.com; s=arc-20160816; b=yCXfxqh5Eun0KhWePWrfXBVUaoTj7DhC5WXWHNVhGD/k1TxFcjj2ZPnl+MVHdrRQCK tg8MRPlXehz2WvrhkapY/oxqrlSezm0rmzqrhB7TXZkrdEqGLjRX6qP7q3KHB7DP0ktD ImGwgzl6MTs/jtSg5WDpyRvTz3qliTU2CljVoew2puguZWNIaAiHsHgWt2NbtaUEL/b9 WMSLyWGqRykAe5MxnAc5JNRBcNdYbwfUa4KH00WpNWByeADnhKNRPU7/j2rx1JMYZrxc K3If81LXUNhw832nZGTf1+yNlWZ8OEN9844UdFQrh4Hva+myuiBmBYW6TyzTitt+OcQc AlLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=X/I1RnU3Gpzzhqg3pT6YB/0pqxY8xpqZMXsz/E2FYa4=; b=GUL4ng/2s+yNK2Xf0W8n1ocrxU9bgRdXcgk66sOUZiBgxrElhbk8EQxgOjIdFYS+mb dX5USnqCPTh2yOeqOfYL81OdRYe4+yHwRauovZW9n7+IT83zRXjg2fkNIl/usgj+7mZX uFmR3FJStULGPXCTiicv6x2hQ3sD4e5WtCQDcuxzLTOnzCoC6ixgdZ2MTnNMvDnXIvQI hpfakawDEC261vdblYUpQdcmV1LUeeH2Q5vBX7TRdyMCXT3o4IvX4hqeNntQ3/2HAgAV og8+lcjv2TDb06RcAno9B4hku4H3MbqfNSYBWOL4BE+Fkc8E1iTl5ybGOvk9MFpqtJ0V wIsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=v+mfaEEj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v26si1746596pgc.383.2017.09.07.04.45.47; Thu, 07 Sep 2017 04:45:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=v+mfaEEj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755394AbdIGLpa (ORCPT + 26 others); Thu, 7 Sep 2017 07:45:30 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:17251 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755223AbdIGLn7 (ORCPT ); Thu, 7 Sep 2017 07:43:59 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id v87BgcP3021413; Thu, 7 Sep 2017 20:42:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v87BgcP3021413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1504784566; bh=X/I1RnU3Gpzzhqg3pT6YB/0pqxY8xpqZMXsz/E2FYa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v+mfaEEjEDASsoAlytN+uZbu7QfE3gxL7g6ZMN8YCQN5qbiQ/l9HTLL51oQAdXLMT b/aPPOxpSFMGrFUAXVc4I6lLT+sKvrzLrtKDVoe2qZ6B4QBa9Y/xodLq7yQ1CWgW9v HuQciynbixVNGknv8KEKl4IWEFYX6LbzffiZNco/GZqurQBjk/CD7H6/ft/YoH8Oy8 Ndg9RLjzPXmjNAUb8yOX/8QQnrxiGY5hX5mtey3vFQfR8y7Qmkm5AaslQZ+TU1tjCW /dOJVS0TjS3Z84hJIwu327cqF2vNHZhVP3GSoCaQNBpSL+aCM+jpuO3KOCTa9TLZZi R8pM5/2iTLWDQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Marc Zyngier , Thomas Gleixner , Linus Walleij , linux-gpio@vger.kernel.org, Rob Herring Cc: Jassi Brar , devicetree@vger.kernel.org, Jason Cooper , Masami Hiramatsu , David Daney , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v4 5/6] irqdomain: add IRQ_DOMAIN_FLAG_NO_CREATE flag Date: Thu, 7 Sep 2017 20:42:01 +0900 Message-Id: <1504784522-26841-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504784522-26841-1-git-send-email-yamada.masahiro@socionext.com> References: <1504784522-26841-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an irqchip driver uses irq_domain_push_irq(), all irqs should be statically created by the irqchip. If a device tries to allocate an irq on-the-fly, irq_domain_alloc_irqs() is called. It allocates struct irq_data and invokes .alloc() hook passing fwspec as its argument. This is probably not what the irqchip expects (unless .alloc can call it recursively). This issue could happen when a device tries to get irq after irq_domain_create_hierarchy(), but before irq_domain_push_irq(). To avoid the race, add IRQ_DOMAIN_FLAG_NO_CREATE flag. This flag prevents devices from creating irqs. Devices are only allowed to get already existing irqs. Signed-off-by: Masahiro Yamada --- Changes in v4: - Newly added include/linux/irqdomain.h | 3 +++ kernel/irq/irqdomain.c | 3 +++ 2 files changed, 6 insertions(+) -- 2.7.4 diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 7609807..525de32 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -195,6 +195,9 @@ enum { /* Irq domain name was allocated in __irq_domain_add() */ IRQ_DOMAIN_NAME_ALLOCATED = (1 << 6), + /* Do not allow irq consumers to create irq */ + IRQ_DOMAIN_FLAG_NO_CREATE = (1 << 7), + /* * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved * for implementation specific purposes and ignored by the diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index b317a64..ecf107ab 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -806,6 +806,9 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) return 0; } + if (domain->flags & IRQ_DOMAIN_FLAG_NO_CREATE) + return -EPROBE_DEFER; + if (irq_domain_is_hierarchy(domain)) { virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec); if (virq <= 0)