Lines Matching full:bar

55 	/* A requested region spanning an entire BAR. */
59 * A requested region spanning an entire BAR, and a mapping for
60 * the entire BAR.
65 * A mapping within a BAR, either spanning the whole BAR or just a
81 int bar; member
87 res->bar = -1; in pcim_addr_devres_clear()
101 * @bar: BAR the range is within
102 * @offset: offset from the BAR's start address
109 * Request a range within a device's PCI BAR. Sanity check the input.
111 static int __pcim_request_region_range(struct pci_dev *pdev, int bar, in __pcim_request_region_range() argument
116 resource_size_t start = pci_resource_start(pdev, bar); in __pcim_request_region_range()
117 resource_size_t len = pci_resource_len(pdev, bar); in __pcim_request_region_range()
118 unsigned long dev_flags = pci_resource_flags(pdev, bar); in __pcim_request_region_range()
120 if (start == 0 || len == 0) /* Unused BAR. */ in __pcim_request_region_range()
145 static void __pcim_release_region_range(struct pci_dev *pdev, int bar, in __pcim_release_region_range() argument
149 resource_size_t start = pci_resource_start(pdev, bar); in __pcim_release_region_range()
150 resource_size_t len = pci_resource_len(pdev, bar); in __pcim_release_region_range()
151 unsigned long flags = pci_resource_flags(pdev, bar); in __pcim_release_region_range()
156 if (len == 0 || maxlen == 0) /* This an unused BAR. Do nothing. */ in __pcim_release_region_range()
171 static int __pcim_request_region(struct pci_dev *pdev, int bar, in __pcim_request_region() argument
175 unsigned long len = pci_resource_len(pdev, bar); in __pcim_request_region()
177 return __pcim_request_region_range(pdev, bar, offset, len, name, flags); in __pcim_request_region()
180 static void __pcim_release_region(struct pci_dev *pdev, int bar) in __pcim_release_region() argument
183 unsigned long len = pci_resource_len(pdev, bar); in __pcim_release_region()
185 __pcim_release_region_range(pdev, bar, offset, len); in __pcim_release_region()
195 __pcim_release_region(pdev, res->bar); in pcim_addr_resource_release()
199 __pcim_release_region(pdev, res->bar); in pcim_addr_resource_release()
243 return a->bar == b->bar; in pcim_addr_resources_match()
409 static inline bool mask_contains_bar(int mask, int bar) in mask_contains_bar() argument
411 return mask & BIT(bar); in mask_contains_bar()
566 * void __iomem \*mappy = pcim_iomap(pdev, bar, length);
587 * still get a BAR's mapping address through pcim_iomap_table().
590 void __iomem *mapping, int bar) in pcim_add_mapping_to_legacy_table() argument
594 if (bar >= PCI_STD_NUM_BARS) in pcim_add_mapping_to_legacy_table()
602 WARN_ON(legacy_iomap_table[bar]); in pcim_add_mapping_to_legacy_table()
604 legacy_iomap_table[bar] = mapping; in pcim_add_mapping_to_legacy_table()
610 * Remove a mapping. The table only contains whole-BAR mappings, so this will
616 int bar; in pcim_remove_mapping_from_legacy_table() local
623 for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { in pcim_remove_mapping_from_legacy_table()
624 if (legacy_iomap_table[bar] == addr) { in pcim_remove_mapping_from_legacy_table()
625 legacy_iomap_table[bar] = NULL; in pcim_remove_mapping_from_legacy_table()
633 * mapping by its BAR index.
635 static void pcim_remove_bar_from_legacy_table(struct pci_dev *pdev, int bar) in pcim_remove_bar_from_legacy_table() argument
639 if (bar >= PCI_STD_NUM_BARS) in pcim_remove_bar_from_legacy_table()
646 legacy_iomap_table[bar] = NULL; in pcim_remove_bar_from_legacy_table()
652 * @bar: BAR to iomap
660 * This SHOULD only be used once per BAR.
667 void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen) in pcim_iomap() argument
677 mapping = pci_iomap(pdev, bar, maxlen); in pcim_iomap()
682 if (pcim_add_mapping_to_legacy_table(pdev, mapping, bar) != 0) in pcim_iomap()
723 * pcim_iomap_region - Request and iomap a PCI BAR
725 * @bar: Index of a BAR to map
733 void __iomem *pcim_iomap_region(struct pci_dev *pdev, int bar, in pcim_iomap_region() argument
744 res->bar = bar; in pcim_iomap_region()
746 ret = __pcim_request_region(pdev, bar, name, 0); in pcim_iomap_region()
750 res->baseaddr = pci_iomap(pdev, bar, 0); in pcim_iomap_region()
760 __pcim_release_region(pdev, bar); in pcim_iomap_region()
769 * pcim_iounmap_region - Unmap and release a PCI BAR
771 * @bar: Index of BAR to unmap and release
773 * Unmap a BAR and release its region manually. Only pass BARs that were
776 static void pcim_iounmap_region(struct pci_dev *pdev, int bar) in pcim_iounmap_region() argument
782 res_searched.bar = bar; in pcim_iounmap_region()
804 int bar; in pcim_iomap_regions() local
807 for (bar = 0; bar < DEVICE_COUNT_RESOURCE; bar++) { in pcim_iomap_regions()
808 if (!mask_contains_bar(mask, bar)) in pcim_iomap_regions()
811 mapping = pcim_iomap_region(pdev, bar, name); in pcim_iomap_regions()
816 ret = pcim_add_mapping_to_legacy_table(pdev, mapping, bar); in pcim_iomap_regions()
824 while (--bar >= 0) { in pcim_iomap_regions()
825 pcim_iounmap_region(pdev, bar); in pcim_iomap_regions()
826 pcim_remove_bar_from_legacy_table(pdev, bar); in pcim_iomap_regions()
833 static int _pcim_request_region(struct pci_dev *pdev, int bar, const char *name, in _pcim_request_region() argument
843 res->bar = bar; in _pcim_request_region()
845 ret = __pcim_request_region(pdev, bar, name, request_flags); in _pcim_request_region()
856 * pcim_request_region - Request a PCI BAR
858 * @bar: Index of BAR to request
863 * Request region specified by @bar.
868 int pcim_request_region(struct pci_dev *pdev, int bar, const char *name) in pcim_request_region() argument
870 return _pcim_request_region(pdev, bar, name, 0); in pcim_request_region()
875 * pcim_request_region_exclusive - Request a PCI BAR exclusively
877 * @bar: Index of BAR to request
882 * Request region specified by @bar exclusively.
887 int pcim_request_region_exclusive(struct pci_dev *pdev, int bar, const char *name) in pcim_request_region_exclusive() argument
889 return _pcim_request_region(pdev, bar, name, IORESOURCE_EXCLUSIVE); in pcim_request_region_exclusive()
893 * pcim_release_region - Release a PCI BAR
895 * @bar: Index of BAR to release
900 void pcim_release_region(struct pci_dev *pdev, int bar) in pcim_release_region() argument
906 res_searched.bar = bar; in pcim_release_region()
925 int bar; in pcim_release_all_regions() local
927 for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) in pcim_release_all_regions()
928 pcim_release_region(pdev, bar); in pcim_release_all_regions()
945 int bar; in pcim_request_all_regions() local
947 for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { in pcim_request_all_regions()
948 ret = pcim_request_region(pdev, bar, name); in pcim_request_all_regions()
982 int bar; in pcim_iomap_regions_request_all() local
990 for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { in pcim_iomap_regions_request_all()
991 if (!mask_contains_bar(mask, bar)) in pcim_iomap_regions_request_all()
993 if (!pcim_iomap(pdev, bar, 0)) in pcim_iomap_regions_request_all()
1001 * If bar is larger than 0, then pcim_iomap() above has most likely in pcim_iomap_regions_request_all()
1005 ret = bar > 0 ? -EINVAL : -ENOMEM; in pcim_iomap_regions_request_all()
1008 while (--bar >= 0) in pcim_iomap_regions_request_all()
1009 pcim_iounmap(pdev, legacy_iomap_table[bar]); in pcim_iomap_regions_request_all()
1039 * pcim_iomap_range - Create a ranged __iomap mapping within a PCI BAR
1041 * @bar: Index of the BAR
1042 * @offset: Offset from the begin of the BAR
1047 * Creates a new IO-Mapping within the specified @bar, ranging from @offset to
1053 void __iomem *pcim_iomap_range(struct pci_dev *pdev, int bar, in pcim_iomap_range() argument
1063 mapping = pci_iomap_range(pdev, bar, offset, len); in pcim_iomap_range()