public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: adurbin@google.com
To: linux-kernel@vger.kernel.org
Cc: ak@suse.de
Subject: [PATCH] x86_64: add mmconfig to resource tree
Date: Thu, 31 Aug 2006 15:49:13 -0700	[thread overview]
Message-ID: <20060831224913.GA19882@google.com> (raw)


This patch addes the PCI memory mapped config region(s) to be visible in
/proc/iomem.  This will allow for more visibility into the physical memory
map without having to parse the dmesg output.

Signed-off-by: Aaron Durbin <adurbin@google.com>

---

diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
index 3c55c76..f95af08 100644
--- a/arch/x86_64/pci/mmconfig.c
+++ b/arch/x86_64/pci/mmconfig.c
@@ -9,6 +9,7 @@ #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/acpi.h>
 #include <linux/bitmap.h>
+#include <linux/ioport.h>
 #include <asm/e820.h>
 
 #include "pci.h"
@@ -164,6 +165,37 @@ static __init void unreachable_devices(v
 	}
 }
 
+static __init void pci_mmcfg_insert_resources(void)
+{
+#define PCI_MMCFG_RESOURCE_NAME_LEN 19
+	int i;
+	struct resource *res;
+	char *names;
+	unsigned n;
+
+	n = (PCI_MMCFG_RESOURCE_NAME_LEN + sizeof(*res));
+	n *= pci_mmcfg_config_num;
+
+	res = kcalloc(1, n, GFP_KERNEL);
+
+	if (!res)
+		return;
+
+	names = (void *)&res[pci_mmcfg_config_num];
+	for (i = 0; i < pci_mmcfg_config_num; i++, res++) {
+		n = pci_mmcfg_config[i].end_bus_number - 
+		    pci_mmcfg_config[i].start_bus_number + 1;
+		res->name = names;
+		snprintf(names, PCI_MMCFG_RESOURCE_NAME_LEN, "PCI MMCONFIG %u",
+			pci_mmcfg_config[i].pci_segment_group_number);
+		res->start = pci_mmcfg_config[i].base_address;
+		res->end = res->start + (n << 20) - 1;
+		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+		insert_resource(&iomem_resource, res);
+		names += PCI_MMCFG_RESOURCE_NAME_LEN;
+	}
+}
+
 void __init pci_mmcfg_init(void)
 {
 	int i;
@@ -205,6 +237,7 @@ void __init pci_mmcfg_init(void)
 	}
 
 	unreachable_devices();
+	pci_mmcfg_insert_resources();
 
 	raw_pci_ops = &pci_mmcfg;
 	pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;

                 reply	other threads:[~2006-08-31 22:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20060831224913.GA19882@google.com \
    --to=adurbin@google.com \
    --cc=ak@suse.de \
    --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