diff --git a/linux-5.10/rk3568_patch/kernel.patch b/linux-5.10/rk3568_patch/kernel.patch index 3b42aa45083b0ab422b60bb89660bdb839a98927..9f2f61e6b65c8d69227c444d74ca518ea3315439 100644 --- a/linux-5.10/rk3568_patch/kernel.patch +++ b/linux-5.10/rk3568_patch/kernel.patch @@ -456,7 +456,7 @@ index 7f94669e9..346e466c2 100644 region. - interrupts : The interrupt number to the cpu. The interrupt specifier format diff --git a/Makefile b/Makefile -index 8ae72cc7d..ba3d542a9 100644 +index 77a916d2b..3def27a50 100644 --- a/Makefile +++ b/Makefile @@ -494,7 +494,7 @@ LINUXINCLUDE := \ @@ -90717,7 +90717,7 @@ index 000000000..489967f13 +}; diff --git a/arch/arm64/boot/dts/rockchip/rk3568-linux.dtsi b/arch/arm64/boot/dts/rockchip/rk3568-linux.dtsi new file mode 100755 -index 000000000..9f346dc7e +index 000000000..295f9bdb5 --- /dev/null +++ b/arch/arm64/boot/dts/rockchip/rk3568-linux.dtsi @@ -0,0 +1,60 @@ @@ -103601,10 +103601,10 @@ index 4999caff3..b47d477f4 100644 * UpdateCapsule() depends on the system being reset via * ResetSystem(). diff --git a/drivers/Kconfig b/drivers/Kconfig -index 12e0cceac..e683e9f1e 100644 +index 3584901f1..753f7ba51 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig -@@ -244,4 +244,7 @@ source "drivers/accesstokenid/Kconfig" +@@ -242,4 +242,7 @@ source "drivers/accesstokenid/Kconfig" source "drivers/hooks/Kconfig" @@ -103613,10 +103613,10 @@ index 12e0cceac..e683e9f1e 100644 +source "drivers/rk_nand/Kconfig" endmenu diff --git a/drivers/Makefile b/drivers/Makefile -index 8ec75883a..5ffe117f9 100644 +index f13d70df6..3ec690272 100644 --- a/drivers/Makefile +++ b/drivers/Makefile -@@ -195,3 +195,5 @@ obj-$(CONFIG_DRIVERS_HDF) += hdf/ +@@ -194,3 +194,5 @@ obj-$(CONFIG_COUNTER) += counter/ obj-$(CONFIG_MOST) += most/ obj-$(CONFIG_ACCESS_TOKENID) += accesstokenid/ obj-$(CONFIG_VENDOR_HOOKS) += hooks/ @@ -119815,7 +119815,7 @@ index e363ae04a..f1327e7fe 100644 list_del(&priv->node); } diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c -index ebee0ad55..56fecf202 100644 +index 8e159fb6a..ffe4eec2d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -688,8 +688,12 @@ static ssize_t show_##file_name \ @@ -119832,7 +119832,7 @@ index ebee0ad55..56fecf202 100644 show_one(cpuinfo_transition_latency, cpuinfo.transition_latency); show_one(scaling_min_freq, min); show_one(scaling_max_freq, max); -@@ -2536,6 +2540,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, +@@ -2535,6 +2539,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, return ret; } @@ -929772,7 +929772,7 @@ index 000000000..796b678cb +MODULE_DESCRIPTION("Rockchip Nand Flash Controller Driver"); +MODULE_ALIAS("platform:rockchip-nand-controller"); diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c -index da1d185f6..404cbf60d 100644 +index 65b9e5846..7b25d960d 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c @@ -559,11 +559,6 @@ int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self, @@ -931464,7 +931464,7 @@ index 000000000..d71989b0f +#endif /* __DWMAC_RK_TOOL_H__ */ + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c -index 6ef30252b..bb0c0e44b 100644 +index e7fbc9b30..0fac2a260 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -11,6 +11,7 @@ @@ -1578548,7 +1578548,7 @@ index 000000000..8bef3d728 +obj-$(CONFIG_BLACKBOX_STORAGE_BY_MEMORY) += system_adapter_by_memory.o diff --git a/drivers/staging/blackbox/rockchip/system_adapter.c b/drivers/staging/blackbox/rockchip/system_adapter.c new file mode 100644 -index 000000000..77bf90b9a +index 000000000..7dae3e6a4 --- /dev/null +++ b/drivers/staging/blackbox/rockchip/system_adapter.c @@ -0,0 +1,314 @@ @@ -1578868,7 +1578868,7 @@ index 000000000..77bf90b9a +MODULE_AUTHOR("OHOS"); diff --git a/drivers/staging/blackbox/rockchip/system_adapter_by_memory.c b/drivers/staging/blackbox/rockchip/system_adapter_by_memory.c new file mode 100644 -index 000000000..f52ba07ae +index 000000000..8567156f8 --- /dev/null +++ b/drivers/staging/blackbox/rockchip/system_adapter_by_memory.c @@ -0,0 +1,315 @@ @@ -1580151,10 +1580151,10 @@ index aa9e0e31e..e1c667e8f 100644 module_platform_driver(rockchip_thermal_driver); diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c -index 17de8a9b9..c83fb45e1 100644 +index d9e34ac37..595046139 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c -@@ -540,6 +540,7 @@ int thermal_zone_device_is_enabled(struct thermal_zone_device *tz) +@@ -542,6 +542,7 @@ int thermal_zone_device_is_enabled(struct thermal_zone_device *tz) return mode == THERMAL_DEVICE_ENABLED; } @@ -1580775,7 +1580775,7 @@ index 6d6a78eea..fee4f2933 100644 } diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c -index 110a19c51..dd41c694c 100644 +index 7c07ebb37..1ad77505b 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1567,8 +1567,13 @@ static inline void __start_tx(struct uart_port *port) @@ -1580878,7 +1580878,7 @@ index 110a19c51..dd41c694c 100644 uart_unlock_and_check_sysrq(port, flags); return 1; } -@@ -2412,7 +2460,11 @@ int serial8250_do_startup(struct uart_port *port) +@@ -2405,7 +2453,11 @@ int serial8250_do_startup(struct uart_port *port) if (uart_console(port)) msg = "forbid DMA for kernel console"; else if (serial8250_request_dma(up)) @@ -1580890,7 +1580890,7 @@ index 110a19c51..dd41c694c 100644 if (msg) { dev_warn_ratelimited(port->dev, "%s\n", msg); up->dma = NULL; -@@ -2606,6 +2658,10 @@ void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud, +@@ -2599,6 +2651,10 @@ void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud, { struct uart_8250_port *up = up_to_u8250p(port); @@ -1580901,7 +1580901,7 @@ index 110a19c51..dd41c694c 100644 /* Workaround to enable 115200 baud on OMAP1510 internal ports */ if (is_omap1510_8250(up)) { if (baud == 115200) { -@@ -2625,6 +2681,17 @@ void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud, +@@ -2618,6 +2674,17 @@ void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud, serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); serial_dl_write(up, quot); @@ -1580919,7 +1580919,7 @@ index 110a19c51..dd41c694c 100644 } EXPORT_SYMBOL_GPL(serial8250_do_set_divisor); -@@ -2804,6 +2871,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, +@@ -2797,6 +2864,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, if ((termios->c_cflag & CREAD) == 0) port->ignore_status_mask |= UART_LSR_DR; @@ -1580927,7 +1580927,7 @@ index 110a19c51..dd41c694c 100644 /* * CTS flow control flag and modem status interrupts */ -@@ -2817,6 +2885,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, +@@ -2810,6 +2878,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, up->ier |= UART_IER_RTOIE; serial_port_out(port, UART_IER, up->ier); @@ -1580935,7 +1580935,7 @@ index 110a19c51..dd41c694c 100644 if (up->capabilities & UART_CAP_EFR) { unsigned char efr = 0; -@@ -2835,16 +2904,25 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, +@@ -2828,16 +2897,25 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, serial_port_out(port, UART_EFR, efr); } @@ -1580963,7 +1580963,7 @@ index 110a19c51..dd41c694c 100644 if (port->type != PORT_16750) { /* emulated UARTs (Lucent Venus 167x) need two steps */ if (up->fcr & UART_FCR_ENABLE_FIFO) -@@ -2852,6 +2930,23 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, +@@ -2845,6 +2923,23 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, serial_port_out(port, UART_FCR, up->fcr); /* set fcr */ } serial8250_set_mctrl(port, port->mctrl); @@ -1580987,6 +1580987,18 @@ index 110a19c51..dd41c694c 100644 spin_unlock_irqrestore(&port->lock, flags); serial8250_rpm_put(up); +diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c +index 78acc270e..6314498de 100644 +--- a/drivers/tty/vt/keyboard.c ++++ b/drivers/tty/vt/keyboard.c +@@ -488,6 +488,7 @@ static void fn_hold(struct vc_data *vc) + { + struct tty_struct *tty = vc->port.tty; + ++ chg_vc_kbd_led(kbd, VC_SCROLLOCK); + if (rep || !tty) + return; + diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c old mode 100644 new mode 100755 @@ -1581238,7 +1581250,7 @@ index 1c2c04079..fc3341f2b diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c old mode 100644 new mode 100755 -index 95a9bae72..c1395d568 +index 3f406519d..6f5f89f5f --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1826,7 +1826,8 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -1581251,7 +1581263,7 @@ index 95a9bae72..c1395d568 } else { /* root hub */ const struct hc_driver *drv = bus_to_hcd(hdev->bus)->driver; -@@ -5322,7 +5323,8 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, +@@ -5331,7 +5332,8 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, done: hub_port_disable(hub, port1, 1); if (hcd->driver->relinquish_port && !hub->hdev->parent) { @@ -1581262,7 +1581274,7 @@ index 95a9bae72..c1395d568 } } diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c -index a54a735b6..8b1f40384 100644 +index 61f686c5b..3f7ca3dc3 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -322,6 +322,10 @@ static const struct usb_device_id usb_quirk_list[] = { @@ -1581314,10 +1581326,10 @@ index 641e4251c..03c68ba22 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c old mode 100644 new mode 100755 -index 7207a36c6..46ad220e4 +index 449f19c36..dd86059a8 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c -@@ -4518,6 +4518,14 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget, +@@ -4529,6 +4529,14 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget, goto err; } @@ -1581332,7 +1581344,7 @@ index 7207a36c6..46ad220e4 if (!IS_ERR_OR_NULL(hsotg->uphy)) otg_set_peripheral(hsotg->uphy->otg, &hsotg->gadget); -@@ -4577,6 +4585,11 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget) +@@ -4588,6 +4596,11 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget) if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) dwc2_lowlevel_hw_disable(hsotg); @@ -1581509,7 +1581521,7 @@ index d5f4ec1b7..4989ec761 diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c old mode 100644 new mode 100755 -index 68bbac64b..9d2b92a37 +index 94af71e98..b2e0721a3 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c @@ -730,8 +730,14 @@ static int dwc2_uframe_schedule_split(struct dwc2_hsotg *hsotg, @@ -1583287,10 +1583299,10 @@ index 3cd294264..658739410 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c old mode 100644 new mode 100755 -index 8b236394a..c9b5fbd55 +index e9a87e1f4..2138b3627 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c -@@ -405,6 +405,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd, +@@ -416,6 +416,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd, return ret; } @@ -1583298,7 +1583310,7 @@ index 8b236394a..c9b5fbd55 static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep) { -@@ -628,8 +629,192 @@ static int dwc3_gadget_set_ep_config(struct dwc3_ep *dep, unsigned int action) +@@ -639,8 +640,192 @@ static int dwc3_gadget_set_ep_config(struct dwc3_ep *dep, unsigned int action) return dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETEPCONFIG, ¶ms); } @@ -1583493,7 +1583505,7 @@ index 8b236394a..c9b5fbd55 /** * __dwc3_gadget_ep_enable - initializes a hw endpoint -@@ -648,6 +833,10 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action) +@@ -659,6 +844,10 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action) int ret; if (!(dep->flags & DWC3_EP_ENABLED)) { @@ -1583504,7 +1583516,7 @@ index 8b236394a..c9b5fbd55 ret = dwc3_gadget_start_config(dep); if (ret) return ret; -@@ -730,8 +919,16 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action) +@@ -741,8 +930,16 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action) * All stream eps will reinitiate stream on NoStream * rejection until we can determine that the host can * prime after the first transfer. @@ -1583522,7 +1583534,7 @@ index 8b236394a..c9b5fbd55 } } -@@ -802,7 +999,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) +@@ -813,7 +1010,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) dep->stream_capable = false; dep->type = 0; @@ -1583531,7 +1583543,7 @@ index 8b236394a..c9b5fbd55 return 0; } -@@ -1404,7 +1601,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep) +@@ -1415,7 +1612,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep) dwc3_stop_active_transfer(dep, true, true); list_for_each_entry_safe(req, tmp, &dep->started_list, list) @@ -1583540,7 +1583552,7 @@ index 8b236394a..c9b5fbd55 /* If ep isn't started, then there's no end transfer pending */ if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) -@@ -1620,7 +1817,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) +@@ -1631,7 +1828,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) struct dwc3 *dwc = dep->dwc; if (!dep->endpoint.desc || !dwc->pullups_connected || !dwc->connected) { @@ -1583549,7 +1583561,7 @@ index 8b236394a..c9b5fbd55 dep->name); return -ESHUTDOWN; } -@@ -1733,10 +1930,25 @@ static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) +@@ -1744,10 +1941,25 @@ static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) { struct dwc3_request *req; struct dwc3_request *tmp; @@ -1583576,7 +1583588,7 @@ index 8b236394a..c9b5fbd55 } } -@@ -1780,7 +1992,8 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, +@@ -1791,7 +2003,8 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, * cancelled. */ list_for_each_entry_safe(r, t, &dep->started_list, list) @@ -1583586,7 +1583598,7 @@ index 8b236394a..c9b5fbd55 dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE; -@@ -1801,8 +2014,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) +@@ -1812,8 +2025,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) { struct dwc3_gadget_ep_cmd_params params; struct dwc3 *dwc = dep->dwc; @@ -1583595,7 +1583607,7 @@ index 8b236394a..c9b5fbd55 int ret; if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { -@@ -1851,16 +2062,14 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) +@@ -1862,16 +2073,14 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) dwc3_stop_active_transfer(dep, true, true); @@ -1583614,7 +1583626,7 @@ index 8b236394a..c9b5fbd55 ret = dwc3_send_clear_stall_ep_cmd(dep); if (ret) { dev_err(dwc->dev, "failed to clear STALL on %s\n", -@@ -2059,6 +2268,102 @@ static void dwc3_stop_active_transfers(struct dwc3 *dwc) +@@ -2070,6 +2279,102 @@ static void dwc3_stop_active_transfers(struct dwc3 *dwc) } } @@ -1583717,7 +1583729,7 @@ index 8b236394a..c9b5fbd55 static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) { u32 reg; -@@ -2081,6 +2386,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) +@@ -2092,6 +2397,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) if (dwc->has_hibernation) reg |= DWC3_DCTL_KEEP_CONNECT; @@ -1583725,7 +1583737,7 @@ index 8b236394a..c9b5fbd55 dwc->pullups_connected = true; } else { reg &= ~DWC3_DCTL_RUN_STOP; -@@ -2111,10 +2417,12 @@ static int __dwc3_gadget_start(struct dwc3 *dwc); +@@ -2122,10 +2428,12 @@ static int __dwc3_gadget_start(struct dwc3 *dwc); static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) { struct dwc3 *dwc = gadget_to_dwc(g); @@ -1583738,7 +1583750,7 @@ index 8b236394a..c9b5fbd55 /* * Per databook, when we want to stop the gadget, if a control transfer -@@ -2205,8 +2513,7 @@ static void dwc3_gadget_enable_irq(struct dwc3 *dwc) +@@ -2216,8 +2524,7 @@ static void dwc3_gadget_enable_irq(struct dwc3 *dwc) u32 reg; /* Enable all but Start and End of Frame IRQs */ @@ -1583748,7 +1583760,7 @@ index 8b236394a..c9b5fbd55 DWC3_DEVTEN_CMDCMPLTEN | DWC3_DEVTEN_ERRTICERREN | DWC3_DEVTEN_WKUPEVTEN | -@@ -2219,7 +2526,7 @@ static void dwc3_gadget_enable_irq(struct dwc3 *dwc) +@@ -2230,7 +2537,7 @@ static void dwc3_gadget_enable_irq(struct dwc3 *dwc) /* On 2.30a and above this bit enables U3/L2-L1 Suspend Events */ if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) @@ -1583757,7 +1583769,7 @@ index 8b236394a..c9b5fbd55 dwc3_writel(dwc->regs, DWC3_DEVTEN, reg); } -@@ -2262,9 +2569,7 @@ static void dwc3_gadget_setup_nump(struct dwc3 *dwc) +@@ -2273,9 +2580,7 @@ static void dwc3_gadget_setup_nump(struct dwc3 *dwc) u32 reg; ram2_depth = DWC3_GHWPARAMS7_RAM2_DEPTH(dwc->hwparams.hwparams7); @@ -1583768,7 +1583780,7 @@ index 8b236394a..c9b5fbd55 nump = ((ram2_depth * mdwidth / 8) - 24 - 16) / 1024; nump = min_t(u32, nump, 16); -@@ -2282,6 +2587,15 @@ static int __dwc3_gadget_start(struct dwc3 *dwc) +@@ -2293,6 +2598,15 @@ static int __dwc3_gadget_start(struct dwc3 *dwc) int ret = 0; u32 reg; @@ -1583784,7 +1583796,7 @@ index 8b236394a..c9b5fbd55 /* * Use IMOD if enabled via dwc->imod_interval. Otherwise, if * the core supports IMOD, disable it. -@@ -2310,6 +2624,17 @@ static int __dwc3_gadget_start(struct dwc3 *dwc) +@@ -2321,6 +2635,17 @@ static int __dwc3_gadget_start(struct dwc3 *dwc) dwc3_gadget_setup_nump(dwc); @@ -1583802,7 +1583814,7 @@ index 8b236394a..c9b5fbd55 /* Start with SuperSpeed Default */ dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); -@@ -2397,6 +2722,7 @@ static int dwc3_gadget_stop(struct usb_gadget *g) +@@ -2408,6 +2733,7 @@ static int dwc3_gadget_stop(struct usb_gadget *g) spin_lock_irqsave(&dwc->lock, flags); dwc->gadget_driver = NULL; @@ -1583810,7 +1583822,7 @@ index 8b236394a..c9b5fbd55 spin_unlock_irqrestore(&dwc->lock, flags); free_irq(dwc->irq_gadget, dwc->ev_buf); -@@ -2448,59 +2774,94 @@ static void dwc3_gadget_set_speed(struct usb_gadget *g, +@@ -2459,59 +2785,94 @@ static void dwc3_gadget_set_speed(struct usb_gadget *g, { struct dwc3 *dwc = gadget_to_dwc(g); unsigned long flags; @@ -1583952,7 +1583964,7 @@ index 8b236394a..c9b5fbd55 spin_unlock_irqrestore(&dwc->lock, flags); } -@@ -2512,7 +2873,11 @@ static const struct usb_gadget_ops dwc3_gadget_ops = { +@@ -2523,7 +2884,11 @@ static const struct usb_gadget_ops dwc3_gadget_ops = { .udc_start = dwc3_gadget_start, .udc_stop = dwc3_gadget_stop, .udc_set_speed = dwc3_gadget_set_speed, @@ -1583964,7 +1583976,7 @@ index 8b236394a..c9b5fbd55 }; /* -------------------------------------------------------------------------- */ -@@ -2535,12 +2900,10 @@ static int dwc3_gadget_init_control_endpoint(struct dwc3_ep *dep) +@@ -2546,12 +2911,10 @@ static int dwc3_gadget_init_control_endpoint(struct dwc3_ep *dep) static int dwc3_gadget_init_in_endpoint(struct dwc3_ep *dep) { struct dwc3 *dwc = dep->dwc; @@ -1583979,7 +1583991,7 @@ index 8b236394a..c9b5fbd55 /* MDWIDTH is represented in bits, we need it in bytes */ mdwidth /= 8; -@@ -2582,12 +2945,10 @@ static int dwc3_gadget_init_in_endpoint(struct dwc3_ep *dep) +@@ -2593,12 +2956,10 @@ static int dwc3_gadget_init_in_endpoint(struct dwc3_ep *dep) static int dwc3_gadget_init_out_endpoint(struct dwc3_ep *dep) { struct dwc3 *dwc = dep->dwc; @@ -1583994,7 +1584006,7 @@ index 8b236394a..c9b5fbd55 /* MDWIDTH is represented in bits, convert to bytes */ mdwidth /= 8; -@@ -2880,6 +3241,11 @@ static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep, +@@ -2891,6 +3252,11 @@ static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep, static bool dwc3_gadget_ep_should_continue(struct dwc3_ep *dep) { struct dwc3_request *req; @@ -1584006,27 +1584018,27 @@ index 8b236394a..c9b5fbd55 if (!list_empty(&dep->pending_list)) return true; -@@ -2907,6 +3273,9 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep, +@@ -2918,6 +3284,9 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep, struct dwc3 *dwc = dep->dwc; bool no_started_trb = true; + if (!dep->endpoint.desc) + return no_started_trb; + - dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); + if (!dep->endpoint.desc) + return no_started_trb; - if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) -@@ -2954,6 +3323,9 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep, +@@ -2968,6 +3337,9 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep, { int status = 0; + if (!dep->endpoint.desc) + return; + - if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) - dwc3_gadget_endpoint_frame_from_event(dep, event); + if (!dep->endpoint.desc) + return; -@@ -3145,7 +3517,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, +@@ -3170,7 +3542,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, static void dwc3_disconnect_gadget(struct dwc3 *dwc) { @@ -1584035,7 +1584047,7 @@ index 8b236394a..c9b5fbd55 spin_unlock(&dwc->lock); dwc->gadget_driver->disconnect(dwc->gadget); spin_lock(&dwc->lock); -@@ -3154,7 +3526,7 @@ static void dwc3_disconnect_gadget(struct dwc3 *dwc) +@@ -3179,7 +3551,7 @@ static void dwc3_disconnect_gadget(struct dwc3 *dwc) static void dwc3_suspend_gadget(struct dwc3 *dwc) { @@ -1584044,7 +1584056,7 @@ index 8b236394a..c9b5fbd55 spin_unlock(&dwc->lock); dwc->gadget_driver->suspend(dwc->gadget); spin_lock(&dwc->lock); -@@ -3163,7 +3535,7 @@ static void dwc3_suspend_gadget(struct dwc3 *dwc) +@@ -3188,7 +3560,7 @@ static void dwc3_suspend_gadget(struct dwc3 *dwc) static void dwc3_resume_gadget(struct dwc3 *dwc) { @@ -1584053,7 +1584065,7 @@ index 8b236394a..c9b5fbd55 spin_unlock(&dwc->lock); dwc->gadget_driver->resume(dwc->gadget); spin_lock(&dwc->lock); -@@ -3175,14 +3547,14 @@ static void dwc3_reset_gadget(struct dwc3 *dwc) +@@ -3200,14 +3572,14 @@ static void dwc3_reset_gadget(struct dwc3 *dwc) if (!dwc->gadget_driver) return; @@ -1584070,7 +1584082,7 @@ index 8b236394a..c9b5fbd55 bool interrupt) { struct dwc3_gadget_ep_cmd_params params; -@@ -3242,6 +3614,7 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, +@@ -3259,6 +3631,7 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, else dep->flags |= DWC3_EP_END_TRANSFER_PENDING; } @@ -1584078,7 +1584090,7 @@ index 8b236394a..c9b5fbd55 static void dwc3_clear_stall_all_ep(struct dwc3 *dwc) { -@@ -3356,12 +3729,18 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) +@@ -3373,12 +3746,18 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) struct dwc3_ep *dep; int ret; u32 reg; @@ -1584097,7 +1584109,7 @@ index 8b236394a..c9b5fbd55 /* * RAMClkSel is reset to 0 after USB reset, so it must be reprogrammed * each time on Connect Done. -@@ -3376,6 +3755,11 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) +@@ -3393,6 +3772,11 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); dwc->gadget->ep0->maxpacket = 512; dwc->gadget->speed = USB_SPEED_SUPER_PLUS; @@ -1584109,7 +1584121,7 @@ index 8b236394a..c9b5fbd55 break; case DWC3_DSTS_SUPERSPEED: /* -@@ -3397,6 +3781,11 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) +@@ -3414,6 +3798,11 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); dwc->gadget->ep0->maxpacket = 512; dwc->gadget->speed = USB_SPEED_SUPER; @@ -1584121,7 +1584133,7 @@ index 8b236394a..c9b5fbd55 break; case DWC3_DSTS_HIGHSPEED: dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64); -@@ -3488,7 +3877,7 @@ static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc) +@@ -3505,7 +3894,7 @@ static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc) * implemented. */ @@ -1584130,7 +1584142,7 @@ index 8b236394a..c9b5fbd55 spin_unlock(&dwc->lock); dwc->gadget_driver->resume(dwc->gadget); spin_lock(&dwc->lock); -@@ -3656,7 +4045,7 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc, +@@ -3671,7 +4060,7 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc, case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE: dwc3_gadget_linksts_change_interrupt(dwc, event->event_info); break; @@ -1584139,7 +1584151,7 @@ index 8b236394a..c9b5fbd55 /* It changed to be suspend event for version 2.30a and above */ if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) { /* -@@ -3900,6 +4289,7 @@ int dwc3_gadget_init(struct dwc3 *dwc) +@@ -3915,6 +4304,7 @@ int dwc3_gadget_init(struct dwc3 *dwc) dev->platform_data = dwc; dwc->gadget->ops = &dwc3_gadget_ops; dwc->gadget->speed = USB_SPEED_UNKNOWN; @@ -1584147,7 +1584159,7 @@ index 8b236394a..c9b5fbd55 dwc->gadget->sg_supported = true; dwc->gadget->name = "dwc3-gadget"; dwc->gadget->lpm_capable = !dwc->usb2_gadget_lpm_disable; -@@ -3926,6 +4316,7 @@ int dwc3_gadget_init(struct dwc3 *dwc) +@@ -3941,6 +4331,7 @@ int dwc3_gadget_init(struct dwc3 *dwc) dwc->revision); dwc->gadget->max_speed = dwc->maximum_speed; @@ -1584155,7 +1584167,7 @@ index 8b236394a..c9b5fbd55 /* * REVISIT: Here we should clear all pending IRQs to be -@@ -3942,7 +4333,10 @@ int dwc3_gadget_init(struct dwc3 *dwc) +@@ -3957,7 +4348,10 @@ int dwc3_gadget_init(struct dwc3 *dwc) goto err5; } @@ -1584167,7 +1584179,7 @@ index 8b236394a..c9b5fbd55 return 0; -@@ -3997,9 +4391,10 @@ int dwc3_gadget_suspend(struct dwc3 *dwc) +@@ -4012,9 +4406,10 @@ int dwc3_gadget_suspend(struct dwc3 *dwc) int dwc3_gadget_resume(struct dwc3 *dwc) { @@ -1590238,7 +1590250,7 @@ index 9a01a7d4f..3e92a28d8 100644 #endif /* U_UVC_H */ diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h -index 23ee25383..8fb61023d 100644 +index 893aaa70f..4ccbc3a83 100644 --- a/drivers/usb/gadget/function/uvc.h +++ b/drivers/usb/gadget/function/uvc.h @@ -14,6 +14,7 @@ @@ -1590819,7 +1590831,7 @@ index 61e2c94cc..3cc3da8ff 100644 if (ret) return ret; diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c -index 4ca89eab6..2528c8942 100644 +index 197c26f7a..10fab9220 100644 --- a/drivers/usb/gadget/function/uvc_v4l2.c +++ b/drivers/usb/gadget/function/uvc_v4l2.c @@ -41,6 +41,7 @@ uvc_send_response(struct uvc_device *uvc, struct uvc_request_data *data) @@ -1590865,7 +1590877,7 @@ index 4ca89eab6..2528c8942 100644 return 0; } -@@ -354,6 +367,9 @@ const struct v4l2_file_operations uvc_v4l2_fops = { +@@ -389,6 +402,9 @@ const struct v4l2_file_operations uvc_v4l2_fops = { .open = uvc_v4l2_open, .release = uvc_v4l2_release, .unlocked_ioctl = video_ioctl2, @@ -1592759,7 +1592771,7 @@ index 561d0b7bc..e726a5723 diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c old mode 100644 new mode 100755 -index 4512c4223..a937bc6db +index 667a37f50..dfbad4946 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -57,7 +57,10 @@ @@ -1592869,7 +1592881,7 @@ index 4512c4223..a937bc6db static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay) { -@@ -414,9 +440,8 @@ void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, +@@ -421,9 +447,8 @@ void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, trace_xhci_ring_ep_doorbell(slot_id, DB_VALUE(ep_index, stream_id)); writel(DB_VALUE(ep_index, stream_id), db_addr); @@ -1592881,7 +1592893,7 @@ index 4512c4223..a937bc6db } /* Ring the doorbell for any rings with pending URBs */ -@@ -472,6 +497,26 @@ static struct xhci_virt_ep *xhci_get_virt_ep(struct xhci_hcd *xhci, +@@ -479,6 +504,26 @@ static struct xhci_virt_ep *xhci_get_virt_ep(struct xhci_hcd *xhci, return &xhci->devs[slot_id]->eps[ep_index]; } @@ -1592908,7 +1592920,7 @@ index 4512c4223..a937bc6db /* Get the right ring for the given slot_id, ep_index and stream_id. * If the endpoint supports streams, boundary check the URB's stream ID. * If the endpoint doesn't support streams, return the singular endpoint ring. -@@ -486,29 +531,7 @@ struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, +@@ -493,29 +538,7 @@ struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, if (!ep) return NULL; @@ -1592939,7 +1592951,7 @@ index 4512c4223..a937bc6db } -@@ -535,97 +558,55 @@ static u64 xhci_get_hw_deq(struct xhci_hcd *xhci, struct xhci_virt_device *vdev, +@@ -542,97 +565,55 @@ static u64 xhci_get_hw_deq(struct xhci_hcd *xhci, struct xhci_virt_device *vdev, return le64_to_cpu(ep_ctx->deq); } @@ -1593059,7 +1593071,7 @@ index 4512c4223..a937bc6db /* * We want to find the pointer, segment and cycle state of the new trb -@@ -640,40 +621,71 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, +@@ -647,40 +628,71 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, if (td_last_trb_found) break; } @@ -1593147,7 +1593159,7 @@ index 4512c4223..a937bc6db } /* flip_cycle means flip the cycle bit of all but the first and last TRB. -@@ -766,153 +778,326 @@ static void xhci_unmap_td_bounce_buffer(struct xhci_hcd *xhci, +@@ -773,153 +785,326 @@ static void xhci_unmap_td_bounce_buffer(struct xhci_hcd *xhci, seg->bounce_offs = 0; } @@ -1593587,7 +1593599,7 @@ index 4512c4223..a937bc6db } static void xhci_kill_ring_urbs(struct xhci_hcd *xhci, struct xhci_ring *ring) -@@ -1126,10 +1311,10 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, +@@ -1133,10 +1318,10 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, unsigned int ep_index; unsigned int stream_id; struct xhci_ring *ep_ring; @@ -1593599,7 +1593611,7 @@ index 4512c4223..a937bc6db ep_index = TRB_TO_EP_INDEX(le32_to_cpu(trb->generic.field[3])); stream_id = TRB_TO_STREAM_ID(le32_to_cpu(trb->generic.field[2])); -@@ -1137,8 +1322,7 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, +@@ -1144,8 +1329,7 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, if (!ep) return; @@ -1593609,7 +1593621,7 @@ index 4512c4223..a937bc6db if (!ep_ring) { xhci_warn(xhci, "WARN Set TR deq ptr command for freed stream ID %u\n", stream_id); -@@ -1146,8 +1330,8 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, +@@ -1153,8 +1337,8 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, goto cleanup; } @@ -1593620,7 +1593632,7 @@ index 4512c4223..a937bc6db trace_xhci_handle_cmd_set_deq(slot_ctx); trace_xhci_handle_cmd_set_deq_ep(ep_ctx); -@@ -1200,7 +1384,7 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, +@@ -1207,7 +1391,7 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, /* Update the ring's dequeue segment and dequeue pointer * to reflect the new position. */ @@ -1593629,7 +1593641,7 @@ index 4512c4223..a937bc6db ep_ring, ep_index); } else { xhci_warn(xhci, "Mismatch between completed Set TR Deq Ptr command & xHCI internal state.\n"); -@@ -1208,7 +1392,15 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, +@@ -1215,7 +1399,15 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, ep->queued_deq_seg, ep->queued_deq_ptr); } } @@ -1593646,7 +1593658,7 @@ index 4512c4223..a937bc6db cleanup: ep->ep_state &= ~SET_DEQ_PENDING; ep->queued_deq_seg = NULL; -@@ -1220,7 +1412,6 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, +@@ -1227,7 +1419,6 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id, union xhci_trb *trb, u32 cmd_comp_code) { @@ -1593654,7 +1593666,7 @@ index 4512c4223..a937bc6db struct xhci_virt_ep *ep; struct xhci_ep_ctx *ep_ctx; unsigned int ep_index; -@@ -1230,8 +1421,7 @@ static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id, +@@ -1237,8 +1428,7 @@ static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id, if (!ep) return; @@ -1593664,7 +1593676,7 @@ index 4512c4223..a937bc6db trace_xhci_handle_cmd_reset_ep(ep_ctx); /* This command will only fail if the endpoint wasn't halted, -@@ -1240,27 +1430,15 @@ static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id, +@@ -1247,27 +1437,15 @@ static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id, xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep, "Ignoring reset ep completion code of %u", cmd_comp_code); @@ -1593699,7 +1593711,7 @@ index 4512c4223..a937bc6db /* if this was a soft reset, then restart */ if ((le32_to_cpu(trb->generic.field[3])) & TRB_TSP) -@@ -1295,7 +1473,7 @@ static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id) +@@ -1302,7 +1480,7 @@ static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id) } static void xhci_handle_cmd_config_ep(struct xhci_hcd *xhci, int slot_id, @@ -1593708,7 +1593720,7 @@ index 4512c4223..a937bc6db { struct xhci_virt_device *virt_dev; struct xhci_input_control_ctx *ctrl_ctx; -@@ -1313,6 +1491,8 @@ static void xhci_handle_cmd_config_ep(struct xhci_hcd *xhci, int slot_id, +@@ -1320,6 +1498,8 @@ static void xhci_handle_cmd_config_ep(struct xhci_hcd *xhci, int slot_id, * is not waiting on the configure endpoint command. */ virt_dev = xhci->devs[slot_id]; @@ -1593717,7 +1593729,7 @@ index 4512c4223..a937bc6db ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx); if (!ctrl_ctx) { xhci_warn(xhci, "Could not get input context, bad type.\n"); -@@ -1357,24 +1537,27 @@ static void xhci_handle_cmd_addr_dev(struct xhci_hcd *xhci, int slot_id) +@@ -1364,24 +1544,27 @@ static void xhci_handle_cmd_addr_dev(struct xhci_hcd *xhci, int slot_id) struct xhci_slot_ctx *slot_ctx; vdev = xhci->devs[slot_id]; @@ -1593750,7 +1593762,7 @@ index 4512c4223..a937bc6db } static void xhci_handle_cmd_nec_get_fw(struct xhci_hcd *xhci, -@@ -1467,7 +1650,7 @@ void xhci_handle_command_timeout(struct work_struct *work) +@@ -1474,7 +1657,7 @@ void xhci_handle_command_timeout(struct work_struct *work) static void handle_cmd_completion(struct xhci_hcd *xhci, struct xhci_event_cmd *event) { @@ -1593759,7 +1593771,7 @@ index 4512c4223..a937bc6db u64 cmd_dma; dma_addr_t cmd_dequeue_dma; u32 cmd_comp_code; -@@ -1475,6 +1658,11 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, +@@ -1482,6 +1665,11 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, struct xhci_command *cmd; u32 cmd_type; @@ -1593771,7 +1593783,7 @@ index 4512c4223..a937bc6db cmd_dma = le64_to_cpu(event->cmd_trb); cmd_trb = xhci->cmd_ring->dequeue; -@@ -1535,8 +1723,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, +@@ -1542,8 +1730,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, break; case TRB_CONFIG_EP: if (!cmd->completion) @@ -1593781,7 +1593793,7 @@ index 4512c4223..a937bc6db break; case TRB_EVAL_CONTEXT: break; -@@ -1547,7 +1734,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, +@@ -1554,7 +1741,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, WARN_ON(slot_id != TRB_TO_SLOT_ID( le32_to_cpu(cmd_trb->generic.field[3]))); if (!cmd->completion) @@ -1593791,7 +1593803,7 @@ index 4512c4223..a937bc6db break; case TRB_SET_DEQ: WARN_ON(slot_id != TRB_TO_SLOT_ID( -@@ -1570,7 +1758,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, +@@ -1577,7 +1765,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, */ slot_id = TRB_TO_SLOT_ID( le32_to_cpu(cmd_trb->generic.field[3])); @@ -1593800,7 +1593812,7 @@ index 4512c4223..a937bc6db break; case TRB_NEC_GET_FW: xhci_handle_cmd_nec_get_fw(xhci, event); -@@ -1597,11 +1785,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, +@@ -1604,11 +1792,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, } static void handle_vendor_event(struct xhci_hcd *xhci, @@ -1593813,7 +1593825,7 @@ index 4512c4223..a937bc6db xhci_dbg(xhci, "Vendor specific event TRB type = %u\n", trb_type); if (trb_type == TRB_NEC_CMD_COMP && (xhci->quirks & XHCI_NEC_HOST)) handle_cmd_completion(xhci, &event->event_cmd); -@@ -1918,37 +2103,6 @@ static void xhci_clear_hub_tt_buffer(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -1925,37 +2110,6 @@ static void xhci_clear_hub_tt_buffer(struct xhci_hcd *xhci, struct xhci_td *td, } } @@ -1593851,7 +1593863,7 @@ index 4512c4223..a937bc6db /* Check if an error has halted the endpoint ring. The class driver will * cleanup the halt for a non-default control endpoint if we indicate a stall. * However, a babble and other errors also halt the endpoint ring, and the class -@@ -1989,82 +2143,60 @@ int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code) +@@ -1996,82 +2150,60 @@ int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code) return 0; } @@ -1593981,7 +1593993,7 @@ index 4512c4223..a937bc6db /* * xhci internal endpoint state will go to a "halt" state for * any stall, including default control pipe protocol stall. -@@ -2075,18 +2207,24 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2082,18 +2214,24 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, * stall later. Hub TT buffer should only be cleared for FS/LS * devices behind HS hubs for functional stalls. */ @@ -1594015,7 +1594027,7 @@ index 4512c4223..a937bc6db } /* sum trb lengths from ring dequeue up to stop_trb, _excluding_ stop_trb */ -@@ -2107,23 +2245,17 @@ static int sum_trb_lengths(struct xhci_hcd *xhci, struct xhci_ring *ring, +@@ -2114,23 +2252,17 @@ static int sum_trb_lengths(struct xhci_hcd *xhci, struct xhci_ring *ring, /* * Process control tds, update urb status and actual_length. */ @@ -1594043,7 +1594055,7 @@ index 4512c4223..a937bc6db trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len)); requested = td->urb->transfer_buffer_length; remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); -@@ -2133,13 +2265,13 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2140,13 +2272,13 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, if (trb_type != TRB_STATUS) { xhci_warn(xhci, "WARN: Success on ctrl %s TRB without IOC set?\n", (trb_type == TRB_DATA) ? "data" : "setup"); @@ -1594060,7 +1594072,7 @@ index 4512c4223..a937bc6db break; case COMP_STOPPED_SHORT_PACKET: if (trb_type == TRB_DATA || trb_type == TRB_NORMAL) -@@ -2171,7 +2303,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2178,7 +2310,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, ep_ctx, trb_comp_code)) break; xhci_dbg(xhci, "TRB error %u, halted endpoint index = %u\n", @@ -1594069,7 +1594081,7 @@ index 4512c4223..a937bc6db fallthrough; case COMP_STALL_ERROR: /* Did we transfer part of the data (middle) phase? */ -@@ -2203,17 +2335,16 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2210,17 +2342,16 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, td->urb->actual_length = requested; finish_td: @@ -1594091,7 +1594103,7 @@ index 4512c4223..a937bc6db struct urb_priv *urb_priv; int idx; struct usb_iso_packet_descriptor *frame; -@@ -2222,7 +2353,6 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2229,7 +2360,6 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, u32 remaining, requested, ep_trb_len; int short_framestatus; @@ -1594099,7 +1594111,7 @@ index 4512c4223..a937bc6db trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len)); urb_priv = td->urb->hcpriv; idx = urb_priv->num_tds_done; -@@ -2283,26 +2413,23 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2290,26 +2420,23 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, } if (sum_trbs_for_length) @@ -1594129,7 +1594141,7 @@ index 4512c4223..a937bc6db urb_priv = td->urb->hcpriv; idx = urb_priv->num_tds_done; frame = &td->urb->iso_frame_desc[idx]; -@@ -2314,31 +2441,26 @@ static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2321,31 +2448,26 @@ static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, frame->actual_length = 0; /* Update ring dequeue pointer */ @@ -1594170,7 +1594182,7 @@ index 4512c4223..a937bc6db trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len)); remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); ep_trb_len = TRB_LEN(le32_to_cpu(ep_trb->generic.field[2])); -@@ -2354,13 +2476,13 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2361,13 +2483,13 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, td->urb->ep->desc.bEndpointAddress, requested, remaining); } @@ -1594186,7 +1594198,7 @@ index 4512c4223..a937bc6db break; case COMP_STOPPED_SHORT_PACKET: td->urb->actual_length = remaining; -@@ -2375,9 +2497,11 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2382,9 +2504,11 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, (ep_ring->err_count++ > MAX_SOFT_RETRY) || le32_to_cpu(slot_ctx->tt_info) & TT_SLOT) break; @@ -1594201,7 +1594213,7 @@ index 4512c4223..a937bc6db return 0; default: /* do nothing */ -@@ -2396,7 +2520,8 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2403,7 +2527,8 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, remaining); td->urb->actual_length = 0; } @@ -1594211,7 +1594223,7 @@ index 4512c4223..a937bc6db } /* -@@ -2407,7 +2532,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2414,7 +2539,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, static int handle_tx_event(struct xhci_hcd *xhci, struct xhci_transfer_event *event) { @@ -1594219,7 +1594231,7 @@ index 4512c4223..a937bc6db struct xhci_virt_ep *ep; struct xhci_ring *ep_ring; unsigned int slot_id; -@@ -2434,9 +2558,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2441,9 +2565,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, goto err_out; } @@ -1594230,7 +1594242,7 @@ index 4512c4223..a937bc6db if (GET_EP_CTX_STATE(ep_ctx) == EP_STATE_DISABLED) { xhci_err(xhci, -@@ -2452,8 +2575,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2459,8 +2582,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, case COMP_USB_TRANSACTION_ERROR: case COMP_INVALID_STREAM_TYPE_ERROR: case COMP_INVALID_STREAM_ID_ERROR: @@ -1594241,7 +1594253,7 @@ index 4512c4223..a937bc6db goto cleanup; case COMP_RING_UNDERRUN: case COMP_RING_OVERRUN: -@@ -2508,7 +2631,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2515,7 +2638,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, case COMP_STALL_ERROR: xhci_dbg(xhci, "Stalled endpoint for slot %u ep %u\n", slot_id, ep_index); @@ -1594249,7 +1594261,7 @@ index 4512c4223..a937bc6db status = -EPIPE; break; case COMP_SPLIT_TRANSACTION_ERROR: -@@ -2636,11 +2758,10 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2643,11 +2765,10 @@ static int handle_tx_event(struct xhci_hcd *xhci, if (trb_comp_code == COMP_STALL_ERROR || xhci_requires_manual_halt_cleanup(xhci, ep_ctx, trb_comp_code)) { @@ -1594265,7 +1594277,7 @@ index 4512c4223..a937bc6db } goto cleanup; } -@@ -2699,7 +2820,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2706,7 +2827,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, return -ESHUTDOWN; } @@ -1594274,7 +1594286,7 @@ index 4512c4223..a937bc6db goto cleanup; } if (trb_comp_code == COMP_SHORT_PACKET) -@@ -2727,25 +2848,26 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2734,25 +2855,26 @@ static int handle_tx_event(struct xhci_hcd *xhci, * endpoint. Otherwise, the endpoint remains stalled * indefinitely. */ @@ -1594309,7 +1594321,7 @@ index 4512c4223..a937bc6db cleanup: handling_skipped_tds = ep->skip && trb_comp_code != COMP_MISSED_SERVICE_ERROR && -@@ -2786,10 +2908,11 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2793,10 +2915,11 @@ static int handle_tx_event(struct xhci_hcd *xhci, * Returns >0 for "possibly more events to process" (caller should call again), * otherwise 0 if done. In future, <0 returns should indicate error code. */ @@ -1594322,7 +1594334,7 @@ index 4512c4223..a937bc6db int ret; /* Event ring hasn't been allocated yet. */ -@@ -2811,31 +2934,30 @@ static int xhci_handle_event(struct xhci_hcd *xhci) +@@ -2818,31 +2941,30 @@ static int xhci_handle_event(struct xhci_hcd *xhci) * speculative reads of the event's flags/data below. */ rmb(); @@ -1594364,7 +1594376,7 @@ index 4512c4223..a937bc6db } /* Any of the above functions may drop and re-acquire the lock, so check * to make sure a watchdog timer didn't mark the host as non-responsive. -@@ -2855,13 +2977,14 @@ static int xhci_handle_event(struct xhci_hcd *xhci) +@@ -2862,13 +2984,14 @@ static int xhci_handle_event(struct xhci_hcd *xhci) */ return 1; } @@ -1594380,7 +1594392,7 @@ index 4512c4223..a937bc6db union xhci_trb *event_ring_deq) { u64 temp_64; -@@ -2891,6 +3014,16 @@ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci, +@@ -2898,6 +3021,16 @@ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci, temp_64 |= ERST_EHB; xhci_write_64(xhci, temp_64, &xhci->ir_set->erst_dequeue); } @@ -1594397,7 +1594409,7 @@ index 4512c4223..a937bc6db /* * xHCI spec says we can get an interrupt, and if the HC has an error condition, -@@ -2926,6 +3059,10 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) +@@ -2933,6 +3066,10 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) goto out; } @@ -1594408,7 +1594420,7 @@ index 4512c4223..a937bc6db /* * Clear the op reg interrupt status first, * so we can receive interrupts from other MSI-X interrupters. -@@ -3016,6 +3153,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, +@@ -3023,6 +3160,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, u32 ep_state, unsigned int num_trbs, gfp_t mem_flags) { unsigned int num_trbs_needed; @@ -1594416,7 +1594428,7 @@ index 4512c4223..a937bc6db /* Make sure the endpoint has been added to xHC schedule */ switch (ep_state) { -@@ -3086,7 +3224,19 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, +@@ -3093,7 +3231,19 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, ep_ring->enq_seg = ep_ring->enq_seg->next; ep_ring->enqueue = ep_ring->enq_seg->trbs; @@ -1594436,7 +1594448,7 @@ index 4512c4223..a937bc6db return 0; } -@@ -3105,7 +3255,8 @@ static int prepare_transfer(struct xhci_hcd *xhci, +@@ -3112,7 +3262,8 @@ static int prepare_transfer(struct xhci_hcd *xhci, struct xhci_ring *ep_ring; struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); @@ -1594446,7 +1594458,7 @@ index 4512c4223..a937bc6db if (!ep_ring) { xhci_dbg(xhci, "Can't prepare ring for bad stream ID %u\n", stream_id); -@@ -3474,7 +3625,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, +@@ -3481,7 +3632,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, field |= TRB_IOC; more_trbs_coming = false; td->last_trb = ring->enqueue; @@ -1594455,7 +1594467,7 @@ index 4512c4223..a937bc6db if (xhci_urb_suitable_for_idt(urb)) { memcpy(&send_addr, urb->transfer_buffer, trb_buff_len); -@@ -3500,7 +3651,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, +@@ -3507,7 +3658,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, upper_32_bits(send_addr), length_field, field); @@ -1594464,7 +1594476,7 @@ index 4512c4223..a937bc6db addr += trb_buff_len; sent_len = trb_buff_len; -@@ -3524,8 +3675,10 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, +@@ -3531,8 +3682,10 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, ep_index, urb->stream_id, 1, urb, 1, mem_flags); urb_priv->td[1].last_trb = ring->enqueue; @@ -1594475,7 +1594487,7 @@ index 4512c4223..a937bc6db } check_trb_math(urb, enqd_len); -@@ -3576,6 +3729,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, +@@ -3583,6 +3736,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, urb_priv = urb->hcpriv; td = &urb_priv->td[0]; @@ -1594483,7 +1594495,7 @@ index 4512c4223..a937bc6db /* * Don't give the first TRB to the hardware (by toggling the cycle bit) -@@ -3648,6 +3802,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, +@@ -3655,6 +3809,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, /* Save the DMA address of the last TRB in the TD */ td->last_trb = ep_ring->enqueue; @@ -1594491,7 +1594503,7 @@ index 4512c4223..a937bc6db /* Queue status TRB - see Table 7 and sections 4.11.2.2 and 6.4.1.2.3 */ /* If the device sent data, the status stage is an OUT transfer */ -@@ -3892,7 +4047,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, +@@ -3899,7 +4054,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, goto cleanup; } td = &urb_priv->td[i]; @@ -1594500,7 +1594512,7 @@ index 4512c4223..a937bc6db /* use SIA as default, if frame id is used overwrite it */ sia_frame_id = TRB_SIA; if (!(urb->transfer_flags & URB_ISO_ASAP) && -@@ -3935,6 +4090,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, +@@ -3942,6 +4097,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, } else { more_trbs_coming = false; td->last_trb = ep_ring->enqueue; @@ -1594508,7 +1594520,7 @@ index 4512c4223..a937bc6db field |= TRB_IOC; if (trb_block_event_intr(xhci, num_tds, i)) field |= TRB_BEI; -@@ -4217,71 +4373,7 @@ int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, struct xhci_command *cmd, +@@ -4224,71 +4380,7 @@ int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, struct xhci_command *cmd, return queue_command(xhci, cmd, 0, 0, 0, trb_slot_id | trb_ep_index | type | trb_suspend, false); } @@ -1596272,7 +1596284,7 @@ index 7d499f356..d2ca41aea diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c old mode 100644 new mode 100755 -index 99562cc65..887644b39 +index 700e38e92..3b36e5353 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -343,12 +343,11 @@ static int fusb302_sw_reset(struct fusb302_chip *chip) @@ -1597222,7 +1597234,7 @@ index 723d7dd38..7b39cbd09 diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c old mode 100644 new mode 100755 -index 291d02042..41fcd89a7 +index 721d9c4dd..a5341e00d --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -76,6 +76,8 @@ @@ -1598180,7 +1598192,7 @@ index 291d02042..41fcd89a7 tcpm_queue_vdm(port, header, data, count); } -@@ -1442,51 +1921,83 @@ static unsigned int vdm_ready_timeout(u32 vdm_hdr) +@@ -1442,7 +1921,8 @@ static unsigned int vdm_ready_timeout(u32 vdm_hdr) static void vdm_run_state_machine(struct tcpm_port *port) { struct pd_message msg; @@ -1598190,19 +1598202,16 @@ index 291d02042..41fcd89a7 switch (port->vdm_state) { case VDM_STATE_READY: - /* Only transmit VDM if attached */ - if (!port->attached) { -- port->vdm_state = VDM_STATE_ERR_BUSY; -- break; -- } -- -- /* -- * if there's traffic or we're not in PDO ready state don't send -- * a VDM. -- */ +@@ -1456,37 +1936,68 @@ static void vdm_run_state_machine(struct tcpm_port *port) + * if there's traffic or we're not in PDO ready state don't send + * a VDM. + */ - if (port->state != SRC_READY && port->state != SNK_READY) -- break; -- ++ if (port->state != SRC_READY && port->state != SNK_READY) { ++ port->vdm_sm_running = false; + break; ++ } + - /* Prepare and send VDM */ - memset(&msg, 0, sizeof(msg)); - msg.header = PD_HEADER_LE(PD_DATA_VENDOR_DEF, @@ -1598217,23 +1598226,6 @@ index 291d02042..41fcd89a7 - port->vdm_state = VDM_STATE_ERR_SEND; - } else { - unsigned long timeout; -+ port->vdm_state = VDM_STATE_ERR_BUSY; -+ break; -+ } - -- port->vdm_retries = 0; -- port->vdm_state = VDM_STATE_BUSY; -- timeout = vdm_ready_timeout(port->vdo_data[0]); -- mod_vdm_delayed_work(port, timeout); -+ /* -+ * if there's traffic or we're not in PDO ready state don't send -+ * a VDM. -+ */ -+ if (port->state != SRC_READY && port->state != SNK_READY) { -+ port->vdm_sm_running = false; -+ break; -+ } -+ + /* TODO: AMS operation for Unstructured VDM */ + if (PD_VDO_SVDM(vdo_hdr) && PD_VDO_CMDT(vdo_hdr) == CMDT_INIT) { + switch (PD_VDO_CMD(vdo_hdr)) { @@ -1598267,7 +1598259,11 @@ index 291d02042..41fcd89a7 + res = -EOPNOTSUPP; + break; + } -+ + +- port->vdm_retries = 0; +- port->vdm_state = VDM_STATE_BUSY; +- timeout = vdm_ready_timeout(port->vdo_data[0]); +- mod_vdm_delayed_work(port, timeout); + if (res < 0) { + port->vdm_state = VDM_STATE_ERR_BUSY; + return; @@ -1599253,15 +1599249,11 @@ index 291d02042..41fcd89a7 tcpm_set_state(port, SRC_TRANSITION_SUPPLY, PD_T_SRC_TRANSITION); } -@@ -3237,10 +4043,39 @@ static void run_state_machine(struct tcpm_port *port) - #endif - port->try_src_count = 0; +@@ -3240,7 +4046,36 @@ static void run_state_machine(struct tcpm_port *port) + tcpm_swap_complete(port, 0); + tcpm_typec_connect(port); -- tcpm_swap_complete(port, 0); -- tcpm_typec_connect(port); -+ tcpm_swap_complete(port, 0); -+ tcpm_typec_connect(port); -+ +- tcpm_check_send_discover(port); + if (port->ams != NONE_AMS) + tcpm_ams_finish(port); + if (port->next_ams != NONE_AMS) { @@ -1599291,8 +1599283,7 @@ index 291d02042..41fcd89a7 + mod_send_discover_delayed_work(port, 0); + else + port->send_discover = false; - -- tcpm_check_send_discover(port); ++ /* * 6.3.5 * Sending ping messages is not necessary if @@ -1599331,959 +1599322,8 @@ index 291d02042..41fcd89a7 + port->debouncing = false; + } break; - case SRC_TRY: port->try_src_count++; -@@ -3353,6 +4201,12 @@ static void run_state_machine(struct tcpm_port *port) - port->message_id = 0; - port->rx_msgid = -1; - port->explicit_contract = false; -+ -+ if (port->ams == POWER_ROLE_SWAP || -+ port->ams == FAST_ROLE_SWAP) -+ /* SRC -> SNK POWER/FAST_ROLE_SWAP finished */ -+ tcpm_ams_finish(port); -+ - tcpm_set_state(port, SNK_DISCOVERY, 0); - break; - case SNK_DISCOVERY: -@@ -3410,9 +4264,15 @@ static void run_state_machine(struct tcpm_port *port) - break; - case SNK_NEGOTIATE_CAPABILITIES: - port->pd_capable = true; -+ tcpm_set_partner_usb_comm_capable(port, -+ !!(port->source_caps[0] & PDO_FIXED_USB_COMM)); - port->hard_reset_count = 0; - ret = tcpm_pd_send_request(port); - if (ret < 0) { -+ /* Restore back to the original state */ -+ tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_PD, -+ port->pps_data.active, -+ port->supply_voltage); - /* Let the Source send capabilities again. */ - tcpm_set_state(port, SNK_WAIT_CAPABILITIES, 0); - } else { -@@ -3423,6 +4283,10 @@ static void run_state_machine(struct tcpm_port *port) - case SNK_NEGOTIATE_PPS_CAPABILITIES: - ret = tcpm_pd_send_pps_request(port); - if (ret < 0) { -+ /* Restore back to the original state */ -+ tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_PD, -+ port->pps_data.active, -+ port->supply_voltage); - port->pps_status = ret; - /* - * If this was called due to updates to sink -@@ -3439,6 +4303,23 @@ static void run_state_machine(struct tcpm_port *port) - } - break; - case SNK_TRANSITION_SINK: -+ /* From the USB PD spec: -+ * "The Sink Shall transition to Sink Standby before a positive or -+ * negative voltage transition of VBUS. During Sink Standby -+ * the Sink Shall reduce its power draw to pSnkStdby." -+ * -+ * This is not applicable to PPS though as the port can continue -+ * to draw negotiated power without switching to standby. -+ */ -+ if (port->supply_voltage != port->req_supply_voltage && !port->pps_data.active && -+ port->current_limit * port->supply_voltage / 1000 > PD_P_SNK_STDBY_MW) { -+ u32 stdby_ma = PD_P_SNK_STDBY_MW * 1000 / port->supply_voltage; -+ -+ tcpm_log(port, "Setting standby current %u mV @ %u mA", -+ port->supply_voltage, stdby_ma); -+ tcpm_set_current_limit(port, stdby_ma, port->supply_voltage); -+ } -+ fallthrough; - case SNK_TRANSITION_SINK_VBUS: - tcpm_set_state(port, hard_reset_state(port), - PD_T_PS_TRANSITION); -@@ -3454,9 +4335,39 @@ static void run_state_machine(struct tcpm_port *port) - - tcpm_swap_complete(port, 0); - tcpm_typec_connect(port); -- tcpm_check_send_discover(port); - mod_enable_frs_delayed_work(port, 0); - tcpm_pps_complete(port, port->pps_status); -+ -+ if (port->ams != NONE_AMS) -+ tcpm_ams_finish(port); -+ if (port->next_ams != NONE_AMS) { -+ port->ams = port->next_ams; -+ port->next_ams = NONE_AMS; -+ } -+ -+ /* -+ * If previous AMS is interrupted, switch to the upcoming -+ * state. -+ */ -+ if (port->upcoming_state != INVALID_STATE) { -+ upcoming_state = port->upcoming_state; -+ port->upcoming_state = INVALID_STATE; -+ tcpm_set_state(port, upcoming_state, 0); -+ break; -+ } -+ -+ /* -+ * 6.4.4.3.1 Discover Identity -+ * "The Discover Identity Command Shall only be sent to SOP when there is an -+ * Explicit Contract." -+ * For now, this driver only supports SOP for DISCOVER_IDENTITY, thus using -+ * port->explicit_contract. -+ */ -+ if (port->explicit_contract) -+ mod_send_discover_delayed_work(port, 0); -+ else -+ port->send_discover = false; -+ - power_supply_changed(port->psy); - break; - -@@ -3477,8 +4388,14 @@ static void run_state_machine(struct tcpm_port *port) - - /* Hard_Reset states */ - case HARD_RESET_SEND: -- tcpm_pd_transmit(port, TCPC_TX_HARD_RESET, NULL); -- tcpm_set_state(port, HARD_RESET_START, 0); -+ if (port->ams != NONE_AMS) -+ tcpm_ams_finish(port); -+ /* -+ * State machine will be directed to HARD_RESET_START, -+ * thus set upcoming_state to INVALID_STATE. -+ */ -+ port->upcoming_state = INVALID_STATE; -+ tcpm_ams_start(port, HARD_RESET); - break; - case HARD_RESET_START: - port->sink_cap_done = false; -@@ -3522,11 +4439,15 @@ static void run_state_machine(struct tcpm_port *port) - case SRC_HARD_RESET_VBUS_ON: - tcpm_set_vconn(port, true); - tcpm_set_vbus(port, true); -+ if (port->ams == HARD_RESET) -+ tcpm_ams_finish(port); - port->tcpc->set_pd_rx(port->tcpc, true); - tcpm_set_attached_state(port, true); - tcpm_set_state(port, SRC_UNATTACHED, PD_T_PS_SOURCE_ON); - break; - case SNK_HARD_RESET_SINK_OFF: -+ /* Do not discharge/disconnect during hard reseet */ -+ tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, false, 0); - memset(&port->pps_data, 0, sizeof(port->pps_data)); - tcpm_set_vconn(port, false); - if (port->pd_capable) -@@ -3541,6 +4462,8 @@ static void run_state_machine(struct tcpm_port *port) - tcpm_set_state(port, SNK_HARD_RESET_SINK_ON, PD_T_SAFE_0V); - break; - case SNK_HARD_RESET_WAIT_VBUS: -+ if (port->ams == HARD_RESET) -+ tcpm_ams_finish(port); - /* Assume we're disconnected if VBUS doesn't come back. */ - tcpm_set_state(port, SNK_UNATTACHED, - PD_T_SRC_RECOVER_MAX + PD_T_SRC_TURN_ON); -@@ -3568,7 +4491,10 @@ static void run_state_machine(struct tcpm_port *port) - 5000); - tcpm_set_charge(port, true); - } -+ if (port->ams == HARD_RESET) -+ tcpm_ams_finish(port); - tcpm_set_attached_state(port, true); -+ tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, false, VSAFE5V); - tcpm_set_state(port, SNK_STARTUP, 0); - break; - -@@ -3577,10 +4503,20 @@ static void run_state_machine(struct tcpm_port *port) - port->message_id = 0; - port->rx_msgid = -1; - tcpm_pd_send_control(port, PD_CTRL_ACCEPT); -- if (port->pwr_role == TYPEC_SOURCE) -- tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0); -- else -+ tcpm_ams_finish(port); -+ if (port->pwr_role == TYPEC_SOURCE) { -+ port->upcoming_state = SRC_SEND_CAPABILITIES; -+ tcpm_ams_start(port, POWER_NEGOTIATION); -+ } else { - tcpm_set_state(port, SNK_WAIT_CAPABILITIES, 0); -+ } -+ break; -+ case SRC_SOFT_RESET_WAIT_SNK_TX: -+ case SNK_SOFT_RESET: -+ if (port->ams != NONE_AMS) -+ tcpm_ams_finish(port); -+ port->upcoming_state = SOFT_RESET_SEND; -+ tcpm_ams_start(port, SOFT_RESET_AMS); - break; - case SOFT_RESET_SEND: - port->message_id = 0; -@@ -3595,15 +4531,21 @@ static void run_state_machine(struct tcpm_port *port) - /* DR_Swap states */ - case DR_SWAP_SEND: - tcpm_pd_send_control(port, PD_CTRL_DR_SWAP); -+ if (port->data_role == TYPEC_DEVICE || port->negotiated_rev > PD_REV20) -+ port->send_discover = true; - tcpm_set_state_cond(port, DR_SWAP_SEND_TIMEOUT, - PD_T_SENDER_RESPONSE); - break; - case DR_SWAP_ACCEPT: - tcpm_pd_send_control(port, PD_CTRL_ACCEPT); -+ if (port->data_role == TYPEC_DEVICE || port->negotiated_rev > PD_REV20) -+ port->send_discover = true; - tcpm_set_state_cond(port, DR_SWAP_CHANGE_DR, 0); - break; - case DR_SWAP_SEND_TIMEOUT: - tcpm_swap_complete(port, -ETIMEDOUT); -+ port->send_discover = false; -+ tcpm_ams_finish(port); - tcpm_set_state(port, ready_state(port), 0); - break; - case DR_SWAP_CHANGE_DR: -@@ -3614,8 +4556,8 @@ static void run_state_machine(struct tcpm_port *port) - } else { - tcpm_set_roles(port, true, port->pwr_role, - TYPEC_HOST); -- port->send_discover = true; - } -+ tcpm_ams_finish(port); - tcpm_set_state(port, ready_state(port), 0); - break; - -@@ -3663,6 +4605,7 @@ static void run_state_machine(struct tcpm_port *port) - tcpm_set_state(port, ready_state(port), 0); - break; - case PR_SWAP_START: -+ tcpm_apply_rc(port); - if (port->pwr_role == TYPEC_SOURCE) - tcpm_set_state(port, PR_SWAP_SRC_SNK_TRANSITION_OFF, - PD_T_SRC_TRANSITION); -@@ -3670,6 +4613,10 @@ static void run_state_machine(struct tcpm_port *port) - tcpm_set_state(port, PR_SWAP_SNK_SRC_SINK_OFF, 0); - break; - case PR_SWAP_SRC_SNK_TRANSITION_OFF: -+ /* -+ * Prevent vbus discharge circuit from turning on during PR_SWAP -+ * as this is not a disconnect. -+ */ - tcpm_set_vbus(port, false); - port->explicit_contract = false; - /* allow time for Vbus discharge, must be < tSrcSwapStdby */ -@@ -3695,9 +4642,12 @@ static void run_state_machine(struct tcpm_port *port) - tcpm_set_state(port, ERROR_RECOVERY, 0); - break; - } -- tcpm_set_state_cond(port, SNK_UNATTACHED, PD_T_PS_SOURCE_ON); -+ tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_ON_PRS); - break; - case PR_SWAP_SRC_SNK_SINK_ON: -+ tcpm_enable_auto_vbus_discharge(port, true); -+ /* Set the vbus disconnect threshold for implicit contract */ -+ tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, false, VSAFE5V); - tcpm_set_state(port, SNK_STARTUP, 0); - break; - case PR_SWAP_SNK_SRC_SINK_OFF: -@@ -3706,6 +4656,7 @@ static void run_state_machine(struct tcpm_port *port) - PD_T_PS_SOURCE_OFF); - break; - case PR_SWAP_SNK_SRC_SOURCE_ON: -+ tcpm_enable_auto_vbus_discharge(port, true); - tcpm_set_cc(port, tcpm_rp_cc(port)); - tcpm_set_vbus(port, true); - /* -@@ -3731,6 +4682,7 @@ static void run_state_machine(struct tcpm_port *port) - - case VCONN_SWAP_ACCEPT: - tcpm_pd_send_control(port, PD_CTRL_ACCEPT); -+ tcpm_ams_finish(port); - tcpm_set_state(port, VCONN_SWAP_START, 0); - break; - case VCONN_SWAP_SEND: -@@ -3835,6 +4787,25 @@ static void run_state_machine(struct tcpm_port *port) - tcpm_default_state(port), - port->vbus_present ? PD_T_PS_SOURCE_OFF : 0); - break; -+ -+ /* AMS intermediate state */ -+ case AMS_START: -+ if (port->upcoming_state == INVALID_STATE) { -+ tcpm_set_state(port, port->pwr_role == TYPEC_SOURCE ? -+ SRC_READY : SNK_READY, 0); -+ break; -+ } -+ -+ upcoming_state = port->upcoming_state; -+ port->upcoming_state = INVALID_STATE; -+ tcpm_set_state(port, upcoming_state, 0); -+ break; -+ -+ /* Chunk state */ -+ case CHUNK_NOT_SUPP: -+ tcpm_pd_send_control(port, PD_CTRL_NOT_SUPP); -+ tcpm_set_state(port, port->pwr_role == TYPEC_SOURCE ? SRC_READY : SNK_READY, 0); -+ break; - default: - WARN(1, "Unexpected port state %d\n", port->state); - break; -@@ -3924,9 +4895,9 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1, - if (tcpm_port_is_disconnected(port) || - !tcpm_port_is_source(port)) { - if (port->port_type == TYPEC_PORT_SRC) -- tcpm_set_state(port, SRC_UNATTACHED, 0); -+ tcpm_set_state(port, SRC_UNATTACHED, tcpm_wait_for_discharge(port)); - else -- tcpm_set_state(port, SNK_UNATTACHED, 0); -+ tcpm_set_state(port, SNK_UNATTACHED, tcpm_wait_for_discharge(port)); - } - break; - case SNK_UNATTACHED: -@@ -3957,7 +4928,23 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1, - tcpm_set_state(port, SNK_DEBOUNCED, 0); - break; - case SNK_READY: -- if (tcpm_port_is_disconnected(port)) -+ /* -+ * EXIT condition is based primarily on vbus disconnect and CC is secondary. -+ * "A port that has entered into USB PD communications with the Source and -+ * has seen the CC voltage exceed vRd-USB may monitor the CC pin to detect -+ * cable disconnect in addition to monitoring VBUS. -+ * -+ * A port that is monitoring the CC voltage for disconnect (but is not in -+ * the process of a USB PD PR_Swap or USB PD FR_Swap) shall transition to -+ * Unattached.SNK within tSinkDisconnect after the CC voltage remains below -+ * vRd-USB for tPDDebounce." -+ * -+ * When set_auto_vbus_discharge_threshold is enabled, CC pins go -+ * away before vbus decays to disconnect threshold. Allow -+ * disconnect to be driven by vbus disconnect when auto vbus -+ * discharge is enabled. -+ */ -+ if (!port->auto_vbus_discharge_enabled && tcpm_port_is_disconnected(port)) - tcpm_set_state(port, unattached_state(port), 0); - else if (!port->pd_capable && - (cc1 != old_cc1 || cc2 != old_cc2)) -@@ -4022,6 +5009,12 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1, - if (!tcpm_port_is_sink(port)) - tcpm_set_state(port, SNK_TRYWAIT_DEBOUNCE, 0); - break; -+ case SNK_TRY_WAIT_DEBOUNCE_CHECK_VBUS: -+ if (!tcpm_port_is_sink(port)) -+ tcpm_set_state(port, SRC_TRYWAIT, PD_T_TRY_CC_DEBOUNCE); -+ else -+ tcpm_set_state(port, SNK_TRY_WAIT_DEBOUNCE_CHECK_VBUS, 0); -+ break; - case SNK_TRYWAIT: - /* Do nothing, waiting for tCCDebounce */ - break; -@@ -4050,9 +5043,13 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1, - * Ignore CC changes here. - */ - break; -- - default: -- if (tcpm_port_is_disconnected(port)) -+ /* -+ * While acting as sink and auto vbus discharge is enabled, Allow disconnect -+ * to be driven by vbus disconnect. -+ */ -+ if (tcpm_port_is_disconnected(port) && !(port->pwr_role == TYPEC_SINK && -+ port->auto_vbus_discharge_enabled)) - tcpm_set_state(port, unattached_state(port), 0); - break; - } -@@ -4062,6 +5059,12 @@ static void _tcpm_pd_vbus_on(struct tcpm_port *port) - { - tcpm_log_force(port, "VBUS on"); - port->vbus_present = true; -+ /* -+ * When vbus_present is true i.e. Voltage at VBUS is greater than VSAFE5V implicitly -+ * states that vbus is not at VSAFE0V, hence clear the vbus_vsafe0v flag here. -+ */ -+ port->vbus_vsafe0v = false; -+ - switch (port->state) { - case SNK_TRANSITION_SINK_VBUS: - port->explicit_contract = true; -@@ -4108,11 +5111,24 @@ static void _tcpm_pd_vbus_on(struct tcpm_port *port) - case SNK_TRYWAIT_DEBOUNCE: - /* Do nothing, waiting for Rp */ - break; -+ case SNK_TRY_WAIT_DEBOUNCE_CHECK_VBUS: -+ if (port->vbus_present && tcpm_port_is_sink(port)) -+ tcpm_set_state(port, SNK_ATTACHED, 0); -+ break; - case SRC_TRY_WAIT: - case SRC_TRY_DEBOUNCE: - /* Do nothing, waiting for sink detection */ - break; -+ case FR_SWAP_SEND: -+ case FR_SWAP_SEND_TIMEOUT: -+ case FR_SWAP_SNK_SRC_TRANSITION_TO_OFF: -+ case FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED: -+ if (port->tcpc->frs_sourcing_vbus) -+ port->tcpc->frs_sourcing_vbus(port->tcpc); -+ break; - case FR_SWAP_SNK_SRC_NEW_SINK_READY: -+ if (port->tcpc->frs_sourcing_vbus) -+ port->tcpc->frs_sourcing_vbus(port->tcpc); - tcpm_set_state(port, FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED, 0); - break; - -@@ -4138,16 +5154,8 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) - case SNK_HARD_RESET_SINK_OFF: - tcpm_set_state(port, SNK_HARD_RESET_WAIT_VBUS, 0); - break; -- case SRC_HARD_RESET_VBUS_OFF: -- /* -- * After establishing the vSafe0V voltage condition on VBUS, the Source Shall wait -- * tSrcRecover before re-applying VCONN and restoring VBUS to vSafe5V. -- */ -- tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER); -- break; - case HARD_RESET_SEND: - break; -- - case SNK_TRY: - /* Do nothing, waiting for timeout */ - break; -@@ -4164,6 +5172,7 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) - case SNK_TRYWAIT_DEBOUNCE: - break; - case SNK_ATTACH_WAIT: -+ port->debouncing = false; - tcpm_set_state(port, SNK_UNATTACHED, 0); - break; - -@@ -4178,6 +5187,14 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) - /* Do nothing, expected */ - break; - -+ case PR_SWAP_SNK_SRC_SOURCE_ON: -+ /* -+ * Do nothing when vbus off notification is received. -+ * TCPM can wait for PD_T_NEWSRC in PR_SWAP_SNK_SRC_SOURCE_ON -+ * for the vbus source to ramp up. -+ */ -+ break; -+ - case PORT_RESET_WAIT_OFF: - tcpm_set_state(port, tcpm_default_state(port), 0); - break; -@@ -4187,6 +5204,25 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) - /* Do nothing, waiting for sink detection */ - break; - -+ case SRC_STARTUP: -+ case SRC_SEND_CAPABILITIES: -+ case SRC_SEND_CAPABILITIES_TIMEOUT: -+ case SRC_NEGOTIATE_CAPABILITIES: -+ case SRC_TRANSITION_SUPPLY: -+ case SRC_READY: -+ case SRC_WAIT_NEW_CAPABILITIES: -+ /* -+ * Force to unattached state to re-initiate connection. -+ * DRP port should move to Unattached.SNK instead of Unattached.SRC if -+ * sink removed. Although sink removal here is due to source's vbus collapse, -+ * treat it the same way for consistency. -+ */ -+ if (port->port_type == TYPEC_PORT_SRC) -+ tcpm_set_state(port, SRC_UNATTACHED, tcpm_wait_for_discharge(port)); -+ else -+ tcpm_set_state(port, SNK_UNATTACHED, tcpm_wait_for_discharge(port)); -+ break; -+ - case PORT_RESET: - /* - * State set back to default mode once the timer completes. -@@ -4203,8 +5239,51 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) - break; - - default: -- if (port->pwr_role == TYPEC_SINK && -- port->attached) -+ if (port->pwr_role == TYPEC_SINK && port->attached) -+ tcpm_set_state(port, SNK_UNATTACHED, tcpm_wait_for_discharge(port)); -+ break; -+ } -+} -+ -+static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port) -+{ -+ unsigned int timer_val_msecs; -+ -+ tcpm_log_force(port, "VBUS VSAFE0V"); -+ port->vbus_vsafe0v = true; -+ switch (port->state) { -+ case SRC_HARD_RESET_VBUS_OFF: -+ /* -+ * After establishing the vSafe0V voltage condition on VBUS, the Source Shall wait -+ * tSrcRecover before re-applying VCONN and restoring VBUS to vSafe5V. -+ */ -+ tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER); -+ break; -+ case SRC_ATTACH_WAIT: -+ if (tcpm_port_is_source(port)) -+ tcpm_set_state(port, tcpm_try_snk(port) ? SNK_TRY : SRC_ATTACHED, -+ PD_T_CC_DEBOUNCE); -+ break; -+ case SRC_STARTUP: -+ case SRC_SEND_CAPABILITIES: -+ case SRC_SEND_CAPABILITIES_TIMEOUT: -+ case SRC_NEGOTIATE_CAPABILITIES: -+ case SRC_TRANSITION_SUPPLY: -+ case SRC_READY: -+ case SRC_WAIT_NEW_CAPABILITIES: -+ if (port->auto_vbus_discharge_enabled) { -+ if (port->port_type == TYPEC_PORT_SRC) -+ tcpm_set_state(port, SRC_UNATTACHED, 0); -+ else -+ tcpm_set_state(port, SNK_UNATTACHED, 0); -+ } -+ break; -+ case PR_SWAP_SNK_SRC_SINK_OFF: -+ case PR_SWAP_SNK_SRC_SOURCE_ON: -+ /* Do nothing, vsafe0v is expected during transition */ -+ break; -+ default: -+ if (port->pwr_role == TYPEC_SINK && port->auto_vbus_discharge_enabled) - tcpm_set_state(port, SNK_UNATTACHED, 0); - break; - } -@@ -4216,6 +5295,10 @@ static void _tcpm_pd_hard_reset(struct tcpm_port *port) - if (port->bist_request == BDO_MODE_TESTDATA && port->tcpc->set_bist_data) - port->tcpc->set_bist_data(port->tcpc, false); - -+ if (port->ams != NONE_AMS) -+ port->ams = NONE_AMS; -+ if (port->hard_reset_count < PD_N_HARD_RESET_COUNT) -+ port->ams = HARD_RESET; - /* - * If we keep receiving hard reset requests, executing the hard reset - * must have failed. Revert to error recovery if that happens. -@@ -4245,10 +5328,19 @@ static void tcpm_pd_event_handler(struct kthread_work *work) - bool vbus; - - vbus = port->tcpc->get_vbus(port->tcpc); -- if (vbus) -+ if (vbus) { - _tcpm_pd_vbus_on(port); -- else -+ } else { - _tcpm_pd_vbus_off(port); -+ /* -+ * When TCPC does not support detecting vsafe0v voltage level, -+ * treat vbus absent as vsafe0v. Else invoke is_vbus_vsafe0v -+ * to see if vbus has discharge to VSAFE0V. -+ */ -+ if (!port->tcpc->is_vbus_vsafe0v || -+ port->tcpc->is_vbus_vsafe0v(port->tcpc)) -+ _tcpm_pd_vbus_vsafe0v(port); -+ } - } - if (events & TCPM_CC_EVENT) { - enum typec_cc_status cc1, cc2; -@@ -4257,10 +5349,16 @@ static void tcpm_pd_event_handler(struct kthread_work *work) - _tcpm_cc_change(port, cc1, cc2); - } - if (events & TCPM_FRS_EVENT) { -- if (port->state == SNK_READY) -- tcpm_set_state(port, FR_SWAP_SEND, 0); -- else -+ if (port->state == SNK_READY) { -+ int ret; -+ -+ port->upcoming_state = FR_SWAP_SEND; -+ ret = tcpm_ams_start(port, FAST_ROLE_SWAP); -+ if (ret == -EAGAIN) -+ port->upcoming_state = INVALID_STATE; -+ } else { - tcpm_log(port, "Discarding FRS_SIGNAL! Not in sink ready"); -+ } - } - if (events & TCPM_SOURCING_VBUS) { - tcpm_log(port, "sourcing vbus"); -@@ -4329,6 +5427,7 @@ EXPORT_SYMBOL_GPL(tcpm_sourcing_vbus); - static void tcpm_enable_frs_work(struct kthread_work *work) - { - struct tcpm_port *port = container_of(work, struct tcpm_port, enable_frs); -+ int ret; - - mutex_lock(&port->lock); - /* Not FRS capable */ -@@ -4340,18 +5439,49 @@ static void tcpm_enable_frs_work(struct kthread_work *work) - goto unlock; - - /* Send when the state machine is idle */ -- if (port->state != SNK_READY || port->vdm_state != VDM_STATE_DONE || port->send_discover) -+ if (port->state != SNK_READY || port->vdm_sm_running || port->send_discover) - goto resched; - -- tcpm_set_state(port, GET_SINK_CAP, 0); -- port->sink_cap_done = true; -- -+ port->upcoming_state = GET_SINK_CAP; -+ ret = tcpm_ams_start(port, GET_SINK_CAPABILITIES); -+ if (ret == -EAGAIN) { -+ port->upcoming_state = INVALID_STATE; -+ } else { -+ port->sink_cap_done = true; -+ goto unlock; -+ } - resched: - mod_enable_frs_delayed_work(port, GET_SINK_CAP_RETRY_MS); - unlock: - mutex_unlock(&port->lock); - } - -+static void tcpm_send_discover_work(struct kthread_work *work) -+{ -+ struct tcpm_port *port = container_of(work, struct tcpm_port, send_discover_work); -+ -+ mutex_lock(&port->lock); -+ /* No need to send DISCOVER_IDENTITY anymore */ -+ if (!port->send_discover) -+ goto unlock; -+ -+ if (port->data_role == TYPEC_DEVICE && port->negotiated_rev < PD_REV30) { -+ port->send_discover = false; -+ goto unlock; -+ } -+ -+ /* Retry if the port is not idle */ -+ if ((port->state != SRC_READY && port->state != SNK_READY) || port->vdm_sm_running) { -+ mod_send_discover_delayed_work(port, SEND_DISCOVER_RETRY_MS); -+ goto unlock; -+ } -+ -+ tcpm_send_vdm(port, USB_SID_PD, CMD_DISCOVER_IDENT, NULL, 0); -+ -+unlock: -+ mutex_unlock(&port->lock); -+} -+ - static int tcpm_dr_set(struct typec_port *p, enum typec_data_role data) - { - struct tcpm_port *port = typec_get_drvdata(p); -@@ -4395,7 +5525,12 @@ static int tcpm_dr_set(struct typec_port *p, enum typec_data_role data) - port->non_pd_role_swap = true; - tcpm_set_state(port, PORT_RESET, 0); - } else { -- tcpm_set_state(port, DR_SWAP_SEND, 0); -+ port->upcoming_state = DR_SWAP_SEND; -+ ret = tcpm_ams_start(port, DATA_ROLE_SWAP); -+ if (ret == -EAGAIN) { -+ port->upcoming_state = INVALID_STATE; -+ goto port_unlock; -+ } - } - - port->swap_status = 0; -@@ -4441,10 +5576,16 @@ static int tcpm_pr_set(struct typec_port *p, enum typec_role role) - goto port_unlock; - } - -+ port->upcoming_state = PR_SWAP_SEND; -+ ret = tcpm_ams_start(port, POWER_ROLE_SWAP); -+ if (ret == -EAGAIN) { -+ port->upcoming_state = INVALID_STATE; -+ goto port_unlock; -+ } -+ - port->swap_status = 0; - port->swap_pending = true; - reinit_completion(&port->swap_complete); -- tcpm_set_state(port, PR_SWAP_SEND, 0); - mutex_unlock(&port->lock); - - if (!wait_for_completion_timeout(&port->swap_complete, -@@ -4480,10 +5621,16 @@ static int tcpm_vconn_set(struct typec_port *p, enum typec_role role) - goto port_unlock; - } - -+ port->upcoming_state = VCONN_SWAP_SEND; -+ ret = tcpm_ams_start(port, VCONN_SWAP); -+ if (ret == -EAGAIN) { -+ port->upcoming_state = INVALID_STATE; -+ goto port_unlock; -+ } -+ - port->swap_status = 0; - port->swap_pending = true; - reinit_completion(&port->swap_complete); -- tcpm_set_state(port, VCONN_SWAP_SEND, 0); - mutex_unlock(&port->lock); - - if (!wait_for_completion_timeout(&port->swap_complete, -@@ -4548,6 +5695,13 @@ static int tcpm_pps_set_op_curr(struct tcpm_port *port, u16 req_op_curr) - goto port_unlock; - } - -+ port->upcoming_state = SNK_NEGOTIATE_PPS_CAPABILITIES; -+ ret = tcpm_ams_start(port, POWER_NEGOTIATION); -+ if (ret == -EAGAIN) { -+ port->upcoming_state = INVALID_STATE; -+ goto port_unlock; -+ } -+ - /* Round down operating current to align with PPS valid steps */ - req_op_curr = req_op_curr - (req_op_curr % RDO_PROG_CURR_MA_STEP); - -@@ -4555,7 +5709,6 @@ static int tcpm_pps_set_op_curr(struct tcpm_port *port, u16 req_op_curr) - port->pps_data.req_op_curr = req_op_curr; - port->pps_status = 0; - port->pps_pending = true; -- tcpm_set_state(port, SNK_NEGOTIATE_PPS_CAPABILITIES, 0); - mutex_unlock(&port->lock); - - if (!wait_for_completion_timeout(&port->pps_complete, -@@ -4604,6 +5757,13 @@ static int tcpm_pps_set_out_volt(struct tcpm_port *port, u16 req_out_volt) - goto port_unlock; - } - -+ port->upcoming_state = SNK_NEGOTIATE_PPS_CAPABILITIES; -+ ret = tcpm_ams_start(port, POWER_NEGOTIATION); -+ if (ret == -EAGAIN) { -+ port->upcoming_state = INVALID_STATE; -+ goto port_unlock; -+ } -+ - /* Round down output voltage to align with PPS valid steps */ - req_out_volt = req_out_volt - (req_out_volt % RDO_PROG_VOLT_MV_STEP); - -@@ -4611,7 +5771,6 @@ static int tcpm_pps_set_out_volt(struct tcpm_port *port, u16 req_out_volt) - port->pps_data.req_out_volt = req_out_volt; - port->pps_status = 0; - port->pps_pending = true; -- tcpm_set_state(port, SNK_NEGOTIATE_PPS_CAPABILITIES, 0); - mutex_unlock(&port->lock); - - if (!wait_for_completion_timeout(&port->pps_complete, -@@ -4651,6 +5810,16 @@ static int tcpm_pps_activate(struct tcpm_port *port, bool activate) - goto port_unlock; - } - -+ if (activate) -+ port->upcoming_state = SNK_NEGOTIATE_PPS_CAPABILITIES; -+ else -+ port->upcoming_state = SNK_NEGOTIATE_CAPABILITIES; -+ ret = tcpm_ams_start(port, POWER_NEGOTIATION); -+ if (ret == -EAGAIN) { -+ port->upcoming_state = INVALID_STATE; -+ goto port_unlock; -+ } -+ - reinit_completion(&port->pps_complete); - port->pps_status = 0; - port->pps_pending = true; -@@ -4659,9 +5828,6 @@ static int tcpm_pps_activate(struct tcpm_port *port, bool activate) - if (activate) { - port->pps_data.req_out_volt = port->supply_voltage; - port->pps_data.req_op_curr = port->current_limit; -- tcpm_set_state(port, SNK_NEGOTIATE_PPS_CAPABILITIES, 0); -- } else { -- tcpm_set_state(port, SNK_NEGOTIATE_CAPABILITIES, 0); - } - mutex_unlock(&port->lock); - -@@ -4698,6 +5864,24 @@ static void tcpm_init(struct tcpm_port *port) - if (port->vbus_present) - port->vbus_never_low = true; - -+ /* -+ * 1. When vbus_present is true, voltage on VBUS is already at VSAFE5V. -+ * So implicitly vbus_vsafe0v = false. -+ * -+ * 2. When vbus_present is false and TCPC does NOT support querying -+ * vsafe0v status, then, it's best to assume vbus is at VSAFE0V i.e. -+ * vbus_vsafe0v is true. -+ * -+ * 3. When vbus_present is false and TCPC does support querying vsafe0v, -+ * then, query tcpc for vsafe0v status. -+ */ -+ if (port->vbus_present) -+ port->vbus_vsafe0v = false; -+ else if (!port->tcpc->is_vbus_vsafe0v) -+ port->vbus_vsafe0v = true; -+ else -+ port->vbus_vsafe0v = port->tcpc->is_vbus_vsafe0v(port->tcpc); -+ - tcpm_set_state(port, tcpm_default_state(port), 0); - - if (port->tcpc->get_cc(port->tcpc, &cc1, &cc2) == 0) -@@ -4783,6 +5967,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, - port->typec_caps.type = ret; - port->port_type = port->typec_caps.type; - -+ port->slow_charger_loop = fwnode_property_read_bool(fwnode, "slow-charger-loop"); - if (port->port_type == TYPEC_PORT_SNK) - goto sink; - -@@ -4830,14 +6015,99 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, - - /* FRS can only be supported byb DRP ports */ - if (port->port_type == TYPEC_PORT_DRP) { -- ret = fwnode_property_read_u32(fwnode, "frs-typec-current", &frs_current); -+ ret = fwnode_property_read_u32(fwnode, "new-source-frs-typec-current", -+ &frs_current); - if (ret >= 0 && frs_current <= FRS_5V_3A) -- port->frs_current = frs_current; -+ port->new_source_frs_current = frs_current; -+ } -+ -+ /* sink-vdos is optional */ -+ ret = fwnode_property_count_u32(fwnode, "sink-vdos"); -+ if (ret < 0) -+ ret = 0; -+ -+ port->nr_snk_vdo = min(ret, VDO_MAX_OBJECTS); -+ if (port->nr_snk_vdo) { -+ ret = fwnode_property_read_u32_array(fwnode, "sink-vdos", -+ port->snk_vdo, -+ port->nr_snk_vdo); -+ if (ret < 0) -+ return ret; -+ } -+ -+ /* If sink-vdos is found, sink-vdos-v1 is expected for backward compatibility. */ -+ if (port->nr_snk_vdo) { -+ ret = fwnode_property_count_u32(fwnode, "sink-vdos-v1"); -+ if (ret < 0) -+ return ret; -+ else if (ret == 0) -+ return -ENODATA; -+ -+ port->nr_snk_vdo_v1 = min(ret, VDO_MAX_OBJECTS); -+ ret = fwnode_property_read_u32_array(fwnode, "sink-vdos-v1", -+ port->snk_vdo_v1, -+ port->nr_snk_vdo_v1); -+ if (ret < 0) -+ return ret; - } - - return 0; - } - -+static int tcpm_copy_pdos(u32 *dest_pdo, const u32 *src_pdo, unsigned int nr_pdo) -+{ -+ unsigned int i; -+ -+ if (nr_pdo > PDO_MAX_OBJECTS) -+ nr_pdo = PDO_MAX_OBJECTS; -+ -+ for (i = 0; i < nr_pdo; i++) -+ dest_pdo[i] = src_pdo[i]; -+ -+ return nr_pdo; -+} -+ -+int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, unsigned int nr_pdo, -+ unsigned int operating_snk_mw) -+{ -+ int ret = 0; -+ -+ if (tcpm_validate_caps(port, pdo, nr_pdo)) -+ return -EINVAL; -+ -+ mutex_lock(&port->lock); -+ port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, pdo, nr_pdo); -+ port->operating_snk_mw = operating_snk_mw; -+ -+ switch (port->state) { -+ case SNK_NEGOTIATE_CAPABILITIES: -+ case SNK_NEGOTIATE_PPS_CAPABILITIES: -+ case SNK_READY: -+ case SNK_TRANSITION_SINK: -+ case SNK_TRANSITION_SINK_VBUS: -+ if (port->pps_data.active) -+ port->upcoming_state = SNK_NEGOTIATE_PPS_CAPABILITIES; -+ else if (port->pd_capable) -+ port->upcoming_state = SNK_NEGOTIATE_CAPABILITIES; -+ else -+ break; -+ -+ port->update_sink_caps = true; -+ -+ ret = tcpm_ams_start(port, POWER_NEGOTIATION); -+ if (ret == -EAGAIN) { -+ port->upcoming_state = INVALID_STATE; -+ break; -+ } -+ break; -+ default: -+ break; -+ } -+ mutex_unlock(&port->lock); -+ return ret; -+} -+EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities); -+ - /* Power Supply access to expose source power information */ - enum tcpm_psy_online_states { - TCPM_PSY_OFFLINE = 0, -@@ -4952,7 +6222,6 @@ static int tcpm_psy_get_prop(struct power_supply *psy, - ret = -EINVAL; - break; - } -- - return ret; - } - -@@ -5087,6 +6356,14 @@ static enum hrtimer_restart enable_frs_timer_handler(struct hrtimer *timer) - return HRTIMER_NORESTART; - } - -+static enum hrtimer_restart send_discover_timer_handler(struct hrtimer *timer) -+{ -+ struct tcpm_port *port = container_of(timer, struct tcpm_port, send_discover_timer); -+ -+ kthread_queue_work(port->wq, &port->send_discover_work); -+ return HRTIMER_NORESTART; -+} -+ - struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) - { - struct tcpm_port *port; -@@ -5117,12 +6394,15 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) - kthread_init_work(&port->vdm_state_machine, vdm_state_machine_work); - kthread_init_work(&port->event_work, tcpm_pd_event_handler); - kthread_init_work(&port->enable_frs, tcpm_enable_frs_work); -+ kthread_init_work(&port->send_discover_work, tcpm_send_discover_work); - hrtimer_init(&port->state_machine_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - port->state_machine_timer.function = state_machine_timer_handler; - hrtimer_init(&port->vdm_state_machine_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - port->vdm_state_machine_timer.function = vdm_state_machine_timer_handler; - hrtimer_init(&port->enable_frs_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - port->enable_frs_timer.function = enable_frs_timer_handler; -+ hrtimer_init(&port->send_discover_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); -+ port->send_discover_timer.function = send_discover_timer_handler; - - spin_lock_init(&port->pd_event_lock); - -@@ -5140,6 +6420,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) - port->typec_caps.fwnode = tcpc->fwnode; - port->typec_caps.revision = 0x0120; /* Type-C spec release 1.2 */ - port->typec_caps.pd_revision = 0x0300; /* USB-PD spec release 3.0 */ -+ port->typec_caps.svdm_version = SVDM_VER_2_0; - port->typec_caps.driver_data = port; - port->typec_caps.ops = &tcpm_ops; - port->typec_caps.orientation_aware = 1; -@@ -5164,6 +6445,10 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) - goto out_role_sw_put; - } - -+ typec_port_register_altmodes(port->typec_port, -+ &tcpm_altmode_ops, port, -+ port->port_altmode, ALTMODE_DISCOVERY_MAX); -+ - mutex_lock(&port->lock); - tcpm_init(port); - mutex_unlock(&port->lock); -@@ -5184,6 +6469,7 @@ void tcpm_unregister_port(struct tcpm_port *port) - { - int i; - -+ hrtimer_cancel(&port->send_discover_timer); - hrtimer_cancel(&port->enable_frs_timer); - hrtimer_cancel(&port->vdm_state_machine_timer); - hrtimer_cancel(&port->state_machine_timer); diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c old mode 100644 new mode 100755 @@ -1653723,7 +1652763,7 @@ index 000000000..39c497774 + +#endif diff --git a/include/linux/sched.h b/include/linux/sched.h -index 4948f0925..eed4f9e52 100644 +index a67583bfa..51f0715eb 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1366,7 +1366,7 @@ struct task_struct { @@ -1663113,10 +1662153,10 @@ index 55b74d7e5..f4c4e2404 100644 rootfs_initcall(populate_rootfs); +#endif diff --git a/init/main.c b/init/main.c -index 3a87bc79a..5aa7dadc9 100644 +index e8d5c6477..885ce026d 100644 --- a/init/main.c +++ b/init/main.c -@@ -1532,6 +1532,10 @@ static noinline void __init kernel_init_freeable(void) +@@ -1533,6 +1533,10 @@ static noinline void __init kernel_init_freeable(void) smp_init(); sched_init_smp(); @@ -1663127,7 +1662167,7 @@ index 3a87bc79a..5aa7dadc9 100644 padata_init(); page_alloc_init_late(); /* Initialize page ext after all struct pages are initialized. */ -@@ -1541,6 +1545,10 @@ static noinline void __init kernel_init_freeable(void) +@@ -1542,6 +1546,10 @@ static noinline void __init kernel_init_freeable(void) kunit_run_all_tests(); @@ -1663193,10 +1662233,10 @@ index d3b9b73cd..7d9c06b0a 100644 return -ENOMEM; } diff --git a/ipc/shm.c b/ipc/shm.c -index fce0b7b12..e25c7c610 100644 +index b418731d6..471ac3e74 100644 --- a/ipc/shm.c +++ b/ipc/shm.c -@@ -619,7 +619,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) +@@ -711,7 +711,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) ns->shm_tot + numpages > ns->shm_ctlall) return -ENOSPC; @@ -1663206,7 +1662246,7 @@ index fce0b7b12..e25c7c610 100644 return -ENOMEM; diff --git a/ipc/util.c b/ipc/util.c -index cc46cfa06..cfa0045e7 100644 +index 7c3601dad..bbb5190af 100644 --- a/ipc/util.c +++ b/ipc/util.c @@ -754,13 +754,21 @@ struct pid_namespace *ipc_seq_pid_ns(struct seq_file *s) @@ -1663931,10 +1662971,10 @@ index 08236798d..081d026f1 100644 }; +EXPORT_SYMBOL_GPL(freezer_cgrp_subsys); diff --git a/kernel/cpu.c b/kernel/cpu.c -index d33629370..e799bf115 100644 +index 4b27158d3..b076ccd1b 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c -@@ -38,6 +38,8 @@ +@@ -39,6 +39,8 @@ #define CREATE_TRACE_POINTS #include @@ -1663943,7 +1662983,7 @@ index d33629370..e799bf115 100644 #include "smpboot.h" /** -@@ -273,11 +275,13 @@ void cpu_maps_update_begin(void) +@@ -274,11 +276,13 @@ void cpu_maps_update_begin(void) { mutex_lock(&cpu_add_remove_lock); } @@ -1663957,7 +1662997,7 @@ index d33629370..e799bf115 100644 /* * If set, cpu_up and cpu_down will return -EBUSY and do nothing. -@@ -1046,7 +1050,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, +@@ -1053,7 +1057,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); int prev_state, ret = 0; @@ -1664055,7 +1663095,7 @@ index 119b929dc..41430128d 100644 dev_info(dev, "EM: created perf domain\n"); diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c -index 2fc7d509a..da0b41914 100644 +index bf640fd61..b13fe337f 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -326,7 +326,7 @@ static int create_image(int platform_mode) @@ -1664706,10 +1663746,10 @@ index af6f23d8b..bce629531 100644 { /* The boot cpu is always logical cpu 0 */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index 1dba7d70b..2ed1b74bb 100644 +index e2f00be4b..750da3e7c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -46,6 +46,13 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_overutilized_tp); +@@ -47,6 +47,13 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_overutilized_tp); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_se_tp); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp); @@ -1664723,7 +1663763,7 @@ index 1dba7d70b..2ed1b74bb 100644 DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); -@@ -659,7 +666,7 @@ int get_nohz_timer_target(void) +@@ -660,7 +667,7 @@ int get_nohz_timer_target(void) int i, cpu = smp_processor_id(), default_cpu = -1; struct sched_domain *sd; @@ -1664732,7 +1663772,7 @@ index 1dba7d70b..2ed1b74bb 100644 if (!idle_cpu(cpu)) return cpu; default_cpu = cpu; -@@ -679,8 +686,25 @@ int get_nohz_timer_target(void) +@@ -680,8 +687,25 @@ int get_nohz_timer_target(void) } } @@ -1664760,7 +1663800,7 @@ index 1dba7d70b..2ed1b74bb 100644 cpu = default_cpu; unlock: rcu_read_unlock(); -@@ -1769,7 +1793,10 @@ static inline bool is_cpu_allowed(struct task_struct *p, int cpu) +@@ -1770,7 +1794,10 @@ static inline bool is_cpu_allowed(struct task_struct *p, int cpu) if (is_per_cpu_kthread(p)) return cpu_online(cpu); @@ -1664772,7 +1663812,7 @@ index 1dba7d70b..2ed1b74bb 100644 } /* -@@ -2432,10 +2459,9 @@ static int select_fallback_rq(int cpu, struct task_struct *p) +@@ -2433,10 +2460,9 @@ static int select_fallback_rq(int cpu, struct task_struct *p) } fallthrough; case possible: @@ -1664784,7 +1663824,7 @@ index 1dba7d70b..2ed1b74bb 100644 case fail: #ifdef CONFIG_CPU_ISOLATION_OPT allow_iso = true; -@@ -2626,6 +2652,9 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags, +@@ -2627,6 +2653,9 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags, { int en_flags = ENQUEUE_WAKEUP | ENQUEUE_NOCLOCK; @@ -1664794,7 +1663834,7 @@ index 1dba7d70b..2ed1b74bb 100644 lockdep_assert_held(&rq->lock); if (p->sched_contributes_to_load) -@@ -3015,6 +3044,19 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) +@@ -3019,6 +3048,19 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) if (!(p->state & state)) goto unlock; @@ -1664814,7 +1663854,7 @@ index 1dba7d70b..2ed1b74bb 100644 trace_sched_waking(p); /* We're going to change ->state: */ -@@ -5000,7 +5042,7 @@ asmlinkage __visible void __sched preempt_schedule_irq(void) +@@ -5004,7 +5046,7 @@ asmlinkage __visible void __sched preempt_schedule_irq(void) int default_wake_function(wait_queue_entry_t *curr, unsigned mode, int wake_flags, void *key) { @@ -1664823,7 +1663863,7 @@ index 1dba7d70b..2ed1b74bb 100644 return try_to_wake_up(curr->private, mode, wake_flags); } EXPORT_SYMBOL(default_wake_function); -@@ -5709,16 +5751,19 @@ int sched_setscheduler(struct task_struct *p, int policy, +@@ -5713,16 +5755,19 @@ int sched_setscheduler(struct task_struct *p, int policy, { return _sched_setscheduler(p, policy, param, true); } @@ -1664843,7 +1663883,7 @@ index 1dba7d70b..2ed1b74bb 100644 /** * sched_setscheduler_nocheck - change the scheduling policy and/or RT priority of a thread from kernelspace. -@@ -5738,6 +5783,7 @@ int sched_setscheduler_nocheck(struct task_struct *p, int policy, +@@ -5742,6 +5787,7 @@ int sched_setscheduler_nocheck(struct task_struct *p, int policy, { return _sched_setscheduler(p, policy, param, false); }