Lines Matching refs:udev

1372 static int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
1378 if (!hcd || (check_ep && !ep) || !udev) {
1382 if (!udev->parent) {
1389 if (!udev->slot_id || !xhci->devs[udev->slot_id]) {
1395 virt_dev = xhci->devs[udev->slot_id];
1396 if (virt_dev->udev != udev) {
1397 xhci_dbg(xhci, "xHCI %s called with udev and "
1410 struct usb_device *udev, struct xhci_command *command,
1770 int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1782 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
1789 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
1797 in_ctx = xhci->devs[udev->slot_id]->in_ctx;
1798 out_ctx = xhci->devs[udev->slot_id]->out_ctx;
1815 if (xhci->devs[udev->slot_id]->eps[ep_index].ring != NULL)
1827 xhci_debugfs_remove_endpoint(xhci, xhci->devs[udev->slot_id], ep_index);
1829 xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep);
1833 udev->slot_id,
1853 int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1866 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
1887 virt_dev = xhci->devs[udev->slot_id];
1922 if (xhci_endpoint_init(xhci, virt_dev, udev, ep, GFP_NOIO) < 0) {
1923 dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n",
1940 ep->hcpriv = udev;
1947 udev->slot_id,
1989 struct usb_device *udev, u32 *cmd_status)
2000 dev_warn(&udev->dev,
2007 dev_warn(&udev->dev,
2014 dev_warn(&udev->dev, "ERROR: Endpoint drop flag = 0, "
2020 dev_warn(&udev->dev,
2039 struct usb_device *udev, u32 *cmd_status)
2050 dev_warn(&udev->dev,
2055 dev_warn(&udev->dev,
2060 dev_warn(&udev->dev,
2065 dev_warn(&udev->dev,
2071 dev_warn(&udev->dev, "WARN: Max Exit Latency too large\n");
2195 static unsigned int xhci_get_block_size(struct usb_device *udev)
2197 switch (udev->speed) {
2329 if (virt_dev->udev->speed >= USB_SPEED_SUPER)
2332 if (virt_dev->udev->speed == USB_SPEED_HIGH) {
2345 block_size = xhci_get_block_size(virt_dev->udev);
2462 if (!virt_dev->tt_info && virt_dev->udev->speed == USB_SPEED_HIGH) {
2520 struct usb_device *udev,
2530 if (udev->speed >= USB_SPEED_SUPER) {
2532 xhci->devs[udev->slot_id]->bw_table->ss_bw_in -=
2535 xhci->devs[udev->slot_id]->bw_table->ss_bw_out -=
2548 if (udev->speed == USB_SPEED_HIGH)
2557 switch (udev->speed) {
2581 struct usb_device *udev,
2592 if (udev->speed == USB_SPEED_SUPER) {
2594 xhci->devs[udev->slot_id]->bw_table->ss_bw_in +=
2597 xhci->devs[udev->slot_id]->bw_table->ss_bw_out +=
2605 if (udev->speed == USB_SPEED_HIGH)
2614 switch (udev->speed) {
2702 virt_dev->udev,
2714 virt_dev->udev,
2739 virt_dev->udev,
2751 virt_dev->udev,
2763 struct usb_device *udev,
2783 virt_dev = xhci->devs[udev->slot_id];
2818 udev->slot_id, must_succeed);
2822 udev->slot_id, must_succeed);
2838 ret = xhci_configure_endpoint_result(xhci, udev,
2841 ret = xhci_evaluate_context_result(xhci, udev,
2882 int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
2892 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
2900 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
2901 virt_dev = xhci->devs[udev->slot_id];
2940 ret = xhci_configure_endpoint(xhci, udev, command,
2981 void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
2987 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
2992 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
2993 virt_dev = xhci->devs[udev->slot_id];
3024 struct usb_device *udev;
3032 udev = (struct usb_device *)host_ep->hcpriv;
3033 if (!udev || !udev->slot_id)
3036 vdev = xhci->devs[udev->slot_id];
3074 struct usb_device *udev;
3087 udev = (struct usb_device *) host_ep->hcpriv;
3088 vdev = xhci->devs[udev->slot_id];
3095 if (!udev->slot_id || !vdev)
3138 dev_err(&udev->dev, "EP not empty, refuse reset\n");
3144 err = xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id,
3176 udev->slot_id, false);
3200 struct usb_device *udev, struct usb_host_endpoint *ep,
3209 ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__);
3266 struct usb_device *udev,
3276 ret = xhci_check_streams_endpoint(xhci, udev,
3277 eps[i], udev->slot_id);
3298 struct usb_device *udev,
3307 slot_id = udev->slot_id;
3354 static int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
3404 ret = xhci_calculate_streams_and_bitmask(xhci, udev, eps,
3418 vdev = xhci->devs[udev->slot_id];
3470 ret = xhci_configure_endpoint(xhci, udev, config_cmd,
3485 udev->slot_id, ep_index);
3521 static int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
3535 vdev = xhci->devs[udev->slot_id];
3540 udev, eps, num_eps);
3565 xhci->devs[udev->slot_id]->eps[ep_index].ep_state |=
3581 ret = xhci_configure_endpoint(xhci, udev, command,
3648 * If the virt_dev to be reset does not exist or does not match the udev,
3654 struct usb_device *udev)
3665 ret = xhci_check_args(hcd, udev, NULL, 0, false, __func__);
3669 slot_id = udev->slot_id;
3674 ret = xhci_alloc_dev(hcd, udev);
3684 if (virt_dev->udev != udev) {
3685 /* If the virt_dev and the udev does not match, this virt_dev
3686 * may belong to another udev.
3690 "not match the udev. Re-allocate the device\n",
3692 ret = xhci_alloc_dev(hcd, udev);
3795 udev,
3815 static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
3831 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
3838 virt_dev = xhci->devs[udev->slot_id];
3845 virt_dev->udev = NULL;
3846 xhci_disable_slot(xhci, udev->slot_id);
3849 xhci_free_virt_device(xhci, udev->slot_id);
3925 int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
3980 if (!xhci_alloc_virt_device(xhci, slot_id, udev, GFP_NOIO)) {
3988 udev->slot_id = slot_id;
4004 xhci_disable_slot(xhci, udev->slot_id);
4005 xhci_free_virt_device(xhci, udev->slot_id);
4014 static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
4034 if (!udev->slot_id) {
4036 "Bad Slot ID %d", udev->slot_id);
4041 virt_dev = xhci->devs[udev->slot_id];
4050 udev->slot_id);
4087 xhci_setup_addressable_virt_dev(xhci, udev);
4090 xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev);
4101 udev->slot_id, setup);
4127 act, udev->slot_id);
4131 dev_warn(&udev->dev, "Device not responding to setup %s.\n", act);
4134 ret = xhci_disable_slot(xhci, udev->slot_id);
4135 xhci_free_virt_device(xhci, udev->slot_id);
4137 xhci_alloc_dev(hcd, udev);
4142 dev_warn(&udev->dev,
4165 udev->slot_id,
4166 &xhci->dcbaa->dev_context_ptrs[udev->slot_id],
4168 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[udev->slot_id]));
4184 udev->devaddr = (u8)(le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK);
4198 static int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
4200 return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ADDRESS);
4203 static int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev)
4205 return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ONLY);
4227 struct usb_device *udev, u16 max_exit_latency)
4242 virt_dev = xhci->devs[udev->slot_id];
4279 ret = xhci_configure_endpoint(xhci, udev, command,
4301 struct usb_device *udev)
4308 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4335 static int xhci_calculate_usb2_hw_lpm_params(struct usb_device *udev)
4342 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4345 l1 = udev->l1_params.timeout / 256;
4357 struct usb_device *udev, int enable)
4372 !udev->lpm_capable)
4375 if (!udev->parent || udev->parent->parent ||
4376 udev->descriptor.bDeviceClass == USB_CLASS_HUB)
4379 if (udev->usb2_hw_lpm_capable != 1)
4385 port_num = udev->portnum - 1;
4395 if (udev->usb2_hw_lpm_besl_capable) {
4400 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4405 hird = udev->l1_params.besl;
4410 ret = xhci_change_max_exit_latency(xhci, udev,
4416 hlpm_val = xhci_calculate_usb2_hw_lpm_params(udev);
4421 hird = xhci_calculate_hird_besl(xhci, udev);
4425 pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev->slot_id);
4437 if (udev->usb2_hw_lpm_besl_capable) {
4439 xhci_change_max_exit_latency(xhci, udev, 0);
4474 static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
4477 int portnum = udev->portnum - 1;
4479 if (hcd->speed >= HCD_USB3 || !udev->lpm_capable)
4483 if (!udev->parent || udev->parent->parent ||
4484 udev->descriptor.bDeviceClass == USB_CLASS_HUB)
4490 udev->usb2_hw_lpm_capable = 1;
4491 udev->l1_params.timeout = XHCI_L1_TIMEOUT;
4492 udev->l1_params.besl = XHCI_DEFAULT_BESL;
4495 udev->usb2_hw_lpm_besl_capable = 1;
4510 static u16 xhci_get_timeout_no_hub_lpm(struct usb_device *udev,
4521 sel = DIV_ROUND_UP(udev->u1_params.sel, 1000);
4522 pel = DIV_ROUND_UP(udev->u1_params.pel, 1000);
4527 sel = DIV_ROUND_UP(udev->u2_params.sel, 1000);
4528 pel = DIV_ROUND_UP(udev->u2_params.pel, 1000);
4533 dev_warn(&udev->dev, "%s: Can't get timeout for non-U1 or U2 state.\n",
4542 dev_dbg(&udev->dev, "Device-initiated %s disabled "
4546 dev_dbg(&udev->dev, "Device-initiated %s disabled "
4561 struct usb_device *udev,
4571 timeout_ns = udev->u1_params.sel * 3;
4574 timeout_ns = udev->u1_params.sel * 5;
4579 timeout_ns = udev->u1_params.sel * 3;
4587 if (timeout_ns < udev->u1_params.sel * 2)
4588 timeout_ns = udev->u1_params.sel * 2;
4599 struct usb_device *udev,
4606 if (xhci_service_interval_to_ns(desc) <= udev->u1_params.mel) {
4607 dev_dbg(&udev->dev, "Disable U1, ESIT shorter than exit latency\n");
4613 timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
4615 timeout_ns = udev->u1_params.sel;
4630 dev_dbg(&udev->dev, "Hub-initiated U1 disabled "
4632 return xhci_get_timeout_no_hub_lpm(udev, USB3_LPM_U1);
4642 struct usb_device *udev,
4654 u2_del_ns = le16_to_cpu(udev->bos->ss_cap->bU2DevExitLat) * 1000ULL;
4663 struct usb_device *udev,
4670 if (xhci_service_interval_to_ns(desc) <= udev->u2_params.mel) {
4671 dev_dbg(&udev->dev, "Disable U2, ESIT shorter than exit latency\n");
4677 timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
4679 timeout_ns = udev->u2_params.sel;
4688 dev_dbg(&udev->dev, "Hub-initiated U2 disabled "
4690 return xhci_get_timeout_no_hub_lpm(udev, USB3_LPM_U2);
4694 struct usb_device *udev,
4700 return xhci_calculate_u1_timeout(xhci, udev, desc);
4702 return xhci_calculate_u2_timeout(xhci, udev, desc);
4708 struct usb_device *udev,
4715 alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev,
4733 struct usb_device *udev,
4741 if (xhci_update_timeout_for_endpoint(xhci, udev,
4749 struct usb_device *udev,
4752 struct usb_device *parent = udev->parent;
4767 dev_dbg(&udev->dev, "Tier policy prevents U1/U2 LPM states for devices at tier %d\n",
4778 struct usb_device *udev, enum usb3_link_state state)
4791 dev_warn(&udev->dev, "Can't enable unknown link state %i\n",
4799 if (xhci_update_timeout_for_endpoint(xhci, udev, &udev->ep0.desc,
4803 config = udev->actconfig;
4820 dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n",
4822 timeout = xhci_get_timeout_no_hub_lpm(udev,
4833 if (xhci_update_timeout_for_interface(xhci, udev,
4841 static int calculate_max_exit_latency(struct usb_device *udev,
4866 if ((udev->u1_params.timeout != USB3_LPM_DISABLED && !disabling_u1) ||
4868 u1_mel_us = DIV_ROUND_UP(udev->u1_params.mel, 1000);
4869 if ((udev->u2_params.timeout != USB3_LPM_DISABLED && !disabling_u2) ||
4871 u2_mel_us = DIV_ROUND_UP(udev->u2_params.mel, 1000);
4877 dev_warn(&udev->dev, "Link PM max exit latency of %lluus "
4886 struct usb_device *udev, enum usb3_link_state state)
4900 !xhci->devs[udev->slot_id])
4903 if (xhci_check_tier_policy(xhci, udev, state) < 0)
4907 if (udev->parent && !udev->parent->parent) {
4908 port = xhci->usb3_rhub.ports[udev->portnum - 1];
4913 hub_encoded_timeout = xhci_calculate_lpm_timeout(hcd, udev, state);
4914 mel = calculate_max_exit_latency(udev, state, hub_encoded_timeout);
4921 ret = xhci_change_max_exit_latency(xhci, udev, mel);
4928 struct usb_device *udev, enum usb3_link_state state)
4935 !xhci->devs[udev->slot_id])
4938 mel = calculate_max_exit_latency(udev, state, USB3_LPM_DISABLED);
4939 return xhci_change_max_exit_latency(xhci, udev, mel);
4944 struct usb_device *udev, int enable)
4949 static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
4955 struct usb_device *udev, enum usb3_link_state state)
4961 struct usb_device *udev, enum usb3_link_state state)
5256 struct usb_device *udev;
5264 udev = (struct usb_device *)ep->hcpriv;
5265 slot_id = udev->slot_id;