Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-25 Thread Yi Liu
On 2023/10/25 01:30, Jason Gunthorpe wrote: On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) if (pt_obj->type == IOMMUFD_OBJ_IOAS) {

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Yi Liu
On 2023/10/25 02:19, Nicolin Chen wrote: On Tue, Oct 24, 2023 at 03:00:49PM -0300, Jason Gunthorpe wrote: On Tue, Oct 24, 2023 at 10:50:58AM -0700, Nicolin Chen wrote: The point is for the user_data to always be available, the driver needs to check it if it is passed. This should all be plumb

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Nicolin Chen
On Tue, Oct 24, 2023 at 03:00:49PM -0300, Jason Gunthorpe wrote: > On Tue, Oct 24, 2023 at 10:50:58AM -0700, Nicolin Chen wrote: > > > > The point is for the user_data to always be available, the driver > > > needs to check it if it is passed. > > > > > > This should all be plumbed to allow drive

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 10:50:58AM -0700, Nicolin Chen wrote: > > The point is for the user_data to always be available, the driver > > needs to check it if it is passed. > > > > This should all be plumbed to allow drivers to also customize their > > paging domains too. > > We don't have a use c

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Nicolin Chen
On Tue, Oct 24, 2023 at 02:31:39PM -0300, Jason Gunthorpe wrote: > On Tue, Oct 24, 2023 at 10:28:45AM -0700, Nicolin Chen wrote: > > On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: > > > On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > > > > @@ -195,6 +279,10 @@ int iommuf

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > static inline void iommufd_hw_pagetable_put(struct iommufd_ctx *ictx, > struct iommufd_hw_pagetable *hwpt) > { > - struct iommufd_hwpt_paging *hwpt_paging = to_hwpt_paging(hwpt); > + if (WA

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 10:28:45AM -0700, Nicolin Chen wrote: > On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: > > On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > > > @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > > > if (pt_obj->type == IOMMU

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: > On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > > @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > > if (pt_obj->type == IOMMUFD_OBJ_IOAS) { > > struct iommufd_hwpt_paging *hwpt_pagi

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Nicolin Chen
On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: > On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > > @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > > if (pt_obj->type == IOMMUFD_OBJ_IOAS) { > > struct iommufd_hwpt_paging *hwpt_pagi

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > if (pt_obj->type == IOMMUFD_OBJ_IOAS) { > struct iommufd_hwpt_paging *hwpt_paging; > > + if (cmd->data_type != IOMMU_HWPT_DATA_NONE) {

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > +static struct iommufd_hwpt_nested * > +iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx, > + struct iommufd_hwpt_paging *parent, > + struct iommufd_device *idev, u32 flags, > +

[PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Yi Liu
From: Nicolin Chen IOMMU_HWPT_ALLOC already supports iommu_domain allocation for usersapce. But it can only allocate a hw_pagetable that associates to a given IOAS, i.e. only a kernel-managed hw_pagetable of IOMMUFD_OBJ_HWPT_PAGING type. IOMMU drivers can now support user-managed hw_pagetables,