linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: sumit chaudhary <flyingbee.linux@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>, linux-pci@vger.kernel.org
Subject: Re: 64 bit address to a pcie card
Date: Mon, 9 Jul 2012 01:41:45 -0700	[thread overview]
Message-ID: <CAE9FiQUbALKRWA2QsTapJOYArX0XBjU7DDxX6OSfhjXs+BGjmw@mail.gmail.com> (raw)
In-Reply-To: <CAJkVMNo4MwCXY0iHwua3hR82D14dGnALGwXkujgONPQDzaRTdQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 972 bytes --]

On Sun, Jul 8, 2012 at 10:39 PM, sumit chaudhary
<flyingbee.linux@gmail.com> wrote:
>  Hi Bjorn,
>
>  Device is working as expected but problem is that I want to test this
>  device  with real 64 bit addresses that lies above 4GB.
>  is there a way to allocate addresses above 4GB range ?
>  If I try to allocate BAR size more than 2GB i.e. to push allocated
>  address above 4GB, I increase resource size asked from OS
>  than host system stopped booting and hangs.
>  I also tried enumerating PCI subsystem using kernel command line
>  option pci_assign = buses, but same problem persist.
>  I also tried  Increasing RAM of my system to 4 GB but still address
>  allocation is in 32 bit range.

you can check my for-pci-res_alloc branch and attached patch.

	git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git
for-pci-res-alloc

and you need to boot with pci=pref_bar. it will clear pref_bar and
assign mem64 bar to above at first.

Thanks

Yinghai

[-- Attachment #2: pci_assign_pref.patch --]
[-- Type: application/octet-stream, Size: 2689 bytes --]

Subject: [PATCH] PCI, x86: Add pci=pref_bar to realloc pref bars

So could reallocate 64bit pref mem above 4g.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 arch/x86/include/asm/pci_x86.h |    1 +
 arch/x86/pci/common.c          |    3 +++
 arch/x86/pci/i386.c            |   20 +++++++++++++-------
 3 files changed, 17 insertions(+), 7 deletions(-)

Index: linux-2.6/arch/x86/include/asm/pci_x86.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/pci_x86.h
+++ linux-2.6/arch/x86/include/asm/pci_x86.h
@@ -35,6 +35,7 @@ do {						\
 #define PCI_NOASSIGN_ROMS	0x80000
 #define PCI_ROOT_NO_CRS		0x100000
 #define PCI_NOASSIGN_BARS	0x200000
+#define PCI_ASSIGN_PREF_BARS	0x400000
 
 extern unsigned int pci_probe;
 extern unsigned long pirq_table_addr;
Index: linux-2.6/arch/x86/pci/common.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/common.c
+++ linux-2.6/arch/x86/pci/common.c
@@ -573,6 +573,9 @@ char * __devinit  pcibios_setup(char *st
 	} else if (!strcmp(str, "assign-busses")) {
 		pci_probe |= PCI_ASSIGN_ALL_BUSSES;
 		return NULL;
+	} else if (!strcmp(str, "pref_bar")) {
+		pci_probe |= PCI_ASSIGN_PREF_BARS;
+		return NULL;
 	} else if (!strcmp(str, "use_crs")) {
 		pci_probe |= PCI_USE__CRS;
 		return NULL;
Index: linux-2.6/arch/x86/pci/i386.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/i386.c
+++ linux-2.6/arch/x86/pci/i386.c
@@ -212,7 +212,9 @@ static void pcibios_allocate_bridge_reso
 			continue;
 		if (!r->flags)
 			continue;
-		if (!r->start || pci_claim_resource(dev, idx) < 0) {
+		if (((r->flags & IORESOURCE_PREFETCH) &&
+		     (pci_probe & PCI_ASSIGN_PREF_BARS)) ||
+		    !r->start || pci_claim_resource(dev, idx) < 0) {
 			/*
 			 * Something is wrong with the region.
 			 * Invalidate the resource to prevent
@@ -253,15 +255,19 @@ static void pcibios_allocate_dev_resourc
 		else
 			disabled = !(command & PCI_COMMAND_MEMORY);
 		if (pass == disabled) {
+			if ((r->flags & IORESOURCE_PREFETCH) &&
+			    (pci_probe & PCI_ASSIGN_PREF_BARS))
+				goto clear_start;
 			dev_dbg(&dev->dev,
 				"BAR %d: reserving %pr (d=%d, p=%d)\n",
 				idx, r, disabled, pass);
-			if (pci_claim_resource(dev, idx) < 0) {
-				/* We'll assign a new address later */
-				pcibios_save_fw_addr(dev, idx, r->start);
-				r->end -= r->start;
-				r->start = 0;
-			}
+			if (!pci_claim_resource(dev, idx))
+				continue;
+clear_start:
+			/* We'll assign a new address later */
+			pcibios_save_fw_addr(dev, idx, r->start);
+			r->end -= r->start;
+			r->start = 0;
 		}
 	}
 	if (!pass) {

      reply	other threads:[~2012-07-09  8:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-04  6:33 64 bit address to a pcie card sumit chaudhary
2012-07-04 13:59 ` Bjorn Helgaas
     [not found]   ` <CAJkVMNpZaMKm8tc+axdOBySpp68_j=EegEUOO+B=cYudsxNCgw@mail.gmail.com>
2012-07-05 15:16     ` Bjorn Helgaas
2012-07-06  0:14       ` Yinghai Lu
2012-07-06  3:49         ` Bjorn Helgaas
2012-07-09  5:39       ` sumit chaudhary
2012-07-09  8:41         ` Yinghai Lu [this message]

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=CAE9FiQUbALKRWA2QsTapJOYArX0XBjU7DDxX6OSfhjXs+BGjmw@mail.gmail.com \
    --to=yinghai@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=flyingbee.linux@gmail.com \
    --cc=linux-pci@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;
as well as URLs for NNTP newsgroup(s).