Received: by 10.223.185.116 with SMTP id b49csp7569444wrg; Thu, 1 Mar 2018 07:34:10 -0800 (PST) X-Google-Smtp-Source: AG47ELv/LqgZje0npzFLb9PWtVLt41UD0G+GkCHFbtCYvKGw8KHFEV4urRa1nIY8g75LoBPEPvBO X-Received: by 10.99.185.84 with SMTP id v20mr1901815pgo.112.1519918450539; Thu, 01 Mar 2018 07:34:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519918450; cv=none; d=google.com; s=arc-20160816; b=jgFuxY5GmevlY8gaNww3uooWMLUstiF2qxE+O26xj684OB8KKAEwl3wGJpgkNsHBgI B9IqkmWmUqw/Q13HkktSLrzv2YlavkkCCfBsABlfJse/14XpIdzexmr6z32veLw3pVoE h8dv5VMM4teItPrEFTnbJMEi5etUbyyOOSxuWwfo5z1SE5b2SdSE0BfURe1ghqhbHp4D 2lwcBitCa1Tq5X2CG+uRi3CThrwhT4jwwP5xy1xOp4fmvKHzwXLA5JYqOgE7Q89HOThN rKYsMqSqK6lBsaMsX6eAvEV0baAC5m/E7pCB8oXa1wYoLVg2YK++R8WaZ7kcd78w0Tel vjFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature :arc-authentication-results; bh=GcdllJf+FJO+D6qYY5JCEovwPXMB3oezCGI9PY8eavk=; b=P/goOFzYnSXOIhORFxnZsmVUOGRcEW42gsi38gpWRuNkDJJsVcAA2j76rN7hqr5+ff oPWNpCZcpz6XNm45TM/UihtF93U3iYkuv7QhsxC8cLTVnzF3VqYBsnUU16y2Gx6Aj5zm U43dsGdKxgwQkS2wuxf9xVXBU3EC1ZsFnCcL40obwefSRaxe0mov//PrpNn5/FGJwEUY JRzXpbY7aGWRpYPsdQP4X9AUvGvGqnIdwr5XC1AgFPFk7U8OWQ9QHDSFHTndM3rOlTIY 2KOLZwAa+gT4ciZgM4Jombh46mYlazOUr17xcmC+yow+fl0MFDXB0LcSL9OHa4YDYfE4 QEtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=iaIPzBj3; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12-v6si3232265plk.508.2018.03.01.07.33.55; Thu, 01 Mar 2018 07:34:10 -0800 (PST) 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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=iaIPzBj3; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032324AbeCAPcY (ORCPT + 99 others); Thu, 1 Mar 2018 10:32:24 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:12539 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032293AbeCAPcJ (ORCPT ); Thu, 1 Mar 2018 10:32:09 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w21FVwjZ021022; Thu, 1 Mar 2018 09:31:58 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519918318; bh=jsQuiLHL1fFn1B8uOJMH0wPTisQkwuhMb/8mHbNBKMc=; h=Subject:From:To:CC:References:Date:In-Reply-To; b=iaIPzBj3V9xRLxb/YOPLavbDcEa+neZ0D6zR7igjlulaqAT/7XC1SDIBTwKZTDe3y xLCP7Gibx5XKSysXgL2S5wSrfGwyZPeCPaRqgK9Iw3CiLK8cSiEJZeDwhq6EGWiGNh dePfkV39+Dv+NuEAk4Y0Irfvy9Q3ff6n9T4q38U4= Received: from DFLE107.ent.ti.com (dfle107.ent.ti.com [10.64.6.28]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w21FVwNA012285; Thu, 1 Mar 2018 09:31:58 -0600 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Thu, 1 Mar 2018 09:31:58 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Thu, 1 Mar 2018 09:31:58 -0600 Received: from [172.22.216.156] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w21FVspp024697; Thu, 1 Mar 2018 09:31:55 -0600 Subject: Re: [PATCH 2/3] PCI: dwc: pci-dra7xx: Improve MSI IRQ handling From: Vignesh R To: Lorenzo Pieralisi CC: Jingoo Han , Joao Pinto , KISHON VIJAY ABRAHAM , Bjorn Helgaas , Niklas Cassel , "linux-omap@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20180209120415.17590-1-vigneshr@ti.com> <20180209120415.17590-3-vigneshr@ti.com> <20180212175801.GA29070@e107981-ln.cambridge.arm.com> <7cfa73af-09fa-d298-aaab-3e74ee7e1dd5@ti.com> Message-ID: Date: Thu, 1 Mar 2018 21:01:53 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <7cfa73af-09fa-d298-aaab-3e74ee7e1dd5@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lorenzo, On 15-Feb-18 9:59 AM, Vignesh R wrote: > Hi, > > On Monday 12 February 2018 11:28 PM, Lorenzo Pieralisi wrote: >> On Fri, Feb 09, 2018 at 05:34:14PM +0530, Vignesh R wrote: >>> We need to ensure that there are no pending MSI IRQ vector set (i.e >>> PCIE_MSI_INTR0_STATUS reads 0 at least once) before exiting >>> dra7xx_pcie_msi_irq_handler(). Else, the dra7xx PCIe wrapper will not >>> register new MSI IRQs even though PCIE_MSI_INTR0_STATUS shows IRQs are >>> pending. Therefore, keep calling dra7xx_pcie_msi_irq_handler() until it >>> returns IRQ_NONE, which suggests that PCIE_MSI_INTR0_STATUS is 0. >>> >>> This fixes a bug, where PCIe wifi cards with 4 DMA queues like Intel >>> 8260 used to throw following error and stall during ping/iperf3 tests. >>> >>> [   97.776310] iwlwifi 0000:01:00.0: Queue 9 stuck for 2500 ms. >>> >>> Signed-off-by: Vignesh R >>> --- >>>   drivers/pci/dwc/pci-dra7xx.c | 21 ++++++++++++++++++--- >>>   1 file changed, 18 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c >>> index ed8558d638e5..3420cbf7b60a 100644 >>> --- a/drivers/pci/dwc/pci-dra7xx.c >>> +++ b/drivers/pci/dwc/pci-dra7xx.c >>> @@ -254,14 +254,31 @@ static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg) >>>         struct dra7xx_pcie *dra7xx = arg; >>>         struct dw_pcie *pci = dra7xx->pci; >>>         struct pcie_port *pp = &pci->pp; >>> +     int count = 0; >>>         unsigned long reg; >>>         u32 virq, bit; >>>   >>>         reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI); >>> +     dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI, reg); >>>   >>>         switch (reg) { >>>         case MSI: >>> -             dw_handle_msi_irq(pp); >>> +             /* >>> +              * Need to make sure no MSI IRQs are pending before >>> +              * exiting handler, else the wrapper will not catch new >>> +              * IRQs. So loop around till dw_handle_msi_irq() returns >>> +              * IRQ_NONE >>> +              */ >>> +             while (dw_handle_msi_irq(pp) != IRQ_NONE && count < 1000) >>> +                     count++; >>> + >>> +             if (count == 1000) { >>> +                     dev_err(pci->dev, "too much work in msi irq\n"); >>> +                     dra7xx_pcie_writel(dra7xx, >>> +                                        PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI, >>> +                                        reg); >>> +                     return IRQ_HANDLED; >> >> I am not merging any code patching this IRQ handling routine anymore >> unless you thoroughly explain to me how this CONF_IRQSTATUS_MSI register >> works (and how it is related to DW registers) and why this specific host >> controller needs handling that is not required by any other host >> controller relying on dw_handle_msi_irq(). > > Unlike other DW PCIe controllers, TI implementation has a wrapper on top > of DW core. This wrapper latches the DW core level MSI and legacy > interrupts and then propagates it to GIC. > PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI register is present in this TI > wrapper which aggregates all the MSI IRQs(PCIE_MSI_INTR0_STATUS) of DW > level. They are mapped on the MSI interrupt line of PCIe controller, > using a single status bit in the PCIECTRL_TI_CONF_IRQSTATUS_MSI register. > > So, the irq handler, dra7xx_pcie_msi_irq_handler(), first needs to look > at PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI[4] to know that its MSI IRQ and > then call dw_handle_msi_irq() to handle individual MSI vectors. > Driver has to make sure there are no pending vectors in DW core MSI > status register before exiting handler. Otherwise next MSI IRQ will not > be latched by the wrapper. > > Did above explanation clarify CONF_IRQSTATUS_MSI register usage and the need for IRQ handler? Are you okay with this fix? Regards Vignesh >> >> I suspect there is a code design flaw with the way this host handles >> IRQs and we are going to find it and fix it the way it should, not with >> any plaster like this patch. >> > > I agree there has been some churn wrt this wrapper level IRQ handler. > But, that was because hardware documentation/TRM did not match > actual behavior and so it took some time to understand how the > hardware is working. I have extensively tested this series on multiple > problematic PCIe USB cards and PCIe WiFi cards over week long stress > tests. And also had some agreement with internal hardware designers. > Hardware documentations will also be updated. > > >> Lorenzo >> >>> +             } >>>                 break; >>>         case INTA: >>>         case INTB: >>> @@ -275,8 +292,6 @@ static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg) >>>                 break; >>>         } >>>   >>> -     dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI, reg); >>> - >>>         return IRQ_HANDLED; >>>   } >>>   >>> -- >>> 2.16.1 >>> >