Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2290574pxk; Sat, 5 Sep 2020 16:29:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9GVSLNKDiY8rEyJhfnDBiZWfIztPXj8H69LmRVCH+UGcpNzeMWVGgO1V7sv571v1WPdnV X-Received: by 2002:aa7:cf0e:: with SMTP id a14mr15487477edy.81.1599348594677; Sat, 05 Sep 2020 16:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599348594; cv=none; d=google.com; s=arc-20160816; b=fE5pFE6ZcN1tzlcVXpICg5F08dsNtBRrs9GKenC0QEieACHiUgqDM7XJbQlVmWfJUe TzqZbn6WFLCFiIjulT9N99BLRD59Zz1wTmH+wwYozl5/6SOF/JaU0ZXlpDe3b5TlMQBo zW7C0MC1GSoun/sf9d9tuQAmJ31/u6erihkBaJHxWiYzLqKwIzqfuZvm/pX5QqCV4+/D IxS24BQFfQfbk5yID4tFRYADcbxV17Nx7XsPsE77kA6wzA9ZHUuxxku76y9f5SOn63qL 19ERa4jqZx1nOqPzlt6hTF0T1ttzddSQeRJWGevIhdBo4zm12JVwxtcT8iJ2s7wMoEvH 0QAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=65lekfF5GTproJK3NX4r2RmZkvX/zDhPGKJhILygxVA=; b=WgDkfdSS5xM/lmjC9NC9wne/veMNBlzEFuoIugMRTT2425KocpNHI+fe54i0xItvH1 Aq1h9/Sp7+tnD5JSFrjKTN/xoyN2NtTjkkLT1HsJ2p4HroE8N0T2+BG1URG9g9SXeWAi 3RgMQgKR6JIgu985YqP4fLiHjQsFfjQS7mf9UWCx5z+QfkU5MUxwq80Hi3YkZxf3riw3 29N1dPsAq5QXxCwUls+SGL62buxq1E0bEetQgdII4xi4TLRXp+5EMIGQEbfDdJUvTT5i LrCTJEq6k+vifqNoTox8GXJrc1m1WdEljO4M+5CWKKI3UsUieQWXaiAM4Jx4WX46hO0N WV6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KITCRHBK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn22si8073147edb.175.2020.09.05.16.29.30; Sat, 05 Sep 2020 16:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KITCRHBK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728790AbgIEX1P (ORCPT + 99 others); Sat, 5 Sep 2020 19:27:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:48542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbgIEX1P (ORCPT ); Sat, 5 Sep 2020 19:27:15 -0400 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 28E9A20760; Sat, 5 Sep 2020 23:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599348434; bh=A7EvWwYyZIg7QaFOdO9o87JScI5m8RkQBYiqzNGzEvw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KITCRHBKnJrF02EID/fEfEJJHzcNhXJNfg4nlPbAzsMVxUDaKH5HD32plB5WvUD7Z hX9EVWnEpQ6buLJHZate6UPxCIe0g2QH/pOZZeaBGtE2P2zzLUZvwhRt8XZOhF+NaT KYASqugwvRhykwwJvBhofx9gVY+rNhRedN0Pf/+c= Date: Sat, 5 Sep 2020 16:27:12 -0700 From: Jakub Kicinski To: Dexuan Cui Cc: wei.liu@kernel.org, kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, davem@davemloft.net, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com Subject: Re: [PATCH net] hv_netvsc: Fix hibernation for mlx5 VF driver Message-ID: <20200905162712.65b886a4@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20200905025218.45268-1-decui@microsoft.com> References: <20200905025218.45268-1-decui@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 4 Sep 2020 19:52:18 -0700 Dexuan Cui wrote: > mlx5_suspend()/resume() keep the network interface, so during hibernation > netvsc_unregister_vf() and netvsc_register_vf() are not called, and hence > netvsc_resume() should call netvsc_vf_changed() to switch the data path > back to the VF after hibernation. Does suspending the system automatically switch back to the synthetic datapath? Please clarify this in the commit message and/or add a code comment. > Similarly, netvsc_suspend() should not call netvsc_unregister_vf(). > > BTW, mlx4_suspend()/resume() are differnt in that they destroy and > re-create the network device, so netvsc_register_vf() and > netvsc_unregister_vf() are automatically called. Note: mlx4 can also work > with the changes here because in netvsc_suspend()/resume() > ndev_ctx->vf_netdev is NULL for mlx4. > > Fixes: 0efeea5fb153 ("hv_netvsc: Add the support of hibernation") > Signed-off-by: Dexuan Cui > --- > drivers/net/hyperv/netvsc_drv.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c > index 64b0a74c1523..f896059a9588 100644 > --- a/drivers/net/hyperv/netvsc_drv.c > +++ b/drivers/net/hyperv/netvsc_drv.c > @@ -2587,7 +2587,7 @@ static int netvsc_remove(struct hv_device *dev) > static int netvsc_suspend(struct hv_device *dev) > { > struct net_device_context *ndev_ctx; > - struct net_device *vf_netdev, *net; > + struct net_device *net; > struct netvsc_device *nvdev; > int ret; Please keep reverse xmas tree variable ordering. > @@ -2604,10 +2604,6 @@ static int netvsc_suspend(struct hv_device *dev) > goto out; > } > > - vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev); > - if (vf_netdev) > - netvsc_unregister_vf(vf_netdev); > - > /* Save the current config info */ > ndev_ctx->saved_netvsc_dev_info = netvsc_devinfo_get(nvdev); > > @@ -2623,6 +2619,7 @@ static int netvsc_resume(struct hv_device *dev) > struct net_device *net = hv_get_drvdata(dev); > struct net_device_context *net_device_ctx; > struct netvsc_device_info *device_info; > + struct net_device *vf_netdev; > int ret; > > rtnl_lock(); > @@ -2635,6 +2632,10 @@ static int netvsc_resume(struct hv_device *dev) > netvsc_devinfo_put(device_info); > net_device_ctx->saved_netvsc_dev_info = NULL; > > + vf_netdev = rtnl_dereference(net_device_ctx->vf_netdev); > + if (vf_netdev && netvsc_vf_changed(vf_netdev) != NOTIFY_OK) > + ret = -EINVAL; Should you perhaps remove the VF in case of the failure? > rtnl_unlock(); > > return ret;