diff options
author | Matt Evans <matt@ozlabs.org> | 2011-03-28 22:40:46 -0400 |
---|---|---|
committer | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2011-05-02 19:42:49 -0400 |
commit | 28ccd2962c66556d7037b2d9f1c11cdcd3b805d5 (patch) | |
tree | 02bf9319e60c43c655a97aedeb76ec5171459508 /drivers/usb/host/xhci.c | |
parent | 7fc2a61638ef78cdf8d65d5934782963a6e0fc66 (diff) |
xhci: Make xHCI driver endian-safe
This patch changes the struct members defining access to xHCI device-visible
memory to use __le32/__le64 where appropriate, and then adds swaps where
required. Checked with sparse that all accesses are correct.
MMIO accesses use readl/writel so already are performed LE, but prototypes
now reflect this with __le*.
There were a couple of (debug) instances of DMA pointers being truncated to
32bits which have been fixed too.
Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/host/xhci.c')
-rw-r--r-- | drivers/usb/host/xhci.c | 109 |
1 files changed, 57 insertions, 52 deletions
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 81b976e45880..e8ab1899c88e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -973,8 +973,8 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, | |||
973 | 973 | ||
974 | out_ctx = xhci->devs[slot_id]->out_ctx; | 974 | out_ctx = xhci->devs[slot_id]->out_ctx; |
975 | ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); | 975 | ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); |
976 | hw_max_packet_size = MAX_PACKET_DECODED(ep_ctx->ep_info2); | 976 | hw_max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2)); |
977 | max_packet_size = urb->dev->ep0.desc.wMaxPacketSize; | 977 | max_packet_size = le16_to_cpu(urb->dev->ep0.desc.wMaxPacketSize); |
978 | if (hw_max_packet_size != max_packet_size) { | 978 | if (hw_max_packet_size != max_packet_size) { |
979 | xhci_dbg(xhci, "Max Packet Size for ep 0 changed.\n"); | 979 | xhci_dbg(xhci, "Max Packet Size for ep 0 changed.\n"); |
980 | xhci_dbg(xhci, "Max packet size in usb_device = %d\n", | 980 | xhci_dbg(xhci, "Max packet size in usb_device = %d\n", |
@@ -988,15 +988,15 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, | |||
988 | xhci->devs[slot_id]->out_ctx, ep_index); | 988 | xhci->devs[slot_id]->out_ctx, ep_index); |
989 | in_ctx = xhci->devs[slot_id]->in_ctx; | 989 | in_ctx = xhci->devs[slot_id]->in_ctx; |
990 | ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index); | 990 | ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index); |
991 | ep_ctx->ep_info2 &= ~MAX_PACKET_MASK; | 991 | ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET_MASK); |
992 | ep_ctx->ep_info2 |= MAX_PACKET(max_packet_size); | 992 | ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size)); |
993 | 993 | ||
994 | /* Set up the input context flags for the command */ | 994 | /* Set up the input context flags for the command */ |
995 | /* FIXME: This won't work if a non-default control endpoint | 995 | /* FIXME: This won't work if a non-default control endpoint |
996 | * changes max packet sizes. | 996 | * changes max packet sizes. |
997 | */ | 997 | */ |
998 | ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); | 998 | ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); |
999 | ctrl_ctx->add_flags = EP0_FLAG; | 999 | ctrl_ctx->add_flags = cpu_to_le32(EP0_FLAG); |
1000 | ctrl_ctx->drop_flags = 0; | 1000 | ctrl_ctx->drop_flags = 0; |
1001 | 1001 | ||
1002 | xhci_dbg(xhci, "Slot %d input context\n", slot_id); | 1002 | xhci_dbg(xhci, "Slot %d input context\n", slot_id); |
@@ -1010,7 +1010,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, | |||
1010 | /* Clean up the input context for later use by bandwidth | 1010 | /* Clean up the input context for later use by bandwidth |
1011 | * functions. | 1011 | * functions. |
1012 | */ | 1012 | */ |
1013 | ctrl_ctx->add_flags = SLOT_FLAG; | 1013 | ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG); |
1014 | } | 1014 | } |
1015 | return ret; | 1015 | return ret; |
1016 | } | 1016 | } |
@@ -1331,27 +1331,30 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, | |||
1331 | /* If the HC already knows the endpoint is disabled, | 1331 | /* If the HC already knows the endpoint is disabled, |
1332 | * or the HCD has noted it is disabled, ignore this request | 1332 | * or the HCD has noted it is disabled, ignore this request |
1333 | */ | 1333 | */ |
1334 | if ((ep_ctx->ep_info & EP_STATE_MASK) == EP_STATE_DISABLED || | 1334 | if ((le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK) == |
1335 | ctrl_ctx->drop_flags & xhci_get_endpoint_flag(&ep->desc)) { | 1335 | EP_STATE_DISABLED || |
1336 | le32_to_cpu(ctrl_ctx->drop_flags) & | ||
1337 | xhci_get_endpoint_flag(&ep->desc)) { | ||
1336 | xhci_warn(xhci, "xHCI %s called with disabled ep %p\n", | 1338 | xhci_warn(xhci, "xHCI %s called with disabled ep %p\n", |
1337 | __func__, ep); | 1339 | __func__, ep); |
1338 | return 0; | 1340 | return 0; |
1339 | } | 1341 | } |
1340 | 1342 | ||
1341 | ctrl_ctx->drop_flags |= drop_flag; | 1343 | ctrl_ctx->drop_flags |= cpu_to_le32(drop_flag); |
1342 | new_drop_flags = ctrl_ctx->drop_flags; | 1344 | new_drop_flags = le32_to_cpu(ctrl_ctx->drop_flags); |
1343 | 1345 | ||
1344 | ctrl_ctx->add_flags &= ~drop_flag; | 1346 | ctrl_ctx->add_flags &= cpu_to_le32(~drop_flag); |
1345 | new_add_flags = ctrl_ctx->add_flags; | 1347 | new_add_flags = le32_to_cpu(ctrl_ctx->add_flags); |
1346 | 1348 | ||
1347 | last_ctx = xhci_last_valid_endpoint(ctrl_ctx->add_flags); | 1349 | last_ctx = xhci_last_valid_endpoint(le32_to_cpu(ctrl_ctx->add_flags)); |
1348 | slot_ctx = xhci_get_slot_ctx(xhci, in_ctx); | 1350 | slot_ctx = xhci_get_slot_ctx(xhci, in_ctx); |
1349 | /* Update the last valid endpoint context, if we deleted the last one */ | 1351 | /* Update the last valid endpoint context, if we deleted the last one */ |
1350 | if ((slot_ctx->dev_info & LAST_CTX_MASK) > LAST_CTX(last_ctx)) { | 1352 | if ((le32_to_cpu(slot_ctx->dev_info) & LAST_CTX_MASK) > |
1351 | slot_ctx->dev_info &= ~LAST_CTX_MASK; | 1353 | LAST_CTX(last_ctx)) { |
1352 | slot_ctx->dev_info |= LAST_CTX(last_ctx); | 1354 | slot_ctx->dev_info &= cpu_to_le32(~LAST_CTX_MASK); |
1355 | slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(last_ctx)); | ||
1353 | } | 1356 | } |
1354 | new_slot_info = slot_ctx->dev_info; | 1357 | new_slot_info = le32_to_cpu(slot_ctx->dev_info); |
1355 | 1358 | ||
1356 | xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep); | 1359 | xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep); |
1357 | 1360 | ||
@@ -1419,7 +1422,8 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, | |||
1419 | /* If the HCD has already noted the endpoint is enabled, | 1422 | /* If the HCD has already noted the endpoint is enabled, |
1420 | * ignore this request. | 1423 | * ignore this request. |
1421 | */ | 1424 | */ |
1422 | if (ctrl_ctx->add_flags & xhci_get_endpoint_flag(&ep->desc)) { | 1425 | if (le32_to_cpu(ctrl_ctx->add_flags) & |
1426 | xhci_get_endpoint_flag(&ep->desc)) { | ||
1423 | xhci_warn(xhci, "xHCI %s called with enabled ep %p\n", | 1427 | xhci_warn(xhci, "xHCI %s called with enabled ep %p\n", |
1424 | __func__, ep); | 1428 | __func__, ep); |
1425 | return 0; | 1429 | return 0; |
@@ -1437,8 +1441,8 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, | |||
1437 | return -ENOMEM; | 1441 | return -ENOMEM; |
1438 | } | 1442 | } |
1439 | 1443 | ||
1440 | ctrl_ctx->add_flags |= added_ctxs; | 1444 | ctrl_ctx->add_flags |= cpu_to_le32(added_ctxs); |
1441 | new_add_flags = ctrl_ctx->add_flags; | 1445 | new_add_flags = le32_to_cpu(ctrl_ctx->add_flags); |
1442 | 1446 | ||
1443 | /* If xhci_endpoint_disable() was called for this endpoint, but the | 1447 | /* If xhci_endpoint_disable() was called for this endpoint, but the |
1444 | * xHC hasn't been notified yet through the check_bandwidth() call, | 1448 | * xHC hasn't been notified yet through the check_bandwidth() call, |
@@ -1446,15 +1450,16 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, | |||
1446 | * descriptors. We must drop and re-add this endpoint, so we leave the | 1450 | * descriptors. We must drop and re-add this endpoint, so we leave the |
1447 | * drop flags alone. | 1451 | * drop flags alone. |
1448 | */ | 1452 | */ |
1449 | new_drop_flags = ctrl_ctx->drop_flags; | 1453 | new_drop_flags = le32_to_cpu(ctrl_ctx->drop_flags); |
1450 | 1454 | ||
1451 | slot_ctx = xhci_get_slot_ctx(xhci, in_ctx); | 1455 | slot_ctx = xhci_get_slot_ctx(xhci, in_ctx); |
1452 | /* Update the last valid endpoint context, if we just added one past */ | 1456 | /* Update the last valid endpoint context, if we just added one past */ |
1453 | if ((slot_ctx->dev_info & LAST_CTX_MASK) < LAST_CTX(last_ctx)) { | 1457 | if ((le32_to_cpu(slot_ctx->dev_info) & LAST_CTX_MASK) < |
1454 | slot_ctx->dev_info &= ~LAST_CTX_MASK; | 1458 | LAST_CTX(last_ctx)) { |
1455 | slot_ctx->dev_info |= LAST_CTX(last_ctx); | 1459 | slot_ctx->dev_info &= cpu_to_le32(~LAST_CTX_MASK); |
1460 | slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(last_ctx)); | ||
1456 | } | 1461 | } |
1457 | new_slot_info = slot_ctx->dev_info; | 1462 | new_slot_info = le32_to_cpu(slot_ctx->dev_info); |
1458 | 1463 | ||
1459 | /* Store the usb_device pointer for later use */ | 1464 | /* Store the usb_device pointer for later use */ |
1460 | ep->hcpriv = udev; | 1465 | ep->hcpriv = udev; |
@@ -1484,9 +1489,9 @@ static void xhci_zero_in_ctx(struct xhci_hcd *xhci, struct xhci_virt_device *vir | |||
1484 | ctrl_ctx->drop_flags = 0; | 1489 | ctrl_ctx->drop_flags = 0; |
1485 | ctrl_ctx->add_flags = 0; | 1490 | ctrl_ctx->add_flags = 0; |
1486 | slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); | 1491 | slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); |
1487 | slot_ctx->dev_info &= ~LAST_CTX_MASK; | 1492 | slot_ctx->dev_info &= cpu_to_le32(~LAST_CTX_MASK); |
1488 | /* Endpoint 0 is always valid */ | 1493 | /* Endpoint 0 is always valid */ |
1489 | slot_ctx->dev_info |= LAST_CTX(1); | 1494 | slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1)); |
1490 | for (i = 1; i < 31; ++i) { | 1495 | for (i = 1; i < 31; ++i) { |
1491 | ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, i); | 1496 | ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, i); |
1492 | ep_ctx->ep_info = 0; | 1497 | ep_ctx->ep_info = 0; |
@@ -1581,7 +1586,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, | |||
1581 | unsigned long flags; | 1586 | unsigned long flags; |
1582 | struct xhci_container_ctx *in_ctx; | 1587 | struct xhci_container_ctx *in_ctx; |
1583 | struct completion *cmd_completion; | 1588 | struct completion *cmd_completion; |
1584 | int *cmd_status; | 1589 | u32 *cmd_status; |
1585 | struct xhci_virt_device *virt_dev; | 1590 | struct xhci_virt_device *virt_dev; |
1586 | 1591 | ||
1587 | spin_lock_irqsave(&xhci->lock, flags); | 1592 | spin_lock_irqsave(&xhci->lock, flags); |
@@ -1595,8 +1600,8 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, | |||
1595 | /* Enqueue pointer can be left pointing to the link TRB, | 1600 | /* Enqueue pointer can be left pointing to the link TRB, |
1596 | * we must handle that | 1601 | * we must handle that |
1597 | */ | 1602 | */ |
1598 | if ((command->command_trb->link.control & TRB_TYPE_BITMASK) | 1603 | if ((le32_to_cpu(command->command_trb->link.control) |
1599 | == TRB_TYPE(TRB_LINK)) | 1604 | & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK)) |
1600 | command->command_trb = | 1605 | command->command_trb = |
1601 | xhci->cmd_ring->enq_seg->next->trbs; | 1606 | xhci->cmd_ring->enq_seg->next->trbs; |
1602 | 1607 | ||
@@ -1672,14 +1677,13 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev) | |||
1672 | 1677 | ||
1673 | /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */ | 1678 | /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */ |
1674 | ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); | 1679 | ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); |
1675 | ctrl_ctx->add_flags |= SLOT_FLAG; | 1680 | ctrl_ctx->add_flags |= cpu_to_le32(SLOT_FLAG); |
1676 | ctrl_ctx->add_flags &= ~EP0_FLAG; | 1681 | ctrl_ctx->add_flags &= cpu_to_le32(~EP0_FLAG); |
1677 | ctrl_ctx->drop_flags &= ~SLOT_FLAG; | 1682 | ctrl_ctx->drop_flags &= cpu_to_le32(~(SLOT_FLAG | EP0_FLAG)); |
1678 | ctrl_ctx->drop_flags &= ~EP0_FLAG; | ||
1679 | xhci_dbg(xhci, "New Input Control Context:\n"); | 1683 | xhci_dbg(xhci, "New Input Control Context:\n"); |
1680 | slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); | 1684 | slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); |
1681 | xhci_dbg_ctx(xhci, virt_dev->in_ctx, | 1685 | xhci_dbg_ctx(xhci, virt_dev->in_ctx, |
1682 | LAST_CTX_TO_EP_NUM(slot_ctx->dev_info)); | 1686 | LAST_CTX_TO_EP_NUM(le32_to_cpu(slot_ctx->dev_info))); |
1683 | 1687 | ||
1684 | ret = xhci_configure_endpoint(xhci, udev, NULL, | 1688 | ret = xhci_configure_endpoint(xhci, udev, NULL, |
1685 | false, false); | 1689 | false, false); |
@@ -1690,7 +1694,7 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev) | |||
1690 | 1694 | ||
1691 | xhci_dbg(xhci, "Output context after successful config ep cmd:\n"); | 1695 | xhci_dbg(xhci, "Output context after successful config ep cmd:\n"); |
1692 | xhci_dbg_ctx(xhci, virt_dev->out_ctx, | 1696 | xhci_dbg_ctx(xhci, virt_dev->out_ctx, |
1693 | LAST_CTX_TO_EP_NUM(slot_ctx->dev_info)); | 1697 | LAST_CTX_TO_EP_NUM(le32_to_cpu(slot_ctx->dev_info))); |
1694 | 1698 | ||
1695 | xhci_zero_in_ctx(xhci, virt_dev); | 1699 | xhci_zero_in_ctx(xhci, virt_dev); |
1696 | /* Install new rings and free or cache any old rings */ | 1700 | /* Install new rings and free or cache any old rings */ |
@@ -1740,10 +1744,10 @@ static void xhci_setup_input_ctx_for_config_ep(struct xhci_hcd *xhci, | |||
1740 | { | 1744 | { |
1741 | struct xhci_input_control_ctx *ctrl_ctx; | 1745 | struct xhci_input_control_ctx *ctrl_ctx; |
1742 | ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); | 1746 | ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); |
1743 | ctrl_ctx->add_flags = add_flags; | 1747 | ctrl_ctx->add_flags = cpu_to_le32(add_flags); |
1744 | ctrl_ctx->drop_flags = drop_flags; | 1748 | ctrl_ctx->drop_flags = cpu_to_le32(drop_flags); |
1745 | xhci_slot_copy(xhci, in_ctx, out_ctx); | 1749 | xhci_slot_copy(xhci, in_ctx, out_ctx); |
1746 | ctrl_ctx->add_flags |= SLOT_FLAG; | 1750 | ctrl_ctx->add_flags |= cpu_to_le32(SLOT_FLAG); |
1747 | 1751 | ||
1748 | xhci_dbg(xhci, "Input Context:\n"); | 1752 | xhci_dbg(xhci, "Input Context:\n"); |
1749 | xhci_dbg_ctx(xhci, in_ctx, xhci_last_valid_endpoint(add_flags)); | 1753 | xhci_dbg_ctx(xhci, in_ctx, xhci_last_valid_endpoint(add_flags)); |
@@ -1772,7 +1776,7 @@ static void xhci_setup_input_ctx_for_quirk(struct xhci_hcd *xhci, | |||
1772 | deq_state->new_deq_ptr); | 1776 | deq_state->new_deq_ptr); |
1773 | return; | 1777 | return; |
1774 | } | 1778 | } |
1775 | ep_ctx->deq = addr | deq_state->new_cycle_state; | 1779 | ep_ctx->deq = cpu_to_le64(addr | deq_state->new_cycle_state); |
1776 | 1780 | ||
1777 | added_ctxs = xhci_get_endpoint_flag_from_index(ep_index); | 1781 | added_ctxs = xhci_get_endpoint_flag_from_index(ep_index); |
1778 | xhci_setup_input_ctx_for_config_ep(xhci, xhci->devs[slot_id]->in_ctx, | 1782 | xhci_setup_input_ctx_for_config_ep(xhci, xhci->devs[slot_id]->in_ctx, |
@@ -2327,8 +2331,8 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
2327 | /* Enqueue pointer can be left pointing to the link TRB, | 2331 | /* Enqueue pointer can be left pointing to the link TRB, |
2328 | * we must handle that | 2332 | * we must handle that |
2329 | */ | 2333 | */ |
2330 | if ((reset_device_cmd->command_trb->link.control & TRB_TYPE_BITMASK) | 2334 | if ((le32_to_cpu(reset_device_cmd->command_trb->link.control) |
2331 | == TRB_TYPE(TRB_LINK)) | 2335 | & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK)) |
2332 | reset_device_cmd->command_trb = | 2336 | reset_device_cmd->command_trb = |
2333 | xhci->cmd_ring->enq_seg->next->trbs; | 2337 | xhci->cmd_ring->enq_seg->next->trbs; |
2334 | 2338 | ||
@@ -2609,10 +2613,10 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
2609 | temp_64 = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); | 2613 | temp_64 = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); |
2610 | xhci_dbg(xhci, "Op regs DCBAA ptr = %#016llx\n", temp_64); | 2614 | xhci_dbg(xhci, "Op regs DCBAA ptr = %#016llx\n", temp_64); |
2611 | xhci_dbg(xhci, "Slot ID %d dcbaa entry @%p = %#016llx\n", | 2615 | xhci_dbg(xhci, "Slot ID %d dcbaa entry @%p = %#016llx\n", |
2612 | udev->slot_id, | 2616 | udev->slot_id, |
2613 | &xhci->dcbaa->dev_context_ptrs[udev->slot_id], | 2617 | &xhci->dcbaa->dev_context_ptrs[udev->slot_id], |
2614 | (unsigned long long) | 2618 | (unsigned long long) |
2615 | xhci->dcbaa->dev_context_ptrs[udev->slot_id]); | 2619 | le64_to_cpu(xhci->dcbaa->dev_context_ptrs[udev->slot_id])); |
2616 | xhci_dbg(xhci, "Output Context DMA address = %#08llx\n", | 2620 | xhci_dbg(xhci, "Output Context DMA address = %#08llx\n", |
2617 | (unsigned long long)virt_dev->out_ctx->dma); | 2621 | (unsigned long long)virt_dev->out_ctx->dma); |
2618 | xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id); | 2622 | xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id); |
@@ -2626,7 +2630,8 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
2626 | slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); | 2630 | slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); |
2627 | /* Use kernel assigned address for devices; store xHC assigned | 2631 | /* Use kernel assigned address for devices; store xHC assigned |
2628 | * address locally. */ | 2632 | * address locally. */ |
2629 | virt_dev->address = (slot_ctx->dev_state & DEV_ADDR_MASK) + 1; | 2633 | virt_dev->address = (le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK) |
2634 | + 1; | ||
2630 | /* Zero the input context control for later use */ | 2635 | /* Zero the input context control for later use */ |
2631 | ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); | 2636 | ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); |
2632 | ctrl_ctx->add_flags = 0; | 2637 | ctrl_ctx->add_flags = 0; |
@@ -2670,16 +2675,16 @@ int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev, | |||
2670 | spin_lock_irqsave(&xhci->lock, flags); | 2675 | spin_lock_irqsave(&xhci->lock, flags); |
2671 | xhci_slot_copy(xhci, config_cmd->in_ctx, vdev->out_ctx); | 2676 | xhci_slot_copy(xhci, config_cmd->in_ctx, vdev->out_ctx); |
2672 | ctrl_ctx = xhci_get_input_control_ctx(xhci, config_cmd->in_ctx); | 2677 | ctrl_ctx = xhci_get_input_control_ctx(xhci, config_cmd->in_ctx); |
2673 | ctrl_ctx->add_flags |= SLOT_FLAG; | 2678 | ctrl_ctx->add_flags |= cpu_to_le32(SLOT_FLAG); |
2674 | slot_ctx = xhci_get_slot_ctx(xhci, config_cmd->in_ctx); | 2679 | slot_ctx = xhci_get_slot_ctx(xhci, config_cmd->in_ctx); |
2675 | slot_ctx->dev_info |= DEV_HUB; | 2680 | slot_ctx->dev_info |= cpu_to_le32(DEV_HUB); |
2676 | if (tt->multi) | 2681 | if (tt->multi) |
2677 | slot_ctx->dev_info |= DEV_MTT; | 2682 | slot_ctx->dev_info |= cpu_to_le32(DEV_MTT); |
2678 | if (xhci->hci_version > 0x95) { | 2683 | if (xhci->hci_version > 0x95) { |
2679 | xhci_dbg(xhci, "xHCI version %x needs hub " | 2684 | xhci_dbg(xhci, "xHCI version %x needs hub " |
2680 | "TT think time and number of ports\n", | 2685 | "TT think time and number of ports\n", |
2681 | (unsigned int) xhci->hci_version); | 2686 | (unsigned int) xhci->hci_version); |
2682 | slot_ctx->dev_info2 |= XHCI_MAX_PORTS(hdev->maxchild); | 2687 | slot_ctx->dev_info2 |= cpu_to_le32(XHCI_MAX_PORTS(hdev->maxchild)); |
2683 | /* Set TT think time - convert from ns to FS bit times. | 2688 | /* Set TT think time - convert from ns to FS bit times. |
2684 | * 0 = 8 FS bit times, 1 = 16 FS bit times, | 2689 | * 0 = 8 FS bit times, 1 = 16 FS bit times, |
2685 | * 2 = 24 FS bit times, 3 = 32 FS bit times. | 2690 | * 2 = 24 FS bit times, 3 = 32 FS bit times. |
@@ -2687,7 +2692,7 @@ int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev, | |||
2687 | think_time = tt->think_time; | 2692 | think_time = tt->think_time; |
2688 | if (think_time != 0) | 2693 | if (think_time != 0) |
2689 | think_time = (think_time / 666) - 1; | 2694 | think_time = (think_time / 666) - 1; |
2690 | slot_ctx->tt_info |= TT_THINK_TIME(think_time); | 2695 | slot_ctx->tt_info |= cpu_to_le32(TT_THINK_TIME(think_time)); |
2691 | } else { | 2696 | } else { |
2692 | xhci_dbg(xhci, "xHCI version %x doesn't need hub " | 2697 | xhci_dbg(xhci, "xHCI version %x doesn't need hub " |
2693 | "TT think time or number of ports\n", | 2698 | "TT think time or number of ports\n", |