From patchwork Tue May 17 21:39:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 623294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3r8W2X5WLrz9sBR for ; Wed, 18 May 2016 07:40:04 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751638AbcEQVkC (ORCPT ); Tue, 17 May 2016 17:40:02 -0400 Received: from mga04.intel.com ([192.55.52.120]:37591 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750790AbcEQVkB (ORCPT ); Tue, 17 May 2016 17:40:01 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 17 May 2016 14:40:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,325,1459839600"; d="scan'208";a="105675168" Received: from dcgshare.lm.intel.com ([10.232.118.254]) by fmsmga004.fm.intel.com with ESMTP; 17 May 2016 14:40:00 -0700 Received: by dcgshare.lm.intel.com (Postfix, from userid 1017) id 3C2B6E0C6D; Tue, 17 May 2016 15:40:00 -0600 (MDT) From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas , linux-nvme@lists.infradead.org, Jens Axboe , Christoph Hellwig Cc: Keith Busch Subject: [PATCH 1/2] pci: Error disabling SR-IOV if in VFs assigned Date: Tue, 17 May 2016 15:39:58 -0600 Message-Id: <1463521199-16604-1-git-send-email-keith.busch@intel.com> X-Mailer: git-send-email 1.7.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Every sriov capable driver has to check if any guest is using a virtual function prior to disabling, so let's make it common code. Signed-off-by: Keith Busch --- drivers/pci/pci-sysfs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 342b691..5011fa9 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -487,6 +487,11 @@ static ssize_t sriov_numvfs_store(struct device *dev, if (num_vfs == 0) { /* disable VFs */ + if (pci_vfs_assigned(pdev)) { + dev_warn(&pdev->dev, + "Cannot disable SR-IOV VFs while assigned\n"); + return -EPERM; + } ret = pdev->driver->sriov_configure(pdev, 0); if (ret < 0) return ret;