Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: endpoint: Clear BAR before freeing its space

Associated pci_epf_bar structure is needed in pci_epc_clear_bar() to
clear a BAR correctly but it is reset in pci_epf_free_space() (that
is called first) which results in pci_epc_clear_bar() failure.

Reorder the pci_epc_clear_bar()/pci_epf_free_space() calls execution
to fix the issue.

Signed-off-by: Alan Mikhak <alan.mikhak@sifive.com>
[lorenzo.pieralisi@arm.com: reworded the commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Alan Mikhak and committed by
Lorenzo Pieralisi
dbb7bbcc 3041a643

+1 -1
+1 -1
drivers/pci/endpoint/functions/pci-epf-test.c
··· 381 381 epf_bar = &epf->bar[bar]; 382 382 383 383 if (epf_test->reg[bar]) { 384 - pci_epf_free_space(epf, epf_test->reg[bar], bar); 385 384 pci_epc_clear_bar(epc, epf->func_no, epf_bar); 385 + pci_epf_free_space(epf, epf_test->reg[bar], bar); 386 386 } 387 387 } 388 388 }