Commit dbb7bbcc authored by Alan Mikhak's avatar Alan Mikhak Committed by Lorenzo Pieralisi
Browse files

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: default avatarAlan Mikhak <alan.mikhak@sifive.com>
[lorenzo.pieralisi@arm.com: reworded the commit log]
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent 3041a643
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -381,8 +381,8 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
		epf_bar = &epf->bar[bar];
		epf_bar = &epf->bar[bar];


		if (epf_test->reg[bar]) {
		if (epf_test->reg[bar]) {
			pci_epf_free_space(epf, epf_test->reg[bar], bar);
			pci_epc_clear_bar(epc, epf->func_no, epf_bar);
			pci_epc_clear_bar(epc, epf->func_no, epf_bar);
			pci_epf_free_space(epf, epf_test->reg[bar], bar);
		}
		}
	}
	}
}
}