[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [RFC PATCH qemu 2/5] spapr-iommu: Subclass TYPE_IOMMU_MEM
From: |
Alexey Kardashevskiy |
Subject: |
Re: [Qemu-ppc] [RFC PATCH qemu 2/5] spapr-iommu: Subclass TYPE_IOMMU_MEMORY_REGION |
Date: |
Fri, 31 Mar 2017 22:47:38 +1100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 31/03/17 00:00, Paolo Bonzini wrote:
>
>
> On 30/03/2017 14:47, Alexey Kardashevskiy wrote:
>> +static int spapr_tce_get_fd(IOMMUMemoryRegion *iommu)
>> +{
>> + sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu);
>> +
>> + return tcet->fd;
>> +}
>> +
>> static int spapr_tce_table_post_load(void *opaque, int version_id)
>> {
>> sPAPRTCETable *tcet = SPAPR_TCE_TABLE(opaque);
>> @@ -266,7 +273,7 @@ static int spapr_tce_table_realize(DeviceState *dev)
>> memory_region_init(&tcet->root, tcetobj, tmp, UINT64_MAX);
>>
>> snprintf(tmp, sizeof(tmp), "tce-iommu-%x", tcet->liobn);
>> - memory_region_init_iommu_type(TYPE_IOMMU_MEMORY_REGION,
>> + memory_region_init_iommu_type(TYPE_SPAPR_IOMMU_MEMORY_REGION,
>> &tcet->iommu, tcetobj, &spapr_iommu_ops,
>> tmp, 0);
>>
>> @@ -634,9 +641,25 @@ static TypeInfo spapr_tce_table_info = {
>> .class_init = spapr_tce_table_class_init,
>> };
>>
>> +static void spapr_iommu_memory_region_class_init(ObjectClass *k, void *data)
>> +{
>> + sPAPRIOMMUMemoryRegionClass *smrc = SPAPR_IOMMU_MEMORY_REGION_CLASS(k);
>> +
>> + smrc->get_fd = spapr_tce_get_fd;
>> +}
>> +
>
> You don't even need the virtual function. Rather, make spapr_tce_get_fd
> public and give it a sPAPRTCETable argument. Then vfio_spapr_notify_kvm
> can use SPAPR_IOMMU_MEMORY_REGION(iommumr).
Well, if I make spapr_tce_get_fd() public, vfio_spapr_notify_kvm() could
just take MemoryRegion and cast it to sPAPRTCETable without all these
dances with MemoryRegion, IOMMUMemoryRegion, what do I miss here? I have
made a big patch with IOMMUMemoryRegion though, post it?
--
Alexey