Skip to content

Commit 07820c3

Browse files
committed
Merge tag 'microblaze-4.17-rc1' of git://git.monstr.eu/linux-2.6-microblaze
Pull microblaze updates from Michal Simek: "Use generic pci_mmap_resource_range()" * tag 'microblaze-4.17-rc1' of git://git.monstr.eu/linux-2.6-microblaze: microblaze: Use generic pci_mmap_resource_range() microblaze: Provide pgprot_device/writecombine macros for nommu
2 parents c17b0aa + 70f6283 commit 07820c3

3 files changed

Lines changed: 15 additions & 93 deletions

File tree

‎arch/microblaze/include/asm/pci.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ extern int pci_proc_domain(struct pci_bus *bus);
4747

4848
struct vm_area_struct;
4949

50-
/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() */
51-
#define HAVE_PCI_MMAP 1
52-
#define arch_can_pci_mmap_io() 1
50+
/* Tell PCI code what kind of PCI resource mappings we support */
51+
#define HAVE_PCI_MMAP 1
52+
#define ARCH_GENERIC_PCI_MMAP_RESOURCE 1
53+
#define arch_can_pci_mmap_io() 1
5354

5455
extern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val,
5556
size_t count);

‎arch/microblaze/include/asm/pgtable.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ extern int mem_init_done;
3333
#define PAGE_KERNEL __pgprot(0) /* these mean nothing to non MMU */
3434

3535
#define pgprot_noncached(x) (x)
36+
#define pgprot_writecombine pgprot_noncached
37+
#define pgprot_device pgprot_noncached
3638

3739
#define __swp_type(x) (0)
3840
#define __swp_offset(x) (0)

‎arch/microblaze/pci/pci-common.c‎

Lines changed: 9 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -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 */
303222
int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val, size_t size)
304223
{

0 commit comments

Comments
 (0)