All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] *** PCI: kirin: MSI patch discription ***
@ 2018-05-16  1:21 Xiaowei Song
  2018-05-16  1:21 ` [PATCH v4] PCI: kirin: Add MSI support Xiaowei Song
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaowei Song @ 2018-05-16  1:21 UTC (permalink / raw)
  To: wangbinghui, bhelgaas, xuwei5, robh+dt, linux-pci, linux-kernel,
	dimitrysh, andy.shevchenko
  Cc: guodong.xu, suzhuangluan, kongfei, chenyao11, songxiaowei

From: Yao Chen <chenyao11@huawei.com>

Before Version Patches
======================
patch v3
https://www.spinics.net/lists/linux-pci/msg72322.html
patch v2
https://www.spinics.net/lists/kernel/msg2797610.html

patch v1
https://www.spinics.net/lists/kernel/msg2796410.html

Changes between V4 and V3
=========================
1. remove DT binding patch, for Wei Xu had applied it.
2. fix issues according to review comments from Andy Shevchenko.
   (1) Take the msi number get and request as a seperate function,
   (2) Use the result of  platform_get_irq as return val.

Changes between V3 and V2
=========================
1. fix issues according to review comments
   (1)from Bjorn Helgaas: Check for 'pci->pp.msi_irq < 0'.
   (2)from Bjorn Helgaas: Update the message of 'msi irq' in dev_err().

Changes between V2 and V1
=========================
1. seperate DT binding patch.
2. fix issues according to review comments
   (1)from Bjorn Helgaas: Update the style of subject and changelog.
   (2)from Bjorn Helgaas: Add msi irq number in the message.
   (3)from Bjorn Helgaas: Delete unnecessary code 'pci->pp.root_bus_nr = -1'.
   (4)from Dmitry Shmidt: Fix typing error. Replace 'interrupts-names' of 'interrupt-names'.


Yao Chen (1):
  PCI: kirin: Add MSI support

 drivers/pci/dwc/pcie-kirin.c | 51 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

-- 
2.7.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v4] PCI: kirin: Add MSI support
  2018-05-16  1:21 [PATCH v4] *** PCI: kirin: MSI patch discription *** Xiaowei Song
@ 2018-05-16  1:21 ` Xiaowei Song
  2018-05-17 17:46   ` Lorenzo Pieralisi
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaowei Song @ 2018-05-16  1:21 UTC (permalink / raw)
  To: wangbinghui, bhelgaas, xuwei5, robh+dt, linux-pci, linux-kernel,
	dimitrysh, andy.shevchenko
  Cc: guodong.xu, suzhuangluan, kongfei, chenyao11, songxiaowei

From: Yao Chen <chenyao11@huawei.com>

Add support for MSI.

Signed-off-by: Yao Chen <chenyao11@huawei.com>
Cc: Xiaowei Song <songxiaowei@hisilicon.com>
---
 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);
+}
+
+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);
+}
+
 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);
+	}
+	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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] PCI: kirin: Add MSI support
  2018-05-16  1:21 ` [PATCH v4] PCI: kirin: Add MSI support Xiaowei Song
@ 2018-05-17 17:46   ` Lorenzo Pieralisi
  2018-05-18 20:41     ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Lorenzo Pieralisi @ 2018-05-17 17:46 UTC (permalink / raw)
  To: Xiaowei Song
  Cc: wangbinghui, bhelgaas, xuwei5, robh+dt, linux-pci, linux-kernel,
	dimitrysh, andy.shevchenko, guodong.xu, suzhuangluan, kongfei,
	chenyao11

On Wed, May 16, 2018 at 09:21:59AM +0800, Xiaowei Song wrote:
> From: Yao Chen <chenyao11@huawei.com>
> 
> Add support for MSI.
> 
> Signed-off-by: Yao Chen <chenyao11@huawei.com>
> Cc: Xiaowei Song <songxiaowei@hisilicon.com>
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] PCI: kirin: Add MSI support
  2018-05-17 17:46   ` Lorenzo Pieralisi
@ 2018-05-18 20:41     ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2018-05-18 20:41 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Xiaowei Song, Wangbinghui, Bjorn Helgaas, xuwei (O),
	Rob Herring, linux-pci, Linux Kernel Mailing List, Dmitry Shmidt,
	Guodong Xu, Suzhuangluan, Kongfei, Yao Chen

On Thu, May 17, 2018 at 8:46 PM, Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
> On Wed, May 16, 2018 at 09:21:59AM +0800, Xiaowei Song wrote:

>> +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 ?

It's probably misreading of my suggestion which is more clearly can look like

  if (!IS_ENABLED(CONFIG_PCI_MSI))
    return;
  dw_pcie_msi_init(pp);

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-18 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16  1:21 [PATCH v4] *** PCI: kirin: MSI patch discription *** Xiaowei Song
2018-05-16  1:21 ` [PATCH v4] PCI: kirin: Add MSI support Xiaowei Song
2018-05-17 17:46   ` Lorenzo Pieralisi
2018-05-18 20:41     ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.