2019-04-25 06:09:47

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 0/9] PCI: add help pci_dev_id

In several places in the kernel we find PCI_DEVID used like this:
PCI_DEVID(dev->bus->number, dev->devfn) Therefore create a helper
for it.

v2:
- apply the change to all affected places in the kernel

Heiner Kallweit (9):
PCI: add helper pci_dev_id
PCI: use helper pci_dev_id
r8169: use new helper pci_dev_id
powerpc/powernv/npu: use helper pci_dev_id
drm/amdkfd: use helper pci_dev_id
iommu/amd: use helper pci_dev_id
iommu/vt-d: use helper pci_dev_id
stmmac: pci: use helper pci_dev_id
platform/chrome: chromeos_laptop: use helper pci_dev_id

arch/powerpc/platforms/powernv/npu-dma.c | 14 ++++++--------
drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 +--
drivers/iommu/amd_iommu.c | 2 +-
drivers/iommu/intel-iommu.c | 2 +-
drivers/iommu/intel_irq_remapping.c | 2 +-
drivers/net/ethernet/realtek/r8169.c | 3 +--
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +-
drivers/pci/msi.c | 6 +++---
drivers/pci/search.c | 10 +++-------
drivers/platform/chrome/chromeos_laptop.c | 2 +-
include/linux/pci.h | 5 +++++
11 files changed, 24 insertions(+), 27 deletions(-)

--
2.21.0


2019-04-25 06:18:01

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 1/9] PCI: add helper pci_dev_id

In several places in the kernel we find PCI_DEVID used like this:
PCI_DEVID(dev->bus->number, dev->devfn) Therefore create a helper
for it.

Signed-off-by: Heiner Kallweit <[email protected]>
---
include/linux/pci.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2c056a7a7..28d0313a3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -598,6 +598,11 @@ struct pci_bus {

#define to_pci_bus(n) container_of(n, struct pci_bus, dev)

+static inline u16 pci_dev_id(struct pci_dev *dev)
+{
+ return PCI_DEVID(dev->bus->number, dev->devfn);
+}
+
/*
* Returns true if the PCI bus is root (behind host-PCI bridge),
* false otherwise
--
2.21.0



2019-04-25 06:20:53

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 3/9] r8169: use new helper pci_dev_id

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/net/ethernet/realtek/r8169.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index efaea1a0a..ae476fe8d 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -7020,8 +7020,7 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
new_bus->priv = tp;
new_bus->parent = &pdev->dev;
new_bus->irq[0] = PHY_IGNORE_INTERRUPT;
- snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x",
- PCI_DEVID(pdev->bus->number, pdev->devfn));
+ snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x", pci_dev_id(pdev));

new_bus->read = r8169_mdio_read_reg;
new_bus->write = r8169_mdio_write_reg;
--
2.21.0




2019-04-25 06:22:41

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 9/9] platform/chrome: chromeos_laptop: use helper pci_dev_id

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/platform/chrome/chromeos_laptop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
index 24326eecd..7abbb6167 100644
--- a/drivers/platform/chrome/chromeos_laptop.c
+++ b/drivers/platform/chrome/chromeos_laptop.c
@@ -125,7 +125,7 @@ static bool chromeos_laptop_match_adapter_devid(struct device *dev, u32 devid)
return false;

pdev = to_pci_dev(dev);
- return devid == PCI_DEVID(pdev->bus->number, pdev->devfn);
+ return devid == pci_dev_id(pdev);
}

static void chromeos_laptop_check_adapter(struct i2c_adapter *adapter)
--
2.21.0


2019-04-25 06:22:43

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 7/9] iommu/vt-d: use helper pci_dev_id

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/iommu/intel-iommu.c | 2 +-
drivers/iommu/intel_irq_remapping.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index d93c4bd7d..3f475a23a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1391,7 +1391,7 @@ static void iommu_enable_dev_iotlb(struct device_domain_info *info)

/* pdev will be returned if device is not a vf */
pf_pdev = pci_physfn(pdev);
- info->pfsid = PCI_DEVID(pf_pdev->bus->number, pf_pdev->devfn);
+ info->pfsid = pci_dev_id(pf_pdev);
}

#ifdef CONFIG_INTEL_IOMMU_SVM
diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index 634d8f059..4160aa9f3 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -424,7 +424,7 @@ static int set_msi_sid(struct irte *irte, struct pci_dev *dev)
set_irte_sid(irte, SVT_VERIFY_SID_SQ, SQ_ALL_16, data.alias);
else
set_irte_sid(irte, SVT_VERIFY_SID_SQ, SQ_ALL_16,
- PCI_DEVID(dev->bus->number, dev->devfn));
+ pci_dev_id(dev));

return 0;
}
--
2.21.0


2019-04-25 06:25:00

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 8/9] stmmac: pci: use helper pci_dev_id

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index cc1e887e4..0e87a9596 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -208,7 +208,7 @@ static int quark_default_data(struct pci_dev *pdev,
ret = 1;
}

- plat->bus_id = PCI_DEVID(pdev->bus->number, pdev->devfn);
+ plat->bus_id = pci_dev_id(pdev);
plat->phy_addr = ret;
plat->interface = PHY_INTERFACE_MODE_RMII;

--
2.21.0


2019-04-25 06:26:24

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 6/9] iommu/amd: use helper pci_dev_id

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/iommu/amd_iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index f467cc4b4..5cb201422 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -165,7 +165,7 @@ static inline u16 get_pci_device_id(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);

- return PCI_DEVID(pdev->bus->number, pdev->devfn);
+ return pci_dev_id(pdev);
}

static inline int get_acpihid_device_id(struct device *dev,
--
2.21.0


2019-04-25 08:30:02

by Christian König

[permalink] [raw]
Subject: Re: [PATCH v2 5/9] drm/amdkfd: use helper pci_dev_id

Am 24.04.19 um 21:14 schrieb Heiner Kallweit:
> Use new helper pci_dev_id() to simplify the code.
>
> Signed-off-by: Heiner Kallweit <[email protected]>

Acked-by: Christian König <[email protected]>

> ---
> drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> index 2cb09e088..769dbc7be 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> @@ -1272,8 +1272,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
>
> dev->node_props.vendor_id = gpu->pdev->vendor;
> dev->node_props.device_id = gpu->pdev->device;
> - dev->node_props.location_id = PCI_DEVID(gpu->pdev->bus->number,
> - gpu->pdev->devfn);
> + dev->node_props.location_id = pci_dev_id(gpu->pdev);
> dev->node_props.max_engine_clk_fcompute =
> amdgpu_amdkfd_get_max_engine_clock_in_mhz(dev->gpu->kgd);
> dev->node_props.max_engine_clk_ccompute =

2019-04-25 10:02:14

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 2/9] PCI: use helper pci_dev_id

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/pci/msi.c | 6 +++---
drivers/pci/search.c | 10 +++-------
2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 73986825d..e039b740f 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1338,7 +1338,7 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev,
struct msi_desc *desc)
{
return (irq_hw_number_t)desc->msi_attrib.entry_nr |
- PCI_DEVID(dev->bus->number, dev->devfn) << 11 |
+ pci_dev_id(dev) << 11 |
(pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27;
}

@@ -1508,7 +1508,7 @@ static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data)
u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev)
{
struct device_node *of_node;
- u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn);
+ u32 rid = pci_dev_id(pdev);

pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid);

@@ -1531,7 +1531,7 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev)
struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev)
{
struct irq_domain *dom;
- u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn);
+ u32 rid = pci_dev_id(pdev);

pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid);
dom = of_msi_map_get_device_domain(&pdev->dev, rid);
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 2b5f72086..5c7922612 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -33,7 +33,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
struct pci_bus *bus;
int ret;

- ret = fn(pdev, PCI_DEVID(pdev->bus->number, pdev->devfn), data);
+ ret = fn(pdev, pci_dev_id(pdev), data);
if (ret)
return ret;

@@ -88,9 +88,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
return ret;
continue;
case PCI_EXP_TYPE_PCIE_BRIDGE:
- ret = fn(tmp,
- PCI_DEVID(tmp->bus->number,
- tmp->devfn), data);
+ ret = fn(tmp, pci_dev_id(tmp), data);
if (ret)
return ret;
continue;
@@ -101,9 +99,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
PCI_DEVID(tmp->subordinate->number,
PCI_DEVFN(0, 0)), data);
else
- ret = fn(tmp,
- PCI_DEVID(tmp->bus->number,
- tmp->devfn), data);
+ ret = fn(tmp, pci_dev_id(tmp), data);
if (ret)
return ret;
}
--
2.21.0




2019-04-25 10:03:28

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 5/9] drm/amdkfd: use helper pci_dev_id

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 2cb09e088..769dbc7be 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -1272,8 +1272,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)

dev->node_props.vendor_id = gpu->pdev->vendor;
dev->node_props.device_id = gpu->pdev->device;
- dev->node_props.location_id = PCI_DEVID(gpu->pdev->bus->number,
- gpu->pdev->devfn);
+ dev->node_props.location_id = pci_dev_id(gpu->pdev);
dev->node_props.max_engine_clk_fcompute =
amdgpu_amdkfd_get_max_engine_clock_in_mhz(dev->gpu->kgd);
dev->node_props.max_engine_clk_ccompute =
--
2.21.0


2019-04-25 11:07:19

by Heiner Kallweit

[permalink] [raw]
Subject: [PATCH v2 4/9] powerpc/powernv/npu: use helper pci_dev_id

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <[email protected]>
---
arch/powerpc/platforms/powernv/npu-dma.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
index dc23d9d2a..495550432 100644
--- a/arch/powerpc/platforms/powernv/npu-dma.c
+++ b/arch/powerpc/platforms/powernv/npu-dma.c
@@ -1213,9 +1213,8 @@ int pnv_npu2_map_lpar_dev(struct pci_dev *gpdev, unsigned int lparid,
* Currently we only support radix and non-zero LPCR only makes sense
* for hash tables so skiboot expects the LPCR parameter to be a zero.
*/
- ret = opal_npu_map_lpar(nphb->opal_id,
- PCI_DEVID(gpdev->bus->number, gpdev->devfn), lparid,
- 0 /* LPCR bits */);
+ ret = opal_npu_map_lpar(nphb->opal_id, pci_dev_id(gpdev), lparid,
+ 0 /* LPCR bits */);
if (ret) {
dev_err(&gpdev->dev, "Error %d mapping device to LPAR\n", ret);
return ret;
@@ -1224,7 +1223,7 @@ int pnv_npu2_map_lpar_dev(struct pci_dev *gpdev, unsigned int lparid,
dev_dbg(&gpdev->dev, "init context opalid=%llu msr=%lx\n",
nphb->opal_id, msr);
ret = opal_npu_init_context(nphb->opal_id, 0/*__unused*/, msr,
- PCI_DEVID(gpdev->bus->number, gpdev->devfn));
+ pci_dev_id(gpdev));
if (ret < 0)
dev_err(&gpdev->dev, "Failed to init context: %d\n", ret);
else
@@ -1258,7 +1257,7 @@ int pnv_npu2_unmap_lpar_dev(struct pci_dev *gpdev)
dev_dbg(&gpdev->dev, "destroy context opalid=%llu\n",
nphb->opal_id);
ret = opal_npu_destroy_context(nphb->opal_id, 0/*__unused*/,
- PCI_DEVID(gpdev->bus->number, gpdev->devfn));
+ pci_dev_id(gpdev));
if (ret < 0) {
dev_err(&gpdev->dev, "Failed to destroy context: %d\n", ret);
return ret;
@@ -1266,9 +1265,8 @@ int pnv_npu2_unmap_lpar_dev(struct pci_dev *gpdev)

/* Set LPID to 0 anyway, just to be safe */
dev_dbg(&gpdev->dev, "Map LPAR opalid=%llu lparid=0\n", nphb->opal_id);
- ret = opal_npu_map_lpar(nphb->opal_id,
- PCI_DEVID(gpdev->bus->number, gpdev->devfn), 0 /*LPID*/,
- 0 /* LPCR bits */);
+ ret = opal_npu_map_lpar(nphb->opal_id, pci_dev_id(gpdev), 0 /*LPID*/,
+ 0 /* LPCR bits */);
if (ret)
dev_err(&gpdev->dev, "Error %d mapping device to LPAR\n", ret);

--
2.21.0


2019-04-25 21:11:59

by Benson Leung

[permalink] [raw]
Subject: Re: [PATCH v2 9/9] platform/chrome: chromeos_laptop: use helper pci_dev_id

Hi Heiner,

On Wed, Apr 24, 2019 at 09:17:19PM +0200, Heiner Kallweit wrote:
> Use new helper pci_dev_id() to simplify the code.
>
> Signed-off-by: Heiner Kallweit <[email protected]>

Acked-By: Benson Leung <[email protected]>

> ---
> drivers/platform/chrome/chromeos_laptop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
> index 24326eecd..7abbb6167 100644
> --- a/drivers/platform/chrome/chromeos_laptop.c
> +++ b/drivers/platform/chrome/chromeos_laptop.c
> @@ -125,7 +125,7 @@ static bool chromeos_laptop_match_adapter_devid(struct device *dev, u32 devid)
> return false;
>
> pdev = to_pci_dev(dev);
> - return devid == PCI_DEVID(pdev->bus->number, pdev->devfn);
> + return devid == pci_dev_id(pdev);
> }
>
> static void chromeos_laptop_check_adapter(struct i2c_adapter *adapter)
> --
> 2.21.0
>
>

--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]


Attachments:
(No filename) (1.08 kB)
signature.asc (849.00 B)
Download all attachments

2019-04-26 04:41:37

by Alexey Kardashevskiy

[permalink] [raw]
Subject: Re: [PATCH v2 4/9] powerpc/powernv/npu: use helper pci_dev_id



On 25/04/2019 05:14, Heiner Kallweit wrote:
> Use new helper pci_dev_id() to simplify the code.
>
> Signed-off-by: Heiner Kallweit <[email protected]>



Reviewed-by: Alexey Kardashevskiy <[email protected]>


> ---
> arch/powerpc/platforms/powernv/npu-dma.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
> index dc23d9d2a..495550432 100644
> --- a/arch/powerpc/platforms/powernv/npu-dma.c
> +++ b/arch/powerpc/platforms/powernv/npu-dma.c
> @@ -1213,9 +1213,8 @@ int pnv_npu2_map_lpar_dev(struct pci_dev *gpdev, unsigned int lparid,
> * Currently we only support radix and non-zero LPCR only makes sense
> * for hash tables so skiboot expects the LPCR parameter to be a zero.
> */
> - ret = opal_npu_map_lpar(nphb->opal_id,
> - PCI_DEVID(gpdev->bus->number, gpdev->devfn), lparid,
> - 0 /* LPCR bits */);
> + ret = opal_npu_map_lpar(nphb->opal_id, pci_dev_id(gpdev), lparid,
> + 0 /* LPCR bits */);
> if (ret) {
> dev_err(&gpdev->dev, "Error %d mapping device to LPAR\n", ret);
> return ret;
> @@ -1224,7 +1223,7 @@ int pnv_npu2_map_lpar_dev(struct pci_dev *gpdev, unsigned int lparid,
> dev_dbg(&gpdev->dev, "init context opalid=%llu msr=%lx\n",
> nphb->opal_id, msr);
> ret = opal_npu_init_context(nphb->opal_id, 0/*__unused*/, msr,
> - PCI_DEVID(gpdev->bus->number, gpdev->devfn));
> + pci_dev_id(gpdev));
> if (ret < 0)
> dev_err(&gpdev->dev, "Failed to init context: %d\n", ret);
> else
> @@ -1258,7 +1257,7 @@ int pnv_npu2_unmap_lpar_dev(struct pci_dev *gpdev)
> dev_dbg(&gpdev->dev, "destroy context opalid=%llu\n",
> nphb->opal_id);
> ret = opal_npu_destroy_context(nphb->opal_id, 0/*__unused*/,
> - PCI_DEVID(gpdev->bus->number, gpdev->devfn));
> + pci_dev_id(gpdev));
> if (ret < 0) {
> dev_err(&gpdev->dev, "Failed to destroy context: %d\n", ret);
> return ret;
> @@ -1266,9 +1265,8 @@ int pnv_npu2_unmap_lpar_dev(struct pci_dev *gpdev)
>
> /* Set LPID to 0 anyway, just to be safe */
> dev_dbg(&gpdev->dev, "Map LPAR opalid=%llu lparid=0\n", nphb->opal_id);
> - ret = opal_npu_map_lpar(nphb->opal_id,
> - PCI_DEVID(gpdev->bus->number, gpdev->devfn), 0 /*LPID*/,
> - 0 /* LPCR bits */);
> + ret = opal_npu_map_lpar(nphb->opal_id, pci_dev_id(gpdev), 0 /*LPID*/,
> + 0 /* LPCR bits */);
> if (ret)
> dev_err(&gpdev->dev, "Error %d mapping device to LPAR\n", ret);
>
>

--
Alexey

2019-04-26 13:48:25

by Joerg Roedel

[permalink] [raw]
Subject: Re: [PATCH v2 6/9] iommu/amd: use helper pci_dev_id

On Wed, Apr 24, 2019 at 09:15:25PM +0200, Heiner Kallweit wrote:
> Use new helper pci_dev_id() to simplify the code.
>
> Signed-off-by: Heiner Kallweit <[email protected]>

Reviewed-by: Joerg Roedel <[email protected]>

> ---
> drivers/iommu/amd_iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
> index f467cc4b4..5cb201422 100644
> --- a/drivers/iommu/amd_iommu.c
> +++ b/drivers/iommu/amd_iommu.c
> @@ -165,7 +165,7 @@ static inline u16 get_pci_device_id(struct device *dev)
> {
> struct pci_dev *pdev = to_pci_dev(dev);
>
> - return PCI_DEVID(pdev->bus->number, pdev->devfn);
> + return pci_dev_id(pdev);
> }
>
> static inline int get_acpihid_device_id(struct device *dev,
> --
> 2.21.0
>

2019-04-26 13:49:22

by Joerg Roedel

[permalink] [raw]
Subject: Re: [PATCH v2 7/9] iommu/vt-d: use helper pci_dev_id

On Wed, Apr 24, 2019 at 09:16:10PM +0200, Heiner Kallweit wrote:
> Use new helper pci_dev_id() to simplify the code.
>
> Signed-off-by: Heiner Kallweit <[email protected]>

Reviewed-by: Joerg Roedel <[email protected]>

> ---
> drivers/iommu/intel-iommu.c | 2 +-
> drivers/iommu/intel_irq_remapping.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index d93c4bd7d..3f475a23a 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -1391,7 +1391,7 @@ static void iommu_enable_dev_iotlb(struct device_domain_info *info)
>
> /* pdev will be returned if device is not a vf */
> pf_pdev = pci_physfn(pdev);
> - info->pfsid = PCI_DEVID(pf_pdev->bus->number, pf_pdev->devfn);
> + info->pfsid = pci_dev_id(pf_pdev);
> }
>
> #ifdef CONFIG_INTEL_IOMMU_SVM
> diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
> index 634d8f059..4160aa9f3 100644
> --- a/drivers/iommu/intel_irq_remapping.c
> +++ b/drivers/iommu/intel_irq_remapping.c
> @@ -424,7 +424,7 @@ static int set_msi_sid(struct irte *irte, struct pci_dev *dev)
> set_irte_sid(irte, SVT_VERIFY_SID_SQ, SQ_ALL_16, data.alias);
> else
> set_irte_sid(irte, SVT_VERIFY_SID_SQ, SQ_ALL_16,
> - PCI_DEVID(dev->bus->number, dev->devfn));
> + pci_dev_id(dev));
>
> return 0;
> }
> --
> 2.21.0
>

2019-04-29 21:15:57

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH v2 0/9] PCI: add help pci_dev_id

On Wed, Apr 24, 2019 at 09:10:21PM +0200, Heiner Kallweit wrote:
> In several places in the kernel we find PCI_DEVID used like this:
> PCI_DEVID(dev->bus->number, dev->devfn) Therefore create a helper
> for it.
>
> v2:
> - apply the change to all affected places in the kernel
>
> Heiner Kallweit (9):
> PCI: add helper pci_dev_id
> PCI: use helper pci_dev_id
> r8169: use new helper pci_dev_id
> powerpc/powernv/npu: use helper pci_dev_id
> drm/amdkfd: use helper pci_dev_id
> iommu/amd: use helper pci_dev_id
> iommu/vt-d: use helper pci_dev_id
> stmmac: pci: use helper pci_dev_id
> platform/chrome: chromeos_laptop: use helper pci_dev_id
>
> arch/powerpc/platforms/powernv/npu-dma.c | 14 ++++++--------
> drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 +--
> drivers/iommu/amd_iommu.c | 2 +-
> drivers/iommu/intel-iommu.c | 2 +-
> drivers/iommu/intel_irq_remapping.c | 2 +-
> drivers/net/ethernet/realtek/r8169.c | 3 +--
> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +-
> drivers/pci/msi.c | 6 +++---
> drivers/pci/search.c | 10 +++-------
> drivers/platform/chrome/chromeos_laptop.c | 2 +-
> include/linux/pci.h | 5 +++++
> 11 files changed, 24 insertions(+), 27 deletions(-)

Applied with acks/reviewed-by from Benson, Joerg, Christian, Alexey, and
David to pci/misc for v5.2, thanks!