PCI: endpoint: Clear BAR before freeing its space
authorAlan Mikhak <alan.mikhak@sifive.com>
Thu, 23 May 2019 21:57:27 +0000 (14:57 -0700)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tue, 11 Jun 2019 09:57:54 +0000 (10:57 +0100)
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>
drivers/pci/endpoint/functions/pci-epf-test.c

index e8bcc924dbf8f252b696b7cac94b8d2a4f90a466..1cfe3687a21191c799acf1686df0372317c56e7b 100644 (file)
@@ -381,8 +381,8 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
                epf_bar = &epf->bar[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_epf_free_space(epf, epf_test->reg[bar], bar);
                }
        }
 }