Skip to contentSkip to conversation

Swiotlb: Add CONFIG_HAS_IOMEM check around memremap() in the swiotlb_mem_remap()

PATCH In review Tianyu Lan 4 participants 6 messages Dec 31, 2021 – Jan 4, 2022 DMA mapping helpers

lore
Share & tools
lore

Tianyu Lan

author
#0 lore raw

PATCH 1/1 Swiotlb: Add CONFIG_HAS_IOMEM check around memremap() in the swiotlb_mem_remap()

From: Tianyu Lan <[email protected]>

HAS_IOMEM option may not be selected on some platforms(e.g, s390) and this will cause compile error due to miss memremap() implementation. Fix it via adding HAS_IOMEM check around memremap() in the swiotlb.c.

---
 kernel/dma/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/dma/swiotlb.c +2 -0
index b36c1cdd0c4f..3de651ba38cc 100644
@@ -167,6 +167,7 @@ static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes)
 {
 	void *vaddr = NULL;
 
+#ifdef CONFIG_HAS_IOMEM
 	if (swiotlb_unencrypted_base) {
 		phys_addr_t paddr = mem->start + swiotlb_unencrypted_base;
 
@@ -175,6 +176,7 @@ static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes)
 			pr_err("Failed to map the unencrypted memory %pa size %lx.\n",
 			       &paddr, bytes);
 	}
+#endif
 
 	return vaddr;
 }
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
#1 lore raw
Quoted 4 lines · Tianyu Lan

From: Tianyu Lan <[email protected]>

HAS_IOMEM option may not be selected on some platforms(e.g, s390) and this will cause compile error due to miss memremap() implementation. Fix it via

miss -> missingk

Quoted 4 lines

adding HAS_IOMEM check around memremap() in the swiotlb.c.

Hi Christoph

Are you happy with this fix?

Thanks,
Wei.

Quoted 27 lines
---
 kernel/dma/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/dma/swiotlb.c +2 -0
index b36c1cdd0c4f..3de651ba38cc 100644
@@ -167,6 +167,7 @@ static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes)
 {
 	void *vaddr = NULL;
 
+#ifdef CONFIG_HAS_IOMEM
 	if (swiotlb_unencrypted_base) {
 		phys_addr_t paddr = mem->start + swiotlb_unencrypted_base;
 
@@ -175,6 +176,7 @@ static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes)
 			pr_err("Failed to map the unencrypted memory %pa size %lx.\n",
 			       &paddr, bytes);
 	}
+#endif
 
 	return vaddr;
 }
Signature · 1 line
2.25.1
#2 lore raw
In reply to Tianyu Lan
Quoted 17 lines · Tianyu Lan

From: Tianyu Lan <[email protected]>

HAS_IOMEM option may not be selected on some platforms(e.g, s390) and this will cause compile error due to miss memremap() implementation. Fix it via adding HAS_IOMEM check around memremap() in the swiotlb.c.

---
 kernel/dma/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/dma/swiotlb.c +0 -0
index b36c1cdd0c4f..3de651ba38cc 100644

kernel/dma/swiotlb.c static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes) · line 170

Quoted 4 lines
kernel/dma/swiotlb.c +1 -0
@@ -167,6 +167,7 @@ static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes)
 {
 	void *vaddr = NULL;
 
+#ifdef CONFIG_HAS_IOMEM

Please stub out all of swiotlb_mem_remap instead of the ifdef inside the function.

#3 lore raw
Quoted 21 lines · Christoph Hellwig
Quoted 20 lines · Tianyu Lan

From: Tianyu Lan <[email protected]>

HAS_IOMEM option may not be selected on some platforms(e.g, s390) and this will cause compile error due to miss memremap() implementation. Fix it via adding HAS_IOMEM check around memremap() in the swiotlb.c.

---
 kernel/dma/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/dma/swiotlb.c +0 -0
index b36c1cdd0c4f..3de651ba38cc 100644
@@ -167,6 +167,7 @@ static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes)
 {
 	void *vaddr = NULL;
 
Quoted 4 lines

kernel/dma/swiotlb.c static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes) · line 170

Quoted 1 line
kernel/dma/swiotlb.c +1 -0
+#ifdef CONFIG_HAS_IOMEM

Please stub out all of swiotlb_mem_remap instead of the ifdef inside the function.

Does this look okay to you?

---8<---

kernel/dma/swiotlb.c +7 -0
index b36c1cdd0c4f..f1e7ea160b43 100644
@@ -163,6 +163,7 @@ static inline unsigned long nr_slots(u64 val)
  * when swiotlb_unencrypted_base is set. (e.g. for Hyper-V AMD SEV-SNP
  * Isolation VMs).
  */
+#ifdef CONFIG_HAS_IOMEM
 static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes)
 {
 	void *vaddr = NULL;
@@ -178,6 +179,12 @@ static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes)
 
 	return vaddr;
 }
+#else
+static void *swiotlb_mem_remap(struct io_tlb_mem *mem, unsigned long bytes)
+{
+	return NULL;
+}
+#endif
 
 /*
  * Early SWIOTLB allocation may be too early to allow an architecture to
#4 lore raw
Quoted 4 lines · Wei Liu
Quoted 2 lines

Please stub out all of swiotlb_mem_remap instead of the ifdef inside the function.

Does this look okay to you?

Yes, thanks!

#5 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 4 lines · Wei Liu
Quoted 2 lines

Please stub out all of swiotlb_mem_remap instead of the ifdef inside the function.

Does this look okay to you?

Yes, thanks!

Thanks for confirming!

I will turn this into an ack and apply the diff to hyperv-next.

Wei.