Gerd Hoffmann | 7 Jun 2012 10:34
Picon
Favicon

[PATCH 0/4] pci: 64bit pci window patches

  Hi,

Time to repost, aiming for merge.  The patches survived my local testing
and win2k8 testing by Alexey.  Patch #4 got some finishing touches:
Tries two 64bit I/O window sizes only, also added a comment explaining
why it is done.  Rebased to latest master.

cheers,
  Gerd

Gerd Hoffmann (4):
  update bios date
  pciinit: make pci ressources configurable
  update dsdt ressources at runtime
  pci: runtime i/o window sizing

 src/acpi-dsdt.dsl |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/acpi.c        |   28 ++++++++++++++++++++++-
 src/acpi.h        |    9 +++++++
 src/pci.h         |    2 +
 src/pciinit.c     |   46 +++++++++++++++++++++++++++++++------
 src/smbios.c      |    2 +-
 6 files changed, 139 insertions(+), 13 deletions(-)
Gerd Hoffmann | 7 Jun 2012 10:34
Picon
Favicon

[PATCH 4/4] pci: runtime i/o window sizing

Update the pci i/o windows at runtime, depending on the amount memory
the machine has.  The 32bit window starts above low memory and ends at
the ioapic map address, the 64bit window is placed above high memory.

Signed-off-by: Gerd Hoffmann <kraxel <at> redhat.com>
---
 src/pciinit.c |   33 +++++++++++++++++++++++++++++----
 1 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/pciinit.c b/src/pciinit.c
index dc33f83..dd74963 100644
--- a/src/pciinit.c
+++ b/src/pciinit.c
 <at>  <at>  -592,6 +592,20  <at>  <at>  static void pci_region_map_entries(struct pci_bus *busses, struct pci_region *r)

 static void pci_bios_map_devices(struct pci_bus *busses)
 {
+    /*
+     * Try smaller 64bit windows first, sized to be half of the
+     * maximum physical address space of common cpus.
+     * Your cpu: try 'grep "address sizes" /proc/cpuinfo'
+     */
+    static const u64 sizes[] = {
+        (1LL << 35),  // 36 bits physical (64 GB, every PAE-capable cpu can do this)
+        (1LL << 39),  // 40 bits physical (1 TB)
+    };
+    u64 pcimem64_size;
+    int i;
+
+    pcimem_start = RamSize;
(Continue reading)

Kevin O'Connor | 9 Jun 2012 14:57

Re: [PATCH 4/4] pci: runtime i/o window sizing

On Thu, Jun 07, 2012 at 10:34:34AM +0200, Gerd Hoffmann wrote:
> Update the pci i/o windows at runtime, depending on the amount memory
> the machine has.  The 32bit window starts above low memory and ends at
> the ioapic map address, the 64bit window is placed above high memory.
[...]
> -        r64_mem.base = pcimem64_start;
> -        u64 sum = pci_region_sum(&r64_mem);
> -        u64 align = pci_region_align(&r64_pref);
> -        r64_pref.base = ALIGN(r64_mem.base + sum, align);
> +        for (i = 0; i < ARRAY_SIZE(sizes); i++) {
> +            pcimem64_size = sizes[i];
> +            pcimem64_start = ALIGN(0x100000000LL + RamSizeOver4G, pcimem64_size);

Why align to 64GB (or 1TB)?  How about just starting at 4GB past ram
aligned to 4GB.

> +            pcimem64_end = pcimem64_start + pcimem64_size;
> +
> +            r64_mem.base = pcimem64_start;
> +            u64 sum = pci_region_sum(&r64_mem);
> +            u64 align = pci_region_align(&r64_pref);
> +            r64_pref.base = ALIGN(r64_mem.base + sum, align);
> +            if (r64_pref.base + pci_region_sum(&r64_pref) <= pcimem64_end)
> +                break;

Why not just assign "pcimem64_end = r64_pref.base +
pci_region_sum(&r64_pref)" instead?  That is, instead of looping to
try certain sizes, why not just set the range according to how much
space is found to be needed?

(Continue reading)

Gerd Hoffmann | 7 Jun 2012 10:34
Picon
Favicon

[PATCH 2/4] pciinit: make pci ressources configurable

This patch adds variables for the pci io window, so they are
runtime-configurable.  They are initialized with the values
from config.h

Signed-off-by: Gerd Hoffmann <kraxel <at> redhat.com>
---
 src/pci.h     |    2 ++
 src/pciinit.c |   15 ++++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/pci.h b/src/pci.h
index 6be838c..ebf934c 100644
--- a/src/pci.h
+++ b/src/pci.h
 <at>  <at>  -56,6 +56,8  <at>  <at>  struct pci_device {
     // Local information on device.
     int have_driver;
 };
+extern u64 pcimem_start, pcimem_end;
+extern u64 pcimem64_start, pcimem64_end;
 extern struct pci_device *PCIDevices;
 extern int MaxPCIBus;
 int pci_probe_host(void);
diff --git a/src/pciinit.c b/src/pciinit.c
index 8452572..dc33f83 100644
--- a/src/pciinit.c
+++ b/src/pciinit.c
 <at>  <at>  -30,6 +30,11  <at>  <at>  static const char *region_type_name[] = {
     [ PCI_REGION_TYPE_PREFMEM ] = "prefmem",
 };
(Continue reading)

Gerd Hoffmann | 7 Jun 2012 10:34
Picon
Favicon

[PATCH 3/4] update dsdt ressources at runtime

Write the pci window location to memory and add a pointer to the SSDT
(BDAT region).  Turn \\SB.PCI0._CRS into a method which looks up the
information there and updates the ressources accordingly.

Signed-off-by: Gerd Hoffmann <kraxel <at> redhat.com>
---
 src/acpi-dsdt.dsl |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/acpi.c        |   28 ++++++++++++++++++++++-
 src/acpi.h        |    9 +++++++
 3 files changed, 98 insertions(+), 4 deletions(-)

diff --git a/src/acpi-dsdt.dsl b/src/acpi-dsdt.dsl
index 4bdc268..5305ff9 100644
--- a/src/acpi-dsdt.dsl
+++ b/src/acpi-dsdt.dsl
 <at>  <at>  -59,7 +59,6  <at>  <at>  DefinitionBlock (
         }
     }

-
 /****************************************************************
  * PCI Bus definition
  ****************************************************************/
 <at>  <at>  -132,7 +131,7  <at>  <at>  DefinitionBlock (
                 B0EJ, 32,
             }

-            Name (_CRS, ResourceTemplate ()
+            Name (CRES, ResourceTemplate ()
             {
(Continue reading)

Gerd Hoffmann | 7 Jun 2012 10:34
Picon
Favicon

[PATCH 1/4] update bios date

Linux ignores some information from acpi in case the bios is old
as acpi support used to be buggy in the early days.  This affects
ressources for example (unless forced with pci=use_crs).  So lets
go for something more recent.  With this patch applied the
ressources for \\SB.PCI0 will show up in /proc/{iomem,ioports},
tagged as "PCI Bus 0000:00".

Signed-off-by: Gerd Hoffmann <kraxel <at> redhat.com>
---
 src/smbios.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/smbios.c b/src/smbios.c
index 20d2d47..fc84aad 100644
--- a/src/smbios.c
+++ b/src/smbios.c
 <at>  <at>  -93,7 +93,7  <at>  <at>  smbios_entry_point_init(u16 max_structure_size,
     } while (0)

 /* Type 0 -- BIOS Information */
-#define RELEASE_DATE_STR "01/01/2007"
+#define RELEASE_DATE_STR "01/01/2011"
 static void *
 smbios_init_type_0(void *start)
 {
--

-- 
1.7.1
Fred . | 7 Jun 2012 10:49
Picon

Re: [PATCH 1/4] update bios date

But its 2012 not 2011 now...

On Thu, Jun 7, 2012 at 10:34 AM, Gerd Hoffmann <kraxel <at> redhat.com> wrote:
> Linux ignores some information from acpi in case the bios is old
> as acpi support used to be buggy in the early days.  This affects
> ressources for example (unless forced with pci=use_crs).  So lets
> go for something more recent.  With this patch applied the
> ressources for \\SB.PCI0 will show up in /proc/{iomem,ioports},
> tagged as "PCI Bus 0000:00".
>
> Signed-off-by: Gerd Hoffmann <kraxel <at> redhat.com>
> ---
>  src/smbios.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/smbios.c b/src/smbios.c
> index 20d2d47..fc84aad 100644
> --- a/src/smbios.c
> +++ b/src/smbios.c
>  <at>  <at>  -93,7 +93,7  <at>  <at>  smbios_entry_point_init(u16 max_structure_size,
>     } while (0)
>
>  /* Type 0 -- BIOS Information */
> -#define RELEASE_DATE_STR "01/01/2007"
> +#define RELEASE_DATE_STR "01/01/2011"
>  static void *
>  smbios_init_type_0(void *start)
>  {
> --
> 1.7.1
(Continue reading)

Kevin O'Connor | 8 Jun 2012 02:03

Re: [PATCH 0/4] pci: 64bit pci window patches

On Thu, Jun 07, 2012 at 10:34:30AM +0200, Gerd Hoffmann wrote:
>   Hi,
> 
> Time to repost, aiming for merge.  The patches survived my local testing
> and win2k8 testing by Alexey.  Patch #4 got some finishing touches:
> Tries two 64bit I/O window sizes only, also added a comment explaining
> why it is done.  Rebased to latest master.

Thanks.  I pushed patches 1-3.  I'm still not understanding what patch
4 does.  I'll try to take a closer look this weekend.

-Kevin

Gmane