linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] PCI: add help pci_dev_id
@ 2019-04-19 18:27 Heiner Kallweit
  2019-04-19 18:28 ` [PATCH 1/3] PCI: add helper pci_dev_id Heiner Kallweit
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Heiner Kallweit @ 2019-04-19 18:27 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, netdev

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.

Heiner Kallweit (3):
  PCI: add helper pci_dev_id
  PCI: use helper pci_dev_id
  r8169: use new helper pci_dev_id

 drivers/net/ethernet/realtek/r8169.c |  3 +--
 drivers/pci/msi.c                    |  6 +++---
 drivers/pci/search.c                 | 10 +++-------
 include/linux/pci.h                  |  5 +++++
 4 files changed, 12 insertions(+), 12 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] PCI: add helper pci_dev_id
  2019-04-19 18:27 [PATCH 0/3] PCI: add help pci_dev_id Heiner Kallweit
@ 2019-04-19 18:28 ` Heiner Kallweit
  2019-04-19 18:29 ` [PATCH 2/3] PCI: use " Heiner Kallweit
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Heiner Kallweit @ 2019-04-19 18:28 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, netdev

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 <hkallweit1@gmail.com>
---
 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




^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] PCI: use helper pci_dev_id
  2019-04-19 18:27 [PATCH 0/3] PCI: add help pci_dev_id Heiner Kallweit
  2019-04-19 18:28 ` [PATCH 1/3] PCI: add helper pci_dev_id Heiner Kallweit
@ 2019-04-19 18:29 ` Heiner Kallweit
  2019-04-19 18:29 ` [PATCH 3/3] r8169: use new " Heiner Kallweit
  2019-04-19 22:13 ` [PATCH 0/3] PCI: add help pci_dev_id David Miller
  3 siblings, 0 replies; 9+ messages in thread
From: Heiner Kallweit @ 2019-04-19 18:29 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, netdev

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 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




^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] r8169: use new helper pci_dev_id
  2019-04-19 18:27 [PATCH 0/3] PCI: add help pci_dev_id Heiner Kallweit
  2019-04-19 18:28 ` [PATCH 1/3] PCI: add helper pci_dev_id Heiner Kallweit
  2019-04-19 18:29 ` [PATCH 2/3] PCI: use " Heiner Kallweit
@ 2019-04-19 18:29 ` Heiner Kallweit
  2019-04-19 22:13 ` [PATCH 0/3] PCI: add help pci_dev_id David Miller
  3 siblings, 0 replies; 9+ messages in thread
From: Heiner Kallweit @ 2019-04-19 18:29 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, netdev

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 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




^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] PCI: add help pci_dev_id
  2019-04-19 18:27 [PATCH 0/3] PCI: add help pci_dev_id Heiner Kallweit
                   ` (2 preceding siblings ...)
  2019-04-19 18:29 ` [PATCH 3/3] r8169: use new " Heiner Kallweit
@ 2019-04-19 22:13 ` David Miller
  2019-04-22 13:20   ` Bjorn Helgaas
  3 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2019-04-19 22:13 UTC (permalink / raw)
  To: hkallweit1; +Cc: bhelgaas, linux-pci, netdev

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Fri, 19 Apr 2019 20:27:45 +0200

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

I'll wait for an ACK from the PCI folks on patch #1.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] PCI: add help pci_dev_id
  2019-04-19 22:13 ` [PATCH 0/3] PCI: add help pci_dev_id David Miller
@ 2019-04-22 13:20   ` Bjorn Helgaas
  2019-04-23  4:09     ` David Miller
  2019-04-23  6:05     ` Heiner Kallweit
  0 siblings, 2 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2019-04-22 13:20 UTC (permalink / raw)
  To: David Miller; +Cc: hkallweit1, linux-pci, netdev

On Fri, Apr 19, 2019 at 03:13:38PM -0700, David Miller wrote:
> From: Heiner Kallweit <hkallweit1@gmail.com>
> Date: Fri, 19 Apr 2019 20:27:45 +0200
> 
> > 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.
> 
> I'll wait for an ACK from the PCI folks on patch #1.

#1 and #2 touch PCI, #3 is a trivial r8169 patch.  There are a few
other places where this helper could be used (powernv/npu-dma.c,
amdkfd/kfd_topology.c, amd_iommu.c, intel-iommu.c,
intel_irq_remapping.c, stmmac_pci.c, chromeos_laptop.c).

I think it would be easier for me to collect acks for the trivial
changes to those places and merge the whole shebang via PCI.

Heiner, do you want to update those other places, too?

Bjorn

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] PCI: add help pci_dev_id
  2019-04-22 13:20   ` Bjorn Helgaas
@ 2019-04-23  4:09     ` David Miller
  2019-04-23  6:05     ` Heiner Kallweit
  1 sibling, 0 replies; 9+ messages in thread
From: David Miller @ 2019-04-23  4:09 UTC (permalink / raw)
  To: helgaas; +Cc: hkallweit1, linux-pci, netdev

From: Bjorn Helgaas <helgaas@kernel.org>
Date: Mon, 22 Apr 2019 08:20:20 -0500

> On Fri, Apr 19, 2019 at 03:13:38PM -0700, David Miller wrote:
>> From: Heiner Kallweit <hkallweit1@gmail.com>
>> Date: Fri, 19 Apr 2019 20:27:45 +0200
>> 
>> > 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.
>> 
>> I'll wait for an ACK from the PCI folks on patch #1.
> 
> #1 and #2 touch PCI, #3 is a trivial r8169 patch.  There are a few
> other places where this helper could be used (powernv/npu-dma.c,
> amdkfd/kfd_topology.c, amd_iommu.c, intel-iommu.c,
> intel_irq_remapping.c, stmmac_pci.c, chromeos_laptop.c).
> 
> I think it would be easier for me to collect acks for the trivial
> changes to those places and merge the whole shebang via PCI.

That's fine with me, you can add my:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] PCI: add help pci_dev_id
  2019-04-22 13:20   ` Bjorn Helgaas
  2019-04-23  4:09     ` David Miller
@ 2019-04-23  6:05     ` Heiner Kallweit
  1 sibling, 0 replies; 9+ messages in thread
From: Heiner Kallweit @ 2019-04-23  6:05 UTC (permalink / raw)
  To: Bjorn Helgaas, David Miller; +Cc: linux-pci, netdev

On 22.04.2019 15:20, Bjorn Helgaas wrote:
> On Fri, Apr 19, 2019 at 03:13:38PM -0700, David Miller wrote:
>> From: Heiner Kallweit <hkallweit1@gmail.com>
>> Date: Fri, 19 Apr 2019 20:27:45 +0200
>>
>>> 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.
>>
>> I'll wait for an ACK from the PCI folks on patch #1.
> 
> #1 and #2 touch PCI, #3 is a trivial r8169 patch.  There are a few
> other places where this helper could be used (powernv/npu-dma.c,
> amdkfd/kfd_topology.c, amd_iommu.c, intel-iommu.c,
> intel_irq_remapping.c, stmmac_pci.c, chromeos_laptop.c).
> 
> I think it would be easier for me to collect acks for the trivial
> changes to those places and merge the whole shebang via PCI.
> 
> Heiner, do you want to update those other places, too?
> 
Yes, will do so.

> Bjorn
> 
Heiner

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/3] PCI: use helper pci_dev_id
  2019-04-19 11:08 Heiner Kallweit
@ 2019-04-19 11:09 ` Heiner Kallweit
  0 siblings, 0 replies; 9+ messages in thread
From: Heiner Kallweit @ 2019-04-19 11:09 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci, netdev

Use new helper pci_dev_id() to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 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



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-04-23  6:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-19 18:27 [PATCH 0/3] PCI: add help pci_dev_id Heiner Kallweit
2019-04-19 18:28 ` [PATCH 1/3] PCI: add helper pci_dev_id Heiner Kallweit
2019-04-19 18:29 ` [PATCH 2/3] PCI: use " Heiner Kallweit
2019-04-19 18:29 ` [PATCH 3/3] r8169: use new " Heiner Kallweit
2019-04-19 22:13 ` [PATCH 0/3] PCI: add help pci_dev_id David Miller
2019-04-22 13:20   ` Bjorn Helgaas
2019-04-23  4:09     ` David Miller
2019-04-23  6:05     ` Heiner Kallweit
  -- strict thread matches above, loose matches on Subject: below --
2019-04-19 11:08 Heiner Kallweit
2019-04-19 11:09 ` [PATCH 2/3] PCI: use helper pci_dev_id Heiner Kallweit

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