Received: by 10.223.185.116 with SMTP id b49csp5473314wrg; Wed, 7 Mar 2018 12:21:58 -0800 (PST) X-Google-Smtp-Source: AG47ELuODlh/BoI7KqppxjN2vC0k4e2sSlV0zJEJjmOWmfwpwuHZF6ZUJYhPfSMeL/7JhrwEz3// X-Received: by 10.99.189.1 with SMTP id a1mr19179540pgf.189.1520454118621; Wed, 07 Mar 2018 12:21:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520454118; cv=none; d=google.com; s=arc-20160816; b=J3MlURm6fQMuObxKvKaVTMUnQ/XOyO046a6HUrE2K9zt1UBfZAIlhiNeLjAvvOaLep k4nXWxNFmOs+AkbSvWQ3dgJGlP+dwtPy5kgxPMJ4SYWcjTYKgch6GUifOyMD4R6GW5GT Os9SosCdpEBlf2LtV7KS9BVQCEnYxc1xQ8x2LM8HcO1UxOsrk9qP7TYTRWDQs0wfbn4r Mund//VjlVGBJKPNT344VYFyi4T7rVlzeJUykMb8tOzHAjZmByRPJ9u0xLZj/WPJNH9Q K6IdFJMbT40wDWRDK5zsfhWfyJVKvlVbHsj9QpLeQPmX8cdHdF96OJ8nA4iuPwwHDbFg JZWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=MyFMoy8qTq24HD4UufgZw0+qBpcwvipwO1VmxeHxHyw=; b=fxcLPztQVg7x3x2hY7qqi5FGtJhM330cxV+6A72y+7b/rwETJqdK0jUOMyrPTyWYEp 7j3XlcKXJGnpL5uXeQ1te8rRI1dr3byllcrUm4XpkLS8QdGppjFZdqYtugJ1Mt2PMOmj GM/6gjBW/V4Tb0UavToAmR/qMLhzB5l5Ztsi5zL+gfC3mkwHSgGc6sKMpMJ0KJzzuqEW PQ6glwIE4xys/xdTZRLo9p1/K+FKQuN5nl8zl3NeTKJLwJ3ToIhT9WC1E4SmNkYezFYO uJBU/Db5qd4m5mFv9I4CfjddeWgoYNNXjb1ia0lpfKPkegz7ljfIcsicUJqhN8a0LLqz 4U2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y125si11811286pgb.120.2018.03.07.12.21.43; Wed, 07 Mar 2018 12:21:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965099AbeCGUTk (ORCPT + 99 others); Wed, 7 Mar 2018 15:19:40 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43500 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934983AbeCGTnt (ORCPT ); Wed, 7 Mar 2018 14:43:49 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 41A58E1E; Wed, 7 Mar 2018 19:43:49 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Wang , "Michael S. Tsirkin" , "David S. Miller" Subject: [PATCH 4.15 078/122] virtio-net: disable NAPI only when enabled during XDP set Date: Wed, 7 Mar 2018 11:38:10 -0800 Message-Id: <20180307191740.519486798@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191729.190879024@linuxfoundation.org> References: <20180307191729.190879024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Wang [ Upstream commit 4e09ff5362843dff3accfa84c805c7f3a99de9cd ] We try to disable NAPI to prevent a single XDP TX queue being used by multiple cpus. But we don't check if device is up (NAPI is enabled), this could result stall because of infinite wait in napi_disable(). Fixing this by checking device state through netif_running() before. Fixes: 4941d472bf95b ("virtio-net: do not reset during XDP set") Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/virtio_net.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2040,8 +2040,9 @@ static int virtnet_xdp_set(struct net_de } /* Make sure NAPI is not using any XDP TX queues for RX. */ - for (i = 0; i < vi->max_queue_pairs; i++) - napi_disable(&vi->rq[i].napi); + if (netif_running(dev)) + for (i = 0; i < vi->max_queue_pairs; i++) + napi_disable(&vi->rq[i].napi); netif_set_real_num_rx_queues(dev, curr_qp + xdp_qp); err = _virtnet_set_queues(vi, curr_qp + xdp_qp); @@ -2060,7 +2061,8 @@ static int virtnet_xdp_set(struct net_de } if (old_prog) bpf_prog_put(old_prog); - virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi); + if (netif_running(dev)) + virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi); } return 0;