Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'virtio_net-fix-lock-warning-and-unrecoverable-state'

Heng Qi says:

====================
virtio_net: fix lock warning and unrecoverable state

Patch 1 describes and fixes an issue where dim cannot return to
normal state in certain scenarios.

Patch 2 attempts to resolve lockdep's complaints that holding many
nested locks.
====================

Link: https://lore.kernel.org/r/20240528134116.117426-1-hengqi@linux.alibaba.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+17 -21
+17 -21
drivers/net/virtio_net.c
··· 4259 4259 struct virtio_net_ctrl_coal_rx *coal_rx __free(kfree) = NULL; 4260 4260 bool rx_ctrl_dim_on = !!ec->use_adaptive_rx_coalesce; 4261 4261 struct scatterlist sgs_rx; 4262 - int ret = 0; 4263 4262 int i; 4264 4263 4265 4264 if (rx_ctrl_dim_on && !virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL)) ··· 4268 4269 ec->rx_max_coalesced_frames != vi->intr_coal_rx.max_packets)) 4269 4270 return -EINVAL; 4270 4271 4271 - /* Acquire all queues dim_locks */ 4272 - for (i = 0; i < vi->max_queue_pairs; i++) 4273 - mutex_lock(&vi->rq[i].dim_lock); 4274 - 4275 4272 if (rx_ctrl_dim_on && !vi->rx_dim_enabled) { 4276 4273 vi->rx_dim_enabled = true; 4277 - for (i = 0; i < vi->max_queue_pairs; i++) 4274 + for (i = 0; i < vi->max_queue_pairs; i++) { 4275 + mutex_lock(&vi->rq[i].dim_lock); 4278 4276 vi->rq[i].dim_enabled = true; 4279 - goto unlock; 4277 + mutex_unlock(&vi->rq[i].dim_lock); 4278 + } 4279 + return 0; 4280 4280 } 4281 4281 4282 4282 coal_rx = kzalloc(sizeof(*coal_rx), GFP_KERNEL); 4283 - if (!coal_rx) { 4284 - ret = -ENOMEM; 4285 - goto unlock; 4286 - } 4283 + if (!coal_rx) 4284 + return -ENOMEM; 4287 4285 4288 4286 if (!rx_ctrl_dim_on && vi->rx_dim_enabled) { 4289 4287 vi->rx_dim_enabled = false; 4290 - for (i = 0; i < vi->max_queue_pairs; i++) 4288 + for (i = 0; i < vi->max_queue_pairs; i++) { 4289 + mutex_lock(&vi->rq[i].dim_lock); 4291 4290 vi->rq[i].dim_enabled = false; 4291 + mutex_unlock(&vi->rq[i].dim_lock); 4292 + } 4292 4293 } 4293 4294 4294 4295 /* Since the per-queue coalescing params can be set, ··· 4301 4302 4302 4303 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, 4303 4304 VIRTIO_NET_CTRL_NOTF_COAL_RX_SET, 4304 - &sgs_rx)) { 4305 - ret = -EINVAL; 4306 - goto unlock; 4307 - } 4305 + &sgs_rx)) 4306 + return -EINVAL; 4308 4307 4309 4308 vi->intr_coal_rx.max_usecs = ec->rx_coalesce_usecs; 4310 4309 vi->intr_coal_rx.max_packets = ec->rx_max_coalesced_frames; 4311 4310 for (i = 0; i < vi->max_queue_pairs; i++) { 4311 + mutex_lock(&vi->rq[i].dim_lock); 4312 4312 vi->rq[i].intr_coal.max_usecs = ec->rx_coalesce_usecs; 4313 4313 vi->rq[i].intr_coal.max_packets = ec->rx_max_coalesced_frames; 4314 - } 4315 - unlock: 4316 - for (i = vi->max_queue_pairs - 1; i >= 0; i--) 4317 4314 mutex_unlock(&vi->rq[i].dim_lock); 4315 + } 4318 4316 4319 - return ret; 4317 + return 0; 4320 4318 } 4321 4319 4322 4320 static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi, ··· 4415 4419 if (err) 4416 4420 pr_debug("%s: Failed to send dim parameters on rxq%d\n", 4417 4421 dev->name, qnum); 4418 - dim->state = DIM_START_MEASURE; 4419 4422 } 4420 4423 out: 4424 + dim->state = DIM_START_MEASURE; 4421 4425 mutex_unlock(&rq->dim_lock); 4422 4426 } 4423 4427