Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp790104pxb; Wed, 29 Sep 2021 09:41:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAjCVckKKYcXk3svW1yEki570TWqUzK2YJNKz+pekvDVz4IBBsMskFx6j/jXlxme2ILZgl X-Received: by 2002:a17:906:144e:: with SMTP id q14mr754861ejc.19.1632933695256; Wed, 29 Sep 2021 09:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632933695; cv=none; d=google.com; s=arc-20160816; b=U7KP6PK39aqNB9wUcWvhw0cX1jPqPzO0vZIC3m/Ira4q/3tQDnaeJaRtonkWXWyB0i R8BEwdfgjdsCJNjJtSPwQ5i8F6M+EZwKQK5maJ8voY0lb/JnCT3vrL8Xdxe+mC6B2S/s XmdgcTuFyTbd24oD/fUROODpmVZaGdHZd1SJtZjTzsLQt9Ms0PHvVShhpojW6a5SWojq 8PFXgy8fuljROwmf+JLA7gKlYaYVTw68zZX9E0vXSSWqf6b9DJMJTqfMcRIZ2RzehUcu A+f4GKRLVQZvnxjbEZhond7vT0FtYw2j5FQH4/xRZbCQCekbu06RDc+dnCZuTrkcKGHz QGMQ== 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=uMpL4gbi9HfxJBTdO54gKI3e7KWxyDpvI9nJ/7ghTV8=; b=UxpfZZ6iLhN6+WsuJ4pz7+NAUsdj8kU7e/Lh9OpUxBonVd58oVg2FAArhi/CIIo9+e NJCXXI5xTDq/iZ9TGy/EEuWPnJPkYKZKzbiy272pMq6xOpvkZF6OemEIi1ta+J4Myotm CGqcQxFB+Se0MbijL267CNtKFgEq2Bnp1Qp4NXBFP16uh60NkqT51dp46cuMa9cOOqXm mOlWEpZX3dbiHFNSvbYM5Ku/EPJsKwLGCmlPDzhV3cPeqv3q13q7GrQ+OkK/+duKlqlm bfE5rst4KROfx9+EFaSCKXXekZc7VuvtqdQ9KppXHvoyQQsQ/KAQooe0Ky8MWfntseIM EsBw== 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 w3si352249ejv.301.2021.09.29.09.41.04; Wed, 29 Sep 2021 09:41:35 -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 S1345899AbhI2Qko (ORCPT + 99 others); Wed, 29 Sep 2021 12:40:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:40628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345941AbhI2Qkh (ORCPT ); Wed, 29 Sep 2021 12:40:37 -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 1976E61425; Wed, 29 Sep 2021 16:38:56 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.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 1mVcbe-00DmcL-FM; Wed, 29 Sep 2021 17:38:54 +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 , Joey Gouly , Joerg Roedel , kernel-team@android.com, Rob Herring Subject: [PATCH v5 02/14] of/irq: Allow matching of an interrupt-map local to an interrupt controller Date: Wed, 29 Sep 2021 17:38:35 +0100 Message-Id: <20210929163847.2807812-3-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210929163847.2807812-1-maz@kernel.org> References: <20210929163847.2807812-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 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, joey.gouly@arm.com, joro@8bytes.org, kernel-team@android.com, robh@kernel.org 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 is 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). Reviewed-by: Rob Herring Tested-by: Alyssa Rosenzweig 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