Re: [PATCH v3 01/15] genpt: Generic Page Table base API

2025-07-28 Thread Jason Gunthorpe
On Mon, Jul 28, 2025 at 11:23:42AM +, Ankit Soni wrote: > > +static __always_inline struct pt_range _pt_top_range(struct pt_common > > *common, > > +uintptr_t top_of_table) > > +{ > > + struct pt_range range = { > > + .common = common

Re: [PATCH v9 17/29] iommufd: Add mmap interface

2025-07-14 Thread Jason Gunthorpe
On Mon, Jul 14, 2025 at 08:08:21AM +0200, Arnd Bergmann wrote: > The mtree_alloc_range() interface explicitly operates on 'unsigned long' > address values, so I don't see an immediate workaround for this that would > make it work on these machines. On the other hand, I fixed this already, PHYS_

Re: [PATCH v9 22/29] iommufd/selftest: Update hw_info coverage for an input data_type

2025-07-10 Thread Jason Gunthorpe
On Thu, Jul 10, 2025 at 04:43:14PM +, Pranjal Shrivastava wrote: > On Thu, Jul 10, 2025 at 12:32:02PM -0300, Jason Gunthorpe wrote: > Alright, this was on the `for-next` branch when the head was at: > 3e2a9811f6a9cefd310cc33cab73d5435b4a4caa > iommufd: Apply the new iommufd_objec

Re: [PATCH v9 22/29] iommufd/selftest: Update hw_info coverage for an input data_type

2025-07-10 Thread Jason Gunthorpe
On Thu, Jul 10, 2025 at 11:09:26AM +, Pranjal Shrivastava wrote: > On Wed, Jul 09, 2025 at 10:59:14PM -0700, Nicolin Chen wrote: > > Test both IOMMU_HW_INFO_TYPE_DEFAULT and IOMMU_HW_INFO_TYPE_SELFTEST, and > > add a negative test for an unsupported type. > > > > Also drop the unused mask in t

Re: [PATCH v3 15/15] iommupt: Add a kunit test for the IOMMU implementation

2025-07-09 Thread Jason Gunthorpe
On Wed, Jul 09, 2025 at 08:56:19AM +, Ankit Soni wrote: > > Hi Jason, > I noticed a few minor nits that might be worth addressing in a future > revision. Got them all thanks Jason

Re: [PATCH v8 00/29] iommufd: Add vIOMMU infrastructure (Part-4 HW QUEUE)

2025-07-09 Thread Jason Gunthorpe
On Fri, Jul 04, 2025 at 06:13:16PM -0700, Nicolin Chen wrote: > Nicolin Chen (29): > iommufd: Report unmapped bytes in the error path of > iopt_unmap_iova_range > iommufd: Correct virt_id kdoc at struct iommu_vdevice_alloc > iommufd/viommu: Explicitly define vdev->virt_id > iommu: Use e

Re: [PATCH v8 14/29] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-07-09 Thread Jason Gunthorpe
On Fri, Jul 04, 2025 at 06:13:30PM -0700, Nicolin Chen wrote: > +static struct iommufd_access * > +iommufd_hw_queue_alloc_phys(struct iommu_hw_queue_alloc *cmd, > + struct iommufd_viommu *viommu, phys_addr_t *base_pa) > +{ > + struct iommufd_access *access; > + struc

Re: [PATCH v8 04/29] iommu: Use enum iommu_hw_info_type for type in hw_info op

2025-07-09 Thread Jason Gunthorpe
s changed, 9 insertions(+), 6 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v3 03/15] iommupt: Add the basic structure of the iommu implementation

2025-07-08 Thread Jason Gunthorpe
On Tue, Jul 08, 2025 at 06:36:35AM +, Ankit Soni wrote: > > Tested-by: Alejandro Jimenez > > Signed-off-by: Jason Gunthorpe > > Tested patch series with multiple command line configurations for amd > iommu on zen5 machine with 12 NVMe devices. > > Suggested-

Re: [PATCH v7 13/28] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-07-04 Thread Jason Gunthorpe
On Fri, Jul 04, 2025 at 10:26:02AM -0300, Jason Gunthorpe wrote: > /* DIV_ROUND_UP(offset + cmd->length, PAGE_SIZE) */ > if (check_add_overflow(offset, cmd->length, &length)) >return -ERANGE; > if (check_add_overflow(length, PAGE_SIZE-1, &length)) >return -ER

Re: [PATCH v7 13/28] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-07-04 Thread Jason Gunthorpe
> SIZE_MAX) return -ERANGE; max_npages = length / PAGE_SIZE; And then max_npages and i should be size_t. Otherwise it looks OK Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v7 09/28] iommufd/access: Add internal APIs for HW queue to use

2025-07-04 Thread Jason Gunthorpe
ufd/device.c | 59 +++++---- > 2 files changed, 73 insertions(+), 9 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v7 03/28] iommu: Use enum iommu_hw_info_type for type in hw_info op

2025-07-04 Thread Jason Gunthorpe
| 6 +++--- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 3 ++- > drivers/iommu/intel/iommu.c | 3 ++- > drivers/iommu/iommufd/selftest.c| 3 ++- > 4 files changed, 9 insertions(+), 6 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v7 02/28] iommufd/viommu: Explicitly define vdev->virt_id

2025-07-04 Thread Jason Gunthorpe
rivers/iommu/iommufd/iommufd_private.h | 7 ++- > drivers/iommu/iommufd/driver.c | 2 +- > drivers/iommu/iommufd/viommu.c | 4 ++-- > 3 files changed, 9 insertions(+), 4 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v7 01/28] iommufd: Report unmapped bytes in the error path of iopt_unmap_iova_range

2025-07-04 Thread Jason Gunthorpe
; access") > Cc: sta...@vger.kernel.org > Signed-off-by: Nicolin Chen > --- > drivers/iommu/iommufd/io_pagetable.c | 7 +-- > 1 file changed, 5 insertions(+), 2 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v7 27/28] iommu/tegra241-cmdqv: Add user-space use support

2025-07-04 Thread Jason Gunthorpe
On Thu, Jul 03, 2025 at 06:48:42PM +, Pranjal Shrivastava wrote: > Ahh, thanks for this, that saved a lot of my time! And yes, I see some > functions in eventq.c calling the iopf_group_response which settles the > CMD_RESUME. So.. I assume these resume commands would be trapped and > *actually

Re: [PATCH v7 27/28] iommu/tegra241-cmdqv: Add user-space use support

2025-07-03 Thread Jason Gunthorpe
On Thu, Jul 03, 2025 at 02:46:03PM +, Pranjal Shrivastava wrote: > Right.. I was however hoping we'd also trap commands like CMD_PRI_RESP > and CMD_RESUME...I'm not sure if they should be accelerated via CMDQV.. > I guess I'll need to look and understand a little more if they are.. Right now

Re: [PATCH v7 27/28] iommu/tegra241-cmdqv: Add user-space use support

2025-07-02 Thread Jason Gunthorpe
On Wed, Jul 02, 2025 at 01:38:33AM +, Pranjal Shrivastava wrote: > On Tue, Jul 01, 2025 at 05:46:06PM -0700, Nicolin Chen wrote: > > On Wed, Jul 02, 2025 at 12:14:28AM +, Pranjal Shrivastava wrote: > > > Thus, coming back to the two initial points: > > > > > > 1) Issuing "non-invalidation"

Re: [PATCH v6 20/25] iommu/arm-smmu-v3-iommufd: Add hw_info to impl_ops

2025-06-19 Thread Jason Gunthorpe
On Thu, Jun 19, 2025 at 11:47:24AM +, Pranjal Shrivastava wrote: > I'm not sure if I get this right.. if the user (while porting a VMM or > something) mistakenly passes *type == IOMMU_HW_INFO_TYPE_INTEL_VTD here, > they'll get impl-specific info? It should call the impl hw_info which should fa

Re: [PATCH v6 08/25] iommufd/viommu: Add driver-defined vDEVICE support

2025-06-19 Thread Jason Gunthorpe
On Thu, Jun 19, 2025 at 10:26:28AM +, Pranjal Shrivastava wrote: > > +struct iommufd_vdevice { > > + struct iommufd_object obj; > > + struct iommufd_viommu *viommu; > > + struct device *dev; > > + u64 id; /* per-vIOMMU virtual ID */ > > Nit: Why not call this viommu_id? And lets have

Re: [PATCH v3 02/15] genpt: Add Documentation/ files

2025-06-17 Thread Jason Gunthorpe
On Tue, Jun 17, 2025 at 08:59:34AM +0700, Bagas Sanjaya wrote: > On Mon, Jun 16, 2025 at 03:06:05PM -0300, Jason Gunthorpe wrote: > > +The generic tests are intended to prove out the format functions and give > > +clearer failures to speed finding the problems. Once those pass then

Re: [PATCH v6 13/25] iommufd: Add mmap interface

2025-06-17 Thread Jason Gunthorpe
On Mon, Jun 16, 2025 at 07:37:26PM -0700, Nicolin Chen wrote: > On Mon, Jun 16, 2025 at 11:13:19AM -0300, Jason Gunthorpe wrote: > > On Sat, Jun 14, 2025 at 12:14:38AM -0700, Nicolin Chen wrote: > > > > > +/* Entry for iommufd_ctx::mt_mmap */ > > > +str

Re: [PATCH v6 07/25] iommufd/access: Add internal APIs for HW queue to use

2025-06-17 Thread Jason Gunthorpe
On Tue, Jun 17, 2025 at 12:23:20PM +0800, Baolu Lu wrote: > On 6/17/25 10:25, Nicolin Chen wrote: > > > > struct iommufd_eventq { > > > > struct iommufd_object obj; > > > > struct iommufd_ctx *ictx; > > > > diff --git a/drivers/iommu/iommufd/device.c > > > > b/drivers/iommu/iommu

[PATCH v3 04/15] iommupt: Add the AMD IOMMU v1 page table format

2025-06-16 Thread Jason Gunthorpe
ases. This version makes it explicit with a memset64() call. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/Makefile | 1 + drivers/iommu/generic_pt/Kconfig | 13 + drivers/iommu/generic_pt/fmt/Makefile | 11 + drivers/iommu/gene

[PATCH v3 14/15] iommu/amd: Remove AMD io_pgtable support

2025-06-16 Thread Jason Gunthorpe
None of this is used anymore, delete it. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/amd/Makefile | 2 +- drivers/iommu/amd/amd_iommu_types.h | 97 - drivers/iommu/amd/io_pgtable.c | 559 drivers/iommu/amd

[PATCH v3 07/15] iommupt: Add map_pages op

2025-06-16 Thread Jason Gunthorpe
map_range() and can do arbitrary ranges, internally handling all the validation and supporting any arrangment of page sizes. A future series can optimize iommu_map() to take advantage of this. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/generic_pt/iommu_pt.h | 480

[PATCH v3 03/15] iommupt: Add the basic structure of the iommu implementation

2025-06-16 Thread Jason Gunthorpe
their different roles with no change to any of the existing iommu core code. Implement the basic starting point: pt_iommu_init(), get_info() and deinit(). Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/generic_pt/Kconfig | 13 + drivers/iommu

[PATCH v3 02/15] genpt: Add Documentation/ files

2025-06-16 Thread Jason Gunthorpe
Add some general description and pull in the kdoc comments from the source file to index most of the useful functions. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- Documentation/driver-api/generic_pt.rst | 140 Documentation/driver-api/index.rst

[PATCH v3 08/15] iommupt: Add read_and_clear_dirty op

2025-06-16 Thread Jason Gunthorpe
ll if a contiguous entry is dirty, and a function to clear a contiguous entry back to clean. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/generic_pt/iommu_pt.h | 103 include/linux/generic_pt/iommu.h| 6 ++ 2 files changed

[PATCH v3 00/15] Consolidate iommu page table implementations (AMD)

2025-06-16 Thread Jason Gunthorpe
iommu_pt_...@nvidia.com/ Alejandro Jimenez (1): iommu/amd: Use the generic iommu page table Jason Gunthorpe (14): genpt: Generic Page Table base API genpt: Add Documentation/ files iommupt: Add the basic structure of the iommu implementation iommupt: Add the AMD IOMMU v1 page table format

[PATCH v3 05/15] iommupt: Add iova_to_phys op

2025-06-16 Thread Jason Gunthorpe
iova_to_phys is a performance path for the DMA API and iommufd, implement it using an unrolled get_user_pages() like function waterfall scheme. The implementation itself is fairly trivial. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/generic_pt/iommu_pt.h

[PATCH v3 09/15] iommupt: Add a kunit test for Generic Page Table

2025-06-16 Thread Jason Gunthorpe
et_write_clean(), pt_entry_make_write_dirty(), and pt_entry_write_is_dirty() work Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/generic_pt/.kunitconfig | 12 + drivers/iommu/generic_pt/Kconfig | 12 + drivers/iommu/generic_pt/fmt/Makefile | 12 +

[PATCH v3 06/15] iommupt: Add unmap_pages op

2025-06-16 Thread Jason Gunthorpe
ommu_unmap() to take advantage of this. Freed page table memory is batched up in the gather and will be freed in the driver's iotlb_sync() callback after the IOTLB flush completes. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/generic

[PATCH v3 01/15] genpt: Generic Page Table base API

2025-06-16 Thread Jason Gunthorpe
functions. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- .clang-format | 1 + drivers/iommu/Kconfig | 2 + drivers/iommu/generic_pt/Kconfig | 22 + drivers/iommu/generic_pt/pt_common.h | 354 dri

[PATCH v3 13/15] iommu/amd: Use the generic iommu page table

2025-06-16 Thread Jason Gunthorpe
-off-by: Alejandro Jimenez Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/amd/Kconfig | 5 +- drivers/iommu/amd/amd_iommu.h | 1 - drivers/iommu/amd/amd_iommu_types.h | 12 +- drivers/iommu/amd/io_pgtable.c | 1 - drivers/iommu/a

[PATCH v3 15/15] iommupt: Add a kunit test for the IOMMU implementation

2025-06-16 Thread Jason Gunthorpe
s when hitting collions doing nothing, unmap/map with random intersections and full unmap of random sizes. Also checked iommu_iova_to_phys() with random sizes - Check for memory leaks by monitoring NR_SECONDARY_PAGETABLE Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe ---

[PATCH v3 11/15] iommufd: Change the selftest to use iommupt instead of xarray

2025-06-16 Thread Jason Gunthorpe
otherwise the logic the test uses fails. They cannot be broken up or combined. Aside from aligning the selftest with a real page table implementation, this helps test the iommupt code itself. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/generic_pt/iommu_pt.h

[PATCH v3 10/15] iommupt: Add a mock pagetable format for iommufd selftest to use

2025-06-16 Thread Jason Gunthorpe
: Jason Gunthorpe --- drivers/iommu/generic_pt/fmt/Makefile | 1 + drivers/iommu/generic_pt/fmt/amdv1.h | 18 -- drivers/iommu/generic_pt/fmt/iommu_mock.c | 10 ++ include/linux/generic_pt/iommu.h | 6 ++ 4 files changed, 33 insertions(+), 2 deletions

[PATCH v3 12/15] iommupt: Add the x86 64 bit page table format

2025-06-16 Thread Jason Gunthorpe
iommu_pgsize() before invoking the domain op. This is unncessary with this implementation. Future work optimizes this and gets to 2%, 4%, 3%. Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe --- drivers/iommu/generic_pt/.kunitconfig | 1 + drivers/iommu/generic_pt/Kconfig

Re: [PATCH v6 24/25] iommu/tegra241-cmdqv: Add user-space use support

2025-06-16 Thread Jason Gunthorpe
if (vintf->hyp_own) > + kfree(vintf); else ? Otherwise looks OK to me Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v6 23/25] iommu/tegra241-cmdqv: Do not statically map LVCMDQs

2025-06-16 Thread Jason Gunthorpe
Signed-off-by: Nicolin Chen > --- > .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c| 37 +++++-- > 1 file changed, 33 insertions(+), 4 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v6 20/25] iommu/arm-smmu-v3-iommufd: Add hw_info to impl_ops

2025-06-16 Thread Jason Gunthorpe
On Sat, Jun 14, 2025 at 12:14:45AM -0700, Nicolin Chen wrote: > This will be used by Tegra241 CMDQV implementation to report a non-default > HW info data. > > Reviewed-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h

Re: [PATCH v6 19/25] iommu/arm-smmu-v3-iommufd: Add vsmmu_size/type and vsmmu_init impl ops

2025-06-16 Thread Jason Gunthorpe
rm-smmu-v3/arm-smmu-v3.h | 5 + > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 8 > 2 files changed, 13 insertions(+) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v6 17/25] iommufd: Allow an input data_type via iommu_hw_info

2025-06-16 Thread Jason Gunthorpe
include/uapi/linux/iommufd.h | 20 +++- > drivers/iommu/iommufd/device.c | 9 ++--- > 2 files changed, 25 insertions(+), 4 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v6 13/25] iommufd: Add mmap interface

2025-06-16 Thread Jason Gunthorpe
this is already in PAGE_SIZE units. > + /* Physical range for io_remap_pfn_range() */ > + unsigned long mmio_pfn; physaddr_t and maybe don't use pfn? > + unsigned long num_pfns; size_t Rest looks OK Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v6 11/25] iommufd/driver: Add iommufd_hw_queue_depend/undepend() helpers

2025-06-16 Thread Jason Gunthorpe
ude/linux/iommufd.h| 44 ++ > drivers/iommu/iommufd/driver.c | 28 ++ > 2 files changed, 72 insertions(+) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v6 10/25] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-06-16 Thread Jason Gunthorpe
On Sat, Jun 14, 2025 at 12:14:35AM -0700, Nicolin Chen wrote: > + /* > + * FIXME allocation may fail when sizeof(*pages) * max_npages is > + * larger than PAGE_SIZE. This might need a new API returning a > + * bio_vec or something more efficient. > + */ > + pages = kcall

Re: [PATCH v6 09/25] iommufd/viommu: Introduce IOMMUFD_OBJ_HW_QUEUE and its related struct

2025-06-16 Thread Jason Gunthorpe
On Sat, Jun 14, 2025 at 12:14:34AM -0700, Nicolin Chen wrote: > +struct iommufd_hw_queue { > + struct iommufd_object obj; > + struct iommufd_ctx *ictx; Try to avoid this if we don't need it Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v6 07/25] iommufd/access: Add internal APIs for HW queue to use

2025-06-16 Thread Jason Gunthorpe
On Sat, Jun 14, 2025 at 12:14:32AM -0700, Nicolin Chen wrote: > Now, access->ops can be NULL, to support an internal use case for the new > HW queue object. Since an access object in this case will be allocated by > an inernal iommufd object, the refcount on the ictx should be skipped, so > as not

Re: [PATCH v6 06/25] iommufd/access: Allow access->ops to be NULL for internal use

2025-06-16 Thread Jason Gunthorpe
nal access should be able to use this mechanism. Otherwise: Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v2 12/15] iommupt: Add the x86 64 bit page table format

2025-06-06 Thread Jason Gunthorpe
On Thu, Jun 05, 2025 at 02:03:58PM -0700, Jacob Pan wrote: > Hi Jason, > > On Mon, 5 May 2025 11:18:42 -0300 > Jason Gunthorpe wrote: > > > +config IOMMU_PT_X86_64 > > + tristate "IOMMU page table for x86 64 bit, 4/5 levels" > > + d

Re: [PATCH v5 10/29] iommufd: Abstract iopt_pin_pages and iopt_unpin_pages helpers

2025-06-05 Thread Jason Gunthorpe
On Thu, Jun 05, 2025 at 10:04:35AM -0700, Nicolin Chen wrote: > On Thu, Jun 05, 2025 at 12:16:48PM -0300, Jason Gunthorpe wrote: > > On Wed, Jun 04, 2025 at 09:11:07PM -0700, Nicolin Chen wrote: > > > > > I found the entire ictx would be locked by iommufd_access_create()

Re: [PATCH v2 07/15] iommupt: Add map_pages op

2025-06-05 Thread Jason Gunthorpe
On Mon, May 05, 2025 at 11:18:37AM -0300, Jason Gunthorpe wrote: > +/* > + * Check that the items in a contiguous block are all empty. This will > + * recursively check any tables in the block to validate they are empty and > + * accumulate them on the free list. Makes no change on

Re: [PATCH v5 10/29] iommufd: Abstract iopt_pin_pages and iopt_unpin_pages helpers

2025-06-05 Thread Jason Gunthorpe
On Wed, Jun 04, 2025 at 09:11:07PM -0700, Nicolin Chen wrote: > I found the entire ictx would be locked by iommufd_access_create(), > then the release fop couldn't even get invoked to destroy objects. Yes, that makes sense.. It looks to me like you can safely leave ictx as NULL instead of adding

Re: [PATCH v5 14/29] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-06-03 Thread Jason Gunthorpe
On Mon, Jun 02, 2025 at 10:41:05PM -0700, Nicolin Chen wrote: > I found that the size_viommu or size_hw_queue might not work using > a static macro as that RDMA one does: > > - The size in vIOMMU case is type dependent. E.g. smmuv3 driver >uses one iommu_ops to support two types: vSMMU and v

Re: [PATCH v5 20/29] iommu: Allow an input type in hw_info op

2025-05-30 Thread Jason Gunthorpe
| 3 +++ > drivers/iommu/iommufd/selftest.c| 4 > 6 files changed, 22 insertions(+), 3 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v5 29/29] iommu/tegra241-cmdqv: Add IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV support

2025-05-30 Thread Jason Gunthorpe
f-by: Nicolin Chen > --- > include/uapi/linux/iommufd.h | 15 + > .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c| 22 +++ > 2 files changed, 37 insertions(+) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v4 05/23] iommufd/driver: Let iommufd_viommu_alloc helper save ictx to viommu->ictx

2025-05-30 Thread Jason Gunthorpe
On Tue, May 27, 2025 at 11:41:19AM -0700, Nicolin Chen wrote: > On Mon, May 26, 2025 at 10:30:46AM -0300, Jason Gunthorpe wrote: > > On Fri, May 16, 2025 at 01:56:26PM -0700, Nicolin Chen wrote: > > > > > > You don't need to move this unless you are using inl

Re: [PATCH v5 14/29] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-05-30 Thread Jason Gunthorpe
On Fri, May 30, 2025 at 11:23:02AM -0700, Nicolin Chen wrote: > On Fri, May 30, 2025 at 02:40:37PM -0300, Jason Gunthorpe wrote: > > On Fri, May 30, 2025 at 10:38:24AM -0700, Nicolin Chen wrote: > > > On Fri, May 30, 2025 at 01:14:55PM -0300, Jason Gunthorpe wrote: > > >

Re: [PATCH v5 14/29] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-05-30 Thread Jason Gunthorpe
On Fri, May 30, 2025 at 10:38:24AM -0700, Nicolin Chen wrote: > On Fri, May 30, 2025 at 01:14:55PM -0300, Jason Gunthorpe wrote: > > On Sat, May 17, 2025 at 08:21:31PM -0700, Nicolin Chen wrote: > > > + offset = > > > + cmd->nesting_parent_iova - PAGE_

Re: [PATCH v5 17/29] iommufd: Add mmap interface

2025-05-30 Thread Jason Gunthorpe
On Fri, May 30, 2025 at 09:59:36AM -0700, Nicolin Chen wrote: > > > +/* The vm_pgoff must be pre-allocated from mt_mmap, and given to user > > > space */ > > > +static int iommufd_fops_mmap(struct file *filp, struct vm_area_struct > > > *vma) > > > +{ > > > + struct iommufd_ctx *ictx = filp->priv

Re: [PATCH v5 28/29] iommu/tegra241-cmdqv: Add user-space use support

2025-05-30 Thread Jason Gunthorpe
On Sat, May 17, 2025 at 08:21:45PM -0700, Nicolin Chen wrote: > +static inline phys_addr_t > +arm_smmu_domain_ipa_to_pa(struct arm_smmu_domain *smmu_domain, u64 ipa) > +{ > + if (WARN_ON_ONCE(smmu_domain->stage != ARM_SMMU_DOMAIN_S2)) > + return 0; > + return iommu_iova_to_phys(

Re: [PATCH v5 21/29] iommufd: Allow an input data_type via iommu_hw_info

2025-05-30 Thread Jason Gunthorpe
On Sat, May 17, 2025 at 08:21:38PM -0700, Nicolin Chen wrote: > @@ -666,7 +678,7 @@ struct iommu_hw_info { > __u32 dev_id; > __u32 data_len; > __aligned_u64 data_uptr; > - __u32 out_data_type; > + __u32 data_type; It would be better to avoid changing this name, maybe stic

Re: [PATCH v5 24/29] iommu/arm-smmu-v3-iommufd: Add hw_info to impl_ops

2025-05-30 Thread Jason Gunthorpe
/arm-smmu-v3/arm-smmu-v3-iommufd.c | 8 ++-- > 2 files changed, 7 insertions(+), 2 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v5 17/29] iommufd: Add mmap interface

2025-05-30 Thread Jason Gunthorpe
On Sat, May 17, 2025 at 08:21:34PM -0700, Nicolin Chen wrote: > +/* > + * Helpers for IOMMU driver to alloc/destroy an mmapable area for a > structure. > + * > + * To support an mmappable MMIO region, kernel driver must first register it > to > + * iommufd core to allocate an @out_offset, in the

Re: [PATCH v5 14/29] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-05-30 Thread Jason Gunthorpe
On Sat, May 17, 2025 at 08:21:31PM -0700, Nicolin Chen wrote: > +int iommufd_hw_queue_alloc_ioctl(struct iommufd_ucmd *ucmd) > +{ > + struct iommu_hw_queue_alloc *cmd = ucmd->cmd; > + struct iommufd_hw_queue *hw_queue; > + struct iommufd_viommu *viommu; > + struct page **pages; > +

Re: [PATCH v5 13/29] iommufd/viommu: Introduce IOMMUFD_OBJ_HW_QUEUE and its related struct

2025-05-30 Thread Jason Gunthorpe
On Sat, May 17, 2025 at 08:21:30PM -0700, Nicolin Chen wrote: > struct iommufd_viommu_ops { > + u32 flags; > void (*destroy)(struct iommufd_viommu *viommu); > struct iommu_domain *(*alloc_domain_nested)( > struct iommufd_viommu *viommu, u32 flags, > @@ -171,6 +200,10

Re: [PATCH v5 10/29] iommufd: Abstract iopt_pin_pages and iopt_unpin_pages helpers

2025-05-28 Thread Jason Gunthorpe
gt; for a pair of iopt helpers that can be shared with the HW QUEUE allocator. > > Rename check_area_prot() to align with the existing iopt_area helpers, and > inline it to the header since iommufd_access_rw() still uses it. > > Reviewed-by: Pranjal Shrivastava > Reviewed-by: Kevin Ti

Re: [PATCH v5 09/29] iommufd: Do not unmap an owned iopt_area

2025-05-28 Thread Jason Gunthorpe
On Sat, May 17, 2025 at 08:21:26PM -0700, Nicolin Chen wrote: > Do not allow to unmap an iopt_area that is owned by an object, giving this > owner a choice to lock the mapping in the iopt. > > It will be used by vIOMMU's HW QUEUE structure that must prevent the queue > memory from being unmapped i

Re: [PATCH v5 03/29] iommu: Apply the new iommufd_object_alloc_ucmd helper

2025-05-28 Thread Jason Gunthorpe
n to all existing > viommu_alloc op accordingly. > > Note that __iommufd_object_alloc_ucmd() builds in some static tests that > cover both static_asserts in the iommufd_viommu_alloc(). Thus drop them. > > Suggested-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- >

Re: [PATCH v5 02/29] iommufd: Introduce iommufd_object_alloc_ucmd helper

2025-05-28 Thread Jason Gunthorpe
abort itself. > > Similar to iommufd_object_alloc() and __iommufd_object_alloc(), add a pair > of helpers: __iommufd_object_alloc_ucmd() and iommufd_object_alloc_ucmd(). > > Suggested-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > drivers/iommu/iommu

Re: [PATCH v5 01/29] iommufd: Apply obvious cosmetic fixes

2025-05-28 Thread Jason Gunthorpe
> 10 files changed, 27 insertions(+), 38 deletions(-) I have mixed feelings, I know people don't like churn, but it doesn't seem so bad.. Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v4 05/23] iommufd/driver: Let iommufd_viommu_alloc helper save ictx to viommu->ictx

2025-05-26 Thread Jason Gunthorpe
On Fri, May 16, 2025 at 01:56:26PM -0700, Nicolin Chen wrote: > > You don't need to move this unless you are using inlines. Just use a > > forward declaration. > > Since we forward ucmd now, ictx is in the ucmd so we need this > structure for: > > - if (!IS_ERR(ret))

Re: [PATCH v4 11/23] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-05-26 Thread Jason Gunthorpe
On Fri, May 23, 2025 at 01:51:25AM +, Tian, Kevin wrote: > > If page is unmapped then stage 2 (Host page table) gets updated. IOMMU > > will not > > be able to find page and logs fault. > > As long as the fault is contained only for the relevant queue, yes > we don't need another pinning from

Re: [PATCH v4 11/23] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-05-16 Thread Jason Gunthorpe
On Thu, May 15, 2025 at 01:32:48PM -0700, Nicolin Chen wrote: > On Thu, May 15, 2025 at 03:59:38PM -0300, Jason Gunthorpe wrote: > > On Thu, May 15, 2025 at 11:16:45AM -0700, Nicolin Chen wrote: > > > > I don't think this actually works like this without an unmap > >

Re: [PATCH v4 14/23] iommufd: Add mmap interface

2025-05-16 Thread Jason Gunthorpe
On Fri, May 16, 2025 at 04:08:25AM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Friday, May 16, 2025 12:47 AM > > > > On Thu, May 08, 2025 at 08:02:35PM -0700, Nicolin Chen wrote: > > > + /* vma->vm_pgoff carries an index to an mtree entry (

Re: [PATCH v4 05/23] iommufd/driver: Let iommufd_viommu_alloc helper save ictx to viommu->ictx

2025-05-16 Thread Jason Gunthorpe
On Thu, May 15, 2025 at 07:05:45PM -0700, Nicolin Chen wrote: > Otherwise, they would be something like: > // in my_viommu_alloc() > my_viommu = iommufd_viommu_alloc(ucmd, ...); > iommufd_viommu_alloc_mmap(ucmd->ictx, my_viommu, ...); > iommufd_viommu_destroy_mmap(ucmd->ict

Re: [PATCH v4 11/23] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-05-16 Thread Jason Gunthorpe
On Fri, May 16, 2025 at 02:42:32AM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Friday, May 16, 2025 12:06 AM > > > > Do we have way to make the pinning optional? > > > > As I understand AMD's system the iommu HW itself translates th

Re: [PATCH v4 18/23] iommu/arm-smmu-v3-iommufd: Support implementation-defined hw_info

2025-05-16 Thread Jason Gunthorpe
On Thu, May 15, 2025 at 01:17:47PM -0700, Nicolin Chen wrote: > > I think the former is simpler to code, you can just add the req_type > > to the signatures and if the driver comes back with a type != req_type > > the core code will return EOPNOTSUPP > > OK. > > Maybe just turn the out_data_type

Re: [PATCH v2 04/15] iommupt: Add the AMD IOMMU v1 page table format

2025-05-16 Thread Jason Gunthorpe
On Fri, May 16, 2025 at 04:30:23PM +0800, Yi Liu wrote: > On 2025/5/5 22:18, Jason Gunthorpe wrote: > > AMD IOMMU v1 is unique in supporting contiguous pages with a variable size > > and it can decode the full 64 bit VA space. Unlike other x86 page tables > > this explic

Re: [PATCH v2 03/15] iommupt: Add the basic structure of the iommu implementation

2025-05-15 Thread Jason Gunthorpe
On Wed, May 14, 2025 at 04:08:09PM -0400, Alejandro Jimenez wrote: > > > On 5/14/25 11:54 AM, Jason Gunthorpe wrote: > > On Wed, May 14, 2025 at 09:23:49AM +, Ankit Soni wrote: > > > I am experiencing a system hang with a 5-level v2 page table mode, on > > >

Re: [PATCH v4 16/23] Documentation: userspace-api: iommufd: Update HW QUEUE

2025-05-15 Thread Jason Gunthorpe
hanged, 12 insertions(+) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v4 18/23] iommu/arm-smmu-v3-iommufd: Support implementation-defined hw_info

2025-05-15 Thread Jason Gunthorpe
On Thu, May 15, 2025 at 12:21:17PM -0700, Nicolin Chen wrote: > On Thu, May 15, 2025 at 03:56:29PM -0300, Jason Gunthorpe wrote: > > On Thu, May 15, 2025 at 11:52:05AM -0700, Nicolin Chen wrote: > > > On Thu, May 15, 2025 at 02:17:06PM -0300, Jason Gunthorpe wrote: > > >

Re: [PATCH v4 11/23] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-05-15 Thread Jason Gunthorpe
On Thu, May 15, 2025 at 11:16:45AM -0700, Nicolin Chen wrote: > > As I understand AMD's system the iommu HW itself translates the > > base_addr through the S2 page table automatically, so it doesn't need > > pinned memory and physical addresses but just the IOVA. > > Right. That's why we invented

Re: [PATCH v4 18/23] iommu/arm-smmu-v3-iommufd: Support implementation-defined hw_info

2025-05-15 Thread Jason Gunthorpe
On Thu, May 15, 2025 at 11:52:05AM -0700, Nicolin Chen wrote: > On Thu, May 15, 2025 at 02:17:06PM -0300, Jason Gunthorpe wrote: > > On Thu, May 08, 2025 at 08:02:39PM -0700, Nicolin Chen wrote: > > > Repurpose the @__reserved field in the struct iommu_hw_info_arm_smmu

Re: [PATCH v4 20/23] iommu/tegra241-cmdqv: Simplify deinit flow in tegra241_cmdqv_remove_vintf()

2025-05-15 Thread Jason Gunthorpe
t; Acked-by: Pranjal Shrivastava > Signed-off-by: Nicolin Chen > --- > drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 13 +++-- > 1 file changed, 3 insertions(+), 10 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v4 14/23] iommufd: Add mmap interface

2025-05-15 Thread Jason Gunthorpe
On Thu, May 08, 2025 at 08:02:35PM -0700, Nicolin Chen wrote: > +int _iommufd_alloc_mmap(struct iommufd_ctx *ictx, struct iommufd_object > *owner, > + phys_addr_t base, size_t length, unsigned long *offset) > +{ > + struct iommufd_mmap *immap; > + unsigned long startp;

Re: [PATCH v4 19/23] iommu/tegra241-cmdqv: Use request_threaded_irq

2025-05-15 Thread Jason Gunthorpe
/arm-smmu-v3/tegra241-cmdqv.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v4 17/23] iommu/arm-smmu-v3-iommufd: Add vsmmu_alloc impl op

2025-05-15 Thread Jason Gunthorpe
On Thu, May 08, 2025 at 08:02:38PM -0700, Nicolin Chen wrote: > An impl driver might want to allocate its own type of vIOMMU object or the > standard IOMMU_VIOMMU_TYPE_ARM_SMMUV3 by setting up its own SW/HW bits, as > the tegra241-cmdqv driver will add IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV. > > Add a v

Re: [PATCH v4 18/23] iommu/arm-smmu-v3-iommufd: Support implementation-defined hw_info

2025-05-15 Thread Jason Gunthorpe
On Thu, May 08, 2025 at 08:02:39PM -0700, Nicolin Chen wrote: > Repurpose the @__reserved field in the struct iommu_hw_info_arm_smmuv3, > to an HW implementation-defined field @impl. It would be nicer to have a tegra/cmdq specific struct and a way for iommu_hw_info to select it. 'impl' isn't going

Re: [PATCH v4 12/23] iommufd/driver: Add iommufd_hw_queue_depend/undepend() helpers

2025-05-15 Thread Jason Gunthorpe
On Thu, May 08, 2025 at 08:02:33PM -0700, Nicolin Chen wrote: > +/* > + * Helpers for IOMMU driver to build/destroy a dependency between two sibling > + * structures created by one of the allocators above > + */ > +#define iommufd_hw_queue_depend(dependent, depended, member) > \

Re: [PATCH v4 11/23] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

2025-05-15 Thread Jason Gunthorpe
On Thu, May 08, 2025 at 08:02:32PM -0700, Nicolin Chen wrote: > +/** > + * struct iommu_hw_queue_alloc - ioctl(IOMMU_HW_QUEUE_ALLOC) > + * @size: sizeof(struct iommu_hw_queue_alloc) > + * @flags: Must be 0 > + * @viommu_id: Virtual IOMMU ID to associate the HW queue with > + * @type: One of enum io

Re: [PATCH v4 10/23] iommufd/viommu: Introduce IOMMUFD_OBJ_HW_QUEUE and its related struct

2025-05-15 Thread Jason Gunthorpe
On Thu, May 08, 2025 at 08:02:31PM -0700, Nicolin Chen wrote: > +#define iommufd_hw_queue_alloc(viommu, drv_struct, member) > \ > + ({ \ > + drv_struct *ret;

Re: [PATCH v4 06/23] iommufd/driver: Add iommufd_struct_destroy to revert iommufd_viommu_alloc

2025-05-15 Thread Jason Gunthorpe
On Wed, May 14, 2025 at 12:21:37PM -0700, Nicolin Chen wrote: > > Then when the command is over the core code either aborts or finalizes > > the objects in the iommufd_ucmd. This way you don't have to expose > > abort and related to drivers. > > I see! Do you want this to apply to the all objects

Re: [PATCH v4 09/23] iommufd: Abstract iopt_pin_pages and iopt_unpin_pages helpers

2025-05-14 Thread Jason Gunthorpe
mu/iommufd/io_pagetable.h| 8 ++ > drivers/iommu/iommufd/iommufd_private.h | 6 ++ > drivers/iommu/iommufd/device.c | 117 ++-- > drivers/iommu/iommufd/io_pagetable.c| 95 +++ > 4 files changed, 117 insertions(+), 109 deletions(-) Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v4 06/23] iommufd/driver: Add iommufd_struct_destroy to revert iommufd_viommu_alloc

2025-05-14 Thread Jason Gunthorpe
> } > return &my_viommu->core; > } > > Move iommufd_object_abort() to the driver.c file and the public header, to > introduce common iommufd_struct_destroy() helper that will abort all kinds > of driver structures, not confined to iommufd_viommu but also the n

Re: [PATCH v4 05/23] iommufd/driver: Let iommufd_viommu_alloc helper save ictx to viommu->ictx

2025-05-14 Thread Jason Gunthorpe
of viommu allocations so it isn't such a big deal, but just generally that is how it was built that the ictx comes from the ioctl not the object. Reviewed-by: Jason Gunthorpe Jason

Re: [PATCH v2 03/15] iommupt: Add the basic structure of the iommu implementation

2025-05-14 Thread Jason Gunthorpe
On Wed, May 14, 2025 at 09:23:49AM +, Ankit Soni wrote: > I am experiencing a system hang with a 5-level v2 page table mode, on boot. > The NVMe boot drive is not initializing. > Below are the relevant dmesg logs with some prints i had added: > > [6.386439] AMD-Vi v2 domain init > [6.3

Re: [PATCH v2 02/15] genpt: Add Documentation/ files

2025-05-13 Thread Jason Gunthorpe
On Wed, May 07, 2025 at 09:37:07AM +0700, Bagas Sanjaya wrote: > On Mon, May 05, 2025 at 11:18:32AM -0300, Jason Gunthorpe wrote: > > +Since each compilation unit can only access one underlying format at a > > time, > > +code that is intended to be generic across multiple f

Re: [PATCH v2 07/15] iommupt: Add map_pages op

2025-05-13 Thread Jason Gunthorpe
On Tue, May 13, 2025 at 05:15:50AM +, Ankit Soni wrote: > > +static int increase_top(struct pt_iommu *iommu_table, struct pt_range > > *range, > > + struct pt_iommu_map_args *map) > > +{ > > + struct iommu_pages_list free_list = IOMMU_PAGES_LIST_INIT(free_list); > > + str

  1   2   3   >