* [PATCH V4 13/26] bnx2x: deprecate pci_get_bus_and_slot() [not found] <1513661883-28662-1-git-send-email-okaya@codeaurora.org> @ 2017-12-19 5:37 ` Sinan Kaya 2017-12-19 14:14 ` David Miller 2017-12-19 5:37 ` [PATCH V4 14/26] pch_gbe: " Sinan Kaya 1 sibling, 1 reply; 8+ messages in thread From: Sinan Kaya @ 2017-12-19 5:37 UTC (permalink / raw) To: linux-pci, timur Cc: linux-arm-msm, linux-arm-kernel, Sinan Kaya, Ariel Elior, supporter:BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER, open list:BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER, open list 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(). Signed-off-by: Sinan Kaya <okaya@codeaurora.org> --- 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(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c index 3591077..ffa7959 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c @@ -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); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h index 53466f6..eb814c6 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h @@ -182,6 +182,7 @@ struct bnx2x_virtf { u32 error; /* 0 means all's-well */ /* BDF */ + unsigned int domain; unsigned int bus; unsigned int devfn; -- 1.9.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH V4 13/26] bnx2x: deprecate pci_get_bus_and_slot() 2017-12-19 5:37 ` [PATCH V4 13/26] bnx2x: deprecate pci_get_bus_and_slot() Sinan Kaya @ 2017-12-19 14:14 ` David Miller 0 siblings, 0 replies; 8+ messages in thread From: David Miller @ 2017-12-19 14:14 UTC (permalink / raw) To: okaya Cc: linux-pci, timur, linux-arm-msm, linux-arm-kernel, ariel.elior, everest-linux-l2, netdev, linux-kernel From: Sinan Kaya <okaya@codeaurora.org> Date: Tue, 19 Dec 2017 00:37:49 -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(). > > 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(). > > Signed-off-by: Sinan Kaya <okaya@codeaurora.org> Acked-by: David S. Miller <davem@davemloft.net> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot() [not found] <1513661883-28662-1-git-send-email-okaya@codeaurora.org> 2017-12-19 5:37 ` [PATCH V4 13/26] bnx2x: deprecate pci_get_bus_and_slot() Sinan Kaya @ 2017-12-19 5:37 ` Sinan Kaya 2017-12-19 10:45 ` Andy Shevchenko 2017-12-19 14:13 ` David Miller 1 sibling, 2 replies; 8+ messages in thread From: Sinan Kaya @ 2017-12-19 5:37 UTC (permalink / raw) To: linux-pci, timur Cc: linux-arm-msm, linux-arm-kernel, Sinan Kaya, David S. Miller, Kees Cook, Eric Dumazet, Tobias Klauser, Andy Shevchenko, open list:NETWORKING DRIVERS, open list 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(-) 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot() 2017-12-19 5:37 ` [PATCH V4 14/26] pch_gbe: " Sinan Kaya @ 2017-12-19 10:45 ` Andy Shevchenko 2017-12-19 12:17 ` Sinan Kaya 2017-12-19 14:13 ` David Miller 1 sibling, 1 reply; 8+ messages in thread From: Andy Shevchenko @ 2017-12-19 10:45 UTC (permalink / raw) To: Sinan Kaya, linux-pci, timur Cc: linux-arm-msm, linux-arm-kernel, David S. Miller, Kees Cook, Eric Dumazet, Tobias Klauser, open list:NETWORKING DRIVERS, open list 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 <andriy.shevchenko@linux.intel.com> Intel Finland Oy ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot() 2017-12-19 10:45 ` Andy Shevchenko @ 2017-12-19 12:17 ` Sinan Kaya 2017-12-19 13:24 ` Andy Shevchenko 2017-12-19 14:53 ` David Miller 0 siblings, 2 replies; 8+ messages in thread From: Sinan Kaya @ 2017-12-19 12:17 UTC (permalink / raw) To: Andy Shevchenko, linux-pci, timur Cc: linux-arm-msm, linux-arm-kernel, David S. Miller, Kees Cook, Eric Dumazet, Tobias Klauser, open list:NETWORKING DRIVERS, open list 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. -- 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot() 2017-12-19 12:17 ` Sinan Kaya @ 2017-12-19 13:24 ` Andy Shevchenko 2017-12-19 14:53 ` David Miller 1 sibling, 0 replies; 8+ messages in thread From: Andy Shevchenko @ 2017-12-19 13:24 UTC (permalink / raw) To: Sinan Kaya, linux-pci, timur Cc: linux-arm-msm, linux-arm-kernel, David S. Miller, Kees Cook, Eric Dumazet, Tobias Klauser, open list:NETWORKING DRIVERS, open list 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. -- Andy Shevchenko <andriy.shevchenko@linux.intel.com> Intel Finland Oy ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot() 2017-12-19 12:17 ` Sinan Kaya 2017-12-19 13:24 ` Andy Shevchenko @ 2017-12-19 14:53 ` David Miller 1 sibling, 0 replies; 8+ messages in thread From: David Miller @ 2017-12-19 14:53 UTC (permalink / raw) To: okaya Cc: andriy.shevchenko, linux-pci, timur, linux-arm-msm, linux-arm-kernel, keescook, edumazet, tklauser, netdev, linux-kernel 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V4 14/26] pch_gbe: deprecate pci_get_bus_and_slot() 2017-12-19 5:37 ` [PATCH V4 14/26] pch_gbe: " Sinan Kaya 2017-12-19 10:45 ` Andy Shevchenko @ 2017-12-19 14:13 ` David Miller 1 sibling, 0 replies; 8+ messages in thread From: David Miller @ 2017-12-19 14:13 UTC (permalink / raw) To: okaya Cc: linux-pci, timur, linux-arm-msm, linux-arm-kernel, keescook, edumazet, tklauser, andriy.shevchenko, netdev, linux-kernel 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> ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-12-19 14:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1513661883-28662-1-git-send-email-okaya@codeaurora.org>
2017-12-19 5:37 ` [PATCH V4 13/26] bnx2x: deprecate pci_get_bus_and_slot() Sinan Kaya
2017-12-19 14:14 ` David Miller
2017-12-19 5:37 ` [PATCH V4 14/26] pch_gbe: " Sinan Kaya
2017-12-19 10:45 ` Andy Shevchenko
2017-12-19 12:17 ` Sinan Kaya
2017-12-19 13:24 ` Andy Shevchenko
2017-12-19 14:53 ` David Miller
2017-12-19 14:13 ` David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).