diff --git a/linux-5.10/rk3568_patch/kernel.patch b/linux-5.10/rk3568_patch/kernel.patch index b1e73a2048f8f8e6dc9f655cb01b68254780cd34..6a858122be3dadbc45c74db29b6fa6ac3a774031 100755 --- a/linux-5.10/rk3568_patch/kernel.patch +++ b/linux-5.10/rk3568_patch/kernel.patch @@ -1627410,8 +1627410,7 @@ index b69b8c7e7966..78345e425264 - } else { - td_to_noop(xhci, ep_ring, cur_td, false); - } -+ ep_ctx = xhci_get_ep_ctx(xhci, ep->vdev->out_ctx, ep_index); - +- -remove_finished_td: - /* - * The event handler won't see a completion for this TD anymore, @@ -1627422,7 +1627421,8 @@ index b69b8c7e7966..78345e425264 - } - - xhci_stop_watchdog_timer_in_irq(xhci, ep); -- ++ ep_ctx = xhci_get_ep_ctx(xhci, ep->vdev->out_ctx, ep_index); + - /* If necessary, queue a Set Transfer Ring Dequeue Pointer command */ - if (deq_state.new_deq_ptr && deq_state.new_deq_seg) { - xhci_queue_new_dequeue_state(xhci, slot_id, ep_index, @@ -1627750,23 +1627750,9 @@ index b69b8c7e7966..78345e425264 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); -@@ -2062,29 +2155,60 @@ int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code) - return 0; - } +@@ -2070,18 +2163,52 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, --static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, -- struct xhci_transfer_event *event, struct xhci_virt_ep *ep) -+static int finish_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, -+ struct xhci_ring *ep_ring, struct xhci_td *td, -+ u32 trb_comp_code) - { - struct xhci_ep_ctx *ep_ctx; -- struct xhci_ring *ep_ring; -- u32 trb_comp_code; - -- ep_ring = xhci_dma_to_transfer_ring(ep, le64_to_cpu(event->buffer)); ep_ctx = xhci_get_ep_ctx(xhci, ep->vdev->out_ctx, ep->ep_index); -- trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len)); - if (trb_comp_code == COMP_STOPPED_LENGTH_INVALID || - trb_comp_code == COMP_STOPPED || @@ -1627826,7 +1627812,7 @@ index b69b8c7e7966..78345e425264 /* * xhci internal endpoint state will go to a "halt" state for * any stall, including default control pipe protocol stall. -@@ -2095,18 +2219,23 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2092,19 +2219,23 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, * stall later. Hub TT buffer should only be cleared for FS/LS * devices behind HS hubs for functional stalls. */ @@ -1627838,8 +1627824,9 @@ index b69b8c7e7966..78345e425264 - EP_HARD_RESET); - } else { - /* Update ring dequeue pointer */ -- while (ep_ring->dequeue != td->last_trb) -- inc_deq(xhci, ep_ring); +- ep_ring->dequeue = td->last_trb; +- ep_ring->deq_seg = td->last_trb_seg; +- ep_ring->num_trbs_free += td->num_trbs - 1; - inc_deq(xhci, ep_ring); + EP_HARD_RESET); + @@ -1627857,95 +1627844,7 @@ index b69b8c7e7966..78345e425264 return xhci_td_cleanup(xhci, td, ep_ring, td->status); } -@@ -2128,9 +2257,9 @@ static int sum_trb_lengths(struct xhci_hcd *xhci, struct xhci_ring *ring, - /* - * Process control tds, update urb status and actual_length. - */ --static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, -- union xhci_trb *ep_trb, struct xhci_transfer_event *event, -- struct xhci_virt_ep *ep) -+static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, -+ struct xhci_ring *ep_ring, struct xhci_td *td, -+ union xhci_trb *ep_trb, struct xhci_transfer_event *event) - { - struct xhci_ep_ctx *ep_ctx; - u32 trb_comp_code; -@@ -2218,18 +2347,19 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, - td->urb->actual_length = requested; - - finish_td: -- return finish_td(xhci, td, event, ep); -+ return finish_td(xhci, ep, ep_ring, td, trb_comp_code); - } - - /* - * Process isochronous tds, update urb packet status and actual_length. - */ --static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, -- union xhci_trb *ep_trb, struct xhci_transfer_event *event, -- struct xhci_virt_ep *ep) -+static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, -+ struct xhci_ring *ep_ring, struct xhci_td *td, -+ union xhci_trb *ep_trb, struct xhci_transfer_event *event) - { - struct urb_priv *urb_priv; - int idx; -+ - struct usb_iso_packet_descriptor *frame; - u32 trb_comp_code; - bool sum_trbs_for_length = false; -@@ -2303,7 +2433,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, - - td->urb->actual_length += frame->actual_length; - -- return finish_td(xhci, td, event, ep); -+ return finish_td(xhci, ep, ep_ring, td, trb_comp_code); - } - - static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, -@@ -2324,8 +2454,9 @@ static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, - frame->actual_length = 0; - - /* Update ring dequeue pointer */ -- while (ep->ring->dequeue != td->last_trb) -- inc_deq(xhci, ep->ring); -+ ep->ring->dequeue = td->last_trb; -+ ep->ring->deq_seg = td->last_trb_seg; -+ ep->ring->num_trbs_free += td->num_trbs - 1; - inc_deq(xhci, ep->ring); - - return xhci_td_cleanup(xhci, td, ep->ring, status); -@@ -2334,17 +2465,15 @@ static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, - /* - * Process bulk and interrupt tds, update urb status and actual_length. - */ --static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, -- union xhci_trb *ep_trb, struct xhci_transfer_event *event, -- struct xhci_virt_ep *ep) -+static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, -+ struct xhci_ring *ep_ring, struct xhci_td *td, -+ union xhci_trb *ep_trb, struct xhci_transfer_event *event) - { - struct xhci_slot_ctx *slot_ctx; -- struct xhci_ring *ep_ring; - u32 trb_comp_code; - u32 remaining, requested, ep_trb_len; - - slot_ctx = xhci_get_slot_ctx(xhci, ep->vdev->out_ctx); -- ep_ring = xhci_dma_to_transfer_ring(ep, le64_to_cpu(event->buffer)); - 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])); -@@ -2404,7 +2533,7 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, - remaining); - td->urb->actual_length = 0; - } -- return finish_td(xhci, td, event, ep); -+ return finish_td(xhci, ep, ep_ring, td, trb_comp_code); - } - - /* -@@ -2415,7 +2544,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, +@@ -2432,7 +2563,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, static int handle_tx_event(struct xhci_hcd *xhci, struct xhci_transfer_event *event) { @@ -1627953,7 +1627852,7 @@ index b69b8c7e7966..78345e425264 struct xhci_virt_ep *ep; struct xhci_ring *ep_ring; unsigned int slot_id; -@@ -2442,9 +2570,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2459,9 +2589,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, goto err_out; } @@ -1627964,7 +1627863,7 @@ index b69b8c7e7966..78345e425264 if (GET_EP_CTX_STATE(ep_ctx) == EP_STATE_DISABLED) { xhci_err(xhci, -@@ -2522,7 +2649,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2539,7 +2668,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); @@ -1627972,22 +1627871,7 @@ index b69b8c7e7966..78345e425264 status = -EPIPE; break; case COMP_SPLIT_TRANSACTION_ERROR: -@@ -2755,11 +2881,11 @@ static int handle_tx_event(struct xhci_hcd *xhci, - - /* update the urb's actual_length and give back to the core */ - if (usb_endpoint_xfer_control(&td->urb->ep->desc)) -- process_ctrl_td(xhci, td, ep_trb, event, ep); -+ process_ctrl_td(xhci, ep, ep_ring, td, ep_trb, event); - else if (usb_endpoint_xfer_isoc(&td->urb->ep->desc)) -- process_isoc_td(xhci, td, ep_trb, event, ep); -+ process_isoc_td(xhci, ep, ep_ring, td, ep_trb, event); - else -- process_bulk_intr_td(xhci, td, ep_trb, event, ep); -+ process_bulk_intr_td(xhci, ep, ep_ring, td, ep_trb, event); - cleanup: - handling_skipped_tds = ep->skip && - trb_comp_code != COMP_MISSED_SERVICE_ERROR && -@@ -2800,10 +2926,11 @@ static int handle_tx_event(struct xhci_hcd *xhci, +@@ -2848,10 +2976,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. */ @@ -1628000,7 +1627884,7 @@ index b69b8c7e7966..78345e425264 int ret; /* Event ring hasn't been allocated yet. */ -@@ -2825,31 +2952,30 @@ static int xhci_handle_event(struct xhci_hcd *xhci) +@@ -2873,31 +3002,30 @@ static int xhci_handle_event(struct xhci_hcd *xhci) * speculative reads of the event's flags/data below. */ rmb(); @@ -1628042,7 +1627926,7 @@ index b69b8c7e7966..78345e425264 } /* 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. -@@ -2869,13 +2995,14 @@ static int xhci_handle_event(struct xhci_hcd *xhci) +@@ -2917,13 +3045,14 @@ static int xhci_handle_event(struct xhci_hcd *xhci) */ return 1; } @@ -1628058,7 +1627942,7 @@ index b69b8c7e7966..78345e425264 union xhci_trb *event_ring_deq) { u64 temp_64; -@@ -2905,6 +3032,16 @@ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci, +@@ -2953,6 +3082,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); } @@ -1628075,7 +1627959,7 @@ index b69b8c7e7966..78345e425264 /* * xHCI spec says we can get an interrupt, and if the HC has an error condition, -@@ -2940,6 +3077,10 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) +@@ -2988,6 +3127,10 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) goto out; } @@ -1628086,7 +1627970,7 @@ index b69b8c7e7966..78345e425264 /* * Clear the op reg interrupt status first, * so we can receive interrupts from other MSI-X interrupters. -@@ -3032,6 +3173,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, +@@ -3080,6 +3223,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; @@ -1628094,7 +1627978,7 @@ index b69b8c7e7966..78345e425264 /* Make sure the endpoint has been added to xHC schedule */ switch (ep_state) { -@@ -3102,7 +3244,19 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, +@@ -3150,7 +3294,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; @@ -1628114,7 +1627998,7 @@ index b69b8c7e7966..78345e425264 return 0; } -@@ -3121,7 +3275,8 @@ static int prepare_transfer(struct xhci_hcd *xhci, +@@ -3169,7 +3325,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); @@ -1628124,68 +1628008,15 @@ index b69b8c7e7966..78345e425264 if (!ep_ring) { xhci_dbg(xhci, "Can't prepare ring for bad stream ID %u\n", stream_id); -@@ -3490,7 +3645,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; -- -+ td->last_trb_seg = ring->enq_seg; - if (xhci_urb_suitable_for_idt(urb)) { - memcpy(&send_addr, urb->transfer_buffer, - trb_buff_len); -@@ -3516,7 +3671,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, - upper_32_bits(send_addr), - length_field, - field); -- -+ td->num_trbs++; - addr += trb_buff_len; - sent_len = trb_buff_len; - -@@ -3540,8 +3695,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; -+ urb_priv->td[1].last_trb_seg = ring->enq_seg; - field = TRB_TYPE(TRB_NORMAL) | ring->cycle_state | TRB_IOC; - queue_trb(xhci, ring, 0, 0, 0, TRB_INTR_TARGET(0), field); -+ urb_priv->td[1].num_trbs++; - } +@@ -3488,6 +3645,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, + need_zero_pkt = true; - check_trb_math(urb, enqd_len); -@@ -3592,6 +3749,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, - - urb_priv = urb->hcpriv; td = &urb_priv->td[0]; + td->num_trbs = num_trbs; /* * Don't give the first TRB to the hardware (by toggling the cycle bit) -@@ -3664,6 +3822,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; -+ td->last_trb_seg = ep_ring->enq_seg; - - /* 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 */ -@@ -3908,6 +4067,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, - goto cleanup; - } - td = &urb_priv->td[i]; -+ td->num_trbs = trbs_per_td; - - /* use SIA as default, if frame id is used overwrite it */ - sia_frame_id = TRB_SIA; -@@ -3951,6 +4111,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; -+ td->last_trb_seg = ep_ring->enq_seg; - field |= TRB_IOC; - if (trb_block_event_intr(xhci, num_tds, i)) - field |= TRB_BEI; -@@ -4233,71 +4394,7 @@ int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, struct xhci_command *cmd, +@@ -4286,71 +4444,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); } @@ -1628714,7 +1628545,7 @@ index c7749f6e3474..06243f940bd4 /* Nec vendor-specific command completion event. */ #define TRB_NEC_CMD_COMP 48 /* Get NEC firmware revision. */ -@@ -1542,17 +1542,27 @@ struct xhci_segment { +@@ -1542,10 +1542,18 @@ struct xhci_segment { unsigned int bounce_len; }; @@ -1628733,16 +1628564,7 @@ index c7749f6e3474..06243f940bd4 struct urb *urb; struct xhci_segment *start_seg; union xhci_trb *first_trb; - union xhci_trb *last_trb; -+ struct xhci_segment *last_trb_seg; - struct xhci_segment *bounce_seg; - /* actual_length of the URB has already been set */ - bool urb_length_set; -+ unsigned int num_trbs; - }; - - /* xHCI command default timeout value */ -@@ -1564,13 +1574,6 @@ struct xhci_cd { +@@ -1567,13 +1575,6 @@ struct xhci_cd { union xhci_trb *cmd_trb; }; @@ -1628756,7 +1628578,7 @@ index c7749f6e3474..06243f940bd4 enum xhci_ring_type { TYPE_CTRL = 0, TYPE_ISOC, -@@ -1923,6 +1926,7 @@ struct xhci_hcd { +@@ -1928,6 +1929,7 @@ struct xhci_hcd { struct list_head regset_list; void *dbc; @@ -1628764,7 +1628586,7 @@ index c7749f6e3474..06243f940bd4 /* platform-specific data -- must come last */ unsigned long priv[] __aligned(sizeof(s64)); }; -@@ -1932,8 +1936,15 @@ struct xhci_driver_overrides { +@@ -1937,8 +1939,15 @@ struct xhci_driver_overrides { size_t extra_priv_size; int (*reset)(struct usb_hcd *hcd); int (*start)(struct usb_hcd *hcd); @@ -1628780,7 +1628602,7 @@ index c7749f6e3474..06243f940bd4 int (*update_hub_device)(struct usb_hcd *hcd, struct usb_device *hdev, struct usb_tt *tt, gfp_t mem_flags); }; -@@ -2062,10 +2073,6 @@ void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci, +@@ -2067,10 +2076,6 @@ void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci, struct xhci_ring *xhci_dma_to_transfer_ring( struct xhci_virt_ep *ep, u64 address); @@ -1628791,7 +1628613,7 @@ index c7749f6e3474..06243f940bd4 struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, bool allocate_completion, gfp_t mem_flags); struct xhci_command *xhci_alloc_command_with_ctx(struct xhci_hcd *xhci, -@@ -2090,8 +2097,13 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); +@@ -2095,8 +2100,13 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); void xhci_shutdown(struct usb_hcd *hcd); void xhci_init_driver(struct hc_driver *drv, const struct xhci_driver_overrides *over); @@ -1628805,7 +1628627,7 @@ index c7749f6e3474..06243f940bd4 int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev, struct usb_tt *tt, gfp_t mem_flags); int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id); -@@ -2141,13 +2153,6 @@ int xhci_queue_reset_ep(struct xhci_hcd *xhci, struct xhci_command *cmd, +@@ -2146,13 +2156,6 @@ int xhci_queue_reset_ep(struct xhci_hcd *xhci, struct xhci_command *cmd, enum xhci_ep_reset_type reset_type); int xhci_queue_reset_device(struct xhci_hcd *xhci, struct xhci_command *cmd, u32 slot_id); @@ -1628819,7 +1628641,7 @@ index c7749f6e3474..06243f940bd4 void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, unsigned int slot_id, unsigned int ep_index, unsigned int stream_id, struct xhci_td *td); -@@ -2208,6 +2213,53 @@ static inline struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, +@@ -2213,6 +2216,53 @@ static inline struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, urb->stream_id); }