From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bk4xB-0007R1-F5 for qemu-devel@nongnu.org; Wed, 14 Sep 2016 03:49:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bk4x8-0001tc-AD for qemu-devel@nongnu.org; Wed, 14 Sep 2016 03:49:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bk4x8-0001tP-4Y for qemu-devel@nongnu.org; Wed, 14 Sep 2016 03:49:54 -0400 Date: Wed, 14 Sep 2016 15:49:41 +0800 From: Peter Xu Message-ID: <20160914074941.GO3776@pxdev.xzpeter.org> References: <1473389864-19694-1-git-send-email-peterx@redhat.com> <1473389864-19694-3-git-send-email-peterx@redhat.com> <20160914055528.GM15077@voom.fritz.box> <20160914071243.GM3776@pxdev.xzpeter.org> <20160914072240.GP15077@voom.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160914072240.GP15077@voom.fritz.box> Subject: Re: [Qemu-devel] [PATCH v4 2/3] memory: introduce IOMMUOps.notify_flag_changed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, vkaplans@redhat.com, alex.williamson@redhat.com, wexu@redhat.com, pbonzini@redhat.com, cornelia.huck@de.ibm.com, dgibson@redhat.com On Wed, Sep 14, 2016 at 05:22:40PM +1000, David Gibson wrote: > On Wed, Sep 14, 2016 at 03:12:43PM +0800, Peter Xu wrote: > > On Wed, Sep 14, 2016 at 03:55:28PM +1000, David Gibson wrote: > > > > [...] > > > > > > -static void vtd_iommu_notify_started(MemoryRegion *iommu) > > > > +static void vtd_iommu_notify_flag_changed(MemoryRegion *iommu, > > > > + IOMMUNotifierFlag old, > > > > + IOMMUNotifierFlag new) > > > > { > > > > VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu); > > > > > > Shouldn't this have a sanity check that the new flags doesn't include > > > MAP actions? > > > > See your r-b for patch 3, thanks! So skipping this one. > > > > [...] > > > > > > +static void spapr_tce_notify_flag_changed(MemoryRegion *iommu, > > > > + IOMMUNotifierFlag old, > > > > + IOMMUNotifierFlag new) > > > > +{ > > > > + if (old == IOMMU_NOTIFIER_NONE && new == IOMMU_NOTIFIER_ALL) { > > > > + spapr_tce_notify_started(iommu); > > > > + } else if (old == IOMMU_NOTIFIER_ALL && new == IOMMU_NOTIFIER_NONE) { > > > > + spapr_tce_notify_stopped(iommu); > > > > + } > > > > > > This is wrong. We need to do the notify_start and stop actions if > > > *any* bits are set in the new/old flags, not just if all of them are > > > set. > > > > Power should need both, right? I can switch all > > > > "== IOMMU_NOTIFIER_ALL" > > > > into: > > > > "!= IOMMU_NOTIFIER_NONE" > > Yes, that should be right. > > > in the next version if you like, but AFAICT they are totally the > > same. > > Again, only if you assume things about how the notifiers will be used, > which is not a good look when designing an interface. This should not be related to the interface at all? I was based on the assumption that "Power cannot support either one of MAP/UNMAP, but only if both exist". To be more specific, we possibly can have this at the beginning of flags_changed(): assert(old == IOMMU_NOTIFIER_NONE || old == IOMMU_NOTIFIER_ALL); assert(new == IOMMU_NOTIFIER_NONE || new == IOMMU_NOTIFIER_ALL); To make sure nothing will go wrong. Thanks, -- peterx