diff options
author | Adam Wallis <awallis@codeaurora.org> | 2018-05-22 14:55:32 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-06-01 07:24:51 -0400 |
commit | a965315e59f3cbceb5d27d0feb68a456544f0f8d (patch) | |
tree | fb0f20225f2762488008e1d71ff715a154da2791 | |
parent | 5ef12cb4a3a78ffb331c03a795a15eea4ae35155 (diff) |
usb: xhci: force all memory allocations to node
The xhci driver forces DMA memory to be node aware, however, there are
several ring-related memory allocations that are not memory node aware.
This patch resolves those *alloc functions to be allocated on the proper
memory node.
Signed-off-by: Adam Wallis <awallis@codeaurora.org>
Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/host/xhci-mem.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 0b61b77dd26f..4fe74711938e 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -33,8 +33,9 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, | |||
33 | struct xhci_segment *seg; | 33 | struct xhci_segment *seg; |
34 | dma_addr_t dma; | 34 | dma_addr_t dma; |
35 | int i; | 35 | int i; |
36 | struct device *dev = xhci_to_hcd(xhci)->self.sysdev; | ||
36 | 37 | ||
37 | seg = kzalloc(sizeof *seg, flags); | 38 | seg = kzalloc_node(sizeof(*seg), flags, dev_to_node(dev)); |
38 | if (!seg) | 39 | if (!seg) |
39 | return NULL; | 40 | return NULL; |
40 | 41 | ||
@@ -45,7 +46,8 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, | |||
45 | } | 46 | } |
46 | 47 | ||
47 | if (max_packet) { | 48 | if (max_packet) { |
48 | seg->bounce_buf = kzalloc(max_packet, flags); | 49 | seg->bounce_buf = kzalloc_node(max_packet, flags, |
50 | dev_to_node(dev)); | ||
49 | if (!seg->bounce_buf) { | 51 | if (!seg->bounce_buf) { |
50 | dma_pool_free(xhci->segment_pool, seg->trbs, dma); | 52 | dma_pool_free(xhci->segment_pool, seg->trbs, dma); |
51 | kfree(seg); | 53 | kfree(seg); |
@@ -363,8 +365,9 @@ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, | |||
363 | { | 365 | { |
364 | struct xhci_ring *ring; | 366 | struct xhci_ring *ring; |
365 | int ret; | 367 | int ret; |
368 | struct device *dev = xhci_to_hcd(xhci)->self.sysdev; | ||
366 | 369 | ||
367 | ring = kzalloc(sizeof *(ring), flags); | 370 | ring = kzalloc_node(sizeof(*ring), flags, dev_to_node(dev)); |
368 | if (!ring) | 371 | if (!ring) |
369 | return NULL; | 372 | return NULL; |
370 | 373 | ||
@@ -458,11 +461,12 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, | |||
458 | int type, gfp_t flags) | 461 | int type, gfp_t flags) |
459 | { | 462 | { |
460 | struct xhci_container_ctx *ctx; | 463 | struct xhci_container_ctx *ctx; |
464 | struct device *dev = xhci_to_hcd(xhci)->self.sysdev; | ||
461 | 465 | ||
462 | if ((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT)) | 466 | if ((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT)) |
463 | return NULL; | 467 | return NULL; |
464 | 468 | ||
465 | ctx = kzalloc(sizeof(*ctx), flags); | 469 | ctx = kzalloc_node(sizeof(*ctx), flags, dev_to_node(dev)); |
466 | if (!ctx) | 470 | if (!ctx) |
467 | return NULL; | 471 | return NULL; |
468 | 472 | ||
@@ -615,6 +619,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | |||
615 | struct xhci_ring *cur_ring; | 619 | struct xhci_ring *cur_ring; |
616 | u64 addr; | 620 | u64 addr; |
617 | int ret; | 621 | int ret; |
622 | struct device *dev = xhci_to_hcd(xhci)->self.sysdev; | ||
618 | 623 | ||
619 | xhci_dbg(xhci, "Allocating %u streams and %u " | 624 | xhci_dbg(xhci, "Allocating %u streams and %u " |
620 | "stream context array entries.\n", | 625 | "stream context array entries.\n", |
@@ -625,7 +630,8 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | |||
625 | } | 630 | } |
626 | xhci->cmd_ring_reserved_trbs++; | 631 | xhci->cmd_ring_reserved_trbs++; |
627 | 632 | ||
628 | stream_info = kzalloc(sizeof(struct xhci_stream_info), mem_flags); | 633 | stream_info = kzalloc_node(sizeof(*stream_info), mem_flags, |
634 | dev_to_node(dev)); | ||
629 | if (!stream_info) | 635 | if (!stream_info) |
630 | goto cleanup_trbs; | 636 | goto cleanup_trbs; |
631 | 637 | ||
@@ -633,9 +639,9 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | |||
633 | stream_info->num_stream_ctxs = num_stream_ctxs; | 639 | stream_info->num_stream_ctxs = num_stream_ctxs; |
634 | 640 | ||
635 | /* Initialize the array of virtual pointers to stream rings. */ | 641 | /* Initialize the array of virtual pointers to stream rings. */ |
636 | stream_info->stream_rings = kzalloc( | 642 | stream_info->stream_rings = kcalloc_node( |
637 | sizeof(struct xhci_ring *)*num_streams, | 643 | num_streams, sizeof(struct xhci_ring *), mem_flags, |
638 | mem_flags); | 644 | dev_to_node(dev)); |
639 | if (!stream_info->stream_rings) | 645 | if (!stream_info->stream_rings) |
640 | goto cleanup_info; | 646 | goto cleanup_info; |
641 | 647 | ||
@@ -831,6 +837,7 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci, | |||
831 | struct xhci_tt_bw_info *tt_info; | 837 | struct xhci_tt_bw_info *tt_info; |
832 | unsigned int num_ports; | 838 | unsigned int num_ports; |
833 | int i, j; | 839 | int i, j; |
840 | struct device *dev = xhci_to_hcd(xhci)->self.sysdev; | ||
834 | 841 | ||
835 | if (!tt->multi) | 842 | if (!tt->multi) |
836 | num_ports = 1; | 843 | num_ports = 1; |
@@ -840,7 +847,8 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci, | |||
840 | for (i = 0; i < num_ports; i++, tt_info++) { | 847 | for (i = 0; i < num_ports; i++, tt_info++) { |
841 | struct xhci_interval_bw_table *bw_table; | 848 | struct xhci_interval_bw_table *bw_table; |
842 | 849 | ||
843 | tt_info = kzalloc(sizeof(*tt_info), mem_flags); | 850 | tt_info = kzalloc_node(sizeof(*tt_info), mem_flags, |
851 | dev_to_node(dev)); | ||
844 | if (!tt_info) | 852 | if (!tt_info) |
845 | goto free_tts; | 853 | goto free_tts; |
846 | INIT_LIST_HEAD(&tt_info->tt_list); | 854 | INIT_LIST_HEAD(&tt_info->tt_list); |
@@ -1641,7 +1649,8 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) | |||
1641 | if (!num_sp) | 1649 | if (!num_sp) |
1642 | return 0; | 1650 | return 0; |
1643 | 1651 | ||
1644 | xhci->scratchpad = kzalloc(sizeof(*xhci->scratchpad), flags); | 1652 | xhci->scratchpad = kzalloc_node(sizeof(*xhci->scratchpad), flags, |
1653 | dev_to_node(dev)); | ||
1645 | if (!xhci->scratchpad) | 1654 | if (!xhci->scratchpad) |
1646 | goto fail_sp; | 1655 | goto fail_sp; |
1647 | 1656 | ||
@@ -1651,7 +1660,8 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) | |||
1651 | if (!xhci->scratchpad->sp_array) | 1660 | if (!xhci->scratchpad->sp_array) |
1652 | goto fail_sp2; | 1661 | goto fail_sp2; |
1653 | 1662 | ||
1654 | xhci->scratchpad->sp_buffers = kzalloc(sizeof(void *) * num_sp, flags); | 1663 | xhci->scratchpad->sp_buffers = kcalloc_node(num_sp, sizeof(void *), |
1664 | flags, dev_to_node(dev)); | ||
1655 | if (!xhci->scratchpad->sp_buffers) | 1665 | if (!xhci->scratchpad->sp_buffers) |
1656 | goto fail_sp3; | 1666 | goto fail_sp3; |
1657 | 1667 | ||
@@ -1719,14 +1729,16 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, | |||
1719 | bool allocate_completion, gfp_t mem_flags) | 1729 | bool allocate_completion, gfp_t mem_flags) |
1720 | { | 1730 | { |
1721 | struct xhci_command *command; | 1731 | struct xhci_command *command; |
1732 | struct device *dev = xhci_to_hcd(xhci)->self.sysdev; | ||
1722 | 1733 | ||
1723 | command = kzalloc(sizeof(*command), mem_flags); | 1734 | command = kzalloc_node(sizeof(*command), mem_flags, dev_to_node(dev)); |
1724 | if (!command) | 1735 | if (!command) |
1725 | return NULL; | 1736 | return NULL; |
1726 | 1737 | ||
1727 | if (allocate_completion) { | 1738 | if (allocate_completion) { |
1728 | command->completion = | 1739 | command->completion = |
1729 | kzalloc(sizeof(struct completion), mem_flags); | 1740 | kzalloc_node(sizeof(struct completion), mem_flags, |
1741 | dev_to_node(dev)); | ||
1730 | if (!command->completion) { | 1742 | if (!command->completion) { |
1731 | kfree(command); | 1743 | kfree(command); |
1732 | return NULL; | 1744 | return NULL; |
@@ -2099,6 +2111,7 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, | |||
2099 | int i; | 2111 | int i; |
2100 | u8 major_revision, minor_revision; | 2112 | u8 major_revision, minor_revision; |
2101 | struct xhci_hub *rhub; | 2113 | struct xhci_hub *rhub; |
2114 | struct device *dev = xhci_to_hcd(xhci)->self.sysdev; | ||
2102 | 2115 | ||
2103 | temp = readl(addr); | 2116 | temp = readl(addr); |
2104 | major_revision = XHCI_EXT_PORT_MAJOR(temp); | 2117 | major_revision = XHCI_EXT_PORT_MAJOR(temp); |
@@ -2135,8 +2148,8 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, | |||
2135 | 2148 | ||
2136 | rhub->psi_count = XHCI_EXT_PORT_PSIC(temp); | 2149 | rhub->psi_count = XHCI_EXT_PORT_PSIC(temp); |
2137 | if (rhub->psi_count) { | 2150 | if (rhub->psi_count) { |
2138 | rhub->psi = kcalloc(rhub->psi_count, sizeof(*rhub->psi), | 2151 | rhub->psi = kcalloc_node(rhub->psi_count, sizeof(*rhub->psi), |
2139 | GFP_KERNEL); | 2152 | GFP_KERNEL, dev_to_node(dev)); |
2140 | if (!rhub->psi) | 2153 | if (!rhub->psi) |
2141 | rhub->psi_count = 0; | 2154 | rhub->psi_count = 0; |
2142 | 2155 | ||
@@ -2214,10 +2227,12 @@ static void xhci_create_rhub_port_array(struct xhci_hcd *xhci, | |||
2214 | { | 2227 | { |
2215 | int port_index = 0; | 2228 | int port_index = 0; |
2216 | int i; | 2229 | int i; |
2230 | struct device *dev = xhci_to_hcd(xhci)->self.sysdev; | ||
2217 | 2231 | ||
2218 | if (!rhub->num_ports) | 2232 | if (!rhub->num_ports) |
2219 | return; | 2233 | return; |
2220 | rhub->ports = kcalloc(rhub->num_ports, sizeof(rhub->ports), flags); | 2234 | rhub->ports = kcalloc_node(rhub->num_ports, sizeof(rhub->ports), flags, |
2235 | dev_to_node(dev)); | ||
2221 | for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { | 2236 | for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { |
2222 | if (xhci->hw_ports[i].rhub != rhub || | 2237 | if (xhci->hw_ports[i].rhub != rhub || |
2223 | xhci->hw_ports[i].hcd_portnum == DUPLICATE_ENTRY) | 2238 | xhci->hw_ports[i].hcd_portnum == DUPLICATE_ENTRY) |
@@ -2245,9 +2260,11 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) | |||
2245 | int i, j; | 2260 | int i, j; |
2246 | int cap_count = 0; | 2261 | int cap_count = 0; |
2247 | u32 cap_start; | 2262 | u32 cap_start; |
2263 | struct device *dev = xhci_to_hcd(xhci)->self.sysdev; | ||
2248 | 2264 | ||
2249 | num_ports = HCS_MAX_PORTS(xhci->hcs_params1); | 2265 | num_ports = HCS_MAX_PORTS(xhci->hcs_params1); |
2250 | xhci->hw_ports = kcalloc(num_ports, sizeof(*xhci->hw_ports), flags); | 2266 | xhci->hw_ports = kcalloc_node(num_ports, sizeof(*xhci->hw_ports), |
2267 | flags, dev_to_node(dev)); | ||
2251 | if (!xhci->hw_ports) | 2268 | if (!xhci->hw_ports) |
2252 | return -ENOMEM; | 2269 | return -ENOMEM; |
2253 | 2270 | ||
@@ -2257,7 +2274,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) | |||
2257 | xhci->hw_ports[i].hw_portnum = i; | 2274 | xhci->hw_ports[i].hw_portnum = i; |
2258 | } | 2275 | } |
2259 | 2276 | ||
2260 | xhci->rh_bw = kzalloc(sizeof(*xhci->rh_bw)*num_ports, flags); | 2277 | xhci->rh_bw = kzalloc_node(sizeof(*xhci->rh_bw)*num_ports, flags, |
2278 | dev_to_node(dev)); | ||
2261 | if (!xhci->rh_bw) | 2279 | if (!xhci->rh_bw) |
2262 | return -ENOMEM; | 2280 | return -ENOMEM; |
2263 | for (i = 0; i < num_ports; i++) { | 2281 | for (i = 0; i < num_ports; i++) { |
@@ -2284,7 +2302,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) | |||
2284 | XHCI_EXT_CAPS_PROTOCOL); | 2302 | XHCI_EXT_CAPS_PROTOCOL); |
2285 | } | 2303 | } |
2286 | 2304 | ||
2287 | xhci->ext_caps = kzalloc(sizeof(*xhci->ext_caps) * cap_count, flags); | 2305 | xhci->ext_caps = kcalloc_node(cap_count, sizeof(*xhci->ext_caps), |
2306 | flags, dev_to_node(dev)); | ||
2288 | if (!xhci->ext_caps) | 2307 | if (!xhci->ext_caps) |
2289 | return -ENOMEM; | 2308 | return -ENOMEM; |
2290 | 2309 | ||