Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp232350pxb; Mon, 13 Sep 2021 17:52:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoBNFwDqXrZPFWrwzp1AqQVfVyoG1/lTLwmsjcKhjSXpvlu3VscTtrrYacf6+nBlxSt9P+ X-Received: by 2002:a17:906:d1d1:: with SMTP id bs17mr15431262ejb.198.1631580728054; Mon, 13 Sep 2021 17:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631580728; cv=none; d=google.com; s=arc-20160816; b=KYAVaiPVualGVa+j6Ceki8g51nsfXLIR2LktYtT+YDBZdqJU35xb3fKkJbaonHBDeU 0JMNhig2sqQ9eh34DzCe1PYO4j9KA8bQidWIvl9SPKLbXYnDvnyGbd2/T9d9v1osoa01 4wOO+5FfM30KoW3q+zHVPYPgNodWiFaipgH6GQgh/BHH4wck1kKgBC8D31BM3QenksD4 p8b3Ba92/c0NUsFcoZZz1oL3ZhaDUgFYkA972c/ndvKcQU1yXYhQ3ZSIZOAKd4jICUE2 A2+iu4gX7/L1cc99eWjjayR6H5JZZYOkHYjisu/I3EPj3VGcu1XymOdEFY+2aqaqyPqe gN6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4mvLGDRmFRF7BAi+b9wvSx/MrrN0TC630J0nKmRrC3I=; b=FVwWGMp9tUNmcve0B/ia9Rh2CQ4yawWLgztZpmNMEOMDngXsiWn6YoBZT/hyYbXZFD nYOEoQKGYle/nC4S+Rs5D/3OGE98grcmrU4KuH3L311uyI8crQ7hmkePlJ9em6/ZJelo CSFsxFZgHogK9hP/+5zYlVuhqVhOU1qO3e86ub+vMugPfhxuKeS8MbGOUZ1ptZrUb+FW Y7HrdwxpbTeOuU5bHUeO36QyklK1xJPx23+iY32Z6FvxLMaz/kiOuirZ3xYQ8xraCgkF PKkH4DDwzN/xUhSEW7Tt9j0H+827fLO134KJbbEegmA5JWNQg63hQw09kq47yRcc3sjt fELQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si12354102ejy.328.2021.09.13.17.51.45; Mon, 13 Sep 2021 17:52:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245230AbhIMS12 (ORCPT + 99 others); Mon, 13 Sep 2021 14:27:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:59664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236394AbhIMS1U (ORCPT ); Mon, 13 Sep 2021 14:27:20 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D53DB60F46; Mon, 13 Sep 2021 18:26:04 +0000 (UTC) Received: from [198.52.44.129] (helo=wait-a-minute.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mPqeZ-00AYPD-0P; Mon, 13 Sep 2021 19:26:03 +0100 From: Marc Zyngier To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Alyssa Rosenzweig , Stan Skowronek , Mark Kettenis , Sven Peter , Hector Martin , Robin Murphy , kernel-team@android.com Subject: [PATCH v3 02/10] of/irq: Allow matching of an interrupt-map local to an interrupt controller Date: Mon, 13 Sep 2021 19:25:42 +0100 Message-Id: <20210913182550.264165-3-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210913182550.264165-1-maz@kernel.org> References: <20210913182550.264165-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 198.52.44.129 X-SA-Exim-Rcpt-To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com, robh+dt@kernel.org, lorenzo.pieralisi@arm.com, kw@linux.com, alyssa@rosenzweig.io, stan@corellium.com, kettenis@openbsd.org, sven@svenpeter.dev, marcan@marcan.st, Robin.Murphy@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org of_irq_parse_raw() has a baked assumption that if a node has an interrupt-controller property, it cannot possibly also have an interrupt-map property (the latter being ignored). This seems to be an odd behaviour, and there are no reason why we should avoid supporting this use case. This is specially useful when a PCI root port acts as an interrupt controller for PCI endpoints, such as this: pcie0: pcie@690000000 { [...] port00: pci@0,0 { device_type = "pci"; [...] #address-cells = <3>; interrupt-controller; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 7>; interrupt-map = <0 0 0 1 &port00 0 0 0 0>, <0 0 0 2 &port00 0 0 0 1>, <0 0 0 3 &port00 0 0 0 2>, <0 0 0 4 &port00 0 0 0 3>; }; }; Handle it by detecting that we have an interrupt-map early in the parsing, and special case the situation where the phandle in the interrupt map refers to the current node (which is the interesting case here). Signed-off-by: Marc Zyngier --- drivers/of/irq.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 352e14b007e7..32be5a03951f 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -156,10 +156,14 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) /* Now start the actual "proper" walk of the interrupt tree */ while (ipar != NULL) { - /* Now check if cursor is an interrupt-controller and if it is - * then we are done + /* + * Now check if cursor is an interrupt-controller and + * if it is then we are done, unless there is an + * interrupt-map which takes precedence. */ - if (of_property_read_bool(ipar, "interrupt-controller")) { + imap = of_get_property(ipar, "interrupt-map", &imaplen); + if (imap == NULL && + of_property_read_bool(ipar, "interrupt-controller")) { pr_debug(" -> got it !\n"); return 0; } @@ -173,8 +177,6 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) goto fail; } - /* Now look for an interrupt-map */ - imap = of_get_property(ipar, "interrupt-map", &imaplen); /* No interrupt map, check for an interrupt parent */ if (imap == NULL) { pr_debug(" -> no map, getting parent\n"); @@ -255,6 +257,11 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) out_irq->args_count = intsize = newintsize; addrsize = newaddrsize; + if (ipar == newpar) { + pr_debug("%pOF interrupt-map entry to self\n", ipar); + return 0; + } + skiplevel: /* Iterate again with new parent */ out_irq->np = newpar; -- 2.30.2