Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: joro@8bytes.org, iommu@lists.linux-foundation.org
Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	Baoquan He <bhe@redhat.com>
Subject: [PATCH 02/10] iommu/amd: Adjust functons which get first/last devid by reading pci config
Date: Thu, 24 Sep 2015 14:37:28 +0800	[thread overview]
Message-ID: <1443076656-31776-3-git-send-email-bhe@redhat.com> (raw)
In-Reply-To: <1443076656-31776-1-git-send-email-bhe@redhat.com>

The old functon find_last_devid_on_pci not only gets the last devid, but calls
update_last_devid(). Now adjust the function definition to make it be consistent
with its name. Meanwhile add a new function find_first_devid_on_pci for later use.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 drivers/iommu/amd_iommu_init.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 286da26..be20a56 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -412,14 +412,32 @@ static inline int ivhd_entry_length(u8 *ivhd)
  * This function reads the last device id the IOMMU has to handle from the PCI
  * capability header for this IOMMU
  */
-static int __init find_last_devid_on_pci(int bus, int dev, int fn, int cap_ptr)
+static int __init find_first_devid_on_pci(struct ivhd_header *h)
 {
-	u32 cap;
+	u32 range;
 
-	cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET);
-	update_last_devid(PCI_DEVID(MMIO_GET_BUS(cap), MMIO_GET_LD(cap)));
+	range = read_pci_config(PCI_BUS_NUM(h->devid),
+				PCI_SLOT(h->devid),
+				PCI_FUNC(h->devid),
+				h->cap_ptr+MMIO_RANGE_OFFSET);
 
-	return 0;
+	return PCI_DEVID(MMIO_GET_BUS(range), MMIO_GET_FD(range));
+}
+
+/*
+ * This function reads the last device id the IOMMU has to handle from the PCI
+ * capability header for this IOMMU
+ */
+static int __init find_last_devid_on_pci(struct ivhd_header *h)
+{
+	u32 range;
+
+	range = read_pci_config(PCI_BUS_NUM(h->devid),
+				PCI_SLOT(h->devid),
+				PCI_FUNC(h->devid),
+				h->cap_ptr+MMIO_RANGE_OFFSET);
+
+	return PCI_DEVID(MMIO_GET_BUS(range), MMIO_GET_LD(range));
 }
 
 /*
@@ -430,15 +448,14 @@ static int __init find_last_devid_from_ivhd(struct ivhd_header *h)
 {
 	u8 *p = (void *)h, *end = (void *)h;
 	struct ivhd_entry *dev;
+	u16 devid;
+
+	devid = find_last_devid_on_pci(h);
+	update_last_devid(devid);
 
 	p += sizeof(*h);
 	end += h->length;
 
-	find_last_devid_on_pci(PCI_BUS_NUM(h->devid),
-			PCI_SLOT(h->devid),
-			PCI_FUNC(h->devid),
-			h->cap_ptr);
-
 	while (p < end) {
 		dev = (struct ivhd_entry *)p;
 		switch (dev->type) {
-- 
2.4.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  parent reply	other threads:[~2015-09-24  6:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-24  6:37 [PATCH 00/10] Fix AMD IOMMU faults in kdump kernel Baoquan He
2015-09-24  6:37 ` [PATCH 01/10] iommu/amd: Use standard bitmap operation to set bitmap Baoquan He
2015-09-24  6:37 ` Baoquan He [this message]
2015-09-24  6:37 ` [PATCH 03/10] iommu/amd: Get the first/last device of iommu earlier Baoquan He
2015-09-24  6:37 ` [PATCH 04/10] iommu/amd: Detect pre enabled translation Baoquan He
2015-09-24  6:37 ` [PATCH 05/10] iommu/amd: Add function copy_dev_tables Baoquan He
2015-09-24  6:37 ` [PATCH 06/10] iommu/amd: Add functions copy_command_buffer/copy_event_buffer Baoquan He
     [not found]   ` <20150929160439.GN3036@8bytes.org>
2015-10-10 12:24     ` Baoquan He
2015-09-24  6:37 ` [PATCH 07/10] iommu/amd: copy old dev tables and do not touch dev tables Baoquan He
     [not found]   ` <20150929160808.GO3036@8bytes.org>
2015-10-10 12:28     ` Baoquan He
2015-09-24  6:37 ` [PATCH 08/10] iommu/amd: Do not update the information of domain to devtables before device driver init Baoquan He
2015-09-24  6:37 ` [PATCH 09/10] iommu/amd: Clear the iommu pre enabled setting Baoquan He
     [not found]   ` <20150929160949.GP3036@8bytes.org>
2015-10-10 12:30     ` Baoquan He
2015-09-24  6:37 ` [PATCH 10/10] iommu/amd: Copy the old ir table Baoquan He
     [not found]   ` <20150929161140.GQ3036@8bytes.org>
2015-10-10 12:40     ` Baoquan He

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=1443076656-31776-3-git-send-email-bhe@redhat.com \
    --to=bhe@redhat.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox