提交 a965315e 编写于 作者: A Adam Wallis 提交者: Greg Kroah-Hartman

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: NAdam Wallis <awallis@codeaurora.org>
Acked-by: NMathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 5ef12cb4
...@@ -33,8 +33,9 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, ...@@ -33,8 +33,9 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
struct xhci_segment *seg; struct xhci_segment *seg;
dma_addr_t dma; dma_addr_t dma;
int i; int i;
struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
seg = kzalloc(sizeof *seg, flags); seg = kzalloc_node(sizeof(*seg), flags, dev_to_node(dev));
if (!seg) if (!seg)
return NULL; return NULL;
...@@ -45,7 +46,8 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, ...@@ -45,7 +46,8 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
} }
if (max_packet) { if (max_packet) {
seg->bounce_buf = kzalloc(max_packet, flags); seg->bounce_buf = kzalloc_node(max_packet, flags,
dev_to_node(dev));
if (!seg->bounce_buf) { if (!seg->bounce_buf) {
dma_pool_free(xhci->segment_pool, seg->trbs, dma); dma_pool_free(xhci->segment_pool, seg->trbs, dma);
kfree(seg); kfree(seg);
...@@ -363,8 +365,9 @@ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, ...@@ -363,8 +365,9 @@ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
{ {
struct xhci_ring *ring; struct xhci_ring *ring;
int ret; int ret;
struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
ring = kzalloc(sizeof *(ring), flags); ring = kzalloc_node(sizeof(*ring), flags, dev_to_node(dev));
if (!ring) if (!ring)
return NULL; return NULL;
...@@ -458,11 +461,12 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, ...@@ -458,11 +461,12 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci,
int type, gfp_t flags) int type, gfp_t flags)
{ {
struct xhci_container_ctx *ctx; struct xhci_container_ctx *ctx;
struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
if ((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT)) if ((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT))
return NULL; return NULL;
ctx = kzalloc(sizeof(*ctx), flags); ctx = kzalloc_node(sizeof(*ctx), flags, dev_to_node(dev));
if (!ctx) if (!ctx)
return NULL; return NULL;
...@@ -615,6 +619,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, ...@@ -615,6 +619,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci,
struct xhci_ring *cur_ring; struct xhci_ring *cur_ring;
u64 addr; u64 addr;
int ret; int ret;
struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
xhci_dbg(xhci, "Allocating %u streams and %u " xhci_dbg(xhci, "Allocating %u streams and %u "
"stream context array entries.\n", "stream context array entries.\n",
...@@ -625,7 +630,8 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, ...@@ -625,7 +630,8 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci,
} }
xhci->cmd_ring_reserved_trbs++; xhci->cmd_ring_reserved_trbs++;
stream_info = kzalloc(sizeof(struct xhci_stream_info), mem_flags); stream_info = kzalloc_node(sizeof(*stream_info), mem_flags,
dev_to_node(dev));
if (!stream_info) if (!stream_info)
goto cleanup_trbs; goto cleanup_trbs;
...@@ -633,9 +639,9 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, ...@@ -633,9 +639,9 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci,
stream_info->num_stream_ctxs = num_stream_ctxs; stream_info->num_stream_ctxs = num_stream_ctxs;
/* Initialize the array of virtual pointers to stream rings. */ /* Initialize the array of virtual pointers to stream rings. */
stream_info->stream_rings = kzalloc( stream_info->stream_rings = kcalloc_node(
sizeof(struct xhci_ring *)*num_streams, num_streams, sizeof(struct xhci_ring *), mem_flags,
mem_flags); dev_to_node(dev));
if (!stream_info->stream_rings) if (!stream_info->stream_rings)
goto cleanup_info; goto cleanup_info;
...@@ -831,6 +837,7 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci, ...@@ -831,6 +837,7 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci,
struct xhci_tt_bw_info *tt_info; struct xhci_tt_bw_info *tt_info;
unsigned int num_ports; unsigned int num_ports;
int i, j; int i, j;
struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
if (!tt->multi) if (!tt->multi)
num_ports = 1; num_ports = 1;
...@@ -840,7 +847,8 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci, ...@@ -840,7 +847,8 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci,
for (i = 0; i < num_ports; i++, tt_info++) { for (i = 0; i < num_ports; i++, tt_info++) {
struct xhci_interval_bw_table *bw_table; struct xhci_interval_bw_table *bw_table;
tt_info = kzalloc(sizeof(*tt_info), mem_flags); tt_info = kzalloc_node(sizeof(*tt_info), mem_flags,
dev_to_node(dev));
if (!tt_info) if (!tt_info)
goto free_tts; goto free_tts;
INIT_LIST_HEAD(&tt_info->tt_list); INIT_LIST_HEAD(&tt_info->tt_list);
...@@ -1641,7 +1649,8 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) ...@@ -1641,7 +1649,8 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
if (!num_sp) if (!num_sp)
return 0; return 0;
xhci->scratchpad = kzalloc(sizeof(*xhci->scratchpad), flags); xhci->scratchpad = kzalloc_node(sizeof(*xhci->scratchpad), flags,
dev_to_node(dev));
if (!xhci->scratchpad) if (!xhci->scratchpad)
goto fail_sp; goto fail_sp;
...@@ -1651,7 +1660,8 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) ...@@ -1651,7 +1660,8 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
if (!xhci->scratchpad->sp_array) if (!xhci->scratchpad->sp_array)
goto fail_sp2; goto fail_sp2;
xhci->scratchpad->sp_buffers = kzalloc(sizeof(void *) * num_sp, flags); xhci->scratchpad->sp_buffers = kcalloc_node(num_sp, sizeof(void *),
flags, dev_to_node(dev));
if (!xhci->scratchpad->sp_buffers) if (!xhci->scratchpad->sp_buffers)
goto fail_sp3; goto fail_sp3;
...@@ -1719,14 +1729,16 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, ...@@ -1719,14 +1729,16 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
bool allocate_completion, gfp_t mem_flags) bool allocate_completion, gfp_t mem_flags)
{ {
struct xhci_command *command; struct xhci_command *command;
struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
command = kzalloc(sizeof(*command), mem_flags); command = kzalloc_node(sizeof(*command), mem_flags, dev_to_node(dev));
if (!command) if (!command)
return NULL; return NULL;
if (allocate_completion) { if (allocate_completion) {
command->completion = command->completion =
kzalloc(sizeof(struct completion), mem_flags); kzalloc_node(sizeof(struct completion), mem_flags,
dev_to_node(dev));
if (!command->completion) { if (!command->completion) {
kfree(command); kfree(command);
return NULL; return NULL;
...@@ -2099,6 +2111,7 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, ...@@ -2099,6 +2111,7 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
int i; int i;
u8 major_revision, minor_revision; u8 major_revision, minor_revision;
struct xhci_hub *rhub; struct xhci_hub *rhub;
struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
temp = readl(addr); temp = readl(addr);
major_revision = XHCI_EXT_PORT_MAJOR(temp); 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,8 +2148,8 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
rhub->psi_count = XHCI_EXT_PORT_PSIC(temp); rhub->psi_count = XHCI_EXT_PORT_PSIC(temp);
if (rhub->psi_count) { if (rhub->psi_count) {
rhub->psi = kcalloc(rhub->psi_count, sizeof(*rhub->psi), rhub->psi = kcalloc_node(rhub->psi_count, sizeof(*rhub->psi),
GFP_KERNEL); GFP_KERNEL, dev_to_node(dev));
if (!rhub->psi) if (!rhub->psi)
rhub->psi_count = 0; rhub->psi_count = 0;
...@@ -2214,10 +2227,12 @@ static void xhci_create_rhub_port_array(struct xhci_hcd *xhci, ...@@ -2214,10 +2227,12 @@ static void xhci_create_rhub_port_array(struct xhci_hcd *xhci,
{ {
int port_index = 0; int port_index = 0;
int i; int i;
struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
if (!rhub->num_ports) if (!rhub->num_ports)
return; return;
rhub->ports = kcalloc(rhub->num_ports, sizeof(rhub->ports), flags); rhub->ports = kcalloc_node(rhub->num_ports, sizeof(rhub->ports), flags,
dev_to_node(dev));
for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) {
if (xhci->hw_ports[i].rhub != rhub || if (xhci->hw_ports[i].rhub != rhub ||
xhci->hw_ports[i].hcd_portnum == DUPLICATE_ENTRY) 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,9 +2260,11 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
int i, j; int i, j;
int cap_count = 0; int cap_count = 0;
u32 cap_start; u32 cap_start;
struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
num_ports = HCS_MAX_PORTS(xhci->hcs_params1); num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
xhci->hw_ports = kcalloc(num_ports, sizeof(*xhci->hw_ports), flags); xhci->hw_ports = kcalloc_node(num_ports, sizeof(*xhci->hw_ports),
flags, dev_to_node(dev));
if (!xhci->hw_ports) if (!xhci->hw_ports)
return -ENOMEM; return -ENOMEM;
...@@ -2257,7 +2274,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) ...@@ -2257,7 +2274,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
xhci->hw_ports[i].hw_portnum = i; xhci->hw_ports[i].hw_portnum = i;
} }
xhci->rh_bw = kzalloc(sizeof(*xhci->rh_bw)*num_ports, flags); xhci->rh_bw = kzalloc_node(sizeof(*xhci->rh_bw)*num_ports, flags,
dev_to_node(dev));
if (!xhci->rh_bw) if (!xhci->rh_bw)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < num_ports; i++) { 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,7 +2302,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
XHCI_EXT_CAPS_PROTOCOL); XHCI_EXT_CAPS_PROTOCOL);
} }
xhci->ext_caps = kzalloc(sizeof(*xhci->ext_caps) * cap_count, flags); xhci->ext_caps = kcalloc_node(cap_count, sizeof(*xhci->ext_caps),
flags, dev_to_node(dev));
if (!xhci->ext_caps) if (!xhci->ext_caps)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册