Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1878277lqa; Tue, 30 Apr 2024 01:43:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUAMz95rQEEZuGMBND7J2A6UzM7F0WwVMwjRwvFXGNQp3GewfiODRYuAJrAO+OIqezeqm0vWm6c+xe7HYN0hKTfTwzyJB/EKuumGOfSlQ== X-Google-Smtp-Source: AGHT+IHkrWSm5C0vFshEzRW2b1ReP77RRPC/U0yul7UL+R0I4SaxSz4OG3Pm2Fo6l6OjK/CWviz/ X-Received: by 2002:a05:6402:a4b:b0:572:6872:8baf with SMTP id bt11-20020a0564020a4b00b0057268728bafmr6330978edb.38.1714466633261; Tue, 30 Apr 2024 01:43:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714466633; cv=pass; d=google.com; s=arc-20160816; b=Z2k1PBmQ2KBUEGOIa4+hSWFS7QHTFoxqVXn34ng5Nf8mjloNxg3yaDj1wYDkKHSoCw yhuOMazzPhoxPA1pIFxPWCO9Ka/8qa3uvaNpOGPTd97bU5TG79fWYfd01BkMJwFzWZcB Dk6AnhTPjadssK7lpVpB6D7TBnEdRt9j8/CD5IkgwirA30/4xjyO5JBzTMdB/p8d4KRB afMlY+y5+8pxNf62zVyeKuebK+ee/ov49QUzqll5Voewgk5anqLnYsrgUwc7HJpBDTeJ Rcs2qjHQ/1zKvC/zaUTMDiBVFD3GoXbbv5AGI79WARIFuJIqs1dTk73w7cq8lHVbJUW0 gskA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EL/+wWthdbbXpsMfHadEqQrahJY+3VcTmg9gLeOEcoI=; fh=wLJMNfcbOxpEep4AozbD3QJkKmGbYz7NO97H9PCORXg=; b=GtxIPs0nBZOiptnW/w2PKYyeqOssTY6qTkWWDRGcM3ncWLOStwT/JMsGsknaUPV/8v e6KP/o1u9AxyU0BjRS1iiV0Dd1oMTUk+vfiqx+HAns6SlGvTOUMen5fRfWudNH0Mf9JH 1Hk8OQUZ0nVQGV6FIrHhtDC6Ka54hRvg390FHZGKKN0mTywX6FB8t/e5KEq2DQ3otMzf 3YRDWKfnR1gfQV8Py0hKo6ABxR6HjMmTSSy3Bewgv3lgbxOhFEnsi2J3U0qwctj0fVjc TVcUBbDyF9YjTLb50WejtaUZK+VYnhRwTW8gHUGjEEw7pV3L07BhUE/3K8uX5OmNJ4Cz UaWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=a1xRvzFe; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-163565-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163565-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r5-20020aa7c145000000b00572a1672fa6si25841edp.82.2024.04.30.01.43.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 01:43:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163565-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=a1xRvzFe; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-163565-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163565-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 039C81F22467 for ; Tue, 30 Apr 2024 08:43:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B75B1C2305; Tue, 30 Apr 2024 08:39:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="a1xRvzFe" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40D751BF6D7; Tue, 30 Apr 2024 08:39:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714466377; cv=none; b=WcDmRhc/MTUm5oUZu+SrIok13oVAe40FqzpHslSEZDiyrnf46MP5sITLVW8jrTbdVfcwPPXekYblqyVCgUxxb3akROSZAXvjE9sg+NLNafz2pfeMery44a8/jhmp7T8KxIilFOWOMERH+N3hIaTJSBrBL5Jp0hq1sdfteacJJr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714466377; c=relaxed/simple; bh=wDWXPuQPX0SK7eCiZC1Dda7dfb6gfYPOkdHIxbXuONY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kQaUJesp0Vlzd+6ysaeCNsBY3zSfmZdQQd0fvbvqHlAAVovzWt/a9x3MlBw9Cjmx/FaJKq5M1OfxQuNFKfNfZUUyy/T27dL3pfWRutcL2I0xZnNUv+ZQ5Vo1L3oGCLEHhSp2OWbqBbaTv/l6OFezysOU6ZZRiNGB1KYIobcvia8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=a1xRvzFe; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id 331C320014; Tue, 30 Apr 2024 08:39:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1714466373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EL/+wWthdbbXpsMfHadEqQrahJY+3VcTmg9gLeOEcoI=; b=a1xRvzFeeKIKQGG0I7FiPVUgVyIrQwZl8MJm/CPkMjOEjYyT9Ie0Umir5GpeC47xIn0y/Z yLGkaqdm3WCC0uX/WrU2T1flH87ngShPmFcd8QL75pDHdbngjKiwUYkt3Sy80J8OzKn7Md 1XHxJ9mqrv4sbtLXSy8KgpRLlFCogcZFyfSo06fmkfGmhLf/yJgAQTne7vUgEV59l+trvl aKhvnI9PDh9/XBwZ4e4fQ1lBevOlWcl9KProlh5ZBfDDioNS5bDakrHdtkB2rN+gJMw+KQ +8jybgwR+4yDjCxRTs6Jlsz87DdhrYHfDqHE7i0VuW9w9zkJtlHQn8KwYVuc+A== From: Herve Codina To: Herve Codina , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones , Arnd Bergmann , Horatiu Vultur , UNGLinuxDriver@microchip.com, Andrew Lunn , Heiner Kallweit , Russell King , Saravana Kannan , Bjorn Helgaas , Philipp Zabel , Lars Povlsen , Steen Hegelund , Daniel Machon , Alexandre Belloni Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Allan Nielsen , Steen Hegelund , Luca Ceresoli , Thomas Petazzoni Subject: [PATCH 15/17] pci: of_property: Add the interrupt-controller property in PCI device nodes Date: Tue, 30 Apr 2024 10:37:24 +0200 Message-ID: <20240430083730.134918-16-herve.codina@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430083730.134918-1-herve.codina@bootlin.com> References: <20240430083730.134918-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com PCI devices and bridges DT nodes created during the PCI scan are created with the interrupt-map property set to handle interrupts. In order to set this interrupt-map property at a specific level, a phandle to the parent interrupt controller is needed. On systems that are not fully described by a device-tree, the parent interrupt controller may be unavailable (i.e. not described by the device-tree). As mentioned in the [1], avoiding the use of the interrupt-map property and considering a PCI device as an interrupt controller itself avoid the use of a parent interrupt phandle. In that case, the PCI device itself as an interrupt controller is responsible for routing the interrupts described in the device-tree world (DT overlay) to the PCI interrupts. Add the 'interrupt-controller' property in the PCI device DT node. [1]: https://lore.kernel.org/lkml/CAL_Jsq+je7+9ATR=B6jXHjEJHjn24vQFs4Tvi9=vhDeK9n42Aw@mail.gmail.com/ Signed-off-by: Herve Codina --- drivers/pci/of_property.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c index c2c7334152bc..9f8b940029ed 100644 --- a/drivers/pci/of_property.c +++ b/drivers/pci/of_property.c @@ -183,6 +183,26 @@ static int of_pci_prop_interrupts(struct pci_dev *pdev, return of_changeset_add_prop_u32(ocs, np, "interrupts", (u32)pin); } +static int of_pci_prop_intr_ctrl(struct pci_dev *pdev, struct of_changeset *ocs, + struct device_node *np) +{ + int ret; + u8 pin; + + ret = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin); + if (ret != 0) + return ret; + + if (!pin) + return 0; + + ret = of_changeset_add_prop_u32(ocs, np, "#interrupt-cells", 1); + if (ret) + return ret; + + return of_changeset_add_prop_bool(ocs, np, "interrupt-controller"); +} + static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs, struct device_node *np) { @@ -334,6 +354,10 @@ int of_pci_add_properties(struct pci_dev *pdev, struct of_changeset *ocs, ret = of_pci_prop_intr_map(pdev, ocs, np); if (ret) return ret; + } else { + ret = of_pci_prop_intr_ctrl(pdev, ocs, np); + if (ret) + return ret; } ret = of_pci_prop_ranges(pdev, ocs, np); -- 2.44.0