Browse Source

cnss2: use dma_set_mask and dma_set_coherent_mask

In kernel 5.18, pci-dma-compat.h is removed and so instead of
calling pci_set_dma_mask and pci_set_consistent_dma_mask, call
dma_set_mask and dma_set_coherent_mask.

Change-Id: I91cbe8700b8f165c1140d015c28b1c34d3ea99bd
CRs-Fixed: 3298228
Rajesh Chauhan 2 years ago
parent
commit
ecb1bc2deb
1 changed files with 27 additions and 3 deletions
  1. 27 3
      cnss2/pci.c

+ 27 - 3
cnss2/pci.c

@@ -4544,6 +4544,30 @@ u32 cnss_pci_get_wake_msi(struct cnss_pci_data *pci_priv)
 	return user_base_data;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
+static inline int cnss_pci_set_dma_mask(struct pci_dev *pci_dev, u64 mask)
+{
+	return dma_set_mask(&pci_dev->dev, mask);
+}
+
+static inline int cnss_pci_set_coherent_dma_mask(struct pci_dev *pci_dev,
+	u64 mask)
+{
+	return dma_set_coherent_mask(&pci_dev->dev, mask);
+}
+#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)) */
+static inline int cnss_pci_set_dma_mask(struct pci_dev *pci_dev, u64 mask)
+{
+	return pci_set_dma_mask(pci_dev, mask);
+}
+
+static inline int cnss_pci_set_coherent_dma_mask(struct pci_dev *pci_dev,
+	u64 mask)
+{
+	return pci_set_consistent_dma_mask(pci_dev, mask);
+}
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)) */
+
 static int cnss_pci_enable_bus(struct cnss_pci_data *pci_priv)
 {
 	int ret = 0;
@@ -4593,15 +4617,15 @@ static int cnss_pci_enable_bus(struct cnss_pci_data *pci_priv)
 
 	cnss_pr_dbg("Set PCI DMA MASK (0x%llx)\n", pci_priv->dma_bit_mask);
 
-	ret = pci_set_dma_mask(pci_dev, pci_priv->dma_bit_mask);
+	ret = cnss_pci_set_dma_mask(pci_dev, pci_priv->dma_bit_mask);
 	if (ret) {
 		cnss_pr_err("Failed to set PCI DMA mask, err = %d\n", ret);
 		goto release_region;
 	}
 
-	ret = pci_set_consistent_dma_mask(pci_dev, pci_priv->dma_bit_mask);
+	ret = cnss_pci_set_coherent_dma_mask(pci_dev, pci_priv->dma_bit_mask);
 	if (ret) {
-		cnss_pr_err("Failed to set PCI consistent DMA mask, err = %d\n",
+		cnss_pr_err("Failed to set PCI coherent DMA mask, err = %d\n",
 			    ret);
 		goto release_region;
 	}