qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v8 13/17] vfio-user: handle DMA mappings


From: Jag Raman
Subject: Re: [PATCH v8 13/17] vfio-user: handle DMA mappings
Date: Tue, 26 Apr 2022 19:53:14 +0000


> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]