Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp708572pxv; Thu, 15 Jul 2021 14:05:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY8mIEb4TcGFXF+mgJEo0r+rDnqCJneLkh1Z6sE433Qn4EsYRLQ+Sv6wdUeeSHmLHqk/EV X-Received: by 2002:a17:906:3e0b:: with SMTP id k11mr7589954eji.305.1626383101262; Thu, 15 Jul 2021 14:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383101; cv=none; d=google.com; s=arc-20160816; b=JgsKA0BLQ3ozm6CGwpFaTk9HVIdvCw22gLemAdvFByT3xP/uuDuolx4oQXSmZbWxJr 092qBijASeusZNA0uF+dRIcpslycX276DSU/C+acO2VTbEhJ/YstImTpqhAQjkrX8DOj r1icmjytelcvgN2lgUvZbcxRvIzgCNfzrdytZI0T6Zz0PcTPUQpGok4X1K1ytNch4oIp /QPQW4vHBpTdw0xJlHuKJWao7W6CCfX7adUNTtT0HaYOuShvJTIhBjr3/lY5mryIprN/ W4HboHxH8MJyUd5MpDjFwdaDGVElR/eOfUgzSUi5LFNDfc9b11Vug/5JvyxHpQ+3V/WL JUQQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0hYPr+TZ6aAIhZPOQkMhAA3pvqniIF9vfvGSBi3cZfA=; b=jLywhS8ldlkS0SXcTMaV2g0m3kTLOWXIJr+94kl3SHVd+cMEmJwNNpdcBOesNhqBju yG9jOeUuvM/QrXcx6m+cufIzx29LALQlZyh3Ks+geGxkOadxkAU2lUOO8axWKXIUlh/C 7aQ+0StzNUBCnZ9jw7LJiNiGl3DDhJd4YCyPNxFBANcNoP0ys0PFSn0gdlS23pIyDq/a SRkNkkQxQf/37f9XDeVAJxKQ+CUgGnnVFoh/8F6iLVPihMlRlG1bi1Er5WbCKY/rsBgu p+QBwq/kFurOehimeerMyXdUjf5jqPLVCxRhu8qTxEhCNIIYou4PmvkmHPyW1lrpaEH9 tmYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OjqIAmAV; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si1131700eds.168.2021.07.15.14.04.38; Thu, 15 Jul 2021 14:05:01 -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=@linuxfoundation.org header.s=korg header.b=OjqIAmAV; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244101AbhGOTPp (ORCPT + 99 others); Thu, 15 Jul 2021 15:15:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:39764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239129AbhGOTBr (ORCPT ); Thu, 15 Jul 2021 15:01:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 21A66613D1; Thu, 15 Jul 2021 18:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375522; bh=I3uMaH+VaCwt5rAUvLlpeXRhPaNL4gm4eDiwWCOwxY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OjqIAmAVLkH5Y056xnFCHFg7XbFv5Ni8FCO4pPdTrmd/dcPlibJNAwfAMABETscYI FkunuRYVmBxmI424bZWmolBPy3bQ+L9Txtz8+J2R4/C9/ezeKE397O5VmyLJSJuGwV GFknB2aHY2boFl05cVRdghFZUH8xxzuwNKjSXzRA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 124/242] sfc: error code if SRIOV cannot be disabled Date: Thu, 15 Jul 2021 20:38:06 +0200 Message-Id: <20210715182614.896932229@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Íñigo Huguet [ Upstream commit 1ebe4feb8b442884f5a28d2437040096723dd1ea ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 @@ fail1: 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.30.2