All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jag Raman <jag.raman@oracle.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: "eduardo@habkost.net" <eduardo@habkost.net>,
	"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
	"thuth@redhat.com" <thuth@redhat.com>,
	"John Johnson" <john.g.johnson@oracle.com>,
	"berrange@redhat.com" <berrange@redhat.com>,
	"bleal@redhat.com" <bleal@redhat.com>,
	"john.levon@nutanix.com" <john.levon@nutanix.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"armbru@redhat.com" <armbru@redhat.com>,
	"quintela@redhat.com" <quintela@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	"thanos.makatos@nutanix.com" <thanos.makatos@nutanix.com>,
	"Kanth Ghatraju" <kanth.ghatraju@oracle.com>,
	"marcandre.lureau@redhat.com" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"eblake@redhat.com" <eblake@redhat.com>,
	"dgilbert@redhat.com" <dgilbert@redhat.com>
Subject: Re: [PATCH v8 13/17] vfio-user: handle DMA mappings
Date: Tue, 26 Apr 2022 19:53:14 +0000	[thread overview]
Message-ID: <80C58234-8E8A-4779-90FD-5F825B95F62A@oracle.com> (raw)
In-Reply-To: <C75E641A-1654-440C-93BF-3AE223C60CFC@oracle.com>



> On Apr 25, 2022, at 1:34 PM, Jag Raman <jag.raman@oracle.com> wrote:
> 
> 
> 
>> On Apr 25, 2022, at 5:56 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>> 
>> On Tue, Apr 19, 2022 at 04:44:18PM -0400, Jagannathan Raman wrote:
>>> +static void dma_unregister(vfu_ctx_t *vfu_ctx, vfu_dma_info_t *info)
>>> +{
>>> + VfuObject *o = vfu_get_private(vfu_ctx);
>>> + AddressSpace *dma_as = NULL;
>>> + MemoryRegion *mr = NULL;
>>> + ram_addr_t offset;
>>> +
>>> + mr = memory_region_from_host(info->vaddr, &offset);
>>> + if (!mr) {
>>> + return;
>>> + }
>>> +
>>> + dma_as = pci_device_iommu_address_space(o->pci_dev);
>>> +
>>> + memory_region_del_subregion(dma_as->root, mr);
>>> +
>>> + object_unparent((OBJECT(mr)));
>> 
>> Where is obj->parent set?
> 
> Yeah, it should be object_unref().

I think object_unparent() is the appropriate way to finalize the
MemoryRegion in this case.

‘mr’ is an owner-less MemoryRegion created by dma_register(). owner-less
MemoryRegions initialized using memory_region_init* functions are children
of the “/unattached” object.

The parent is set by dma_register() -> memory_region_init_ram_ptr() ->
memory_region_init() -> memory_region_do_init() ->
object_property_add_child() -> object_property_try_add_child().

Thank you!
--
Jag

> 
> Thank you!
> --
> Jag
> 
>> 
>> If it is not set then this call is a nop and mr is not freed:
>> 
>> void object_unparent(Object *obj)
>> {
>> if (obj->parent) {
>> object_property_del_child(obj->parent, obj);
>> }
>> }


  reply	other threads:[~2022-04-26 19:54 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-19 20:44 [PATCH v8 00/17] vfio-user server in QEMU Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 01/17] tests/avocado: Specify target VM argument to helper routines Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 02/17] qdev: unplug blocker for devices Jagannathan Raman
2022-04-21 14:55   ` Markus Armbruster
2022-04-21 17:49     ` Jag Raman
2022-04-22  5:18       ` Markus Armbruster
2022-04-22 14:18         ` Jag Raman
2022-04-19 20:44 ` [PATCH v8 03/17] remote/machine: add HotplugHandler for remote machine Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 04/17] remote/machine: add vfio-user property Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 05/17] configure: require cmake 3.19 or newer Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 06/17] vfio-user: build library Jagannathan Raman
2022-04-25  8:22   ` Stefan Hajnoczi
2022-04-19 20:44 ` [PATCH v8 07/17] vfio-user: define vfio-user-server object Jagannathan Raman
2022-04-25  8:27   ` Stefan Hajnoczi
2022-04-19 20:44 ` [PATCH v8 08/17] vfio-user: instantiate vfio-user context Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 09/17] vfio-user: find and init PCI device Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 10/17] vfio-user: run vfio-user context Jagannathan Raman
2022-04-21 14:59   ` Markus Armbruster
2022-04-21 17:52     ` Jag Raman
2022-04-22  5:14       ` Markus Armbruster
2022-04-22 14:18         ` Jag Raman
2022-04-19 20:44 ` [PATCH v8 11/17] vfio-user: handle PCI config space accesses Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 12/17] vfio-user: IOMMU support for remote device Jagannathan Raman
2022-04-20 11:15   ` Jag Raman
2022-04-25  9:38     ` Stefan Hajnoczi
2022-04-25 17:30       ` Jag Raman
2022-04-28  9:47         ` Stefan Hajnoczi
2022-04-25  9:31   ` Stefan Hajnoczi
2022-04-25 17:26     ` Jag Raman
2022-04-19 20:44 ` [PATCH v8 13/17] vfio-user: handle DMA mappings Jagannathan Raman
2022-04-25  9:56   ` Stefan Hajnoczi
2022-04-25 17:34     ` Jag Raman
2022-04-26 19:53       ` Jag Raman [this message]
2022-04-19 20:44 ` [PATCH v8 14/17] vfio-user: handle PCI BAR accesses Jagannathan Raman
2022-04-25 10:05   ` Stefan Hajnoczi
2022-04-25 17:36     ` Jag Raman
2022-04-19 20:44 ` [PATCH v8 15/17] vfio-user: handle device interrupts Jagannathan Raman
2022-04-25 10:27   ` Stefan Hajnoczi
2022-04-25 17:40     ` Jag Raman
2022-04-28  9:54       ` Stefan Hajnoczi
2022-05-05 16:22         ` Alex Williamson
2022-04-19 20:44 ` [PATCH v8 16/17] vfio-user: handle reset of remote device Jagannathan Raman
2022-04-25 10:27   ` Stefan Hajnoczi
2022-04-19 20:44 ` [PATCH v8 17/17] vfio-user: avocado tests for vfio-user Jagannathan Raman
2022-04-25 10:32 ` [PATCH v8 00/17] vfio-user server in QEMU Stefan Hajnoczi
2022-04-25 17:40   ` Jag Raman

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=80C58234-8E8A-4779-90FD-5F825B95F62A@oracle.com \
    --to=jag.raman@oracle.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=bleal@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=elena.ufimtseva@oracle.com \
    --cc=f4bug@amsat.org \
    --cc=john.g.johnson@oracle.com \
    --cc=john.levon@nutanix.com \
    --cc=kanth.ghatraju@oracle.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=thanos.makatos@nutanix.com \
    --cc=thuth@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.