>-----Original Message-----
>From: Steven Sistare <steven.sist...@oracle.com>
>Subject: Re: [PATCH V3 28/42] backends/iommufd:
>iommufd_backend_map_file_dma
>
>On 5/19/2025 11:51 AM, Steven Sistare wrote:
>> On 5/16/2025 4:26 AM, Duan, Zhenzhong wrote:
>>>> -----Original Message-----
>>>> From: Steve Sistare <steven.sist...@oracle.com>
>>>> Subject: [PATCH V3 28/42] backends/iommufd:
>>>> iommufd_backend_map_file_dma
>>>>
>>>> Define iommufd_backend_map_file_dma to implement
>IOMMU_IOAS_MAP_FILE.
>>>> This will be called as a substitute for iommufd_backend_map_dma, so
>>>> the error conditions for BARs are copied as-is from that function.
>>>>
>>>> Signed-off-by: Steve Sistare <steven.sist...@oracle.com>
>>>> ---
>>>> backends/iommufd.c       | 36 ++++++++++++++++++++++++++++++++++++
>>>> backends/trace-events    |  1 +
>>>> include/system/iommufd.h |  3 +++
>>>> 3 files changed, 40 insertions(+)
>>>>
>>>> diff --git a/backends/iommufd.c b/backends/iommufd.c
>>>> index b73f75c..5c1958f 100644
>>>> --- a/backends/iommufd.c
>>>> +++ b/backends/iommufd.c
>>>> @@ -172,6 +172,42 @@ int
>iommufd_backend_map_dma(IOMMUFDBackend
>>>> *be, uint32_t ioas_id, hwaddr iova,
>>>>      return ret;
>>>> }
>>>>
>>>> +int iommufd_backend_map_file_dma(IOMMUFDBackend *be, uint32_t
>ioas_id,
>>>> +                                 hwaddr iova, ram_addr_t size,
>>>> +                                 int mfd, unsigned long start, bool 
>>>> readonly)
>>>> +{
>>>> +    int ret, fd = be->fd;
>>>> +    struct iommu_ioas_map_file map = {
>>>> +        .size = sizeof(map),
>>>> +        .flags = IOMMU_IOAS_MAP_READABLE |
>>>> +                 IOMMU_IOAS_MAP_FIXED_IOVA,
>>>> +        .ioas_id = ioas_id,
>>>> +        .fd = mfd,
>>>> +        .start = start,
>>>> +        .iova = iova,
>>>> +        .length = size,
>>>> +    };
>>>> +
>>>> +    if (!readonly) {
>>>> +        map.flags |= IOMMU_IOAS_MAP_WRITEABLE;
>>>> +    }
>>>> +
>>>> +    ret = ioctl(fd, IOMMU_IOAS_MAP_FILE, &map);
>>>> +    trace_iommufd_backend_map_file_dma(fd, ioas_id, iova, size, mfd, 
>>>> start,
>>>> +                                       readonly, ret);
>>>> +    if (ret) {
>>>> +        ret = -errno;
>>>> +
>>>> +        /* TODO: Not support mapping hardware PCI BAR region for now. */
>>>> +        if (errno == EFAULT) {
>>>> +            warn_report("IOMMU_IOAS_MAP_FILE failed: %m, PCI BAR?");
>>>> +        } else {
>>>> +            error_report("IOMMU_IOAS_MAP_FILE failed: %m");
>>>
>>> No need to print error here as caller does the same thing.
>>
>> OK.  I was copying iommufd_backend_map_dma, but I see it has recently
>> dropped the error_report.
>
>If I delete the error_report line, can I add your RB?

Sure.

Reviewed-by: Zhenzhong Duan <zhenzhong.d...@intel.com>

Thanks
Zhenzhong

Reply via email to