From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bh8pW-0006K6-Js for qemu-devel@nongnu.org; Tue, 06 Sep 2016 01:21:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bh8pV-000097-3f for qemu-devel@nongnu.org; Tue, 06 Sep 2016 01:21:54 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:56538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bh8pU-00007z-0B for qemu-devel@nongnu.org; Tue, 06 Sep 2016 01:21:53 -0400 Date: Tue, 6 Sep 2016 15:12:26 +1000 From: David Gibson Message-ID: <20160906051226.GC16479@voom.fritz.box> References: <1473060081-17835-1-git-send-email-peterx@redhat.com> <1473060081-17835-3-git-send-email-peterx@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ctP54qlpMx3WjD+/" Content-Disposition: inline In-Reply-To: <1473060081-17835-3-git-send-email-peterx@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/3] memory: add iommu_notify_flag List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu 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 --ctP54qlpMx3WjD+/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 05, 2016 at 03:21:20PM +0800, Peter Xu wrote: > When there are active IOMMU notify registers, the iommu_notify_flag will > cache existing notify flag. When notifiers are triggered, flag will be > checked against the cached result. >=20 > Signed-off-by: Peter Xu > --- > hw/ppc/spapr_iommu.c | 2 +- > hw/s390x/s390-pci-inst.c | 2 +- > include/exec/memory.h | 6 +++++- > memory.c | 6 +++++- > 4 files changed, 12 insertions(+), 4 deletions(-) >=20 > diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c > index 09660fc..14b1f00 100644 > --- a/hw/ppc/spapr_iommu.c > +++ b/hw/ppc/spapr_iommu.c > @@ -411,7 +411,7 @@ static target_ulong put_tce_emu(sPAPRTCETable *tcet, = target_ulong ioba, > entry.translated_addr =3D tce & page_mask; > entry.addr_mask =3D ~page_mask; > entry.perm =3D spapr_tce_iommu_access_flags(tce); > - memory_region_notify_iommu(&tcet->iommu, entry); > + memory_region_notify_iommu(&tcet->iommu, entry, IOMMU_RW); > =20 > return H_SUCCESS; > } > diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c > index f069b11..29ef345 100644 > --- a/hw/s390x/s390-pci-inst.c > +++ b/hw/s390x/s390-pci-inst.c > @@ -616,7 +616,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint= 8_t r2) > goto out; > } > =20 > - memory_region_notify_iommu(mr, entry); > + memory_region_notify_iommu(mr, entry, IOMMU_RW); > start +=3D entry.addr_mask + 1; > } > =20 > diff --git a/include/exec/memory.h b/include/exec/memory.h > index 6c16a86..c67b3da 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -57,6 +57,7 @@ typedef enum { > IOMMU_RO =3D 1, > IOMMU_WO =3D 2, > IOMMU_RW =3D 3, > + IOMMU_ACCESS_INVALID =3D 4, > } IOMMUAccessFlags; > =20 > struct IOMMUTLBEntry { > @@ -202,6 +203,7 @@ struct MemoryRegion { > unsigned ioeventfd_nb; > MemoryRegionIoeventfd *ioeventfds; > NotifierList iommu_notify; > + IOMMUAccessFlags iommu_notify_flag; > }; > =20 > /** > @@ -611,9 +613,11 @@ uint64_t memory_region_iommu_get_min_page_size(Memor= yRegion *mr); > * @entry: the new entry in the IOMMU translation table. The entry > * replaces all old entries for the same virtual I/O address ran= ge. > * Deleted entries have .@perm =3D=3D 0. > + * @flag: type of IOMMU notification (IOMMU_RW, IOMMU_NONE) This makes no sense. The overall type of the notifier is already noted in register / notify_start. The permission on this specific mapping is already included in the IOMMUTLBEntry. > */ > void memory_region_notify_iommu(MemoryRegion *mr, > - IOMMUTLBEntry entry); > + IOMMUTLBEntry entry, > + IOMMUAccessFlags flag); > =20 > /** > * memory_region_register_iommu_notifier: register a notifier for change= s to > diff --git a/memory.c b/memory.c > index 747a9ec..5b50d15 100644 > --- a/memory.c > +++ b/memory.c > @@ -1418,6 +1418,7 @@ void memory_region_init_iommu(MemoryRegion *mr, > memory_region_init(mr, owner, name, size); > mr->iommu_ops =3D ops, > mr->terminates =3D true; /* then re-forwards */ > + mr->iommu_notify_flag =3D IOMMU_ACCESS_INVALID; > notifier_list_init(&mr->iommu_notify); > } > =20 > @@ -1520,6 +1521,7 @@ void memory_region_register_iommu_notifier(MemoryRe= gion *mr, Notifier *n, > if (mr->iommu_ops->notify_started && > QLIST_EMPTY(&mr->iommu_notify.notifiers)) { > mr->iommu_ops->notify_started(mr, flag); > + mr->iommu_notify_flag =3D flag; > } > notifier_list_add(&mr->iommu_notify, n); > } > @@ -1560,13 +1562,15 @@ void memory_region_unregister_iommu_notifier(Memo= ryRegion *mr, Notifier *n) > if (mr->iommu_ops->notify_stopped && > QLIST_EMPTY(&mr->iommu_notify.notifiers)) { > mr->iommu_ops->notify_stopped(mr); > + mr->iommu_notify_flag =3D IOMMU_ACCESS_INVALID; > } > } > =20 > void memory_region_notify_iommu(MemoryRegion *mr, > - IOMMUTLBEntry entry) > + IOMMUTLBEntry entry, IOMMUAccessFlags fl= ag) > { > assert(memory_region_is_iommu(mr)); > + assert(flag =3D=3D mr->iommu_notify_flag); > notifier_list_notify(&mr->iommu_notify, &entry); > } > =20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --ctP54qlpMx3WjD+/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJXzlA6AAoJEGw4ysog2bOSEx4P/0YM/GKF+/1+ZN8acTB8JWj8 WfwUP26c7oVye7rL97fRBmJ2mvBc5+WHuxH5BNAp/vbydO114PtOhsUvqHKTD4bA 6DD/CyJhmWsgPAmQ6QL6eYv/kbeMKSBufsOjIomZkYmqNkgf1N/tdg45C4RUDd30 guchxcQjRUCheTklH85ToIcj7RYFNz27kXbosTv7zJ92MxLg/BUJcSVqJm5QZD0b p68a+B2WRTyx5Ilx4ZSwhbCUO7Eg0u6EO4knzmdbaXEnvlkaKE/yllY8rxwnuCn+ cmt8bcUMtFjjpVwzIVpfCKZtKs7L7p3cMTRr+8K50SpDvYBQKrrpvodDIxLnO1L9 dypoEeAVFs6N6hW1eFoBBC6NbChFjCcfoRReqpahEQy0DfIekSCsFcojKnHxfxIE 0sIqtp1+FP3LVA2+m8YajAgOc/4L/Qtt4tVNxZqhk8ug5Pigu7p5UDI8PfG7sbEW 2E8eUCu6zXkhIf8tEKe64PscJxSCWk65+2Es/wQSHoZHjaBAOE7OxBIymaZfoGFV r2//DqS+gwxIc07DgET4yr4HJlPTI6kXfAQnsQk4N0SR43+TdMPOdoNtLeeVQUGx 3pd2oeP8Uqa54M/CFed0woK36Cn+kKaOA5t7McZxVkK/Q6t0dDKURtE337Q0HgfS YDY6LaiHte8k5nxIm8Sy =SXGd -----END PGP SIGNATURE----- --ctP54qlpMx3WjD+/--