@@ -2572,44 +2572,73 @@ pci_xhci_complete_commands(struct pci_xhci_vdev *xdev)
2572
2572
2573
2573
case XHCI_TRB_TYPE_DISABLE_SLOT : /* 0x0A */
2574
2574
slot = XHCI_TRB_3_SLOT_GET (trb -> dwTrb3 );
2575
- cmderr = pci_xhci_cmd_disable_slot (xdev , slot );
2575
+ /*
2576
+ * From spec 4.5.3.2 The only command that software is
2577
+ * allowed to issue for the slot in disabled state
2578
+ * is Enable Slot Command.
2579
+ * */
2580
+ if (xdev -> slot_allocated [slot ])
2581
+ cmderr = pci_xhci_cmd_disable_slot (xdev , slot );
2582
+ else
2583
+ cmderr = XHCI_TRB_ERROR_SLOT_NOT_ON ;
2576
2584
break ;
2577
2585
2578
2586
case XHCI_TRB_TYPE_ADDRESS_DEVICE : /* 0x0B */
2579
2587
slot = XHCI_TRB_3_SLOT_GET (trb -> dwTrb3 );
2580
- cmderr = pci_xhci_cmd_address_device (xdev , slot , trb );
2588
+ if (xdev -> slot_allocated [slot ])
2589
+ cmderr = pci_xhci_cmd_address_device (xdev , slot , trb );
2590
+ else
2591
+ cmderr = XHCI_TRB_ERROR_SLOT_NOT_ON ;
2581
2592
break ;
2582
2593
2583
2594
case XHCI_TRB_TYPE_CONFIGURE_EP : /* 0x0C */
2584
2595
slot = XHCI_TRB_3_SLOT_GET (trb -> dwTrb3 );
2585
- cmderr = pci_xhci_cmd_config_ep (xdev , slot , trb );
2596
+ if (xdev -> slot_allocated [slot ])
2597
+ cmderr = pci_xhci_cmd_config_ep (xdev , slot , trb );
2598
+ else
2599
+ cmderr = XHCI_TRB_ERROR_SLOT_NOT_ON ;
2586
2600
break ;
2587
2601
2588
2602
case XHCI_TRB_TYPE_EVALUATE_CTX : /* 0x0D */
2589
2603
slot = XHCI_TRB_3_SLOT_GET (trb -> dwTrb3 );
2590
- cmderr = pci_xhci_cmd_eval_ctx (xdev , slot , trb );
2604
+ if (xdev -> slot_allocated [slot ])
2605
+ cmderr = pci_xhci_cmd_eval_ctx (xdev , slot , trb );
2606
+ else
2607
+ cmderr = XHCI_TRB_ERROR_SLOT_NOT_ON ;
2591
2608
break ;
2592
2609
2593
2610
case XHCI_TRB_TYPE_RESET_EP : /* 0x0E */
2594
2611
UPRINTF (LDBG , "Reset Endpoint on slot %d\r\n" , slot );
2595
2612
slot = XHCI_TRB_3_SLOT_GET (trb -> dwTrb3 );
2596
- cmderr = pci_xhci_cmd_reset_ep (xdev , slot , trb );
2613
+ if (xdev -> slot_allocated [slot ])
2614
+ cmderr = pci_xhci_cmd_reset_ep (xdev , slot , trb );
2615
+ else
2616
+ cmderr = XHCI_TRB_ERROR_SLOT_NOT_ON ;
2597
2617
break ;
2598
2618
2599
2619
case XHCI_TRB_TYPE_STOP_EP : /* 0x0F */
2600
2620
UPRINTF (LDBG , "Stop Endpoint on slot %d\r\n" , slot );
2601
2621
slot = XHCI_TRB_3_SLOT_GET (trb -> dwTrb3 );
2602
- cmderr = pci_xhci_cmd_reset_ep (xdev , slot , trb );
2622
+ if (xdev -> slot_allocated [slot ])
2623
+ cmderr = pci_xhci_cmd_reset_ep (xdev , slot , trb );
2624
+ else
2625
+ cmderr = XHCI_TRB_ERROR_SLOT_NOT_ON ;
2603
2626
break ;
2604
2627
2605
2628
case XHCI_TRB_TYPE_SET_TR_DEQUEUE : /* 0x10 */
2606
2629
slot = XHCI_TRB_3_SLOT_GET (trb -> dwTrb3 );
2607
- cmderr = pci_xhci_cmd_set_tr (xdev , slot , trb );
2630
+ if (xdev -> slot_allocated [slot ])
2631
+ cmderr = pci_xhci_cmd_set_tr (xdev , slot , trb );
2632
+ else
2633
+ cmderr = XHCI_TRB_ERROR_SLOT_NOT_ON ;
2608
2634
break ;
2609
2635
2610
2636
case XHCI_TRB_TYPE_RESET_DEVICE : /* 0x11 */
2611
2637
slot = XHCI_TRB_3_SLOT_GET (trb -> dwTrb3 );
2612
- cmderr = pci_xhci_cmd_reset_device (xdev , slot );
2638
+ if (xdev -> slot_allocated [slot ])
2639
+ cmderr = pci_xhci_cmd_reset_device (xdev , slot );
2640
+ else
2641
+ cmderr = XHCI_TRB_ERROR_SLOT_NOT_ON ;
2613
2642
break ;
2614
2643
2615
2644
case XHCI_TRB_TYPE_FORCE_EVENT : /* 0x12 */
0 commit comments