@@ -151,72 +151,22 @@ void pcibios_set_master(struct pci_dev *dev)
151151}
152152
153153/*
154- * Platform support for /proc/bus/pci/X/Y mmap()s,
155- * modelled on the sparc64 implementation by Dave Miller.
156- * -- paulus.
154+ * Platform support for /proc/bus/pci/X/Y mmap()s.
157155 */
158156
159- /*
160- * Adjust vm_pgoff of VMA such that it is the physical page offset
161- * corresponding to the 32-bit pci bus offset for DEV requested by the user.
162- *
163- * Basically, the user finds the base address for his device which he wishes
164- * to mmap. They read the 32-bit value from the config space base register,
165- * add whatever PAGE_SIZE multiple offset they wish, and feed this into the
166- * offset parameter of mmap on /proc/bus/pci/XXX for that device.
167- *
168- * Returns negative error code on failure, zero on success.
169- */
170- static struct resource * __pci_mmap_make_offset (struct pci_dev * dev ,
171- resource_size_t * offset ,
172- enum pci_mmap_state mmap_state )
157+ int pci_iobar_pfn (struct pci_dev * pdev , int bar , struct vm_area_struct * vma )
173158{
174- struct pci_controller * hose = pci_bus_to_host (dev -> bus );
175- unsigned long io_offset = 0 ;
176- int i , res_bit ;
159+ struct pci_controller * hose = pci_bus_to_host (pdev -> bus );
160+ resource_size_t ioaddr = pci_resource_start (pdev , bar );
177161
178162 if (!hose )
179- return NULL ; /* should never happen */
180-
181- /* If memory, add on the PCI bridge address offset */
182- if (mmap_state == pci_mmap_mem ) {
183- #if 0 /* See comment in pci_resource_to_user() for why this is disabled */
184- * offset += hose -> pci_mem_offset ;
185- #endif
186- res_bit = IORESOURCE_MEM ;
187- } else {
188- io_offset = (unsigned long )hose -> io_base_virt - _IO_BASE ;
189- * offset += io_offset ;
190- res_bit = IORESOURCE_IO ;
191- }
192-
193- /*
194- * Check that the offset requested corresponds to one of the
195- * resources of the device.
196- */
197- for (i = 0 ; i <= PCI_ROM_RESOURCE ; i ++ ) {
198- struct resource * rp = & dev -> resource [i ];
199- int flags = rp -> flags ;
163+ return - EINVAL ; /* should never happen */
200164
201- /* treat ROM as memory (should be already) */
202- if (i == PCI_ROM_RESOURCE )
203- flags |= IORESOURCE_MEM ;
204-
205- /* Active and same type? */
206- if ((flags & res_bit ) == 0 )
207- continue ;
208-
209- /* In the range of this resource? */
210- if (* offset < (rp -> start & PAGE_MASK ) || * offset > rp -> end )
211- continue ;
212-
213- /* found it! construct the final physical address */
214- if (mmap_state == pci_mmap_io )
215- * offset += hose -> io_base_phys - io_offset ;
216- return rp ;
217- }
165+ /* Convert to an offset within this PCI controller */
166+ ioaddr -= (unsigned long )hose -> io_base_virt - _IO_BASE ;
218167
219- return NULL ;
168+ vma -> vm_pgoff += (ioaddr + hose -> io_base_phys ) >> PAGE_SHIFT ;
169+ return 0 ;
220170}
221171
222172/*
@@ -268,37 +218,6 @@ pgprot_t pci_phys_mem_access_prot(struct file *file,
268218 return prot ;
269219}
270220
271- /*
272- * Perform the actual remap of the pages for a PCI device mapping, as
273- * appropriate for this architecture. The region in the process to map
274- * is described by vm_start and vm_end members of VMA, the base physical
275- * address is found in vm_pgoff.
276- * The pci device structure is provided so that architectures may make mapping
277- * decisions on a per-device or per-bus basis.
278- *
279- * Returns a negative error code on failure, zero on success.
280- */
281- int pci_mmap_page_range (struct pci_dev * dev , int bar , struct vm_area_struct * vma ,
282- enum pci_mmap_state mmap_state , int write_combine )
283- {
284- resource_size_t offset =
285- ((resource_size_t )vma -> vm_pgoff ) << PAGE_SHIFT ;
286- struct resource * rp ;
287- int ret ;
288-
289- rp = __pci_mmap_make_offset (dev , & offset , mmap_state );
290- if (rp == NULL )
291- return - EINVAL ;
292-
293- vma -> vm_pgoff = offset >> PAGE_SHIFT ;
294- vma -> vm_page_prot = pgprot_noncached (vma -> vm_page_prot );
295-
296- ret = remap_pfn_range (vma , vma -> vm_start , vma -> vm_pgoff ,
297- vma -> vm_end - vma -> vm_start , vma -> vm_page_prot );
298-
299- return ret ;
300- }
301-
302221/* This provides legacy IO read access on a bus */
303222int pci_legacy_read (struct pci_bus * bus , loff_t port , u32 * val , size_t size )
304223{
0 commit comments