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: 9115271 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 927449F30C for ; Tue, 17 May 2016 21:40:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9B9C20253 for ; Tue, 17 May 2016 21:40:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7ED512021B for ; Tue, 17 May 2016 21:40:04 +0000 (UTC) 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 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;