PCI: endpoint: Improve pci_epc_mem_alloc_addr()
authorDamien Le Moal <dlemoal@kernel.org>
Sat, 12 Oct 2024 11:32:42 +0000 (20:32 +0900)
committerManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Sat, 12 Oct 2024 11:55:54 +0000 (17:25 +0530)
commit2314c6ffe8113ac3c22c8112fa9623e30eec6c4a
treeaa7d7d7f26dd4b31407d58e34810c458427273bf
parentca3c342fb3c76eee739a1cfc4ff59841722ebee7
PCI: endpoint: Improve pci_epc_mem_alloc_addr()

There is no point in attempting to allocate memory from an endpoint
controller memory window if the requested size is larger than the memory
window size. Add a check to skip bitmap_find_free_region() calls for
such case. This check can be done without the mem->lock mutex held as
memory window sizes are constant and never modified at runtime.
Also change the final return to return NULL to simplify the code.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20241012113246.95634-3-dlemoal@kernel.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
drivers/pci/endpoint/pci-epc-mem.c