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

Subsystems: networking drivers, the rest

STALE3226d

Revision v4 of 4 in this series.

6 messages, 3 authors, 2017-12-19 · open the first message on its own page

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

From: Sinan Kaya <hidden>
Date: 2017-12-19 05:43:50

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.

Signed-off-by: Sinan Kaya <redacted>
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 40e52ff..7cd4946 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -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;
-- 
1.9.1

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

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2017-12-19 10:45:38

On Tue, 2017-12-19 at 00:37 -0500, Sinan Kaya wrote:
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.

-- 
Andy Shevchenko [off-list ref]
Intel Finland Oy

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

From: Sinan Kaya <hidden>
Date: 2017-12-19 12:17:53

On 12/19/2017 5:45 AM, Andy Shevchenko wrote:
On Tue, 2017-12-19 at 00:37 -0500, Sinan Kaya wrote:
quoted
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.
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.

-- 
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.

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

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2017-12-19 13:25:03

On Tue, 2017-12-19 at 07:17 -0500, Sinan Kaya wrote:
On 12/19/2017 5:45 AM, Andy Shevchenko wrote:
quoted
On Tue, 2017-12-19 at 00:37 -0500, Sinan Kaya wrote:
quoted
quoted
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.
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.

-- 
Andy Shevchenko [off-list ref]
Intel Finland Oy

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

From: David Miller <davem@davemloft.net>
Date: 2017-12-19 14:13:46

From: Sinan Kaya <redacted>
Date: Tue, 19 Dec 2017 00:37:50 -0500
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.

Signed-off-by: Sinan Kaya <redacted>
Acked-by: David S. Miller <davem@davemloft.net>

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

From: David Miller <davem@davemloft.net>
Date: 2017-12-19 14:53:40

From: Sinan Kaya <redacted>
Date: Tue, 19 Dec 2017 07:17:41 -0500
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help