]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SPARC64]: Kill pci_memspace_mask.
authorDavid S. Miller <davem@sunset.davemloft.net>
Thu, 11 Oct 2007 22:41:01 +0000 (15:41 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sun, 14 Oct 2007 04:53:14 +0000 (21:53 -0700)
It is totally unnecessary as the needed information is properly
encoded in the resources.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc64/kernel/pci.c
arch/sparc64/kernel/pci_fire.c
arch/sparc64/kernel/pci_impl.h
arch/sparc64/kernel/pci_psycho.c
arch/sparc64/kernel/pci_schizo.c
arch/sparc64/kernel/pci_sun4v.c

index e8dac81d8a0d01e9be9ffb2914c37d7570a36d6a..9b808640a193d5c941cbb2dd16e4ec5bbffb465a 100644 (file)
@@ -29,8 +29,6 @@
 
 #include "pci_impl.h"
 
-unsigned long pci_memspace_mask = 0xffffffffUL;
-
 #ifndef CONFIG_PCI
 /* A "nop" PCI implementation. */
 asmlinkage int sys_pciconfig_read(unsigned long bus, unsigned long dfn,
@@ -1066,8 +1064,8 @@ static int __pci_mmap_make_offset_bus(struct pci_dev *pdev, struct vm_area_struc
        return 0;
 }
 
-/* Adjust vm_pgoff of VMA such that it is the physical page offset corresponding
- * to the 32-bit pci bus offset for DEV requested by the user.
+/* Adjust vm_pgoff of VMA such that it is the physical page offset
+ * corresponding to the 32-bit pci bus offset for DEV requested by the user.
  *
  * Basically, the user finds the base address for his device which he wishes
  * to mmap.  They read the 32-bit value from the config space base register,
@@ -1076,21 +1074,35 @@ static int __pci_mmap_make_offset_bus(struct pci_dev *pdev, struct vm_area_struc
  *
  * Returns negative error code on failure, zero on success.
  */
-static int __pci_mmap_make_offset(struct pci_dev *dev, struct vm_area_struct *vma,
+static int __pci_mmap_make_offset(struct pci_dev *pdev,
+                                 struct vm_area_struct *vma,
                                  enum pci_mmap_state mmap_state)
 {
-       unsigned long user_offset = vma->vm_pgoff << PAGE_SHIFT;
-       unsigned long user32 = user_offset & pci_memspace_mask;
-       unsigned long largest_base, this_base, addr32;
-       int i;
+       unsigned long user_paddr, user_size;
+       int i, err;
 
-       if ((dev->class >> 8) == PCI_CLASS_BRIDGE_HOST)
-               return __pci_mmap_make_offset_bus(dev, vma, mmap_state);
+       /* First compute the physical address in vma->vm_pgoff,
+        * making sure the user offset is within range in the
+        * appropriate PCI space.
+        */
+       err = __pci_mmap_make_offset_bus(pdev, vma, mmap_state);
+       if (err)
+               return err;
+
+       /* If this is a mapping on a host bridge, any address
+        * is OK.
+        */
+       if ((pdev->class >> 8) == PCI_CLASS_BRIDGE_HOST)
+               return err;
+
+       /* Otherwise make sure it's in the range for one of the
+        * device's resources.
+        */
+       user_paddr = vma->vm_pgoff << PAGE_SHIFT;
+       user_size = vma->vm_end - vma->vm_start;
 
-       /* Figure out which base address this is for. */
-       largest_base = 0UL;
        for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
-               struct resource *rp = &dev->resource[i];
+               struct resource *rp = &pdev->resource[i];
 
                /* Active? */
                if (!rp->flags)
@@ -1108,26 +1120,14 @@ static int __pci_mmap_make_offset(struct pci_dev *dev, struct vm_area_struct *vm
                                continue;
                }
 
-               this_base = rp->start;
-
-               addr32 = (this_base & PAGE_MASK) & pci_memspace_mask;
-
-               if (mmap_state == pci_mmap_io)
-                       addr32 &= 0xffffff;
-
-               if (addr32 <= user32 && this_base > largest_base)
-                       largest_base = this_base;
+               if ((rp->start <= user_paddr) &&
+                   (user_paddr + user_size) <= (rp->end + 1UL))
+                       break;
        }
 
-       if (largest_base == 0UL)
+       if (i > PCI_ROM_RESOURCE)
                return -EINVAL;
 
-       /* Now construct the final physical address. */
-       if (mmap_state == pci_mmap_io)
-               vma->vm_pgoff = (((largest_base & ~0xffffffUL) | user32) >> PAGE_SHIFT);
-       else
-               vma->vm_pgoff = (((largest_base & ~(pci_memspace_mask)) | user32) >> PAGE_SHIFT);
-
        return 0;
 }
 
index bcf6a5d425ab37b9d433913a8f7419a60ff4d0b9..fef3b37487bf4fc92f850afc2053afbd22c6cad2 100644 (file)
@@ -519,13 +519,6 @@ void fire_pci_init(struct device_node *dp, const char *model_name)
 
        p->pbm_B.iommu = iommu;
 
-       /* XXX MSI support XXX */
-
-       /* Like PSYCHO and SCHIZO we have a 2GB aligned area
-        * for memory space.
-        */
-       pci_memspace_mask = 0x7fffffffUL;
-
        if (pci_fire_pbm_init(p, dp, portid))
                goto fatal_memory_error;
 
index ccbb188f2e61473bc79b5dfdcff85753477b225b..4a50da13ce4899d7641cceb667e13652a2d46c32 100644 (file)
@@ -157,7 +157,6 @@ struct pci_controller_info {
 };
 
 extern struct pci_pbm_info *pci_pbm_root;
-extern unsigned long pci_memspace_mask;
 
 extern int pci_num_pbms;
 
index b6b4cfea5b5f55bdc7f23e87b1ddd577a8a25f64..d27ee5d528a2d6bfb3ef79f64aa7e225f5caa330 100644 (file)
@@ -1058,12 +1058,6 @@ void psycho_init(struct device_node *dp, char *model_name)
        p->pbm_A.config_space = p->pbm_B.config_space =
                (pr_regs[2].phys_addr + PSYCHO_CONFIGSPACE);
 
-       /*
-        * Psycho's PCI MEM space is mapped to a 2GB aligned area, so
-        * we need to adjust our MEM space mask.
-        */
-       pci_memspace_mask = 0x7fffffffUL;
-
        psycho_controller_hwinit(&p->pbm_A);
 
        if (psycho_iommu_init(&p->pbm_A))
index 3c30bfa1f3a37a9c0d7be4c6a43d7501a5ed26cd..9546ba9f5dee5c5b16b76c77c1324aeacb484b68 100644 (file)
@@ -1464,9 +1464,6 @@ static void __schizo_init(struct device_node *dp, char *model_name, int chip_typ
 
        p->pbm_B.iommu = iommu;
 
-       /* Like PSYCHO we have a 2GB aligned area for memory space. */
-       pci_memspace_mask = 0x7fffffffUL;
-
        if (schizo_pbm_init(p, dp, portid, chip_type))
                goto fatal_memory_error;
 
index 97c45b26b780d3b390a60c1385d42a71cae875b8..95de1444ee674c912a4fc51cf66a2b0b2f64754b 100644 (file)
@@ -1055,11 +1055,6 @@ void __init sun4v_pci_init(struct device_node *dp, char *model_name)
 
        p->pbm_B.iommu = iommu;
 
-       /* Like PSYCHO and SCHIZO we have a 2GB aligned area
-        * for memory space.
-        */
-       pci_memspace_mask = 0x7fffffffUL;
-
        pci_sun4v_pbm_init(p, dp, devhandle);
        return;