Jelajahi Sumber

Merge pull request #206 from Zaryob/master

Fixed kernel 5.10.0 problems mentioned  in 9fd63b7fe849f5fa8019c897d1642ce4f34bf3f7
Tomás Pinho 4 tahun lalu
induk
melakukan
818ecc836a
5 mengubah file dengan 62 tambahan dan 2 penghapusan
  1. 10 0
      core/rtw_btcoex.c
  2. 5 0
      core/rtw_ieee80211.c
  3. 12 2
      core/rtw_wlan_util.c
  4. 18 0
      os_dep/linux/os_intfs.c
  5. 17 0
      os_dep/osdep_service.c

+ 10 - 0
core/rtw_btcoex.c

@@ -17,6 +17,12 @@
 #ifdef CONFIG_BT_COEXIST
 #include <hal_btcoex.h>
 
+#ifdef PLATFORM_LINUX
+	#ifndef KERNEL_DS
+		#define KERNEL_DS   MAKE_MM_SEG(-1UL)   // <----- 0xffffffffffffffff
+	#endif
+#endif
+
 void rtw_btcoex_Initialize(PADAPTER padapter)
 {
 	hal_btcoex_Initialize(padapter);
@@ -1478,6 +1484,8 @@ u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool for
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	oldfs = get_fs();
 	set_fs(KERNEL_DS);
+#else
+	oldfs = force_uaccess_begin();
 #endif
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
@@ -1487,6 +1495,8 @@ u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool for
 #endif
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	set_fs(oldfs);
+#else
+	force_uaccess_end(oldfs);
 #endif
 	if (error < 0) {
 		RTW_INFO("Error when sendimg msg, error:%d\n", error);

+ 5 - 0
core/rtw_ieee80211.c

@@ -19,6 +19,11 @@
 #endif
 #include <drv_types.h>
 
+#ifdef PLATFORM_LINUX
+	#ifndef KERNEL_DS
+		#define KERNEL_DS   MAKE_MM_SEG(-1UL)   // <----- 0xffffffffffffffff
+	#endif
+#endif
 
 u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 };
 u16 RTW_WPA_VERSION = 1;

+ 12 - 2
core/rtw_wlan_util.c

@@ -26,6 +26,12 @@
 	#define IPv6_PROTOCOL_OFFSET	20
 #endif
 
+#ifdef PLATFORM_LINUX
+	#ifndef KERNEL_DS
+		#define KERNEL_DS   MAKE_MM_SEG(-1UL)   // <----- 0xffffffffffffffff
+	#endif
+#endif
+
 unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f};
 unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74};
 
@@ -4751,9 +4757,11 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t *ssid,
 		return 0;
 	}
 
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	fs = get_fs();
 	set_fs(KERNEL_DS);
+#else
+	fs = force_uaccess_begin();
 #endif
 
 	source = rtw_zmalloc(2048);
@@ -4764,8 +4772,10 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t *ssid,
 		rtw_mfree(source, 2048);
 	}
 
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	set_fs(fs);
+#else
+	force_uaccess_end(fs);
 #endif
 	filp_close(fp, NULL);
 

+ 18 - 0
os_dep/linux/os_intfs.c

@@ -23,6 +23,11 @@
 
 #endif
 
+#ifdef PLATFORM_LINUX
+	#ifndef KERNEL_DS
+		#define KERNEL_DS   MAKE_MM_SEG(-1UL)   // <----- 0xffffffffffffffff
+	#endif
+#endif
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Realtek Wireless Lan Driver");
@@ -4011,6 +4016,8 @@ static int route_dump(u32 *gw_addr , int *gw_index)
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	oldfs = get_fs();
 	set_fs(KERNEL_DS);
+#else
+	oldfs = force_uaccess_begin();
 #endif
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
 	err = sock_sendmsg(sock, &msg);
@@ -4019,6 +4026,8 @@ static int route_dump(u32 *gw_addr , int *gw_index)
 #endif
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	set_fs(oldfs);
+#else
+	force_uaccess_end(oldfs);
 #endif
 
 	if (err < 0)
@@ -4047,6 +4056,8 @@ restart:
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 		oldfs = get_fs();
 		set_fs(KERNEL_DS);
+#else
+		oldfs = force_uaccess_begin();
 #endif
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
 		err = sock_recvmsg(sock, &msg, MSG_DONTWAIT);
@@ -4055,6 +4066,9 @@ restart:
 #endif
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 		set_fs(oldfs);
+#else
+		force_uaccess_end(oldfs);
+
 #endif
 
 		if (err < 0)
@@ -4129,6 +4143,8 @@ done:
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 		oldfs = get_fs();
 		set_fs(KERNEL_DS);
+#else
+		oldfs = force_uaccess_begin();
 #endif
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
 		err = sock_sendmsg(sock, &msg);
@@ -4137,6 +4153,8 @@ done:
 #endif
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 		set_fs(oldfs);
+#else
+		force_uaccess_end(oldfs)
 #endif
 
 		if (err > 0)

+ 17 - 0
os_dep/osdep_service.c

@@ -24,11 +24,16 @@
 #ifdef PLATFORM_LINUX
 atomic_t _malloc_cnt = ATOMIC_INIT(0);
 atomic_t _malloc_size = ATOMIC_INIT(0);
+#ifndef KERNEL_DS
+#define KERNEL_DS   MAKE_MM_SEG(-1UL)   // <----- 0xffffffffffffffff
+#endif
 #endif
 #endif /* DBG_MEMORY_LEAK */
 
 
+
 #if defined(PLATFORM_LINUX)
+
 /*
 * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE
 * @return: one of RTW_STATUS_CODE
@@ -2203,6 +2208,8 @@ static int isFileReadable(const char *path, u32 *sz)
 	#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 		oldfs = get_fs();
 		set_fs(KERNEL_DS);
+	#else
+		oldfs = force_uaccess_begin();;
 	#endif
 
 		if (1 != readFile(fp, &buf, 1))
@@ -2218,6 +2225,8 @@ static int isFileReadable(const char *path, u32 *sz)
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 		set_fs(oldfs);
+#else
+        force_uaccess_end(oldfs);
 #endif
 		filp_close(fp, NULL);
 	}
@@ -2245,10 +2254,14 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
 		#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 			oldfs = get_fs();
 			set_fs(KERNEL_DS);
+		#else
+			oldfs = force_uaccess_begin();
 		#endif
 			ret = readFile(fp, buf, sz);
 		#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 			set_fs(oldfs);
+		#else
+      		force_uaccess_end(oldfs);
 		#endif
 			closeFile(fp);
 
@@ -2284,10 +2297,14 @@ static int storeToFile(const char *path, u8 *buf, u32 sz)
 		#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 			oldfs = get_fs();
 			set_fs(KERNEL_DS);
+		#else
+	   		oldfs = force_uaccess_begin();
 		#endif
 			ret = writeFile(fp, buf, sz);
 		#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 			set_fs(oldfs);
+		#else
+			force_uaccess_end(oldfs);
 		#endif
 			closeFile(fp);