pci-epc-mem uses a bitmap to manage the Endpoint outbound (OB) address region. This address region will be shared by multiple endpoint functions (in the case of multi function endpoint) and it has to be protected from concurrent access to avoid updating an inconsistent state. Use a mutex to protect bitmap updates to prevent the memory allocation API from returning incorrect addresses.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -71,6 +71,7 @@ struct pci_epc_ops { · 70 unmodified lines | ||
| 71 | 71 | * @bitmap: bitmap to manage the PCI address space |
| 72 | 72 | * @pages: number of bits representing the address region |
| 73 | 73 | * @page_size: size of each page |
| 74 | + * @lock: mutex to protect bitmap | |
| 74 | 75 | */ |
| 75 | 76 | struct pci_epc_mem { |
| 76 | 77 | phys_addr_t phys_base; |
| @@ -78,6 +79,8 @@ struct pci_epc_mem { · 1 unmodified line | ||
| 78 | 79 | unsigned long *bitmap; |
| 79 | 80 | size_t page_size; |
| 80 | 81 | int pages; |
| 82 | + /* mutex to protect against concurrent access for memory allocation*/ | |
| 83 | + struct mutex lock; | |
| 81 | 84 | }; |
| 82 | 85 | |
| 83 | 86 | /** |