Skip to contentSkip to conversation

PCI: deprecate pci_get_bus_and_slot()

PATCH Applied Sinan Kaya 11 participants 62 messages Dec 19, 2017 – Feb 16, 2018

Subsystems (23)
lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

v4 cover PCI: deprecate pci_get_bus_and_slot()

Deprecate pci_get_bus_and_slot() in favor of pci_get_domain_bus_and_slot() in order to remove domain 0 assumptions in the kernel.

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't extract the domain number. Other places, use the actual domain number from the device.

Changes from v3:
* rebase to linux-next
* drop drm i915 as it is going through the drm tip
* commit summary cleanups

Sinan Kaya (26):
alpha/PCI: deprecate pci_get_bus_and_slot() powerpc/PCI: deprecate pci_get_bus_and_slot() x86/PCI: deprecate pci_get_bus_and_slot()
ata: deprecate pci_get_bus_and_slot()
agp: nvidia: deprecate pci_get_bus_and_slot()
edd: deprecate pci_get_bus_and_slot()
ibft: deprecate pci_get_bus_and_slot() drm/gma500: deprecate pci_get_bus_and_slot() drm/nouveau: deprecate pci_get_bus_and_slot()
Drivers: ide: deprecate pci_get_bus_and_slot() iommu/amd: deprecate pci_get_bus_and_slot() powerpc/powermac: deprecate pci_get_bus_and_slot()
bnx2x: deprecate pci_get_bus_and_slot()
pch_gbe: deprecate pci_get_bus_and_slot()
PCI: cpqhp: deprecate pci_get_bus_and_slot()
PCI: ibmphp: deprecate pci_get_bus_and_slot() PCI/quirks: deprecate pci_get_bus_and_slot() PCI/syscall: deprecate pci_get_bus_and_slot()
xen: deprecate pci_get_bus_and_slot()
openprom: deprecate pci_get_bus_and_slot()
backlight: deprecate pci_get_bus_and_slot()
video: fbdev: intelfb: deprecate pci_get_bus_and_slot()
video: fbdev: nvidia: deprecate pci_get_bus_and_slot()
video: fbdev: riva: deprecate pci_get_bus_and_slot()
i7300_idle: remove unused file
PCI: Remove pci_get_bus_and_slot() function

 arch/alpha/kernel/pci.c                            |  2 +-
 arch/alpha/kernel/sys_nautilus.c                   |  2 +-
 arch/powerpc/kernel/pci_32.c                       |  3 +-
 arch/powerpc/platforms/powermac/feature.c          |  2 +-
 arch/powerpc/sysdev/mv64x60_pci.c                  |  4 +-
 arch/x86/pci/irq.c                                 |  3 +-
 drivers/ata/pata_ali.c                             |  3 +-
 drivers/char/agp/nvidia-agp.c                      | 12 +++-
 drivers/char/agp/sworks-agp.c                      |  3 +-
 drivers/firmware/edd.c                             |  8 +--
 drivers/firmware/iscsi_ibft.c                      |  5 +-
 drivers/gpu/drm/gma500/cdv_device.c                | 16 +++--
 drivers/gpu/drm/gma500/gma_device.c                |  4 +-
 drivers/gpu/drm/gma500/mid_bios.c                  | 12 +++-
 drivers/gpu/drm/gma500/psb_drv.c                   | 10 ++-
 drivers/gpu/drm/gma500/psb_drv.h                   | 18 ++---
 drivers/gpu/drm/nouveau/dispnv04/arb.c             |  4 +-
 drivers/gpu/drm/nouveau/dispnv04/hw.c              | 10 ++-
 drivers/gpu/drm/nouveau/nouveau_drm.c              |  3 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c   | 10 ++-
 drivers/ide/sl82c105.c                             |  5 +-
 drivers/iommu/amd_iommu.c                          |  3 +-
 drivers/iommu/amd_iommu_init.c                     |  9 +--
 drivers/iommu/amd_iommu_v2.c                       |  3 +-
 drivers/macintosh/via-pmu.c                        |  2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c  | 10 ++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h  |  1 +
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   |  6 +-
 drivers/pci/hotplug/cpqphp_pci.c                   | 18 +++--
 drivers/pci/hotplug/ibmphp_core.c                  |  7 +-
 drivers/pci/quirks.c                               |  3 +-
 drivers/pci/syscall.c                              |  4 +-
 drivers/pci/xen-pcifront.c                         |  3 +-
 drivers/sbus/char/openprom.c                       |  5 +-
 drivers/video/backlight/apple_bl.c                 |  2 +-
 drivers/video/fbdev/intelfb/intelfbhw.c            |  4 +-
 drivers/video/fbdev/nvidia/nv_hw.c                 | 11 +--
 drivers/video/fbdev/nvidia/nv_setup.c              |  3 +-
 drivers/video/fbdev/riva/fbdev.c                   |  2 +-
 drivers/video/fbdev/riva/nv_driver.c               |  7 +-
 drivers/video/fbdev/riva/riva_hw.c                 | 20 ++++--
 drivers/video/fbdev/riva/riva_hw.h                 |  3 +-
 include/linux/i7300_idle.h                         | 84 ----------------------
 include/linux/pci.h                                |  8 ---
 44 files changed, 175 insertions(+), 182 deletions(-)
 delete mode 100644 include/linux/i7300_idle.h
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v4 1/26 alpha/PCI: deprecate pci_get_bus_and_slot()

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't extract the domain number. Other places, use the actual domain number from the device.

---
 arch/alpha/kernel/pci.c          | 2 +-
 arch/alpha/kernel/sys_nautilus.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/alpha/kernel/pci.c +1 -1
index 87da005..2e86ebb 100644
@@ -425,7 +425,7 @@ struct resource * __init
 		if (bus == 0 && dfn == 0) {
 			hose = pci_isa_hose;
 		} else {
-			dev = pci_get_bus_and_slot(bus, dfn);
+			dev = pci_get_domain_bus_and_slot(0, bus, dfn);
 			if (!dev)
 				return -ENODEV;
 			hose = dev->sysdata;
arch/alpha/kernel/sys_nautilus.c +1 -1
index 239dc0e..ff4f54b 100644
@@ -237,7 +237,7 @@
 	bus = hose->bus = bridge->bus;
 	pcibios_claim_one_bus(bus);
 
-	irongate = pci_get_bus_and_slot(0, 0);
+	irongate = pci_get_domain_bus_and_slot(pci_domain_nr(bus), 0, 0);
 	bus->self = irongate;
 	bus->resource[0] = &irongate_io;
 	bus->resource[1] = &irongate_mem;
Signature · 1 line
1.9.1
author
#2 lore raw

Re: [PATCH V4 01/26] alpha/PCI: deprecate pci_get_bus_and_slot()

Quoted 33 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't extract the domain number. Other places, use the actual domain number from the device.

---
 arch/alpha/kernel/pci.c          | 2 +-
 arch/alpha/kernel/sys_nautilus.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/alpha/kernel/pci.c +1 -1
index 87da005..2e86ebb 100644
@@ -425,7 +425,7 @@ struct resource * __init
 		if (bus == 0 && dfn == 0) {
 			hose = pci_isa_hose;
 		} else {
-			dev = pci_get_bus_and_slot(bus, dfn);
+			dev = pci_get_domain_bus_and_slot(0, bus, dfn);
 			if (!dev)
 				return -ENODEV;
 			hose = dev->sysdata;
arch/alpha/kernel/sys_nautilus.c +0 -0
index 239dc0e..ff4f54b 100644

arch/alpha/kernel/sys_nautilus.c line 243

Quoted 8 lines
arch/alpha/kernel/sys_nautilus.c +1 -1
@@ -237,7 +237,7 @@
 	bus = hose->bus = bridge->bus;
 	pcibios_claim_one_bus(bus);
 
-	irongate = pci_get_bus_and_slot(0, 0);
+	irongate = pci_get_domain_bus_and_slot(pci_domain_nr(bus), 0, 0);
 	bus->self = irongate;
 	bus->resource[0] = &irongate_io;
 	bus->resource[1] = &irongate_mem;

Any feedback here? most of the remaining patches have the ACK except these.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#3 lore raw

PATCH v4 2/26 powerpc/PCI: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Use pci_get_domain_bus_and_slot() with a domain number of 0 as the code is not ready to consume multiple domains and existing code used domain number 0.

---
 arch/powerpc/kernel/pci_32.c              | 3 ++-
 arch/powerpc/platforms/powermac/feature.c | 2 +-
 arch/powerpc/sysdev/mv64x60_pci.c         | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)
arch/powerpc/kernel/pci_32.c +2 -1
index 1d817f4..85ad2f7 100644
@@ -96,7 +96,8 @@
 		reg = of_get_property(node, "reg", NULL);
 		if (!reg)
 			continue;
-		dev = pci_get_bus_and_slot(pci_bus, ((reg[0] >> 8) & 0xff));
+		dev = pci_get_domain_bus_and_slot(0, pci_bus,
+						  ((reg[0] >> 8) & 0xff));
 		if (!dev || !dev->subordinate) {
 			pci_dev_put(dev);
 			continue;
arch/powerpc/platforms/powermac/feature.c +1 -1
index 466b842..3f82cb2 100644
@@ -829,7 +829,7 @@ static long core99_scc_enable(struct device_node *node, long param, long value)
 
 	if (value) {
 		if (pci_device_from_OF_node(node, &pbus, &pid) == 0)
-			pdev = pci_get_bus_and_slot(pbus, pid);
+			pdev = pci_get_domain_bus_and_slot(0, pbus, pid);
 		if (pdev == NULL)
 			return 0;
 		rc = pci_enable_device(pdev);
arch/powerpc/sysdev/mv64x60_pci.c +2 -2
index d52b3b8..6fe9104 100644
@@ -37,7 +37,7 @@ static ssize_t mv64x60_hs_reg_read(struct file *filp, struct kobject *kobj,
 	if (count < MV64X60_VAL_LEN_MAX)
 		return -EINVAL;
 
-	phb = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
+	phb = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
 	if (!phb)
 		return -ENODEV;
 	pci_read_config_dword(phb, MV64X60_PCICFG_CPCI_HOTSWAP, &v);
@@ -61,7 +61,7 @@ static ssize_t mv64x60_hs_reg_write(struct file *filp, struct kobject *kobj,
 	if (sscanf(buf, "%i", &v) != 1)
 		return -EINVAL;
 
-	phb = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
+	phb = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
 	if (!phb)
 		return -ENODEV;
 	pci_write_config_dword(phb, MV64X60_PCICFG_CPCI_HOTSWAP, v);
Signature · 1 line
1.9.1
reviewer Acked-by on v4 2/26
#4 lore raw

Re: [PATCH V4 02/26] powerpc/PCI: deprecate pci_get_bus_and_slot()

Quoted 11 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Use pci_get_domain_bus_and_slot() with a domain number of 0 as the code is not ready to consume multiple domains and existing code used domain number 0.

Quoted 6 lines
---
 arch/powerpc/kernel/pci_32.c              | 3 ++-
 arch/powerpc/platforms/powermac/feature.c | 2 +-
 arch/powerpc/sysdev/mv64x60_pci.c         | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

Looks to do what it says. I don't know if any of these call sites could be improved to provide the domain, but that's not really your problem.

cheers

author
#5 lore raw

Re: [PATCH V4 02/26] powerpc/PCI: deprecate pci_get_bus_and_slot()

Quoted 20 lines · Michael Ellerman
Quoted 11 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Use pci_get_domain_bus_and_slot() with a domain number of 0 as the code is not ready to consume multiple domains and existing code used domain number 0.

Quoted 6 lines
---
 arch/powerpc/kernel/pci_32.c              | 3 ++-
 arch/powerpc/platforms/powermac/feature.c | 2 +-
 arch/powerpc/sysdev/mv64x60_pci.c         | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)
Quoted 3 lines

Looks to do what it says. I don't know if any of these call sites could be improved to provide the domain, but that's not really your problem.

I tried to fix the places where I can at the rest of the series. I even took a stab at fixing powerpc. There were places where the domain information was not available and I couldn't locate where to extract it. I decided to leave it as it is and hope that someone someday may expand the powerpc PCI adaptation.

Quoted 4 lines

cheers

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#6 lore raw

PATCH v4 3/26 x86/PCI: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Use domain number of 0 as the domain number is not available in struct irq_routing_table.

---
 arch/x86/pci/irq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/pci/irq.c +2 -1
index 04526291..52e5510 100644
@@ -839,7 +839,8 @@ static void __init pirq_find_router(struct irq_router *r)
 	DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for [%04x:%04x]\n",
 	    rt->rtr_vendor, rt->rtr_device);
 
-	pirq_router_dev = pci_get_bus_and_slot(rt->rtr_bus, rt->rtr_devfn);
+	pirq_router_dev = pci_get_domain_bus_and_slot(0, rt->rtr_bus,
+						      rt->rtr_devfn);
 	if (!pirq_router_dev) {
 		DBG(KERN_DEBUG "PCI: Interrupt router not found at "
 			"%02x:%02x\n", rt->rtr_bus, rt->rtr_devfn);
Signature · 1 line
1.9.1
author
#7 lore raw

PATCH v4 4/26 ata: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Use pci_get_domain_bus_and_slot() and extract the actual domain number from the pdev passed in.

---
 drivers/ata/pata_ali.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ata/pata_ali.c +2 -1
index d19cd88..0b122f9 100644
@@ -466,7 +466,8 @@ static void ali_init_chipset(struct pci_dev *pdev)
 			tmp |= 0x01;	/* CD_ROM enable for DMA */
 		pci_write_config_byte(pdev, 0x53, tmp);
 	}
-	north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0));
+	north = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 0,
+					    PCI_DEVFN(0, 0));
 	if (north && north->vendor == PCI_VENDOR_ID_AL && ali_isa_bridge) {
 		/* Configure the ALi bridge logic. For non ALi rely on BIOS.
 		   Set the south bridge enable bit */
Signature · 1 line
1.9.1
author
#8 lore raw

PATCH v4 5/26 agp: nvidia: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot() and extract the domain number from struct pci_dev.

---
 drivers/char/agp/nvidia-agp.c | 12 +++++++++---
 drivers/char/agp/sworks-agp.c |  3 ++-
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/char/agp/nvidia-agp.c +9 -3
index 828b344..623205b 100644
@@ -340,11 +340,17 @@ static int agp_nvidia_probe(struct pci_dev *pdev,
 	u8 cap_ptr;
 
 	nvidia_private.dev_1 =
-		pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 1));
+		pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+					    (unsigned int)pdev->bus->number,
+					    PCI_DEVFN(0, 1));
 	nvidia_private.dev_2 =
-		pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2));
+		pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+					    (unsigned int)pdev->bus->number,
+					    PCI_DEVFN(0, 2));
 	nvidia_private.dev_3 =
-		pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0));
+		pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+					    (unsigned int)pdev->bus->number,
+					    PCI_DEVFN(30, 0));
 
 	if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) {
 		printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
drivers/char/agp/sworks-agp.c +2 -1
index 03be4ac..4dbdd3b 100644
@@ -474,7 +474,8 @@ static int agp_serverworks_probe(struct pci_dev *pdev,
 	}
 
 	/* Everything is on func 1 here so we are hardcoding function one */
-	bridge_dev = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
+	bridge_dev = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+			(unsigned int)pdev->bus->number,
 			PCI_DEVFN(0, 1));
 	if (!bridge_dev) {
 		dev_info(&pdev->dev, "can't find secondary device\n");
Signature · 1 line
1.9.1
author
#9 lore raw

Re: [PATCH V4 05/26] agp: nvidia: deprecate pci_get_bus_and_slot()

Quoted 47 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot() and extract the domain number from struct pci_dev.

---
 drivers/char/agp/nvidia-agp.c | 12 +++++++++---
 drivers/char/agp/sworks-agp.c |  3 ++-
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/char/agp/nvidia-agp.c +9 -3
index 828b344..623205b 100644
@@ -340,11 +340,17 @@ static int agp_nvidia_probe(struct pci_dev *pdev,
 	u8 cap_ptr;
 
 	nvidia_private.dev_1 =
-		pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 1));
+		pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+					    (unsigned int)pdev->bus->number,
+					    PCI_DEVFN(0, 1));
 	nvidia_private.dev_2 =
-		pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2));
+		pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+					    (unsigned int)pdev->bus->number,
+					    PCI_DEVFN(0, 2));
 	nvidia_private.dev_3 =
-		pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0));
+		pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+					    (unsigned int)pdev->bus->number,
+					    PCI_DEVFN(30, 0));
 
 	if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) {
 		printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
drivers/char/agp/sworks-agp.c +0 -0
index 03be4ac..4dbdd3b 100644

drivers/char/agp/sworks-agp.c static int agp_serverworks_probe(struct pci_dev *pdev, · line 481

Quoted 9 lines
drivers/char/agp/sworks-agp.c +2 -1
@@ -474,7 +474,8 @@ static int agp_serverworks_probe(struct pci_dev *pdev,
 	}
 
 	/* Everything is on func 1 here so we are hardcoding function one */
-	bridge_dev = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
+	bridge_dev = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+			(unsigned int)pdev->bus->number,
 			PCI_DEVFN(0, 1));
 	if (!bridge_dev) {
 		dev_info(&pdev->dev, "can't find secondary device\n");

Any feedback here? most of the remaining patches have the ACK except these.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
maintainer
#10 lore raw

Re: [PATCH V4 05/26] agp: nvidia: deprecate pci_get_bus_and_slot()

Quoted 4 lines · Sinan Kaya
Quoted 3 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

So not a major problem, but it would be pretty much impossible for either of these agp drivers to be used in any other domain ever.

What does this buy us, maybe just rename pci_get_bus_and_slot to pci_get_domain0_bus_and_slot as a helper, or just pass the pdev in and have it do the right thing always.

Dave.

Quoted 61 lines
Quoted 44 lines

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot() and extract the domain number from struct pci_dev.

---
 drivers/char/agp/nvidia-agp.c | 12 +++++++++---
 drivers/char/agp/sworks-agp.c |  3 ++-
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/char/agp/nvidia-agp.c +9 -3
index 828b344..623205b 100644
@@ -340,11 +340,17 @@ static int agp_nvidia_probe(struct pci_dev *pdev,
      u8 cap_ptr;
 
      nvidia_private.dev_1 =
-             pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 1));
+             pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+                                         (unsigned int)pdev->bus->number,
+                                         PCI_DEVFN(0, 1));
      nvidia_private.dev_2 =
-             pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2));
+             pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+                                         (unsigned int)pdev->bus->number,
+                                         PCI_DEVFN(0, 2));
      nvidia_private.dev_3 =
-             pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0));
+             pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+                                         (unsigned int)pdev->bus->number,
+                                         PCI_DEVFN(30, 0));
 
      if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) {
              printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
drivers/char/agp/sworks-agp.c +0 -0
index 03be4ac..4dbdd3b 100644

drivers/char/agp/sworks-agp.c static int agp_serverworks_probe(struct pci_dev *pdev, · line 481

Quoted 9 lines
drivers/char/agp/sworks-agp.c +2 -1
@@ -474,7 +474,8 @@ static int agp_serverworks_probe(struct pci_dev *pdev,
      }
 
      /* Everything is on func 1 here so we are hardcoding function one */
-     bridge_dev = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
+     bridge_dev = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+                     (unsigned int)pdev->bus->number,
                      PCI_DEVFN(0, 1));
      if (!bridge_dev) {
              dev_info(&pdev->dev, "can't find secondary device\n");

Any feedback here? most of the remaining patches have the ACK except these.

--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

author
#11 lore raw

Re: [PATCH V4 05/26] agp: nvidia: deprecate pci_get_bus_and_slot()

Quoted 10 lines · Dave Airlie
Quoted 4 lines
Quoted 3 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

So not a major problem, but it would be pretty much impossible for either of these agp drivers to be used in any other domain ever.

What does this buy us, maybe just rename pci_get_bus_and_slot to pci_get_domain0_bus_and_slot as a helper, or just pass the pdev in and have it do the right thing always.

There is nothing wrong with doing all three. Since nobody replied until patch v4, I did the heavy-lifting and converted code to use pci_domain_nr() as much as I can rather than hard-coding a 0 while calling pci_get_domain_bus_and_slot().

Quoted 1 line

From PCI coding perspective, pci_domain_nr() call is the right thing. It is

guaranteed to work no matter what your domain number is.

People look at other code for examples on how to write a PCI driver in general. You want to minimize the exceptions as much as possible.

Some discussion here about the benefits:

https://lkml.org/lkml/2017/12/19/349

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#12 lore raw

Re: [PATCH V4 05/26] agp: nvidia: deprecate pci_get_bus_and_slot()

In reply to Dave Airlie
Quoted 6 lines · Dave Airlie
Quoted 4 lines · Sinan Kaya
Quoted 3 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Quoted 6 lines

So not a major problem, but it would be pretty much impossible for either of these agp drivers to be used in any other domain ever.

What does this buy us, maybe just rename pci_get_bus_and_slot to pci_get_domain0_bus_and_slot as a helper, or just pass the pdev in and have it do the right thing always.

I already have this patch on my "next" branch, planned for the v4.16 merge window, so it's done unless you have a major objection.

Quoted 65 lines
Quoted 56 lines
Quoted 43 lines

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot() and extract the domain number from struct pci_dev.

---
 drivers/char/agp/nvidia-agp.c | 12 +++++++++---
 drivers/char/agp/sworks-agp.c |  3 ++-
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/char/agp/nvidia-agp.c +9 -3
index 828b344..623205b 100644
@@ -340,11 +340,17 @@ static int agp_nvidia_probe(struct pci_dev *pdev,
      u8 cap_ptr;
 
      nvidia_private.dev_1 =
-             pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 1));
+             pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+                                         (unsigned int)pdev->bus->number,
+                                         PCI_DEVFN(0, 1));
      nvidia_private.dev_2 =
-             pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2));
+             pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+                                         (unsigned int)pdev->bus->number,
+                                         PCI_DEVFN(0, 2));
      nvidia_private.dev_3 =
-             pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0));
+             pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+                                         (unsigned int)pdev->bus->number,
+                                         PCI_DEVFN(30, 0));
 
      if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) {
              printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
drivers/char/agp/sworks-agp.c +0 -0
index 03be4ac..4dbdd3b 100644

drivers/char/agp/sworks-agp.c static int agp_serverworks_probe(struct pci_dev *pdev, · line 481

Quoted 9 lines
drivers/char/agp/sworks-agp.c +2 -1
@@ -474,7 +474,8 @@ static int agp_serverworks_probe(struct pci_dev *pdev,
      }
 
      /* Everything is on func 1 here so we are hardcoding function one */
-     bridge_dev = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
+     bridge_dev = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+                     (unsigned int)pdev->bus->number,
                      PCI_DEVFN(0, 1));
      if (!bridge_dev) {
              dev_info(&pdev->dev, "can't find secondary device\n");

Any feedback here? most of the remaining patches have the ACK except these.

Quoted 4 lines

--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#13 lore raw

Re: [PATCH V4 05/26] agp: nvidia: deprecate pci_get_bus_and_slot()

Quoted 10 lines · Bjorn Helgaas
Quoted 9 lines · Dave Airlie
Quoted 4 lines · Sinan Kaya
Quoted 3 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

So not a major problem, but it would be pretty much impossible for either of these agp drivers to be used in any other domain ever.

Quoted 6 lines
Quoted 3 lines

What does this buy us, maybe just rename pci_get_bus_and_slot to pci_get_domain0_bus_and_slot as a helper, or just pass the pdev in and have it do the right thing always.

I already have this patch on my "next" branch, planned for the v4.16 merge window, so it's done unless you have a major objection.

Yeah I don't really care either way, I just can't seen the point in changing agp drivers that definitely will never see a domain, but if it gets rid of a dumb API,
so be it.

Dave.

author
#14 lore raw

PATCH v4 6/26 edd: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Domain number is not available in struct edd_info. Hard-coding the domain number as 0.

---
 drivers/firmware/edd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/firmware/edd.c +4 -4
index e229576..60a8f13 100644
@@ -669,10 +669,10 @@ static void edd_release(struct kobject * kobj)
 	struct edd_info *info = edd_dev_get_info(edev);
 
 	if (edd_dev_is_type(edev, "PCI") || edd_dev_is_type(edev, "XPRS")) {
-		return pci_get_bus_and_slot(info->params.interface_path.pci.bus,
-				     PCI_DEVFN(info->params.interface_path.pci.slot,
-					       info->params.interface_path.pci.
-					       function));
+		return pci_get_domain_bus_and_slot(0,
+				info->params.interface_path.pci.bus,
+				PCI_DEVFN(info->params.interface_path.pci.slot,
+				info->params.interface_path.pci.function));
 	}
 	return NULL;
 }
Signature · 1 line
1.9.1
author
#15 lore raw

Re: [PATCH V4 06/26] edd: deprecate pci_get_bus_and_slot()

Quoted 25 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Domain number is not available in struct edd_info. Hard-coding the domain number as 0.

---
 drivers/firmware/edd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/firmware/edd.c +0 -1
index e229576..60a8f13 100644
@@ -669,10 +669,10 @@ static void edd_release(struct kobject * kobj)
 	struct edd_info *info = edd_dev_get_info(edev);
 
 	if (edd_dev_is_type(edev, "PCI") || edd_dev_is_type(edev, "XPRS")) {
-		return pci_get_bus_and_slot(info->params.interface_path.pci.bus,

drivers/firmware/edd.c static void edd_release(struct kobject * kobj) · line 678

Quoted 10 lines
drivers/firmware/edd.c +4 -3
-				     PCI_DEVFN(info->params.interface_path.pci.slot,
-					       info->params.interface_path.pci.
-					       function));
+		return pci_get_domain_bus_and_slot(0,
+				info->params.interface_path.pci.bus,
+				PCI_DEVFN(info->params.interface_path.pci.slot,
+				info->params.interface_path.pci.function));
 	}
 	return NULL;
 }

Any feedback here? most of the remaining patches have the ACK except these.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#16 lore raw

PATCH v4 7/26 ibft: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

We don't search for the device in other domains than zero. This is because on x86 platforms the BIOS executes only devices which are in domain 0. Furthermore, the iBFT spec doesn't have a domain id field.

---
 drivers/firmware/iscsi_ibft.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/firmware/iscsi_ibft.c +3 -2
index 14042a6..6bc8e66 100644
@@ -719,8 +719,9 @@ static int __init ibft_create_kobject(struct acpi_table_ibft *header,
 		* executes only devices which are in domain 0. Furthermore, the
 		* iBFT spec doesn't have a domain id field :-(
 		*/
-		pci_dev = pci_get_bus_and_slot((nic->pci_bdf & 0xff00) >> 8,
-					       (nic->pci_bdf & 0xff));
+		pci_dev = pci_get_domain_bus_and_slot(0,
+						(nic->pci_bdf & 0xff00) >> 8,
+						(nic->pci_bdf & 0xff));
 		if (pci_dev) {
 			rc = sysfs_create_link(&boot_kobj->kobj,
 					       &pci_dev->dev.kobj, "device");
Signature · 1 line
1.9.1
author
#17 lore raw

PATCH v4 8/26 drm/gma500: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Add domain parameter to CDV_MSG_READ32, CDV_MSG_WRITE32, MRST_MSG_READ32, MRST_MSG_WRITE32, MDFLD_MSG_READ32, MDFLD_MSG_WRITE32.

Extract pci_dev from struct drm_device and use pdev to find the domain number while calling pci_get_domain_bus_and_slot().

---
 drivers/gpu/drm/gma500/cdv_device.c | 16 +++++++++-------
 drivers/gpu/drm/gma500/gma_device.c |  4 +++-
 drivers/gpu/drm/gma500/mid_bios.c   | 12 +++++++++---
 drivers/gpu/drm/gma500/psb_drv.c    | 10 ++++++++--
 drivers/gpu/drm/gma500/psb_drv.h    | 18 ++++++++++--------
 5 files changed, 39 insertions(+), 21 deletions(-)
drivers/gpu/drm/gma500/cdv_device.c +9 -7
index 8745971..3a3bf75 100644
@@ -185,21 +185,22 @@ static int cdv_backlight_init(struct drm_device *dev)
  *	for this and the MID devices.
  */
 
-static inline u32 CDV_MSG_READ32(uint port, uint offset)
+static inline u32 CDV_MSG_READ32(int domain, uint port, uint offset)
 {
 	int mcr = (0x10<<24) | (port << 16) | (offset << 8);
 	uint32_t ret_val = 0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
 	pci_dev_put(pci_root);
 	return ret_val;
 }
 
-static inline void CDV_MSG_WRITE32(uint port, uint offset, u32 value)
+static inline void CDV_MSG_WRITE32(int domain, uint port, uint offset,
+				   u32 value)
 {
 	int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD4, value);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_dev_put(pci_root);
@@ -216,11 +217,12 @@ static void cdv_init_pm(struct drm_device *dev)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	u32 pwr_cnt;
+	int domain = pci_domain_nr(dev->pdev->bus);
 	int i;
 
-	dev_priv->apm_base = CDV_MSG_READ32(PSB_PUNIT_PORT,
+	dev_priv->apm_base = CDV_MSG_READ32(domain, PSB_PUNIT_PORT,
 							PSB_APMBA) & 0xFFFF;
-	dev_priv->ospm_base = CDV_MSG_READ32(PSB_PUNIT_PORT,
+	dev_priv->ospm_base = CDV_MSG_READ32(domain, PSB_PUNIT_PORT,
 							PSB_OSPMBA) & 0xFFFF;
 
 	/* Power status */
@@ -251,7 +253,7 @@ static void cdv_errata(struct drm_device *dev)
 	 *	Bonus Launch to work around the issue, by degrading
 	 *	performance.
 	 */
-	 CDV_MSG_WRITE32(3, 0x30, 0x08027108);
+	 CDV_MSG_WRITE32(pci_domain_nr(dev->pdev->bus), 3, 0x30, 0x08027108);
 }
 
 /**
drivers/gpu/drm/gma500/gma_device.c +3 -1
index 4a295f9..a7fb6de 100644
@@ -19,7 +19,9 @@
 void gma_get_core_freq(struct drm_device *dev)
 {
 	uint32_t clock;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root =
+		pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus),
+					    0, 0);
 	struct drm_psb_private *dev_priv = dev->dev_private;
 
 	/*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/
drivers/gpu/drm/gma500/mid_bios.c +9 -3
index 1fa1633..7171b74 100644
@@ -32,7 +32,9 @@
 static void mid_get_fuse_settings(struct drm_device *dev)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root =
+		pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus),
+					    0, 0);
 	uint32_t fuse_value = 0;
 	uint32_t fuse_value_tmp = 0;
 
@@ -104,7 +106,9 @@ static void mid_get_fuse_settings(struct drm_device *dev)
 static void mid_get_pci_revID(struct drm_psb_private *dev_priv)
 {
 	uint32_t platform_rev_id = 0;
-	struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
+	int domain = pci_domain_nr(dev_priv->dev->pdev->bus);
+	struct pci_dev *pci_gfx_root =
+		pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(2, 0));
 
 	if (pci_gfx_root == NULL) {
 		WARN_ON(1);
@@ -281,7 +285,9 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
 	u32 addr;
 	u8 __iomem *vbt_virtual;
 	struct mid_vbt_header vbt_header;
-	struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
+	struct pci_dev *pci_gfx_root =
+		pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus),
+					    0, PCI_DEVFN(2, 0));
 	int ret = -1;
 
 	/* Get the address of the platform config vbt */
drivers/gpu/drm/gma500/psb_drv.c +8 -2
index 38d09d4..ac32ab5 100644
@@ -248,7 +248,11 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 		goto out_err;
 
 	if (IS_MRST(dev)) {
-		dev_priv->aux_pdev = pci_get_bus_and_slot(0, PCI_DEVFN(3, 0));
+		int domain = pci_domain_nr(dev->pdev->bus);
+
+		dev_priv->aux_pdev =
+			pci_get_domain_bus_and_slot(domain, 0,
+						    PCI_DEVFN(3, 0));
 
 		if (dev_priv->aux_pdev) {
 			resource_start = pci_resource_start(dev_priv->aux_pdev,
@@ -268,7 +272,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 		}
 		dev_priv->gmbus_reg = dev_priv->aux_reg;
 
-		dev_priv->lpc_pdev = pci_get_bus_and_slot(0, PCI_DEVFN(31, 0));
+		dev_priv->lpc_pdev =
+			pci_get_domain_bus_and_slot(domain, 0,
+						    PCI_DEVFN(31, 0));
 		if (dev_priv->lpc_pdev) {
 			pci_read_config_word(dev_priv->lpc_pdev, PSB_LPC_GBA,
 				&dev_priv->lpc_gpio_base);
drivers/gpu/drm/gma500/psb_drv.h +10 -8
index 4918efc..e8300f5 100644
@@ -780,38 +780,40 @@ extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
 extern int drm_idle_check_interval;
 
 /* Utilities */
-static inline u32 MRST_MSG_READ32(uint port, uint offset)
+static inline u32 MRST_MSG_READ32(int domain, uint port, uint offset)
 {
 	int mcr = (0xD0<<24) | (port << 16) | (offset << 8);
 	uint32_t ret_val = 0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
 	pci_dev_put(pci_root);
 	return ret_val;
 }
-static inline void MRST_MSG_WRITE32(uint port, uint offset, u32 value)
+static inline void MRST_MSG_WRITE32(int domain, uint port, uint offset,
+				    u32 value)
 {
 	int mcr = (0xE0<<24) | (port << 16) | (offset << 8) | 0xF0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD4, value);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_dev_put(pci_root);
 }
-static inline u32 MDFLD_MSG_READ32(uint port, uint offset)
+static inline u32 MDFLD_MSG_READ32(int domain, uint port, uint offset)
 {
 	int mcr = (0x10<<24) | (port << 16) | (offset << 8);
 	uint32_t ret_val = 0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
 	pci_dev_put(pci_root);
 	return ret_val;
 }
-static inline void MDFLD_MSG_WRITE32(uint port, uint offset, u32 value)
+static inline void MDFLD_MSG_WRITE32(int domain, uint port, uint offset,
+				     u32 value)
 {
 	int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD4, value);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_dev_put(pci_root);
Signature · 1 line
1.9.1
author
#18 lore raw

Re: [PATCH V4 08/26] drm/gma500: deprecate pci_get_bus_and_slot()

Quoted 201 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Add domain parameter to CDV_MSG_READ32, CDV_MSG_WRITE32, MRST_MSG_READ32, MRST_MSG_WRITE32, MDFLD_MSG_READ32, MDFLD_MSG_WRITE32.

Extract pci_dev from struct drm_device and use pdev to find the domain number while calling pci_get_domain_bus_and_slot().

---
 drivers/gpu/drm/gma500/cdv_device.c | 16 +++++++++-------
 drivers/gpu/drm/gma500/gma_device.c |  4 +++-
 drivers/gpu/drm/gma500/mid_bios.c   | 12 +++++++++---
 drivers/gpu/drm/gma500/psb_drv.c    | 10 ++++++++--
 drivers/gpu/drm/gma500/psb_drv.h    | 18 ++++++++++--------
 5 files changed, 39 insertions(+), 21 deletions(-)
drivers/gpu/drm/gma500/cdv_device.c +9 -7
index 8745971..3a3bf75 100644
@@ -185,21 +185,22 @@ static int cdv_backlight_init(struct drm_device *dev)
  *	for this and the MID devices.
  */
 
-static inline u32 CDV_MSG_READ32(uint port, uint offset)
+static inline u32 CDV_MSG_READ32(int domain, uint port, uint offset)
 {
 	int mcr = (0x10<<24) | (port << 16) | (offset << 8);
 	uint32_t ret_val = 0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
 	pci_dev_put(pci_root);
 	return ret_val;
 }
 
-static inline void CDV_MSG_WRITE32(uint port, uint offset, u32 value)
+static inline void CDV_MSG_WRITE32(int domain, uint port, uint offset,
+				   u32 value)
 {
 	int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD4, value);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_dev_put(pci_root);
@@ -216,11 +217,12 @@ static void cdv_init_pm(struct drm_device *dev)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	u32 pwr_cnt;
+	int domain = pci_domain_nr(dev->pdev->bus);
 	int i;
 
-	dev_priv->apm_base = CDV_MSG_READ32(PSB_PUNIT_PORT,
+	dev_priv->apm_base = CDV_MSG_READ32(domain, PSB_PUNIT_PORT,
 							PSB_APMBA) & 0xFFFF;
-	dev_priv->ospm_base = CDV_MSG_READ32(PSB_PUNIT_PORT,
+	dev_priv->ospm_base = CDV_MSG_READ32(domain, PSB_PUNIT_PORT,
 							PSB_OSPMBA) & 0xFFFF;
 
 	/* Power status */
@@ -251,7 +253,7 @@ static void cdv_errata(struct drm_device *dev)
 	 *	Bonus Launch to work around the issue, by degrading
 	 *	performance.
 	 */
-	 CDV_MSG_WRITE32(3, 0x30, 0x08027108);
+	 CDV_MSG_WRITE32(pci_domain_nr(dev->pdev->bus), 3, 0x30, 0x08027108);
 }
 
 /**
drivers/gpu/drm/gma500/gma_device.c +3 -1
index 4a295f9..a7fb6de 100644
@@ -19,7 +19,9 @@
 void gma_get_core_freq(struct drm_device *dev)
 {
 	uint32_t clock;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root =
+		pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus),
+					    0, 0);
 	struct drm_psb_private *dev_priv = dev->dev_private;
 
 	/*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/
drivers/gpu/drm/gma500/mid_bios.c +9 -3
index 1fa1633..7171b74 100644
@@ -32,7 +32,9 @@
 static void mid_get_fuse_settings(struct drm_device *dev)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root =
+		pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus),
+					    0, 0);
 	uint32_t fuse_value = 0;
 	uint32_t fuse_value_tmp = 0;
 
@@ -104,7 +106,9 @@ static void mid_get_fuse_settings(struct drm_device *dev)
 static void mid_get_pci_revID(struct drm_psb_private *dev_priv)
 {
 	uint32_t platform_rev_id = 0;
-	struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
+	int domain = pci_domain_nr(dev_priv->dev->pdev->bus);
+	struct pci_dev *pci_gfx_root =
+		pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(2, 0));
 
 	if (pci_gfx_root == NULL) {
 		WARN_ON(1);
@@ -281,7 +285,9 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
 	u32 addr;
 	u8 __iomem *vbt_virtual;
 	struct mid_vbt_header vbt_header;
-	struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
+	struct pci_dev *pci_gfx_root =
+		pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus),
+					    0, PCI_DEVFN(2, 0));
 	int ret = -1;
 
 	/* Get the address of the platform config vbt */
drivers/gpu/drm/gma500/psb_drv.c +8 -2
index 38d09d4..ac32ab5 100644
@@ -248,7 +248,11 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 		goto out_err;
 
 	if (IS_MRST(dev)) {
-		dev_priv->aux_pdev = pci_get_bus_and_slot(0, PCI_DEVFN(3, 0));
+		int domain = pci_domain_nr(dev->pdev->bus);
+
+		dev_priv->aux_pdev =
+			pci_get_domain_bus_and_slot(domain, 0,
+						    PCI_DEVFN(3, 0));
 
 		if (dev_priv->aux_pdev) {
 			resource_start = pci_resource_start(dev_priv->aux_pdev,
@@ -268,7 +272,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 		}
 		dev_priv->gmbus_reg = dev_priv->aux_reg;
 
-		dev_priv->lpc_pdev = pci_get_bus_and_slot(0, PCI_DEVFN(31, 0));
+		dev_priv->lpc_pdev =
+			pci_get_domain_bus_and_slot(domain, 0,
+						    PCI_DEVFN(31, 0));
 		if (dev_priv->lpc_pdev) {
 			pci_read_config_word(dev_priv->lpc_pdev, PSB_LPC_GBA,
 				&dev_priv->lpc_gpio_base);
drivers/gpu/drm/gma500/psb_drv.h +7 -6
index 4918efc..e8300f5 100644
@@ -780,38 +780,40 @@ extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
 extern int drm_idle_check_interval;
 
 /* Utilities */
-static inline u32 MRST_MSG_READ32(uint port, uint offset)
+static inline u32 MRST_MSG_READ32(int domain, uint port, uint offset)
 {
 	int mcr = (0xD0<<24) | (port << 16) | (offset << 8);
 	uint32_t ret_val = 0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
 	pci_dev_put(pci_root);
 	return ret_val;
 }
-static inline void MRST_MSG_WRITE32(uint port, uint offset, u32 value)
+static inline void MRST_MSG_WRITE32(int domain, uint port, uint offset,
+				    u32 value)
 {
 	int mcr = (0xE0<<24) | (port << 16) | (offset << 8) | 0xF0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD4, value);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_dev_put(pci_root);
 }
-static inline u32 MDFLD_MSG_READ32(uint port, uint offset)
+static inline u32 MDFLD_MSG_READ32(int domain, uint port, uint offset)
 {
 	int mcr = (0x10<<24) | (port << 16) | (offset << 8);
 	uint32_t ret_val = 0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_read_config_dword(pci_root, 0xD4, &ret_val);
 	pci_dev_put(pci_root);
 	return ret_val;
 }

drivers/gpu/drm/gma500/psb_drv.h extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev, · line 819

Quoted 10 lines
drivers/gpu/drm/gma500/psb_drv.h +3 -2
-static inline void MDFLD_MSG_WRITE32(uint port, uint offset, u32 value)
+static inline void MDFLD_MSG_WRITE32(int domain, uint port, uint offset,
+				     u32 value)
 {
 	int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
-	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+	struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
 	pci_write_config_dword(pci_root, 0xD4, value);
 	pci_write_config_dword(pci_root, 0xD0, mcr);
 	pci_dev_put(pci_root);

Any feedback here? I don't have any hardware to test the changes. I just did a compile test.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#19 lore raw

PATCH v4 9/26 drm/nouveau: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot() and extract the domain number from
1. struct pci_dev
2. struct pci_dev through drm_device->pdev
3. struct pci_dev through fb->subdev->drm_device->pdev

---
 drivers/gpu/drm/nouveau/dispnv04/arb.c           |  4 +++-
 drivers/gpu/drm/nouveau/dispnv04/hw.c            | 10 +++++++---
 drivers/gpu/drm/nouveau/nouveau_drm.c            |  3 ++-
 drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c | 10 +++++++++-
 4 files changed, 21 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/arb.c +3 -1
index 90075b6..c79160c 100644
@@ -213,8 +213,10 @@ struct nv_sim_state {
 	if ((dev->pdev->device & 0xffff) == 0x01a0 /*CHIPSET_NFORCE*/ ||
 	    (dev->pdev->device & 0xffff) == 0x01f0 /*CHIPSET_NFORCE2*/) {
 		uint32_t type;
+		int domain = pci_domain_nr(dev->pdev->bus);
 
-		pci_read_config_dword(pci_get_bus_and_slot(0, 1), 0x7c, &type);
+		pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 1),
+				      0x7c, &type);
 
 		sim_data.memory_type = (type >> 12) & 1;
 		sim_data.memory_width = 64;
drivers/gpu/drm/nouveau/dispnv04/hw.c +7 -3
index b985990..0c9bdf0 100644
@@ -216,12 +216,15 @@
 {
 	struct nvkm_pll_vals pllvals;
 	int ret;
+	int domain;
+
+	domain = pci_domain_nr(dev->pdev->bus);
 
 	if (plltype == PLL_MEMORY &&
 	    (dev->pdev->device & 0x0ff0) == CHIPSET_NFORCE) {
 		uint32_t mpllP;
-
-		pci_read_config_dword(pci_get_bus_and_slot(0, 3), 0x6c, &mpllP);
+		pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 3),
+				      0x6c, &mpllP);
 		mpllP = (mpllP >> 8) & 0xf;
 		if (!mpllP)
 			mpllP = 4;
@@ -232,7 +235,8 @@
 	    (dev->pdev->device & 0xff0) == CHIPSET_NFORCE2) {
 		uint32_t clock;
 
-		pci_read_config_dword(pci_get_bus_and_slot(0, 5), 0x4c, &clock);
+		pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 5),
+				      0x4c, &clock);
 		return clock / 1000;
 	}
 
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -1
index 8d4a5be..33b6139 100644
@@ -524,7 +524,8 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
 	}
 
 	/* subfunction one is a hdmi audio device? */
-	drm->hdmi_device = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
+	drm->hdmi_device = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+						(unsigned int)pdev->bus->number,
 						PCI_DEVFN(PCI_SLOT(pdev->devfn), 1));
 
 	if (!drm->hdmi_device) {
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c +9 -1
index 4c07d10..18241c6 100644
@@ -28,8 +28,16 @@
 {
 	struct pci_dev *bridge;
 	u32 mem, mib;
+	int domain = 0;
+	struct pci_dev *pdev = NULL;
 
-	bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 1));
+	if (dev_is_pci(fb->subdev.device->dev))
+		pdev = to_pci_dev(fb->subdev.device->dev);
+
+	if (pdev)
+		domain = pci_domain_nr(pdev->bus);
+
+	bridge = pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(0, 1));
 	if (!bridge) {
 		nvkm_error(&fb->subdev, "no bridge device\n");
 		return -ENODEV;
Signature · 6 lines
1.9.1

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
author
#20 lore raw

Re: [PATCH V4 09/26] drm/nouveau: deprecate pci_get_bus_and_slot()

Quoted 96 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot() and extract the domain number from
1. struct pci_dev
2. struct pci_dev through drm_device->pdev
3. struct pci_dev through fb->subdev->drm_device->pdev

---
 drivers/gpu/drm/nouveau/dispnv04/arb.c           |  4 +++-
 drivers/gpu/drm/nouveau/dispnv04/hw.c            | 10 +++++++---
 drivers/gpu/drm/nouveau/nouveau_drm.c            |  3 ++-
 drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c | 10 +++++++++-
 4 files changed, 21 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/arb.c +3 -1
index 90075b6..c79160c 100644
@@ -213,8 +213,10 @@ struct nv_sim_state {
 	if ((dev->pdev->device & 0xffff) == 0x01a0 /*CHIPSET_NFORCE*/ ||
 	    (dev->pdev->device & 0xffff) == 0x01f0 /*CHIPSET_NFORCE2*/) {
 		uint32_t type;
+		int domain = pci_domain_nr(dev->pdev->bus);
 
-		pci_read_config_dword(pci_get_bus_and_slot(0, 1), 0x7c, &type);
+		pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 1),
+				      0x7c, &type);
 
 		sim_data.memory_type = (type >> 12) & 1;
 		sim_data.memory_width = 64;
drivers/gpu/drm/nouveau/dispnv04/hw.c +7 -3
index b985990..0c9bdf0 100644
@@ -216,12 +216,15 @@
 {
 	struct nvkm_pll_vals pllvals;
 	int ret;
+	int domain;
+
+	domain = pci_domain_nr(dev->pdev->bus);
 
 	if (plltype == PLL_MEMORY &&
 	    (dev->pdev->device & 0x0ff0) == CHIPSET_NFORCE) {
 		uint32_t mpllP;
-
-		pci_read_config_dword(pci_get_bus_and_slot(0, 3), 0x6c, &mpllP);
+		pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 3),
+				      0x6c, &mpllP);
 		mpllP = (mpllP >> 8) & 0xf;
 		if (!mpllP)
 			mpllP = 4;
@@ -232,7 +235,8 @@
 	    (dev->pdev->device & 0xff0) == CHIPSET_NFORCE2) {
 		uint32_t clock;
 
-		pci_read_config_dword(pci_get_bus_and_slot(0, 5), 0x4c, &clock);
+		pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 5),
+				      0x4c, &clock);
 		return clock / 1000;
 	}
 
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -1
index 8d4a5be..33b6139 100644
@@ -524,7 +524,8 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
 	}
 
 	/* subfunction one is a hdmi audio device? */
-	drm->hdmi_device = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
+	drm->hdmi_device = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+						(unsigned int)pdev->bus->number,
 						PCI_DEVFN(PCI_SLOT(pdev->devfn), 1));
 
 	if (!drm->hdmi_device) {
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c +2 -1
index 4c07d10..18241c6 100644
@@ -28,8 +28,16 @@
 {
 	struct pci_dev *bridge;
 	u32 mem, mib;
+	int domain = 0;
+	struct pci_dev *pdev = NULL;
 
-	bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 1));

drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c line 43

Quoted 10 lines
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c +7 -0
+	if (dev_is_pci(fb->subdev.device->dev))
+		pdev = to_pci_dev(fb->subdev.device->dev);
+
+	if (pdev)
+		domain = pci_domain_nr(pdev->bus);
+
+	bridge = pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(0, 1));
 	if (!bridge) {
 		nvkm_error(&fb->subdev, "no bridge device\n");
 		return -ENODEV;

Any feedback here? I don't have any hardware to test the changes. I just did a compile test.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#21 lore raw

PATCH v4 10/26 Drivers: ide: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot() and extract the domain number from struct pci_dev.

---
 drivers/ide/sl82c105.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ide/sl82c105.c +3 -2
index 8755df3..3300dac 100644
@@ -239,8 +239,9 @@ static u8 sl82c105_bridge_revision(struct pci_dev *dev)
 	/*
 	 * The bridge should be part of the same device, but function 0.
 	 */
-	bridge = pci_get_bus_and_slot(dev->bus->number,
-			       PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
+	bridge = pci_get_domain_bus_and_slot(pci_domain_nr(dev->bus),
+					dev->bus->number,
+					PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
 	if (!bridge)
 		return -1;
 
Signature · 1 line
1.9.1
maintainer Acked-by on v4 10/26
#22 lore raw

Re: [PATCH V4 10/26] Drivers: ide: deprecate pci_get_bus_and_slot()

From: Sinan Kaya <[email protected]>
Date: Tue, 19 Dec 2017 00:37:46 -0500

Quoted 11 lines

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot() and extract the domain number from struct pci_dev.

author
#23 lore raw

PATCH v4 11/26 iommu/amd: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-code the domain number as 0 for the AMD IOMMU driver.

---
 drivers/iommu/amd_iommu.c      | 3 ++-
 drivers/iommu/amd_iommu_init.c | 9 +++++----
 drivers/iommu/amd_iommu_v2.c   | 3 ++-
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/iommu/amd_iommu.c +2 -1
index 7d5eb00..821547b 100644
@@ -527,7 +527,8 @@ static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
 	struct iommu_dev_data *dev_data = NULL;
 	struct pci_dev *pdev;
 
-	pdev = pci_get_bus_and_slot(PCI_BUS_NUM(devid), devid & 0xff);
+	pdev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(devid),
+					   devid & 0xff);
 	if (pdev)
 		dev_data = get_dev_data(&pdev->dev);
 
drivers/iommu/amd_iommu_init.c +5 -4
index 6fe2d03..4e4a615 100644
@@ -1697,8 +1697,8 @@ static int iommu_init_pci(struct amd_iommu *iommu)
 	u32 range, misc, low, high;
 	int ret;
 
-	iommu->dev = pci_get_bus_and_slot(PCI_BUS_NUM(iommu->devid),
-					  iommu->devid & 0xff);
+	iommu->dev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(iommu->devid),
+						 iommu->devid & 0xff);
 	if (!iommu->dev)
 		return -ENODEV;
 
@@ -1764,8 +1764,9 @@ static int iommu_init_pci(struct amd_iommu *iommu)
 	if (is_rd890_iommu(iommu->dev)) {
 		int i, j;
 
-		iommu->root_pdev = pci_get_bus_and_slot(iommu->dev->bus->number,
-				PCI_DEVFN(0, 0));
+		iommu->root_pdev =
+			pci_get_domain_bus_and_slot(0, iommu->dev->bus->number,
+						    PCI_DEVFN(0, 0));
 
 		/*
 		 * Some rd890 systems may not be fully reconfigured by the
drivers/iommu/amd_iommu_v2.c +2 -1
index 7d94e1d..8696382 100644
@@ -564,7 +564,8 @@ static int ppr_notifier(struct notifier_block *nb, unsigned long e, void *data)
 	finish      = (iommu_fault->tag >> 9) & 1;
 
 	devid = iommu_fault->device_id;
-	pdev = pci_get_bus_and_slot(PCI_BUS_NUM(devid), devid & 0xff);
+	pdev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(devid),
+					   devid & 0xff);
 	if (!pdev)
 		return -ENODEV;
 	dev_data = get_dev_data(&pdev->dev);
Signature · 1 line
1.9.1
author
#24 lore raw

Re: [PATCH V4 11/26] iommu/amd: deprecate pci_get_bus_and_slot()

Quoted 63 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-code the domain number as 0 for the AMD IOMMU driver.

---
 drivers/iommu/amd_iommu.c      | 3 ++-
 drivers/iommu/amd_iommu_init.c | 9 +++++----
 drivers/iommu/amd_iommu_v2.c   | 3 ++-
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/iommu/amd_iommu.c +2 -1
index 7d5eb00..821547b 100644
@@ -527,7 +527,8 @@ static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
 	struct iommu_dev_data *dev_data = NULL;
 	struct pci_dev *pdev;
 
-	pdev = pci_get_bus_and_slot(PCI_BUS_NUM(devid), devid & 0xff);
+	pdev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(devid),
+					   devid & 0xff);
 	if (pdev)
 		dev_data = get_dev_data(&pdev->dev);
 
drivers/iommu/amd_iommu_init.c +5 -4
index 6fe2d03..4e4a615 100644
@@ -1697,8 +1697,8 @@ static int iommu_init_pci(struct amd_iommu *iommu)
 	u32 range, misc, low, high;
 	int ret;
 
-	iommu->dev = pci_get_bus_and_slot(PCI_BUS_NUM(iommu->devid),
-					  iommu->devid & 0xff);
+	iommu->dev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(iommu->devid),
+						 iommu->devid & 0xff);
 	if (!iommu->dev)
 		return -ENODEV;
 
@@ -1764,8 +1764,9 @@ static int iommu_init_pci(struct amd_iommu *iommu)
 	if (is_rd890_iommu(iommu->dev)) {
 		int i, j;
 
-		iommu->root_pdev = pci_get_bus_and_slot(iommu->dev->bus->number,
-				PCI_DEVFN(0, 0));
+		iommu->root_pdev =
+			pci_get_domain_bus_and_slot(0, iommu->dev->bus->number,
+						    PCI_DEVFN(0, 0));
 
 		/*
 		 * Some rd890 systems may not be fully reconfigured by the
drivers/iommu/amd_iommu_v2.c +0 -0
index 7d94e1d..8696382 100644

drivers/iommu/amd_iommu_v2.c static int ppr_notifier(struct notifier_block *nb, unsigned long e, void *data) · line 571

Quoted 9 lines
drivers/iommu/amd_iommu_v2.c +2 -1
@@ -564,7 +564,8 @@ static int ppr_notifier(struct notifier_block *nb, unsigned long e, void *data)
 	finish      = (iommu_fault->tag >> 9) & 1;
 
 	devid = iommu_fault->device_id;
-	pdev = pci_get_bus_and_slot(PCI_BUS_NUM(devid), devid & 0xff);
+	pdev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(devid),
+					   devid & 0xff);
 	if (!pdev)
 		return -ENODEV;
 	dev_data = get_dev_data(&pdev->dev);

Any comments from the IOMMU people?

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#25 lore raw

Re: [PATCH V4 11/26] iommu/amd: deprecate pci_get_bus_and_slot()

Quoted 9 lines · Sinan Kaya
Quoted 8 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-code the domain number as 0 for the AMD IOMMU driver.

<snip>

Quoted 3 lines

Any comments from the IOMMU people?

pci_get_bus_and_slot() appears to (now) be a convenience function that wraps pci_get_domain_bus_and_slot() while using a 0 for the domain value. Exactly what you are doing here, albeit in a more overt way.

How is this patch advantageous? Seems to me that if other domains need to be enabled, that driver could be changed if and when that requirement arises.

But perhaps I'm missing a nuance here.

author
#26 lore raw

Re: [PATCH V4 11/26] iommu/amd: deprecate pci_get_bus_and_slot()

Quoted 14 lines · Gary R Hook
Quoted 9 lines · Sinan Kaya
Quoted 8 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-code the domain number as 0 for the AMD IOMMU driver.

<snip>

Quoted 1 line
Quoted 10 lines
Quoted 2 lines

Any comments from the IOMMU people?

pci_get_bus_and_slot() appears to (now) be a convenience function that wraps pci_get_domain_bus_and_slot() while using a 0 for the domain value. Exactly what you are doing here, albeit in a more overt way.

How is this patch advantageous? Seems to me that if other domains need to be enabled, that driver could be changed if and when that requirement arises.

But perhaps I'm missing a nuance here.

The benefit of the change was discussed here:

https://lkml.org/lkml/2017/12/19/349

I hope it helps.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#27 lore raw

Re: [PATCH V4 11/26] iommu/amd: deprecate pci_get_bus_and_slot()

Quoted 26 lines · Sinan Kaya
Quoted 14 lines · Gary R Hook
Quoted 9 lines · Sinan Kaya
Quoted 8 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-code the domain number as 0 for the AMD IOMMU driver.

<snip>

Quoted 1 line
Quoted 10 lines
Quoted 2 lines

Any comments from the IOMMU people?

pci_get_bus_and_slot() appears to (now) be a convenience function that wraps pci_get_domain_bus_and_slot() while using a 0 for the domain value. Exactly what you are doing here, albeit in a more overt way.

How is this patch advantageous? Seems to me that if other domains need to be enabled, that driver could be changed if and when that requirement arises.

But perhaps I'm missing a nuance here.

Quoted 7 lines

The benefit of the change was discussed here:

https://lkml.org/lkml/2017/12/19/349

I hope it helps.

Thank you for pointing out that thread directly. I read through it and thought further about this change.

I am not the maintainer, but as an AMD developer, this is fine change. I can't ACK but I can agree.

Gary

maintainer Acked-by on v4 11/26
#28 lore raw

Re: [PATCH V4 11/26] iommu/amd: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya
Quoted 7 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Quoted 8 lines

Hard-code the domain number as 0 for the AMD IOMMU driver.

---
 drivers/iommu/amd_iommu.c      | 3 ++-
 drivers/iommu/amd_iommu_init.c | 9 +++++----
 drivers/iommu/amd_iommu_v2.c   | 3 ++-
 3 files changed, 9 insertions(+), 6 deletions(-)
author
#29 lore raw

PATCH v4 12/26 powerpc/powermac: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-code the domain number as 0 to match the previous behavior.

---
 drivers/macintosh/via-pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/macintosh/via-pmu.c +1 -1
index e8b29fc..08849e3 100644
@@ -1799,7 +1799,7 @@ static int powerbook_sleep_grackle(void)
 	struct adb_request req;
 	struct pci_dev *grackle;
 
-	grackle = pci_get_bus_and_slot(0, 0);
+	grackle = pci_get_domain_bus_and_slot(0, 0, 0);
 	if (!grackle)
 		return -ENODEV;
 
Signature · 1 line
1.9.1
author
#30 lore raw

PATCH v4 13/26 bnx2x: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Introduce bnx2x_vf_domain() function to extract the domain information and save it to VF specific data structure.

Use the saved domain value while calling pci_get_domain_bus_and_slot().

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 10 +++++++++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +9 -1
index 3591077..ffa7959 100644
@@ -812,7 +812,7 @@ static u8 bnx2x_vf_is_pcie_pending(struct bnx2x *bp, u8 abs_vfid)
 	if (!vf)
 		return false;
 
-	dev = pci_get_bus_and_slot(vf->bus, vf->devfn);
+	dev = pci_get_domain_bus_and_slot(vf->domain, vf->bus, vf->devfn);
 	if (dev)
 		return bnx2x_is_pcie_pending(dev);
 	return false;
@@ -1041,6 +1041,13 @@ void bnx2x_iov_init_dmae(struct bnx2x *bp)
 		REG_WR(bp, DMAE_REG_BACKWARD_COMP_EN, 0);
 }
 
+static int bnx2x_vf_domain(struct bnx2x *bp, int vfid)
+{
+	struct pci_dev *dev = bp->pdev;
+
+	return pci_domain_nr(dev->bus);
+}
+
 static int bnx2x_vf_bus(struct bnx2x *bp, int vfid)
 {
 	struct pci_dev *dev = bp->pdev;
@@ -1606,6 +1613,7 @@ int bnx2x_iov_nic_init(struct bnx2x *bp)
 		struct bnx2x_virtf *vf = BP_VF(bp, vfid);
 
 		/* fill in the BDF and bars */
+		vf->domain = bnx2x_vf_domain(bp, vfid);
 		vf->bus = bnx2x_vf_bus(bp, vfid);
 		vf->devfn = bnx2x_vf_devfn(bp, vfid);
 		bnx2x_vf_set_bars(bp, vf);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h +1 -0
index 53466f6..eb814c6 100644
@@ -182,6 +182,7 @@ struct bnx2x_virtf {
 	u32 error;	/* 0 means all's-well */
 
 	/* BDF */
+	unsigned int domain;
 	unsigned int bus;
 	unsigned int devfn;
 
Signature · 1 line
1.9.1
maintainer Acked-by on v4 13/26
#31 lore raw

Re: [PATCH V4 13/26] bnx2x: deprecate pci_get_bus_and_slot()

From: Sinan Kaya <[email protected]>
Date: Tue, 19 Dec 2017 00:37:49 -0500

Quoted 7 lines

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Quoted 6 lines

Introduce bnx2x_vf_domain() function to extract the domain information and save it to VF specific data structure.

Use the saved domain value while calling pci_get_domain_bus_and_slot().

author
#32 lore raw

PATCH v4 14/26 pch_gbe: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Use the domain information from pdev while calling into pci_get_domain_bus_and_slot() function.

---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +4 -2
index 40e52ff..7cd4946 100644
@@ -2594,8 +2594,10 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 	if (adapter->pdata && adapter->pdata->platform_init)
 		adapter->pdata->platform_init(pdev);
 
-	adapter->ptp_pdev = pci_get_bus_and_slot(adapter->pdev->bus->number,
-					       PCI_DEVFN(12, 4));
+	adapter->ptp_pdev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(adapter->pdev->bus),
+					    adapter->pdev->bus->number,
+					    PCI_DEVFN(12, 4));
 
 	netdev->netdev_ops = &pch_gbe_netdev_ops;
 	netdev->watchdog_timeo = PCH_GBE_WATCHDOG_PERIOD;
Signature · 1 line
1.9.1
#33 lore raw

Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot()

Quoted 7 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Where this idea come from?

pci_get_bus_and_slot() still might be useful for the wired devices in SoC where we know for sure that domain == 0.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
author
#34 lore raw

Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot()

Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Where this idea come from?

There are systems out (mostly ARM) there with non-zero segment numbers. The pci_get_bus_and_slot() API is restrictive and unnecessarily forces 0 segment numbers for some generic device drivers. Obtaining the segment number is as easy as calling pci_domain_nr().

The problems with pci_get_bus_and_slot() are:

1. we don't know if the device driver intentionally called pci_get_bus_and_slot() to limit 0 segment number.
2. we don't know if the driver developer just copied an example from another system and it just happened to work on x86 architecture while broken on other architectures.

Some device drivers may want to limit the segment number. Than specifying 0 while calling pci_get_domain_bus_and_slot() is a better way to express this.

pci_get_bus_and_slot() is unnecessarily restricting some device drivers. Nvidia as an example. I remember that somebody came up with a very ugly patch to force segment 0 into Microsoft hypervisor layer.

This was rejected out right and told to fix the Nvidia driver instead. This patch essentially fixes some of these flaws while removing the limiting API from the kernel altogether so that same mistakes are not made.

Quoted 4 lines

pci_get_bus_and_slot() still might be useful for the wired devices in SoC where we know for sure that domain == 0.

Then hard code the domain number as 0 while calling pci_get_domain_bus_and_slot() if you know for sure that this device will never work on a non-zero domain.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#35 lore raw

Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot()

Quoted 9 lines · Sinan Kaya
Quoted 7 lines · Andy Shevchenko
Quoted 1 line · Sinan Kaya

pci_get_bus_and_slot() still might be useful for the wired devices in
SoC where we know for sure that domain == 0.

Quoted 4 lines

Then hard code the domain number as 0 while calling pci_get_domain_bus_and_slot()
if you know for sure that this device will never work on a non-zero domain.

Thanks for so detailed explanation.

Okay, I suppose you did estimate the amount of drivers / modules that may look better with pci_get_bus_and_slot() and the result is comparable
small.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
maintainer
#36 lore raw

Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

From: Sinan Kaya <[email protected]>
Date: Tue, 19 Dec 2017 07:17:41 -0500

Quoted 3 lines

Then hard code the domain number as 0 while calling pci_get_domain_bus_and_slot() if you know for sure that this device will never work on a non-zero domain.

Agreed, it's so much better to be explicit about this.

maintainer Acked-by on v4 14/26
#37 lore raw

Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

From: Sinan Kaya <[email protected]>
Date: Tue, 19 Dec 2017 00:37:50 -0500

Quoted 11 lines

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Use the domain information from pdev while calling into pci_get_domain_bus_and_slot() function.

author
#38 lore raw

PATCH v4 15/26 PCI: cpqhp: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-coding the domain number as 0. The code doesn't seem to be ready for multiple domains.

---
 drivers/pci/hotplug/cpqphp_pci.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/pci/hotplug/cpqphp_pci.c +14 -4
index e220d49..8897a77 100644
@@ -89,7 +89,9 @@ int cpqhp_configure_device(struct controller *ctrl, struct pci_func *func)
 	pci_lock_rescan_remove();
 
 	if (func->pci_dev == NULL)
-		func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function));
+		func->pci_dev = pci_get_domain_bus_and_slot(0, func->bus,
+							PCI_DEVFN(func->device,
+							func->function));
 
 	/* No pci device, we need to create it then */
 	if (func->pci_dev == NULL) {
@@ -99,7 +101,9 @@ int cpqhp_configure_device(struct controller *ctrl, struct pci_func *func)
 		if (num)
 			pci_bus_add_devices(ctrl->pci_dev->bus);
 
-		func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function));
+		func->pci_dev = pci_get_domain_bus_and_slot(0, func->bus,
+							PCI_DEVFN(func->device,
+							func->function));
 		if (func->pci_dev == NULL) {
 			dbg("ERROR: pci_dev still null\n");
 			goto out;
@@ -129,7 +133,10 @@ int cpqhp_unconfigure_device(struct pci_func *func)
 
 	pci_lock_rescan_remove();
 	for (j = 0; j < 8 ; j++) {
-		struct pci_dev *temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j));
+		struct pci_dev *temp = pci_get_domain_bus_and_slot(0,
+							func->bus,
+							PCI_DEVFN(func->device,
+							j));
 		if (temp) {
 			pci_dev_put(temp);
 			pci_stop_and_remove_bus_device(temp);
@@ -319,6 +326,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
 	int cloop = 0;
 	int stop_it;
 	int index;
+	u16 devfn;
 
 	/* Decide which slots are supported */
 
@@ -416,7 +424,9 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
 			new_slot->switch_save = 0x10;
 			/* In case of unsupported board */
 			new_slot->status = DevError;
-			new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function);
+			devfn = (new_slot->device << 3) | new_slot->function;
+			new_slot->pci_dev = pci_get_domain_bus_and_slot(0,
+							new_slot->bus, devfn);
 
 			for (cloop = 0; cloop < 0x20; cloop++) {
 				rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) &(new_slot->config_space[cloop]));
Signature · 1 line
1.9.1
author
#39 lore raw

PATCH v4 16/26 PCI: ibmphp: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-coding the domain parameter as 0 since the code doesn't seem to be ready for multiple domains.

---
 drivers/pci/hotplug/ibmphp_core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pci/hotplug/ibmphp_core.c +4 -3
index 73cf846..92dd882 100644
@@ -707,7 +707,8 @@ static void ibm_unconfigure_device(struct pci_func *func)
 	pci_lock_rescan_remove();
 
 	for (j = 0; j < 0x08; j++) {
-		temp = pci_get_bus_and_slot(func->busno, (func->device << 3) | j);
+		temp = pci_get_domain_bus_and_slot(0, func->busno,
+						   (func->device << 3) | j);
 		if (temp) {
 			pci_stop_and_remove_bus_device(temp);
 			pci_dev_put(temp);
@@ -780,7 +781,7 @@ static int ibm_configure_device(struct pci_func *func)
 	if (!(bus_structure_fixup(func->busno)))
 		flag = 1;
 	if (func->dev == NULL)
-		func->dev = pci_get_bus_and_slot(func->busno,
+		func->dev = pci_get_domain_bus_and_slot(0, func->busno,
 				PCI_DEVFN(func->device, func->function));
 
 	if (func->dev == NULL) {
@@ -793,7 +794,7 @@ static int ibm_configure_device(struct pci_func *func)
 		if (num)
 			pci_bus_add_devices(bus);
 
-		func->dev = pci_get_bus_and_slot(func->busno,
+		func->dev = pci_get_domain_bus_and_slot(0, func->busno,
 				PCI_DEVFN(func->device, func->function));
 		if (func->dev == NULL) {
 			err("ERROR... : pci_dev still NULL\n");
Signature · 1 line
1.9.1
author
#40 lore raw

PATCH v4 17/26 PCI/quirks: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Extract the domain number from pdev while calling into pci_get_domain_bus_and_slot() function.

---
 drivers/pci/quirks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/quirks.c +2 -1
index fd49b97..d7aa31f 100644
@@ -2698,7 +2698,8 @@ static void __nv_msi_ht_cap_quirk(struct pci_dev *dev, int all)
 	 * HT MSI mapping should be disabled on devices that are below
 	 * a non-Hypertransport host bridge. Locate the host bridge...
 	 */
-	host_bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
+	host_bridge = pci_get_domain_bus_and_slot(pci_domain_nr(dev->bus), 0,
+						  PCI_DEVFN(0, 0));
 	if (host_bridge == NULL) {
 		dev_warn(&dev->dev, "nv_msi_ht_cap_quirk didn't locate host bridge\n");
 		return;
Signature · 1 line
1.9.1
author
#41 lore raw

PATCH v4 18/26 PCI/syscall: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-coding the domain value as 0 because the domain information is not coming from the userspace.

---
 drivers/pci/syscall.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/syscall.c +2 -2
index 83efa00..e725f99 100644
@@ -28,7 +28,7 @@
 		return -EPERM;
 
 	err = -ENODEV;
-	dev = pci_get_bus_and_slot(bus, dfn);
+	dev = pci_get_domain_bus_and_slot(0, bus, dfn);
 	if (!dev)
 		goto error;
 
@@ -96,7 +96,7 @@
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	dev = pci_get_bus_and_slot(bus, dfn);
+	dev = pci_get_domain_bus_and_slot(0, bus, dfn);
 	if (!dev)
 		return -ENODEV;
 
Signature · 1 line
1.9.1
author
#42 lore raw

PATCH v4 19/26 xen: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't extract the domain number. Other places, use the actual domain number from the device.

---
 drivers/pci/xen-pcifront.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/xen-pcifront.c +2 -1
index 8fc2e95..94b25b5 100644
@@ -595,6 +595,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
 	struct pci_driver *pdrv;
 	int bus = pdev->sh_info->aer_op.bus;
 	int devfn = pdev->sh_info->aer_op.devfn;
+	int domain = pdev->sh_info->aer_op.domain;
 	struct pci_dev *pcidev;
 	int flag = 0;
 
@@ -603,7 +604,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
 		cmd, bus, devfn);
 	result = PCI_ERS_RESULT_NONE;
 
-	pcidev = pci_get_bus_and_slot(bus, devfn);
+	pcidev = pci_get_domain_bus_and_slot(domain, bus, devfn);
 	if (!pcidev || !pcidev->driver) {
 		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
 		pci_dev_put(pcidev);
Signature · 1 line
1.9.1
author
#43 lore raw

PATCH v4 20/26 openprom: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-coding the domain as 0 since domain information is not available.

---
 drivers/sbus/char/openprom.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/sbus/char/openprom.c +3 -2
index 2c2e6a3..7b31f19 100644
@@ -251,8 +251,9 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp
 		struct pci_dev *pdev;
 		struct device_node *dp;
 
-		pdev = pci_get_bus_and_slot (((int *) op->oprom_array)[0],
-				      ((int *) op->oprom_array)[1]);
+		pdev = pci_get_domain_bus_and_slot(0,
+						((int *) op->oprom_array)[0],
+						((int *) op->oprom_array)[1]);
 
 		dp = pci_device_to_OF_node(pdev);
 		data->current_node = dp;
Signature · 1 line
1.9.1
maintainer Acked-by on v4 20/26
#44 lore raw

Re: [PATCH V4 20/26] openprom: deprecate pci_get_bus_and_slot()

From: Sinan Kaya <[email protected]>
Date: Tue, 19 Dec 2017 00:37:56 -0500

Quoted 10 lines

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-coding the domain as 0 since domain information is not available.

author
#45 lore raw

PATCH v4 21/26 backlight: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Hard-coding the domain as 0.

---
 drivers/video/backlight/apple_bl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/backlight/apple_bl.c +1 -1
index d843296..6a34ab9 100644
@@ -143,7 +143,7 @@ static int apple_bl_add(struct acpi_device *dev)
 	struct pci_dev *host;
 	int intensity;
 
-	host = pci_get_bus_and_slot(0, 0);
+	host = pci_get_domain_bus_and_slot(0, 0, 0);
 
 	if (!host) {
 		pr_err("unable to find PCI host\n");
Signature · 1 line
1.9.1
Applied
#46 lore raw

Re: [PATCH V4 21/26] backlight: deprecate pci_get_bus_and_slot()

Quoted 7 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Quoted 8 lines

Hard-coding the domain as 0.

---
 drivers/video/backlight/apple_bl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Signature · 4 lines
Lee Jones
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#47 lore raw

PATCH v4 22/26 video: fbdev: intelfb: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Find the domain number from pdev.

---
 drivers/video/fbdev/intelfb/intelfbhw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/video/fbdev/intelfb/intelfbhw.c +3 -1
index 83fec57..57aff74 100644
@@ -181,7 +181,9 @@ int intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
 		return 1;
 
 	/* Find the bridge device.  It is always 0:0.0 */
-	if (!(bridge_dev = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)))) {
+	bridge_dev = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 0,
+						 PCI_DEVFN(0, 0));
+	if (!bridge_dev) {
 		ERR_MSG("cannot find bridge device\n");
 		return 1;
 	}
Signature · 1 line
1.9.1
author
#48 lore raw

Re: [PATCH V4 22/26] video: fbdev: intelfb: deprecate pci_get_bus_and_slot()

Quoted 10 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Find the domain number from pdev.

Any feedback here ? most of the remaining patches have the ACK except these.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#49 lore raw

Re: [PATCH V4 22/26] video: fbdev: intelfb: deprecate pci_get_bus_and_slot()

Quoted 5 lines · Sinan Kaya
Quoted 4 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Quoted 8 lines
Quoted 6 lines

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Find the domain number from pdev.

Any feedback here ? most of the remaining patches have the ACK except these.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

author
#50 lore raw

PATCH v4 23/26 video: fbdev: nvidia: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

struct nvidia_par has a pointer to struct pci_dev. Use the pci_dev member to extract the domain information and pass it to pci_get_domain_bus_and_slot() function.

---
 drivers/video/fbdev/nvidia/nv_hw.c    | 11 ++++++-----
 drivers/video/fbdev/nvidia/nv_setup.c |  3 ++-
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/video/fbdev/nvidia/nv_hw.c +6 -5
index 81c80ac..8335da4 100644
@@ -683,10 +683,11 @@ static void nForceUpdateArbitrationSettings(unsigned VClk,
 	nv10_sim_state sim_data;
 	unsigned int M, N, P, pll, MClk, NVClk, memctrl;
 	struct pci_dev *dev;
+	int domain = pci_domain_nr(par->pci_dev->bus);
 
 	if ((par->Chipset & 0x0FF0) == 0x01A0) {
 		unsigned int uMClkPostDiv;
-		dev = pci_get_bus_and_slot(0, 3);
+		dev = pci_get_domain_bus_and_slot(domain, 0, 3);
 		pci_read_config_dword(dev, 0x6C, &uMClkPostDiv);
 		uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf;
 
@@ -694,7 +695,7 @@ static void nForceUpdateArbitrationSettings(unsigned VClk,
 			uMClkPostDiv = 4;
 		MClk = 400000 / uMClkPostDiv;
 	} else {
-		dev = pci_get_bus_and_slot(0, 5);
+		dev = pci_get_domain_bus_and_slot(domain, 0, 5);
 		pci_read_config_dword(dev, 0x4c, &MClk);
 		MClk /= 1000;
 	}
@@ -707,13 +708,13 @@ static void nForceUpdateArbitrationSettings(unsigned VClk,
 	sim_data.pix_bpp = (char)pixelDepth;
 	sim_data.enable_video = 0;
 	sim_data.enable_mp = 0;
-	dev = pci_get_bus_and_slot(0, 1);
+	dev = pci_get_domain_bus_and_slot(domain, 0, 1);
 	pci_read_config_dword(dev, 0x7C, &sim_data.memory_type);
 	pci_dev_put(dev);
 	sim_data.memory_type = (sim_data.memory_type >> 12) & 1;
 	sim_data.memory_width = 64;
 
-	dev = pci_get_bus_and_slot(0, 3);
+	dev = pci_get_domain_bus_and_slot(domain, 0, 3);
 	pci_read_config_dword(dev, 0, &memctrl);
 	pci_dev_put(dev);
 	memctrl >>= 16;
@@ -721,7 +722,7 @@ static void nForceUpdateArbitrationSettings(unsigned VClk,
 	if ((memctrl == 0x1A9) || (memctrl == 0x1AB) || (memctrl == 0x1ED)) {
 		u32 dimm[3];
 
-		dev = pci_get_bus_and_slot(0, 2);
+		dev = pci_get_domain_bus_and_slot(domain, 0, 2);
 		pci_read_config_dword(dev, 0x40, &dimm[0]);
 		dimm[0] = (dimm[0] >> 8) & 0x4f;
 		pci_read_config_dword(dev, 0x44, &dimm[1]);
drivers/video/fbdev/nvidia/nv_setup.c +2 -1
index 2f2e162..b17acd2 100644
@@ -264,7 +264,8 @@ static void nv10GetConfig(struct nvidia_par *par)
 	}
 #endif
 
-	dev = pci_get_bus_and_slot(0, 1);
+	dev = pci_get_domain_bus_and_slot(pci_domain_nr(par->pci_dev->bus),
+					  0, 1);
 	if ((par->Chipset & 0xffff) == 0x01a0) {
 		u32 amt;
 
Signature · 1 line
1.9.1
author
#51 lore raw

Re: [PATCH V4 23/26] video: fbdev: nvidia: deprecate pci_get_bus_and_slot()

Quoted 4 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Quoted 8 lines

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

struct nvidia_par has a pointer to struct pci_dev. Use the pci_dev member to extract the domain information and pass it to pci_get_domain_bus_and_slot() function.

Any feedback here ? most of the remaining patches have the ACK except these.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#52 lore raw

Re: [PATCH V4 23/26] video: fbdev: nvidia: deprecate pci_get_bus_and_slot()

Quoted 8 lines · Sinan Kaya
Quoted 7 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

Quoted 7 lines
Quoted 5 lines

struct nvidia_par has a pointer to struct pci_dev. Use the pci_dev member to extract the domain information and pass it to pci_get_domain_bus_and_slot() function.

Any feedback here ? most of the remaining patches have the ACK except these.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

author
#53 lore raw

PATCH v4 24/26 video: fbdev: riva: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

struct riva_par has a pointer to struct pci_dev. Use the pci_dev member to extract the domain information.

Change the function signature for CalcStateExt and RivaGetConfig to pass in struct pci_dev in addition to RIVA_HW_INST so that code inside the riva_hw.c can also calculate domain number and pass it to pci_get_domain_bus_and_slot().

---
 drivers/video/fbdev/riva/fbdev.c     |  2 +-
 drivers/video/fbdev/riva/nv_driver.c |  7 ++++---
 drivers/video/fbdev/riva/riva_hw.c   | 20 +++++++++++++-------
 drivers/video/fbdev/riva/riva_hw.h   |  3 ++-
 4 files changed, 20 insertions(+), 12 deletions(-)
drivers/video/fbdev/riva/fbdev.c +1 -1
index 1ea78bb..ff82823 100644
@@ -780,7 +780,7 @@ static int riva_load_video_mode(struct fb_info *info)
 	else
 		newmode.misc_output |= 0x80;	
 
-	rc = CalcStateExt(&par->riva, &newmode.ext, bpp, width,
+	rc = CalcStateExt(&par->riva, &newmode.ext, par->pdev, bpp, width,
 			  hDisplaySize, height, dotClock);
 	if (rc)
 		goto out;
drivers/video/fbdev/riva/nv_driver.c +4 -3
index f3694cf..a3d9c66 100644
@@ -159,6 +159,7 @@ unsigned long riva_get_memlen(struct riva_par *par)
 	unsigned int chipset = par->Chipset;
 	struct pci_dev* dev;
 	u32 amt;
+	int domain = pci_domain_nr(par->pdev->bus);
 
 	switch (chip->Architecture) {
 	case NV_ARCH_03:
@@ -226,12 +227,12 @@ unsigned long riva_get_memlen(struct riva_par *par)
 	case NV_ARCH_30:
 		if(chipset == NV_CHIP_IGEFORCE2) {
 
-			dev = pci_get_bus_and_slot(0, 1);
+			dev = pci_get_domain_bus_and_slot(domain, 0, 1);
 			pci_read_config_dword(dev, 0x7C, &amt);
 			pci_dev_put(dev);
 			memlen = (((amt >> 6) & 31) + 1) * 1024;
 		} else if (chipset == NV_CHIP_0x01F0) {
-			dev = pci_get_bus_and_slot(0, 1);
+			dev = pci_get_domain_bus_and_slot(domain, 0, 1);
 			pci_read_config_dword(dev, 0x84, &amt);
 			pci_dev_put(dev);
 			memlen = (((amt >> 4) & 127) + 1) * 1024;
@@ -417,6 +418,6 @@ unsigned long riva_get_maxdclk(struct riva_par *par)
 	}
 	par->riva.flatPanel = (par->FlatPanel > 0) ? TRUE : FALSE;
 
-	RivaGetConfig(&par->riva, par->Chipset);
+	RivaGetConfig(&par->riva, par->pdev, par->Chipset);
 }
 
drivers/video/fbdev/riva/riva_hw.c +13 -7
index 8bdf37f..0601c13 100644
@@ -1108,7 +1108,8 @@ static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_ar
     unsigned      pixelDepth,
     unsigned     *burst,
     unsigned     *lwm,
-    RIVA_HW_INST *chip
+    RIVA_HW_INST *chip,
+    struct pci_dev *pdev
 )
 {
     nv10_fifo_info fifo_data;
@@ -1116,8 +1117,9 @@ static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_ar
     unsigned int M, N, P, pll, MClk, NVClk;
     unsigned int uMClkPostDiv;
     struct pci_dev *dev;
+    int domain = pci_domain_nr(pdev->bus);
 
-    dev = pci_get_bus_and_slot(0, 3);
+    dev = pci_get_domain_bus_and_slot(domain, 0, 3);
     pci_read_config_dword(dev, 0x6C, &uMClkPostDiv);
     pci_dev_put(dev);
     uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf;
@@ -1132,7 +1134,7 @@ static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_ar
     sim_data.enable_video   = 0;
     sim_data.enable_mp      = 0;
 
-    dev = pci_get_bus_and_slot(0, 1);
+    dev = pci_get_domain_bus_and_slot(domain, 0, 1);
     pci_read_config_dword(dev, 0x7C, &sim_data.memory_type);
     pci_dev_put(dev);
     sim_data.memory_type    = (sim_data.memory_type >> 12) & 1;
@@ -1234,6 +1236,7 @@ static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_ar
 (
     RIVA_HW_INST  *chip,
     RIVA_HW_STATE *state,
+    struct pci_dev *pdev,
     int            bpp,
     int            width,
     int            hDisplaySize,
@@ -1300,7 +1303,7 @@ static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_ar
                                           pixelDepth * 8,
                                          &(state->arbitration0),
                                          &(state->arbitration1),
-                                          chip);
+                                          chip, pdev);
             } else {
                 nv10UpdateArbitrationSettings(VClk, 
                                           pixelDepth * 8, 
@@ -2102,10 +2105,12 @@ static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_ar
 static void nv10GetConfig
 (
     RIVA_HW_INST *chip,
+    struct pci_dev *pdev,
     unsigned int chipset
 )
 {
     struct pci_dev* dev;
+    int domain = pci_domain_nr(pdev->bus);
     u32 amt;
 
 #ifdef __BIG_ENDIAN
@@ -2118,12 +2123,12 @@ static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_ar
      * Fill in chip configuration.
      */
     if(chipset == NV_CHIP_IGEFORCE2) {
-        dev = pci_get_bus_and_slot(0, 1);
+        dev = pci_get_domain_bus_and_slot(domain, 0, 1);
         pci_read_config_dword(dev, 0x7C, &amt);
         pci_dev_put(dev);
         chip->RamAmountKBytes = (((amt >> 6) & 31) + 1) * 1024;
     } else if(chipset == NV_CHIP_0x01F0) {
-        dev = pci_get_bus_and_slot(0, 1);
+        dev = pci_get_domain_bus_and_slot(domain, 0, 1);
         pci_read_config_dword(dev, 0x84, &amt);
         pci_dev_put(dev);
         chip->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024;
@@ -2224,6 +2229,7 @@ static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_ar
 int RivaGetConfig
 (
     RIVA_HW_INST *chip,
+    struct pci_dev *pdev,
     unsigned int chipset
 )
 {
@@ -2245,7 +2251,7 @@ static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_ar
         case NV_ARCH_10:
         case NV_ARCH_20:
         case NV_ARCH_30:
-            nv10GetConfig(chip, chipset);
+            nv10GetConfig(chip, pdev, chipset);
             break;
         default:
             return (-1);
drivers/video/fbdev/riva/riva_hw.h +2 -1
index c2769f7..5e7b354 100644
@@ -536,6 +536,7 @@
 (
     RIVA_HW_INST  *chip,
     RIVA_HW_STATE *state,
+    struct pci_dev *pdev,
     int            bpp,
     int            width,
     int            hDisplaySize,
@@ -546,7 +547,7 @@
 /*
  * External routines.
  */
-int RivaGetConfig(RIVA_HW_INST *, unsigned int);
+int RivaGetConfig(RIVA_HW_INST *chip, struct pci_dev *pdev, unsigned int c);
 /*
  * FIFO Free Count. Should attempt to yield processor if RIVA is busy.
  */
Signature · 1 line
1.9.1
author
#54 lore raw

Re: [PATCH V4 24/26] video: fbdev: riva: deprecate pci_get_bus_and_slot()

Quoted 10 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

struct riva_par has a pointer to struct pci_dev. Use the pci_dev member to extract the domain information.

Quoted 6 lines

Change the function signature for CalcStateExt and RivaGetConfig to pass in struct pci_dev in addition to RIVA_HW_INST so that code inside the riva_hw.c can also calculate domain number and pass it to pci_get_domain_bus_and_slot().

Any feedback here, most of the remaining patches have the ACK except these?

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#55 lore raw

Re: [PATCH V4 24/26] video: fbdev: riva: deprecate pci_get_bus_and_slot()

Quoted 11 lines · Sinan Kaya
Quoted 10 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot().

struct riva_par has a pointer to struct pci_dev. Use the pci_dev member to extract the domain information.

Quoted 8 lines
Quoted 6 lines

Change the function signature for CalcStateExt and RivaGetConfig to pass in struct pci_dev in addition to RIVA_HW_INST so that code inside the riva_hw.c can also calculate domain number and pass it to pci_get_domain_bus_and_slot().

Any feedback here, most of the remaining patches have the ACK except these?

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

author
#56 lore raw

PATCH v4 25/26 i7300_idle: remove unused file

In reply to Sinan Kaya

i7300_idle.h is not being called by any source file and contains calls to pci_get_bus_and_slot() that we are trying to deprecate. Remove unused file.

---
 include/linux/i7300_idle.h | 84 ----------------------------------------------
 1 file changed, 84 deletions(-)
 delete mode 100644 include/linux/i7300_idle.h
include/linux/i7300_idle.h deleted +0 -84
deleted file mode 100644
index 4dbe651..0000000
@@ -1,84 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef I7300_IDLE_H
-#define I7300_IDLE_H
-
-#include <linux/pci.h>
-
-/*
- * I/O AT controls (PCI bus 0 device 8 function 0)
- * DIMM controls (PCI bus 0 device 16 function 1)
- */
-#define IOAT_BUS 0
-#define IOAT_DEVFN PCI_DEVFN(8, 0)
-#define MEMCTL_BUS 0
-#define MEMCTL_DEVFN PCI_DEVFN(16, 1)
-
-struct fbd_ioat {
-	unsigned int vendor;
-	unsigned int ioat_dev;
-	unsigned int enabled;
-};
-
-/*
- * The i5000 chip-set has the same hooks as the i7300
- * but it is not enabled by default and must be manually
- * manually enabled with "forceload=1" because it is
- * only lightly validated.
- */
-
-static const struct fbd_ioat fbd_ioat_list[] = {
-	{PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_CNB, 1},
-	{PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT, 0},
-	{0, 0}
-};
-
-/* table of devices that work with this driver */
-static const struct pci_device_id pci_tbl[] = {
-	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_FBD_CNB) },
-	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
-	{ } /* Terminating entry */
-};
-
-/* Check for known platforms with I/O-AT */
-static inline int i7300_idle_platform_probe(struct pci_dev **fbd_dev,
-						struct pci_dev **ioat_dev,
-						int enable_all)
-{
-	int i;
-	struct pci_dev *memdev, *dmadev;
-
-	memdev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);
-	if (!memdev)
-		return -ENODEV;
-
-	for (i = 0; pci_tbl[i].vendor != 0; i++) {
-		if (memdev->vendor == pci_tbl[i].vendor &&
-		    memdev->device == pci_tbl[i].device) {
-			break;
-		}
-	}
-	if (pci_tbl[i].vendor == 0)
-		return -ENODEV;
-
-	dmadev = pci_get_bus_and_slot(IOAT_BUS, IOAT_DEVFN);
-	if (!dmadev)
-		return -ENODEV;
-
-	for (i = 0; fbd_ioat_list[i].vendor != 0; i++) {
-		if (dmadev->vendor == fbd_ioat_list[i].vendor &&
-		    dmadev->device == fbd_ioat_list[i].ioat_dev) {
-			if (!(fbd_ioat_list[i].enabled || enable_all))
-				continue;
-			if (fbd_dev)
-				*fbd_dev = memdev;
-			if (ioat_dev)
-				*ioat_dev = dmadev;
-
-			return 0;
-		}
-	}
-	return -ENODEV;
-}
-
-#endif
Signature · 1 line
1.9.1
author
#57 lore raw

Re: [PATCH V4 25/26] i7300_idle: remove unused file

Hi Greg,

Quoted 4 lines · Sinan Kaya

i7300_idle.h is not being called by any source file and contains calls to pci_get_bus_and_slot() that we are trying to deprecate. Remove unused file.

Do you think you can pick this up?

I'll start pinging all the remaining patches.

Sinan

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#58 lore raw

Re: [PATCH V4 25/26] i7300_idle: remove unused file

Quoted 9 lines · Sinan Kaya

Hi Greg,

Quoted 4 lines · Sinan Kaya

i7300_idle.h is not being called by any source file and contains calls to pci_get_bus_and_slot() that we are trying to deprecate. Remove unused file.

Do you think you can pick this up?

Sure, will do so, thanks.

greg k-h

author
#59 lore raw

PATCH v4 26/26 PCI: Remove pci_get_bus_and_slot() function

In reply to Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Now that all users of pci_get_bus_and_slot() switched to pci_get_domain_bus_and_slot(), it is now safe to remove this function.

---
 include/linux/pci.h | 8 --------
 1 file changed, 8 deletions(-)
include/linux/pci.h +0 -8
index 66cca1c..04cecbe 100644
@@ -948,11 +948,6 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
 struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
 struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 					    unsigned int devfn);
-static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
-						   unsigned int devfn)
-{
-	return pci_get_domain_bus_and_slot(0, bus, devfn);
-}
 struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
 int pci_dev_present(const struct pci_device_id *ids);
 
@@ -1660,9 +1655,6 @@ static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
 						unsigned int devfn)
 { return NULL; }
-static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
-						unsigned int devfn)
-{ return NULL; }
 static inline struct pci_dev *pci_get_domain_bus_and_slot(int domain,
 					unsigned int bus, unsigned int devfn)
 { return NULL; }
Signature · 1 line
1.9.1
#60 lore raw

Re: [PATCH V4 26/26] PCI: Remove pci_get_bus_and_slot() function

Quoted 8 lines · Sinan Kaya

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Now that all users of pci_get_bus_and_slot() switched to pci_get_domain_bus_and_slot(), it is now safe to remove this function.

Applied to pci/deprecate-get-bus-and-slot for v4.17, thanks!

Quoted 38 lines
---
 include/linux/pci.h | 8 --------
 1 file changed, 8 deletions(-)
include/linux/pci.h +0 -8
index 66cca1c..04cecbe 100644
@@ -948,11 +948,6 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
 struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
 struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 					    unsigned int devfn);
-static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
-						   unsigned int devfn)
-{
-	return pci_get_domain_bus_and_slot(0, bus, devfn);
-}
 struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
 int pci_dev_present(const struct pci_device_id *ids);
 
@@ -1660,9 +1655,6 @@ static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
 						unsigned int devfn)
 { return NULL; }
-static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
-						unsigned int devfn)
-{ return NULL; }
 static inline struct pci_dev *pci_get_domain_bus_and_slot(int domain,
 					unsigned int bus, unsigned int devfn)
 { return NULL; }
Signature · 7 lines
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#61 lore raw

v4 cover PCI: deprecate pci_get_bus_and_slot()

In reply to Sinan Kaya
Quoted 11 lines · Sinan Kaya

Deprecate pci_get_bus_and_slot() in favor of pci_get_domain_bus_and_slot() in order to remove domain 0 assumptions in the kernel.

pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers.

Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't extract the domain number. Other places, use the actual domain number from the device.

Quoted 6 lines

Changes from v3:
* rebase to linux-next
* drop drm i915 as it is going through the drm tip
* commit summary cleanups

Sinan Kaya (26):

I applied most of these on pci/deprecate-get-bus-and-slot for v4.16. Details below:

Quoted 1 line

alpha/PCI: deprecate pci_get_bus_and_slot()

Applied.

Quoted 1 line

powerpc/PCI: deprecate pci_get_bus_and_slot()

Aplied with Michael's ack.

Quoted 7 lines

x86/PCI: deprecate pci_get_bus_and_slot()
ata: deprecate pci_get_bus_and_slot()
agp: nvidia: deprecate pci_get_bus_and_slot()
edd: deprecate pci_get_bus_and_slot()
ibft: deprecate pci_get_bus_and_slot()
drm/gma500: deprecate pci_get_bus_and_slot()
drm/nouveau: deprecate pci_get_bus_and_slot()

Applied.

Quoted 1 line

Drivers: ide: deprecate pci_get_bus_and_slot()

Applied with David's ack.

Quoted 1 line

iommu/amd: deprecate pci_get_bus_and_slot()

Applied with Gary's informal approval converted to

Quoted 1 line

powerpc/powermac: deprecate pci_get_bus_and_slot()

Applied.

Quoted 2 lines

bnx2x: deprecate pci_get_bus_and_slot()
pch_gbe: deprecate pci_get_bus_and_slot()

Applied with David's ack.

Quoted 2 lines

PCI: cpqhp: deprecate pci_get_bus_and_slot()
PCI: ibmphp: deprecate pci_get_bus_and_slot()

Applied.

Quoted 2 lines

PCI/quirks: deprecate pci_get_bus_and_slot()
PCI/syscall: deprecate pci_get_bus_and_slot()

Applied (squashed together).

Quoted 1 line

xen: deprecate pci_get_bus_and_slot()

Applied.

Quoted 1 line

openprom: deprecate pci_get_bus_and_slot()

Applied with David's ack.

Quoted 1 line

backlight: deprecate pci_get_bus_and_slot()

Dropped because Lee applied it.

Quoted 3 lines

video: fbdev: intelfb: deprecate pci_get_bus_and_slot()
video: fbdev: nvidia: deprecate pci_get_bus_and_slot()
video: fbdev: riva: deprecate pci_get_bus_and_slot()

Applied with Bartlomiej's ack.

Quoted 1 line

i7300_idle: remove unused file

Dropped because Greg KH picked it up.

Quoted 1 line

PCI: Remove pci_get_bus_and_slot() function

Deferred so pull requests during the merge window can happen in any order. We can remove it at the end of the merge window or during the next cycle.

Bjorn