Received: by 10.223.185.116 with SMTP id b49csp1563961wrg; Wed, 14 Feb 2018 20:31:41 -0800 (PST) X-Google-Smtp-Source: AH8x227FIR7CRKjQbHaJYKRKAEd83UllHkmDRGjrfvUdVwl+JeAOgwRnSPL8Sv9M6i3nhpQVk33D X-Received: by 10.98.35.66 with SMTP id j63mr1378643pfj.140.1518669101752; Wed, 14 Feb 2018 20:31:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518669101; cv=none; d=google.com; s=arc-20160816; b=FyrLs+NCaSADQMKgx6b0p1ptUGHSSOygENHHe2ESykZWCfGTtYb/A5j4zt5Akqj1XD PoWjNpowNPdQHpHLheko8k8I/+s7fqOxT8fSpXPsUxAto4G7LAL87SVhwLLGpjaKk+LT qJgTorNbWpFHpjVYOfj26cxyluqACFgp4E+9FlU71WWOc6ae7GPi26pcwC7S7i3g2GOF DwLmmhMVVTfKmZpoQk70+7lEguAHsAUVBOwjmjs0keaob6SN3jdz9XQ76K7jyDSUfZY3 7RfhwC9NoSTU112Dt0Gd/IdHIrhDRa8A9opw/UtB0ozelitOMfVW2G2Tje/sZ5WZcLzp beEw== 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:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=b7JjL73Nt+j5bXZrq+xxHx1BRtYGbTW/ldf63bxuuqo=; b=ZSUgt7fx3xKVLsYDVM2gg8WnJJbfgULl6izwvztzpt/G5k9xn+osU3i4kk588hXW5J y9di8Cjp37OmeSlc1DcCVwBHFrOgm8tuKC3i1IeVUSwwW2JsQ1mceJ8cvLfskCmRnF2h W0yvPQMTAKuKyW5wKAEm30nR4RyW9+mwHkcV7OEG8Z2fVTBnnyFFkFlt6RgkeHjcUOqw 67zrPqfaO6DFn8m6r8otKEia62yl1ELA8HmCEeLRwuUuimZ53oKNfrNqNC22R53VaPS9 K0uOG1c8krFr6bwWZZZYo7db/DsptUY6LgKjtE/yvKjK14DCgW6naGrZthGxrXf5C391 RSOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wOQ9ew88; 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 x6-v6si901694plo.104.2018.02.14.20.31.27; Wed, 14 Feb 2018 20:31:41 -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=wOQ9ew88; 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 S966769AbeBOE26 (ORCPT + 99 others); Wed, 14 Feb 2018 23:28:58 -0500 Received: from lelnx194.ext.ti.com ([198.47.27.80]:57148 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754214AbeBOE24 (ORCPT ); Wed, 14 Feb 2018 23:28:56 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1F4SkQk004424; Wed, 14 Feb 2018 22:28:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1518668926; bh=dQ3e6xfAvrk1QAPlRrZI/p4K9bVXsnV2fQ33wwv8EVI=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=wOQ9ew888TxWy44h6xPvse+TfnIBfATzmV13AbAGeFW3cpQDmNOqcUcitC2I2bVxx w8DgFl3daixmDAkPIJbzv4i9jqA67XIdzIMDz1leS+ZnjPApb1lLkolx8TE4iC47iJ jFlX+aivKXlmoO+77ucWWjZCJcidyEEVoriV4nSk= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1F4SksB023356; Wed, 14 Feb 2018 22:28:46 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 14 Feb 2018 22:28:45 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Wed, 14 Feb 2018 22:28:45 -0600 Received: from [172.24.190.89] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1F4Sg9u015533; Wed, 14 Feb 2018 22:28:43 -0600 Subject: Re: [PATCH 2/3] PCI: dwc: pci-dra7xx: Improve MSI IRQ handling 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> From: Vignesh R Message-ID: <7cfa73af-09fa-d298-aaab-3e74ee7e1dd5@ti.com> Date: Thu, 15 Feb 2018 09:59:21 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180212175801.GA29070@e107981-ln.cambridge.arm.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, 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. > > 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 >> -- Regards Vignesh