netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.h.duyck@intel.com>
To: Alex Williamson <alex.williamson@redhat.com>,
	Yuval Mintz <Yuval.Mintz@qlogic.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	linux-pci <linux-pci@vger.kernel.org>,
	"e1000-devel@lists.sourceforge.net"
	<e1000-devel@lists.sourceforge.net>,
	"vaughan.cao@oracle.com" <vaughan.cao@oracle.com>,
	"jesse.brandeburg@intel.com" <jesse.brandeburg@intel.com>,
	Ethan Zhao <ethan.kernel@gmail.com>,
	Ethan Zhao <ethan.zhao@oracle.com>,
	"linux.nics@intel.com" <linux.nics@intel.com>,
	"konrad.wilk@oracle.com" <konrad.wilk@oracle.com>,
	"gleb@kernel.org" <gleb@kernel.org>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"boris.ostrovsky@oracle.com" <boris.ostrovsky@oracle.com>,
	netdev <netdev@vger.kernel.org>,
	"bruce.w.allan@intel.com" <bruce.w.allan@intel.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"john.ronciak@intel.com" <john.ronciak@intel.com>,
	"david.vrabel@citrix.com" <david.vrabel@citrix.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [PATCH 1/2 V3] PCI: introduce device assignment interface and refactory related code
Date: Mon, 21 Jul 2014 15:41:14 -0700	[thread overview]
Message-ID: <53CD970A.8020706@intel.com> (raw)
In-Reply-To: <1405953543.4463.19.camel@ul30vt.home>

On 07/21/2014 07:39 AM, Alex Williamson wrote:
> On Mon, 2014-07-21 at 14:11 +0000, Yuval Mintz wrote:
>>>>>>>>>> pci_iov_assign_device(),
>>>>>>>>>> pci_iov_deassign_device()
>>>>>>>>>>
>>>>>>>>>> along with the existed one
>>>>>>>>>>
>>>>>>>>>> pci_vfs_assigned()
>>>>>>>>>>
>>>>>>>>>> They construct the VFs assignment management interface,
>>>>>>> perhaps it's the right place to add some sort of mechanism in
>>>>>>> order to prevent module removal once one of its VFs is assigned.
>>>>>>> [e.g., incrementing module reference count]
>>>>>>>
>>>>>> On what module would the reference count be increased, the PF?
>>>>>> The entire "VF assigned" interface is a hack to work around poor
>>>>>> architectures like legacy KVM device assignment where there's no
>>>>>> proper device owner for the VF.  This is "fixed" by using VFIO
>>>>>> instead and hopefully deprecating legacy KVM assignment.  Thanks,
>>>>>
>>>>>   To explain what Alex said, in another word, if VMs access VF via
>>>>> VFIO driver, the owner of the device is VFIO, in this case, if you
>>>>> unload PF driver, you still need to unload VFIO first, then unload
>>>>> PF driver. but the PF driver knows how to notify the VFIO driver to unload.
>>>>>   But without VFIO like driver, for example some of current code
>>>>> will assign devcie (PF/VF) directly to KVM or XEN without driver in
>>>>> the middle. and the PF driver doesn't know how to unbind the assignment...
>>>>
>>>> I thought about perhaps incrementing the reference count of the PF's
>>>> module [i.e., the module supplying the driver for the PF] directly, so
>>>> THAT module won't be removable as long as the VF is assigned.
>>>>
>>>> Although I don't know whether the module is even accessible; Can you
>>>> derive a pointer to a module from a net_device struct?
>>>
>>> A VF is not necessarily a net device.  A pci_dev does have a physfn pointer
>>> though.
>>
>> I stand corrected.
>>
>> Is there anything inherently wrong about this approach, though?
> 
> What does incrementing the module reference on the PF driver accomplish?
> We can still unbind the PF device from the driver.  That's what this "VF
> used" flag is supposed to accomplish is preventing the PF from unbinding
> from the driver while VFs are in use, but as has been noted, it's a
> terrible hack.
> 

Keep in mind there are also use cases such as what occurs in igb/ixgbe
where the PF driver can be swapped out while the VFs are left in place.
 Nothing explicitly says we cannot unload the PF driver while the VFs
are assigned, we just cannot free the VFs or disable SR-IOV while they
are assigned.

In that scenario we just force the link down on the link state down on
the VFs while the PF is not present.  I'm not sure how many people make
use of the behavior but that is currently how we end up supporting it
for igb/ixgbe.

One approach would be to use a reference count for the SR-IOV itself.  I
know in the case of the igb/ixgbe drivers we use the assigned number of
VFs to determine if we can change the number of VFs allocated or not.  I
imagine you could probably just use the assigned count as a reference
count and if it is non-zero prevent SR-IOV from being disabled.

Thanks,

Alex


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

  parent reply	other threads:[~2014-07-21 22:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11 12:30 [PATCH 1/2 V3] PCI: introduce device assignment interface and refactory related code Ethan Zhao
2014-07-11 12:30 ` [PATCH 2/2 V3] PCI: implement VFs assignment reference counter Ethan Zhao
2014-07-11 12:42   ` Varka Bhadram
2014-07-11 12:51     ` Ethan Zhao
2014-07-11 12:56       ` Varka Bhadram
2014-07-11 13:01         ` Ethan Zhao
2014-07-11 13:13 ` [PATCH 1/2 V3] PCI: introduce device assignment interface and refactory related code Alex Williamson
2014-07-11 14:15   ` Alex Williamson
2014-07-11 14:37     ` Ethan Zhao
2014-07-11 14:54       ` Alex Williamson
2014-07-11 15:19         ` Ethan Zhao
2014-07-11 15:25           ` Alex Williamson
2014-07-11 16:06             ` Ethan Zhao
2014-07-11 16:13               ` Alex Williamson
2014-07-12  0:27                 ` Ethan Zhao
2014-07-12  0:40                 ` Ethan Zhao
2014-07-20 14:48     ` Yuval Mintz
2014-07-21  1:58       ` Alex Williamson
2014-07-21  3:17         ` Ethan Zhao
2014-07-21 13:17           ` Yuval Mintz
2014-07-21 14:01             ` Alex Williamson
2014-07-21 14:11               ` Yuval Mintz
2014-07-21 14:39                 ` Alex Williamson
2014-07-21 15:10                   ` Ethan Zhao
2014-07-21 22:41                   ` Alexander Duyck [this message]
2014-07-22  0:35                     ` Ethan Zhao
2014-07-21  3:28       ` Ethan Zhao
2014-07-11 14:20   ` Ethan Zhao
2014-07-11 14:50     ` Alex Williamson
2014-07-11 15:07       ` Ethan Zhao
2014-07-11 15:23         ` Alex Williamson
2014-07-11 16:02           ` Ethan Zhao
2014-07-21 22:29 ` Alexander Duyck
2014-07-22  0:38   ` Ethan Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53CD970A.8020706@intel.com \
    --to=alexander.h.duyck@intel.com \
    --cc=Yuval.Mintz@qlogic.com \
    --cc=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bruce.w.allan@intel.com \
    --cc=david.vrabel@citrix.com \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=ethan.kernel@gmail.com \
    --cc=ethan.zhao@oracle.com \
    --cc=gleb@kernel.org \
    --cc=jesse.brandeburg@intel.com \
    --cc=john.ronciak@intel.com \
    --cc=konrad.wilk@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux.nics@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vaughan.cao@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).