Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-kernel-drivers: Commit

external/kernel-drivers


Commit MetaInfo

Revision6dd72a7721b451d37c5af22eb5a5808dc856a18d (tree)
Time2022-04-18 03:50:24
AuthorMauro Rossi <issor.oruam@gmai...>
CommiterMauro Rossi

Log Message

rtl8821ce: fix build with kernel 5.18

Changes due to kernel 5.18 commit
7968778914e ('PCI: Remove the deprecated "pci-dma-compat.h" API')

Change Summary

Incremental Difference

--- a/rtl8821ce/hal/rtl8821c/pci/rtl8821ce_halmac.c
+++ b/rtl8821ce/hal/rtl8821c/pci/rtl8821ce_halmac.c
@@ -44,8 +44,13 @@ static u8 pci_write_port_not_xmitframe(void *d, u32 size, u8 *pBuf, u8 qsel)
4444 rtw_hal_get_def_var(padapter, HAL_DEF_TX_PAGE_SIZE, &page_size);
4545
4646 /* map TX DESC buf_addr (including TX DESC + tx data) */
47+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
48+ mapping = dma_map_single(&pdev->dev, pBuf,
49+ size+TX_WIFI_INFO_SIZE, DMA_TO_DEVICE);
50+#else
4751 mapping = pci_map_single(pdev, pBuf,
4852 size+TX_WIFI_INFO_SIZE, PCI_DMA_TODEVICE);
53+#endif
4954
5055
5156 /* Calculate page size.
@@ -57,12 +62,22 @@ static u8 pci_write_port_not_xmitframe(void *d, u32 size, u8 *pBuf, u8 qsel)
5762 if (((size + TX_WIFI_INFO_SIZE) % page_size) > 0)
5863 page_size_length++;
5964
65+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
66+ txbd = dma_alloc_coherent(&pdev->dev,
67+ sizeof(struct tx_buf_desc), &txbd_dma, GFP_KERNEL);
68+#else
6069 txbd = pci_alloc_consistent(pdev,
6170 sizeof(struct tx_buf_desc), &txbd_dma);
71+#endif
6272
6373 if (!txbd) {
74+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
75+ dma_unmap_single(&pdev->dev, mapping,
76+ size + TX_WIFI_INFO_SIZE, DMA_FROM_DEVICE);
77+#else
6478 pci_unmap_single(pdev, mapping,
6579 size + TX_WIFI_INFO_SIZE, PCI_DMA_FROMDEVICE);
80+#endif
6681
6782 return _FALSE;
6883 }
@@ -136,10 +151,17 @@ static u8 pci_write_port_not_xmitframe(void *d, u32 size, u8 *pBuf, u8 qsel)
136151
137152 udelay(100);
138153
154+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
155+ dma_free_coherent(&pdev->dev, sizeof(struct tx_buf_desc), txbd, txbd_dma);
156+
157+ dma_unmap_single(&pdev->dev, mapping,
158+ size + TX_WIFI_INFO_SIZE, DMA_FROM_DEVICE);
159+#else
139160 pci_free_consistent(pdev, sizeof(struct tx_buf_desc), txbd, txbd_dma);
140161
141162 pci_unmap_single(pdev, mapping,
142163 size + TX_WIFI_INFO_SIZE, PCI_DMA_FROMDEVICE);
164+#endif
143165
144166 return ret;
145167
@@ -271,7 +293,11 @@ static u8 pci_write_data_rsvd_page_xmitframe(void *d, u8 *pBuf, u32 size)
271293
272294 /*To patch*/
273295
296+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
297+ dma_unmap_single(&pdev->dev, mapping, pxmitbuf->len, DMA_TO_DEVICE);
298+#else
274299 pci_unmap_single(pdev, mapping, pxmitbuf->len, PCI_DMA_TODEVICE);
300+#endif
275301
276302 return _TRUE;
277303 }
--- a/rtl8821ce/hal/rtl8821c/pci/rtl8821ce_ops.c
+++ b/rtl8821ce/hal/rtl8821c/pci/rtl8821ce_ops.c
@@ -86,9 +86,17 @@ static void rtl8821ce_reset_bd(_adapter *padapter)
8686 #ifdef CONFIG_64BIT_DMA
8787 mapping |= (dma_addr_t)GET_TX_BD_PHYSICAL_ADDR0_HIGH(tx_bd) << 32;
8888 #endif
89+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
90+ dma_unmap_single(&pdvobjpriv->ppcidev->dev,
91+#else
8992 pci_unmap_single(pdvobjpriv->ppcidev,
93+#endif
9094 mapping,
95+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
96+ pxmitbuf->len, DMA_TO_DEVICE);
97+#else
9198 pxmitbuf->len, PCI_DMA_TODEVICE);
99+#endif
92100 rtw_free_xmitbuf(t_priv, pxmitbuf);
93101 } else {
94102 RTW_INFO("%s(): qlen(%d) is not zero, but have xmitbuf in pending queue\n",
--- a/rtl8821ce/hal/rtl8821c/pci/rtl8821ce_recv.c
+++ b/rtl8821ce/hal/rtl8821c/pci/rtl8821ce_recv.c
@@ -208,10 +208,18 @@ static void rtl8821ce_rx_mpdu(_adapter *padapter)
208208 _rtw_init_listhead(&precvframe->u.hdr.list);
209209 precvframe->u.hdr.len = 0;
210210
211+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
212+ dma_unmap_single(&pdvobjpriv->ppcidev->dev,
213+#else
211214 pci_unmap_single(pdvobjpriv->ppcidev,
215+#endif
212216 *((dma_addr_t *)skb->cb),
213217 r_priv->rxbuffersize,
218+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
219+ DMA_FROM_DEVICE);
220+#else
214221 PCI_DMA_FROMDEVICE);
222+#endif
215223
216224 rtl8821c_query_rx_desc(precvframe, skb->data);
217225 pattrib = &precvframe->u.hdr.attrib;
@@ -244,10 +252,18 @@ static void rtl8821ce_rx_mpdu(_adapter *padapter)
244252
245253 RTW_INFO("rtl8821ce_rx_mpdu:can't allocate memory for skb copy\n");
246254 *((dma_addr_t *) skb->cb) =
255+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
256+ dma_map_single(&pdvobjpriv->ppcidev->dev,
257+#else
247258 pci_map_single(pdvobjpriv->ppcidev,
259+#endif
248260 skb_tail_pointer(skb),
249261 r_priv->rxbuffersize,
262+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
263+ DMA_FROM_DEVICE);
264+#else
250265 PCI_DMA_FROMDEVICE);
266+#endif
251267 goto done;
252268 }
253269
@@ -264,10 +280,18 @@ static void rtl8821ce_rx_mpdu(_adapter *padapter)
264280 rtw_free_recvframe(precvframe, pfree_recv_queue);
265281 }
266282 *((dma_addr_t *) skb->cb) =
283+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
284+ dma_map_single(&pdvobjpriv->ppcidev->dev,
285+#else
267286 pci_map_single(pdvobjpriv->ppcidev,
287+#endif
268288 skb_tail_pointer(skb),
269289 r_priv->rxbuffersize,
290+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
291+ DMA_FROM_DEVICE);
292+#else
270293 PCI_DMA_FROMDEVICE);
294+#endif
271295 }
272296 done:
273297
@@ -369,10 +393,18 @@ int rtl8821ce_init_rxbd_ring(_adapter *padapter)
369393 /* rx_queue_idx 1:RX_CMD_QUEUE */
370394 for (rx_queue_idx = 0; rx_queue_idx < 1; rx_queue_idx++) {
371395 r_priv->rx_ring[rx_queue_idx].buf_desc =
396+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
397+ dma_alloc_coherent(&pdev->dev,
398+ sizeof(*r_priv->rx_ring[rx_queue_idx].buf_desc) *
399+ r_priv->rxringcount,
400+ &r_priv->rx_ring[rx_queue_idx].dma, GFP_KERNEL);
401+#else
372402 pci_alloc_consistent(pdev,
373403 sizeof(*r_priv->rx_ring[rx_queue_idx].buf_desc) *
374404 r_priv->rxringcount,
375405 &r_priv->rx_ring[rx_queue_idx].dma);
406+#endif
407+
376408
377409 if (!r_priv->rx_ring[rx_queue_idx].buf_desc ||
378410 (unsigned long)r_priv->rx_ring[rx_queue_idx].buf_desc &
@@ -401,9 +433,17 @@ int rtl8821ce_init_rxbd_ring(_adapter *padapter)
401433 /* just set skb->cb to mapping addr
402434 * for pci_unmap_single use
403435 */
436+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
437+ *mapping = dma_map_single(&pdev->dev, skb_tail_pointer(skb),
438+#else
404439 *mapping = pci_map_single(pdev, skb_tail_pointer(skb),
440+#endif
405441 r_priv->rxbuffersize,
442+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
443+ DMA_FROM_DEVICE);
444+#else
406445 PCI_DMA_FROMDEVICE);
446+#endif
407447
408448 /* Reset FS, LS, Total len */
409449 SET_RX_BD_LS(rx_desc, 0);
@@ -445,14 +485,26 @@ void rtl8821ce_free_rxbd_ring(_adapter *padapter)
445485 if (!skb)
446486 continue;
447487
488+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
489+ dma_unmap_single(&pdev->dev,
490+#else
448491 pci_unmap_single(pdev,
492+#endif
449493 *((dma_addr_t *) skb->cb),
450494 r_priv->rxbuffersize,
495+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
496+ DMA_FROM_DEVICE);
497+#else
451498 PCI_DMA_FROMDEVICE);
499+#endif
452500 kfree_skb(skb);
453501 }
454502
503+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
504+ dma_free_coherent(&pdev->dev,
505+#else
455506 pci_free_consistent(pdev,
507+#endif
456508 sizeof(*r_priv->rx_ring[rx_queue_idx].buf_desc) *
457509 r_priv->rxringcount,
458510 r_priv->rx_ring[rx_queue_idx].buf_desc,
--- a/rtl8821ce/hal/rtl8821c/pci/rtl8821ce_xmit.c
+++ b/rtl8821ce/hal/rtl8821c/pci/rtl8821ce_xmit.c
@@ -293,8 +293,13 @@ static void rtl8821ce_update_txbd(struct xmit_frame *pxmitframe,
293293 u16 page_size_length = 0;
294294
295295 /* map TX DESC buf_addr (including TX DESC + tx data) */
296+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
297+ mapping = dma_map_single(&pdvobjpriv->ppcidev->dev, pxmitframe->buf_addr,
298+ sz + TX_WIFI_INFO_SIZE, DMA_TO_DEVICE);
299+#else
296300 mapping = pci_map_single(pdvobjpriv->ppcidev, pxmitframe->buf_addr,
297301 sz + TX_WIFI_INFO_SIZE, PCI_DMA_TODEVICE);
302+#endif
298303
299304 /* Calculate page size.
300305 * Total buffer length including TX_WIFI_INFO and PacketLen
@@ -1248,7 +1253,11 @@ int rtl8821ce_init_txbd_ring(_adapter *padapter, unsigned int q_idx,
12481253
12491254 RTW_INFO("%s entries num:%d\n", __func__, entries);
12501255
1256+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1257+ txbd = dma_alloc_coherent(&pdev->dev, sizeof(*txbd) * entries, &dma, GFP_KERNEL);
1258+#else
12511259 txbd = pci_alloc_consistent(pdev, sizeof(*txbd) * entries, &dma);
1260+#endif
12521261
12531262 if (!txbd || (unsigned long)txbd & 0xFF) {
12541263 RTW_INFO("Cannot allocate TXBD (q_idx = %d)\n", q_idx);
@@ -1294,9 +1303,17 @@ void rtl8821ce_free_txbd_ring(_adapter *padapter, unsigned int prio)
12941303 #ifdef CONFIG_64BIT_DMA
12951304 mapping |= (dma_addr_t)GET_TX_BD_PHYSICAL_ADDR0_HIGH(txbd) << 32;
12961305 #endif
1306+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1307+ dma_unmap_single(&pdev->dev,
1308+#else
12971309 pci_unmap_single(pdev,
1310+#endif
12981311 mapping,
1312+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1313+ pxmitbuf->len, DMA_TO_DEVICE);
1314+#else
12991315 pxmitbuf->len, PCI_DMA_TODEVICE);
1316+#endif
13001317
13011318 rtw_free_xmitbuf(t_priv, pxmitbuf);
13021319
@@ -1307,7 +1324,11 @@ void rtl8821ce_free_txbd_ring(_adapter *padapter, unsigned int prio)
13071324 }
13081325 }
13091326
1327+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1328+ dma_free_coherent(&pdev->dev, sizeof(*ring->buf_desc) * ring->entries,
1329+#else
13101330 pci_free_consistent(pdev, sizeof(*ring->buf_desc) * ring->entries,
1331+#endif
13111332 ring->buf_desc, ring->dma);
13121333 ring->buf_desc = NULL;
13131334
@@ -1442,9 +1463,17 @@ void rtl8821ce_tx_isr(PADAPTER Adapter, int prio)
14421463 #ifdef CONFIG_64BIT_DMA
14431464 mapping |= (dma_addr_t)GET_TX_BD_PHYSICAL_ADDR0_HIGH(tx_desc) << 32;
14441465 #endif
1466+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1467+ dma_unmap_single(&pdvobjpriv->ppcidev->dev,
1468+#else
14451469 pci_unmap_single(pdvobjpriv->ppcidev,
1470+#endif
14461471 mapping,
1472+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1473+ pxmitbuf->len, DMA_TO_DEVICE);
1474+#else
14471475 pxmitbuf->len, PCI_DMA_TODEVICE);
1476+#endif
14481477 rtw_sctx_done(&pxmitbuf->sctx);
14491478 rtw_free_xmitbuf(&(pxmitbuf->padapter->xmitpriv),
14501479 pxmitbuf);
@@ -1519,9 +1548,18 @@ void rtl8821ce_tx_isr(PADAPTER Adapter, int prio)
15191548 #ifdef CONFIG_64BIT_DMA
15201549 mapping |= (dma_addr_t)GET_TX_BD_PHYSICAL_ADDR0_HIGH(tx_desc) << 32;
15211550 #endif
1551+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1552+ dma_unmap_single(&pdvobjpriv->ppcidev->dev,
1553+#else
15221554 pci_unmap_single(pdvobjpriv->ppcidev,
1555+#endif
15231556 mapping,
1557+
1558+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1559+ pxmitbuf->len, DMA_TO_DEVICE);
1560+#else
15241561 pxmitbuf->len, PCI_DMA_TODEVICE);
1562+#endif
15251563 rtw_sctx_done(&pxmitbuf->sctx);
15261564 rtw_free_xmitbuf(&(pxmitbuf->padapter->xmitpriv),
15271565 pxmitbuf);
--- a/rtl8821ce/os_dep/linux/pci_intf.c
+++ b/rtl8821ce/os_dep/linux/pci_intf.c
@@ -1195,9 +1195,17 @@ static struct dvobj_priv *pci_dvobj_init(struct pci_dev *pdev, const struct pci_
11951195 }
11961196
11971197 #ifdef CONFIG_64BIT_DMA
1198+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1199+ if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
1200+#else
11981201 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
1202+#endif
11991203 RTW_INFO("RTL819xCE: Using 64bit DMA\n");
1204+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1205+ err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
1206+#else
12001207 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
1208+#endif
12011209 if (err != 0) {
12021210 RTW_ERR("Unable to obtain 64bit DMA for consistent allocations\n");
12031211 goto disable_picdev;
@@ -1206,8 +1214,13 @@ static struct dvobj_priv *pci_dvobj_init(struct pci_dev *pdev, const struct pci_
12061214 } else
12071215 #endif
12081216 {
1217+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
1218+ if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
1219+ err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
1220+#else
12091221 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
12101222 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
1223+#endif
12111224 if (err != 0) {
12121225 RTW_ERR("Unable to obtain 32bit DMA for consistent allocations\n");
12131226 goto disable_picdev;
--- a/rtl8821ce/os_dep/osdep_service.c
+++ b/rtl8821ce/os_dep/osdep_service.c
@@ -2202,7 +2202,9 @@ static int isFileReadable(const char *path, u32 *sz)
22022202 {
22032203 struct file *fp;
22042204 int ret = 0;
2205+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
22052206 mm_segment_t oldfs;
2207+#endif
22062208 char buf;
22072209
22082210 fp = filp_open(path, O_RDONLY, 0);
@@ -2213,8 +2215,10 @@ static int isFileReadable(const char *path, u32 *sz)
22132215 oldfs = get_fs();
22142216 set_fs(KERNEL_DS);
22152217 #else
2218+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
22162219 oldfs = force_uaccess_begin();;
22172220 #endif
2221+ #endif
22182222
22192223 if (1 != readFile(fp, &buf, 1))
22202224 ret = PTR_ERR(fp);
@@ -2230,8 +2234,10 @@ static int isFileReadable(const char *path, u32 *sz)
22302234 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
22312235 set_fs(oldfs);
22322236 #else
2237+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
22332238 force_uaccess_end(oldfs);
22342239 #endif
2240+#endif
22352241 filp_close(fp, NULL);
22362242 }
22372243 return ret;
@@ -2247,7 +2253,9 @@ static int isFileReadable(const char *path, u32 *sz)
22472253 static int retriveFromFile(const char *path, u8 *buf, u32 sz)
22482254 {
22492255 int ret = -1;
2256+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
22502257 mm_segment_t oldfs;
2258+#endif
22512259 struct file *fp;
22522260
22532261 if (path && buf) {
@@ -2259,14 +2267,18 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
22592267 oldfs = get_fs();
22602268 set_fs(KERNEL_DS);
22612269 #else
2270+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
22622271 oldfs = force_uaccess_begin();
22632272 #endif
2273+ #endif
22642274 ret = readFile(fp, buf, sz);
22652275 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
22662276 set_fs(oldfs);
22672277 #else
2278+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
22682279 force_uaccess_end(oldfs);
22692280 #endif
2281+ #endif
22702282 closeFile(fp);
22712283
22722284 RTW_INFO("%s readFile, ret:%d\n", __FUNCTION__, ret);
@@ -2290,7 +2302,9 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
22902302 static int storeToFile(const char *path, u8 *buf, u32 sz)
22912303 {
22922304 int ret = 0;
2305+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
22932306 mm_segment_t oldfs;
2307+#endif
22942308 struct file *fp;
22952309
22962310 if (path && buf) {
@@ -2302,14 +2316,18 @@ static int storeToFile(const char *path, u8 *buf, u32 sz)
23022316 oldfs = get_fs();
23032317 set_fs(KERNEL_DS);
23042318 #else
2319+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
23052320 oldfs = force_uaccess_begin();
23062321 #endif
2322+ #endif
23072323 ret = writeFile(fp, buf, sz);
23082324 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
23092325 set_fs(oldfs);
23102326 #else
2327+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
23112328 force_uaccess_end(oldfs);
23122329 #endif
2330+ #endif
23132331 closeFile(fp);
23142332
23152333 RTW_INFO("%s writeFile, ret:%d\n", __FUNCTION__, ret);
Show on old repository browser