From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiVLP-0003Ki-Oq for qemu-devel@nongnu.org; Tue, 22 Mar 2016 19:04:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiVLM-0002mc-JM for qemu-devel@nongnu.org; Tue, 22 Mar 2016 19:04:11 -0400 Date: Tue, 22 Mar 2016 21:22:24 +1100 From: David Gibson Message-ID: <20160322102224.GH23586@voom.redhat.com> References: <1458546426-26222-1-git-send-email-aik@ozlabs.ru> <1458546426-26222-17-git-send-email-aik@ozlabs.ru> <20160322044559.GE23586@voom.redhat.com> <56F0E521.6060506@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7GFA+bvAY1vP//DC" Content-Disposition: inline In-Reply-To: <56F0E521.6060506@ozlabs.ru> Subject: Re: [Qemu-devel] [PATCH qemu v14 16/18] spapr_iommu, vfio, memory: Notify IOMMU about starting/stopping being used by VFIO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Alex Williamson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org --7GFA+bvAY1vP//DC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 22, 2016 at 05:24:33PM +1100, Alexey Kardashevskiy wrote: > On 03/22/2016 03:45 PM, David Gibson wrote: > >On Mon, Mar 21, 2016 at 06:47:04PM +1100, Alexey Kardashevskiy wrote: > >>The sPAPR TCE tables manage 2 copies when VFIO is using an IOMMU - > >>a guest view of the table and a hardware TCE table. If there is no VFIO > >>presense in the address space, then just the guest view is used, if > >>this is the case, it is allocated in the KVM. However since there is no > >>support yet for VFIO in KVM TCE hypercalls, when we start using VFIO, > >>we need to move the guest view from KVM to the userspace; and we need > >>to do this for every IOMMU on a bus with VFIO devices. > >> > >>This adds vfio_start/vfio_stop callbacks in MemoryRegionIOMMUOps to > >>notifiy IOMMU about changing environment so it can reallocate the table > >>to/from KVM or (when available) hook the IOMMU groups with the logical > >>bus (LIOBN) in the KVM. > >> > >>This removes explicit spapr_tce_set_need_vfio() call from PCI hotplug > >>path as the new callbacks do this better - they notify IOMMU at > >>the exact moment when the configuration is changed, and this also > >>includes the case of PCI hot unplug. > >> > >>TODO: split into 2 or 3 patches, per maintainership area. > >> > >>Signed-off-by: Alexey Kardashevskiy > > > >I'm finding this one much easier to follow than the previous revision. > > > >>--- > >> hw/ppc/spapr_iommu.c | 12 ++++++++++++ > >> hw/ppc/spapr_pci.c | 6 ------ > >> hw/vfio/common.c | 9 +++++++++ > >> include/exec/memory.h | 4 ++++ > >> 4 files changed, 25 insertions(+), 6 deletions(-) > >> > >>diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c > >>index 6dc3c45..702075d 100644 > >>--- a/hw/ppc/spapr_iommu.c > >>+++ b/hw/ppc/spapr_iommu.c > >>@@ -151,6 +151,16 @@ static uint64_t spapr_tce_get_page_sizes(MemoryReg= ion *iommu) > >> return 1ULL << tcet->page_shift; > >> } > >> > >>+static void spapr_tce_vfio_start(MemoryRegion *iommu) > >>+{ > >>+ spapr_tce_set_need_vfio(container_of(iommu, sPAPRTCETable, iommu),= true); > >>+} > >>+ > >>+static void spapr_tce_vfio_stop(MemoryRegion *iommu) > >>+{ > >>+ spapr_tce_set_need_vfio(container_of(iommu, sPAPRTCETable, iommu),= false); > >>+} > > > >Wonder if a single callback which takes a boolean might be a little > >less clunky. >=20 > I have a feeling that at least once I was asked to do the opposite and now > we have take_ownership/release_ownership. This does not seem to be much > different and the existing names are more self-documenting than the previ= ous > vfio_notify() or whatever name I could think of. Ok, leave it as is. --=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 --7GFA+bvAY1vP//DC Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW8RzgAAoJEGw4ysog2bOSd5AQAJFbYykdfl6/BkWuUI81w3Li 6py8Kw91NF4lILwjy2ix3RG7WmZ+2Dz3OfdKRIAfZRPKFA0HBshqScbfWK11lfVR mwG7bE65PyVHbENJvOVMhQxmiEUW9YvXkKV4nYASyv5T2oU94qfD8ZrtjTF9La7c u3wyTDHLO0TYkt+8X0q0ryWyiKEz/IUw9+FSkXquBkVNsF0R5yWq+W7m7q1eESjq qVFn3po8Eqp+jzuc7ddTM9yzmZAFKN9LHeIixl/+5fpygzSJ4gtJIs1slOBlxXxP gnIItlVcm2YutmkRdPQTtLAaUx10wXJcAKYE3HBTqlvFZ2E2S5j26qYBzuTt+VG3 4M6abq/lY9WGGRiciPnrEiKj8Bde/+/31v696wk2NWZjmImiW8J8olhpg2YBaSJ8 eWCxw9no9mTxy2pXDf3Ei6etoga4VwKMCk7tP9IBRUO6Vp4/oqAu0fj7HDBmrcEf DL2Hb1ExrF/+kH9tU1aCngJeFz2R39nKUHxxEGdKUUWhH8JsNRHaAnTYSOymDf1n 81O/jp00w6qouJwes9VmaABJaEg6MZ/l2Kg/6FzpR04HWGwdOZL/NYZmQK59S8Rt gMUcbdnysNJbJJd5d+Jzi1voHjfc4JEuk3f1RJW9KU0pVkaHf4hSThwRBdFa5hs9 n2YeeRNoJKRqihAvyTID =Hqk8 -----END PGP SIGNATURE----- --7GFA+bvAY1vP//DC--