From df90941db9194bd386a718eab1539f04fbd616cb Mon Sep 17 00:00:00 2001
From: Mike Pagano <mpagano@gentoo.org>
Date: Tue, 11 Jan 2022 07:59:34 -0500
Subject: Linux patch 4.9.297

Signed-off-by: Mike Pagano <mpagano@gentoo.org>
---
 0000_README              |   4 +
 1296_linux-4.9.297.patch | 868 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 872 insertions(+)
 create mode 100644 1296_linux-4.9.297.patch

diff --git a/0000_README b/0000_README
index 89c7405b..124bfa64 100644
--- a/0000_README
+++ b/0000_README
@@ -1227,6 +1227,10 @@ Patch:  1295_linux-4.9.296.patch
 From:   http://www.kernel.org
 Desc:   Linux 4.9.296
 
+Patch:  1296_linux-4.9.297.patch
+From:   http://www.kernel.org
+Desc:   Linux 4.9.297
+
 Patch:  1500_XATTR_USER_PREFIX.patch
 From:   https://bugs.gentoo.org/show_bug.cgi?id=470644
 Desc:   Support for namespace user.pax.* on tmpfs.
diff --git a/1296_linux-4.9.297.patch b/1296_linux-4.9.297.patch
new file mode 100644
index 00000000..f0940546
--- /dev/null
+++ b/1296_linux-4.9.297.patch
@@ -0,0 +1,868 @@
+diff --git a/Makefile b/Makefile
+index 1ec880bcdb2d6..70a11157b2404 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,6 +1,6 @@
+ VERSION = 4
+ PATCHLEVEL = 9
+-SUBLEVEL = 296
++SUBLEVEL = 297
+ EXTRAVERSION =
+ NAME = Roaring Lionus
+ 
+diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
+index 88bbe364b6ae0..ae1b31d02784c 100644
+--- a/arch/arm64/include/asm/sysreg.h
++++ b/arch/arm64/include/asm/sysreg.h
+@@ -20,6 +20,7 @@
+ #ifndef __ASM_SYSREG_H
+ #define __ASM_SYSREG_H
+ 
++#include <asm/compiler.h>
+ #include <linux/stringify.h>
+ 
+ #include <asm/opcodes.h>
+@@ -88,25 +89,81 @@
+ 
+ /* Common SCTLR_ELx flags. */
+ #define SCTLR_ELx_EE    (1 << 25)
++#define SCTLR_ELx_WXN	(1 << 19)
+ #define SCTLR_ELx_I	(1 << 12)
+ #define SCTLR_ELx_SA	(1 << 3)
+ #define SCTLR_ELx_C	(1 << 2)
+ #define SCTLR_ELx_A	(1 << 1)
+ #define SCTLR_ELx_M	1
+ 
+-#define SCTLR_EL2_RES1	((1 << 4)  | (1 << 5)  | (1 << 11) | (1 << 16) | \
+-			 (1 << 16) | (1 << 18) | (1 << 22) | (1 << 23) | \
+-			 (1 << 28) | (1 << 29))
+-
+ #define SCTLR_ELx_FLAGS	(SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \
+ 			 SCTLR_ELx_SA | SCTLR_ELx_I)
+ 
++/* SCTLR_EL2 specific flags. */
++#define SCTLR_EL2_RES1	((1 << 4)  | (1 << 5)  | (1 << 11) | (1 << 16) | \
++			 (1 << 18) | (1 << 22) | (1 << 23) | (1 << 28) | \
++			 (1 << 29))
++#define SCTLR_EL2_RES0	((1 << 6)  | (1 << 7)  | (1 << 8)  | (1 << 9)  | \
++			 (1 << 10) | (1 << 13) | (1 << 14) | (1 << 15) | \
++			 (1 << 17) | (1 << 20) | (1 << 21) | (1 << 24) | \
++			 (1 << 26) | (1 << 27) | (1 << 30) | (1 << 31))
++
++#ifdef CONFIG_CPU_BIG_ENDIAN
++#define ENDIAN_SET_EL2		SCTLR_ELx_EE
++#define ENDIAN_CLEAR_EL2	0
++#else
++#define ENDIAN_SET_EL2		0
++#define ENDIAN_CLEAR_EL2	SCTLR_ELx_EE
++#endif
++
++/* SCTLR_EL2 value used for the hyp-stub */
++#define SCTLR_EL2_SET	(ENDIAN_SET_EL2   | SCTLR_EL2_RES1)
++#define SCTLR_EL2_CLEAR	(SCTLR_ELx_M      | SCTLR_ELx_A    | SCTLR_ELx_C   | \
++			 SCTLR_ELx_SA     | SCTLR_ELx_I    | SCTLR_ELx_WXN | \
++			 ENDIAN_CLEAR_EL2 | SCTLR_EL2_RES0)
++
++/* Check all the bits are accounted for */
++#define SCTLR_EL2_BUILD_BUG_ON_MISSING_BITS	BUILD_BUG_ON((SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != ~0)
++
++
+ /* SCTLR_EL1 specific flags. */
+ #define SCTLR_EL1_UCI		(1 << 26)
++#define SCTLR_EL1_E0E		(1 << 24)
+ #define SCTLR_EL1_SPAN		(1 << 23)
++#define SCTLR_EL1_NTWE		(1 << 18)
++#define SCTLR_EL1_NTWI		(1 << 16)
+ #define SCTLR_EL1_UCT		(1 << 15)
++#define SCTLR_EL1_DZE		(1 << 14)
++#define SCTLR_EL1_UMA		(1 << 9)
+ #define SCTLR_EL1_SED		(1 << 8)
++#define SCTLR_EL1_ITD		(1 << 7)
+ #define SCTLR_EL1_CP15BEN	(1 << 5)
++#define SCTLR_EL1_SA0		(1 << 4)
++
++#define SCTLR_EL1_RES1	((1 << 11) | (1 << 20) | (1 << 22) | (1 << 28) | \
++			 (1 << 29))
++#define SCTLR_EL1_RES0  ((1 << 6)  | (1 << 10) | (1 << 13) | (1 << 17) | \
++			 (1 << 21) | (1 << 27) | (1 << 30) | (1 << 31))
++
++#ifdef CONFIG_CPU_BIG_ENDIAN
++#define ENDIAN_SET_EL1		(SCTLR_EL1_E0E | SCTLR_ELx_EE)
++#define ENDIAN_CLEAR_EL1	0
++#else
++#define ENDIAN_SET_EL1		0
++#define ENDIAN_CLEAR_EL1	(SCTLR_EL1_E0E | SCTLR_ELx_EE)
++#endif
++
++#define SCTLR_EL1_SET	(SCTLR_ELx_M    | SCTLR_ELx_C    | SCTLR_ELx_SA   |\
++			 SCTLR_EL1_SA0  | SCTLR_EL1_SED  | SCTLR_ELx_I    |\
++			 SCTLR_EL1_DZE  | SCTLR_EL1_UCT  | SCTLR_EL1_NTWI |\
++			 SCTLR_EL1_NTWE | SCTLR_EL1_SPAN | ENDIAN_SET_EL1 |\
++			 SCTLR_EL1_UCI  | SCTLR_EL1_RES1)
++#define SCTLR_EL1_CLEAR	(SCTLR_ELx_A   | SCTLR_EL1_CP15BEN | SCTLR_EL1_ITD    |\
++			 SCTLR_EL1_UMA | SCTLR_ELx_WXN     | ENDIAN_CLEAR_EL1 |\
++			 SCTLR_EL1_RES0)
++
++/* Check all the bits are accounted for */
++#define SCTLR_EL1_BUILD_BUG_ON_MISSING_BITS	BUILD_BUG_ON((SCTLR_EL1_SET ^ SCTLR_EL1_CLEAR) != ~0)
+ 
+ /* id_aa64isar0 */
+ #define ID_AA64ISAR0_RDM_SHIFT		28
+@@ -244,6 +301,7 @@
+ 
+ #else
+ 
++#include <linux/build_bug.h>
+ #include <linux/types.h>
+ 
+ asm(
+@@ -300,6 +358,9 @@ static inline void config_sctlr_el1(u32 clear, u32 set)
+ {
+ 	u32 val;
+ 
++	SCTLR_EL2_BUILD_BUG_ON_MISSING_BITS;
++	SCTLR_EL1_BUILD_BUG_ON_MISSING_BITS;
++
+ 	val = read_sysreg(sctlr_el1);
+ 	val &= ~clear;
+ 	val |= set;
+diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
+index 3875423836622..04f81675b6b3a 100644
+--- a/arch/arm64/kernel/head.S
++++ b/arch/arm64/kernel/head.S
+@@ -489,21 +489,16 @@ ENTRY(el2_setup)
+ 	msr	SPsel, #1			// We want to use SP_EL{1,2}
+ 	mrs	x0, CurrentEL
+ 	cmp	x0, #CurrentEL_EL2
+-	b.ne	1f
+-	mrs	x0, sctlr_el2
+-CPU_BE(	orr	x0, x0, #(1 << 25)	)	// Set the EE bit for EL2
+-CPU_LE(	bic	x0, x0, #(1 << 25)	)	// Clear the EE bit for EL2
+-	msr	sctlr_el2, x0
+-	b	2f
+-1:	mrs	x0, sctlr_el1
+-CPU_BE(	orr	x0, x0, #(3 << 24)	)	// Set the EE and E0E bits for EL1
+-CPU_LE(	bic	x0, x0, #(3 << 24)	)	// Clear the EE and E0E bits for EL1
++	b.eq	1f
++	mov_q	x0, (SCTLR_EL1_RES1 | ENDIAN_SET_EL1)
+ 	msr	sctlr_el1, x0
+ 	mov	w0, #BOOT_CPU_MODE_EL1		// This cpu booted in EL1
+ 	isb
+ 	ret
+ 
+-2:
++1:	mov_q	x0, (SCTLR_EL2_RES1 | ENDIAN_SET_EL2)
++	msr	sctlr_el2, x0
++
+ #ifdef CONFIG_ARM64_VHE
+ 	/*
+ 	 * Check for VHE being present. For the rest of the EL2 setup,
+@@ -554,26 +549,6 @@ set_hcr:
+ 	msr	vpidr_el2, x0
+ 	msr	vmpidr_el2, x1
+ 
+-	/*
+-	 * When VHE is not in use, early init of EL2 and EL1 needs to be
+-	 * done here.
+-	 * When VHE _is_ in use, EL1 will not be used in the host and
+-	 * requires no configuration, and all non-hyp-specific EL2 setup
+-	 * will be done via the _EL1 system register aliases in __cpu_setup.
+-	 */
+-	cbnz	x2, 1f
+-
+-	/* sctlr_el1 */
+-	mov	x0, #0x0800			// Set/clear RES{1,0} bits
+-CPU_BE(	movk	x0, #0x33d0, lsl #16	)	// Set EE and E0E on BE systems
+-CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
+-	msr	sctlr_el1, x0
+-
+-	/* Coprocessor traps. */
+-	mov	x0, #0x33ff
+-	msr	cptr_el2, x0			// Disable copro. traps to EL2
+-1:
+-
+ #ifdef CONFIG_COMPAT
+ 	msr	hstr_el2, xzr			// Disable CP15 traps to EL2
+ #endif
+@@ -599,6 +574,20 @@ CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
+ 	ret
+ 
+ install_el2_stub:
++	/*
++	 * When VHE is not in use, early init of EL2 and EL1 needs to be
++	 * done here.
++	 * When VHE _is_ in use, EL1 will not be used in the host and
++	 * requires no configuration, and all non-hyp-specific EL2 setup
++	 * will be done via the _EL1 system register aliases in __cpu_setup.
++	 */
++	mov_q	x0, (SCTLR_EL1_RES1 | ENDIAN_SET_EL1)
++	msr	sctlr_el1, x0
++
++	/* Coprocessor traps. */
++	mov	x0, #0x33ff
++	msr	cptr_el2, x0			// Disable copro. traps to EL2
++
+ 	/* Hypervisor stub */
+ 	adrp	x0, __hyp_stub_vectors
+ 	add	x0, x0, #:lo12:__hyp_stub_vectors
+diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
+index 1b91b8c8999bc..266211a0ecd6d 100644
+--- a/arch/arm64/mm/proc.S
++++ b/arch/arm64/mm/proc.S
+@@ -413,11 +413,7 @@ ENTRY(__cpu_setup)
+ 	/*
+ 	 * Prepare SCTLR
+ 	 */
+-	adr	x5, crval
+-	ldp	w5, w6, [x5]
+-	mrs	x0, sctlr_el1
+-	bic	x0, x0, x5			// clear bits
+-	orr	x0, x0, x6			// set bits
++	mov_q	x0, SCTLR_EL1_SET
+ 	/*
+ 	 * Set/prepare TCR and TTBR. We use 512GB (39-bit) address range for
+ 	 * both user and kernel.
+@@ -453,21 +449,3 @@ ENTRY(__cpu_setup)
+ 	msr	tcr_el1, x10
+ 	ret					// return to head.S
+ ENDPROC(__cpu_setup)
+-
+-	/*
+-	 * We set the desired value explicitly, including those of the
+-	 * reserved bits. The values of bits EE & E0E were set early in
+-	 * el2_setup, which are left untouched below.
+-	 *
+-	 *                 n n            T
+-	 *       U E      WT T UD     US IHBS
+-	 *       CE0      XWHW CZ     ME TEEA S
+-	 * .... .IEE .... NEAI TE.I ..AD DEN0 ACAM
+-	 * 0011 0... 1101 ..0. ..0. 10.. .0.. .... < hardware reserved
+-	 * .... .1.. .... 01.1 11.1 ..01 0.01 1101 < software settings
+-	 */
+-	.type	crval, #object
+-crval:
+-	.word	0xfcffffff			// clear
+-	.word	0x34d5d91d			// set
+-	.popsection
+diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
+index 30c09b9ddbf0d..2069080191eeb 100644
+--- a/drivers/bluetooth/btusb.c
++++ b/drivers/bluetooth/btusb.c
+@@ -2442,11 +2442,9 @@ static const struct qca_device_info qca_devices_table[] = {
+ 	{ 0x00000302, 28, 4, 18 }, /* Rome 3.2 */
+ };
+ 
+-static int btusb_qca_send_vendor_req(struct hci_dev *hdev, u8 request,
++static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request,
+ 				     void *data, u16 size)
+ {
+-	struct btusb_data *btdata = hci_get_drvdata(hdev);
+-	struct usb_device *udev = btdata->udev;
+ 	int pipe, err;
+ 	u8 *buf;
+ 
+@@ -2461,7 +2459,7 @@ static int btusb_qca_send_vendor_req(struct hci_dev *hdev, u8 request,
+ 	err = usb_control_msg(udev, pipe, request, USB_TYPE_VENDOR | USB_DIR_IN,
+ 			      0, 0, buf, size, USB_CTRL_SET_TIMEOUT);
+ 	if (err < 0) {
+-		BT_ERR("%s: Failed to access otp area (%d)", hdev->name, err);
++		dev_err(&udev->dev, "Failed to access otp area (%d)", err);
+ 		goto done;
+ 	}
+ 
+@@ -2617,20 +2615,38 @@ static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,
+ 	return err;
+ }
+ 
++/* identify the ROM version and check whether patches are needed */
++static bool btusb_qca_need_patch(struct usb_device *udev)
++{
++	struct qca_version ver;
++
++	if (btusb_qca_send_vendor_req(udev, QCA_GET_TARGET_VERSION, &ver,
++				      sizeof(ver)) < 0)
++		return false;
++	/* only low ROM versions need patches */
++	return !(le32_to_cpu(ver.rom_version) & ~0xffffU);
++}
++
+ static int btusb_setup_qca(struct hci_dev *hdev)
+ {
++	struct btusb_data *btdata = hci_get_drvdata(hdev);
++	struct usb_device *udev = btdata->udev;
+ 	const struct qca_device_info *info = NULL;
+ 	struct qca_version ver;
+ 	u32 ver_rom;
+ 	u8 status;
+ 	int i, err;
+ 
+-	err = btusb_qca_send_vendor_req(hdev, QCA_GET_TARGET_VERSION, &ver,
++	err = btusb_qca_send_vendor_req(udev, QCA_GET_TARGET_VERSION, &ver,
+ 					sizeof(ver));
+ 	if (err < 0)
+ 		return err;
+ 
+ 	ver_rom = le32_to_cpu(ver.rom_version);
++	/* Don't care about high ROM versions */
++	if (ver_rom & ~0xffffU)
++		return 0;
++
+ 	for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) {
+ 		if (ver_rom == qca_devices_table[i].rom_version)
+ 			info = &qca_devices_table[i];
+@@ -2641,7 +2657,7 @@ static int btusb_setup_qca(struct hci_dev *hdev)
+ 		return -ENODEV;
+ 	}
+ 
+-	err = btusb_qca_send_vendor_req(hdev, QCA_CHECK_STATUS, &status,
++	err = btusb_qca_send_vendor_req(udev, QCA_CHECK_STATUS, &status,
+ 					sizeof(status));
+ 	if (err < 0)
+ 		return err;
+@@ -2787,7 +2803,8 @@ static int btusb_probe(struct usb_interface *intf,
+ 
+ 		/* Old firmware would otherwise let ath3k driver load
+ 		 * patch and sysconfig files */
+-		if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
++		if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001 &&
++		    !btusb_qca_need_patch(udev))
+ 			return -ENODEV;
+ 	}
+ 
+@@ -2937,6 +2954,7 @@ static int btusb_probe(struct usb_interface *intf,
+ 	}
+ 
+ 	if (id->driver_info & BTUSB_ATH3012) {
++		data->setup_on_usb = btusb_setup_qca;
+ 		hdev->set_bdaddr = btusb_set_bdaddr_ath3012;
+ 		set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
+ 		set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
+diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
+index faf505462a4f5..f5a06a6fb297f 100644
+--- a/drivers/isdn/mISDN/core.c
++++ b/drivers/isdn/mISDN/core.c
+@@ -390,7 +390,7 @@ mISDNInit(void)
+ 	err = mISDN_inittimer(&debug);
+ 	if (err)
+ 		goto error2;
+-	err = l1_init(&debug);
++	err = Isdnl1_Init(&debug);
+ 	if (err)
+ 		goto error3;
+ 	err = Isdnl2_Init(&debug);
+@@ -404,7 +404,7 @@ mISDNInit(void)
+ error5:
+ 	Isdnl2_cleanup();
+ error4:
+-	l1_cleanup();
++	Isdnl1_cleanup();
+ error3:
+ 	mISDN_timer_cleanup();
+ error2:
+@@ -417,7 +417,7 @@ static void mISDN_cleanup(void)
+ {
+ 	misdn_sock_cleanup();
+ 	Isdnl2_cleanup();
+-	l1_cleanup();
++	Isdnl1_cleanup();
+ 	mISDN_timer_cleanup();
+ 	class_unregister(&mISDN_class);
+ 
+diff --git a/drivers/isdn/mISDN/core.h b/drivers/isdn/mISDN/core.h
+index 52695bb81ee7a..3c039b6ade2e1 100644
+--- a/drivers/isdn/mISDN/core.h
++++ b/drivers/isdn/mISDN/core.h
+@@ -69,8 +69,8 @@ struct Bprotocol	*get_Bprotocol4id(u_int);
+ extern int	mISDN_inittimer(u_int *);
+ extern void	mISDN_timer_cleanup(void);
+ 
+-extern int	l1_init(u_int *);
+-extern void	l1_cleanup(void);
++extern int	Isdnl1_Init(u_int *);
++extern void	Isdnl1_cleanup(void);
+ extern int	Isdnl2_Init(u_int *);
+ extern void	Isdnl2_cleanup(void);
+ 
+diff --git a/drivers/isdn/mISDN/layer1.c b/drivers/isdn/mISDN/layer1.c
+index bebc57b72138e..94d7cc58da648 100644
+--- a/drivers/isdn/mISDN/layer1.c
++++ b/drivers/isdn/mISDN/layer1.c
+@@ -407,7 +407,7 @@ create_l1(struct dchannel *dch, dchannel_l1callback *dcb) {
+ EXPORT_SYMBOL(create_l1);
+ 
+ int
+-l1_init(u_int *deb)
++Isdnl1_Init(u_int *deb)
+ {
+ 	debug = deb;
+ 	l1fsm_s.state_count = L1S_STATE_COUNT;
+@@ -419,7 +419,7 @@ l1_init(u_int *deb)
+ }
+ 
+ void
+-l1_cleanup(void)
++Isdnl1_cleanup(void)
+ {
+ 	mISDN_FsmFree(&l1fsm_s);
+ }
+diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
+index e7585f6c4665b..104f8eb828a04 100644
+--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
+@@ -5429,6 +5429,27 @@ int i40e_open(struct net_device *netdev)
+ 	return 0;
+ }
+ 
++/**
++ * i40e_netif_set_realnum_tx_rx_queues - Update number of tx/rx queues
++ * @vsi: vsi structure
++ *
++ * This updates netdev's number of tx/rx queues
++ *
++ * Returns status of setting tx/rx queues
++ **/
++static int i40e_netif_set_realnum_tx_rx_queues(struct i40e_vsi *vsi)
++{
++	int ret;
++
++	ret = netif_set_real_num_rx_queues(vsi->netdev,
++					   vsi->num_queue_pairs);
++	if (ret)
++		return ret;
++
++	return netif_set_real_num_tx_queues(vsi->netdev,
++					    vsi->num_queue_pairs);
++}
++
+ /**
+  * i40e_vsi_open -
+  * @vsi: the VSI to open
+@@ -5463,13 +5484,7 @@ int i40e_vsi_open(struct i40e_vsi *vsi)
+ 			goto err_setup_rx;
+ 
+ 		/* Notify the stack of the actual queue counts. */
+-		err = netif_set_real_num_tx_queues(vsi->netdev,
+-						   vsi->num_queue_pairs);
+-		if (err)
+-			goto err_set_queues;
+-
+-		err = netif_set_real_num_rx_queues(vsi->netdev,
+-						   vsi->num_queue_pairs);
++		err = i40e_netif_set_realnum_tx_rx_queues(vsi);
+ 		if (err)
+ 			goto err_set_queues;
+ 
+@@ -9908,6 +9923,9 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
+ 	case I40E_VSI_VMDQ2:
+ 	case I40E_VSI_FCOE:
+ 		ret = i40e_config_netdev(vsi);
++		if (ret)
++			goto err_netdev;
++		ret = i40e_netif_set_realnum_tx_rx_queues(vsi);
+ 		if (ret)
+ 			goto err_netdev;
+ 		ret = register_netdev(vsi->netdev);
+diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
+index 0ee54fba0a237..92df7c2d5850e 100644
+--- a/drivers/net/ieee802154/atusb.c
++++ b/drivers/net/ieee802154/atusb.c
+@@ -79,7 +79,9 @@ static int atusb_control_msg(struct atusb *atusb, unsigned int pipe,
+ 
+ 	ret = usb_control_msg(usb_dev, pipe, request, requesttype,
+ 			      value, index, data, size, timeout);
+-	if (ret < 0) {
++	if (ret < size) {
++		ret = ret < 0 ? ret : -ENODATA;
++
+ 		atusb->err = ret;
+ 		dev_err(&usb_dev->dev,
+ 			"atusb_control_msg: req 0x%02x val 0x%x idx 0x%x, error %d\n",
+@@ -637,9 +639,9 @@ static int atusb_get_and_show_build(struct atusb *atusb)
+ 	if (!build)
+ 		return -ENOMEM;
+ 
+-	ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
+-				ATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0,
+-				build, ATUSB_BUILD_SIZE, 1000);
++	/* We cannot call atusb_control_msg() here, since this request may read various length data */
++	ret = usb_control_msg(atusb->usb_dev, usb_rcvctrlpipe(usb_dev, 0), ATUSB_BUILD,
++			      ATUSB_REQ_FROM_DEV, 0, 0, build, ATUSB_BUILD_SIZE, 1000);
+ 	if (ret >= 0) {
+ 		build[ret] = 0;
+ 		dev_info(&usb_dev->dev, "Firmware: build %s\n", build);
+diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
+index dc5b8e69f8e86..9567bd00a8144 100644
+--- a/drivers/net/usb/rndis_host.c
++++ b/drivers/net/usb/rndis_host.c
+@@ -619,6 +619,11 @@ static const struct usb_device_id	products [] = {
+ 	USB_DEVICE_AND_INTERFACE_INFO(0x1630, 0x0042,
+ 				      USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
+ 	.driver_info = (unsigned long) &rndis_poll_status_info,
++}, {
++	/* Hytera Communications DMR radios' "Radio to PC Network" */
++	USB_VENDOR_AND_INTERFACE_INFO(0x238b,
++				      USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
++	.driver_info = (unsigned long)&rndis_info,
+ }, {
+ 	/* RNDIS is MSFT's un-official variant of CDC ACM */
+ 	USB_INTERFACE_INFO(USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
+diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c
+index 15fed9d8f871a..ec54cff108b3c 100644
+--- a/drivers/power/reset/ltc2952-poweroff.c
++++ b/drivers/power/reset/ltc2952-poweroff.c
+@@ -169,8 +169,8 @@ static void ltc2952_poweroff_kill(void)
+ 
+ static void ltc2952_poweroff_default(struct ltc2952_poweroff *data)
+ {
+-	data->wde_interval = ktime_set(0, 300L*1E6L);
+-	data->trigger_delay = ktime_set(2, 500L*1E6L);
++	data->wde_interval = ktime_set(0, 300L * NSEC_PER_MSEC);
++	data->trigger_delay = ktime_set(2, 500L * NSEC_PER_MSEC);
+ 
+ 	hrtimer_init(&data->timer_trigger, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+ 	data->timer_trigger.function = ltc2952_poweroff_timer_trigger;
+diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
+index 30e954bb6c81e..8d1a05d5eb4dd 100644
+--- a/drivers/scsi/libiscsi.c
++++ b/drivers/scsi/libiscsi.c
+@@ -2991,6 +2991,8 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
+ {
+ 	struct iscsi_conn *conn = cls_conn->dd_data;
+ 	struct iscsi_session *session = conn->session;
++	char *tmp_persistent_address = conn->persistent_address;
++	char *tmp_local_ipaddr = conn->local_ipaddr;
+ 
+ 	del_timer_sync(&conn->transport_timer);
+ 
+@@ -3012,8 +3014,6 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
+ 	spin_lock_bh(&session->frwd_lock);
+ 	free_pages((unsigned long) conn->data,
+ 		   get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
+-	kfree(conn->persistent_address);
+-	kfree(conn->local_ipaddr);
+ 	/* regular RX path uses back_lock */
+ 	spin_lock_bh(&session->back_lock);
+ 	kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
+@@ -3025,6 +3025,8 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
+ 	mutex_unlock(&session->eh_mutex);
+ 
+ 	iscsi_destroy_conn(cls_conn);
++	kfree(tmp_persistent_address);
++	kfree(tmp_local_ipaddr);
+ }
+ EXPORT_SYMBOL_GPL(iscsi_conn_teardown);
+ 
+diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
+index d9a9058279671..37e3ba5dadf60 100644
+--- a/drivers/virtio/virtio_pci_common.c
++++ b/drivers/virtio/virtio_pci_common.c
+@@ -547,6 +547,13 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
+ 	struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
+ 	struct device *dev = get_device(&vp_dev->vdev.dev);
+ 
++	/*
++	 * Device is marked broken on surprise removal so that virtio upper
++	 * layers can abort any ongoing operation.
++	 */
++	if (!pci_device_is_present(pci_dev))
++		virtio_break_device(&vp_dev->vdev);
++
+ 	unregister_virtio_device(&vp_dev->vdev);
+ 
+ 	if (vp_dev->ioaddr)
+diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
+index 6c95812120ebd..5e28a5225e3fb 100644
+--- a/fs/xfs/xfs_ioctl.c
++++ b/fs/xfs/xfs_ioctl.c
+@@ -712,7 +712,8 @@ xfs_ioc_space(
+ 		flags |= XFS_PREALLOC_CLEAR;
+ 		if (bf->l_start > XFS_ISIZE(ip)) {
+ 			error = xfs_alloc_file_space(ip, XFS_ISIZE(ip),
+-					bf->l_start - XFS_ISIZE(ip), 0);
++					bf->l_start - XFS_ISIZE(ip),
++					XFS_BMAPI_PREALLOC);
+ 			if (error)
+ 				goto out_unlock;
+ 		}
+diff --git a/include/linux/bug.h b/include/linux/bug.h
+index 0faae96302bda..eafb6213e582a 100644
+--- a/include/linux/bug.h
++++ b/include/linux/bug.h
+@@ -3,6 +3,7 @@
+ 
+ #include <asm/bug.h>
+ #include <linux/compiler.h>
++#include <linux/build_bug.h>
+ 
+ enum bug_trap_type {
+ 	BUG_TRAP_TYPE_NONE = 0,
+@@ -13,80 +14,9 @@ enum bug_trap_type {
+ struct pt_regs;
+ 
+ #ifdef __CHECKER__
+-#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) (0)
+-#define BUILD_BUG_ON_NOT_POWER_OF_2(n) (0)
+-#define BUILD_BUG_ON_ZERO(e) (0)
+-#define BUILD_BUG_ON_NULL(e) ((void*)0)
+-#define BUILD_BUG_ON_INVALID(e) (0)
+-#define BUILD_BUG_ON_MSG(cond, msg) (0)
+-#define BUILD_BUG_ON(condition) (0)
+-#define BUILD_BUG() (0)
+ #define MAYBE_BUILD_BUG_ON(cond) (0)
+ #else /* __CHECKER__ */
+ 
+-/* Force a compilation error if a constant expression is not a power of 2 */
+-#define __BUILD_BUG_ON_NOT_POWER_OF_2(n)	\
+-	BUILD_BUG_ON(((n) & ((n) - 1)) != 0)
+-#define BUILD_BUG_ON_NOT_POWER_OF_2(n)			\
+-	BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
+-
+-/* Force a compilation error if condition is true, but also produce a
+-   result (of value 0 and type size_t), so the expression can be used
+-   e.g. in a structure initializer (or where-ever else comma expressions
+-   aren't permitted). */
+-#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
+-#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
+-
+-/*
+- * BUILD_BUG_ON_INVALID() permits the compiler to check the validity of the
+- * expression but avoids the generation of any code, even if that expression
+- * has side-effects.
+- */
+-#define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
+-
+-/**
+- * BUILD_BUG_ON_MSG - break compile if a condition is true & emit supplied
+- *		      error message.
+- * @condition: the condition which the compiler should know is false.
+- *
+- * See BUILD_BUG_ON for description.
+- */
+-#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
+-
+-/**
+- * BUILD_BUG_ON - break compile if a condition is true.
+- * @condition: the condition which the compiler should know is false.
+- *
+- * If you have some code which relies on certain constants being equal, or
+- * some other compile-time-evaluated condition, you should use BUILD_BUG_ON to
+- * detect if someone changes it.
+- *
+- * The implementation uses gcc's reluctance to create a negative array, but gcc
+- * (as of 4.4) only emits that error for obvious cases (e.g. not arguments to
+- * inline functions).  Luckily, in 4.3 they added the "error" function
+- * attribute just for this type of case.  Thus, we use a negative sized array
+- * (should always create an error on gcc versions older than 4.4) and then call
+- * an undefined function with the error attribute (should always create an
+- * error on gcc 4.3 and later).  If for some reason, neither creates a
+- * compile-time error, we'll still have a link-time error, which is harder to
+- * track down.
+- */
+-#ifndef __OPTIMIZE__
+-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+-#else
+-#define BUILD_BUG_ON(condition) \
+-	BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
+-#endif
+-
+-/**
+- * BUILD_BUG - break compile if used.
+- *
+- * If you have some code that you expect the compiler to eliminate at
+- * build time, you should use BUILD_BUG to detect if it is
+- * unexpectedly used.
+- */
+-#define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
+-
+ #define MAYBE_BUILD_BUG_ON(cond)			\
+ 	do {						\
+ 		if (__builtin_constant_p((cond)))       \
+diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h
+new file mode 100644
+index 0000000000000..b7d22d60008a9
+--- /dev/null
++++ b/include/linux/build_bug.h
+@@ -0,0 +1,84 @@
++#ifndef _LINUX_BUILD_BUG_H
++#define _LINUX_BUILD_BUG_H
++
++#include <linux/compiler.h>
++
++#ifdef __CHECKER__
++#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) (0)
++#define BUILD_BUG_ON_NOT_POWER_OF_2(n) (0)
++#define BUILD_BUG_ON_ZERO(e) (0)
++#define BUILD_BUG_ON_NULL(e) ((void *)0)
++#define BUILD_BUG_ON_INVALID(e) (0)
++#define BUILD_BUG_ON_MSG(cond, msg) (0)
++#define BUILD_BUG_ON(condition) (0)
++#define BUILD_BUG() (0)
++#else /* __CHECKER__ */
++
++/* Force a compilation error if a constant expression is not a power of 2 */
++#define __BUILD_BUG_ON_NOT_POWER_OF_2(n)	\
++	BUILD_BUG_ON(((n) & ((n) - 1)) != 0)
++#define BUILD_BUG_ON_NOT_POWER_OF_2(n)			\
++	BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
++
++/*
++ * Force a compilation error if condition is true, but also produce a
++ * result (of value 0 and type size_t), so the expression can be used
++ * e.g. in a structure initializer (or where-ever else comma expressions
++ * aren't permitted).
++ */
++#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
++#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:(-!!(e)); }))
++
++/*
++ * BUILD_BUG_ON_INVALID() permits the compiler to check the validity of the
++ * expression but avoids the generation of any code, even if that expression
++ * has side-effects.
++ */
++#define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
++
++/**
++ * BUILD_BUG_ON_MSG - break compile if a condition is true & emit supplied
++ *		      error message.
++ * @condition: the condition which the compiler should know is false.
++ *
++ * See BUILD_BUG_ON for description.
++ */
++#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
++
++/**
++ * BUILD_BUG_ON - break compile if a condition is true.
++ * @condition: the condition which the compiler should know is false.
++ *
++ * If you have some code which relies on certain constants being equal, or
++ * some other compile-time-evaluated condition, you should use BUILD_BUG_ON to
++ * detect if someone changes it.
++ *
++ * The implementation uses gcc's reluctance to create a negative array, but gcc
++ * (as of 4.4) only emits that error for obvious cases (e.g. not arguments to
++ * inline functions).  Luckily, in 4.3 they added the "error" function
++ * attribute just for this type of case.  Thus, we use a negative sized array
++ * (should always create an error on gcc versions older than 4.4) and then call
++ * an undefined function with the error attribute (should always create an
++ * error on gcc 4.3 and later).  If for some reason, neither creates a
++ * compile-time error, we'll still have a link-time error, which is harder to
++ * track down.
++ */
++#ifndef __OPTIMIZE__
++#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
++#else
++#define BUILD_BUG_ON(condition) \
++	BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
++#endif
++
++/**
++ * BUILD_BUG - break compile if used.
++ *
++ * If you have some code that you expect the compiler to eliminate at
++ * build time, you should use BUILD_BUG to detect if it is
++ * unexpectedly used.
++ */
++#define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
++
++#endif	/* __CHECKER__ */
++
++#endif	/* _LINUX_BUILD_BUG_H */
+diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
+index e8bd8de856de9..01c646a1d9e76 100644
+--- a/kernel/trace/trace.c
++++ b/kernel/trace/trace.c
+@@ -2354,7 +2354,7 @@ struct trace_buffer_struct {
+ 	char buffer[4][TRACE_BUF_SIZE];
+ };
+ 
+-static struct trace_buffer_struct *trace_percpu_buffer;
++static struct trace_buffer_struct __percpu *trace_percpu_buffer;
+ 
+ /*
+  * Thise allows for lockless recording.  If we're nested too deeply, then
+@@ -2364,7 +2364,7 @@ static char *get_trace_buf(void)
+ {
+ 	struct trace_buffer_struct *buffer = this_cpu_ptr(trace_percpu_buffer);
+ 
+-	if (!buffer || buffer->nesting >= 4)
++	if (!trace_percpu_buffer || buffer->nesting >= 4)
+ 		return NULL;
+ 
+ 	buffer->nesting++;
+@@ -2383,7 +2383,7 @@ static void put_trace_buf(void)
+ 
+ static int alloc_percpu_trace_buffer(void)
+ {
+-	struct trace_buffer_struct *buffers;
++	struct trace_buffer_struct __percpu *buffers;
+ 
+ 	buffers = alloc_percpu(struct trace_buffer_struct);
+ 	if (WARN(!buffers, "Could not allocate percpu trace_printk buffer"))
+diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
+index 860ab2e6544cc..8770966a564b5 100644
+--- a/net/ipv4/udp.c
++++ b/net/ipv4/udp.c
+@@ -2435,7 +2435,7 @@ int udp4_seq_show(struct seq_file *seq, void *v)
+ {
+ 	seq_setwidth(seq, 127);
+ 	if (v == SEQ_START_TOKEN)
+-		seq_puts(seq, "  sl  local_address rem_address   st tx_queue "
++		seq_puts(seq, "   sl  local_address rem_address   st tx_queue "
+ 			   "rx_queue tr tm->when retrnsmt   uid  timeout "
+ 			   "inode ref pointer drops");
+ 	else {
+diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
+index f58d69216b616..ce5b55491942d 100644
+--- a/net/ipv6/ip6_vti.c
++++ b/net/ipv6/ip6_vti.c
+@@ -773,6 +773,8 @@ vti6_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+ 	struct net *net = dev_net(dev);
+ 	struct vti6_net *ip6n = net_generic(net, vti6_net_id);
+ 
++	memset(&p1, 0, sizeof(p1));
++
+ 	switch (cmd) {
+ 	case SIOCGETTUNNEL:
+ 		if (dev == ip6n->fb_tnl_dev) {
+diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
+index 3217c98f2b5a2..56c58ff8ef748 100644
+--- a/net/mac80211/mlme.c
++++ b/net/mac80211/mlme.c
+@@ -4450,7 +4450,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
+ 
+ 	if (new_sta) {
+ 		u32 rates = 0, basic_rates = 0;
+-		bool have_higher_than_11mbit;
++		bool have_higher_than_11mbit = false;
+ 		int min_rate = INT_MAX, min_rate_index = -1;
+ 		struct ieee80211_chanctx_conf *chanctx_conf;
+ 		const struct cfg80211_bss_ies *ies;
+diff --git a/net/phonet/pep.c b/net/phonet/pep.c
+index 1e7945df39928..a734d47c5eb19 100644
+--- a/net/phonet/pep.c
++++ b/net/phonet/pep.c
+@@ -878,6 +878,7 @@ static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp)
+ 
+ 	err = pep_accept_conn(newsk, skb);
+ 	if (err) {
++		__sock_put(sk);
+ 		sock_put(newsk);
+ 		newsk = NULL;
+ 		goto drop;
+diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
+index ca0516e6f7435..fd48a1e327d6a 100644
+--- a/net/sched/sch_qfq.c
++++ b/net/sched/sch_qfq.c
+@@ -1439,10 +1439,8 @@ static int qfq_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
+ 	if (err < 0)
+ 		return err;
+ 
+-	if (qdisc_dev(sch)->tx_queue_len + 1 > QFQ_MAX_AGG_CLASSES)
+-		max_classes = QFQ_MAX_AGG_CLASSES;
+-	else
+-		max_classes = qdisc_dev(sch)->tx_queue_len + 1;
++	max_classes = min_t(u64, (u64)qdisc_dev(sch)->tx_queue_len + 1,
++			    QFQ_MAX_AGG_CLASSES);
+ 	/* max_cl_shift = floor(log_2(max_classes)) */
+ 	max_cl_shift = __fls(max_classes);
+ 	q->max_agg_classes = 1<<max_cl_shift;
-- 
cgit v1.2.3-65-gdbad