Skip to content

Commit

Permalink
netvsc: save pointer to parent netvsc_device in channel table
Browse files Browse the repository at this point in the history
Keep back pointer in the per-channel data structure to
avoid any possible RCU related issues when napi poll is
called but netvsc_device is in RCU limbo.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
stephen hemminger authored and David S. Miller committed Jul 20, 2017
1 parent 2a926f7 commit 35fbbcc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions drivers/net/hyperv/hyperv_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ struct net_device_context {
/* Per channel data */
struct netvsc_channel {
struct vmbus_channel *channel;
struct netvsc_device *net_device;
const struct vmpacket_descriptor *desc;
struct napi_struct napi;
struct multi_send_data msd;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/hyperv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,11 +1224,11 @@ int netvsc_poll(struct napi_struct *napi, int budget)
{
struct netvsc_channel *nvchan
= container_of(napi, struct netvsc_channel, napi);
struct netvsc_device *net_device = nvchan->net_device;
struct vmbus_channel *channel = nvchan->channel;
struct hv_device *device = netvsc_channel_to_device(channel);
u16 q_idx = channel->offermsg.offer.sub_channel_index;
struct net_device *ndev = hv_get_drvdata(device);
struct netvsc_device *net_device = net_device_to_netvsc_device(ndev);
int work_done = 0;

/* If starting a new interval */
Expand Down Expand Up @@ -1307,6 +1307,7 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
struct netvsc_channel *nvchan = &net_device->chan_table[i];

nvchan->channel = device->channel;
nvchan->net_device = net_device;
}

/* Enable NAPI handler before init callbacks */
Expand Down

0 comments on commit 35fbbcc

Please sign in to comment.