From 6a5d6943fe0e4b1e4c43c3aa1919360f68ae2f9a Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 28 Mar 2013 18:48:28 +0000 Subject: xhci: Use ilog2() rather than __ffs() for calculating SEGMENT_SHIFT Use ilog2() rather than __ffs() for calculating SEGMENT_SHIFT as ilog2() can be worked out at compile time, whereas __ffs() must be calculated at runtime. Signed-off-by: David Howells cc: Sarah Sharp cc: Greg Kroah-Hartman cc: linux-usb@vger.kernel.org Signed-off-by: Sarah Sharp diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6358271..ca550dd 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1239,7 +1239,7 @@ union xhci_trb { /* Allow two commands + a link TRB, along with any reserved command TRBs */ #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) #define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) -#define SEGMENT_SHIFT (__ffs(SEGMENT_SIZE)) +#define SEGMENT_SHIFT (ilog2(SEGMENT_SIZE)) /* TRB buffer pointers can't cross 64KB boundaries */ #define TRB_MAX_BUFF_SHIFT 16 #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) -- cgit v0.10.2 From eb8ccd2b481123e5fe0872a83e07ea8a6e2c4026 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 28 Mar 2013 18:48:35 +0000 Subject: xhci: Rename SEGMENT_SIZE and SEGMENT_SHIFT as the former is used in a.out.h Rename SEGMENT_SIZE and SEGMENT_SHIFT as the former is used in a.out.h. Signed-off-by: David Howells cc: Sarah Sharp cc: Greg Kroah-Hartman cc: linux-usb@vger.kernel.org Signed-off-by: Sarah Sharp diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 6dc238c..965b539 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -51,7 +51,7 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, return NULL; } - memset(seg->trbs, 0, SEGMENT_SIZE); + memset(seg->trbs, 0, TRB_SEGMENT_SIZE); /* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */ if (cycle_state == 0) { for (i = 0; i < TRBS_PER_SEGMENT; i++) @@ -467,7 +467,7 @@ struct xhci_ring *xhci_dma_to_transfer_ring( { if (ep->ep_state & EP_HAS_STREAMS) return radix_tree_lookup(&ep->stream_info->trb_address_map, - address >> SEGMENT_SHIFT); + address >> TRB_SEGMENT_SHIFT); return ep->ring; } @@ -478,7 +478,7 @@ static struct xhci_ring *dma_to_stream_ring( u64 address) { return radix_tree_lookup(&stream_info->trb_address_map, - address >> SEGMENT_SHIFT); + address >> TRB_SEGMENT_SHIFT); } #endif /* CONFIG_USB_XHCI_HCD_DEBUGGING */ @@ -514,7 +514,7 @@ static int xhci_test_radix_tree(struct xhci_hcd *xhci, cur_ring = stream_info->stream_rings[cur_stream]; for (addr = cur_ring->first_seg->dma; - addr < cur_ring->first_seg->dma + SEGMENT_SIZE; + addr < cur_ring->first_seg->dma + TRB_SEGMENT_SIZE; addr += trb_size) { mapped_ring = dma_to_stream_ring(stream_info, addr); if (cur_ring != mapped_ring) { @@ -662,7 +662,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, cur_stream, (unsigned long long) addr); key = (unsigned long) - (cur_ring->first_seg->dma >> SEGMENT_SHIFT); + (cur_ring->first_seg->dma >> TRB_SEGMENT_SHIFT); ret = radix_tree_insert(&stream_info->trb_address_map, key, cur_ring); if (ret) { @@ -693,7 +693,7 @@ cleanup_rings: if (cur_ring) { addr = cur_ring->first_seg->dma; radix_tree_delete(&stream_info->trb_address_map, - addr >> SEGMENT_SHIFT); + addr >> TRB_SEGMENT_SHIFT); xhci_ring_free(xhci, cur_ring); stream_info->stream_rings[cur_stream] = NULL; } @@ -764,7 +764,7 @@ void xhci_free_stream_info(struct xhci_hcd *xhci, if (cur_ring) { addr = cur_ring->first_seg->dma; radix_tree_delete(&stream_info->trb_address_map, - addr >> SEGMENT_SHIFT); + addr >> TRB_SEGMENT_SHIFT); xhci_ring_free(xhci, cur_ring); stream_info->stream_rings[cur_stream] = NULL; } @@ -2305,7 +2305,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) * so we pick the greater alignment need. */ xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, - SEGMENT_SIZE, 64, xhci->page_size); + TRB_SEGMENT_SIZE, 64, xhci->page_size); /* See Table 46 and Note on Figure 55 */ xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev, diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index ca550dd..29c978e 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1238,8 +1238,8 @@ union xhci_trb { #define TRBS_PER_SEGMENT 64 /* Allow two commands + a link TRB, along with any reserved command TRBs */ #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) -#define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) -#define SEGMENT_SHIFT (ilog2(SEGMENT_SIZE)) +#define TRB_SEGMENT_SIZE (TRBS_PER_SEGMENT*16) +#define TRB_SEGMENT_SHIFT (ilog2(TRB_SEGMENT_SIZE)) /* TRB buffer pointers can't cross 64KB boundaries */ #define TRB_MAX_BUFF_SHIFT 16 #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) -- cgit v0.10.2 From 58b1d7999e15e61f314c2ff746ffb9dd8e07eba6 Mon Sep 17 00:00:00 2001 From: Tony Camuso Date: Fri, 5 Apr 2013 14:27:07 -0400 Subject: xhci - clarify compliance mode debug messages There are no functional changes in this patch. However, because the compliance mode timer can be deleted in more than one function, it seemed expedient to include the function name in the debug strings. Also limited the use of capitals to the first word in the compliance mode debug messages, except after a function name where all words start with lower case, in keeping with the style prevalent elsewhere in xhci.c. Signed-off-by: Tony Camuso Signed-off-by: Sarah Sharp diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 5156b72..b4aa79d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -417,9 +417,9 @@ static void compliance_mode_recovery(unsigned long arg) * Compliance Mode Detected. Letting USB Core * handle the Warm Reset */ - xhci_dbg(xhci, "Compliance Mode Detected->Port %d!\n", + xhci_dbg(xhci, "Compliance mode detected->port %d\n", i + 1); - xhci_dbg(xhci, "Attempting Recovery routine!\n"); + xhci_dbg(xhci, "Attempting compliance mode recovery\n"); hcd = xhci->shared_hcd; if (hcd->state == HC_STATE_SUSPENDED) @@ -457,7 +457,7 @@ static void compliance_mode_recovery_timer_init(struct xhci_hcd *xhci) set_timer_slack(&xhci->comp_mode_recovery_timer, msecs_to_jiffies(COMP_MODE_RCVRY_MSECS)); add_timer(&xhci->comp_mode_recovery_timer); - xhci_dbg(xhci, "Compliance Mode Recovery Timer Initialized.\n"); + xhci_dbg(xhci, "Compliance mode recovery timer initialized\n"); } /* @@ -733,8 +733,11 @@ void xhci_stop(struct usb_hcd *hcd) /* Deleting Compliance Mode Recovery Timer */ if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && - (!(xhci_all_ports_seen_u0(xhci)))) + (!(xhci_all_ports_seen_u0(xhci)))) { del_timer_sync(&xhci->comp_mode_recovery_timer); + xhci_dbg(xhci, "%s: compliance mode recovery timer deleted\n", + __func__); + } if (xhci->quirks & XHCI_AMD_PLL_FIX) usb_amd_dev_put(); @@ -930,7 +933,8 @@ int xhci_suspend(struct xhci_hcd *xhci) if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && (!(xhci_all_ports_seen_u0(xhci)))) { del_timer_sync(&xhci->comp_mode_recovery_timer); - xhci_dbg(xhci, "Compliance Mode Recovery Timer Deleted!\n"); + xhci_dbg(xhci, "%s: compliance mode recovery timer deleted\n", + __func__); } /* step 5: remove core well power */ -- cgit v0.10.2