Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4158786pxv; Mon, 19 Jul 2021 18:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGg9mBTcgVW3r/05a80dXe69ANie93PWuD9q0euZTE0x5FHJJyQ8VqmR3Ot2XcD9NoR4tW X-Received: by 2002:a17:906:f0d1:: with SMTP id dk17mr29977954ejb.424.1626745711845; Mon, 19 Jul 2021 18:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626745711; cv=none; d=google.com; s=arc-20160816; b=u88D8nE9bC/wrfHcW8h1hOanq2IZelI96Lz/BqsBS23ogsWN71Fn7Wn20AEjPkC35W A/K+SxFuTfr1kcwTIb0abKd3z4biNLi08Heyml3H7qrfwEAUYHqh3cqh7bBGpm275Xlp yFMIJVbwZ6CuTg8s1o0ZCQKW1onzCiTSRMGccQB/At4A31gshv2kV0TmVAn5qO6XyVve ssBwKXcOViNnV3SrYqokchWySBIs6afhIgmr4v2/NMB4EkVZgPu//xd1Igce5R6btIhL 4M/MmhnFmbkgBkDy3NnRqDKye87xWjLgQZdycRaZmctEIl4oUDgRnto0K8tgn2/dB/Cl /0tQ== 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=3M4KyprXXBOuM92ksDQrOwG23j1lGEZjKHent6iufB4=; b=BlTbcjnOcNQL43h0mQD5fNuYeSM8hQ7cit+2wuan8naK+F6qvIqXLz8JQ95M0EdcRY kHJ78cooSb4jbQ8l2PAphxQ4cfL6E5QElCh/j7srQ2/ciz4Jy6VtKbVzGJ9bWhvbBej7 enYhqksmna0hPdrO/HNHEJ5Q93tFMm87E+PiDdQFQRd6B52C4XobbXgX9R3GA5ikp78C 3l32Etdk92VKH7M+WBTPJo2DqDpq5Ssx5pFyLxO1sC7riDpqYC+3o1951GMHg5BG4SWC 0xaBsGKR6u7aHWalnYx7aeMFo+IngrWg0q5TXln7r81fKtH73oKwwR7MWD06aWUoaEiy EPMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vNzicc+P; 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 d5si24129635ejd.487.2021.07.19.18.48.09; Mon, 19 Jul 2021 18:48:31 -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=vNzicc+P; 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 S1345575AbhGSPEm (ORCPT + 99 others); Mon, 19 Jul 2021 11:04:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:33226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343657AbhGSOmu (ORCPT ); Mon, 19 Jul 2021 10:42:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D22D361283; Mon, 19 Jul 2021 15:22:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626708131; bh=43qgoBIV0gy0S3L/hN2S9YS20QwvsVl4u9q0mM0Sd6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vNzicc+P/MkI9UmUdC/aAyvzqtfL6+xWS4vzpKEWMdjoSexUnvdfhIOKVWv715uxq ZF/6181/oQuGZKJRFAYE3UXNB+NwHYvAATpUQSwU4GH3sT3H9mtYLzkvzWpakRpysL 4tkb5nvk0dsLGUXc8YYf5+PmTykYuWm3BT9tjg0s= 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 4.14 194/315] sfc: error code if SRIOV cannot be disabled Date: Mon, 19 Jul 2021 16:51:23 +0200 Message-Id: <20210719144949.810563646@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@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 76c8d50882fc..2f36b18fd109 100644 --- a/drivers/net/ethernet/sfc/ef10_sriov.c +++ b/drivers/net/ethernet/sfc/ef10_sriov.c @@ -406,12 +406,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; " @@ -421,10 +426,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