From patchwork Thu Jun 14 01:34:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929192 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mQF5zD4z9s01 for ; Thu, 14 Jun 2018 11:35:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935695AbeFNBe6 (ORCPT ); Wed, 13 Jun 2018 21:34:58 -0400 Received: from lucky1.263xmail.com ([211.157.147.135]:52232 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935710AbeFNBe4 (ORCPT ); Wed, 13 Jun 2018 21:34:56 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.87]) by lucky1.263xmail.com (Postfix) with ESMTP id 392506D9C; Thu, 14 Jun 2018 09:34:52 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id DB45D3B9; Thu, 14 Jun 2018 09:34:47 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <7889448ab636eb98f3bb7bd404ba622d> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 13929AHQWXZ; Thu, 14 Jun 2018 09:34:49 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin Subject: [PATCH v4 01/10] PCI: Add pci_host_alloc_intx_irqd() for allocating IRQ domain Date: Thu, 14 Jun 2018 09:34:17 +0800 Message-Id: <1528940057-183252-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org It seems host drivers which allocate IRQ domain for INTx and the related code block looks highly similar to each other. Add a new helper, pci_alloc_intx_irqd(), to avoid code duplication as much as possible. Signed-off-by: Shawn Lin --- Changes in v4: - fix another compile warning reported by Kbuild Robot Changes in v3: - rename to pci_host_alloc_intx_irqd and move to probe.c - fix compile error reported by Kbuild Robot Changes in v2: - fix typo and move the code to C file. drivers/pci/probe.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 7 +++++ 2 files changed, 81 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ac876e3..d37b879 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3139,3 +3139,77 @@ int pci_hp_add_bridge(struct pci_dev *dev) return 0; } EXPORT_SYMBOL_GPL(pci_hp_add_bridge); + +static int pcie_intx_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) +{ + irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); + irq_set_chip_data(irq, domain->host_data); + + return 0; +} + +/** + * pci_host_alloc_intx_irqd() - Allocate INTx IRQ domain + * @dev: device associated with the PCI controller. + * @host: pointer to host specific data struct + * @general_xlate: flag for whether use pci_irqd_intx_xlate() helper + * @intx_domain_ops: pointer to driver specific struct irq_domain_ops + * @local_intc: pointer to driver specific interrupt controller node + * + * A simple helper for drivers to allocate IRQ domain for INTx. If + * intx_domain_ops is NULL, use pci_intx_domain_ops by default. And if + * local_intc is present, then use it firstly, otherwise, fallback to get + * interrupt controller node from @dev. + * + * Returns valid pointer of struct irq_domain on success, or PTR_ERR(-EINVAL) + * if failure occurred. + */ +struct irq_domain *pci_host_alloc_intx_irqd(struct device *dev, void *host, + bool general_xlate, const struct irq_domain_ops *intx_domain_ops, + struct device_node *local_intc) +{ + struct device_node *intc = local_intc; + struct irq_domain *domain = NULL; + struct irq_domain_ops *irqd_ops; + bool need_put = false; + int err = -EINVAL; + + if (!intc) { + intc = of_get_next_child(dev->of_node, NULL); + if (!intc) { + dev_err(dev, "missing child interrupt-controller node\n"); + goto err_out; + } + need_put = true; + } + + if (!intx_domain_ops) { + irqd_ops = (struct irq_domain_ops *)devm_kmalloc(dev, + sizeof(struct irq_domain_ops), GFP_KERNEL); + if (!irqd_ops) { + err = -ENOMEM; + goto err_out; + } + + irqd_ops->map = &pcie_intx_map; + if (general_xlate) + irqd_ops->xlate = &pci_irqd_intx_xlate; + intx_domain_ops = irqd_ops; + } +#ifdef CONFIG_IRQ_DOMAIN + domain = irq_domain_add_linear(intc, PCI_NUM_INTX, + intx_domain_ops, host); +#endif + if (!domain) { + dev_err(dev, "failed to get a INTx IRQ domain\n"); + goto err_out; + } + + return domain; +err_out: + if (need_put) + of_node_put(intc); + return ERR_PTR(err); +} +EXPORT_SYMBOL_GPL(pci_host_alloc_intx_irqd); diff --git a/include/linux/pci.h b/include/linux/pci.h index 340029b..8360972 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -31,6 +31,9 @@ #include #include #include +#include +#include +#include #include #include @@ -1453,6 +1456,10 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d, return 0; } +struct irq_domain *pci_host_alloc_intx_irqd(struct device *dev, + void *host, bool general_xlate, + const struct irq_domain_ops *intx_domain_ops, + struct device_node *local_intc); #ifdef CONFIG_PCIEPORTBUS extern bool pcie_ports_disabled; extern bool pcie_ports_native; From patchwork Thu Jun 14 01:34:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929193 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mQP1rh8z9ryk for ; Thu, 14 Jun 2018 11:35:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935765AbeFNBfH (ORCPT ); Wed, 13 Jun 2018 21:35:07 -0400 Received: from lucky1.263xmail.com ([211.157.147.131]:36976 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935710AbeFNBfF (ORCPT ); Wed, 13 Jun 2018 21:35:05 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.140]) by lucky1.263xmail.com (Postfix) with ESMTP id D045E96B73; Thu, 14 Jun 2018 09:35:01 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 8E5B53BA; Thu, 14 Jun 2018 09:34:59 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <4e9c21554b9a6fb5d036f66e5c6b19e3> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 179178LKRG4; Thu, 14 Jun 2018 09:35:01 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin , Kishon Vijay Abraham I Subject: [PATCH v4 02/10] PCI: dra7xx: Use pci_host_alloc_intx_irqd() helper to simplify the code Date: Thu, 14 Jun 2018 09:34:43 +0800 Message-Id: <1528940083-183300-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Kishon Vijay Abraham I Signed-off-by: Shawn Lin --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/pci/controller/dwc/pci-dra7xx.c | 42 +++------------------------------ 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index cfaeef8..a281924 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c @@ -213,43 +213,6 @@ static int dra7xx_pcie_host_init(struct pcie_port *pp) .host_init = dra7xx_pcie_host_init, }; -static int dra7xx_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -static const struct irq_domain_ops intx_domain_ops = { - .map = dra7xx_pcie_intx_map, - .xlate = pci_irqd_intx_xlate, -}; - -static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp) -{ - struct dw_pcie *pci = to_dw_pcie_from_pp(pp); - struct device *dev = pci->dev; - struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); - struct device_node *node = dev->of_node; - struct device_node *pcie_intc_node = of_get_next_child(node, NULL); - - if (!pcie_intc_node) { - dev_err(dev, "No PCIe Intc node found\n"); - return -ENODEV; - } - - dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &intx_domain_ops, pp); - if (!dra7xx->irq_domain) { - dev_err(dev, "Failed to get a INTx IRQ domain\n"); - return -ENODEV; - } - - return 0; -} - static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg) { struct dra7xx_pcie *dra7xx = arg; @@ -455,8 +418,9 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx, return ret; } - ret = dra7xx_pcie_init_irq_domain(pp); - if (ret < 0) + dra7xx->irq_domain = pci_host_alloc_intx_irqd(dev, dra7xx, true, NULL, + NULL); + if (IS_ERR(dra7xx->irq_domain)) return ret; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rc_dbics"); From patchwork Thu Jun 14 01:34:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929195 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mQg4xdgz9ryk for ; Thu, 14 Jun 2018 11:35:23 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935633AbeFNBfU (ORCPT ); Wed, 13 Jun 2018 21:35:20 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:37681 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935910AbeFNBfT (ORCPT ); Wed, 13 Jun 2018 21:35:19 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.243]) by lucky1.263xmail.com (Postfix) with ESMTP id EE622955FC; Thu, 14 Jun 2018 09:35:15 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 0D6A23A0; Thu, 14 Jun 2018 09:35:14 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 6685XICF8O; Thu, 14 Jun 2018 09:35:15 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin , Kishon Vijay Abraham I Subject: [PATCH v4 03/10] PCI: keystone-dw: Use pci_host_alloc_intx_irqd() helper to get irq domain for INTx Date: Thu, 14 Jun 2018 09:34:54 +0800 Message-Id: <1528940094-183348-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Kishon Vijay Abraham I Signed-off-by: Shawn Lin --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/pci/controller/dwc/pci-keystone-dw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-keystone-dw.c b/drivers/pci/controller/dwc/pci-keystone-dw.c index 0682213..a45809d 100644 --- a/drivers/pci/controller/dwc/pci-keystone-dw.c +++ b/drivers/pci/controller/dwc/pci-keystone-dw.c @@ -470,15 +470,12 @@ int __init ks_dw_pcie_host_init(struct keystone_pcie *ks_pcie, ks_pcie->app = *res; /* Create legacy IRQ domain */ - ks_pcie->legacy_irq_domain = - irq_domain_add_linear(ks_pcie->legacy_intc_np, - PCI_NUM_INTX, + ks_pcie->legacy_irq_domain = pci_host_alloc_intx_irqd(dev, ks_pcie, + false, &ks_dw_pcie_legacy_irq_domain_ops, - NULL); - if (!ks_pcie->legacy_irq_domain) { - dev_err(dev, "Failed to add irq domain for legacy irqs\n"); - return -EINVAL; - } + ks_pcie->legacy_intc_np); + if (IS_ERR(ks_pcie->legacy_irq_domain)) + return PTR_ERR(ks_pcie->legacy_irq_domain); return dw_pcie_host_init(pp); } From patchwork Thu Jun 14 01:35:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929196 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mQy0NKxz9ryk for ; Thu, 14 Jun 2018 11:35:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935916AbeFNBfh (ORCPT ); Wed, 13 Jun 2018 21:35:37 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:34537 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935889AbeFNBfg (ORCPT ); Wed, 13 Jun 2018 21:35:36 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.225]) by lucky1.263xmail.com (Postfix) with ESMTP id 92EAB8F4D; Thu, 14 Jun 2018 09:35:34 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 64ED13EA; Thu, 14 Jun 2018 09:35:25 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 268245U4F5Z; Thu, 14 Jun 2018 09:35:31 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin , Thomas Petazzoni Subject: [PATCH v4 04/10] PCI: aardvark: Use pci_host_alloc_intx_irqd() helper to get irq domain for INTx Date: Thu, 14 Jun 2018 09:35:08 +0800 Message-Id: <1528940108-183399-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Thomas Petazzoni Signed-off-by: Shawn Lin --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/pci/controller/pci-aardvark.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index d3172d5..4c31582 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -704,37 +704,23 @@ static void advk_pcie_remove_msi_irq_domain(struct advk_pcie *pcie) static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) { struct device *dev = &pcie->pdev->dev; - struct device_node *node = dev->of_node; - struct device_node *pcie_intc_node; struct irq_chip *irq_chip; - pcie_intc_node = of_get_next_child(node, NULL); - if (!pcie_intc_node) { - dev_err(dev, "No PCIe Intc node found\n"); - return -ENODEV; - } - irq_chip = &pcie->irq_chip; irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq", dev_name(dev)); - if (!irq_chip->name) { - of_node_put(pcie_intc_node); + if (!irq_chip->name) return -ENOMEM; - } irq_chip->irq_mask = advk_pcie_irq_mask; irq_chip->irq_mask_ack = advk_pcie_irq_mask; irq_chip->irq_unmask = advk_pcie_irq_unmask; - pcie->irq_domain = - irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &advk_pcie_irq_domain_ops, pcie); - if (!pcie->irq_domain) { - dev_err(dev, "Failed to get a INTx IRQ domain\n"); - of_node_put(pcie_intc_node); - return -ENOMEM; - } + pcie->irq_domain = pci_host_alloc_intx_irqd(dev, pcie, false, + &advk_pcie_irq_domain_ops, NULL); + if (IS_ERR(pcie->irq_domain)) + return PTR_ERR(pcie->irq_domain); return 0; } From patchwork Thu Jun 14 01:35:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929197 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mRQ60rFz9ryk for ; Thu, 14 Jun 2018 11:36:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935667AbeFNBgB (ORCPT ); Wed, 13 Jun 2018 21:36:01 -0400 Received: from lucky1.263xmail.com ([211.157.147.130]:44990 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935889AbeFNBgB (ORCPT ); Wed, 13 Jun 2018 21:36:01 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.161]) by lucky1.263xmail.com (Postfix) with ESMTP id 860AD1F5A59; Thu, 14 Jun 2018 09:35:57 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 438BA387; Thu, 14 Jun 2018 09:35:45 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <992f7f7e50c2af867ab176e605cd0724> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 50093M6QNH; Thu, 14 Jun 2018 09:35:50 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin Subject: [PATCH v4 05/10] PCI: faraday: Use pci_host_alloc_intx_irqd() helper to get irq domain for INTx Date: Thu, 14 Jun 2018 09:35:26 +0800 Message-Id: <1528940126-183447-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Signed-off-by: Shawn Lin --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/pci/controller/pci-ftpci100.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c index a1ebe9e..8ace724 100644 --- a/drivers/pci/controller/pci-ftpci100.c +++ b/drivers/pci/controller/pci-ftpci100.c @@ -346,24 +346,19 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) int irq; int i; - if (!intc) { - dev_err(p->dev, "missing child interrupt-controller node\n"); - return -EINVAL; - } + p->irqdomain = pci_host_alloc_intx_irqd(p->dev, p, false, + &faraday_pci_irqdomain_ops, intc); + if (IS_ERR(p->irqdomain)) + return PTR_ERR(p->irqdomain); /* All PCI IRQs cascade off this one */ irq = of_irq_get(intc, 0); if (irq <= 0) { dev_err(p->dev, "failed to get parent IRQ\n"); + irq_domain_remove(p->irqdomain); return irq ?: -EINVAL; } - p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX, - &faraday_pci_irqdomain_ops, p); - if (!p->irqdomain) { - dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n"); - return -EINVAL; - } irq_set_chained_handler_and_data(irq, faraday_pci_irq_handler, p); From patchwork Thu Jun 14 01:35:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929198 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mRf2nD0z9s3x for ; Thu, 14 Jun 2018 11:36:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935837AbeFNBgM (ORCPT ); Wed, 13 Jun 2018 21:36:12 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:54143 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935929AbeFNBgL (ORCPT ); Wed, 13 Jun 2018 21:36:11 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.43]) by lucky1.263xmail.com (Postfix) with ESMTP id B7D07950B0; Thu, 14 Jun 2018 09:36:07 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id EAB0136B; Thu, 14 Jun 2018 09:36:06 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <8a1fdd7ada61fc5a29a967580693028f> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 7486X1A3OV; Thu, 14 Jun 2018 09:36:07 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin , Ley Foon Tan Subject: [PATCH v4 06/10] PCI: altera: Use pci_host_alloc_intx_irqd() helper to get irq domain for INTx Date: Thu, 14 Jun 2018 09:35:45 +0800 Message-Id: <1528940145-183495-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Ley Foon Tan Signed-off-by: Shawn Lin Reviewed-by: Ley Foon Tan --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/pci/controller/pcie-altera.c | 38 ++++-------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c index 7d05e51..0915c8b 100644 --- a/drivers/pci/controller/pcie-altera.c +++ b/drivers/pci/controller/pcie-altera.c @@ -443,19 +443,6 @@ static void altera_pcie_retrain(struct altera_pcie *pcie) } } -static int altera_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); - irq_set_chip_data(irq, domain->host_data); - return 0; -} - -static const struct irq_domain_ops intx_domain_ops = { - .map = altera_pcie_intx_map, - .xlate = pci_irqd_intx_xlate, -}; - static void altera_pcie_isr(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); @@ -519,22 +506,6 @@ static int altera_pcie_parse_request_of_pci_ranges(struct altera_pcie *pcie) return err; } -static int altera_pcie_init_irq_domain(struct altera_pcie *pcie) -{ - struct device *dev = &pcie->pdev->dev; - struct device_node *node = dev->of_node; - - /* Setup INTx */ - pcie->irq_domain = irq_domain_add_linear(node, PCI_NUM_INTX, - &intx_domain_ops, pcie); - if (!pcie->irq_domain) { - dev_err(dev, "Failed to get a INTx IRQ domain\n"); - return -ENOMEM; - } - - return 0; -} - static int altera_pcie_parse_dt(struct altera_pcie *pcie) { struct device *dev = &pcie->pdev->dev; @@ -592,11 +563,10 @@ static int altera_pcie_probe(struct platform_device *pdev) return ret; } - ret = altera_pcie_init_irq_domain(pcie); - if (ret) { - dev_err(dev, "Failed creating IRQ Domain\n"); - return ret; - } + pcie->irq_domain = pci_host_alloc_intx_irqd(dev, pcie, true, NULL, + dev->of_node); + if (IS_ERR(pcie->irq_domain)) + return PTR_ERR(pcie->irq_domain); /* clear all interrupts */ cra_writel(pcie, P2A_INT_STS_ALL, P2A_INT_STATUS); From patchwork Thu Jun 14 01:36:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929200 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mTT17W0z9ryk for ; Thu, 14 Jun 2018 11:37:48 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935745AbeFNBhr (ORCPT ); Wed, 13 Jun 2018 21:37:47 -0400 Received: from lucky1.263xmail.com ([211.157.147.132]:43934 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935929AbeFNBgW (ORCPT ); Wed, 13 Jun 2018 21:36:22 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.193]) by lucky1.263xmail.com (Postfix) with ESMTP id EB7EC6906D; Thu, 14 Jun 2018 09:36:19 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id B67CC3A7; Thu, 14 Jun 2018 09:36:16 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <5c4bf6072253d6e7bff27b4547a7e61d> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 485669QGHC; Thu, 14 Jun 2018 09:36:17 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin , Ryder Lee Subject: [PATCH v4 07/10] PCI: mediatek: Use pci_host_alloc_intx_irqd() helper to get irq domain for INTx Date: Thu, 14 Jun 2018 09:36:00 +0800 Message-Id: <1528940160-183544-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Cc: Ryder Lee Signed-off-by: Shawn Lin --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/pci/controller/pcie-mediatek.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 0baabe3..b35a8ce 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -590,39 +590,17 @@ static void mtk_pcie_enable_msi(struct mtk_pcie_port *port) writel(val, port->base + PCIE_INT_MASK); } -static int mtk_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -static const struct irq_domain_ops intx_domain_ops = { - .map = mtk_pcie_intx_map, -}; - static int mtk_pcie_init_irq_domain(struct mtk_pcie_port *port, struct device_node *node) { struct device *dev = port->pcie->dev; - struct device_node *pcie_intc_node; int ret; - /* Setup INTx */ - pcie_intc_node = of_get_next_child(node, NULL); - if (!pcie_intc_node) { - dev_err(dev, "no PCIe Intc node found\n"); - return -ENODEV; - } + port->irq_domain = pci_host_alloc_intx_irqd(dev, port, false, + NULL, NULL); + if (IS_ERR(port->irq_domain)) + return PTR_ERR(port->irq_domain); - port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &intx_domain_ops, port); - if (!port->irq_domain) { - dev_err(dev, "failed to get INTx IRQ domain\n"); - return -ENODEV; - } if (IS_ENABLED(CONFIG_PCI_MSI)) { ret = mtk_pcie_allocate_msi_domains(port); From patchwork Thu Jun 14 01:36:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929201 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mTW0Jqxz9ryk for ; Thu, 14 Jun 2018 11:37:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935738AbeFNBht (ORCPT ); Wed, 13 Jun 2018 21:37:49 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:35056 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935766AbeFNBgg (ORCPT ); Wed, 13 Jun 2018 21:36:36 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.157]) by lucky1.263xmail.com (Postfix) with ESMTP id 4FF658F53; Thu, 14 Jun 2018 09:36:34 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 75D45407; Thu, 14 Jun 2018 09:36:29 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 26009ZAUFH0; Thu, 14 Jun 2018 09:36:32 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin Subject: [PATCH v4 08/10] PCI: xilinx-nwl: Use pci_host_alloc_intx_irqd() helper to get irq domain for INTx Date: Thu, 14 Jun 2018 09:36:10 +0800 Message-Id: <1528940170-183596-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Signed-off-by: Shawn Lin --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/pci/controller/pcie-xilinx-nwl.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c index 6a4bbb5..b0d13bb 100644 --- a/drivers/pci/controller/pcie-xilinx-nwl.c +++ b/drivers/pci/controller/pcie-xilinx-nwl.c @@ -546,24 +546,12 @@ static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie) static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie) { struct device *dev = pcie->dev; - struct device_node *node = dev->of_node; - struct device_node *legacy_intc_node; - - legacy_intc_node = of_get_next_child(node, NULL); - if (!legacy_intc_node) { - dev_err(dev, "No legacy intc node found\n"); - return -EINVAL; - } - pcie->legacy_irq_domain = irq_domain_add_linear(legacy_intc_node, - PCI_NUM_INTX, - &legacy_domain_ops, - pcie); - - if (!pcie->legacy_irq_domain) { - dev_err(dev, "failed to create IRQ domain\n"); - return -ENOMEM; - } + pcie->legacy_irq_domain = pci_host_alloc_intx_irqd(dev, pcie, false, + &legacy_domain_ops, + NULL); + if (IS_ERR(pcie->legacy_irq_domain)) + return PTR_ERR(pcie->legacy_irq_domain); raw_spin_lock_init(&pcie->leg_mask_lock); nwl_pcie_init_msi_irq_domain(pcie); From patchwork Thu Jun 14 01:36:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929202 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mTW5hy0z9s2g for ; Thu, 14 Jun 2018 11:37:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935766AbeFNBht (ORCPT ); Wed, 13 Jun 2018 21:37:49 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:54506 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935532AbeFNBgp (ORCPT ); Wed, 13 Jun 2018 21:36:45 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.235]) by lucky1.263xmail.com (Postfix) with ESMTP id E35719558D; Thu, 14 Jun 2018 09:36:42 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 6D4193C4; Thu, 14 Jun 2018 09:36:41 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <09d96e167e9024e7bde61298a03d5a97> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 87488BW6SS; Thu, 14 Jun 2018 09:36:42 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin Subject: [PATCH v4 09/10] PCI: xilinx: Use pci_host_alloc_intx_irqd() helper to get irq domain for INTx Date: Thu, 14 Jun 2018 09:36:25 +0800 Message-Id: <1528940185-183646-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Signed-off-by: Shawn Lin --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/pci/controller/pcie-xilinx.c | 44 ++++-------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c index b110a3a..8dbfc76 100644 --- a/drivers/pci/controller/pcie-xilinx.c +++ b/drivers/pci/controller/pcie-xilinx.c @@ -346,31 +346,6 @@ static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port) pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2); } -/* INTx Functions */ - -/** - * xilinx_pcie_intx_map - Set the handler for the INTx and mark IRQ as valid - * @domain: IRQ domain - * @irq: Virtual IRQ number - * @hwirq: HW interrupt number - * - * Return: Always returns 0. - */ -static int xilinx_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -/* INTx IRQ Domain operations */ -static const struct irq_domain_ops intx_domain_ops = { - .map = xilinx_pcie_intx_map, - .xlate = pci_irqd_intx_xlate, -}; - /* PCIe HW Functions */ /** @@ -497,22 +472,11 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port) { struct device *dev = port->dev; struct device_node *node = dev->of_node; - struct device_node *pcie_intc_node; - /* Setup INTx */ - pcie_intc_node = of_get_next_child(node, NULL); - if (!pcie_intc_node) { - dev_err(dev, "No PCIe Intc node found\n"); - return -ENODEV; - } - - port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &intx_domain_ops, - port); - if (!port->leg_domain) { - dev_err(dev, "Failed to get a INTx IRQ domain\n"); - return -ENODEV; - } + port->leg_domain = pci_host_alloc_intx_irqd(dev, port, true, NULL, + NULL); + if (IS_ERR(port->leg_domain)) + return PTR_ERR(port->leg_domain); /* Setup MSI */ if (IS_ENABLED(CONFIG_PCI_MSI)) { From patchwork Thu Jun 14 01:36:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 929203 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415mTX4Sj0z9ryk for ; Thu, 14 Jun 2018 11:37:52 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754498AbeFNBhu (ORCPT ); Wed, 13 Jun 2018 21:37:50 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:35182 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935633AbeFNBg4 (ORCPT ); Wed, 13 Jun 2018 21:36:56 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.73]) by lucky1.263xmail.com (Postfix) with ESMTP id 186F68F5C; Thu, 14 Jun 2018 09:36:54 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 2155C3CC; Thu, 14 Jun 2018 09:36:52 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 55071WAHZL; Thu, 14 Jun 2018 09:36:53 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Shawn Lin Subject: [PATCH v4 10/10] PCI: rockchip: Use pci_host_alloc_intx_irqd() helper to get irq domain for INTx Date: Thu, 14 Jun 2018 09:36:37 +0800 Message-Id: <1528940197-183694-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> References: <1528939995-183203-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Just avoid code duplication, but no functional change intended. Signed-off-by: Shawn Lin --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/pci/controller/pcie-rockchip-host.c | 38 +++-------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index 1372d27..eb62ba4 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -699,39 +699,6 @@ static void rockchip_pcie_enable_interrupts(struct rockchip_pcie *rockchip) rockchip_pcie_enable_bw_int(rockchip); } -static int rockchip_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -static const struct irq_domain_ops intx_domain_ops = { - .map = rockchip_pcie_intx_map, -}; - -static int rockchip_pcie_init_irq_domain(struct rockchip_pcie *rockchip) -{ - struct device *dev = rockchip->dev; - struct device_node *intc = of_get_next_child(dev->of_node, NULL); - - if (!intc) { - dev_err(dev, "missing child interrupt-controller node\n"); - return -EINVAL; - } - - rockchip->irq_domain = irq_domain_add_linear(intc, PCI_NUM_INTX, - &intx_domain_ops, rockchip); - if (!rockchip->irq_domain) { - dev_err(dev, "failed to get a INTx IRQ domain\n"); - return -EINVAL; - } - - return 0; -} - static int rockchip_pcie_prog_ob_atu(struct rockchip_pcie *rockchip, int region_no, int type, u8 num_pass_bits, u32 lower_addr, u32 upper_addr) @@ -990,8 +957,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev) rockchip_pcie_enable_interrupts(rockchip); - err = rockchip_pcie_init_irq_domain(rockchip); - if (err < 0) + rockchip->irq_domain = pci_host_alloc_intx_irqd(dev, rockchip, false, + NULL, NULL); + if (IS_ERR(rockchip->irq_domain)) goto err_deinit_port; err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff,