From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39934 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934161AbdAHXpQ (ORCPT ); Sun, 8 Jan 2017 18:45:16 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id v08NiGaE027556 for ; Sun, 8 Jan 2017 18:45:16 -0500 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141]) by mx0b-001b2d01.pphosted.com with ESMTP id 27unddqump-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sun, 08 Jan 2017 18:45:15 -0500 Received: from localhost by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Jan 2017 09:45:12 +1000 Date: Mon, 9 Jan 2017 10:45:10 +1100 From: Gavin Shan To: Emil Tantilov Cc: linux-pci@vger.kernel.org, intel-wired-lan@lists.osuosl.org, alexander.h.duyck@intel.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] PCI: lock each enable/disable num_vfs operation in sysfs Reply-To: Gavin Shan References: <20170106215908.20736.34632.stgit@localhost6.localdomain6> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <20170106215908.20736.34632.stgit@localhost6.localdomain6> Message-Id: <20170108234510.GA14008@gwshan> Sender: linux-pci-owner@vger.kernel.org List-ID: On Fri, Jan 06, 2017 at 01:59:08PM -0800, Emil Tantilov wrote: >Enabling/disabling SRIOV via sysfs by echo-ing multiple values >simultaneously: > >echo 63 > /sys/class/net/ethX/device/sriov_numvfs& >echo 63 > /sys/class/net/ethX/device/sriov_numvfs > >sleep 5 > >echo 0 > /sys/class/net/ethX/device/sriov_numvfs& >echo 0 > /sys/class/net/ethX/device/sriov_numvfs > >Results in the following bug: > >kernel BUG at drivers/pci/iov.c:495! >invalid opcode: 0000 [#1] SMP >CPU: 1 PID: 8050 Comm: bash Tainted: G W 4.9.0-rc7-net-next #2092 >RIP: 0010:[] > [] pci_iov_release+0x57/0x60 > >Call Trace: > [] pci_release_dev+0x26/0x70 > [] device_release+0x3e/0xb0 > [] kobject_cleanup+0x67/0x180 > [] kobject_put+0x2d/0x60 > [] put_device+0x17/0x20 > [] pci_dev_put+0x1a/0x20 > [] pci_get_dev_by_id+0x5b/0x90 > [] pci_get_subsys+0x35/0x40 > [] pci_get_device+0x18/0x20 > [] pci_get_domain_bus_and_slot+0x2b/0x60 > [] pci_iov_remove_virtfn+0x57/0x180 > [] pci_disable_sriov+0x65/0x140 > [] ixgbe_disable_sriov+0xc7/0x1d0 [ixgbe] > [] ixgbe_pci_sriov_configure+0x3d/0x170 [ixgbe] > [] sriov_numvfs_store+0xdc/0x130 >... >RIP [] pci_iov_release+0x57/0x60 > >Use the existing mutex lock to protect each enable/disable operation. > >-v2: move the existing lock from protecting the config of the IOV bus >to protecting the writes to sriov_numvfs in sysfs without maintaining >a "locked" version of pci_iov_add/remove_virtfn(). >As suggested by Gavin Shan > >CC: Alexander Duyck >Signed-off-by: Emil Tantilov >--- Reviewed-by: Gavin Shan