Skip to content

Commit 60bd3e0

Browse files
Mani-Sadhasivambjorn-helgaas
authored andcommitted
PCI: endpoint: pci-epf-{mhi/test}: Move DMA initialization to EPC init callback
To maintain uniformity across EPF drivers, move DMA initialization to EPC init callback. This will also allow us to deinit DMA during PERST# assert in the further commits. For EPC drivers without PERST#, DMA deinit will only happen during driver unbind. Link: https://lore.kernel.org/linux-pci/[email protected] Tested-by: Niklas Cassel <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Niklas Cassel <[email protected]>
1 parent 942ceba commit 60bd3e0

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

drivers/pci/endpoint/functions/pci-epf-mhi.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,14 @@ static int pci_epf_mhi_epc_init(struct pci_epf *epf)
753753
if (!epf_mhi->epc_features)
754754
return -ENODATA;
755755

756+
if (info->flags & MHI_EPF_USE_DMA) {
757+
ret = pci_epf_mhi_dma_init(epf_mhi);
758+
if (ret) {
759+
dev_err(dev, "Failed to initialize DMA: %d\n", ret);
760+
return ret;
761+
}
762+
}
763+
756764
return 0;
757765
}
758766

@@ -765,14 +773,6 @@ static int pci_epf_mhi_link_up(struct pci_epf *epf)
765773
struct device *dev = &epf->dev;
766774
int ret;
767775

768-
if (info->flags & MHI_EPF_USE_DMA) {
769-
ret = pci_epf_mhi_dma_init(epf_mhi);
770-
if (ret) {
771-
dev_err(dev, "Failed to initialize DMA: %d\n", ret);
772-
return ret;
773-
}
774-
}
775-
776776
mhi_cntrl->mmio = epf_mhi->mmio;
777777
mhi_cntrl->irq = epf_mhi->irq;
778778
mhi_cntrl->mru = info->mru;

drivers/pci/endpoint/functions/pci-epf-test.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,12 @@ static int pci_epf_test_epc_init(struct pci_epf *epf)
737737
bool linkup_notifier = false;
738738
int ret;
739739

740+
epf_test->dma_supported = true;
741+
742+
ret = pci_epf_test_init_dma_chan(epf_test);
743+
if (ret)
744+
epf_test->dma_supported = false;
745+
740746
if (epf->vfunc_no <= 1) {
741747
ret = pci_epc_write_header(epc, epf->func_no, epf->vfunc_no, header);
742748
if (ret) {
@@ -883,12 +889,6 @@ static int pci_epf_test_bind(struct pci_epf *epf)
883889
if (ret)
884890
return ret;
885891

886-
epf_test->dma_supported = true;
887-
888-
ret = pci_epf_test_init_dma_chan(epf_test);
889-
if (ret)
890-
epf_test->dma_supported = false;
891-
892892
return 0;
893893
}
894894

0 commit comments

Comments
 (0)