Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp657672pxv; Thu, 15 Jul 2021 12:40:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN6MvzKtvcY/qQchKNP1JwnJFFA8lNSaeSHP9Y0goCaF3c+z/tGcaHQPVRafGxESVqFpQq X-Received: by 2002:a05:6402:160d:: with SMTP id f13mr9343380edv.295.1626378047659; Thu, 15 Jul 2021 12:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378047; cv=none; d=google.com; s=arc-20160816; b=xDv4j8s7G5VEv4ab7uJWwoXabG/qxx0zOaBd2uBfxn4uWZTu8aQBwzJ/M+oUjoKM+J p2kBqTD4ShAwtHHkpM09wmy3WZBSlIsBhjfvW/Ugbz1AXV+WeqezD3aM63fGT7lFcvOc zPMN5kn5HnkcYdftE1NaGdovsk1lYHH0omFIyouHgQtzn7cQ3rJPRZoHEaVEtaItGjPv CLvc6Hclhgndwbu90nVdmB6pJV9coTf6YKNCahMuocWWGzGJ5JZd0R4fSWADtRzeg7f5 h9EsdZLi0fPxrgsVdkuIgmbWIV7+MMC2+hVLxHK1PmLbyhBU3qMRVG0ixTYMNd5VCg9w frvA== 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=l+jvAIrirGwic6LU+RgBgHECf04/jsoDB4ffY7xmkMOg5uVb8gKrJf9D2LNJZm0qIn 0xENQKd1J0Jt6ufi4njVAkK+mLCOfZg11Dx7GoX2gwgulrx/xZk5fUedV2ptLKFW3bfY dGULVbJGq8R8ZMphjIQv+exBhWaFR7XoczMXOYt13x0Yb+0+6W0zw/kvSsH+0vi5ZrhB of+qS4hTEk+/avs0VGayOMItAn1jt0+/e1Mb32TPD1v+S0GLIZRNM0GoyWmb+DvCNif6 LVaDKWJO/FlHzPsIyWjpRU2VjpLLsBfhoYR2+0pe+vasW8qAa4c2RN+QR+cM+hGTHOOV Muhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BKykWT9K; 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 w25si7659629eja.725.2021.07.15.12.40.24; Thu, 15 Jul 2021 12:40:47 -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=BKykWT9K; 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 S1345733AbhGOTgf (ORCPT + 99 others); Thu, 15 Jul 2021 15:36:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:50954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243464AbhGOTMh (ORCPT ); Thu, 15 Jul 2021 15:12:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8BC10613CF; Thu, 15 Jul 2021 19:09:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376148; bh=I3uMaH+VaCwt5rAUvLlpeXRhPaNL4gm4eDiwWCOwxY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BKykWT9KGtWTtW1fkmq9qTnOokNRoj+bo5D/svjzF0OvhFEfLEFB8OaXI4EhQjn8H irkfJrxhL5e1xy0L2K5pgYwvGjm1izM8wu4rmQE1qWoGqxNV5fexH0VYO7fHv98/mN ai9wo+/46r0ZHIzAfggHR7M31luD0Nn5PQMiVvSI= 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.13 146/266] sfc: error code if SRIOV cannot be disabled Date: Thu, 15 Jul 2021 20:38:21 +0200 Message-Id: <20210715182639.349852415@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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