All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] Add loadable kernel module and power management support
@ 2017-11-24 15:53 ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, rjw-LthD3rsA81gm4RdzfppkhA,
	tglx-hfZtesqFncYOwBW4kG4KsQ
  Cc: vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA, Manikanta Maddireddy

This series of patches add loadable kernel module and power management
support to Tegra PCIe host controller driver.

These patches are tested on Jetson TK1, TX1 and TX2 platforms, following
are the verification details.
	- Multiple module insert & remove
	- PCIe device functionality after module insert
	- Free clock, resets, regulators, powergate, iomem and interrupt
	resources after module remove
	- PCIe device functionality after resume from RAM

Tegra PCIe host controller driver is using ioremap_page_range() which is
not exported. This is switched with devm_ioremap() in the series
'https://patchwork.ozlabs.org/project/linux-tegra/list/?series=9907'.
Both these series will complete the loadable module support for Tegra
PCIe host driver.

Manikanta Maddireddy (10):
  genirq: Export irq_set_msi_desc()
  of: Export of_pci_range_to_resource()
  PM / QoS: Fix device resume latency for non PM QoS devices
  ARM: tegra: EXPORT tegra_cpuidle_pcie_irqs_in_use()
  PCI: Export pci_find_host_bridge()
  PCI: Export pci_flags
  PCI: tegra: free resources on probe failure
  PCI: tegra: Add loadable kernel module support
  PCI: tegra: Broadcast PME_turn_Off message before link goes to L2
  PCI: tegra: Add power management support

 arch/arm/mach-tegra/cpuidle.c |   1 +
 drivers/of/address.c          |   1 +
 drivers/pci/host-bridge.c     |   1 +
 drivers/pci/host/Kconfig      |   2 +-
 drivers/pci/host/pci-tegra.c  | 359 +++++++++++++++++++++++++++++++++---------
 drivers/pci/setup-bus.c       |   1 +
 include/linux/pm_qos.h        |   3 +-
 kernel/irq/chip.c             |   1 +
 8 files changed, 294 insertions(+), 75 deletions(-)

-- 
2.1.4

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

* [PATCH 00/10] Add loadable kernel module and power management support
@ 2017-11-24 15:53 ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

This series of patches add loadable kernel module and power management
support to Tegra PCIe host controller driver.

These patches are tested on Jetson TK1, TX1 and TX2 platforms, following
are the verification details.
	- Multiple module insert & remove
	- PCIe device functionality after module insert
	- Free clock, resets, regulators, powergate, iomem and interrupt
	resources after module remove
	- PCIe device functionality after resume from RAM

Tegra PCIe host controller driver is using ioremap_page_range() which is
not exported. This is switched with devm_ioremap() in the series
'https://patchwork.ozlabs.org/project/linux-tegra/list/?series=9907'.
Both these series will complete the loadable module support for Tegra
PCIe host driver.

Manikanta Maddireddy (10):
  genirq: Export irq_set_msi_desc()
  of: Export of_pci_range_to_resource()
  PM / QoS: Fix device resume latency for non PM QoS devices
  ARM: tegra: EXPORT tegra_cpuidle_pcie_irqs_in_use()
  PCI: Export pci_find_host_bridge()
  PCI: Export pci_flags
  PCI: tegra: free resources on probe failure
  PCI: tegra: Add loadable kernel module support
  PCI: tegra: Broadcast PME_turn_Off message before link goes to L2
  PCI: tegra: Add power management support

 arch/arm/mach-tegra/cpuidle.c |   1 +
 drivers/of/address.c          |   1 +
 drivers/pci/host-bridge.c     |   1 +
 drivers/pci/host/Kconfig      |   2 +-
 drivers/pci/host/pci-tegra.c  | 359 +++++++++++++++++++++++++++++++++---------
 drivers/pci/setup-bus.c       |   1 +
 include/linux/pm_qos.h        |   3 +-
 kernel/irq/chip.c             |   1 +
 8 files changed, 294 insertions(+), 75 deletions(-)

-- 
2.1.4

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

* [PATCH 01/10] genirq: Export irq_set_msi_desc()
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, rjw-LthD3rsA81gm4RdzfppkhA,
	tglx-hfZtesqFncYOwBW4kG4KsQ
  Cc: vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA, Manikanta Maddireddy

PCI bus support MSI interrupts, allow PCI host driver to set MSI descriptor
data for an irq.

Signed-off-by: Manikanta Maddireddy <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 kernel/irq/chip.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 5a2ef92c2782..bfbd17386bc4 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -136,6 +136,7 @@ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
 {
 	return irq_set_msi_desc_off(irq, 0, entry);
 }
+EXPORT_SYMBOL(irq_set_msi_desc);
 
 /**
  *	irq_set_chip_data - set irq chip data for an irq
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 01/10] genirq: Export irq_set_msi_desc()
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

PCI bus support MSI interrupts, allow PCI host driver to set MSI descriptor
data for an irq.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 kernel/irq/chip.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 5a2ef92c2782..bfbd17386bc4 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -136,6 +136,7 @@ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
 {
 	return irq_set_msi_desc_off(irq, 0, entry);
 }
+EXPORT_SYMBOL(irq_set_msi_desc);
 
 /**
  *	irq_set_chip_data - set irq chip data for an irq
-- 
2.1.4

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

* [PATCH 02/10] of: Export of_pci_range_to_resource()
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, rjw-LthD3rsA81gm4RdzfppkhA,
	tglx-hfZtesqFncYOwBW4kG4KsQ
  Cc: vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA, Manikanta Maddireddy

Allow PCI host driver to use of_pci_range_to_resource() to create a
resource from an of_pci_range.

Signed-off-by: Manikanta Maddireddy <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/of/address.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/of/address.c b/drivers/of/address.c
index 792722e7d458..9c7b2071bf2f 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -348,6 +348,7 @@ int of_pci_range_to_resource(struct of_pci_range *range,
 	res->end = (resource_size_t)OF_BAD_ADDR;
 	return err;
 }
+EXPORT_SYMBOL(of_pci_range_to_resource);
 #endif /* CONFIG_PCI */
 
 /*
-- 
2.1.4

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

* [PATCH 02/10] of: Export of_pci_range_to_resource()
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

Allow PCI host driver to use of_pci_range_to_resource() to create a
resource from an of_pci_range.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/of/address.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/of/address.c b/drivers/of/address.c
index 792722e7d458..9c7b2071bf2f 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -348,6 +348,7 @@ int of_pci_range_to_resource(struct of_pci_range *range,
 	res->end = (resource_size_t)OF_BAD_ADDR;
 	return err;
 }
+EXPORT_SYMBOL(of_pci_range_to_resource);
 #endif /* CONFIG_PCI */
 
 /*
-- 
2.1.4

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

* [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, rjw-LthD3rsA81gm4RdzfppkhA,
	tglx-hfZtesqFncYOwBW4kG4KsQ
  Cc: vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA, Manikanta Maddireddy

In 'commit 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")'
PM QoS resume latency modified 0 as "no latency at all". However
dev_pm_qos_raw_read_value() returns 0 for devices which doesn't have
PM QoS constraints. This is blocking runtime suspend for these devices
in rpm_check_suspend_allowed(). Return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
when PM QoS constraints are not available for a particular device.

Fixes: 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")
Signed-off-by: Manikanta Maddireddy <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 include/linux/pm_qos.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index 6737a8c9e8c6..d68b0569a5eb 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -175,7 +175,8 @@ static inline s32 dev_pm_qos_requested_flags(struct device *dev)
 static inline s32 dev_pm_qos_raw_read_value(struct device *dev)
 {
 	return IS_ERR_OR_NULL(dev->power.qos) ?
-		0 : pm_qos_read_value(&dev->power.qos->resume_latency);
+		PM_QOS_RESUME_LATENCY_NO_CONSTRAINT :
+		pm_qos_read_value(&dev->power.qos->resume_latency);
 }
 #else
 static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev,
-- 
2.1.4

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

* [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

In 'commit 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")'
PM QoS resume latency modified 0 as "no latency at all". However
dev_pm_qos_raw_read_value() returns 0 for devices which doesn't have
PM QoS constraints. This is blocking runtime suspend for these devices
in rpm_check_suspend_allowed(). Return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
when PM QoS constraints are not available for a particular device.

Fixes: 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")
Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 include/linux/pm_qos.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index 6737a8c9e8c6..d68b0569a5eb 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -175,7 +175,8 @@ static inline s32 dev_pm_qos_requested_flags(struct device *dev)
 static inline s32 dev_pm_qos_raw_read_value(struct device *dev)
 {
 	return IS_ERR_OR_NULL(dev->power.qos) ?
-		0 : pm_qos_read_value(&dev->power.qos->resume_latency);
+		PM_QOS_RESUME_LATENCY_NO_CONSTRAINT :
+		pm_qos_read_value(&dev->power.qos->resume_latency);
 }
 #else
 static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev,
-- 
2.1.4

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

* [PATCH 04/10] ARM: tegra: EXPORT tegra_cpuidle_pcie_irqs_in_use()
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53   ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

EXPORT tegra_cpuidle_pcie_irqs_in_use() to allow Tegra PCIe driver to be
compiled as loadable kernel module.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 arch/arm/mach-tegra/cpuidle.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-tegra/cpuidle.c b/arch/arm/mach-tegra/cpuidle.c
index 316563141add..7d7e6d3ce32d 100644
--- a/arch/arm/mach-tegra/cpuidle.c
+++ b/arch/arm/mach-tegra/cpuidle.c
@@ -57,3 +57,4 @@ void tegra_cpuidle_pcie_irqs_in_use(void)
 		break;
 	}
 }
+EXPORT_SYMBOL(tegra_cpuidle_pcie_irqs_in_use);
-- 
2.1.4

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

* [PATCH 04/10] ARM: tegra: EXPORT tegra_cpuidle_pcie_irqs_in_use()
@ 2017-11-24 15:53   ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

EXPORT tegra_cpuidle_pcie_irqs_in_use() to allow Tegra PCIe driver to be
compiled as loadable kernel module.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 arch/arm/mach-tegra/cpuidle.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-tegra/cpuidle.c b/arch/arm/mach-tegra/cpuidle.c
index 316563141add..7d7e6d3ce32d 100644
--- a/arch/arm/mach-tegra/cpuidle.c
+++ b/arch/arm/mach-tegra/cpuidle.c
@@ -57,3 +57,4 @@ void tegra_cpuidle_pcie_irqs_in_use(void)
 		break;
 	}
 }
+EXPORT_SYMBOL(tegra_cpuidle_pcie_irqs_in_use);
-- 
2.1.4

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

* [PATCH 05/10] PCI: Export pci_find_host_bridge()
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53   ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

Allow PCI host driver to use pci_find_host_bridge() to get
pci_host_bridge from pci_bus.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/pci/host-bridge.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index add66236215c..e0942fc086ad 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -22,6 +22,7 @@ struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
 
 	return to_pci_host_bridge(root_bus->bridge);
 }
+EXPORT_SYMBOL(pci_find_host_bridge);
 
 struct device *pci_get_host_bridge_device(struct pci_dev *dev)
 {
-- 
2.1.4

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

* [PATCH 05/10] PCI: Export pci_find_host_bridge()
@ 2017-11-24 15:53   ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

Allow PCI host driver to use pci_find_host_bridge() to get
pci_host_bridge from pci_bus.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/pci/host-bridge.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index add66236215c..e0942fc086ad 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -22,6 +22,7 @@ struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
 
 	return to_pci_host_bridge(root_bus->bridge);
 }
+EXPORT_SYMBOL(pci_find_host_bridge);
 
 struct device *pci_get_host_bridge_device(struct pci_dev *dev)
 {
-- 
2.1.4

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

* [PATCH 06/10] PCI: Export pci_flags
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, rjw-LthD3rsA81gm4RdzfppkhA,
	tglx-hfZtesqFncYOwBW4kG4KsQ
  Cc: vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA, Manikanta Maddireddy

pci_flags is used in pci.h, export pci_flags for the driver which is
including pci.h

Signed-off-by: Manikanta Maddireddy <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/pci/setup-bus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 958da7db9033..2d0e8588710a 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -29,6 +29,7 @@
 #include "pci.h"
 
 unsigned int pci_flags;
+EXPORT_SYMBOL(pci_flags);
 
 struct pci_dev_resource {
 	struct list_head list;
-- 
2.1.4

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

* [PATCH 06/10] PCI: Export pci_flags
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

pci_flags is used in pci.h, export pci_flags for the driver which is
including pci.h

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/pci/setup-bus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 958da7db9033..2d0e8588710a 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -29,6 +29,7 @@
 #include "pci.h"
 
 unsigned int pci_flags;
+EXPORT_SYMBOL(pci_flags);
 
 struct pci_dev_resource {
 	struct list_head list;
-- 
2.1.4

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

* [PATCH 07/10] PCI: tegra: free resources on probe failure
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53   ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

tegra_pcie_probe() can fail in multiple instances, this patch takes care
of freeing the resources which are allocated before probe fail.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/pci/host/pci-tegra.c | 102 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 86 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index b52bdd941249..09f52cd569c6 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -681,14 +681,25 @@ static int tegra_pcie_request_resources(struct tegra_pcie *pcie)
 	pci_add_resource(windows, &pcie->busn);
 
 	err = devm_request_pci_bus_resources(dev, windows);
-	if (err < 0)
+	if (err < 0) {
+		pci_free_resource_list(windows);
 		return err;
+	}
 
 	pci_remap_iospace(&pcie->pio, pcie->io.start);
 
 	return 0;
 }
 
+static void tegra_pcie_free_resources(struct tegra_pcie *pcie)
+{
+	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
+	struct list_head *windows = &host->windows;
+
+	pci_unmap_iospace(&pcie->pio);
+	pci_free_resource_list(windows);
+}
+
 static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 {
 	struct pci_host_bridge *host = pci_find_host_bridge(pdev->bus);
@@ -1089,29 +1100,40 @@ static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)
 	return 0;
 }
 
-static void tegra_pcie_power_off(struct tegra_pcie *pcie)
+static void tegra_pcie_disable_controller(struct tegra_pcie *pcie)
 {
 	struct device *dev = pcie->dev;
 	const struct tegra_pcie_soc *soc = pcie->soc;
 	int err;
 
-	/* TODO: disable and unprepare clocks? */
-
 	if (soc->program_uphy) {
 		err = tegra_pcie_phy_power_off(pcie);
 		if (err < 0)
 			dev_err(dev, "failed to power off PHY(s): %d\n", err);
 	}
+}
+
+static void tegra_pcie_power_off(struct tegra_pcie *pcie)
+{
+	struct device *dev = pcie->dev;
+	const struct tegra_pcie_soc *soc = pcie->soc;
+	int err;
 
 	reset_control_assert(pcie->afi_rst);
 	reset_control_assert(pcie->pex_rst);
 
-	if (!dev->pm_domain)
-		tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
+	clk_disable_unprepare(pcie->pll_e);
+	if (soc->has_cml_clk)
+		clk_disable_unprepare(pcie->cml_clk);
+	clk_disable_unprepare(pcie->afi_clk);
+	clk_disable_unprepare(pcie->pex_clk);
 
 	err = regulator_bulk_disable(pcie->num_supplies, pcie->supplies);
 	if (err < 0)
 		dev_warn(dev, "failed to disable regulators: %d\n", err);
+
+	if (!dev->pm_domain)
+		tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
 }
 
 static int tegra_pcie_power_on(struct tegra_pcie *pcie)
@@ -1242,6 +1264,15 @@ static int tegra_pcie_phys_get_legacy(struct tegra_pcie *pcie)
 	return 0;
 }
 
+static void tegra_pcie_phys_put_legacy(struct tegra_pcie *pcie)
+{
+	int err;
+
+	err = phy_exit(pcie->phy);
+	if (err < 0)
+		dev_err(pcie->dev, "failed to teardown PHY: %d\n", err);
+}
+
 static struct phy *devm_of_phy_optional_get_index(struct device *dev,
 						  struct device_node *np,
 						  const char *consumer,
@@ -1295,6 +1326,19 @@ static int tegra_pcie_port_get_phys(struct tegra_pcie_port *port)
 	return 0;
 }
 
+static void tegra_pcie_port_put_phys(struct tegra_pcie_port *port)
+{
+	struct device *dev = port->pcie->dev;
+	unsigned int i;
+	int err;
+
+	for (i = 0; i < port->lanes; i++) {
+		err = phy_exit(port->phys[i]);
+		if (err < 0)
+			dev_err(dev, "failed to teardown PHY#%u: %d\n", i, err);
+	}
+}
+
 static int tegra_pcie_phys_get(struct tegra_pcie *pcie)
 {
 	const struct tegra_pcie_soc *soc = pcie->soc;
@@ -1314,6 +1358,19 @@ static int tegra_pcie_phys_get(struct tegra_pcie *pcie)
 	return 0;
 }
 
+static void tegra_pcie_phys_put(struct tegra_pcie *pcie)
+{
+	const struct tegra_pcie_soc *soc = pcie->soc;
+	struct device_node *np = pcie->dev->of_node;
+	struct tegra_pcie_port *port;
+
+	if (!soc->has_gen2 || of_find_property(np, "phys", NULL) != NULL)
+		tegra_pcie_phys_put_legacy(pcie);
+
+	list_for_each_entry(port, &pcie->ports, list)
+		tegra_pcie_port_put_phys(port);
+}
+
 static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 {
 	struct device *dev = pcie->dev;
@@ -1346,7 +1403,7 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 	err = tegra_pcie_power_on(pcie);
 	if (err) {
 		dev_err(dev, "failed to power up: %d\n", err);
-		return err;
+		goto phys_put;
 	}
 
 	pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads");
@@ -1404,25 +1461,23 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 
 poweroff:
 	tegra_pcie_power_off(pcie);
+phys_put:
+	if (soc->program_uphy)
+		tegra_pcie_phys_put(pcie);
 	return err;
 }
 
 static int tegra_pcie_put_resources(struct tegra_pcie *pcie)
 {
-	struct device *dev = pcie->dev;
 	const struct tegra_pcie_soc *soc = pcie->soc;
-	int err;
 
 	if (pcie->irq > 0)
 		free_irq(pcie->irq, pcie);
 
 	tegra_pcie_power_off(pcie);
 
-	if (soc->program_uphy) {
-		err = phy_exit(pcie->phy);
-		if (err < 0)
-			dev_err(dev, "failed to teardown PHY: %d\n", err);
-	}
+	if (soc->program_uphy)
+		tegra_pcie_phys_put(pcie);
 
 	return 0;
 }
@@ -2351,6 +2406,16 @@ static void tegra_pcie_enable_ports(struct tegra_pcie *pcie)
 	}
 }
 
+static void tegra_pcie_disable_ports(struct tegra_pcie *pcie)
+{
+	struct tegra_pcie_port *port, *tmp;
+
+	reset_control_assert(pcie->pcie_xrst);
+
+	list_for_each_entry_safe(port, tmp, &pcie->ports, list)
+		tegra_pcie_port_disable(port);
+}
+
 static void tegra_pcie_change_link_speed(struct tegra_pcie *pcie,
 					 struct pci_dev *pci_dev)
 {
@@ -2671,7 +2736,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 
 	err = tegra_pcie_request_resources(pcie);
 	if (err)
-		goto put_resources;
+		goto disable_controller;
 
 	/* setup the AFI address translations */
 	tegra_pcie_setup_translations(pcie);
@@ -2680,7 +2745,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 		err = tegra_pcie_enable_msi(pcie);
 		if (err < 0) {
 			dev_err(dev, "failed to enable MSI support: %d\n", err);
-			goto put_resources;
+			goto free_resources;
 		}
 	}
 
@@ -2721,6 +2786,11 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 disable_msi:
 	if (IS_ENABLED(CONFIG_PCI_MSI))
 		tegra_pcie_disable_msi(pcie);
+	tegra_pcie_disable_ports(pcie);
+free_resources:
+	tegra_pcie_free_resources(pcie);
+disable_controller:
+	tegra_pcie_disable_controller(pcie);
 put_resources:
 	tegra_pcie_put_resources(pcie);
 	return err;
-- 
2.1.4

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

* [PATCH 07/10] PCI: tegra: free resources on probe failure
@ 2017-11-24 15:53   ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

tegra_pcie_probe() can fail in multiple instances, this patch takes care
of freeing the resources which are allocated before probe fail.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/pci/host/pci-tegra.c | 102 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 86 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index b52bdd941249..09f52cd569c6 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -681,14 +681,25 @@ static int tegra_pcie_request_resources(struct tegra_pcie *pcie)
 	pci_add_resource(windows, &pcie->busn);
 
 	err = devm_request_pci_bus_resources(dev, windows);
-	if (err < 0)
+	if (err < 0) {
+		pci_free_resource_list(windows);
 		return err;
+	}
 
 	pci_remap_iospace(&pcie->pio, pcie->io.start);
 
 	return 0;
 }
 
+static void tegra_pcie_free_resources(struct tegra_pcie *pcie)
+{
+	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
+	struct list_head *windows = &host->windows;
+
+	pci_unmap_iospace(&pcie->pio);
+	pci_free_resource_list(windows);
+}
+
 static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 {
 	struct pci_host_bridge *host = pci_find_host_bridge(pdev->bus);
@@ -1089,29 +1100,40 @@ static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)
 	return 0;
 }
 
-static void tegra_pcie_power_off(struct tegra_pcie *pcie)
+static void tegra_pcie_disable_controller(struct tegra_pcie *pcie)
 {
 	struct device *dev = pcie->dev;
 	const struct tegra_pcie_soc *soc = pcie->soc;
 	int err;
 
-	/* TODO: disable and unprepare clocks? */
-
 	if (soc->program_uphy) {
 		err = tegra_pcie_phy_power_off(pcie);
 		if (err < 0)
 			dev_err(dev, "failed to power off PHY(s): %d\n", err);
 	}
+}
+
+static void tegra_pcie_power_off(struct tegra_pcie *pcie)
+{
+	struct device *dev = pcie->dev;
+	const struct tegra_pcie_soc *soc = pcie->soc;
+	int err;
 
 	reset_control_assert(pcie->afi_rst);
 	reset_control_assert(pcie->pex_rst);
 
-	if (!dev->pm_domain)
-		tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
+	clk_disable_unprepare(pcie->pll_e);
+	if (soc->has_cml_clk)
+		clk_disable_unprepare(pcie->cml_clk);
+	clk_disable_unprepare(pcie->afi_clk);
+	clk_disable_unprepare(pcie->pex_clk);
 
 	err = regulator_bulk_disable(pcie->num_supplies, pcie->supplies);
 	if (err < 0)
 		dev_warn(dev, "failed to disable regulators: %d\n", err);
+
+	if (!dev->pm_domain)
+		tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
 }
 
 static int tegra_pcie_power_on(struct tegra_pcie *pcie)
@@ -1242,6 +1264,15 @@ static int tegra_pcie_phys_get_legacy(struct tegra_pcie *pcie)
 	return 0;
 }
 
+static void tegra_pcie_phys_put_legacy(struct tegra_pcie *pcie)
+{
+	int err;
+
+	err = phy_exit(pcie->phy);
+	if (err < 0)
+		dev_err(pcie->dev, "failed to teardown PHY: %d\n", err);
+}
+
 static struct phy *devm_of_phy_optional_get_index(struct device *dev,
 						  struct device_node *np,
 						  const char *consumer,
@@ -1295,6 +1326,19 @@ static int tegra_pcie_port_get_phys(struct tegra_pcie_port *port)
 	return 0;
 }
 
+static void tegra_pcie_port_put_phys(struct tegra_pcie_port *port)
+{
+	struct device *dev = port->pcie->dev;
+	unsigned int i;
+	int err;
+
+	for (i = 0; i < port->lanes; i++) {
+		err = phy_exit(port->phys[i]);
+		if (err < 0)
+			dev_err(dev, "failed to teardown PHY#%u: %d\n", i, err);
+	}
+}
+
 static int tegra_pcie_phys_get(struct tegra_pcie *pcie)
 {
 	const struct tegra_pcie_soc *soc = pcie->soc;
@@ -1314,6 +1358,19 @@ static int tegra_pcie_phys_get(struct tegra_pcie *pcie)
 	return 0;
 }
 
+static void tegra_pcie_phys_put(struct tegra_pcie *pcie)
+{
+	const struct tegra_pcie_soc *soc = pcie->soc;
+	struct device_node *np = pcie->dev->of_node;
+	struct tegra_pcie_port *port;
+
+	if (!soc->has_gen2 || of_find_property(np, "phys", NULL) != NULL)
+		tegra_pcie_phys_put_legacy(pcie);
+
+	list_for_each_entry(port, &pcie->ports, list)
+		tegra_pcie_port_put_phys(port);
+}
+
 static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 {
 	struct device *dev = pcie->dev;
@@ -1346,7 +1403,7 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 	err = tegra_pcie_power_on(pcie);
 	if (err) {
 		dev_err(dev, "failed to power up: %d\n", err);
-		return err;
+		goto phys_put;
 	}
 
 	pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads");
@@ -1404,25 +1461,23 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 
 poweroff:
 	tegra_pcie_power_off(pcie);
+phys_put:
+	if (soc->program_uphy)
+		tegra_pcie_phys_put(pcie);
 	return err;
 }
 
 static int tegra_pcie_put_resources(struct tegra_pcie *pcie)
 {
-	struct device *dev = pcie->dev;
 	const struct tegra_pcie_soc *soc = pcie->soc;
-	int err;
 
 	if (pcie->irq > 0)
 		free_irq(pcie->irq, pcie);
 
 	tegra_pcie_power_off(pcie);
 
-	if (soc->program_uphy) {
-		err = phy_exit(pcie->phy);
-		if (err < 0)
-			dev_err(dev, "failed to teardown PHY: %d\n", err);
-	}
+	if (soc->program_uphy)
+		tegra_pcie_phys_put(pcie);
 
 	return 0;
 }
@@ -2351,6 +2406,16 @@ static void tegra_pcie_enable_ports(struct tegra_pcie *pcie)
 	}
 }
 
+static void tegra_pcie_disable_ports(struct tegra_pcie *pcie)
+{
+	struct tegra_pcie_port *port, *tmp;
+
+	reset_control_assert(pcie->pcie_xrst);
+
+	list_for_each_entry_safe(port, tmp, &pcie->ports, list)
+		tegra_pcie_port_disable(port);
+}
+
 static void tegra_pcie_change_link_speed(struct tegra_pcie *pcie,
 					 struct pci_dev *pci_dev)
 {
@@ -2671,7 +2736,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 
 	err = tegra_pcie_request_resources(pcie);
 	if (err)
-		goto put_resources;
+		goto disable_controller;
 
 	/* setup the AFI address translations */
 	tegra_pcie_setup_translations(pcie);
@@ -2680,7 +2745,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 		err = tegra_pcie_enable_msi(pcie);
 		if (err < 0) {
 			dev_err(dev, "failed to enable MSI support: %d\n", err);
-			goto put_resources;
+			goto free_resources;
 		}
 	}
 
@@ -2721,6 +2786,11 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 disable_msi:
 	if (IS_ENABLED(CONFIG_PCI_MSI))
 		tegra_pcie_disable_msi(pcie);
+	tegra_pcie_disable_ports(pcie);
+free_resources:
+	tegra_pcie_free_resources(pcie);
+disable_controller:
+	tegra_pcie_disable_controller(pcie);
 put_resources:
 	tegra_pcie_put_resources(pcie);
 	return err;
-- 
2.1.4

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

* [PATCH 08/10] PCI: tegra: Add loadable kernel module support
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, rjw-LthD3rsA81gm4RdzfppkhA,
	tglx-hfZtesqFncYOwBW4kG4KsQ
  Cc: vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA, Manikanta Maddireddy

Implement remove call back function for Tegra PCIe driver to add
loadable kernel module support. Change PCI_TEGRA config to tristate to
allow pci-tegra driver to build as a module.

Signed-off-by: Manikanta Maddireddy <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/pci/host/Kconfig     |  2 +-
 drivers/pci/host/pci-tegra.c | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig
index b868803792d8..15eb265461b2 100644
--- a/drivers/pci/host/Kconfig
+++ b/drivers/pci/host/Kconfig
@@ -34,7 +34,7 @@ config PCI_FTPCI100
 	default ARCH_GEMINI
 
 config PCI_TEGRA
-	bool "NVIDIA Tegra PCIe controller"
+	tristate "NVIDIA Tegra PCIe controller"
 	depends on ARCH_TEGRA
 	help
 	  Say Y here if you want support for the PCIe host controller found
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 09f52cd569c6..2ff1ac3aefc1 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -35,6 +35,7 @@
 #include <linux/irqdomain.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/module.h>
 #include <linux/msi.h>
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
@@ -2700,6 +2701,12 @@ static int tegra_pcie_debugfs_init(struct tegra_pcie *pcie)
 	return -ENOMEM;
 }
 
+static void tegra_pcie_debugfs_exit(struct tegra_pcie *pcie)
+{
+	debugfs_remove_recursive(pcie->debugfs);
+	pcie->debugfs = NULL;
+}
+
 static int tegra_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -2714,6 +2721,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pcie = pci_host_bridge_priv(host);
+	platform_set_drvdata(pdev, pcie);
 
 	pcie->soc = of_device_get_match_data(dev);
 	INIT_LIST_HEAD(&pcie->buses);
@@ -2796,6 +2804,25 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 	return err;
 }
 
+static int tegra_pcie_remove(struct platform_device *pdev)
+{
+	struct tegra_pcie *pcie = platform_get_drvdata(pdev);
+	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
+
+	if (IS_ENABLED(CONFIG_DEBUG_FS))
+		tegra_pcie_debugfs_exit(pcie);
+	pci_stop_root_bus(host->bus);
+	pci_remove_root_bus(host->bus);
+	if (IS_ENABLED(CONFIG_PCI_MSI))
+		tegra_pcie_disable_msi(pcie);
+	tegra_pcie_disable_ports(pcie);
+	tegra_pcie_free_resources(pcie);
+	tegra_pcie_disable_controller(pcie);
+	tegra_pcie_put_resources(pcie);
+
+	return 0;
+}
+
 static struct platform_driver tegra_pcie_driver = {
 	.driver = {
 		.name = "tegra-pcie",
@@ -2803,5 +2830,7 @@ static struct platform_driver tegra_pcie_driver = {
 		.suppress_bind_attrs = true,
 	},
 	.probe = tegra_pcie_probe,
+	.remove = tegra_pcie_remove,
 };
-builtin_platform_driver(tegra_pcie_driver);
+module_platform_driver(tegra_pcie_driver);
+MODULE_LICENSE("GPL");
-- 
2.1.4

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

* [PATCH 08/10] PCI: tegra: Add loadable kernel module support
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

Implement remove call back function for Tegra PCIe driver to add
loadable kernel module support. Change PCI_TEGRA config to tristate to
allow pci-tegra driver to build as a module.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/pci/host/Kconfig     |  2 +-
 drivers/pci/host/pci-tegra.c | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig
index b868803792d8..15eb265461b2 100644
--- a/drivers/pci/host/Kconfig
+++ b/drivers/pci/host/Kconfig
@@ -34,7 +34,7 @@ config PCI_FTPCI100
 	default ARCH_GEMINI
 
 config PCI_TEGRA
-	bool "NVIDIA Tegra PCIe controller"
+	tristate "NVIDIA Tegra PCIe controller"
 	depends on ARCH_TEGRA
 	help
 	  Say Y here if you want support for the PCIe host controller found
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 09f52cd569c6..2ff1ac3aefc1 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -35,6 +35,7 @@
 #include <linux/irqdomain.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/module.h>
 #include <linux/msi.h>
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
@@ -2700,6 +2701,12 @@ static int tegra_pcie_debugfs_init(struct tegra_pcie *pcie)
 	return -ENOMEM;
 }
 
+static void tegra_pcie_debugfs_exit(struct tegra_pcie *pcie)
+{
+	debugfs_remove_recursive(pcie->debugfs);
+	pcie->debugfs = NULL;
+}
+
 static int tegra_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -2714,6 +2721,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pcie = pci_host_bridge_priv(host);
+	platform_set_drvdata(pdev, pcie);
 
 	pcie->soc = of_device_get_match_data(dev);
 	INIT_LIST_HEAD(&pcie->buses);
@@ -2796,6 +2804,25 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 	return err;
 }
 
+static int tegra_pcie_remove(struct platform_device *pdev)
+{
+	struct tegra_pcie *pcie = platform_get_drvdata(pdev);
+	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
+
+	if (IS_ENABLED(CONFIG_DEBUG_FS))
+		tegra_pcie_debugfs_exit(pcie);
+	pci_stop_root_bus(host->bus);
+	pci_remove_root_bus(host->bus);
+	if (IS_ENABLED(CONFIG_PCI_MSI))
+		tegra_pcie_disable_msi(pcie);
+	tegra_pcie_disable_ports(pcie);
+	tegra_pcie_free_resources(pcie);
+	tegra_pcie_disable_controller(pcie);
+	tegra_pcie_put_resources(pcie);
+
+	return 0;
+}
+
 static struct platform_driver tegra_pcie_driver = {
 	.driver = {
 		.name = "tegra-pcie",
@@ -2803,5 +2830,7 @@ static struct platform_driver tegra_pcie_driver = {
 		.suppress_bind_attrs = true,
 	},
 	.probe = tegra_pcie_probe,
+	.remove = tegra_pcie_remove,
 };
-builtin_platform_driver(tegra_pcie_driver);
+module_platform_driver(tegra_pcie_driver);
+MODULE_LICENSE("GPL");
-- 
2.1.4

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

* [PATCH 09/10] PCI: tegra: Broadcast PME_turn_Off message before link goes to L2
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53   ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

Per PCIe r3.0, sec 5.3.3.2.1, PCIe root port shoould broadcast PME_turn_Off
message before PCIe link goes to L2. PME_turn_Off broadcast mechanism is
implemented in AFI module. Each Tegra PCIe root port has its own
PME_turn_Off and PME_TO_Ack bitmap in AFI_PME register, program this
register to broadcast PME_turn_Off message.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/pci/host/pci-tegra.c | 76 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 2ff1ac3aefc1..af999c650941 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -155,6 +155,8 @@
 #define  AFI_INTR_EN_FPCI_TIMEOUT	(1 << 7)
 #define  AFI_INTR_EN_PRSNT_SENSE	(1 << 8)
 
+#define AFI_PCIE_PME		0xf0
+
 #define AFI_PCIE_CONFIG					0x0f8
 #define  AFI_PCIE_CONFIG_PCIE_DISABLE(x)		(1 << ((x) + 1))
 #define  AFI_PCIE_CONFIG_PCIE_DISABLE_ALL		0xe
@@ -315,6 +317,7 @@
 #define PADS_REFCLK_CFG_DRVI_SHIFT		12 /* 15:12 */
 
 #define LINK_RETRAIN_TIMEOUT 100000
+#define PME_ACK_TIMEOUT 10000
 
 struct tegra_msi {
 	struct msi_controller chip;
@@ -1483,6 +1486,76 @@ static int tegra_pcie_put_resources(struct tegra_pcie *pcie)
 	return 0;
 }
 
+static inline u32 get_pme_turnoff_bitmap(struct tegra_pcie_port *port)
+{
+	struct device *dev = port->pcie->dev;
+	struct device_node *np = dev->of_node;
+	int ret = 0;
+
+	switch (port->index) {
+	case 0:
+		ret = 0;
+	case 1:
+		ret = 8;
+	case 2:
+		if (of_device_is_compatible(np, "nvidia,tegra30-pcie"))
+			ret = 16;
+		else
+			ret = 12;
+	}
+	return ret;
+}
+
+static inline u32 get_pme_ack_bitmap(struct tegra_pcie_port *port)
+{
+	struct device *dev = port->pcie->dev;
+	struct device_node *np = dev->of_node;
+	int ret = 0;
+
+	switch (port->index) {
+	case 0:
+		ret = 5;
+	case 1:
+		ret = 10;
+	case 2:
+		if (of_device_is_compatible(np, "nvidia,tegra30-pcie"))
+			ret = 18;
+		else
+			ret = 14;
+	}
+	return ret;
+}
+
+static void tegra_pcie_pme_turnoff(struct tegra_pcie_port *port)
+{
+	struct tegra_pcie *pcie = port->pcie;
+	ktime_t deadline;
+	unsigned int data;
+
+	data = afi_readl(pcie, AFI_PCIE_PME);
+	data |= (0x1 << get_pme_turnoff_bitmap(port));
+	afi_writel(pcie, data, AFI_PCIE_PME);
+
+	deadline = ktime_add_us(ktime_get(), PME_ACK_TIMEOUT);
+	do {
+		data = afi_readl(pcie, AFI_PCIE_PME);
+		data &= (0x1 << get_pme_ack_bitmap(port));
+		udelay(1);
+		if (ktime_after(ktime_get(), deadline))
+			break;
+	} while (!data);
+
+	if (data)
+		dev_err(pcie->dev, "PME Ack is not receieved on port: %d\n",
+			port->index);
+
+	usleep_range(10000, 11000);
+
+	data = afi_readl(pcie, AFI_PCIE_PME);
+	data &= ~(0x1 << get_pme_turnoff_bitmap(port));
+	afi_writel(pcie, data, AFI_PCIE_PME);
+}
+
 static int tegra_msi_alloc(struct tegra_msi *chip)
 {
 	int msi;
@@ -2808,6 +2881,7 @@ static int tegra_pcie_remove(struct platform_device *pdev)
 {
 	struct tegra_pcie *pcie = platform_get_drvdata(pdev);
 	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
+	struct tegra_pcie_port *port, *tmp;
 
 	if (IS_ENABLED(CONFIG_DEBUG_FS))
 		tegra_pcie_debugfs_exit(pcie);
@@ -2815,6 +2889,8 @@ static int tegra_pcie_remove(struct platform_device *pdev)
 	pci_remove_root_bus(host->bus);
 	if (IS_ENABLED(CONFIG_PCI_MSI))
 		tegra_pcie_disable_msi(pcie);
+	list_for_each_entry_safe(port, tmp, &pcie->ports, list)
+		tegra_pcie_pme_turnoff(port);
 	tegra_pcie_disable_ports(pcie);
 	tegra_pcie_free_resources(pcie);
 	tegra_pcie_disable_controller(pcie);
-- 
2.1.4

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

* [PATCH 09/10] PCI: tegra: Broadcast PME_turn_Off message before link goes to L2
@ 2017-11-24 15:53   ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

Per PCIe r3.0, sec 5.3.3.2.1, PCIe root port shoould broadcast PME_turn_Off
message before PCIe link goes to L2. PME_turn_Off broadcast mechanism is
implemented in AFI module. Each Tegra PCIe root port has its own
PME_turn_Off and PME_TO_Ack bitmap in AFI_PME register, program this
register to broadcast PME_turn_Off message.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/pci/host/pci-tegra.c | 76 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 2ff1ac3aefc1..af999c650941 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -155,6 +155,8 @@
 #define  AFI_INTR_EN_FPCI_TIMEOUT	(1 << 7)
 #define  AFI_INTR_EN_PRSNT_SENSE	(1 << 8)
 
+#define AFI_PCIE_PME		0xf0
+
 #define AFI_PCIE_CONFIG					0x0f8
 #define  AFI_PCIE_CONFIG_PCIE_DISABLE(x)		(1 << ((x) + 1))
 #define  AFI_PCIE_CONFIG_PCIE_DISABLE_ALL		0xe
@@ -315,6 +317,7 @@
 #define PADS_REFCLK_CFG_DRVI_SHIFT		12 /* 15:12 */
 
 #define LINK_RETRAIN_TIMEOUT 100000
+#define PME_ACK_TIMEOUT 10000
 
 struct tegra_msi {
 	struct msi_controller chip;
@@ -1483,6 +1486,76 @@ static int tegra_pcie_put_resources(struct tegra_pcie *pcie)
 	return 0;
 }
 
+static inline u32 get_pme_turnoff_bitmap(struct tegra_pcie_port *port)
+{
+	struct device *dev = port->pcie->dev;
+	struct device_node *np = dev->of_node;
+	int ret = 0;
+
+	switch (port->index) {
+	case 0:
+		ret = 0;
+	case 1:
+		ret = 8;
+	case 2:
+		if (of_device_is_compatible(np, "nvidia,tegra30-pcie"))
+			ret = 16;
+		else
+			ret = 12;
+	}
+	return ret;
+}
+
+static inline u32 get_pme_ack_bitmap(struct tegra_pcie_port *port)
+{
+	struct device *dev = port->pcie->dev;
+	struct device_node *np = dev->of_node;
+	int ret = 0;
+
+	switch (port->index) {
+	case 0:
+		ret = 5;
+	case 1:
+		ret = 10;
+	case 2:
+		if (of_device_is_compatible(np, "nvidia,tegra30-pcie"))
+			ret = 18;
+		else
+			ret = 14;
+	}
+	return ret;
+}
+
+static void tegra_pcie_pme_turnoff(struct tegra_pcie_port *port)
+{
+	struct tegra_pcie *pcie = port->pcie;
+	ktime_t deadline;
+	unsigned int data;
+
+	data = afi_readl(pcie, AFI_PCIE_PME);
+	data |= (0x1 << get_pme_turnoff_bitmap(port));
+	afi_writel(pcie, data, AFI_PCIE_PME);
+
+	deadline = ktime_add_us(ktime_get(), PME_ACK_TIMEOUT);
+	do {
+		data = afi_readl(pcie, AFI_PCIE_PME);
+		data &= (0x1 << get_pme_ack_bitmap(port));
+		udelay(1);
+		if (ktime_after(ktime_get(), deadline))
+			break;
+	} while (!data);
+
+	if (data)
+		dev_err(pcie->dev, "PME Ack is not receieved on port: %d\n",
+			port->index);
+
+	usleep_range(10000, 11000);
+
+	data = afi_readl(pcie, AFI_PCIE_PME);
+	data &= ~(0x1 << get_pme_turnoff_bitmap(port));
+	afi_writel(pcie, data, AFI_PCIE_PME);
+}
+
 static int tegra_msi_alloc(struct tegra_msi *chip)
 {
 	int msi;
@@ -2808,6 +2881,7 @@ static int tegra_pcie_remove(struct platform_device *pdev)
 {
 	struct tegra_pcie *pcie = platform_get_drvdata(pdev);
 	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
+	struct tegra_pcie_port *port, *tmp;
 
 	if (IS_ENABLED(CONFIG_DEBUG_FS))
 		tegra_pcie_debugfs_exit(pcie);
@@ -2815,6 +2889,8 @@ static int tegra_pcie_remove(struct platform_device *pdev)
 	pci_remove_root_bus(host->bus);
 	if (IS_ENABLED(CONFIG_PCI_MSI))
 		tegra_pcie_disable_msi(pcie);
+	list_for_each_entry_safe(port, tmp, &pcie->ports, list)
+		tegra_pcie_pme_turnoff(port);
 	tegra_pcie_disable_ports(pcie);
 	tegra_pcie_free_resources(pcie);
 	tegra_pcie_disable_controller(pcie);
-- 
2.1.4

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

* [PATCH 10/10] PCI: tegra: Add power management support
  2017-11-24 15:53 ` Manikanta Maddireddy
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, rjw-LthD3rsA81gm4RdzfppkhA,
	tglx-hfZtesqFncYOwBW4kG4KsQ
  Cc: vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA, Manikanta Maddireddy

Tegra186 powergate driver is implemented as power domain driver, power
partition ungate/gate are registered as power_on/power_off callback
functions. There are no direct functions to power gate/ungate host
controller in Tegra186. Host controller driver should add "power-domains"
property in device tree and implement runtime suspend and resume
callback functons. Power gate and ungate is taken care by power domain
driver when host controller driver calls pm_runtime_put_sync and
pm_runtime_get_sync respectively.

Register suspend_noirq & resume_noirq callback functions to allow PCIe to
come up after resume from RAM. Both runtime and noirq pm ops share same
callback functions.

Signed-off-by: Manikanta Maddireddy <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/pci/host/pci-tegra.c | 174 ++++++++++++++++++++++++++-----------------
 1 file changed, 106 insertions(+), 68 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index af999c650941..e443b3ebc4b5 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -1404,31 +1404,25 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 		}
 	}
 
-	err = tegra_pcie_power_on(pcie);
-	if (err) {
-		dev_err(dev, "failed to power up: %d\n", err);
-		goto phys_put;
-	}
-
 	pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads");
 	pcie->pads = devm_ioremap_resource(dev, pads);
 	if (IS_ERR(pcie->pads)) {
 		err = PTR_ERR(pcie->pads);
-		goto poweroff;
+		goto phys_put;
 	}
 
 	afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi");
 	pcie->afi = devm_ioremap_resource(dev, afi);
 	if (IS_ERR(pcie->afi)) {
 		err = PTR_ERR(pcie->afi);
-		goto poweroff;
+		goto phys_put;
 	}
 
 	/* request configuration space, but remap later, on demand */
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs");
 	if (!res) {
 		err = -EADDRNOTAVAIL;
-		goto poweroff;
+		goto phys_put;
 	}
 
 	axi_addr = pcie->soc->use_4k_conf_space ?
@@ -1436,21 +1430,21 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 	pcie->cs = devm_request_mem_region(dev, axi_addr, SZ_4K, res->name);
 	if (!pcie->cs) {
 		err = -EADDRNOTAVAIL;
-		goto poweroff;
+		goto phys_put;
 	}
 
 	pcie->cfg_va_base = devm_ioremap(dev, pcie->cs->start, SZ_4K);
 	if (!pcie->cfg_va_base) {
 		dev_err(pcie->dev, "failed to ioremap config space\n");
 		err = -EADDRNOTAVAIL;
-		goto poweroff;
+		goto phys_put;
 	}
 
 	/* request interrupt */
 	err = platform_get_irq_byname(pdev, "intr");
 	if (err < 0) {
 		dev_err(dev, "failed to get IRQ: %d\n", err);
-		goto poweroff;
+		goto phys_put;
 	}
 
 	pcie->irq = err;
@@ -1458,13 +1452,11 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 	err = request_irq(pcie->irq, tegra_pcie_isr, IRQF_SHARED, "PCIE", pcie);
 	if (err) {
 		dev_err(dev, "failed to register IRQ: %d\n", err);
-		goto poweroff;
+		goto phys_put;
 	}
 
 	return 0;
 
-poweroff:
-	tegra_pcie_power_off(pcie);
 phys_put:
 	if (soc->program_uphy)
 		tegra_pcie_phys_put(pcie);
@@ -1478,8 +1470,6 @@ static int tegra_pcie_put_resources(struct tegra_pcie *pcie)
 	if (pcie->irq > 0)
 		free_irq(pcie->irq, pcie);
 
-	tegra_pcie_power_off(pcie);
-
 	if (soc->program_uphy)
 		tegra_pcie_phys_put(pcie);
 
@@ -1702,37 +1692,41 @@ static int tegra_pcie_enable_msi(struct tegra_pcie *pcie)
 	int err;
 	u32 reg;
 
-	mutex_init(&msi->lock);
+	if (!msi->phys) {
+		mutex_init(&msi->lock);
 
-	msi->chip.dev = dev;
-	msi->chip.setup_irq = tegra_msi_setup_irq;
-	msi->chip.teardown_irq = tegra_msi_teardown_irq;
+		msi->chip.dev = dev;
+		msi->chip.setup_irq = tegra_msi_setup_irq;
+		msi->chip.teardown_irq = tegra_msi_teardown_irq;
 
-	msi->domain = irq_domain_add_linear(dev->of_node, INT_PCI_MSI_NR,
-					    &msi_domain_ops, &msi->chip);
-	if (!msi->domain) {
-		dev_err(dev, "failed to create IRQ domain\n");
-		return -ENOMEM;
-	}
+		msi->domain = irq_domain_add_linear(dev->of_node,
+						    INT_PCI_MSI_NR,
+						    &msi_domain_ops,
+						    &msi->chip);
+		if (!msi->domain) {
+			dev_err(dev, "failed to create IRQ domain\n");
+			return -ENOMEM;
+		}
 
-	err = platform_get_irq_byname(pdev, "msi");
-	if (err < 0) {
-		dev_err(dev, "failed to get IRQ: %d\n", err);
-		goto err;
-	}
+		err = platform_get_irq_byname(pdev, "msi");
+		if (err < 0) {
+			dev_err(dev, "failed to get IRQ: %d\n", err);
+			goto err;
+		}
 
-	msi->irq = err;
+		msi->irq = err;
 
-	err = request_irq(msi->irq, tegra_pcie_msi_irq, IRQF_NO_THREAD,
-			  tegra_msi_irq_chip.name, pcie);
-	if (err < 0) {
-		dev_err(dev, "failed to request IRQ: %d\n", err);
-		goto err;
-	}
+		err = request_irq(msi->irq, tegra_pcie_msi_irq, IRQF_NO_THREAD,
+				  tegra_msi_irq_chip.name, pcie);
+		if (err < 0) {
+			dev_err(dev, "failed to request IRQ: %d\n", err);
+			goto err;
+		}
 
-	/* setup AFI/FPCI range */
-	msi->pages = __get_free_pages(GFP_KERNEL, 0);
-	msi->phys = virt_to_phys((void *)msi->pages);
+		/* setup AFI/FPCI range */
+		msi->pages = __get_free_pages(GFP_KERNEL, 0);
+		msi->phys = virt_to_phys((void *)msi->pages);
+	}
 
 	afi_writel(pcie, msi->phys >> soc->msi_base_shift, AFI_MSI_FPCI_BAR_ST);
 	afi_writel(pcie, msi->phys, AFI_MSI_AXI_BAR_ST);
@@ -2811,26 +2805,16 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	err = tegra_pcie_enable_controller(pcie);
-	if (err)
+	pm_runtime_enable(pcie->dev);
+	err = pm_runtime_get_sync(pcie->dev);
+	if (err) {
+		dev_err(dev, "fail to enable pcie controller: %d\n", err);
 		goto put_resources;
+	}
 
 	err = tegra_pcie_request_resources(pcie);
 	if (err)
-		goto disable_controller;
-
-	/* setup the AFI address translations */
-	tegra_pcie_setup_translations(pcie);
-
-	if (IS_ENABLED(CONFIG_PCI_MSI)) {
-		err = tegra_pcie_enable_msi(pcie);
-		if (err < 0) {
-			dev_err(dev, "failed to enable MSI support: %d\n", err);
-			goto free_resources;
-		}
-	}
-
-	tegra_pcie_enable_ports(pcie);
+		goto pm_runtime_put;
 
 	pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS);
 	host->busnr = pcie->busn.start;
@@ -2842,7 +2826,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 	err = pci_scan_root_bus_bridge(host);
 	if (err < 0) {
 		dev_err(dev, "failed to register host: %d\n", err);
-		goto disable_msi;
+		goto free_resources;
 	}
 
 	pci_bus_size_bridges(host->bus);
@@ -2864,14 +2848,13 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 
 	return 0;
 
-disable_msi:
-	if (IS_ENABLED(CONFIG_PCI_MSI))
-		tegra_pcie_disable_msi(pcie);
-	tegra_pcie_disable_ports(pcie);
 free_resources:
 	tegra_pcie_free_resources(pcie);
-disable_controller:
-	tegra_pcie_disable_controller(pcie);
+pm_runtime_put:
+	if (IS_ENABLED(CONFIG_PCI_MSI))
+		tegra_pcie_disable_msi(pcie);
+	pm_runtime_put_sync(pcie->dev);
+	pm_runtime_disable(pcie->dev);
 put_resources:
 	tegra_pcie_put_resources(pcie);
 	return err;
@@ -2881,7 +2864,6 @@ static int tegra_pcie_remove(struct platform_device *pdev)
 {
 	struct tegra_pcie *pcie = platform_get_drvdata(pdev);
 	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
-	struct tegra_pcie_port *port, *tmp;
 
 	if (IS_ENABLED(CONFIG_DEBUG_FS))
 		tegra_pcie_debugfs_exit(pcie);
@@ -2889,21 +2871,77 @@ static int tegra_pcie_remove(struct platform_device *pdev)
 	pci_remove_root_bus(host->bus);
 	if (IS_ENABLED(CONFIG_PCI_MSI))
 		tegra_pcie_disable_msi(pcie);
+	tegra_pcie_free_resources(pcie);
+	pm_runtime_put_sync(pcie->dev);
+	pm_runtime_disable(pcie->dev);
+	tegra_pcie_put_resources(pcie);
+
+	return 0;
+}
+
+static int tegra_pcie_pm_suspend(struct device *dev)
+{
+	struct tegra_pcie *pcie = dev_get_drvdata(dev);
+	struct tegra_pcie_port *port, *tmp;
+
 	list_for_each_entry_safe(port, tmp, &pcie->ports, list)
 		tegra_pcie_pme_turnoff(port);
 	tegra_pcie_disable_ports(pcie);
-	tegra_pcie_free_resources(pcie);
 	tegra_pcie_disable_controller(pcie);
-	tegra_pcie_put_resources(pcie);
+	tegra_pcie_power_off(pcie);
 
 	return 0;
 }
 
+static int tegra_pcie_pm_resume(struct device *dev)
+{
+	struct tegra_pcie *pcie = dev_get_drvdata(dev);
+	int err;
+
+	err = tegra_pcie_power_on(pcie);
+	if (err) {
+		dev_err(dev, "tegra pcie power on fail: %d\n", err);
+		return err;
+	}
+	err = tegra_pcie_enable_controller(pcie);
+	if (err) {
+		dev_err(dev, "tegra pcie controller enable fail: %d\n", err);
+		goto poweroff;
+	}
+	tegra_pcie_setup_translations(pcie);
+
+	if (IS_ENABLED(CONFIG_PCI_MSI)) {
+		err = tegra_pcie_enable_msi(pcie);
+		if (err < 0) {
+			dev_err(dev, "failed to enable MSI support: %d\n", err);
+			goto disable_controller;
+		}
+	}
+
+	tegra_pcie_enable_ports(pcie);
+
+	return 0;
+
+disable_controller:
+	tegra_pcie_disable_controller(pcie);
+poweroff:
+	tegra_pcie_power_off(pcie);
+
+	return err;
+}
+
+static const struct dev_pm_ops tegra_pcie_pm_ops = {
+	SET_RUNTIME_PM_OPS(tegra_pcie_pm_suspend, tegra_pcie_pm_resume, NULL)
+	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(tegra_pcie_pm_suspend,
+				      tegra_pcie_pm_resume)
+};
+
 static struct platform_driver tegra_pcie_driver = {
 	.driver = {
 		.name = "tegra-pcie",
 		.of_match_table = tegra_pcie_of_match,
 		.suppress_bind_attrs = true,
+		.pm = &tegra_pcie_pm_ops,
 	},
 	.probe = tegra_pcie_probe,
 	.remove = tegra_pcie_remove,
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 10/10] PCI: tegra: Add power management support
@ 2017-11-24 15:53     ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-24 15:53 UTC (permalink / raw)
  To: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw, tglx
  Cc: vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Manikanta Maddireddy

Tegra186 powergate driver is implemented as power domain driver, power
partition ungate/gate are registered as power_on/power_off callback
functions. There are no direct functions to power gate/ungate host
controller in Tegra186. Host controller driver should add "power-domains"
property in device tree and implement runtime suspend and resume
callback functons. Power gate and ungate is taken care by power domain
driver when host controller driver calls pm_runtime_put_sync and
pm_runtime_get_sync respectively.

Register suspend_noirq & resume_noirq callback functions to allow PCIe to
come up after resume from RAM. Both runtime and noirq pm ops share same
callback functions.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
---
 drivers/pci/host/pci-tegra.c | 174 ++++++++++++++++++++++++++-----------------
 1 file changed, 106 insertions(+), 68 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index af999c650941..e443b3ebc4b5 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -1404,31 +1404,25 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 		}
 	}
 
-	err = tegra_pcie_power_on(pcie);
-	if (err) {
-		dev_err(dev, "failed to power up: %d\n", err);
-		goto phys_put;
-	}
-
 	pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads");
 	pcie->pads = devm_ioremap_resource(dev, pads);
 	if (IS_ERR(pcie->pads)) {
 		err = PTR_ERR(pcie->pads);
-		goto poweroff;
+		goto phys_put;
 	}
 
 	afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi");
 	pcie->afi = devm_ioremap_resource(dev, afi);
 	if (IS_ERR(pcie->afi)) {
 		err = PTR_ERR(pcie->afi);
-		goto poweroff;
+		goto phys_put;
 	}
 
 	/* request configuration space, but remap later, on demand */
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs");
 	if (!res) {
 		err = -EADDRNOTAVAIL;
-		goto poweroff;
+		goto phys_put;
 	}
 
 	axi_addr = pcie->soc->use_4k_conf_space ?
@@ -1436,21 +1430,21 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 	pcie->cs = devm_request_mem_region(dev, axi_addr, SZ_4K, res->name);
 	if (!pcie->cs) {
 		err = -EADDRNOTAVAIL;
-		goto poweroff;
+		goto phys_put;
 	}
 
 	pcie->cfg_va_base = devm_ioremap(dev, pcie->cs->start, SZ_4K);
 	if (!pcie->cfg_va_base) {
 		dev_err(pcie->dev, "failed to ioremap config space\n");
 		err = -EADDRNOTAVAIL;
-		goto poweroff;
+		goto phys_put;
 	}
 
 	/* request interrupt */
 	err = platform_get_irq_byname(pdev, "intr");
 	if (err < 0) {
 		dev_err(dev, "failed to get IRQ: %d\n", err);
-		goto poweroff;
+		goto phys_put;
 	}
 
 	pcie->irq = err;
@@ -1458,13 +1452,11 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 	err = request_irq(pcie->irq, tegra_pcie_isr, IRQF_SHARED, "PCIE", pcie);
 	if (err) {
 		dev_err(dev, "failed to register IRQ: %d\n", err);
-		goto poweroff;
+		goto phys_put;
 	}
 
 	return 0;
 
-poweroff:
-	tegra_pcie_power_off(pcie);
 phys_put:
 	if (soc->program_uphy)
 		tegra_pcie_phys_put(pcie);
@@ -1478,8 +1470,6 @@ static int tegra_pcie_put_resources(struct tegra_pcie *pcie)
 	if (pcie->irq > 0)
 		free_irq(pcie->irq, pcie);
 
-	tegra_pcie_power_off(pcie);
-
 	if (soc->program_uphy)
 		tegra_pcie_phys_put(pcie);
 
@@ -1702,37 +1692,41 @@ static int tegra_pcie_enable_msi(struct tegra_pcie *pcie)
 	int err;
 	u32 reg;
 
-	mutex_init(&msi->lock);
+	if (!msi->phys) {
+		mutex_init(&msi->lock);
 
-	msi->chip.dev = dev;
-	msi->chip.setup_irq = tegra_msi_setup_irq;
-	msi->chip.teardown_irq = tegra_msi_teardown_irq;
+		msi->chip.dev = dev;
+		msi->chip.setup_irq = tegra_msi_setup_irq;
+		msi->chip.teardown_irq = tegra_msi_teardown_irq;
 
-	msi->domain = irq_domain_add_linear(dev->of_node, INT_PCI_MSI_NR,
-					    &msi_domain_ops, &msi->chip);
-	if (!msi->domain) {
-		dev_err(dev, "failed to create IRQ domain\n");
-		return -ENOMEM;
-	}
+		msi->domain = irq_domain_add_linear(dev->of_node,
+						    INT_PCI_MSI_NR,
+						    &msi_domain_ops,
+						    &msi->chip);
+		if (!msi->domain) {
+			dev_err(dev, "failed to create IRQ domain\n");
+			return -ENOMEM;
+		}
 
-	err = platform_get_irq_byname(pdev, "msi");
-	if (err < 0) {
-		dev_err(dev, "failed to get IRQ: %d\n", err);
-		goto err;
-	}
+		err = platform_get_irq_byname(pdev, "msi");
+		if (err < 0) {
+			dev_err(dev, "failed to get IRQ: %d\n", err);
+			goto err;
+		}
 
-	msi->irq = err;
+		msi->irq = err;
 
-	err = request_irq(msi->irq, tegra_pcie_msi_irq, IRQF_NO_THREAD,
-			  tegra_msi_irq_chip.name, pcie);
-	if (err < 0) {
-		dev_err(dev, "failed to request IRQ: %d\n", err);
-		goto err;
-	}
+		err = request_irq(msi->irq, tegra_pcie_msi_irq, IRQF_NO_THREAD,
+				  tegra_msi_irq_chip.name, pcie);
+		if (err < 0) {
+			dev_err(dev, "failed to request IRQ: %d\n", err);
+			goto err;
+		}
 
-	/* setup AFI/FPCI range */
-	msi->pages = __get_free_pages(GFP_KERNEL, 0);
-	msi->phys = virt_to_phys((void *)msi->pages);
+		/* setup AFI/FPCI range */
+		msi->pages = __get_free_pages(GFP_KERNEL, 0);
+		msi->phys = virt_to_phys((void *)msi->pages);
+	}
 
 	afi_writel(pcie, msi->phys >> soc->msi_base_shift, AFI_MSI_FPCI_BAR_ST);
 	afi_writel(pcie, msi->phys, AFI_MSI_AXI_BAR_ST);
@@ -2811,26 +2805,16 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	err = tegra_pcie_enable_controller(pcie);
-	if (err)
+	pm_runtime_enable(pcie->dev);
+	err = pm_runtime_get_sync(pcie->dev);
+	if (err) {
+		dev_err(dev, "fail to enable pcie controller: %d\n", err);
 		goto put_resources;
+	}
 
 	err = tegra_pcie_request_resources(pcie);
 	if (err)
-		goto disable_controller;
-
-	/* setup the AFI address translations */
-	tegra_pcie_setup_translations(pcie);
-
-	if (IS_ENABLED(CONFIG_PCI_MSI)) {
-		err = tegra_pcie_enable_msi(pcie);
-		if (err < 0) {
-			dev_err(dev, "failed to enable MSI support: %d\n", err);
-			goto free_resources;
-		}
-	}
-
-	tegra_pcie_enable_ports(pcie);
+		goto pm_runtime_put;
 
 	pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS);
 	host->busnr = pcie->busn.start;
@@ -2842,7 +2826,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 	err = pci_scan_root_bus_bridge(host);
 	if (err < 0) {
 		dev_err(dev, "failed to register host: %d\n", err);
-		goto disable_msi;
+		goto free_resources;
 	}
 
 	pci_bus_size_bridges(host->bus);
@@ -2864,14 +2848,13 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 
 	return 0;
 
-disable_msi:
-	if (IS_ENABLED(CONFIG_PCI_MSI))
-		tegra_pcie_disable_msi(pcie);
-	tegra_pcie_disable_ports(pcie);
 free_resources:
 	tegra_pcie_free_resources(pcie);
-disable_controller:
-	tegra_pcie_disable_controller(pcie);
+pm_runtime_put:
+	if (IS_ENABLED(CONFIG_PCI_MSI))
+		tegra_pcie_disable_msi(pcie);
+	pm_runtime_put_sync(pcie->dev);
+	pm_runtime_disable(pcie->dev);
 put_resources:
 	tegra_pcie_put_resources(pcie);
 	return err;
@@ -2881,7 +2864,6 @@ static int tegra_pcie_remove(struct platform_device *pdev)
 {
 	struct tegra_pcie *pcie = platform_get_drvdata(pdev);
 	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
-	struct tegra_pcie_port *port, *tmp;
 
 	if (IS_ENABLED(CONFIG_DEBUG_FS))
 		tegra_pcie_debugfs_exit(pcie);
@@ -2889,21 +2871,77 @@ static int tegra_pcie_remove(struct platform_device *pdev)
 	pci_remove_root_bus(host->bus);
 	if (IS_ENABLED(CONFIG_PCI_MSI))
 		tegra_pcie_disable_msi(pcie);
+	tegra_pcie_free_resources(pcie);
+	pm_runtime_put_sync(pcie->dev);
+	pm_runtime_disable(pcie->dev);
+	tegra_pcie_put_resources(pcie);
+
+	return 0;
+}
+
+static int tegra_pcie_pm_suspend(struct device *dev)
+{
+	struct tegra_pcie *pcie = dev_get_drvdata(dev);
+	struct tegra_pcie_port *port, *tmp;
+
 	list_for_each_entry_safe(port, tmp, &pcie->ports, list)
 		tegra_pcie_pme_turnoff(port);
 	tegra_pcie_disable_ports(pcie);
-	tegra_pcie_free_resources(pcie);
 	tegra_pcie_disable_controller(pcie);
-	tegra_pcie_put_resources(pcie);
+	tegra_pcie_power_off(pcie);
 
 	return 0;
 }
 
+static int tegra_pcie_pm_resume(struct device *dev)
+{
+	struct tegra_pcie *pcie = dev_get_drvdata(dev);
+	int err;
+
+	err = tegra_pcie_power_on(pcie);
+	if (err) {
+		dev_err(dev, "tegra pcie power on fail: %d\n", err);
+		return err;
+	}
+	err = tegra_pcie_enable_controller(pcie);
+	if (err) {
+		dev_err(dev, "tegra pcie controller enable fail: %d\n", err);
+		goto poweroff;
+	}
+	tegra_pcie_setup_translations(pcie);
+
+	if (IS_ENABLED(CONFIG_PCI_MSI)) {
+		err = tegra_pcie_enable_msi(pcie);
+		if (err < 0) {
+			dev_err(dev, "failed to enable MSI support: %d\n", err);
+			goto disable_controller;
+		}
+	}
+
+	tegra_pcie_enable_ports(pcie);
+
+	return 0;
+
+disable_controller:
+	tegra_pcie_disable_controller(pcie);
+poweroff:
+	tegra_pcie_power_off(pcie);
+
+	return err;
+}
+
+static const struct dev_pm_ops tegra_pcie_pm_ops = {
+	SET_RUNTIME_PM_OPS(tegra_pcie_pm_suspend, tegra_pcie_pm_resume, NULL)
+	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(tegra_pcie_pm_suspend,
+				      tegra_pcie_pm_resume)
+};
+
 static struct platform_driver tegra_pcie_driver = {
 	.driver = {
 		.name = "tegra-pcie",
 		.of_match_table = tegra_pcie_of_match,
 		.suppress_bind_attrs = true,
+		.pm = &tegra_pcie_pm_ops,
 	},
 	.probe = tegra_pcie_probe,
 	.remove = tegra_pcie_remove,
-- 
2.1.4

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

* Re: [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices
  2017-11-24 15:53     ` Manikanta Maddireddy
  (?)
@ 2017-11-24 16:50     ` Rafael J. Wysocki
       [not found]       ` <CAJZ5v0ghcwSHdrbZd_=XA=tHz7=aTUVd66dHkMYRNyXpnqP84w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  -1 siblings, 1 reply; 39+ messages in thread
From: Rafael J. Wysocki @ 2017-11-24 16:50 UTC (permalink / raw)
  To: Manikanta Maddireddy
  Cc: Thierry Reding, Jon Hunter, Rob Herring, Frank Rowand,
	Bjorn Helgaas, Rafael J. Wysocki, Thomas Gleixner, vidyas,
	kthota, linux-tegra, devicetree, Linux PCI, Linux PM

On Fri, Nov 24, 2017 at 4:53 PM, Manikanta Maddireddy
<mmaddireddy@nvidia.com> wrote:
> In 'commit 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")'
> PM QoS resume latency modified 0 as "no latency at all". However
> dev_pm_qos_raw_read_value() returns 0 for devices which doesn't have
> PM QoS constraints. This is blocking runtime suspend for these devices
> in rpm_check_suspend_allowed(). Return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
> when PM QoS constraints are not available for a particular device.
>
> Fixes: 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")

That commit has been reverted, so this patch is not applicable and
therefore the whole series isn't.

What kernel is it based off?

Thanks,
Rafael

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

* Re: [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices
  2017-11-24 16:50     ` Rafael J. Wysocki
@ 2017-11-24 20:39           ` Thierry Reding
  0 siblings, 0 replies; 39+ messages in thread
From: Thierry Reding @ 2017-11-24 20:39 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Manikanta Maddireddy, Jon Hunter, Rob Herring, Frank Rowand,
	Bjorn Helgaas, Rafael J. Wysocki, Thomas Gleixner,
	vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Linux PCI, Linux PM

[-- Attachment #1: Type: text/plain, Size: 1385 bytes --]

On Fri, Nov 24, 2017 at 05:50:42PM +0100, Rafael J. Wysocki wrote:
> On Fri, Nov 24, 2017 at 4:53 PM, Manikanta Maddireddy
> <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
> > In 'commit 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")'
> > PM QoS resume latency modified 0 as "no latency at all". However
> > dev_pm_qos_raw_read_value() returns 0 for devices which doesn't have
> > PM QoS constraints. This is blocking runtime suspend for these devices
> > in rpm_check_suspend_allowed(). Return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
> > when PM QoS constraints are not available for a particular device.
> >
> > Fixes: 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")
> 
> That commit has been reverted, so this patch is not applicable and
> therefore the whole series isn't.
> 
> What kernel is it based off?

It looks like this might have crept in via commit 0759e80b84e3 ("PM /
QoS: Fix device resume latency framework"). But checking more closely,
that commit actually incorporates this change already.

According to the git log the correct commit for this showed up in
linux-next only today, which is probably why Manikanta missed it.

Manikanta: can you try rebasing your series on top of next-20171124?
git should notice that this particular change is already part of that
and drop it during the rebase.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices
@ 2017-11-24 20:39           ` Thierry Reding
  0 siblings, 0 replies; 39+ messages in thread
From: Thierry Reding @ 2017-11-24 20:39 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Manikanta Maddireddy, Jon Hunter, Rob Herring, Frank Rowand,
	Bjorn Helgaas, Rafael J. Wysocki, Thomas Gleixner, vidyas,
	kthota, linux-tegra, devicetree, Linux PCI, Linux PM

[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]

On Fri, Nov 24, 2017 at 05:50:42PM +0100, Rafael J. Wysocki wrote:
> On Fri, Nov 24, 2017 at 4:53 PM, Manikanta Maddireddy
> <mmaddireddy@nvidia.com> wrote:
> > In 'commit 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")'
> > PM QoS resume latency modified 0 as "no latency at all". However
> > dev_pm_qos_raw_read_value() returns 0 for devices which doesn't have
> > PM QoS constraints. This is blocking runtime suspend for these devices
> > in rpm_check_suspend_allowed(). Return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
> > when PM QoS constraints are not available for a particular device.
> >
> > Fixes: 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")
> 
> That commit has been reverted, so this patch is not applicable and
> therefore the whole series isn't.
> 
> What kernel is it based off?

It looks like this might have crept in via commit 0759e80b84e3 ("PM /
QoS: Fix device resume latency framework"). But checking more closely,
that commit actually incorporates this change already.

According to the git log the correct commit for this showed up in
linux-next only today, which is probably why Manikanta missed it.

Manikanta: can you try rebasing your series on top of next-20171124?
git should notice that this particular change is already part of that
and drop it during the rebase.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 01/10] genirq: Export irq_set_msi_desc()
  2017-11-24 15:53     ` Manikanta Maddireddy
  (?)
@ 2017-11-24 23:55     ` Thomas Gleixner
  2017-11-25 19:41         ` Manikanta Maddireddy
  -1 siblings, 1 reply; 39+ messages in thread
From: Thomas Gleixner @ 2017-11-24 23:55 UTC (permalink / raw)
  To: Manikanta Maddireddy
  Cc: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw,
	vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Marc Zyngier

On Fri, 24 Nov 2017, Manikanta Maddireddy wrote:

Please CC the proper mailing list for irq related changes.

> PCI bus support MSI interrupts, allow PCI host driver to set MSI descriptor
> data for an irq.

This is not really an explanation why this export is needed.

Thanks,

	tglx

> 
> Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
> ---
>  kernel/irq/chip.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
> index 5a2ef92c2782..bfbd17386bc4 100644
> --- a/kernel/irq/chip.c
> +++ b/kernel/irq/chip.c
> @@ -136,6 +136,7 @@ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
>  {
>  	return irq_set_msi_desc_off(irq, 0, entry);
>  }
> +EXPORT_SYMBOL(irq_set_msi_desc);
>  
>  /**
>   *	irq_set_chip_data - set irq chip data for an irq
> -- 
> 2.1.4
> 
> 

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

* Re: [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices
  2017-11-24 20:39           ` Thierry Reding
@ 2017-11-25  0:02             ` Rafael J. Wysocki
  -1 siblings, 0 replies; 39+ messages in thread
From: Rafael J. Wysocki @ 2017-11-25  0:02 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Rafael J. Wysocki, Manikanta Maddireddy, Jon Hunter, Rob Herring,
	Frank Rowand, Bjorn Helgaas, Rafael J. Wysocki, Thomas Gleixner,
	vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Linux PCI, Linux PM

On Fri, Nov 24, 2017 at 9:39 PM, Thierry Reding
<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On Fri, Nov 24, 2017 at 05:50:42PM +0100, Rafael J. Wysocki wrote:
>> On Fri, Nov 24, 2017 at 4:53 PM, Manikanta Maddireddy
>> <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>> > In 'commit 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")'
>> > PM QoS resume latency modified 0 as "no latency at all". However
>> > dev_pm_qos_raw_read_value() returns 0 for devices which doesn't have
>> > PM QoS constraints. This is blocking runtime suspend for these devices
>> > in rpm_check_suspend_allowed(). Return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
>> > when PM QoS constraints are not available for a particular device.
>> >
>> > Fixes: 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")
>>
>> That commit has been reverted, so this patch is not applicable and
>> therefore the whole series isn't.
>>
>> What kernel is it based off?
>
> It looks like this might have crept in via commit 0759e80b84e3 ("PM /
> QoS: Fix device resume latency framework"). But checking more closely,
> that commit actually incorporates this change already.
>
> According to the git log the correct commit for this showed up in
> linux-next only today, which is probably why Manikanta missed it.

Well, it's been in the Linus' tree for a week, though.

Thanks,
Rafael

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

* Re: [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices
@ 2017-11-25  0:02             ` Rafael J. Wysocki
  0 siblings, 0 replies; 39+ messages in thread
From: Rafael J. Wysocki @ 2017-11-25  0:02 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Rafael J. Wysocki, Manikanta Maddireddy, Jon Hunter, Rob Herring,
	Frank Rowand, Bjorn Helgaas, Rafael J. Wysocki, Thomas Gleixner,
	vidyas, kthota, linux-tegra, devicetree, Linux PCI, Linux PM

On Fri, Nov 24, 2017 at 9:39 PM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> On Fri, Nov 24, 2017 at 05:50:42PM +0100, Rafael J. Wysocki wrote:
>> On Fri, Nov 24, 2017 at 4:53 PM, Manikanta Maddireddy
>> <mmaddireddy@nvidia.com> wrote:
>> > In 'commit 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")'
>> > PM QoS resume latency modified 0 as "no latency at all". However
>> > dev_pm_qos_raw_read_value() returns 0 for devices which doesn't have
>> > PM QoS constraints. This is blocking runtime suspend for these devices
>> > in rpm_check_suspend_allowed(). Return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
>> > when PM QoS constraints are not available for a particular device.
>> >
>> > Fixes: 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")
>>
>> That commit has been reverted, so this patch is not applicable and
>> therefore the whole series isn't.
>>
>> What kernel is it based off?
>
> It looks like this might have crept in via commit 0759e80b84e3 ("PM /
> QoS: Fix device resume latency framework"). But checking more closely,
> that commit actually incorporates this change already.
>
> According to the git log the correct commit for this showed up in
> linux-next only today, which is probably why Manikanta missed it.

Well, it's been in the Linus' tree for a week, though.

Thanks,
Rafael

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

* Re: [PATCH 01/10] genirq: Export irq_set_msi_desc()
  2017-11-24 23:55     ` Thomas Gleixner
@ 2017-11-25 19:41         ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-25 19:41 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, rjw-LthD3rsA81gm4RdzfppkhA,
	vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA, Marc Zyngier



On 25-Nov-17 5:25 AM, Thomas Gleixner wrote:
> On Fri, 24 Nov 2017, Manikanta Maddireddy wrote:
> 
> Please CC the proper mailing list for irq related changes.
> 
>> PCI bus support MSI interrupts, allow PCI host driver to set MSI descriptor
>> data for an irq.
> 
> This is not really an explanation why this export is needed.
> 
> Thanks,
> 
> 	tglx
> 
Updated the commit log with why Tegra PCIe driver is using this function in V2.
Please review.
>>
>> Signed-off-by: Manikanta Maddireddy <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>> ---
>>  kernel/irq/chip.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
>> index 5a2ef92c2782..bfbd17386bc4 100644
>> --- a/kernel/irq/chip.c
>> +++ b/kernel/irq/chip.c
>> @@ -136,6 +136,7 @@ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
>>  {
>>  	return irq_set_msi_desc_off(irq, 0, entry);
>>  }
>> +EXPORT_SYMBOL(irq_set_msi_desc);
>>  
>>  /**
>>   *	irq_set_chip_data - set irq chip data for an irq
>> -- 
>> 2.1.4
>>
>>

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

* Re: [PATCH 01/10] genirq: Export irq_set_msi_desc()
@ 2017-11-25 19:41         ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-25 19:41 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw,
	vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm,
	Marc Zyngier



On 25-Nov-17 5:25 AM, Thomas Gleixner wrote:
> On Fri, 24 Nov 2017, Manikanta Maddireddy wrote:
> 
> Please CC the proper mailing list for irq related changes.
> 
>> PCI bus support MSI interrupts, allow PCI host driver to set MSI descriptor
>> data for an irq.
> 
> This is not really an explanation why this export is needed.
> 
> Thanks,
> 
> 	tglx
> 
Updated the commit log with why Tegra PCIe driver is using this function in V2.
Please review.
>>
>> Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
>> ---
>>  kernel/irq/chip.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
>> index 5a2ef92c2782..bfbd17386bc4 100644
>> --- a/kernel/irq/chip.c
>> +++ b/kernel/irq/chip.c
>> @@ -136,6 +136,7 @@ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
>>  {
>>  	return irq_set_msi_desc_off(irq, 0, entry);
>>  }
>> +EXPORT_SYMBOL(irq_set_msi_desc);
>>  
>>  /**
>>   *	irq_set_chip_data - set irq chip data for an irq
>> -- 
>> 2.1.4
>>
>>

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

* Re: [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices
  2017-11-25  0:02             ` Rafael J. Wysocki
@ 2017-11-25 19:46                 ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-25 19:46 UTC (permalink / raw)
  To: Rafael J. Wysocki, Thierry Reding
  Cc: Jon Hunter, Rob Herring, Frank Rowand, Bjorn Helgaas,
	Rafael J. Wysocki, Thomas Gleixner,
	vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Linux PCI, Linux PM



On 25-Nov-17 5:32 AM, Rafael J. Wysocki wrote:
> On Fri, Nov 24, 2017 at 9:39 PM, Thierry Reding
> <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> On Fri, Nov 24, 2017 at 05:50:42PM +0100, Rafael J. Wysocki wrote:
>>> On Fri, Nov 24, 2017 at 4:53 PM, Manikanta Maddireddy
>>> <mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>>>> In 'commit 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")'
>>>> PM QoS resume latency modified 0 as "no latency at all". However
>>>> dev_pm_qos_raw_read_value() returns 0 for devices which doesn't have
>>>> PM QoS constraints. This is blocking runtime suspend for these devices
>>>> in rpm_check_suspend_allowed(). Return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
>>>> when PM QoS constraints are not available for a particular device.
>>>>
>>>> Fixes: 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")
>>>
>>> That commit has been reverted, so this patch is not applicable and
>>> therefore the whole series isn't.
>>>
>>> What kernel is it based off?
>>
>> It looks like this might have crept in via commit 0759e80b84e3 ("PM /
>> QoS: Fix device resume latency framework"). But checking more closely,
>> that commit actually incorporates this change already.
>>
>> According to the git log the correct commit for this showed up in
>> linux-next only today, which is probably why Manikanta missed it.
> 
> Well, it's been in the Linus' tree for a week, though.
> 
> Thanks,
> Rafael
> 
I dropped this patch in V2.

Thanks,
Manikanta
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices
@ 2017-11-25 19:46                 ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-25 19:46 UTC (permalink / raw)
  To: Rafael J. Wysocki, Thierry Reding
  Cc: Jon Hunter, Rob Herring, Frank Rowand, Bjorn Helgaas,
	Rafael J. Wysocki, Thomas Gleixner, vidyas, kthota, linux-tegra,
	devicetree, Linux PCI, Linux PM



On 25-Nov-17 5:32 AM, Rafael J. Wysocki wrote:
> On Fri, Nov 24, 2017 at 9:39 PM, Thierry Reding
> <thierry.reding@gmail.com> wrote:
>> On Fri, Nov 24, 2017 at 05:50:42PM +0100, Rafael J. Wysocki wrote:
>>> On Fri, Nov 24, 2017 at 4:53 PM, Manikanta Maddireddy
>>> <mmaddireddy@nvidia.com> wrote:
>>>> In 'commit 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")'
>>>> PM QoS resume latency modified 0 as "no latency at all". However
>>>> dev_pm_qos_raw_read_value() returns 0 for devices which doesn't have
>>>> PM QoS constraints. This is blocking runtime suspend for these devices
>>>> in rpm_check_suspend_allowed(). Return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
>>>> when PM QoS constraints are not available for a particular device.
>>>>
>>>> Fixes: 0cc2b4e5a020 ("PM / QoS: Fix device resume latency PM QoS")
>>>
>>> That commit has been reverted, so this patch is not applicable and
>>> therefore the whole series isn't.
>>>
>>> What kernel is it based off?
>>
>> It looks like this might have crept in via commit 0759e80b84e3 ("PM /
>> QoS: Fix device resume latency framework"). But checking more closely,
>> that commit actually incorporates this change already.
>>
>> According to the git log the correct commit for this showed up in
>> linux-next only today, which is probably why Manikanta missed it.
> 
> Well, it's been in the Linus' tree for a week, though.
> 
> Thanks,
> Rafael
> 
I dropped this patch in V2.

Thanks,
Manikanta

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

* Re: [PATCH 01/10] genirq: Export irq_set_msi_desc()
  2017-11-25 19:41         ` Manikanta Maddireddy
@ 2017-11-28 10:00             ` Marc Zyngier
  -1 siblings, 0 replies; 39+ messages in thread
From: Marc Zyngier @ 2017-11-28 10:00 UTC (permalink / raw)
  To: Manikanta Maddireddy, Thomas Gleixner
  Cc: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA, rjw-LthD3rsA81gm4RdzfppkhA,
	vidyas-DDmLM1+adcrQT0dZR+AlfA, kthota-DDmLM1+adcrQT0dZR+AlfA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA

On 25/11/17 19:41, Manikanta Maddireddy wrote:
> 
> 
> On 25-Nov-17 5:25 AM, Thomas Gleixner wrote:
>> On Fri, 24 Nov 2017, Manikanta Maddireddy wrote:
>>
>> Please CC the proper mailing list for irq related changes.
>>
>>> PCI bus support MSI interrupts, allow PCI host driver to set MSI descriptor
>>> data for an irq.
>>
>> This is not really an explanation why this export is needed.
>>
>> Thanks,
>>
>> 	tglx
>>
> Updated the commit log with why Tegra PCIe driver is using this function in V2.
> Please review.

Well, to review it, I would like to be on Cc.

My current position on this is that if you need to export this function,
then you're using a deprecated API, and you should instead consider
moving to the generic MSI model, which doesn't need any of this.

I've done that a distant past, but never actually published the patch
(not tested it):

https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=irq/kill-msi-controller&id=83b3602fcee7972b9d549ed729b56ec28de16081

But without seeing the patches, I may be barking up the wrong tree...

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 01/10] genirq: Export irq_set_msi_desc()
@ 2017-11-28 10:00             ` Marc Zyngier
  0 siblings, 0 replies; 39+ messages in thread
From: Marc Zyngier @ 2017-11-28 10:00 UTC (permalink / raw)
  To: Manikanta Maddireddy, Thomas Gleixner
  Cc: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw,
	vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm

On 25/11/17 19:41, Manikanta Maddireddy wrote:
> 
> 
> On 25-Nov-17 5:25 AM, Thomas Gleixner wrote:
>> On Fri, 24 Nov 2017, Manikanta Maddireddy wrote:
>>
>> Please CC the proper mailing list for irq related changes.
>>
>>> PCI bus support MSI interrupts, allow PCI host driver to set MSI descriptor
>>> data for an irq.
>>
>> This is not really an explanation why this export is needed.
>>
>> Thanks,
>>
>> 	tglx
>>
> Updated the commit log with why Tegra PCIe driver is using this function in V2.
> Please review.

Well, to review it, I would like to be on Cc.

My current position on this is that if you need to export this function,
then you're using a deprecated API, and you should instead consider
moving to the generic MSI model, which doesn't need any of this.

I've done that a distant past, but never actually published the patch
(not tested it):

https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=irq/kill-msi-controller&id=83b3602fcee7972b9d549ed729b56ec28de16081

But without seeing the patches, I may be barking up the wrong tree...

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: [PATCH 01/10] genirq: Export irq_set_msi_desc()
  2017-11-28 10:00             ` Marc Zyngier
@ 2017-11-28 17:19               ` Manikanta Maddireddy
  -1 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-28 17:19 UTC (permalink / raw)
  To: Marc Zyngier, Thomas Gleixner
  Cc: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw,
	vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm



On 28-Nov-17 3:30 PM, Marc Zyngier wrote:
> On 25/11/17 19:41, Manikanta Maddireddy wrote:
>>
>>
>> On 25-Nov-17 5:25 AM, Thomas Gleixner wrote:
>>> On Fri, 24 Nov 2017, Manikanta Maddireddy wrote:
>>>
>>> Please CC the proper mailing list for irq related changes.
>>>
>>>> PCI bus support MSI interrupts, allow PCI host driver to set MSI descriptor
>>>> data for an irq.
>>>
>>> This is not really an explanation why this export is needed.
>>>
>>> Thanks,
>>>
>>> 	tglx
>>>
>> Updated the commit log with why Tegra PCIe driver is using this function in V2.
>> Please review.
> 
> Well, to review it, I would like to be on Cc.
> 
> My current position on this is that if you need to export this function,
> then you're using a deprecated API, and you should instead consider
> moving to the generic MSI model, which doesn't need any of this.
> 
> I've done that a distant past, but never actually published the patch
> (not tested it):
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=irq/kill-msi-controller&id=83b3602fcee7972b9d549ed729b56ec28de16081
> 
> But without seeing the patches, I may be barking up the wrong tree...
> 
> Thanks,
> 
> 	M.
> 
Hi Mark,

I will drop this change from this series and will take up generic MSI work in the next series of changes for pci-tegra driver.
Even without this change, pci-tegra driver will work fine as a builtin module. So other changes can still be reviewed and
can be considered as initial step for adding LKM support for pci-tegra.

Thanks,
Manikanta

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

* Re: [PATCH 01/10] genirq: Export irq_set_msi_desc()
@ 2017-11-28 17:19               ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-28 17:19 UTC (permalink / raw)
  To: Marc Zyngier, Thomas Gleixner
  Cc: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw,
	vidyas, kthota, linux-tegra, devicetree, linux-pci, linux-pm



On 28-Nov-17 3:30 PM, Marc Zyngier wrote:
> On 25/11/17 19:41, Manikanta Maddireddy wrote:
>>
>>
>> On 25-Nov-17 5:25 AM, Thomas Gleixner wrote:
>>> On Fri, 24 Nov 2017, Manikanta Maddireddy wrote:
>>>
>>> Please CC the proper mailing list for irq related changes.
>>>
>>>> PCI bus support MSI interrupts, allow PCI host driver to set MSI descriptor
>>>> data for an irq.
>>>
>>> This is not really an explanation why this export is needed.
>>>
>>> Thanks,
>>>
>>> 	tglx
>>>
>> Updated the commit log with why Tegra PCIe driver is using this function in V2.
>> Please review.
> 
> Well, to review it, I would like to be on Cc.
> 
> My current position on this is that if you need to export this function,
> then you're using a deprecated API, and you should instead consider
> moving to the generic MSI model, which doesn't need any of this.
> 
> I've done that a distant past, but never actually published the patch
> (not tested it):
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=irq/kill-msi-controller&id=83b3602fcee7972b9d549ed729b56ec28de16081
> 
> But without seeing the patches, I may be barking up the wrong tree...
> 
> Thanks,
> 
> 	M.
> 
Hi Mark,

I will drop this change from this series and will take up generic MSI work in the next series of changes for pci-tegra driver.
Even without this change, pci-tegra driver will work fine as a builtin module. So other changes can still be reviewed and
can be considered as initial step for adding LKM support for pci-tegra.

Thanks,
Manikanta

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

* Re: [PATCH 04/10] ARM: tegra: EXPORT tegra_cpuidle_pcie_irqs_in_use()
  2017-11-24 15:53   ` Manikanta Maddireddy
  (?)
@ 2017-11-30 12:41   ` Lorenzo Pieralisi
  2017-11-30 18:46       ` Manikanta Maddireddy
  -1 siblings, 1 reply; 39+ messages in thread
From: Lorenzo Pieralisi @ 2017-11-30 12:41 UTC (permalink / raw)
  To: Manikanta Maddireddy
  Cc: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw,
	tglx, vidyas, kthota, linux-tegra, devicetree, linux-pci,
	linux-pm

On Fri, Nov 24, 2017 at 09:23:14PM +0530, Manikanta Maddireddy wrote:
> EXPORT tegra_cpuidle_pcie_irqs_in_use() to allow Tegra PCIe driver to be
> compiled as loadable kernel module.
> 
> Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
> ---
>  arch/arm/mach-tegra/cpuidle.c | 1 +
>  1 file changed, 1 insertion(+)

You should find a way to remove this call and the corresponding
drivers->arch dependency, not to export it by spreading it even
further.

Lorenzo

> diff --git a/arch/arm/mach-tegra/cpuidle.c b/arch/arm/mach-tegra/cpuidle.c
> index 316563141add..7d7e6d3ce32d 100644
> --- a/arch/arm/mach-tegra/cpuidle.c
> +++ b/arch/arm/mach-tegra/cpuidle.c
> @@ -57,3 +57,4 @@ void tegra_cpuidle_pcie_irqs_in_use(void)
>  		break;
>  	}
>  }
> +EXPORT_SYMBOL(tegra_cpuidle_pcie_irqs_in_use);
> -- 
> 2.1.4
> 

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

* Re: [PATCH 04/10] ARM: tegra: EXPORT tegra_cpuidle_pcie_irqs_in_use()
  2017-11-30 12:41   ` Lorenzo Pieralisi
@ 2017-11-30 18:46       ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-30 18:46 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw,
	tglx, vidyas, kthota, linux-tegra, devicetree, linux-pci,
	linux-pm



On 30-Nov-17 6:11 PM, Lorenzo Pieralisi wrote:
> On Fri, Nov 24, 2017 at 09:23:14PM +0530, Manikanta Maddireddy wrote:
>> EXPORT tegra_cpuidle_pcie_irqs_in_use() to allow Tegra PCIe driver to be
>> compiled as loadable kernel module.
>>
>> Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
>> ---
>>  arch/arm/mach-tegra/cpuidle.c | 1 +
>>  1 file changed, 1 insertion(+)
> 
> You should find a way to remove this call and the corresponding
> drivers->arch dependency, not to export it by spreading it even
> further.
> 
> Lorenzo
> 
I will drop this patch from the series and will explore the possibilities of
removing the arch dependency. I will address it in next series of patches

>> diff --git a/arch/arm/mach-tegra/cpuidle.c b/arch/arm/mach-tegra/cpuidle.c
>> index 316563141add..7d7e6d3ce32d 100644
>> --- a/arch/arm/mach-tegra/cpuidle.c
>> +++ b/arch/arm/mach-tegra/cpuidle.c
>> @@ -57,3 +57,4 @@ void tegra_cpuidle_pcie_irqs_in_use(void)
>>  		break;
>>  	}
>>  }
>> +EXPORT_SYMBOL(tegra_cpuidle_pcie_irqs_in_use);
>> -- 
>> 2.1.4
>>

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

* Re: [PATCH 04/10] ARM: tegra: EXPORT tegra_cpuidle_pcie_irqs_in_use()
@ 2017-11-30 18:46       ` Manikanta Maddireddy
  0 siblings, 0 replies; 39+ messages in thread
From: Manikanta Maddireddy @ 2017-11-30 18:46 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: thierry.reding, jonathanh, robh+dt, frowand.list, bhelgaas, rjw,
	tglx, vidyas, kthota, linux-tegra, devicetree, linux-pci,
	linux-pm



On 30-Nov-17 6:11 PM, Lorenzo Pieralisi wrote:
> On Fri, Nov 24, 2017 at 09:23:14PM +0530, Manikanta Maddireddy wrote:
>> EXPORT tegra_cpuidle_pcie_irqs_in_use() to allow Tegra PCIe driver to be
>> compiled as loadable kernel module.
>>
>> Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
>> ---
>>  arch/arm/mach-tegra/cpuidle.c | 1 +
>>  1 file changed, 1 insertion(+)
> 
> You should find a way to remove this call and the corresponding
> drivers->arch dependency, not to export it by spreading it even
> further.
> 
> Lorenzo
> 
I will drop this patch from the series and will explore the possibilities of
removing the arch dependency. I will address it in next series of patches

>> diff --git a/arch/arm/mach-tegra/cpuidle.c b/arch/arm/mach-tegra/cpuidle.c
>> index 316563141add..7d7e6d3ce32d 100644
>> --- a/arch/arm/mach-tegra/cpuidle.c
>> +++ b/arch/arm/mach-tegra/cpuidle.c
>> @@ -57,3 +57,4 @@ void tegra_cpuidle_pcie_irqs_in_use(void)
>>  		break;
>>  	}
>>  }
>> +EXPORT_SYMBOL(tegra_cpuidle_pcie_irqs_in_use);
>> -- 
>> 2.1.4
>>

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

end of thread, other threads:[~2017-11-30 18:46 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-24 15:53 [PATCH 00/10] Add loadable kernel module and power management support Manikanta Maddireddy
2017-11-24 15:53 ` Manikanta Maddireddy
     [not found] ` <1511538800-8275-1-git-send-email-mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-24 15:53   ` [PATCH 01/10] genirq: Export irq_set_msi_desc() Manikanta Maddireddy
2017-11-24 15:53     ` Manikanta Maddireddy
2017-11-24 23:55     ` Thomas Gleixner
2017-11-25 19:41       ` Manikanta Maddireddy
2017-11-25 19:41         ` Manikanta Maddireddy
     [not found]         ` <600a7b65-670e-b164-913c-99e18ae593d2-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-28 10:00           ` Marc Zyngier
2017-11-28 10:00             ` Marc Zyngier
2017-11-28 17:19             ` Manikanta Maddireddy
2017-11-28 17:19               ` Manikanta Maddireddy
2017-11-24 15:53   ` [PATCH 02/10] of: Export of_pci_range_to_resource() Manikanta Maddireddy
2017-11-24 15:53     ` Manikanta Maddireddy
2017-11-24 15:53   ` [PATCH 03/10] PM / QoS: Fix device resume latency for non PM QoS devices Manikanta Maddireddy
2017-11-24 15:53     ` Manikanta Maddireddy
2017-11-24 16:50     ` Rafael J. Wysocki
     [not found]       ` <CAJZ5v0ghcwSHdrbZd_=XA=tHz7=aTUVd66dHkMYRNyXpnqP84w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-24 20:39         ` Thierry Reding
2017-11-24 20:39           ` Thierry Reding
2017-11-25  0:02           ` Rafael J. Wysocki
2017-11-25  0:02             ` Rafael J. Wysocki
     [not found]             ` <CAJZ5v0h1EdMV5u-5noMv_1_OpS13nH2NW_6Aua9+LMoWH0tL2w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-25 19:46               ` Manikanta Maddireddy
2017-11-25 19:46                 ` Manikanta Maddireddy
2017-11-24 15:53   ` [PATCH 06/10] PCI: Export pci_flags Manikanta Maddireddy
2017-11-24 15:53     ` Manikanta Maddireddy
2017-11-24 15:53   ` [PATCH 08/10] PCI: tegra: Add loadable kernel module support Manikanta Maddireddy
2017-11-24 15:53     ` Manikanta Maddireddy
2017-11-24 15:53   ` [PATCH 10/10] PCI: tegra: Add power management support Manikanta Maddireddy
2017-11-24 15:53     ` Manikanta Maddireddy
2017-11-24 15:53 ` [PATCH 04/10] ARM: tegra: EXPORT tegra_cpuidle_pcie_irqs_in_use() Manikanta Maddireddy
2017-11-24 15:53   ` Manikanta Maddireddy
2017-11-30 12:41   ` Lorenzo Pieralisi
2017-11-30 18:46     ` Manikanta Maddireddy
2017-11-30 18:46       ` Manikanta Maddireddy
2017-11-24 15:53 ` [PATCH 05/10] PCI: Export pci_find_host_bridge() Manikanta Maddireddy
2017-11-24 15:53   ` Manikanta Maddireddy
2017-11-24 15:53 ` [PATCH 07/10] PCI: tegra: free resources on probe failure Manikanta Maddireddy
2017-11-24 15:53   ` Manikanta Maddireddy
2017-11-24 15:53 ` [PATCH 09/10] PCI: tegra: Broadcast PME_turn_Off message before link goes to L2 Manikanta Maddireddy
2017-11-24 15:53   ` Manikanta Maddireddy

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.