All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jike Song <jike.song@intel.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Kirti Wankhede <kwankhede@nvidia.com>,
	pbonzini@redhat.com, guangrong.xiao@linux.intel.com,
	kevin.tian@intel.com, cjia@nvidia.com, kvm@vger.kernel.org
Subject: Re: [v7 2/3] vfio: support notifier chain in vfio_group
Date: Wed, 23 Nov 2016 11:20:55 +0800	[thread overview]
Message-ID: <58350B17.7070406@intel.com> (raw)
In-Reply-To: <20161122075052.52a931ba@t450s.home>

On 11/22/2016 10:50 PM, Alex Williamson wrote:
> On Tue, 22 Nov 2016 20:09:32 +0530
> Kirti Wankhede <kwankhede@nvidia.com> wrote:
> 
>> On 11/22/2016 7:32 PM, Alex Williamson wrote:
>>> On Tue, 22 Nov 2016 19:05:16 +0530
>>> Kirti Wankhede <kwankhede@nvidia.com> wrote:
>>>   
>>>> On 11/22/2016 11:39 AM, Jike Song wrote:  
>>
>> <snip>
>>
>>>>>  /* events for VFIO_IOMMU_NOTIFY */
>>>>>  #define VFIO_IOMMU_NOTIFY_DMA_UNMAP	BIT(0)
>>>>>  
>>>>> +/* events for VFIO_GROUP_NOTIFY */
>>>>> +#define VFIO_GROUP_NOTIFY_SET_KVM	BIT(0)
>>>>> +
>>>>> +struct kvm;
>>>>> +extern void vfio_group_set_kvm(struct vfio_group *group, struct kvm *kvm);
>>>>>      
>>>>
>>>> If I understand correctly, notifier for backend iommu driver and
>>>> notifier for group should be registered with different notifier blocks,
>>>> as per your current implementation:
>>>>
>>>> unsigned long iommu_event = VFIO_IOMMU_NOTIFY_DMA_UNMAP;
>>>> struct notifier_block iommu_nb;
>>>>
>>>> iommu_nb.notifier_call = vfio_iommu_notifier_cb;
>>>> vfio_register_notifier(dev, VFIO_IOMMU_NOTIFY, &iommu_event, &iommu_nb);
>>>>
>>>>
>>>> unsigned long group_event = VFIO_GROUP_NOTIFY_SET_KVM;
>>>> struct notifier_block group_nb;
>>>>
>>>> group_nb.notifier_call = vfio_group_notifier_cb;
>>>> vfio_register_notifier(dev, VFIO_GROUP_NOTIFY, &group_event, &group_nb);
>>>>
>>>> Then what is the use of having 'events' bitmask as input argument?
>>>>
>>>> Its clear that caller should set:
>>>> -  VFIO_IOMMU_NOTIFY_DMA_UNMAP when vfio_notify_type_t is VFIO_IOMMU_NOTIFY
>>>> -  VFIO_GROUP_NOTIFY_SET_KVM when vfio_notify_type_t is VFIO_GROUP_NOTIFY
>>>>
>>>> Notifier action could be a integer as earlier and indexing of action
>>>> would be different for both notifiers.
>>>>
>>>> Then caller don't have to sent event bitmask, for caller it would look like:
>>>>
>>>> struct notifier_block iommu_nb;
>>>>
>>>> iommu_nb.notifier_call = vfio_iommu_notifier_cb;
>>>> vfio_register_notifier(dev, VFIO_IOMMU_NOTIFY, &iommu_nb);
>>>>
>>>>
>>>> struct notifier_block group_nb;
>>>>
>>>> group_nb.notifier_call = vfio_group_notifier_cb;
>>>> vfio_register_notifier(dev, VFIO_GROUP_NOTIFY, &group_nb);  
>>>
>>> If we did that then we'd effectively need to add a new notifier any
>>> time we want a new signal because the vendor driver would have no
>>> ability to query the notifications available.  For instance, say we
>>> added VFIO_IOMMU_NOTIFY_SET_FOO and a vendor driver was dependent on
>>> that and would either refuse to work or would take a backup path if
>>> that notification isn't available.  How could it operate in your
>>> proposal?  By passing a bitmask of events, the vendor driver can
>>> specify the set of required events and see which event signaling is
>>> unavailable.  The purpose of using a bitmask and passing the set of
>>> required bits on registration is to support future expansion.  Thanks,
>>>   
>>
>> If we add VFIO_IOMMU_NOTIFY_SET_FOO in future, we have to define this
>> action in include/linux/vfio.h
>>
>>  #define VFIO_IOMMU_NOTIFY_DMA_UNMAP    (1)
>> +#define VFIO_IOMMU_NOTIFY_SET_FOO      (2)
>>
>> Vendor driver anyways need to be compiled against the kernel to which
>> its going to run. So vendor driver could use conditional directive:
>>
>> #if defined(VFIO_IOMMU_NOTIFY_SET_FOO)
>>     /* foo signal available*/
>> #else
>>     /* foo signal not available*/
>> #endif
> 
> No, the vendor driver is not necessarily compiled against the given
> kernel.  We can also have different backends in vfio, what if we have
> IOMMU_SET_FOO supported by type1 and IOMMU_SET_BAR supported by spapr,
> the vendor driver might only support one of these and can't tell at
> compile time which is active.  Thanks,

Yes, if we rely on macros only, driver not built against current kernel
won't work correctly. But have IOMMU backends considered, seems that we
don't differentiating them, having only one VFIO_IOMMU_NOTIFY?

--
Thanks,
Jike

  reply	other threads:[~2016-11-23  3:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-22  6:09 [v7 0/3] plumb kvm/vfio to notify kvm:group attach/detach Jike Song
2016-11-22  6:09 ` [v7 1/3] vfio: vfio_register_notifier: classify iommu notifier Jike Song
2016-11-23  8:50   ` [UPDATE v7 " Jike Song
2016-11-22  6:09 ` [v7 2/3] vfio: support notifier chain in vfio_group Jike Song
2016-11-22 13:35   ` Kirti Wankhede
2016-11-22 14:02     ` Alex Williamson
2016-11-22 14:39       ` Kirti Wankhede
2016-11-22 14:50         ` Alex Williamson
2016-11-23  3:20           ` Jike Song [this message]
2016-11-23  4:52             ` Kirti Wankhede
2016-11-23  5:56               ` Alex Williamson
2016-11-23  6:29                 ` Jike Song
2016-11-23  6:33                   ` Tian, Kevin
2016-11-23  7:53                     ` Jike Song
2016-11-23 12:45                       ` Alex Williamson
2016-11-22  6:09 ` [v7 3/3] kvm: set/clear kvm to/from vfio_group when group add/delete Jike Song
2016-11-30 17:02   ` Alex Williamson
2016-12-01  2:47     ` Jike Song
2016-11-29  3:02 ` [v7 0/3] plumb kvm/vfio to notify kvm:group attach/detach Jike Song
2016-11-30 17:06   ` Alex Williamson
2016-12-01  2:27     ` Jike Song
2016-12-01  4:42       ` Kirti Wankhede

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=58350B17.7070406@intel.com \
    --to=jike.song@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=cjia@nvidia.com \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.