Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3898158pxb; Mon, 30 Aug 2021 13:23:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDLsyR5x9niYZkLjiiTuKnELknbT5RRw3c6TmL8X+XGp5od4wIkjR3cl2/CCJW3tMBv0Ln X-Received: by 2002:aa7:c64d:: with SMTP id z13mr25961551edr.349.1630355029912; Mon, 30 Aug 2021 13:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630355029; cv=none; d=google.com; s=arc-20160816; b=eme3KQWYcB8hHAnm201E6OphABAzv3UgK72QAYYt7Sz2YucDHlx5d2OxtFY3x35vGP SlF7aislOg9i8aPvaH4gN7RSlSAqxWlAJcPGINorcPSrnsuIBEGdnOqA/yj9oFeSfdy/ ITJXr7mSrcUtRXRmTT9v021ccZWEcmqokKYgi3g7VXlPnp+OxnNlLI0Z1kYzVkNqHNBd k6Mf02FtCO2wd9c6RXpSVm96IO/v/aVKBjZ4qC2RR9ov4tCZ22AtmbOY+RTv4Aajm0LJ AE5M81ThRXaT/QRuyHhNx8zH5ib+2C39Djuv6uKEQ6CLx2M+iCAxPR78by3QmBl34JO2 8NGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=WeBoyWu9VLvyQ2aBGlN7Ol3loFSf1/ZT4tJXyfJBW5U=; b=1EmONKB7o94/8/XWbqkAZSkEqyHR0hXqmlrOzPl884A8C1AVYlLr9DjCRWG7yubAUz c84RgifpaA0eKIie+zbtrlMI5EEGwHyfkFuRFTi3tuEcry6zGz9y+qsfVH2lX7vpii7N gWeJmpwJu1UI6YfepWFOPSBlrbbI5aWpSriS5vz0sWkubVCZ7ccyjlhmvjWPvQRHzJFo N2EBk6v/BO8LaIPoIIABm8KhHxvf4tGBj6uVMQPwvk/CzCvGU7jrxexns+aPWZtEEO78 EpB9EWfzjXCWMcJJLnJjt0IU19aEXGGeR02CyXWyhGNJWzvjoxdzkTvOQER9e1SuQV+X j9Rw== 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 g20si2788680eds.442.2021.08.30.13.23.23; Mon, 30 Aug 2021 13:23:49 -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 S235801AbhH3UVP (ORCPT + 99 others); Mon, 30 Aug 2021 16:21:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:52516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232906AbhH3UVO (ORCPT ); Mon, 30 Aug 2021 16:21:14 -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 B895760F5C; Mon, 30 Aug 2021 20:20:20 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) 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 1mKnlS-00852D-9H; Mon, 30 Aug 2021 21:20:18 +0100 Date: Mon, 30 Aug 2021 21:20:17 +0100 Message-ID: <87o89ed6ri.wl-maz@kernel.org> From: Marc Zyngier To: Rob Herring Cc: Mark Kettenis , devicetree@vger.kernel.org, Alyssa Rosenzweig , Mark Kettenis , Thomas Gleixner , Hector Martin , Bjorn Helgaas , Nicolas Saenz Julienne , Jim Quinlan , Florian Fainelli , "maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE" , Daire McNamara , Saenz Julienne , "linux-kernel@vger.kernel.org" , linux-arm-kernel , PCI , "moderated list:BROADCOM BCM2835 ARM ARCHITECTURE" Subject: Re: [PATCH v4 4/4] arm64: apple: Add PCIe node In-Reply-To: References: <20210827171534.62380-1-mark.kettenis@xs4all.nl> <20210827171534.62380-5-mark.kettenis@xs4all.nl> <87pmtvcgec.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: robh+dt@kernel.org, mark.kettenis@xs4all.nl, devicetree@vger.kernel.org, alyssa@rosenzweig.io, kettenis@openbsd.org, tglx@linutronix.de, marcan@marcan.st, bhelgaas@google.com, nsaenz@kernel.org, jim2101024@gmail.com, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, daire.mcnamara@microchip.com, nsaenzjulienne@suse.de, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-rpi-kernel@lists.infradead.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 On Mon, 30 Aug 2021 16:57:59 +0100, Rob Herring wrote: > > On Mon, Aug 30, 2021 at 6:37 AM Marc Zyngier wrote: > > > > I have now implemented the MSI change on the Linux driver side, and it > > works nicely. So thumbs up from me on this front. > > > > I am now looking at the interrupts provided by each port: > > (1) a bunch of port-private interrupts (link up/down...) > > (2) INTx interrupts > > So each port has an independent INTx space? Yes. > Is that even something PCI defines or comprehends? Can't see why not. That's no different from having several PCI busses. I don't think anything enforces that INTx interrupts have to be unique across the system. As long as they are unique across a PCI hierarchy, we should be OK. > > > Given that the programming is per-port, I've implemented this as a > > per-port interrupt controller. > > > > (1) is dead easy to implement, and doesn't require any DT description. > > (2) is unfortunately exposing the limits of my DT knowledge, and I'm > > not clear how to model it. I came up with the following: > > > > port00: pci@0,0 { > > device_type = "pci"; > > reg = <0x0 0x0 0x0 0x0 0x0>; > > reset-gpios = <&pinctrl_ap 152 0>; > > max-link-speed = <2>; > > > > #address-cells = <3>; > > #size-cells = <2>; > > ranges; > > > > interrupt-controller; > > #interrupt-cells = <1>; > > interrupt-parent = <&port00>; > > interrupt-map-mask = <0 0 0 7>; > > interrupt-map = <0 0 0 1 &port00 0>, > > <0 0 0 2 &port00 1>, > > <0 0 0 3 &port00 2>, > > <0 0 0 4 &port00 3>; > > IIRC, I don't think the DT IRQ code handles a node having both > 'interrupt-controller' and 'interrupt-map' properties. Indeed, and that actually explains why the damned INTx interrupts insist on being 1-based instead of 0-based as the above mapping attempts to describe it. Turns out I can rip the interrupt-map out and it isn't worse. > I think that's why some PCI host bridge nodes have child > interrupt-controller nodes. I don't really like that work-around, > so if the above can be made to work, I'd be happy to see it. But the > DT IRQ code is some ancient code for ancient platforms (PowerMacs > being one of them). That'd probably need some massaging. I'll have a look. I checked that if I add something like: interrupts-extended = <&port02 2>; to each port, I get the PME interrupt correctly assigned should I pass pcie_pme=nomsi. Given that this IP is pretty limited in terms of MSIs, every bit that can free a MSI is welcome. I guess that it would make sense to expand this support to also match for an interrupt-map. > > > }; > > > > which vaguely seem to do the right thing for the devices behind root > > ports, but doesn't seem to work for INTx generated by the root ports > > themselves. Any clue? Alternatively, I could move it to something > > global to the whole PCIe controller, but that doesn't seem completely > > right. I've investigated this one further, and it looks like the DT IRQ code insists on trying to find the interrupt in the main pcie node instead of in the root port itself. But of course it doesn't want to parse an interrupt-map at that level either. I guess that's related to the above. > > > > It also begs the question whether the per-port interrupt to the AIC > > should be moved into each root port, should my per-port approach hold > > any water. > > I tend to think per-port is the right thing to do. However, the child > nodes are PCI devices, so that creates some restrictions. Such as the > per port registers are in the host address space, not the PCI address > space, so we can't move the registers into the child nodes. The > interrupts may be okay. Certainly, being an 'interrupt-controller' > without having an 'interrupts' property for an non root interrupt > controller is odd. That was my own impression as well. I guess there is no real canonical way to handle this particular system and to fully support it, we'll have to amend the current infrastructure. The question is: what is the least ugly way to express this that will work reasonably across implementations (OpenBSD, Linux, u-boot)? M. -- Without deviation from the norm, progress is not possible.