Lines Matching defs:udev

1493 static int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
1499 if (!hcd || (check_ep && !ep) || !udev) {
1503 if (!udev->parent) {
1510 if (!udev->slot_id || !xhci->devs[udev->slot_id]) {
1516 virt_dev = xhci->devs[udev->slot_id];
1517 if (virt_dev->udev != udev) {
1518 xhci_dbg(xhci, "xHCI %s called with udev and "
1531 struct usb_device *udev, struct xhci_command *command,
1551 max_packet_size = usb_endpoint_maxp(&vdev->udev->ep0.desc);
1592 ret = xhci_configure_endpoint(xhci, vdev->udev, command,
1598 dev_dbg(&vdev->udev->dev, "incorrect max packet size %d for ep0\n",
1893 int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1905 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
1912 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
1920 in_ctx = xhci->devs[udev->slot_id]->in_ctx;
1921 out_ctx = xhci->devs[udev->slot_id]->out_ctx;
1938 if (xhci->devs[udev->slot_id]->eps[ep_index].ring != NULL)
1950 xhci_debugfs_remove_endpoint(xhci, xhci->devs[udev->slot_id], ep_index);
1952 xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep);
1956 udev->slot_id,
1976 int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1989 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
2010 virt_dev = xhci->devs[udev->slot_id];
2045 if (xhci_endpoint_init(xhci, virt_dev, udev, ep, GFP_NOIO) < 0) {
2046 dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n",
2063 ep->hcpriv = udev;
2070 udev->slot_id,
2112 struct usb_device *udev, u32 *cmd_status)
2123 dev_warn(&udev->dev,
2130 dev_warn(&udev->dev,
2137 dev_warn(&udev->dev, "ERROR: Endpoint drop flag = 0, "
2143 dev_warn(&udev->dev,
2162 struct usb_device *udev, u32 *cmd_status)
2173 dev_warn(&udev->dev,
2178 dev_warn(&udev->dev,
2183 dev_warn(&udev->dev,
2188 dev_warn(&udev->dev,
2194 dev_warn(&udev->dev, "WARN: Max Exit Latency too large\n");
2318 static unsigned int xhci_get_block_size(struct usb_device *udev)
2320 switch (udev->speed) {
2452 if (virt_dev->udev->speed >= USB_SPEED_SUPER)
2455 if (virt_dev->udev->speed == USB_SPEED_HIGH) {
2468 block_size = xhci_get_block_size(virt_dev->udev);
2585 if (!virt_dev->tt_info && virt_dev->udev->speed == USB_SPEED_HIGH) {
2641 struct usb_device *udev,
2651 if (udev->speed >= USB_SPEED_SUPER) {
2653 xhci->devs[udev->slot_id]->bw_table->ss_bw_in -=
2656 xhci->devs[udev->slot_id]->bw_table->ss_bw_out -=
2669 if (udev->speed == USB_SPEED_HIGH)
2678 switch (udev->speed) {
2702 struct usb_device *udev,
2713 if (udev->speed == USB_SPEED_SUPER) {
2715 xhci->devs[udev->slot_id]->bw_table->ss_bw_in +=
2718 xhci->devs[udev->slot_id]->bw_table->ss_bw_out +=
2726 if (udev->speed == USB_SPEED_HIGH)
2735 switch (udev->speed) {
2823 virt_dev->udev,
2835 virt_dev->udev,
2860 virt_dev->udev,
2872 virt_dev->udev,
2929 struct usb_device *udev,
2949 virt_dev = xhci->devs[udev->slot_id];
2984 udev->slot_id, must_succeed);
2988 udev->slot_id, must_succeed);
3004 ret = xhci_configure_endpoint_result(xhci, udev,
3007 ret = xhci_evaluate_context_result(xhci, udev,
3048 int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
3058 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
3066 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
3067 virt_dev = xhci->devs[udev->slot_id];
3106 ret = xhci_configure_endpoint(xhci, udev, command,
3147 void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
3153 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
3158 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
3159 virt_dev = xhci->devs[udev->slot_id];
3226 struct usb_device *udev;
3234 udev = (struct usb_device *)host_ep->hcpriv;
3235 if (!udev || !udev->slot_id)
3238 vdev = xhci->devs[udev->slot_id];
3279 struct usb_device *udev;
3299 udev = container_of(host_ep, struct usb_device, ep0);
3300 if (udev->speed != USB_SPEED_FULL || !udev->slot_id)
3303 vdev = xhci->devs[udev->slot_id];
3304 if (!vdev || vdev->udev != udev)
3315 udev = (struct usb_device *) host_ep->hcpriv;
3316 vdev = xhci->devs[udev->slot_id];
3318 if (!udev->slot_id || !vdev)
3361 dev_err(&udev->dev, "EP not empty, refuse reset\n");
3367 err = xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id,
3399 udev->slot_id, false);
3423 struct usb_device *udev, struct usb_host_endpoint *ep,
3432 ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__);
3489 struct usb_device *udev,
3499 ret = xhci_check_streams_endpoint(xhci, udev,
3500 eps[i], udev->slot_id);
3521 struct usb_device *udev,
3530 slot_id = udev->slot_id;
3577 static int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
3627 ret = xhci_calculate_streams_and_bitmask(xhci, udev, eps,
3641 vdev = xhci->devs[udev->slot_id];
3693 ret = xhci_configure_endpoint(xhci, udev, config_cmd,
3708 udev->slot_id, ep_index);
3744 static int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
3758 vdev = xhci->devs[udev->slot_id];
3763 udev, eps, num_eps);
3788 xhci->devs[udev->slot_id]->eps[ep_index].ep_state |=
3804 ret = xhci_configure_endpoint(xhci, udev, command,
3858 static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev);
3873 * If the virt_dev to be reset does not exist or does not match the udev,
3879 struct usb_device *udev)
3890 ret = xhci_check_args(hcd, udev, NULL, 0, false, __func__);
3894 slot_id = udev->slot_id;
3899 ret = xhci_alloc_dev(hcd, udev);
3909 if (virt_dev->udev != udev) {
3910 /* If the virt_dev and the udev does not match, this virt_dev
3911 * may belong to another udev.
3915 "not match the udev. Re-allocate the device\n",
3917 ret = xhci_alloc_dev(hcd, udev);
3935 ret = xhci_disable_slot(xhci, udev->slot_id);
3936 xhci_free_virt_device(xhci, udev->slot_id);
3938 ret = xhci_alloc_dev(hcd, udev);
4039 udev,
4059 static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
4075 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
4082 virt_dev = xhci->devs[udev->slot_id];
4089 virt_dev->udev = NULL;
4090 xhci_disable_slot(xhci, udev->slot_id);
4093 xhci_free_virt_device(xhci, udev->slot_id);
4169 int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
4224 if (!xhci_alloc_virt_device(xhci, slot_id, udev, GFP_NOIO)) {
4232 udev->slot_id = slot_id;
4248 xhci_disable_slot(xhci, udev->slot_id);
4249 xhci_free_virt_device(xhci, udev->slot_id);
4258 * @udev: USB dev structure representing the connected device.
4264 static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
4284 if (!udev->slot_id) {
4286 "Bad Slot ID %d", udev->slot_id);
4291 virt_dev = xhci->devs[udev->slot_id];
4300 udev->slot_id);
4338 xhci_setup_addressable_virt_dev(xhci, udev);
4341 xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev);
4352 udev->slot_id, setup);
4378 act, udev->slot_id);
4382 dev_warn(&udev->dev, "Device not responding to setup %s.\n", act);
4385 ret = xhci_disable_slot(xhci, udev->slot_id);
4386 xhci_free_virt_device(xhci, udev->slot_id);
4388 if (xhci_alloc_dev(hcd, udev) == 1)
4389 xhci_setup_addressable_virt_dev(xhci, udev);
4395 dev_warn(&udev->dev,
4418 udev->slot_id,
4419 &xhci->dcbaa->dev_context_ptrs[udev->slot_id],
4421 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[udev->slot_id]));
4437 udev->devaddr = (u8)(le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK);
4451 static int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev,
4454 return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ADDRESS, timeout_ms);
4457 static int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev)
4459 return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ONLY,
4482 struct usb_device *udev, u16 max_exit_latency)
4497 virt_dev = xhci->devs[udev->slot_id];
4534 ret = xhci_configure_endpoint(xhci, udev, command,
4556 struct usb_device *udev)
4563 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4590 static int xhci_calculate_usb2_hw_lpm_params(struct usb_device *udev)
4597 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4600 l1 = udev->l1_params.timeout / 256;
4612 struct usb_device *udev, int enable)
4627 !udev->lpm_capable)
4630 if (!udev->parent || udev->parent->parent ||
4631 udev->descriptor.bDeviceClass == USB_CLASS_HUB)
4634 if (udev->usb2_hw_lpm_capable != 1)
4640 port_num = udev->portnum - 1;
4650 if (udev->usb2_hw_lpm_besl_capable) {
4655 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4660 hird = udev->l1_params.besl;
4665 ret = xhci_change_max_exit_latency(xhci, udev,
4671 hlpm_val = xhci_calculate_usb2_hw_lpm_params(udev);
4676 hird = xhci_calculate_hird_besl(xhci, udev);
4680 pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev->slot_id);
4692 if (udev->usb2_hw_lpm_besl_capable) {
4694 xhci_change_max_exit_latency(xhci, udev, 0);
4706 static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
4713 if (hcd->speed >= HCD_USB3 && !udev->parent->parent) {
4714 port = xhci->usb3_rhub.ports[udev->portnum - 1];
4716 udev->tunnel_mode = xhci_port_is_tunneled(xhci, port);
4717 if (udev->tunnel_mode == USB_LINK_UNKNOWN)
4718 dev_dbg(&udev->dev, "link tunnel state unknown\n");
4719 else if (udev->tunnel_mode == USB_LINK_TUNNELED)
4720 dev_dbg(&udev->dev, "tunneled over USB4 link\n");
4721 else if (udev->tunnel_mode == USB_LINK_NATIVE)
4722 dev_dbg(&udev->dev, "native USB 3.x link\n");
4726 if (hcd->speed >= HCD_USB3 || !udev->lpm_capable || !xhci->hw_lpm_support)
4730 if (!udev->parent || udev->parent->parent ||
4731 udev->descriptor.bDeviceClass == USB_CLASS_HUB)
4734 port = xhci->usb2_rhub.ports[udev->portnum - 1];
4738 udev->usb2_hw_lpm_capable = 1;
4739 udev->l1_params.timeout = XHCI_L1_TIMEOUT;
4740 udev->l1_params.besl = XHCI_DEFAULT_BESL;
4742 udev->usb2_hw_lpm_besl_capable = 1;
4757 static u16 xhci_get_timeout_no_hub_lpm(struct usb_device *udev,
4768 sel = DIV_ROUND_UP(udev->u1_params.sel, 1000);
4769 pel = DIV_ROUND_UP(udev->u1_params.pel, 1000);
4774 sel = DIV_ROUND_UP(udev->u2_params.sel, 1000);
4775 pel = DIV_ROUND_UP(udev->u2_params.pel, 1000);
4780 dev_warn(&udev->dev, "%s: Can't get timeout for non-U1 or U2 state.\n",
4789 dev_dbg(&udev->dev, "Device-initiated %s disabled "
4793 dev_dbg(&udev->dev, "Device-initiated %s disabled "
4808 struct usb_device *udev,
4818 timeout_ns = udev->u1_params.sel * 3;
4821 timeout_ns = udev->u1_params.sel * 5;
4826 timeout_ns = udev->u1_params.sel * 3;
4834 if (timeout_ns < udev->u1_params.sel * 2)
4835 timeout_ns = udev->u1_params.sel * 2;
4846 struct usb_device *udev,
4853 if (xhci_service_interval_to_ns(desc) <= udev->u1_params.mel) {
4854 dev_dbg(&udev->dev, "Disable U1, ESIT shorter than exit latency\n");
4860 timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
4862 timeout_ns = udev->u1_params.sel;
4877 dev_dbg(&udev->dev, "Hub-initiated U1 disabled due to long timeout %lluus\n",
4879 return xhci_get_timeout_no_hub_lpm(udev, USB3_LPM_U1);
4889 struct usb_device *udev,
4901 u2_del_ns = le16_to_cpu(udev->bos->ss_cap->bU2DevExitLat) * 1000ULL;
4910 struct usb_device *udev,
4917 if (xhci_service_interval_to_ns(desc) <= udev->u2_params.mel) {
4918 dev_dbg(&udev->dev, "Disable U2, ESIT shorter than exit latency\n");
4924 timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
4926 timeout_ns = udev->u2_params.sel;
4935 dev_dbg(&udev->dev, "Hub-initiated U2 disabled due to long timeout %lluus\n",
4937 return xhci_get_timeout_no_hub_lpm(udev, USB3_LPM_U2);
4941 struct usb_device *udev,
4947 return xhci_calculate_u1_timeout(xhci, udev, desc);
4949 return xhci_calculate_u2_timeout(xhci, udev, desc);
4955 struct usb_device *udev,
4962 alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev,
4980 struct usb_device *udev,
4988 if (xhci_update_timeout_for_endpoint(xhci, udev,
4996 struct usb_device *udev,
4999 struct usb_device *parent = udev->parent;
5014 dev_dbg(&udev->dev, "Tier policy prevents U1/U2 LPM states for devices at tier %d\n",
5025 struct usb_device *udev, enum usb3_link_state state)
5038 dev_warn(&udev->dev, "Can't enable unknown link state %i\n",
5046 if (xhci_update_timeout_for_endpoint(xhci, udev, &udev->ep0.desc,
5050 config = udev->actconfig;
5067 dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n",
5069 timeout = xhci_get_timeout_no_hub_lpm(udev,
5080 if (xhci_update_timeout_for_interface(xhci, udev,
5088 static int calculate_max_exit_latency(struct usb_device *udev,
5113 if ((udev->u1_params.timeout != USB3_LPM_DISABLED && !disabling_u1) ||
5115 u1_mel_us = DIV_ROUND_UP(udev->u1_params.mel, 1000);
5116 if ((udev->u2_params.timeout != USB3_LPM_DISABLED && !disabling_u2) ||
5118 u2_mel_us = DIV_ROUND_UP(udev->u2_params.mel, 1000);
5124 dev_warn(&udev->dev, "Link PM max exit latency of %lluus "
5133 struct usb_device *udev, enum usb3_link_state state)
5147 !xhci->devs[udev->slot_id])
5150 if (xhci_check_tier_policy(xhci, udev, state) < 0)
5154 if (udev->parent && !udev->parent->parent) {
5155 port = xhci->usb3_rhub.ports[udev->portnum - 1];
5160 hub_encoded_timeout = xhci_calculate_lpm_timeout(hcd, udev, state);
5161 mel = calculate_max_exit_latency(udev, state, hub_encoded_timeout);
5168 ret = xhci_change_max_exit_latency(xhci, udev, mel);
5175 struct usb_device *udev, enum usb3_link_state state)
5182 !xhci->devs[udev->slot_id])
5185 mel = calculate_max_exit_latency(udev, state, USB3_LPM_DISABLED);
5186 return xhci_change_max_exit_latency(xhci, udev, mel);
5191 struct usb_device *udev, int enable)
5196 static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
5202 struct usb_device *udev, enum usb3_link_state state)
5208 struct usb_device *udev, enum usb3_link_state state)
5508 struct usb_device *udev;
5516 udev = (struct usb_device *)ep->hcpriv;
5517 slot_id = udev->slot_id;