>-----Original Message----- >From: Cédric Le Goater <c...@redhat.com> >Sent: Friday, October 27, 2023 10:26 PM >Subject: Re: [PATCH v3 08/37] vfio/container: Switch to dma_map|unmap API > >On 10/26/23 12:30, Zhenzhong Duan wrote: >> From: Eric Auger <eric.au...@redhat.com> >> >> No fucntional change intended. >> >> Signed-off-by: Eric Auger <eric.au...@redhat.com> >> Signed-off-by: Yi Liu <yi.l....@intel.com> >> Signed-off-by: Yi Sun <yi.y....@linux.intel.com> >> Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com> ...
>> diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c >> new file mode 100644 >> index 0000000000..9db8b89b2f >> --- /dev/null >> +++ b/hw/vfio/container-base.c >> @@ -0,0 +1,49 @@ >> +/* >> + * VFIO BASE CONTAINER >> + * >> + * Copyright (C) 2023 Intel Corporation. >> + * Copyright Red Hat, Inc. 2023 >> + * >> + * Authors: Yi Liu <yi.l....@intel.com> >> + * Eric Auger <eric.au...@redhat.com> >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License as published by >> + * the Free Software Foundation; either version 2 of the License, or >> + * (at your option) any later version. >> + >> + * This program is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + * GNU General Public License for more details. >> + >> + * You should have received a copy of the GNU General Public License along >> + * with this program; if not, see <http://www.gnu.org/licenses/>. >> + */ > >Please reduce the header with an SPDX identifier. Will fix. > >> + >> +#include "qemu/osdep.h" >> +#include "qapi/error.h" >> +#include "qemu/error-report.h" >> +#include "hw/vfio/vfio-container-base.h" >> + >> +int vfio_container_dma_map(VFIOContainerBase *bcontainer, >> + hwaddr iova, ram_addr_t size, >> + void *vaddr, bool readonly) >> +{ >> + if (!bcontainer->ops->dma_map) { > >I think this could be an assert instead ? Good suggestion, will fix. > >> + return -EINVAL; >> + } >> + >> + return bcontainer->ops->dma_map(bcontainer, iova, size, vaddr, >> readonly); >> +} >> + >> +int vfio_container_dma_unmap(VFIOContainerBase *bcontainer, >> + hwaddr iova, ram_addr_t size, >> + IOMMUTLBEntry *iotlb) >> +{ >> + if (!bcontainer->ops->dma_unmap) { >> + return -EINVAL; >> + } and here. Thanks Zhenzhong