Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp614120imm; Fri, 28 Sep 2018 04:07:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV61JqADGQmAZAT047KeFBn3yGTVgl0lpNcxdBh/tD2XB7qFSNbpKSUM8ZjyYId6dTmFJsndp X-Received: by 2002:a63:2106:: with SMTP id h6-v6mr14529511pgh.161.1538132830257; Fri, 28 Sep 2018 04:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538132830; cv=none; d=google.com; s=arc-20160816; b=NRPRdx0UaQwA+AH1kaYdSaAwv7YPaoNMipQ6qY42mY3K0R7qztrLqmk9UVFOZRaHV+ 8aXE/9ncjVC7IebAwrVKUm288Dw2BrN5ucg+tionW12ofJdHT1joC5HmRHXZi2rTHeqX rUEhtrl0VGuHXSfmiqtPqpo6azDx0T3PTrb24Dlo2sUKCJB6GotmBEu82kwkdfZ19/E8 qI9qZT6Eg3f5TTteiWKBcezswDhrUVuhAaCfEFtQzoow871fbacnjRef9wETiY3QL4Ff W0gBVC45Mo5gGF0c87kW52XJwT3rE3NTu7Jm3+GcLXhf37oXc/rzcYIzTRQxYMYWHtYx X8bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=22WhJulrIvKjRAW4WKpad3/tv6fUokkfn/7iNT9wknk=; b=eBan+U8z728/2uF8IbfO/cxkWcu3Gm+ldIax1/kqYFEbG+DrWjsOy7jkU4R3XpaKSs H7GEq0l2CyRFbhwi4fIOz8MgwS/u6xu0UqmPjaq9WbK5JWuB5FLOP4WS0akL1IwtFV5G Wj53IoBvzfvS54QZkCJ/kYhlHyZMcWeuZZPjfNc9iWksfF50Aovb2x7xr7/oP7go74fC gKcwl8rikEYUGzlzmMcPKoVkHaWjw4J7Rf0S9JALBkEmyXcYJDuaHQXRRpscGFQb8bcg JxITyjDbkzfPJOxWqJVaIJUhucSIT03vjd6O//Ni/u09N4Bfeu9Xmt949V2uvegJvkxB 7zig== ARC-Authentication-Results: i=1; mx.google.com; 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 k28-v6si4509993pgf.308.2018.09.28.04.06.53; Fri, 28 Sep 2018 04:07:10 -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; 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 S1729373AbeI1RaD (ORCPT + 99 others); Fri, 28 Sep 2018 13:30:03 -0400 Received: from foss.arm.com ([217.140.101.70]:47194 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729240AbeI1RaD (ORCPT ); Fri, 28 Sep 2018 13:30:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 00E367A9; Fri, 28 Sep 2018 04:06:48 -0700 (PDT) Received: from e107981-ln.cambridge.arm.com (e107981-ln.Emea.Arm.com [10.4.13.117]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7BD803F5BD; Fri, 28 Sep 2018 04:06:45 -0700 (PDT) Date: Fri, 28 Sep 2018 12:06:40 +0100 From: Lorenzo Pieralisi To: Kunihiko Hayashi Cc: Gustavo Pimentel , Bjorn Helgaas , Rob Herring , Mark Rutland , Masahiro Yamada , "linux-pci@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Masami Hiramatsu , Jassi Brar , Murali Karicheri , marc.zyngier@arm.com Subject: Re: [PATCH v2 2/2] PCI: controller: dwc: add UniPhier PCIe host controller support Message-ID: <20180928110640.GA18840@e107981-ln.cambridge.arm.com> References: <20180926213135.A4B4.4A936039@socionext.com> <20180927164426.ECD6.4A936039@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180927164426.ECD6.4A936039@socionext.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [+Murali, Marc] On Thu, Sep 27, 2018 at 04:44:26PM +0900, Kunihiko Hayashi wrote: > Hi Lorenzo, Gustavo, > > On Wed, 26 Sep 2018 21:31:36 +0900 wrote: > > > Hi Lorenzo, Gustavo, > > > > Thank you for reviewing. > > > > On Tue, 25 Sep 2018 18:53:01 +0100 > > Gustavo Pimentel wrote: > > > > > On 25/09/2018 17:14, Lorenzo Pieralisi wrote: > > > > [+Gustavo, please have a look at INTX/MSI management] > > > > > > > > On Thu, Sep 06, 2018 at 06:40:32PM +0900, Kunihiko Hayashi wrote: > > > >> This introduces specific glue layer for UniPhier platform to support > > > >> PCIe host controller that is based on the DesignWare PCIe core, and > > > >> this driver supports Root Complex (host) mode. > > > > > > > > Please read this thread and apply it to next versions: > > > > > > > > https://urldefense.proofpoint.com/v2/url?u=https-3A__marc.info_-3Fl-3Dlinux-2Dpci-26m-3D150905742808166-26w-3D2&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=H8UNDDUGQnQnqfWr4CBios689dJcjxu4qeTTRGulLmU&s=CgcXc_2LThyOpW-4bCriJNo9H1lzROEdy_cG9p-Y5hU&e= > > > > I also found this thread in previous linux-pci, and I think it's helpful for me. > > I'll check it carefully. > > [snip] > > > > >> + ret = devm_request_irq(dev, pp->irq, uniphier_pcie_irq_handler, > > > >> + IRQF_SHARED, "pcie", priv); > > > > > > > > This is wrong, you should set-up a chained IRQ for INTX. > > > > > > > > I *think* that > > > > > > > > ks_pcie_setup_interrupts() > > > > > > > > is a good example to start with but I wonder whether it is worth > > > > generalizing the INTX approach to designware as a whole as it was > > > > done for MSIs. > > > > > > > > Thoughts ? > > > > > > From what I understood this is for legacy IRQ, right? > > > > Yes. For legacy IRQ. > > > > > Like you (Lorenzo) said there is 2 drivers (pci-keystone-dw.c and pci-dra7xx.c) > > > that uses it and can be use as a template for handling this type of interrupts. > > > > > > We can try to pass some kind of generic INTX function to the DesignWare host > > > library to handling this, but this will require some help from keystone and > > > dra7xx maintainers, since my setup doesn't have legacy IRQ HW support. > > > > Now I think it's difficult to make a template for INTX function, > > and at first, I'll try to re-write this part with reference to pci-keystone-dw.c. > > I understand that there are 2 types of interrupt and the drivers. > > One like pci-keystone-dw.c is: > > - there are 4 interrupts for legacy, > - invoke handlers for each interrupt, and handle the interrupt, > - call irq_set_chained_handler_and_data() to make a chain of the interrupts > when initializing > > The other like pci-dra7xx.c is: > > - there is 1 IRQ for legacy as a parent, > - check an interrupt factor register, and handle the interrupt correspond > to the factor, > - call request_irq() for the parent IRQ and irq_domain_add_linear() for > the factor when initializing > > The pcie-uniphier.c is the same type as the latter (like pci-dra7xx.c). > > However, in pci-dra7xx.c, MSI and legacy IRQ share the same interrupt number, > so the same handler is called and the handler divides these IRQs. > (found in dra7xx_pcie_msi_irq_handler()) > > In pcie-uniphier.c, MSI and legacy IRQ are independent. > Therefore it's necessary to prepare the handler for the legacy IRQ. > > I think that it's difficult to apply the way of pci-keystone-dw.c, and > uniphier_pcie_irq_handler() and calling devm_request_irq() are still > necessary to handle legacy IRQ. I do not think it is difficult, the difference is that keystone has 1 GIC irq line allocated per legacy IRQ, your set-up has one for all INTX. *However*, I would like some clarifications from Murali on this code in drivers/pci/controller/dwc/pci-keystone.c: static void ks_pcie_legacy_irq_handler(struct irq_desc *desc) { unsigned int irq = irq_desc_get_irq(desc); struct keystone_pcie *ks_pcie = irq_desc_get_handler_data(desc); struct dw_pcie *pci = ks_pcie->pci; struct device *dev = pci->dev; u32 irq_offset = irq - ks_pcie->legacy_host_irqs[0]; Here the IRQ numbers are virtual IRQs, is it correct to consider the virq numbers as sequential values ? The "offset" is used to handle the PCI controller interrupt registers, so it must be a value between 0-3 IIUC. I would appreciated a detailed explanation of keystone legacy IRQ handling so that we can eventually try to replicate it and generalize it. Lorenzo [...] chained_irq_enter(chip, desc); ks_dw_pcie_handle_legacy_irq(ks_pcie, irq_offset); chained_irq_exit(chip, desc); }