From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9Ucn-0002eA-7A for qemu-devel@nongnu.org; Mon, 08 Oct 2018 08:27:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g9Ucm-00030C-BM for qemu-devel@nongnu.org; Mon, 08 Oct 2018 08:27:01 -0400 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:34146) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g9Ucm-0002zd-4L for qemu-devel@nongnu.org; Mon, 08 Oct 2018 08:27:00 -0400 Received: by mail-ot1-x344.google.com with SMTP id i12-v6so19451954otl.1 for ; Mon, 08 Oct 2018 05:27:00 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <0ed94c1e-4c58-d1ac-6ceb-c851cc089cec@redhat.com> References: <1538579266-8389-1-git-send-email-edgar.iglesias@gmail.com> <1538579266-8389-7-git-send-email-edgar.iglesias@gmail.com> <0ed94c1e-4c58-d1ac-6ceb-c851cc089cec@redhat.com> From: Peter Maydell Date: Mon, 8 Oct 2018 13:26:38 +0100 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v1 06/12] net: cadence_gem: Add support for selecting the DMA MemoryRegion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Cc: "Edgar E. Iglesias" , QEMU Developers , qemu-arm , Alistair Francis , figlesia@xilinx.com, Stefano Stabellini , Edgar Iglesias , Sai Pavan Boddu , Francisco Iglesias , Richard Henderson , KONRAD Frederic On 6 October 2018 at 00:14, Philippe Mathieu-Daud=C3=A9 = wrote: > Hi Edgar, > > On 03/10/2018 17:07, Edgar E. Iglesias wrote: >> From: "Edgar E. Iglesias" >> >> Add support for selecting the Memory Region that the GEM >> will do DMA to. >> @@ -1500,6 +1506,13 @@ static void gem_realize(DeviceState *dev, Error *= *errp) >> CadenceGEMState *s =3D CADENCE_GEM(dev); >> int i; >> >> + if (s->dma_mr) { >> + s->dma_as =3D g_malloc0(sizeof(AddressSpace)); >> + address_space_init(s->dma_as, s->dma_mr, NULL); >> + } else { >> + s->dma_as =3D &address_space_memory; >> + } > > This is not the first time I see this if() block. > > Should we consider refactor it? Given that there are only three users of the device in the tree, I think the nicest cleanup would be to make those callers pass in a suitable MemoryRegion (which could just be the system memory MR), and make the "dma" property of the device mandatory to set. We can do that as followup, though. thanks -- PMM