Lines Matching refs:udev
1383 static int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
1389 if (!hcd || (check_ep && !ep) || !udev) {
1393 if (!udev->parent) {
1400 if (!udev->slot_id || !xhci->devs[udev->slot_id]) {
1406 virt_dev = xhci->devs[udev->slot_id];
1407 if (virt_dev->udev != udev) {
1408 xhci_dbg(xhci, "xHCI %s called with udev and "
1421 struct usb_device *udev, struct xhci_command *command,
1781 static int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1793 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
1800 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
1808 in_ctx = xhci->devs[udev->slot_id]->in_ctx;
1809 out_ctx = xhci->devs[udev->slot_id]->out_ctx;
1826 if (xhci->devs[udev->slot_id]->eps[ep_index].ring != NULL)
1838 xhci_debugfs_remove_endpoint(xhci, xhci->devs[udev->slot_id], ep_index);
1840 xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep);
1843 xhci_mtk_drop_ep_quirk(hcd, udev, ep);
1847 udev->slot_id,
1866 static int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1879 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
1900 virt_dev = xhci->devs[udev->slot_id];
1935 if (xhci_endpoint_init(xhci, virt_dev, udev, ep, GFP_NOIO) < 0) {
1936 dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n",
1942 ret = xhci_mtk_add_ep_quirk(hcd, udev, ep);
1962 ep->hcpriv = udev;
1969 udev->slot_id,
2010 struct usb_device *udev, u32 *cmd_status)
2021 dev_warn(&udev->dev,
2028 dev_warn(&udev->dev,
2035 dev_warn(&udev->dev, "ERROR: Endpoint drop flag = 0, "
2041 dev_warn(&udev->dev,
2060 struct usb_device *udev, u32 *cmd_status)
2071 dev_warn(&udev->dev,
2076 dev_warn(&udev->dev,
2081 dev_warn(&udev->dev,
2086 dev_warn(&udev->dev,
2092 dev_warn(&udev->dev, "WARN: Max Exit Latency too large\n");
2216 static unsigned int xhci_get_block_size(struct usb_device *udev)
2218 switch (udev->speed) {
2351 if (virt_dev->udev->speed >= USB_SPEED_SUPER)
2354 if (virt_dev->udev->speed == USB_SPEED_HIGH) {
2367 block_size = xhci_get_block_size(virt_dev->udev);
2484 if (!virt_dev->tt_info && virt_dev->udev->speed == USB_SPEED_HIGH) {
2542 struct usb_device *udev,
2552 if (udev->speed >= USB_SPEED_SUPER) {
2554 xhci->devs[udev->slot_id]->bw_table->ss_bw_in -=
2557 xhci->devs[udev->slot_id]->bw_table->ss_bw_out -=
2570 if (udev->speed == USB_SPEED_HIGH)
2579 switch (udev->speed) {
2606 struct usb_device *udev,
2617 if (udev->speed == USB_SPEED_SUPER) {
2619 xhci->devs[udev->slot_id]->bw_table->ss_bw_in +=
2622 xhci->devs[udev->slot_id]->bw_table->ss_bw_out +=
2630 if (udev->speed == USB_SPEED_HIGH)
2639 switch (udev->speed) {
2730 virt_dev->udev,
2742 virt_dev->udev,
2767 virt_dev->udev,
2779 virt_dev->udev,
2791 struct usb_device *udev,
2811 virt_dev = xhci->devs[udev->slot_id];
2846 udev->slot_id, must_succeed);
2850 udev->slot_id, must_succeed);
2866 ret = xhci_configure_endpoint_result(xhci, udev,
2869 ret = xhci_evaluate_context_result(xhci, udev,
2910 int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
2920 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
2928 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
2929 virt_dev = xhci->devs[udev->slot_id];
2968 ret = xhci_configure_endpoint(xhci, udev, command,
3008 void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
3014 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
3019 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
3020 virt_dev = xhci->devs[udev->slot_id];
3128 struct usb_device *udev;
3136 udev = (struct usb_device *)host_ep->hcpriv;
3137 if (!udev || !udev->slot_id)
3140 vdev = xhci->devs[udev->slot_id];
3180 struct usb_device *udev;
3193 udev = (struct usb_device *) host_ep->hcpriv;
3194 vdev = xhci->devs[udev->slot_id];
3201 if (!udev->slot_id || !vdev)
3246 dev_err(&udev->dev, "EP not empty, refuse reset\n");
3252 err = xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id,
3284 udev->slot_id, false);
3308 struct usb_device *udev, struct usb_host_endpoint *ep,
3317 ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__);
3374 struct usb_device *udev,
3384 ret = xhci_check_streams_endpoint(xhci, udev,
3385 eps[i], udev->slot_id);
3406 struct usb_device *udev,
3415 slot_id = udev->slot_id;
3462 static int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
3512 ret = xhci_calculate_streams_and_bitmask(xhci, udev, eps,
3526 vdev = xhci->devs[udev->slot_id];
3578 ret = xhci_configure_endpoint(xhci, udev, config_cmd,
3593 udev->slot_id, ep_index);
3629 static int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
3643 vdev = xhci->devs[udev->slot_id];
3648 udev, eps, num_eps);
3673 xhci->devs[udev->slot_id]->eps[ep_index].ep_state |=
3689 ret = xhci_configure_endpoint(xhci, udev, command,
3756 * If the virt_dev to be reset does not exist or does not match the udev,
3762 struct usb_device *udev)
3773 ret = xhci_check_args(hcd, udev, NULL, 0, false, __func__);
3777 slot_id = udev->slot_id;
3782 ret = xhci_alloc_dev(hcd, udev);
3792 if (virt_dev->udev != udev) {
3793 /* If the virt_dev and the udev does not match, this virt_dev
3794 * may belong to another udev.
3798 "not match the udev. Re-allocate the device\n",
3800 ret = xhci_alloc_dev(hcd, udev);
3903 udev,
3923 static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
3939 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
3946 virt_dev = xhci->devs[udev->slot_id];
3955 virt_dev->udev = NULL;
3956 xhci_disable_slot(xhci, udev->slot_id);
3959 xhci_free_virt_device(xhci, udev->slot_id);
4035 int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
4089 if (!xhci_alloc_virt_device(xhci, slot_id, udev, GFP_NOIO)) {
4097 udev->slot_id = slot_id;
4113 xhci_disable_slot(xhci, udev->slot_id);
4114 xhci_free_virt_device(xhci, udev->slot_id);
4123 static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
4143 if (!udev->slot_id) {
4145 "Bad Slot ID %d", udev->slot_id);
4150 virt_dev = xhci->devs[udev->slot_id];
4159 udev->slot_id);
4196 xhci_setup_addressable_virt_dev(xhci, udev);
4199 xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev);
4210 udev->slot_id, setup);
4236 act, udev->slot_id);
4240 dev_warn(&udev->dev, "Device not responding to setup %s.\n", act);
4243 ret = xhci_disable_slot(xhci, udev->slot_id);
4244 xhci_free_virt_device(xhci, udev->slot_id);
4246 if (xhci_alloc_dev(hcd, udev) == 1)
4247 xhci_setup_addressable_virt_dev(xhci, udev);
4253 dev_warn(&udev->dev,
4276 udev->slot_id,
4277 &xhci->dcbaa->dev_context_ptrs[udev->slot_id],
4279 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[udev->slot_id]));
4295 udev->devaddr = (u8)(le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK);
4309 static int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
4311 return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ADDRESS);
4314 static int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev)
4316 return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ONLY);
4338 struct usb_device *udev, u16 max_exit_latency)
4349 virt_dev = xhci->devs[udev->slot_id];
4385 ret = xhci_configure_endpoint(xhci, udev, command,
4404 struct usb_device *udev)
4411 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4438 static int xhci_calculate_usb2_hw_lpm_params(struct usb_device *udev)
4445 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4448 l1 = udev->l1_params.timeout / 256;
4460 struct usb_device *udev, int enable)
4475 !udev->lpm_capable)
4478 if (!udev->parent || udev->parent->parent ||
4479 udev->descriptor.bDeviceClass == USB_CLASS_HUB)
4482 if (udev->usb2_hw_lpm_capable != 1)
4488 port_num = udev->portnum - 1;
4498 if (udev->usb2_hw_lpm_besl_capable) {
4503 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4508 hird = udev->l1_params.besl;
4521 ret = xhci_change_max_exit_latency(xhci, udev,
4529 hlpm_val = xhci_calculate_usb2_hw_lpm_params(udev);
4534 hird = xhci_calculate_hird_besl(xhci, udev);
4538 pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev->slot_id);
4550 if (udev->usb2_hw_lpm_besl_capable) {
4553 xhci_change_max_exit_latency(xhci, udev, 0);
4589 static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
4592 int portnum = udev->portnum - 1;
4594 if (hcd->speed >= HCD_USB3 || !udev->lpm_capable)
4598 if (!udev->parent || udev->parent->parent ||
4599 udev->descriptor.bDeviceClass == USB_CLASS_HUB)
4605 udev->usb2_hw_lpm_capable = 1;
4606 udev->l1_params.timeout = XHCI_L1_TIMEOUT;
4607 udev->l1_params.besl = XHCI_DEFAULT_BESL;
4610 udev->usb2_hw_lpm_besl_capable = 1;
4625 static u16 xhci_get_timeout_no_hub_lpm(struct usb_device *udev,
4636 sel = DIV_ROUND_UP(udev->u1_params.sel, 1000);
4637 pel = DIV_ROUND_UP(udev->u1_params.pel, 1000);
4642 sel = DIV_ROUND_UP(udev->u2_params.sel, 1000);
4643 pel = DIV_ROUND_UP(udev->u2_params.pel, 1000);
4648 dev_warn(&udev->dev, "%s: Can't get timeout for non-U1 or U2 state.\n",
4657 dev_dbg(&udev->dev, "Device-initiated %s disabled "
4661 dev_dbg(&udev->dev, "Device-initiated %s disabled "
4676 struct usb_device *udev,
4686 timeout_ns = udev->u1_params.sel * 3;
4689 timeout_ns = udev->u1_params.sel * 5;
4694 timeout_ns = udev->u1_params.sel * 3;
4702 if (timeout_ns < udev->u1_params.sel * 2)
4703 timeout_ns = udev->u1_params.sel * 2;
4714 struct usb_device *udev,
4721 if (xhci_service_interval_to_ns(desc) <= udev->u1_params.mel) {
4722 dev_dbg(&udev->dev, "Disable U1, ESIT shorter than exit latency\n");
4728 timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
4730 timeout_ns = udev->u1_params.sel;
4745 dev_dbg(&udev->dev, "Hub-initiated U1 disabled "
4747 return xhci_get_timeout_no_hub_lpm(udev, USB3_LPM_U1);
4757 struct usb_device *udev,
4769 u2_del_ns = le16_to_cpu(udev->bos->ss_cap->bU2DevExitLat) * 1000ULL;
4778 struct usb_device *udev,
4785 if (xhci_service_interval_to_ns(desc) <= udev->u2_params.mel) {
4786 dev_dbg(&udev->dev, "Disable U2, ESIT shorter than exit latency\n");
4792 timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
4794 timeout_ns = udev->u2_params.sel;
4803 dev_dbg(&udev->dev, "Hub-initiated U2 disabled "
4805 return xhci_get_timeout_no_hub_lpm(udev, USB3_LPM_U2);
4809 struct usb_device *udev,
4815 return xhci_calculate_u1_timeout(xhci, udev, desc);
4817 return xhci_calculate_u2_timeout(xhci, udev, desc);
4823 struct usb_device *udev,
4830 alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev,
4848 struct usb_device *udev,
4856 if (xhci_update_timeout_for_endpoint(xhci, udev,
4864 static int xhci_check_intel_tier_policy(struct usb_device *udev,
4874 for (parent = udev->parent, num_hubs = 0; parent->parent;
4881 dev_dbg(&udev->dev, "Disabling U1 link state for device"
4883 dev_dbg(&udev->dev, "Plug device into first-tier hub "
4889 struct usb_device *udev,
4893 return xhci_check_intel_tier_policy(udev, state);
4904 struct usb_device *udev, enum usb3_link_state state)
4917 dev_warn(&udev->dev, "Can't enable unknown link state %i\n",
4922 if (xhci_check_tier_policy(xhci, udev, state) < 0)
4928 if (xhci_update_timeout_for_endpoint(xhci, udev, &udev->ep0.desc,
4932 config = udev->actconfig;
4949 dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n",
4951 timeout = xhci_get_timeout_no_hub_lpm(udev,
4962 if (xhci_update_timeout_for_interface(xhci, udev,
4970 static int calculate_max_exit_latency(struct usb_device *udev,
4995 if ((udev->u1_params.timeout != USB3_LPM_DISABLED && !disabling_u1) ||
4997 u1_mel_us = DIV_ROUND_UP(udev->u1_params.mel, 1000);
4998 if ((udev->u2_params.timeout != USB3_LPM_DISABLED && !disabling_u2) ||
5000 u2_mel_us = DIV_ROUND_UP(udev->u2_params.mel, 1000);
5008 dev_warn(&udev->dev, "Link PM max exit latency of %lluus "
5017 struct usb_device *udev, enum usb3_link_state state)
5031 !xhci->devs[udev->slot_id])
5035 if (udev->parent && !udev->parent->parent) {
5036 port = xhci->usb3_rhub.ports[udev->portnum - 1];
5041 hub_encoded_timeout = xhci_calculate_lpm_timeout(hcd, udev, state);
5042 mel = calculate_max_exit_latency(udev, state, hub_encoded_timeout);
5049 ret = xhci_change_max_exit_latency(xhci, udev, mel);
5056 struct usb_device *udev, enum usb3_link_state state)
5063 !xhci->devs[udev->slot_id])
5066 mel = calculate_max_exit_latency(udev, state, USB3_LPM_DISABLED);
5067 return xhci_change_max_exit_latency(xhci, udev, mel);
5072 struct usb_device *udev, int enable)
5077 static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
5083 struct usb_device *udev, enum usb3_link_state state)
5089 struct usb_device *udev, enum usb3_link_state state)
5370 struct usb_device *udev;
5378 udev = (struct usb_device *)ep->hcpriv;
5379 slot_id = udev->slot_id;