@@ -33,8 +33,9 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
33
33
struct xhci_segment * seg ;
34
34
dma_addr_t dma ;
35
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
39
if (!seg )
39
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
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
51
if (!seg -> bounce_buf ) {
50
52
dma_pool_free (xhci -> segment_pool , seg -> trbs , dma );
51
53
kfree (seg );
@@ -363,8 +365,9 @@ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
363
365
{
364
366
struct xhci_ring * ring ;
365
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
371
if (!ring )
369
372
return NULL ;
370
373
@@ -458,11 +461,12 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci,
458
461
int type , gfp_t flags )
459
462
{
460
463
struct xhci_container_ctx * ctx ;
464
+ struct device * dev = xhci_to_hcd (xhci )-> self .sysdev ;
461
465
462
466
if ((type != XHCI_CTX_TYPE_DEVICE ) && (type != XHCI_CTX_TYPE_INPUT ))
463
467
return NULL ;
464
468
465
- ctx = kzalloc (sizeof (* ctx ), flags );
469
+ ctx = kzalloc_node (sizeof (* ctx ), flags , dev_to_node ( dev ) );
466
470
if (!ctx )
467
471
return NULL ;
468
472
@@ -615,6 +619,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci,
615
619
struct xhci_ring * cur_ring ;
616
620
u64 addr ;
617
621
int ret ;
622
+ struct device * dev = xhci_to_hcd (xhci )-> self .sysdev ;
618
623
619
624
xhci_dbg (xhci , "Allocating %u streams and %u "
620
625
"stream context array entries.\n" ,
@@ -625,17 +630,18 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci,
625
630
}
626
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
635
if (!stream_info )
630
636
goto cleanup_trbs ;
631
637
632
638
stream_info -> num_streams = num_streams ;
633
639
stream_info -> num_stream_ctxs = num_stream_ctxs ;
634
640
635
641
/* Initialize the array of virtual pointers to stream rings. */
636
- stream_info -> stream_rings = kzalloc (
637
- sizeof (struct xhci_ring * )* num_streams ,
638
- mem_flags );
642
+ stream_info -> stream_rings = kcalloc_node (
643
+ num_streams , sizeof (struct xhci_ring * ), mem_flags ,
644
+ dev_to_node ( dev ) );
639
645
if (!stream_info -> stream_rings )
640
646
goto cleanup_info ;
641
647
@@ -831,6 +837,7 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci,
831
837
struct xhci_tt_bw_info * tt_info ;
832
838
unsigned int num_ports ;
833
839
int i , j ;
840
+ struct device * dev = xhci_to_hcd (xhci )-> self .sysdev ;
834
841
835
842
if (!tt -> multi )
836
843
num_ports = 1 ;
@@ -840,7 +847,8 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci,
840
847
for (i = 0 ; i < num_ports ; i ++ , tt_info ++ ) {
841
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
852
if (!tt_info )
845
853
goto free_tts ;
846
854
INIT_LIST_HEAD (& tt_info -> tt_list );
@@ -1641,7 +1649,8 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
1641
1649
if (!num_sp )
1642
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
1654
if (!xhci -> scratchpad )
1646
1655
goto fail_sp ;
1647
1656
@@ -1651,7 +1660,8 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
1651
1660
if (!xhci -> scratchpad -> sp_array )
1652
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
1665
if (!xhci -> scratchpad -> sp_buffers )
1656
1666
goto fail_sp3 ;
1657
1667
@@ -1719,14 +1729,16 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1719
1729
bool allocate_completion , gfp_t mem_flags )
1720
1730
{
1721
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
1735
if (!command )
1725
1736
return NULL ;
1726
1737
1727
1738
if (allocate_completion ) {
1728
1739
command -> completion =
1729
- kzalloc (sizeof (struct completion ), mem_flags );
1740
+ kzalloc_node (sizeof (struct completion ), mem_flags ,
1741
+ dev_to_node (dev ));
1730
1742
if (!command -> completion ) {
1731
1743
kfree (command );
1732
1744
return NULL ;
@@ -2099,6 +2111,7 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
2099
2111
int i ;
2100
2112
u8 major_revision , minor_revision ;
2101
2113
struct xhci_hub * rhub ;
2114
+ struct device * dev = xhci_to_hcd (xhci )-> self .sysdev ;
2102
2115
2103
2116
temp = readl (addr );
2104
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
2149
rhub -> psi_count = XHCI_EXT_PORT_PSIC (temp );
2137
2150
if (rhub -> psi_count ) {
2138
- rhub -> psi = kcalloc (rhub -> psi_count , sizeof (* rhub -> psi ),
2139
- GFP_KERNEL );
2151
+ rhub -> psi = kcalloc_node (rhub -> psi_count , sizeof (* rhub -> psi ),
2152
+ GFP_KERNEL , dev_to_node ( dev ) );
2140
2153
if (!rhub -> psi )
2141
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
2228
int port_index = 0 ;
2216
2229
int i ;
2230
+ struct device * dev = xhci_to_hcd (xhci )-> self .sysdev ;
2217
2231
2218
2232
if (!rhub -> num_ports )
2219
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
2236
for (i = 0 ; i < HCS_MAX_PORTS (xhci -> hcs_params1 ); i ++ ) {
2222
2237
if (xhci -> hw_ports [i ].rhub != rhub ||
2223
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
2260
int i , j ;
2246
2261
int cap_count = 0 ;
2247
2262
u32 cap_start ;
2263
+ struct device * dev = xhci_to_hcd (xhci )-> self .sysdev ;
2248
2264
2249
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
2268
if (!xhci -> hw_ports )
2252
2269
return - ENOMEM ;
2253
2270
@@ -2257,7 +2274,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
2257
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
2279
if (!xhci -> rh_bw )
2262
2280
return - ENOMEM ;
2263
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
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
2307
if (!xhci -> ext_caps )
2289
2308
return - ENOMEM ;
2290
2309
0 commit comments