Browse code

linux: rsi: fix overflow kernel panic

Extras:
- .config: enable BT stack, enable GPIO sysfs.
- Add Exar USB serial driver.

Change-Id: I22486606992c432eb74cd9c7e0b3930e2c746e3f
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5507
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Sharath George

Alexey Makhalov authored on 2018/08/18 08:21:49
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,210 @@
0
+From: Siva Rebbagondla <siva.rebbagondla@redpinesignals.com>
1
+Date: Wed, 11 Apr 2018 12:13:31 +0530
2
+Subject: [PATCH 1/2] rsi: fix nommu_map_sg overflow kernel panic
3
+Cc: linux-wireless@vger.kernel.org,
4
+	Amitkumar Karwar <amit.karwar@redpinesignals.com>,
5
+	Siva Rebbagondla <siva.rebbagondla@redpinesignals.com>
6
+
7
+Following overflow kernel panic is observed on some platforms while
8
+loading the driver. It is fixed if dynamically allocated memory is
9
+passed to SDIO instead of static one
10
+
11
+[  927.513963] nommu_map_sg: overflow 17d54064ba7c+20 of device mask ffffffff
12
+[  927.517712] Modules linked in: rsi_sdio(+) cmac bnep arc4 rsi_91x mac80211 cfg80211
13
+	       btrsi rfcomm bluetooth ecdh_generic snd_soc_sst_bytcr_rt5660
14
+[  927.517861] CPU: 0 PID: 1624 Comm: insmod Tainted: G W 4.15.0-1000 #1
15
+[  927.517870] RIP: 0010:sdhci_send_command+0x5f0/0xa90 [sdhci]
16
+[  927.517873] RSP: 0000:ffffac3fc064b6d8 EFLAGS: 00010086
17
+[  927.517895] Call Trace:
18
+[  927.517908]  ? __schedule+0x3cd/0x890
19
+[  927.517915]  ? mod_timer+0x17b/0x3c0
20
+[  927.517922]  sdhci_request+0x7c/0xf0 [sdhci]
21
+[  927.517928]  __mmc_start_request+0x5a/0x170
22
+[  927.517932]  mmc_start_request+0x74/0x90
23
+[  927.517936]  mmc_wait_for_req+0x87/0xe0
24
+[  927.517940]  mmc_io_rw_extended+0x2fd/0x330
25
+[  927.517946]  ? mmc_wait_data_done+0x30/0x30
26
+[  927.517951]  sdio_io_rw_ext_helper+0x160/0x210
27
+[  927.517956]  sdio_writesb+0x1d/0x20
28
+[  927.517966]	rsi_sdio_write_register_multiple+0x68/0x110 [rsi_sdio]
29
+[  927.517976]  rsi_hal_device_init+0x357/0x910 [rsi_91x]
30
+[  927.517983]  ? rsi_hal_device_init+0x357/0x910 [rsi_91x]
31
+[  927.517990]  rsi_probe+0x2c6/0x450 [rsi_sdio]
32
+[  927.517995]  sdio_bus_probe+0xfc/0x110
33
+[  927.518000]  driver_probe_device+0x2b3/0x490
34
+[  927.518005]  __driver_attach+0xdf/0xf0
35
+[  927.518008]  ? driver_probe_device+0x490/0x490
36
+[  927.518014]  bus_for_each_dev+0x6c/0xc0
37
+[  927.518018]  driver_attach+0x1e/0x20
38
+[  927.518021]  bus_add_driver+0x1f4/0x270
39
+[  927.518028]  ? rsi_sdio_ack_intr+0x50/0x50 [rsi_sdio]
40
+[  927.518031]  driver_register+0x60/0xe0
41
+[  927.518038]  ? rsi_sdio_ack_intr+0x50/0x50 [rsi_sdio]
42
+[  927.518041]  sdio_register_driver+0x20/0x30
43
+[  927.518047]  rsi_module_init+0x16/0x40 [rsi_sdio]
44
+
45
+Signed-off-by: Siva Rebbagondla <siva.rebbagondla@redpinesignals.com>
46
+Signed-off-by: Amitkumar Karwar <amit.karwar@redpinesignals.com>
47
+---
48
+ drivers/net/wireless/rsi/rsi_91x_hal.c  | 35 ++++++++++++++++++++-------------
49
+ drivers/net/wireless/rsi/rsi_91x_sdio.c | 21 +++++++++++++-------
50
+ drivers/net/wireless/rsi/rsi_sdio.h     |  2 +-
51
+ 3 files changed, 36 insertions(+), 22 deletions(-)
52
+
53
+diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c b/drivers/net/wireless/rsi/rsi_91x_hal.c
54
+index b7c5403..0761e61 100644
55
+--- a/drivers/net/wireless/rsi/rsi_91x_hal.c
56
+@@ -635,28 +635,32 @@ static int bl_write_header(struct rsi_hw *adapter, u8 *flash_content,
57
+ 			   u32 content_size)
58
+ {
59
+ 	struct rsi_host_intf_ops *hif_ops = adapter->host_intf_ops;
60
+-	struct bl_header bl_hdr;
61
++	struct bl_header *bl_hdr;
62
+ 	u32 write_addr, write_len;
63
+ 	int status;
64
+ 
65
+-	bl_hdr.flags = 0;
66
+-	bl_hdr.image_no = cpu_to_le32(adapter->priv->coex_mode);
67
+-	bl_hdr.check_sum = cpu_to_le32(
68
+-				*(u32 *)&flash_content[CHECK_SUM_OFFSET]);
69
+-	bl_hdr.flash_start_address = cpu_to_le32(
70
+-					*(u32 *)&flash_content[ADDR_OFFSET]);
71
+-	bl_hdr.flash_len = cpu_to_le32(*(u32 *)&flash_content[LEN_OFFSET]);
72
++	bl_hdr = kzalloc(sizeof(*bl_hdr), GFP_KERNEL);
73
++	if (!bl_hdr)
74
++		return -ENOMEM;
75
++
76
++	bl_hdr->flags = 0;
77
++	bl_hdr->image_no = cpu_to_le32(adapter->priv->coex_mode);
78
++	bl_hdr->check_sum =
79
++		cpu_to_le32(*(u32 *)&flash_content[CHECK_SUM_OFFSET]);
80
++	bl_hdr->flash_start_address =
81
++		cpu_to_le32(*(u32 *)&flash_content[ADDR_OFFSET]);
82
++	bl_hdr->flash_len = cpu_to_le32(*(u32 *)&flash_content[LEN_OFFSET]);
83
+ 	write_len = sizeof(struct bl_header);
84
+ 
85
+ 	if (adapter->rsi_host_intf == RSI_HOST_INTF_USB) {
86
+ 		write_addr = PING_BUFFER_ADDRESS;
87
+ 		status = hif_ops->write_reg_multiple(adapter, write_addr,
88
+-						 (u8 *)&bl_hdr, write_len);
89
++						 (u8 *)bl_hdr, write_len);
90
+ 		if (status < 0) {
91
+ 			rsi_dbg(ERR_ZONE,
92
+ 				"%s: Failed to load Version/CRC structure\n",
93
+ 				__func__);
94
+-			return status;
95
++			goto fail;
96
+ 		}
97
+ 	} else {
98
+ 		write_addr = PING_BUFFER_ADDRESS >> 16;
99
+@@ -665,20 +669,23 @@ static int bl_write_header(struct rsi_hw *adapter, u8 *flash_content,
100
+ 			rsi_dbg(ERR_ZONE,
101
+ 				"%s: Unable to set ms word to common reg\n",
102
+ 				__func__);
103
+-			return status;
104
++			goto fail;
105
+ 		}
106
+ 		write_addr = RSI_SD_REQUEST_MASTER |
107
+ 			     (PING_BUFFER_ADDRESS & 0xFFFF);
108
+ 		status = hif_ops->write_reg_multiple(adapter, write_addr,
109
+-						 (u8 *)&bl_hdr, write_len);
110
++						 (u8 *)bl_hdr, write_len);
111
+ 		if (status < 0) {
112
+ 			rsi_dbg(ERR_ZONE,
113
+ 				"%s: Failed to load Version/CRC structure\n",
114
+ 				__func__);
115
+-			return status;
116
++			goto fail;
117
+ 		}
118
+ 	}
119
+-	return 0;
120
++	status = 0;
121
++fail:
122
++	kfree(bl_hdr);
123
++	return status;
124
+ }
125
+ 
126
+ static u32 read_flash_capacity(struct rsi_hw *adapter)
127
+diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c
128
+index 8ef0058..f7f2820 100644
129
+--- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
130
+@@ -1038,17 +1038,21 @@ static void ulp_read_write(struct rsi_hw *adapter, u16 addr, u32 data,
131
+ /*This function resets and re-initializes the chip.*/
132
+ static void rsi_reset_chip(struct rsi_hw *adapter)
133
+ {
134
+-	__le32 data;
135
++	u8 *data;
136
+ 	u8 sdio_interrupt_status = 0;
137
+ 	u8 request = 1;
138
+ 	int ret;
139
+ 
140
++	data = kzalloc(sizeof(u32), GFP_KERNEL);
141
++	if (!data)
142
++		return;
143
++
144
+ 	rsi_dbg(INFO_ZONE, "Writing disable to wakeup register\n");
145
+ 	ret =  rsi_sdio_write_register(adapter, 0, SDIO_WAKEUP_REG, &request);
146
+ 	if (ret < 0) {
147
+ 		rsi_dbg(ERR_ZONE,
148
+ 			"%s: Failed to write SDIO wakeup register\n", __func__);
149
+-		return;
150
++		goto err;
151
+ 	}
152
+ 	msleep(20);
153
+ 	ret =  rsi_sdio_read_register(adapter, RSI_FN1_INT_REGISTER,
154
+@@ -1056,7 +1060,7 @@ static void rsi_reset_chip(struct rsi_hw *adapter)
155
+ 	if (ret < 0) {
156
+ 		rsi_dbg(ERR_ZONE, "%s: Failed to Read Intr Status Register\n",
157
+ 			__func__);
158
+-		return;
159
++		goto err;
160
+ 	}
161
+ 	rsi_dbg(INFO_ZONE, "%s: Intr Status Register value = %d\n",
162
+ 		__func__, sdio_interrupt_status);
163
+@@ -1066,17 +1070,17 @@ static void rsi_reset_chip(struct rsi_hw *adapter)
164
+ 		rsi_dbg(ERR_ZONE,
165
+ 			"%s: Unable to set ms word to common reg\n",
166
+ 			__func__);
167
+-		return;
168
++		goto err;
169
+ 	}
170
+ 
171
+-	data = TA_HOLD_THREAD_VALUE;
172
++	put_unaligned_le32(TA_HOLD_THREAD_VALUE, data);
173
+ 	if (rsi_sdio_write_register_multiple(adapter, TA_HOLD_THREAD_REG |
174
+ 					     RSI_SD_REQUEST_MASTER,
175
+-					     (u8 *)&data, 4)) {
176
++					     data, 4)) {
177
+ 		rsi_dbg(ERR_ZONE,
178
+ 			"%s: Unable to hold Thread-Arch processor threads\n",
179
+ 			__func__);
180
+-		return;
181
++		goto err;
182
+ 	}
183
+ 
184
+ 	/* This msleep will ensure Thread-Arch processor to go to hold
185
+@@ -1097,6 +1101,9 @@ static void rsi_reset_chip(struct rsi_hw *adapter)
186
+ 	 * read write operations to complete for chip reset.
187
+ 	 */
188
+ 	msleep(500);
189
++err:
190
++	kfree(data);
191
++	return;
192
+ }
193
+ 
194
+ /**
195
+diff --git a/drivers/net/wireless/rsi/rsi_sdio.h b/drivers/net/wireless/rsi/rsi_sdio.h
196
+index ead8e7c..353dbdf 100644
197
+--- a/drivers/net/wireless/rsi/rsi_sdio.h
198
+@@ -87,7 +87,7 @@ enum sdio_interrupt_type {
199
+ #define TA_SOFT_RST_CLR              0
200
+ #define TA_SOFT_RST_SET              BIT(0)
201
+ #define TA_PC_ZERO                   0
202
+-#define TA_HOLD_THREAD_VALUE         cpu_to_le32(0xF)
203
++#define TA_HOLD_THREAD_VALUE         0xF
204
+ #define TA_RELEASE_THREAD_VALUE      cpu_to_le32(0xF)
205
+ #define TA_BASE_ADDR                 0x2200
206
+ #define MISC_CFG_BASE_ADDR           0x4105
... ...
@@ -1526,7 +1526,36 @@ CONFIG_CAN_CALC_BITTIMING=y
1526 1526
 # CONFIG_CAN_8DEV_USB is not set
1527 1527
 # CONFIG_CAN_MCBA_USB is not set
1528 1528
 # CONFIG_CAN_DEBUG_DEVICES is not set
1529
-# CONFIG_BT is not set
1529
+CONFIG_BT=m
1530
+CONFIG_BT_BREDR=y
1531
+CONFIG_BT_RFCOMM=m
1532
+CONFIG_BT_RFCOMM_TTY=y
1533
+CONFIG_BT_BNEP=m
1534
+# CONFIG_BT_BNEP_MC_FILTER is not set
1535
+# CONFIG_BT_BNEP_PROTO_FILTER is not set
1536
+CONFIG_BT_HIDP=m
1537
+CONFIG_BT_HS=y
1538
+CONFIG_BT_LE=y
1539
+# CONFIG_BT_LEDS is not set
1540
+# CONFIG_BT_SELFTEST is not set
1541
+CONFIG_BT_DEBUGFS=y
1542
+
1543
+#
1544
+# Bluetooth device drivers
1545
+#
1546
+CONFIG_BT_INTEL=m
1547
+CONFIG_BT_BCM=m
1548
+CONFIG_BT_RTL=m
1549
+CONFIG_BT_HCIBTUSB=m
1550
+CONFIG_BT_HCIBTUSB_BCM=y
1551
+CONFIG_BT_HCIBTUSB_RTL=y
1552
+CONFIG_BT_HCIBTSDIO=m
1553
+# CONFIG_BT_HCIUART is not set
1554
+CONFIG_BT_HCIBCM203X=m
1555
+# CONFIG_BT_HCIBFUSB is not set
1556
+# CONFIG_BT_HCIVHCI is not set
1557
+# CONFIG_BT_MRVL is not set
1558
+# CONFIG_BT_ATH3K is not set
1530 1559
 # CONFIG_AF_RXRPC is not set
1531 1560
 # CONFIG_AF_KCM is not set
1532 1561
 # CONFIG_STREAM_PARSER is not set
... ...
@@ -2863,7 +2892,7 @@ CONFIG_GPIOLIB=y
2863 2863
 CONFIG_GPIO_ACPI=y
2864 2864
 CONFIG_GPIOLIB_IRQCHIP=y
2865 2865
 # CONFIG_DEBUG_GPIO is not set
2866
-# CONFIG_GPIO_SYSFS is not set
2866
+CONFIG_GPIO_SYSFS=y
2867 2867
 
2868 2868
 #
2869 2869
 # Memory mapped GPIO drivers
... ...
@@ -5312,10 +5341,11 @@ CONFIG_CRYPTO_RNG_DEFAULT=m
5312 5312
 CONFIG_CRYPTO_AKCIPHER2=y
5313 5313
 CONFIG_CRYPTO_AKCIPHER=y
5314 5314
 CONFIG_CRYPTO_KPP2=y
5315
+CONFIG_CRYPTO_KPP=m
5315 5316
 CONFIG_CRYPTO_ACOMP2=y
5316 5317
 CONFIG_CRYPTO_RSA=y
5317 5318
 # CONFIG_CRYPTO_DH is not set
5318
-# CONFIG_CRYPTO_ECDH is not set
5319
+CONFIG_CRYPTO_ECDH=m
5319 5320
 CONFIG_CRYPTO_MANAGER=y
5320 5321
 CONFIG_CRYPTO_MANAGER2=y
5321 5322
 # CONFIG_CRYPTO_USER is not set
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:        Kernel
3 3
 Name:           linux
4 4
 Version:        4.14.54
5
-Release:        3%{?kat_build:.%kat_build}%{?dist}
5
+Release:        4%{?kat_build:.%kat_build}%{?dist}
6 6
 License:    	GPLv2
7 7
 URL:        	http://www.kernel.org/
8 8
 Group:        	System Environment/Kernel
... ...
@@ -13,9 +13,11 @@ Source0:        http://www.kernel.org/pub/linux/kernel/v4.x/linux-%{version}.tar
13 13
 Source1:	config
14 14
 Source2:	initramfs.trigger
15 15
 %define ena_version 1.5.0
16
-Source3:       https://github.com/amzn/amzn-drivers/archive/ena_linux_%{ena_version}.tar.gz
16
+Source3:	https://github.com/amzn/amzn-drivers/archive/ena_linux_%{ena_version}.tar.gz
17 17
 %define sha1 ena_linux=cbbbe8a3bbab6d01a4e38417cb0ead2f7cb8b2ee
18 18
 Source4:	config_aarch64
19
+Source5:	xr_usb_serial_common_lnx-3.6-and-newer-pak.tar.xz
20
+%define sha1 xr=74df7143a86dd1519fa0ccf5276ed2225665a9db
19 21
 # common
20 22
 Patch0:         linux-4.14-Log-kmsg-dump-on-panic.patch
21 23
 Patch1:         double-tcp_mem-limits.patch
... ...
@@ -25,8 +27,11 @@ Patch3:         SUNRPC-Do-not-reuse-srcport-for-TIME_WAIT-socket.patch
25 25
 Patch4:         SUNRPC-xs_bind-uses-ip_local_reserved_ports.patch
26 26
 Patch5:         vsock-transport-for-9p.patch
27 27
 Patch6:         x86-vmware-STA-support.patch
28
+Patch9:         1-2-rsi-fix-nommu_map_sg-overflow-kernel-panic.patch
28 29
 # rpi3 dts
29 30
 Patch10:	arm-dts-add-vchiq-entry.patch
31
+# ttyXRUSB support
32
+Patch11:	usb-acm-exclude-exar-usb-serial-ports.patch
30 33
 #HyperV patches
31 34
 Patch13:        0004-vmbus-Don-t-spam-the-logs-with-unknown-GUIDs.patch
32 35
 # TODO: Is CONFIG_HYPERV_VSOCKETS the same?
... ...
@@ -121,6 +126,7 @@ Kernel Device Tree Blob files for Raspberry Pi3
121 121
 %setup -q -n linux-%{version}
122 122
 %ifarch x86_64
123 123
 %setup -D -b 3 -n linux-%{version}
124
+%setup -D -b 5 -n linux-%{version}
124 125
 %endif
125 126
 %patch0 -p1
126 127
 %patch1 -p1
... ...
@@ -128,7 +134,9 @@ Kernel Device Tree Blob files for Raspberry Pi3
128 128
 %patch4 -p1
129 129
 %patch5 -p1
130 130
 %patch6 -p1
131
+%patch9 -p1
131 132
 %patch10 -p1
133
+%patch11 -p1
132 134
 %patch13 -p1
133 135
 %patch24 -p1
134 136
 %patch26 -p1
... ...
@@ -162,6 +170,11 @@ bldroot=`pwd`
162 162
 pushd ../amzn-drivers-ena_linux_%{ena_version}/kernel/linux/ena
163 163
 make -C $bldroot M=`pwd` VERBOSE=1 modules %{?_smp_mflags}
164 164
 popd
165
+# build XR module
166
+bldroot=`pwd`
167
+pushd ../xr_usb_serial_common_lnx-3.6-and-newer-pak
168
+make KERNELDIR=$bldroot %{?_smp_mflags} all
169
+popd
165 170
 %endif
166 171
 
167 172
 %define __modules_install_post \
... ...
@@ -196,6 +209,12 @@ pushd ../amzn-drivers-ena_linux_%{ena_version}/kernel/linux/ena
196 196
 make -C $bldroot M=`pwd` INSTALL_MOD_PATH=%{buildroot} modules_install
197 197
 popd
198 198
 
199
+# install XR module
200
+bldroot=`pwd`
201
+pushd ../xr_usb_serial_common_lnx-3.6-and-newer-pak
202
+make KERNELDIR=$bldroot INSTALL_MOD_PATH=%{buildroot} modules_install
203
+popd
204
+
199 205
 # Verify for build-id match
200 206
 # We observe different IDs sometimes
201 207
 # TODO: debug it
... ...
@@ -341,6 +360,10 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg
341 341
 %endif
342 342
 
343 343
 %changelog
344
+*   Wed Aug 22 2018 Alexey Makhalov <amakhalov@vmware.com> 4.14.54-4
345
+-   Fix overflow kernel panic in rsi driver.
346
+-   .config: enable BT stack, enable GPIO sysfs.
347
+-   Add Exar USB serial driver.
344 348
 *   Fri Aug 17 2018 Ajay Kaher <akaher@vmware.com> 4.14.54-3
345 349
 -   Enabled USB PCI in config_aarch64
346 350
 -   Build hang (at make oldconfig) fix in config_aarch64
347 351
new file mode 100644
... ...
@@ -0,0 +1,25 @@
0
+diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1
+index 3b9aadd007f5..96a55ea46c25 100644
2
+--- a/drivers/usb/class/cdc-acm.c
3
+@@ -1942,6 +1942,20 @@ static const struct usb_device_id acm_ids[] = {
4
+ 	.driver_info = IGNORE_DEVICE,
5
+ 	},
6
+ 
7
++	/* Exclude Exar USB serial ports */
8
++	{ USB_DEVICE(0x04e2, 0x1400), .driver_info = IGNORE_DEVICE, },
9
++	{ USB_DEVICE(0x04e2, 0x1401), .driver_info = IGNORE_DEVICE, },
10
++	{ USB_DEVICE(0x04e2, 0x1402), .driver_info = IGNORE_DEVICE, },
11
++	{ USB_DEVICE(0x04e2, 0x1403), .driver_info = IGNORE_DEVICE, },
12
++	{ USB_DEVICE(0x04e2, 0x1410), .driver_info = IGNORE_DEVICE, },
13
++	{ USB_DEVICE(0x04e2, 0x1411), .driver_info = IGNORE_DEVICE, },
14
++	{ USB_DEVICE(0x04e2, 0x1412), .driver_info = IGNORE_DEVICE, },
15
++	{ USB_DEVICE(0x04e2, 0x1414), .driver_info = IGNORE_DEVICE, },
16
++	{ USB_DEVICE(0x04e2, 0x1420), .driver_info = IGNORE_DEVICE, },
17
++	{ USB_DEVICE(0x04e2, 0x1421), .driver_info = IGNORE_DEVICE, },
18
++	{ USB_DEVICE(0x04e2, 0x1422), .driver_info = IGNORE_DEVICE, },
19
++	{ USB_DEVICE(0x04e2, 0x1424), .driver_info = IGNORE_DEVICE, },
20
++
21
+ 	/* control interfaces without any protocol set */
22
+ 	{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
23
+ 		USB_CDC_PROTO_NONE) },