Message ID | 1513661883-28662-15-git-send-email-okaya@codeaurora.org (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Bjorn Helgaas |
Headers | show |
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.
On 12/19/2017 5:45 AM, Andy Shevchenko wrote: > 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? 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.
On Tue, 2017-12-19 at 07:17 -0500, Sinan Kaya wrote: > On 12/19/2017 5:45 AM, Andy Shevchenko wrote: > > On Tue, 2017-12-19 at 00:37 -0500, Sinan Kaya wrote: > > > > > 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.
From: Sinan Kaya <okaya@codeaurora.org> 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 <okaya@codeaurora.org> Acked-by: David S. Miller <davem@davemloft.net>
From: Sinan Kaya <okaya@codeaurora.org> 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.
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;
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 <okaya@codeaurora.org> --- drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)