Skip to content

Commit c3a8d37

Browse files
refactormandavem330
authored andcommitted
net: thunderbolt: Use kmap_local_page() instead of kmap_atomic()
kmap_atomic() is being deprecated in favor of kmap_local_page(). Replace kmap_atomic() and kunmap_atomic() with kmap_local_page() and kunmap_local() respectively. Note that kmap_atomic() disables preemption and page-fault processing, but kmap_local_page() doesn't. When converting uses of kmap_atomic(), one has to check if the code being executed between the map/unmap implicitly depends on page-faults and/or preemption being disabled. If yes, then code to disable page-faults and/or preemption should also be added for functional correctness. That however doesn't appear to be the case here, so just kmap_local_page() is used. Also note that the page being mapped is not allocated by the driver, and so the driver doesn't know if the page is in normal memory. This is the reason kmap_local_page() is used as opposed to page_address(). I don't have hardware, so this change has only been compile tested. Cc: Michael Jamet <[email protected]> Cc: Mika Westerberg <[email protected]> Cc: Yehezkel Bernat <[email protected]> Cc: Ira Weiny <[email protected]> Cc: Fabio M. De Francesco <[email protected]> Signed-off-by: Anirudh Venkataramanan <[email protected]> Acked-by: Mika Westerberg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 350d351 commit c3a8d37

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/thunderbolt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ static void *tbnet_kmap_frag(struct sk_buff *skb, unsigned int frag_num,
10511051
const skb_frag_t *frag = &skb_shinfo(skb)->frags[frag_num];
10521052

10531053
*len = skb_frag_size(frag);
1054-
return kmap_atomic(skb_frag_page(frag)) + skb_frag_off(frag);
1054+
return kmap_local_page(skb_frag_page(frag)) + skb_frag_off(frag);
10551055
}
10561056

10571057
static netdev_tx_t tbnet_start_xmit(struct sk_buff *skb,
@@ -1109,7 +1109,7 @@ static netdev_tx_t tbnet_start_xmit(struct sk_buff *skb,
11091109
dest += len;
11101110

11111111
if (unmap) {
1112-
kunmap_atomic(src);
1112+
kunmap_local(src);
11131113
unmap = false;
11141114
}
11151115

@@ -1147,7 +1147,7 @@ static netdev_tx_t tbnet_start_xmit(struct sk_buff *skb,
11471147
dest += len;
11481148

11491149
if (unmap) {
1150-
kunmap_atomic(src);
1150+
kunmap_local(src);
11511151
unmap = false;
11521152
}
11531153

@@ -1162,7 +1162,7 @@ static netdev_tx_t tbnet_start_xmit(struct sk_buff *skb,
11621162
memcpy(dest, src, data_len);
11631163

11641164
if (unmap)
1165-
kunmap_atomic(src);
1165+
kunmap_local(src);
11661166

11671167
if (!tbnet_xmit_csum_and_map(net, skb, frames, frame_index + 1))
11681168
goto err_drop;

0 commit comments

Comments
 (0)