Thread (55 messages) 55 messages, 7 authors, 2025-03-18

Re: [PATCH v3 09/23] iommu/pages: Formalize the freelist API

From: Jason Gunthorpe <jgg@nvidia.com>
Date: 2025-02-26 17:33:14
Also in: asahi, linux-iommu, linux-patches, linux-riscv, linux-rockchip, linux-samsung-soc, linux-sunxi, linux-tegra

On Wed, Feb 26, 2025 at 02:56:29PM +0800, Baolu Lu wrote:
On 2/26/25 03:39, Jason Gunthorpe wrote:
quoted
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 38c65e92ecd091..e414951c0af83f 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -326,6 +326,18 @@ typedef unsigned int ioasid_t;
  /* Read but do not clear any dirty bits */
  #define IOMMU_DIRTY_NO_CLEAR (1 << 0)
+/*
+ * Pages allocated through iommu_alloc_pages_node() can be placed on this list
+ * using iommu_pages_list_add(). Note: ONLY pages from iommu_alloc_pages_node()
+ * can be used this way!
+ */
+struct iommu_pages_list {
+	struct list_head pages;
+};
+
+#define IOMMU_PAGES_LIST_INIT(name) \
+	((struct iommu_pages_list){ .pages = LIST_HEAD_INIT(name.pages) })
+
  #ifdef CONFIG_IOMMU_API
Any reason why the above cannot be placed in the iommu-pages.h header
file? My understanding is that iommu-pages is only for the iommu drivers
and should not be accessible for external subsystems.
I wanted to do that, but the issue is the gather:

struct iommu_iotlb_gather {
	unsigned long		start;
	unsigned long		end;
	size_t			pgsize;
	struct iommu_pages_list	freelist;

The struct is inlined so it must be declared. I do not want to include
iommu-pages.h in this header.

Once the struct itself is there it made sense to include the INIT too.

FWIW I have a longstanding desire to split iommu.h into
internal-driver-facing and external-user-facing files..

Thanks,
Jason
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help