Revert "PCI: endpoint: Retain fixed-size BAR size as well as aligned size"

This reverts commit 0a3e2ec508 which is
commit 793908d60b8745c386b9f4e29eb702f74ceb0886 upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.

Bug: 161946584
Change-Id: I755ab2605f391a43d42d845a72cb5e3eff0ecd6c
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2025-07-09 09:55:30 +00:00
parent 036a0d8df2
commit a0b4b5586d
2 changed files with 7 additions and 18 deletions

View File

@@ -236,13 +236,12 @@ void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar,
}
dev = epc->dev.parent;
dma_free_coherent(dev, epf_bar[bar].aligned_size, addr,
dma_free_coherent(dev, epf_bar[bar].size, addr,
epf_bar[bar].phys_addr);
epf_bar[bar].phys_addr = 0;
epf_bar[bar].addr = NULL;
epf_bar[bar].size = 0;
epf_bar[bar].aligned_size = 0;
epf_bar[bar].barno = 0;
epf_bar[bar].flags = 0;
}
@@ -265,7 +264,7 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar,
enum pci_epc_interface_type type)
{
u64 bar_fixed_size = epc_features->bar[bar].fixed_size;
size_t aligned_size, align = epc_features->align;
size_t align = epc_features->align;
struct pci_epf_bar *epf_bar;
dma_addr_t phys_addr;
struct pci_epc *epc;
@@ -282,18 +281,12 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar,
return NULL;
}
size = bar_fixed_size;
} else {
/* BAR size must be power of two */
size = roundup_pow_of_two(size);
}
/*
* Allocate enough memory to accommodate the iATU alignment
* requirement. In most cases, this will be the same as .size but
* it might be different if, for example, the fixed size of a BAR
* is smaller than align.
*/
aligned_size = align ? ALIGN(size, align) : size;
if (align)
size = ALIGN(size, align);
else
size = roundup_pow_of_two(size);
if (type == PRIMARY_INTERFACE) {
epc = epf->epc;
@@ -304,7 +297,7 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar,
}
dev = epc->dev.parent;
space = dma_alloc_coherent(dev, aligned_size, &phys_addr, GFP_KERNEL);
space = dma_alloc_coherent(dev, size, &phys_addr, GFP_KERNEL);
if (!space) {
dev_err(dev, "failed to allocate mem space\n");
return NULL;
@@ -313,7 +306,6 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar,
epf_bar[bar].phys_addr = phys_addr;
epf_bar[bar].addr = space;
epf_bar[bar].size = size;
epf_bar[bar].aligned_size = aligned_size;
epf_bar[bar].barno = bar;
if (upper_32_bits(size) || epc_features->bar[bar].only_64bit)
epf_bar[bar].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64;

View File

@@ -114,8 +114,6 @@ struct pci_epf_driver {
* @phys_addr: physical address that should be mapped to the BAR
* @addr: virtual address corresponding to the @phys_addr
* @size: the size of the address space present in BAR
* @aligned_size: the size actually allocated to accommodate the iATU alignment
* requirement
* @barno: BAR number
* @flags: flags that are set for the BAR
*/
@@ -123,7 +121,6 @@ struct pci_epf_bar {
dma_addr_t phys_addr;
void *addr;
size_t size;
size_t aligned_size;
enum pci_barno barno;
int flags;
};