All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Jiang Liu <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, konrad.wilk@oracle.com,
	david.vrabel@citrix.com, boris.ostrovsky@oracle.com,
	jiang.liu@linux.intel.com, linux-kernel@vger.kernel.org,
	mingo@kernel.org, bp@alien8.de, marc.zyngier@arm.com,
	grant.likely@linaro.org, bhelgaas@google.com, hpa@zytor.com,
	wangyijing@huawei.com, tony.luck@intel.com,
	stuart.yoder@freescale.com
Subject: [tip:irq/core] PCI: Use for_each_pci_msi_entry() to access MSI device list
Date: Wed, 22 Jul 2015 13:39:16 -0700	[thread overview]
Message-ID: <tip-5004e98a91e8ad600f5b00872e9ddad810258f08@git.kernel.org> (raw)
In-Reply-To: <1436428847-8886-7-git-send-email-jiang.liu@linux.intel.com>

Commit-ID:  5004e98a91e8ad600f5b00872e9ddad810258f08
Gitweb:     http://git.kernel.org/tip/5004e98a91e8ad600f5b00872e9ddad810258f08
Author:     Jiang Liu <jiang.liu@linux.intel.com>
AuthorDate: Thu, 9 Jul 2015 16:00:41 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 22 Jul 2015 18:37:43 +0200

PCI: Use for_each_pci_msi_entry() to access MSI device list

Use accessor for_each_pci_msi_entry() to access MSI device list, so we
could easily move msi_list from struct pci_dev into struct device
later.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Reviewed-by: Yijing Wang <wangyijing@huawei.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: xen-devel@lists.xenproject.org
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Stuart Yoder <stuart.yoder@freescale.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Link: http://lkml.kernel.org/r/1436428847-8886-7-git-send-email-jiang.liu@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/pci/msi.c          | 39 ++++++++++++++++++++-------------------
 drivers/pci/xen-pcifront.c |  2 +-
 2 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index ab41742..540613e 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -131,7 +131,7 @@ int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 	if (type == PCI_CAP_ID_MSI && nvec > 1)
 		return 1;
 
-	list_for_each_entry(entry, &dev->msi_list, list) {
+	for_each_pci_msi_entry(entry, dev) {
 		ret = arch_setup_msi_irq(dev, entry);
 		if (ret < 0)
 			return ret;
@@ -151,7 +151,7 @@ void default_teardown_msi_irqs(struct pci_dev *dev)
 	int i;
 	struct msi_desc *entry;
 
-	list_for_each_entry(entry, &dev->msi_list, list)
+	for_each_pci_msi_entry(entry, dev)
 		if (entry->irq)
 			for (i = 0; i < entry->nvec_used; i++)
 				arch_teardown_msi_irq(entry->irq + i);
@@ -168,7 +168,7 @@ static void default_restore_msi_irq(struct pci_dev *dev, int irq)
 
 	entry = NULL;
 	if (dev->msix_enabled) {
-		list_for_each_entry(entry, &dev->msi_list, list) {
+		for_each_pci_msi_entry(entry, dev) {
 			if (irq == entry->irq)
 				break;
 		}
@@ -282,7 +282,7 @@ void default_restore_msi_irqs(struct pci_dev *dev)
 {
 	struct msi_desc *entry;
 
-	list_for_each_entry(entry, &dev->msi_list, list)
+	for_each_pci_msi_entry(entry, dev)
 		default_restore_msi_irq(dev, entry->irq);
 }
 
@@ -363,21 +363,22 @@ EXPORT_SYMBOL_GPL(pci_write_msi_msg);
 
 static void free_msi_irqs(struct pci_dev *dev)
 {
+	struct list_head *msi_list = dev_to_msi_list(&dev->dev);
 	struct msi_desc *entry, *tmp;
 	struct attribute **msi_attrs;
 	struct device_attribute *dev_attr;
 	int i, count = 0;
 
-	list_for_each_entry(entry, &dev->msi_list, list)
+	for_each_pci_msi_entry(entry, dev)
 		if (entry->irq)
 			for (i = 0; i < entry->nvec_used; i++)
 				BUG_ON(irq_has_action(entry->irq + i));
 
 	pci_msi_teardown_msi_irqs(dev);
 
-	list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) {
+	list_for_each_entry_safe(entry, tmp, msi_list, list) {
 		if (entry->msi_attrib.is_msix) {
-			if (list_is_last(&entry->list, &dev->msi_list))
+			if (list_is_last(&entry->list, msi_list))
 				iounmap(entry->mask_base);
 		}
 
@@ -448,7 +449,7 @@ static void __pci_restore_msix_state(struct pci_dev *dev)
 
 	if (!dev->msix_enabled)
 		return;
-	BUG_ON(list_empty(&dev->msi_list));
+	BUG_ON(list_empty(dev_to_msi_list(&dev->dev)));
 
 	/* route the table */
 	pci_intx_for_msi(dev, 0);
@@ -456,7 +457,7 @@ static void __pci_restore_msix_state(struct pci_dev *dev)
 				PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);
 
 	arch_restore_msi_irqs(dev);
-	list_for_each_entry(entry, &dev->msi_list, list)
+	for_each_pci_msi_entry(entry, dev)
 		msix_mask_irq(entry, entry->masked);
 
 	pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
@@ -501,7 +502,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
 	int count = 0;
 
 	/* Determine how many msi entries we have */
-	list_for_each_entry(entry, &pdev->msi_list, list)
+	for_each_pci_msi_entry(entry, pdev)
 		++num_msi;
 	if (!num_msi)
 		return 0;
@@ -510,7 +511,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
 	msi_attrs = kzalloc(sizeof(void *) * (num_msi + 1), GFP_KERNEL);
 	if (!msi_attrs)
 		return -ENOMEM;
-	list_for_each_entry(entry, &pdev->msi_list, list) {
+	for_each_pci_msi_entry(entry, pdev) {
 		msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
 		if (!msi_dev_attr)
 			goto error_attrs;
@@ -599,7 +600,7 @@ static int msi_verify_entries(struct pci_dev *dev)
 {
 	struct msi_desc *entry;
 
-	list_for_each_entry(entry, &dev->msi_list, list) {
+	for_each_pci_msi_entry(entry, dev) {
 		if (!dev->no_64bit_msi || !entry->msg.address_hi)
 			continue;
 		dev_err(&dev->dev, "Device has broken 64-bit MSI but arch"
@@ -636,7 +637,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
 	mask = msi_mask(entry->msi_attrib.multi_cap);
 	msi_mask_irq(entry, mask, mask);
 
-	list_add_tail(&entry->list, &dev->msi_list);
+	list_add_tail(&entry->list, dev_to_msi_list(&dev->dev));
 
 	/* Configure MSI capability structure */
 	ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI);
@@ -713,7 +714,7 @@ static int msix_setup_entries(struct pci_dev *dev, void __iomem *base,
 		entry->mask_base		= base;
 		entry->nvec_used		= 1;
 
-		list_add_tail(&entry->list, &dev->msi_list);
+		list_add_tail(&entry->list, dev_to_msi_list(&dev->dev));
 	}
 
 	return 0;
@@ -725,7 +726,7 @@ static void msix_program_entries(struct pci_dev *dev,
 	struct msi_desc *entry;
 	int i = 0;
 
-	list_for_each_entry(entry, &dev->msi_list, list) {
+	for_each_pci_msi_entry(entry, dev) {
 		int offset = entries[i].entry * PCI_MSIX_ENTRY_SIZE +
 						PCI_MSIX_ENTRY_VECTOR_CTRL;
 
@@ -806,7 +807,7 @@ out_avail:
 		struct msi_desc *entry;
 		int avail = 0;
 
-		list_for_each_entry(entry, &dev->msi_list, list) {
+		for_each_pci_msi_entry(entry, dev) {
 			if (entry->irq != 0)
 				avail++;
 		}
@@ -895,8 +896,8 @@ void pci_msi_shutdown(struct pci_dev *dev)
 	if (!pci_msi_enable || !dev || !dev->msi_enabled)
 		return;
 
-	BUG_ON(list_empty(&dev->msi_list));
-	desc = list_first_entry(&dev->msi_list, struct msi_desc, list);
+	BUG_ON(list_empty(dev_to_msi_list(&dev->dev)));
+	desc = first_msi_entry(dev);
 
 	pci_msi_set_enable(dev, 0);
 	pci_intx_for_msi(dev, 1);
@@ -1001,7 +1002,7 @@ void pci_msix_shutdown(struct pci_dev *dev)
 		return;
 
 	/* Return the device with MSI-X masked as initial states */
-	list_for_each_entry(entry, &dev->msi_list, list) {
+	for_each_pci_msi_entry(entry, dev) {
 		/* Keep cached states to be restored */
 		__pci_msix_desc_mask_irq(entry, 1);
 	}
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 8b7a900..c777b97 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -265,7 +265,7 @@ static int pci_frontend_enable_msix(struct pci_dev *dev,
 	}
 
 	i = 0;
-	list_for_each_entry(entry, &dev->msi_list, list) {
+	for_each_pci_msi_entry(entry, dev) {
 		op.msix_entries[i].entry = entry->msi_attrib.entry_nr;
 		/* Vector is useless at this point. */
 		op.msix_entries[i].vector = -1;

  parent reply	other threads:[~2015-07-22 20:40 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09  8:00 [RFC Patch V1 00/12] Reorganize struct msi_desc to prepare for support of generic MSI Jiang Liu
2015-07-09  8:00 ` Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 01/12] PCI: Add helper function msi_desc_to_pci_sysdata() Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-22 20:37   ` [tip:irq/core] " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 02/12] MIPS, PCI: Use for_pci_msi_entry() to access MSI device list Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-09 11:03   ` Sergei Shtylyov
2015-07-09 11:03     ` Sergei Shtylyov
2015-07-22 20:37   ` [tip:irq/core] MIPS/PCI: " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 03/12] PowerPC, PCI: " Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-22 20:38   ` [tip:irq/core] powerpc/PCI: " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 04/12] s390/pci: " Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-13 12:47   ` Sebastian Ott
2015-07-13 12:47     ` Sebastian Ott
2015-07-22 20:38   ` [tip:irq/core] " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 05/12] x86, PCI: " Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-09 19:07   ` Konrad Rzeszutek Wilk
2015-07-09 19:07   ` Konrad Rzeszutek Wilk
2015-07-09 19:07     ` Konrad Rzeszutek Wilk
2015-07-22 20:38   ` [tip:irq/core] x86/PCI: " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 05/12] x86, PCI: " Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 06/12] " Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-09 19:08   ` Konrad Rzeszutek Wilk
2015-07-09 19:08     ` Konrad Rzeszutek Wilk
2015-07-09 19:08   ` Konrad Rzeszutek Wilk
2015-07-22 20:39   ` tip-bot for Jiang Liu [this message]
2015-07-09  8:00 ` Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 07/12] sparc, PCI: Use helper functions to access fields in struct msi_desc Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-09  8:00   ` David Miller
2015-07-09  8:00     ` David Miller
2015-07-09  8:00     ` David Miller
2015-07-22 20:39   ` [tip:irq/core] sparc/PCI: " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 08/12] PCI: " Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-12 11:18   ` Jingoo Han
2015-07-12 11:18     ` Jingoo Han
2015-07-22 20:39   ` [tip:irq/core] " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 09/12] genirq: Move msi_list from struct pci_dev to struct device Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-10  0:19   ` Paul Gortmaker
2015-07-10  0:19     ` Paul Gortmaker
2015-07-21 22:02     ` Thomas Gleixner
2015-07-21 22:02       ` Thomas Gleixner
2015-07-22 20:40   ` [tip:irq/core] genirq/MSI: " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 10/12] genirq, PCI: Store 'struct device *' instead 'struct pci_dev *' in struct msi_desc Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-22 20:40   ` [tip:irq/core] genirq/MSI: Store 'struct device' instead of ' struct pci_dev' " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 11/12] genirq, PCI: Reorginize struct msi_desc to prepare for support of generic MSI Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-10 12:41   ` Marc Zyngier
2015-07-10 12:41     ` Marc Zyngier
2015-07-22 20:41   ` [tip:irq/core] genirq/MSI: " tip-bot for Jiang Liu
2015-07-09  8:00 ` [RFC Patch V1 12/12] genirq, PCI: Move alloc_msi_entry() from PCI MSI code into generic MSI code Jiang Liu
2015-07-09  8:00   ` Jiang Liu
2015-07-22 20:41   ` [tip:irq/core] genirq/MSI: Move alloc_msi_entry() from PCI " tip-bot for Jiang Liu
2015-07-10  1:41 ` [RFC Patch V1 00/12] Reorganize struct msi_desc to prepare for support of generic MSI Yijing Wang
2015-07-10  1:41   ` Yijing Wang
2015-07-10 12:54 ` Marc Zyngier
2015-07-10 12:54   ` Marc Zyngier
2015-07-21  8:31 ` Thomas Gleixner
2015-07-21  8:31   ` Thomas Gleixner
2015-07-21 13:30 ` Bjorn Helgaas
2015-07-21 13:30   ` Bjorn Helgaas
2015-07-21 15:51   ` Thomas Gleixner
2015-07-21 15:51     ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-5004e98a91e8ad600f5b00872e9ddad810258f08@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bhelgaas@google.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=david.vrabel@citrix.com \
    --cc=grant.likely@linaro.org \
    --cc=hpa@zytor.com \
    --cc=jiang.liu@linux.intel.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=mingo@kernel.org \
    --cc=stuart.yoder@freescale.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=wangyijing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.