PCI: endpoint: pci-epf-test: Fix check for DMA MEMCPY test
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Thu, 16 Jan 2025 17:16:47 +0000 (22:46 +0530)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 21 Jan 2025 15:44:13 +0000 (09:44 -0600)
Currently, if DMA MEMCPY test is requested by the host, and if the endpoint
DMA controller supports DMA_PRIVATE, the test will fail. This is not
correct since there is no check for DMA_MEMCPY capability and the DMA
controller can support both DMA_PRIVATE and DMA_MEMCPY.

Fix the check and also reword the error message.

Link: https://lore.kernel.org/r/20250116171650.33585-2-manivannan.sadhasivam@linaro.org
Fixes: 8353813c88ef ("PCI: endpoint: Enable DMA tests for endpoints with DMA capabilities")
Reported-by: Niklas Cassel <cassel@kernel.org>
Closes: https://lore.kernel.org/linux-pci/Z3QtEihbiKIGogWA@ryzen
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
drivers/pci/endpoint/functions/pci-epf-test.c

index d90c8be7371e04df9bd8fb6db0feb322cda04dff..b2fdd8c82c438700a3418b7fd4ef0fc1f892d49c 100644 (file)
@@ -328,8 +328,8 @@ static void pci_epf_test_copy(struct pci_epf_test *epf_test,
        void *copy_buf = NULL, *buf;
 
        if (reg->flags & FLAG_USE_DMA) {
-               if (epf_test->dma_private) {
-                       dev_err(dev, "Cannot transfer data using DMA\n");
+               if (!dma_has_cap(DMA_MEMCPY, epf_test->dma_chan_tx->device->cap_mask)) {
+                       dev_err(dev, "DMA controller doesn't support MEMCPY\n");
                        ret = -EINVAL;
                        goto set_status;
                }