From patchwork Wed Dec 19 12:42:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 154265 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4891139ljp; Wed, 19 Dec 2018 04:43:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/UmJG3F7KV2jSEjhYFYTaAQLtmKXIjZeI++5n6i6ruIKsGIUFq80Ydg4Awori1nMjsr65tX X-Received: by 2002:a17:902:b943:: with SMTP id h3mr20521878pls.12.1545223425720; Wed, 19 Dec 2018 04:43:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545223425; cv=none; d=google.com; s=arc-20160816; b=SAtvcBPq0YJjZavHv/torb1tai2VBdVm2CpxJqN9lKmjRvsZlyT/Oz6HBHTw9FLFW/ rSgvJpwS8KI+xYV3b9GuSNNymoJJp7Map5a2mhD0XCAyJOIVFDTLyyMDXxqKzifxilqh Hz4HN0BzN8Vo5Sg6QX8oz6T3RNqfycIo0siu9Gw3+bubsLPWJALGK6IX6bCFKpFRMzeR fwJXgXM8MPq59fKfS09cIdCjRmnkg5wdxYjqN2am4CGOsMmL0r/TWvO9rAIFYGhR1bsg 4if0VYCxGBCeNRhIO53zmLw0boGDUvrA0rq6ycXJioLOtxNxQvwnZRxguFSyV5H36jh0 iV1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=aGKggKrre68tpewZr9QnXh/i5cUBcmHQ2TJDpEiqdgk=; b=mWoGVM1Hrbziz5kD0US1t9Yn4SCcsz2+q2Tmyrqa07z30c72L6Un68McfzDpF2SeXG mIJ7FQdRVi5FtPEeDJd/7fD9vmj0Vxanhvf+3He9zUSxDetDMhBXSmn2YvO57jDN1/nR IkY3rPCnd1nWv0eks4obxOI7FJ6cv36ysy5+ush2P7vzsapDE+fnYrV6zK+oGeJMbgR7 mMowQ01SGhvCU1/V9/KIQkGR8cDfa1iH2IGQD6qnnHApcBMD/D9MyceyxQGa+US/Npn9 01igq4He5/N/IoPLkwWZRWCGgjQYQQGKiyTyu6VI+cUHEzEfn8vuojNfu19urAVk2i7k beLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fgDBsGKL; 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 v141si17544927pfc.260.2018.12.19.04.43.45; Wed, 19 Dec 2018 04:43:45 -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=fgDBsGKL; 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 S1729834AbeLSMnO (ORCPT + 31 others); Wed, 19 Dec 2018 07:43:14 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:54850 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729796AbeLSMnJ (ORCPT ); Wed, 19 Dec 2018 07:43:09 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wBJCgg3d098497; Wed, 19 Dec 2018 06:42:42 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1545223362; bh=aGKggKrre68tpewZr9QnXh/i5cUBcmHQ2TJDpEiqdgk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fgDBsGKLiEWFeZ0Qd2X6bXgfIdVvHuUuf3tBXtKMxJ54ywWCtLvg6CIk0LtFTq6TM UbVFhXlfPVIrF/JhzrKhOF4N7uN2rwnKyLPED9I61jc5xNNd2aPkb0PoCVKMRAmWNg lAo8q8vkKyzEcTOLF4PXUwLhxkP0KoCd1UusXbA4= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wBJCggpA040985 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 19 Dec 2018 06:42:42 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Wed, 19 Dec 2018 06:42:42 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Wed, 19 Dec 2018 06:42:42 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wBJCgNZo003940; Wed, 19 Dec 2018 06:42:39 -0600 From: Kishon Vijay Abraham I To: Murali Karicheri , Lorenzo Pieralisi , Gustavo Pimentel , Marc Zyngier CC: Bjorn Helgaas , Jingoo Han , , , , Subject: [PATCH 05/10] PCI: keystone: Use hwirq to get the IRQ number offset Date: Wed, 19 Dec 2018 18:12:02 +0530 Message-ID: <20181219124207.13479-6-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181219124207.13479-1-kishon@ti.com> References: <20181219124207.13479-1-kishon@ti.com> MIME-Version: 1.0 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 ks_pcie_msi_irq_handler() uses 'virq' to get the IRQ number offset. This offset is used to get the correct MSI_IRQ_STATUS register corresponding to the IRQ line that raised the interrupt. There is no guarantee that 'virq' assigned for consecutive hardware IRQ will be contiguous. And this might get us an incorrect IRQ number offset. Fix it here by using 'hwirq' to get the IRQ number offset. Since we don't store the 'virq' numbers of all the IRQ numbers, stop checking if irq count is greater than MAX_MSI_HOST_IRQS and remove MAX_MSI_HOST_IRQS. Link: https://lkml.kernel.org/r/bb081d21-7c03-0357-4294-7e92d95d838c@arm.com Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/controller/dwc/pci-keystone.c | 24 ++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index a8712804c891..8a78307dac99 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c @@ -74,7 +74,6 @@ #define ERR_IRQ_ALL (ERR_AER | ERR_AXI | ERR_CORR | \ ERR_NONFATAL | ERR_FATAL | ERR_SYS) -#define MAX_MSI_HOST_IRQS 8 /* PCIE controller device IDs */ #define PCIE_RC_K2HK 0xb008 #define PCIE_RC_K2E 0xb009 @@ -89,7 +88,7 @@ struct keystone_pcie { u32 device_id; struct device_node *legacy_intc_np; - int msi_host_irqs[MAX_MSI_HOST_IRQS]; + int msi_host_irq; int num_lanes; u32 num_viewport; struct phy **phy; @@ -527,9 +526,9 @@ static int ks_pcie_establish_link(struct keystone_pcie *ks_pcie) static void ks_pcie_msi_irq_handler(struct irq_desc *desc) { - unsigned int irq = irq_desc_get_irq(desc); + unsigned int irq = desc->irq_data.hwirq; struct keystone_pcie *ks_pcie = irq_desc_get_handler_data(desc); - u32 offset = irq - ks_pcie->msi_host_irqs[0]; + u32 offset = irq - ks_pcie->msi_host_irq; struct dw_pcie *pci = ks_pcie->pci; struct device *dev = pci->dev; struct irq_chip *chip = irq_desc_get_chip(desc); @@ -587,6 +586,7 @@ static int ks_pcie_config_msi_irq(struct keystone_pcie *ks_pcie) struct device *dev = ks_pcie->pci->dev; struct device_node *np = ks_pcie->np; struct device_node *intc_np; + struct irq_data *irq_data; int irq_count; int irq; int ret; @@ -608,19 +608,21 @@ static int ks_pcie_config_msi_irq(struct keystone_pcie *ks_pcie) goto err; } - if (irq_count > MAX_MSI_HOST_IRQS) { - dev_warn(dev, "Too many MSI interrupt lines defined %u\n", - irq_count); - irq_count = MAX_MSI_HOST_IRQS; - } - for (i = 0; i < irq_count; i++) { irq = irq_of_parse_and_map(intc_np, i); if (!irq) { ret = -EINVAL; goto err; } - ks_pcie->msi_host_irqs[i] = irq; + + if (!ks_pcie->msi_host_irq) { + irq_data = irq_get_irq_data(irq); + if (!irq_data) { + ret = -EINVAL; + goto err; + } + ks_pcie->msi_host_irq = irq_data->hwirq; + } irq_set_chained_handler_and_data(irq, ks_pcie_msi_irq_handler, ks_pcie);