aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-09-01 13:07:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-01 13:07:40 -0400
commit25525bea46e7d5bc1f82cbc12de2f27b9c346a92 (patch)
tree9308304c84f0f776f6477662335bff9a9b0d1327 /lib
parent2962156d5cc0e7f959353d3f5275da7cc3765f06 (diff)
parent2baa891e42d84159b693eadd44f6fe1486285bdc (diff)
Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 mm updates from Ingo Molnar: "The dominant change in this cycle was the continued work to isolate kernel drivers from MTRR legacies: this tree gets rid of all kernel internal driver interfaces to MTRRs (mostly by rewriting it to proper PAT interfaces), the only access left is the /proc/mtrr ABI. This work was done by Luis R Rodriguez. There's also some related PCI interface additions for which I've Cc:-ed Bjorn" * 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (21 commits) x86/mm/mtrr: Remove kernel internal MTRR interfaces: unexport mtrr_add() and mtrr_del() s390/io: Add pci_iomap_wc() and pci_iomap_wc_range() drivers/dma/iop-adma: Use dma_alloc_writecombine() kernel-style drivers/video/fbdev/vt8623fb: Use arch_phys_wc_add() and pci_iomap_wc() drivers/video/fbdev/s3fb: Use arch_phys_wc_add() and pci_iomap_wc() drivers/video/fbdev/arkfb.c: Use arch_phys_wc_add() and pci_iomap_wc() PCI: Add pci_iomap_wc() variants drivers/video/fbdev/gxt4500: Use pci_ioremap_wc_bar() to map framebuffer drivers/video/fbdev/kyrofb: Use arch_phys_wc_add() and pci_ioremap_wc_bar() drivers/video/fbdev/i740fb: Use arch_phys_wc_add() and pci_ioremap_wc_bar() PCI: Add pci_ioremap_wc_bar() x86/mm: Make kernel/check.c explicitly non-modular x86/mm/pat: Make mm/pageattr[-test].c explicitly non-modular x86/mm/pat: Add comments to cachemode translation tables arch/*/io.h: Add ioremap_uc() to all architectures drivers/video/fbdev/atyfb: Use arch_phys_wc_add() and ioremap_wc() drivers/video/fbdev/atyfb: Replace MTRR UC hole with strong UC drivers/video/fbdev/atyfb: Clarify ioremap() base and length used drivers/video/fbdev/atyfb: Carve out framebuffer length fudging into a helper x86/mm, asm-generic: Add IOMMU ioremap_uc() variant default ...
Diffstat (limited to 'lib')
-rw-r--r--lib/pci_iomap.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c
index bcce5f149310..5f5d24d1d53f 100644
--- a/lib/pci_iomap.c
+++ b/lib/pci_iomap.c
@@ -52,6 +52,51 @@ void __iomem *pci_iomap_range(struct pci_dev *dev,
52EXPORT_SYMBOL(pci_iomap_range); 52EXPORT_SYMBOL(pci_iomap_range);
53 53
54/** 54/**
55 * pci_iomap_wc_range - create a virtual WC mapping cookie for a PCI BAR
56 * @dev: PCI device that owns the BAR
57 * @bar: BAR number
58 * @offset: map memory at the given offset in BAR
59 * @maxlen: max length of the memory to map
60 *
61 * Using this function you will get a __iomem address to your device BAR.
62 * You can access it using ioread*() and iowrite*(). These functions hide
63 * the details if this is a MMIO or PIO address space and will just do what
64 * you expect from them in the correct way. When possible write combining
65 * is used.
66 *
67 * @maxlen specifies the maximum length to map. If you want to get access to
68 * the complete BAR from offset to the end, pass %0 here.
69 * */
70void __iomem *pci_iomap_wc_range(struct pci_dev *dev,
71 int bar,
72 unsigned long offset,
73 unsigned long maxlen)
74{
75 resource_size_t start = pci_resource_start(dev, bar);
76 resource_size_t len = pci_resource_len(dev, bar);
77 unsigned long flags = pci_resource_flags(dev, bar);
78
79
80 if (flags & IORESOURCE_IO)
81 return NULL;
82
83 if (len <= offset || !start)
84 return NULL;
85
86 len -= offset;
87 start += offset;
88 if (maxlen && len > maxlen)
89 len = maxlen;
90
91 if (flags & IORESOURCE_MEM)
92 return ioremap_wc(start, len);
93
94 /* What? */
95 return NULL;
96}
97EXPORT_SYMBOL_GPL(pci_iomap_wc_range);
98
99/**
55 * pci_iomap - create a virtual mapping cookie for a PCI BAR 100 * pci_iomap - create a virtual mapping cookie for a PCI BAR
56 * @dev: PCI device that owns the BAR 101 * @dev: PCI device that owns the BAR
57 * @bar: BAR number 102 * @bar: BAR number
@@ -70,4 +115,25 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
70 return pci_iomap_range(dev, bar, 0, maxlen); 115 return pci_iomap_range(dev, bar, 0, maxlen);
71} 116}
72EXPORT_SYMBOL(pci_iomap); 117EXPORT_SYMBOL(pci_iomap);
118
119/**
120 * pci_iomap_wc - create a virtual WC mapping cookie for a PCI BAR
121 * @dev: PCI device that owns the BAR
122 * @bar: BAR number
123 * @maxlen: length of the memory to map
124 *
125 * Using this function you will get a __iomem address to your device BAR.
126 * You can access it using ioread*() and iowrite*(). These functions hide
127 * the details if this is a MMIO or PIO address space and will just do what
128 * you expect from them in the correct way. When possible write combining
129 * is used.
130 *
131 * @maxlen specifies the maximum length to map. If you want to get access to
132 * the complete BAR without checking for its length first, pass %0 here.
133 * */
134void __iomem *pci_iomap_wc(struct pci_dev *dev, int bar, unsigned long maxlen)
135{
136 return pci_iomap_wc_range(dev, bar, 0, maxlen);
137}
138EXPORT_SYMBOL_GPL(pci_iomap_wc);
73#endif /* CONFIG_PCI */ 139#endif /* CONFIG_PCI */