Lines Matching +full:resource +full:- +full:files
1 // SPDX-License-Identifier: GPL-2.0
3 * arch/alpha/kernel/pci-sysfs.c
7 * Alpha PCI resource files.
10 * drivers/pci/pci-sysfs.c
25 base = sparse ? hose->sparse_mem_base : hose->dense_mem_base; in hose_mmap_page_range()
27 base = sparse ? hose->sparse_io_base : hose->dense_io_base; in hose_mmap_page_range()
29 vma->vm_pgoff += base >> PAGE_SHIFT; in hose_mmap_page_range()
31 return io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, in hose_mmap_page_range()
32 vma->vm_end - vma->vm_start, in hose_mmap_page_range()
33 vma->vm_page_prot); in hose_mmap_page_range()
43 start = vma->vm_pgoff; in __pci_mmap_fits()
44 size = ((pci_resource_len(pdev, num) - 1) >> (PAGE_SHIFT - shift)) + 1; in __pci_mmap_fits()
46 if (start < size && size - start >= nr) in __pci_mmap_fits()
48 WARN(1, "process \"%s\" tried to map%s 0x%08lx-0x%08lx on %s BAR %d " in __pci_mmap_fits()
50 current->comm, sparse ? " sparse" : "", start, start + nr, in __pci_mmap_fits()
56 * pci_mmap_resource - map a PCI resource into user memory space
62 * Use the bus mapping routines to map a PCI resource into userspace.
71 struct resource *res = attr->private; in pci_mmap_resource()
77 if (res == &pdev->resource[i]) in pci_mmap_resource()
80 return -ENODEV; in pci_mmap_resource()
82 if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start)) in pci_mmap_resource()
83 return -EINVAL; in pci_mmap_resource()
86 return -EINVAL; in pci_mmap_resource()
88 pcibios_resource_to_bus(pdev->bus, &bar, res); in pci_mmap_resource()
89 vma->vm_pgoff += bar.start >> (PAGE_SHIFT - (sparse ? 5 : 0)); in pci_mmap_resource()
90 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; in pci_mmap_resource()
92 return hose_mmap_page_range(pdev->sysdata, vma, mmap_type, sparse); in pci_mmap_resource()
110 * pci_remove_resource_files - cleanup resource files
113 * If we created resource files for @dev, remove them from sysfs and
123 res_attr = pdev->res_attr[i]; in pci_remove_resource_files()
125 sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); in pci_remove_resource_files()
129 res_attr = pdev->res_attr_wc[i]; in pci_remove_resource_files()
131 sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); in pci_remove_resource_files()
140 struct pci_controller *hose = pdev->sysdata; in sparse_mem_mmap_fits()
144 pcibios_resource_to_bus(pdev->bus, &bar, &pdev->resource[num]); in sparse_mem_mmap_fits()
148 definitions in asm/core_xxx.h files). This corresponds in sparse_mem_mmap_fits()
150 dense_offset = (long)(hose->dense_mem_base - hose->sparse_mem_base); in sparse_mem_mmap_fits()
162 sprintf(name, "resource%d%s", num, suffix); in pci_create_one_attr()
163 res_attr->mmap = sparse ? pci_mmap_resource_sparse : in pci_create_one_attr()
165 res_attr->attr.name = name; in pci_create_one_attr()
166 res_attr->attr.mode = S_IRUSR | S_IWUSR; in pci_create_one_attr()
167 res_attr->size = sparse ? size << 5 : size; in pci_create_one_attr()
168 res_attr->private = &pdev->resource[num]; in pci_create_one_attr()
169 return sysfs_create_bin_file(&pdev->dev.kobj, res_attr); in pci_create_one_attr()
178 struct pci_controller *hose = pdev->sysdata; in pci_create_attr()
181 suffix = ""; /* Assume bwx machine, normal resourceN files. */ in pci_create_attr()
184 if (pdev->resource[num].flags & IORESOURCE_MEM) { in pci_create_attr()
185 sparse_base = hose->sparse_mem_base; in pci_create_attr()
186 dense_base = hose->dense_mem_base; in pci_create_attr()
193 sparse_base = hose->sparse_io_base; in pci_create_attr()
194 dense_base = hose->dense_io_base; in pci_create_attr()
208 return -ENOMEM; in pci_create_attr()
212 pdev->res_attr[num] = attr; in pci_create_attr()
221 pdev->res_attr_wc[num] = attr; in pci_create_attr()
226 * pci_create_resource_files - create resource files in sysfs for @pdev
229 * Walk the resources in @dev creating files for each resource available.
238 /* Expose the PCI resources from this device as files */ in pci_create_resource_files()
263 start = vma->vm_pgoff; in __legacy_mmap_fits()
264 size = ((res_size - 1) >> PAGE_SHIFT) + 1; in __legacy_mmap_fits()
266 if (start < size && size - start >= nr) in __legacy_mmap_fits()
268 WARN(1, "process \"%s\" tried to map%s 0x%08lx-0x%08lx on hose %d " in __legacy_mmap_fits()
270 current->comm, sparse ? " sparse" : "", start, start + nr, in __legacy_mmap_fits()
271 hose->index, size); in __legacy_mmap_fits()
280 base = (mmap_type == pci_mmap_mem) ? hose->sparse_mem_base : in has_sparse()
281 hose->sparse_io_base; in has_sparse()
289 struct pci_controller *hose = bus->sysdata; in pci_mmap_legacy_page_range()
293 res_size = (mmap_type == pci_mmap_mem) ? bus->legacy_mem->size : in pci_mmap_legacy_page_range()
294 bus->legacy_io->size; in pci_mmap_legacy_page_range()
296 return -EINVAL; in pci_mmap_legacy_page_range()
302 * pci_adjust_legacy_attr - adjustment of legacy file attributes
303 * @bus: bus to create files under
310 struct pci_controller *hose = bus->sysdata; in pci_adjust_legacy_attr()
316 bus->legacy_mem->attr.name = "legacy_mem_sparse"; in pci_adjust_legacy_attr()
317 bus->legacy_mem->size <<= 5; in pci_adjust_legacy_attr()
319 bus->legacy_io->attr.name = "legacy_io_sparse"; in pci_adjust_legacy_attr()
320 bus->legacy_io->size <<= 5; in pci_adjust_legacy_attr()
328 struct pci_controller *hose = bus->sysdata; in pci_legacy_read()
330 port += hose->io_space->start; in pci_legacy_read()
338 return -EINVAL; in pci_legacy_read()
343 return -EINVAL; in pci_legacy_read()
347 return -EINVAL; in pci_legacy_read()
352 struct pci_controller *hose = bus->sysdata; in pci_legacy_write()
354 port += hose->io_space->start; in pci_legacy_write()
362 return -EINVAL; in pci_legacy_write()
367 return -EINVAL; in pci_legacy_write()
371 return -EINVAL; in pci_legacy_write()