Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3569098imm; Thu, 17 May 2018 10:48:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpcdAEqb8XpSbfu/NUPQ7ZduK+vAa1oQY6zwc3m2LuQ/D7afYCP9xFJKpJ2aifZvli86mk8 X-Received: by 2002:a17:902:8303:: with SMTP id bd3-v6mr6019073plb.290.1526579281405; Thu, 17 May 2018 10:48:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526579281; cv=none; d=google.com; s=arc-20160816; b=vG0bs8WmneYQOqVSlJ20GZVidw7d/LND4ZXTMGaJA7h6bjXuz8ylsOHjkV0jdwOfOZ u1vtWr/FLVptsxKntf80UFiU86B/0svNzGEG4T2JSe7Jh5CpAfxK/K9KPAdywoTp0zha f85y/wIHmzZyBCipHfdgrR+zMHwLosSIRxaLxGKDDXsrSG02/JJ4/DmrX6EPooyW/JIO 0PsFK3mPJIXxya0Fe72mFJjPk3qtDvzsfo4FY+qAdW9UH0XZxb/BVcdx1SVhus9TSyFj 5orwJIV3p91qGtZVYjl24tnuTUIiyMp6bA2jp4L/4hKtL+I8LCRn3dIPgAs1tQC9EjPe levQ== 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:arc-authentication-results; bh=/NuNZi7O+jMx7rSZKzGExeL/ID4XWsbX3AbBTxu8aiA=; b=JSTo8j6H74h8r1IjtykQAGh8j1V5SfATlj+jRFR6Mbx7998IgPdMIqdKBjqv2sdYq9 Fr1o6TvN1TOPrNXIOjLGq17Ax/BjObU1SZYCukV3QmASBERiXZyufedbjpHC1GlDbBMy Sw9OmzLbC0SciXqrSz20btVMPonQrT7yGY+wh3/OvEGOkp6icZBtLuTOCv7HCQFtFWXA H3CoyRro5B4EDi58VFPi4nIckZdtitvneaZCBIJol71QckObyuQkP9xbAJ/PO9N+8TvT 4vNqOqa/0Qwfbm6wkHJWc7pLP13Er8pEogMB4F7QzRoKOqLd0QylAlLxND/4gCn/KBg4 ZNJQ== 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 p9-v6si5411088plo.208.2018.05.17.10.47.46; Thu, 17 May 2018 10:48:01 -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 S1751649AbeEQRq1 (ORCPT + 99 others); Thu, 17 May 2018 13:46:27 -0400 Received: from foss.arm.com ([217.140.101.70]:39362 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbeEQRq0 (ORCPT ); Thu, 17 May 2018 13:46:26 -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 4DAD91435; Thu, 17 May 2018 10:46:26 -0700 (PDT) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.207.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 17CCD3F53D; Thu, 17 May 2018 10:46:23 -0700 (PDT) Date: Thu, 17 May 2018 18:46:19 +0100 From: Lorenzo Pieralisi To: Xiaowei Song Cc: wangbinghui@hisilicon.com, bhelgaas@google.com, xuwei5@huawei.com, robh+dt@kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, dimitrysh@google.com, andy.shevchenko@gmail.com, guodong.xu@linaro.org, suzhuangluan@hisilicon.com, kongfei@hisilicon.com, chenyao11@huawei.com Subject: Re: [PATCH v4] PCI: kirin: Add MSI support Message-ID: <20180517174619.GA4056@e107981-ln.cambridge.arm.com> References: <20180516012159.44081-1-songxiaowei@hisilicon.com> <20180516012159.44081-2-songxiaowei@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180516012159.44081-2-songxiaowei@hisilicon.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 On Wed, May 16, 2018 at 09:21:59AM +0800, Xiaowei Song wrote: > From: Yao Chen > > Add support for MSI. > > Signed-off-by: Yao Chen > Cc: Xiaowei Song > --- > drivers/pci/dwc/pcie-kirin.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 51 insertions(+) > > diff --git a/drivers/pci/dwc/pcie-kirin.c b/drivers/pci/dwc/pcie-kirin.c > index d2970a0..00ca4e5 100644 > --- a/drivers/pci/dwc/pcie-kirin.c > +++ b/drivers/pci/dwc/pcie-kirin.c > @@ -426,9 +426,28 @@ static int kirin_pcie_establish_link(struct pcie_port *pp) > return 0; > } > > +static irqreturn_t kirin_pcie_msi_irq_handler(int irq, void *arg) > +{ > + struct pcie_port *pp = arg; > + > + return dw_handle_msi_irq(pp); > +} You do not need an IRQ handler, the IRQ is handled already in the dwc driver following Gustavo's rework. https://patchwork.ozlabs.org/patch/882017/ > +static void kirin_pcie_msi_init(struct pcie_port *pp) > +{ > + dw_pcie_msi_init(pp); > +} > + > +static void kirin_pcie_enable_interrupts(struct pcie_port *pp) > +{ > + if (IS_ENABLED(CONFIG_PCI_MSI)) > + kirin_pcie_msi_init(pp); > +} Why do you need two functons ? > + > static int kirin_pcie_host_init(struct pcie_port *pp) > { > kirin_pcie_establish_link(pp); > + kirin_pcie_enable_interrupts(pp); > > return 0; > } > @@ -445,9 +464,41 @@ static const struct dw_pcie_host_ops kirin_pcie_host_ops = { > .host_init = kirin_pcie_host_init, > }; > > +static int kirin_pcie_add_msi(struct dw_pcie *pci, > + struct platform_device *pdev) > +{ > + int ret = 0; > + > + if (IS_ENABLED(CONFIG_PCI_MSI)) { > + ret = platform_get_irq(pdev, 0); > + if (ret < 0) { > + dev_err(&pdev->dev, "failed to get MSI IRQ (%d)\n", > + pci->pp.msi_irq); > + return ret; > + } > + > + pci->pp.msi_irq = ret; > + > + ret = devm_request_irq(&pdev->dev, pci->pp.msi_irq, > + kirin_pcie_msi_irq_handler, > + IRQF_SHARED | IRQF_NO_THREAD, > + "kirin_pcie_msi", &pci->pp); > + if (ret) > + dev_err(&pdev->dev, "failed to request MSI IRQ %d\n", > + pci->pp.msi_irq); This is wrong. If msi_irq is set, the dwc driver will handle the MSI and you must not request the IRQ in the platform driver, see above for the link to Gustavo's work. Lorenzo > + } > + return ret; > +} > + > static int __init kirin_add_pcie_port(struct dw_pcie *pci, > struct platform_device *pdev) > { > + int ret; > + > + ret = kirin_pcie_add_msi(pci, pdev); > + if (ret) > + return ret; > + > pci->pp.ops = &kirin_pcie_host_ops; > > return dw_pcie_host_init(&pci->pp); > -- > 2.7.3 >