Thread (23 messages) 23 messages, 3 authors, 2022-03-16

Re: [PATCH 14/15] swiotlb: remove swiotlb_init_with_tbl and swiotlb_init_late_with_tbl

From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Date: 2022-03-14 23:14:14
Also in: linux-arm-kernel, linux-hyperv, linux-iommu, linux-mips, linux-pci, linux-riscv, linux-s390, xen-devel

On 3/14/22 3:31 AM, Christoph Hellwig wrote:
quoted hunk ↗ jump to hunk
@@ -314,6 +293,7 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)
  int swiotlb_init_late(size_t size, gfp_t gfp_mask,
  		int (*remap)(void *tlb, unsigned long nslabs))
  {
+	struct io_tlb_mem *mem = &io_tlb_default_mem;
  	unsigned long nslabs = ALIGN(size >> IO_TLB_SHIFT, IO_TLB_SEGSIZE);
  	unsigned long bytes;
  	unsigned char *vstart = NULL;
@@ -355,33 +335,28 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
  			(PAGE_SIZE << order) >> 20);
  		nslabs = SLABS_PER_PAGE << order;
  	}
-	rc = swiotlb_late_init_with_tbl(vstart, nslabs);
-	if (rc)
-		free_pages((unsigned long)vstart, order);
-
-	return rc;
-}
-
-int
-swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
-{
-	struct io_tlb_mem *mem = &io_tlb_default_mem;
-	unsigned long bytes = nslabs << IO_TLB_SHIFT;
  
-	if (swiotlb_force_disable)
-		return 0;
+	if (remap)
+		rc = remap(vstart, nslabs);
+	if (rc) {
+		free_pages((unsigned long)vstart, order);
  
-	/* protect against double initialization */
-	if (WARN_ON_ONCE(mem->nslabs))
-		return -ENOMEM;
+		/* Min is 2MB */
+		if (nslabs <= 1024)
+			return rc;
+		nslabs = max(1024UL, ALIGN(nslabs >> 1, IO_TLB_SEGSIZE));
+		goto retry;
+	}

We now end up with two attempts to remap. I think this second one is what we want since it solves the problem I pointed in previous patch.


-boris

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