Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3881149pxj; Mon, 21 Jun 2021 08:34:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoj+F1SSQv3JKw9qYwLJvfrXvadC1zEMkDj7JUXADnWxjpAYcKHjk/mVs2vaRkYNR0+RVu X-Received: by 2002:a17:907:9854:: with SMTP id jj20mr22526718ejc.365.1624289674039; Mon, 21 Jun 2021 08:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624289674; cv=none; d=google.com; s=arc-20160816; b=jWhWCXDY1JAHDKdnCnZhINmjHbO69kdNizpJDP/1JujxGVfbEaewJGyeM5ePTn26ik JgFnm1WDv5Nynl6WMQJcrTcF2CxTJEV4Cr8B8PJbnZ972TPN1o5wiUtnrrI+yMnvpKtg Wa3yRBnWS+VWJzvj31j334X4GsLmibqytey224QjjnI0F0FsrzBmcGgXjIqdBEBD152R KffDgpKdo60joTDX6aIF6IbugXvoSg1aPARlkj9fCWvAXz4LRV7Noq0X5f6BfxWr0Xny QIa/0cw1uH1NahX4fFl4udygnKcFLECS+BU+aN1TY+C04i6BTtuS+aDzW/hGN5yco6Y6 YqPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bT6mPBBQcD2uHGw/yzZaVD0VJRzw9tH+BaS9m1VQ8n0=; b=TuewM+z+ZzpgSPFpl1ix0T+kgzhEgN6lLgZ3Z4HP7LRB+Zbg5b8CDZ9WRbHXtNTGWE 6+kg0eev72gFbe3pBIqXSNQYTvTQ1PFyzjvy7IBG3CwbMrxVSJuHLFdOhbawUMJ0Jnex U0foM+E1bQY6sCiv05Lu9WRrLXvdgJbJPsiJuEshv073rtiHYQwnzNMSzCtPT0XqssEK ZLx7t6BCPdBUYEorhd5U2H4GhcqjOoi+T+pqoHSv/Rs6hbaWSR6qOMH89LHQRwUrMx28 nE4z1pLfOYiLTB5kf0Vc9+sHja/bCMd4jRpTkgncI1jY9R3q4WVCkStzEHjwigAWu7fu l8QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LVboHa7w; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e16si11488728ejj.154.2021.06.21.08.34.12; Mon, 21 Jun 2021 08:34:34 -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=@redhat.com header.s=mimecast20190719 header.b=LVboHa7w; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230318AbhFUPfQ (ORCPT + 99 others); Mon, 21 Jun 2021 11:35:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56023 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbhFUPfP (ORCPT ); Mon, 21 Jun 2021 11:35:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624289581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bT6mPBBQcD2uHGw/yzZaVD0VJRzw9tH+BaS9m1VQ8n0=; b=LVboHa7wA5WdzwcwRlLKW7xCzq2zvtYAdsogL5ZwB4iUim8eN0YACyfXnvw14E5HFSkf+w FqbPTOd3x+97sjBOb0JO3gPaIsf0GOJ9oWzyh+yrpa2YGTGK1AKIvZDuNio9CehqAuwU4c /Z4Ge568Lr9a+4Lh7Q31t0NyXxuJVYg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-6MM2S6b5P-2F5h3WqLohrA-1; Mon, 21 Jun 2021 11:32:59 -0400 X-MC-Unique: 6MM2S6b5P-2F5h3WqLohrA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EF2F5721D; Mon, 21 Jun 2021 15:32:57 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-119.ams2.redhat.com [10.36.112.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91FA418B42; Mon, 21 Jun 2021 15:32:55 +0000 (UTC) From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= To: ecree.xilinx@gmail.com, habetsm.xilinx@gmail.com, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ihuguet@redhat.com, ivecera@redhat.com Subject: [PATCH 2/4] sfc: error code if SRIOV cannot be disabled Date: Mon, 21 Jun 2021 17:32:36 +0200 Message-Id: <20210621153238.13147-2-ihuguet@redhat.com> In-Reply-To: <20210621153238.13147-1-ihuguet@redhat.com> References: <20210621153238.13147-1-ihuguet@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If SRIOV cannot be disabled during device removal or module unloading, return error code so it can be logged properly in the calling function. Note that this can only happen if any VF is currently attached to a guest using Xen, but not with vfio/KVM. Despite that in that case the VFs won't work properly with PF removed and/or the module unloaded, I have let it as is because I don't know what side effects may have changing it, and also it seems to be the same that other drivers are doing in this situation. In the case of being called during SRIOV reconfiguration, the behavior hasn't changed because the function is called with force=false. Signed-off-by: Íñigo Huguet --- drivers/net/ethernet/sfc/ef10_sriov.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef10_sriov.c b/drivers/net/ethernet/sfc/ef10_sriov.c index a5d28b0f75ba..84041cd587d7 100644 --- a/drivers/net/ethernet/sfc/ef10_sriov.c +++ b/drivers/net/ethernet/sfc/ef10_sriov.c @@ -402,12 +402,17 @@ static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs) return rc; } +/* Disable SRIOV and remove VFs + * If some VFs are attached to a guest (using Xen, only) nothing is + * done if force=false, and vports are freed if force=true (for the non + * attachedc ones, only) but SRIOV is not disabled and VFs are not + * removed in either case. + */ static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force) { struct pci_dev *dev = efx->pci_dev; - unsigned int vfs_assigned = 0; - - vfs_assigned = pci_vfs_assigned(dev); + unsigned int vfs_assigned = pci_vfs_assigned(dev); + int rc = 0; if (vfs_assigned && !force) { netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; " @@ -417,10 +422,12 @@ static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force) if (!vfs_assigned) pci_disable_sriov(dev); + else + rc = -EBUSY; efx_ef10_sriov_free_vf_vswitching(efx); efx->vf_count = 0; - return 0; + return rc; } int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs) -- 2.31.1