Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH v1 0/4] swiotlb: some cleanup
@ 2022-06-11  8:25 Dongli Zhang
  2022-06-11  8:25 ` [PATCH v1 1/4] swiotlb: remove unused swiotlb_force Dongli Zhang
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Dongli Zhang @ 2022-06-11  8:25 UTC (permalink / raw)
  To: iommu, linux-doc, x86
  Cc: corbet, dave.hansen, joe.jin, linux-kernel, hch, mingo, bp, tglx

Hello,

The patch 1-2 are to cleanup unused variable and return type.

The patch 3 is to fix the param usage description in kernel doc.

The patch 4 is to panic on purpose when nslabs is too small.


Dongli Zhang:
  [PATCH v1 1/4] swiotlb: remove unused swiotlb_force
  [PATCH v1 2/4] swiotlb: remove useless return
  [PATCH v1 3/4] x86/swiotlb: fix param usage in boot-options.rst
  [PATCH v1 4/4] swiotlb: panic if nslabs is too small


Thank you very much!

Dongli Zhang


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 1/4] swiotlb: remove unused swiotlb_force
  2022-06-11  8:25 [PATCH v1 0/4] swiotlb: some cleanup Dongli Zhang
@ 2022-06-11  8:25 ` Dongli Zhang
  2022-06-11  8:25 ` [PATCH v1 2/4] swiotlb: remove useless return Dongli Zhang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Dongli Zhang @ 2022-06-11  8:25 UTC (permalink / raw)
  To: iommu, linux-doc, x86
  Cc: corbet, dave.hansen, joe.jin, linux-kernel, hch, mingo, bp, tglx

The 'swiotlb_force' is removed since commit c6af2aa9ffc9 ("swiotlb: make
the swiotlb_init interface more useful").

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 include/linux/swiotlb.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 7ed35dd3de6e..bdc58a0e20b1 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -60,7 +60,6 @@ dma_addr_t swiotlb_map(struct device *dev, phys_addr_t phys,
 		size_t size, enum dma_data_direction dir, unsigned long attrs);
 
 #ifdef CONFIG_SWIOTLB
-extern enum swiotlb_force swiotlb_force;
 
 /**
  * struct io_tlb_mem - IO TLB Memory Pool Descriptor
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 2/4] swiotlb: remove useless return
  2022-06-11  8:25 [PATCH v1 0/4] swiotlb: some cleanup Dongli Zhang
  2022-06-11  8:25 ` [PATCH v1 1/4] swiotlb: remove unused swiotlb_force Dongli Zhang
@ 2022-06-11  8:25 ` Dongli Zhang
  2022-06-11  8:25 ` [PATCH v1 3/4] x86/swiotlb: fix param usage in boot-options.rst Dongli Zhang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Dongli Zhang @ 2022-06-11  8:25 UTC (permalink / raw)
  To: iommu, linux-doc, x86
  Cc: corbet, dave.hansen, joe.jin, linux-kernel, hch, mingo, bp, tglx

Both swiotlb_init_remap() and swiotlb_init() have return type void.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 kernel/dma/swiotlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index cb50f8d38360..fd21f4162f4b 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -282,7 +282,7 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
 
 void __init swiotlb_init(bool addressing_limit, unsigned int flags)
 {
-	return swiotlb_init_remap(addressing_limit, flags, NULL);
+	swiotlb_init_remap(addressing_limit, flags, NULL);
 }
 
 /*
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 3/4] x86/swiotlb: fix param usage in boot-options.rst
  2022-06-11  8:25 [PATCH v1 0/4] swiotlb: some cleanup Dongli Zhang
  2022-06-11  8:25 ` [PATCH v1 1/4] swiotlb: remove unused swiotlb_force Dongli Zhang
  2022-06-11  8:25 ` [PATCH v1 2/4] swiotlb: remove useless return Dongli Zhang
@ 2022-06-11  8:25 ` Dongli Zhang
  2022-06-11  8:25 ` [PATCH v1 4/4] swiotlb: panic if nslabs is too small Dongli Zhang
  2022-06-22 10:43 ` [PATCH v1 0/4] swiotlb: some cleanup Christoph Hellwig
  4 siblings, 0 replies; 7+ messages in thread
From: Dongli Zhang @ 2022-06-11  8:25 UTC (permalink / raw)
  To: iommu, linux-doc, x86
  Cc: corbet, dave.hansen, joe.jin, linux-kernel, hch, mingo, bp, tglx

Fix the usage of swiotlb param in kernel doc.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 Documentation/x86/x86_64/boot-options.rst | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/Documentation/x86/x86_64/boot-options.rst b/Documentation/x86/x86_64/boot-options.rst
index 03ec9cf01181..cbd14124a667 100644
--- a/Documentation/x86/x86_64/boot-options.rst
+++ b/Documentation/x86/x86_64/boot-options.rst
@@ -287,11 +287,13 @@ iommu options only relevant to the AMD GART hardware IOMMU:
 iommu options only relevant to the software bounce buffering (SWIOTLB) IOMMU
 implementation:
 
-    swiotlb=<pages>[,force]
-      <pages>
-        Prereserve that many 128K pages for the software IO bounce buffering.
+    swiotlb=<slots>[,force,noforce]
+      <slots>
+        Prereserve that many 2K slots for the software IO bounce buffering.
       force
         Force all IO through the software TLB.
+      noforce
+        Do not initialize the software TLB.
 
 
 Miscellaneous
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 4/4] swiotlb: panic if nslabs is too small
  2022-06-11  8:25 [PATCH v1 0/4] swiotlb: some cleanup Dongli Zhang
                   ` (2 preceding siblings ...)
  2022-06-11  8:25 ` [PATCH v1 3/4] x86/swiotlb: fix param usage in boot-options.rst Dongli Zhang
@ 2022-06-11  8:25 ` Dongli Zhang
  2022-06-13  6:49   ` Dongli Zhang
  2022-06-22 10:43 ` [PATCH v1 0/4] swiotlb: some cleanup Christoph Hellwig
  4 siblings, 1 reply; 7+ messages in thread
From: Dongli Zhang @ 2022-06-11  8:25 UTC (permalink / raw)
  To: iommu, linux-doc, x86
  Cc: corbet, dave.hansen, joe.jin, linux-kernel, hch, mingo, bp, tglx

Panic on purpose if nslabs is too small, in order to sync with the remap
retry logic.

In addition, print the number of bytes for tlb alloc failure.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 kernel/dma/swiotlb.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index fd21f4162f4b..1758b724c7a8 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -242,6 +242,9 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
 	if (swiotlb_force_disable)
 		return;
 
+	if (nslabs < IO_TLB_MIN_SLABS)
+		panic("%s: nslabs = %lu too small\n", __func__, nslabs);
+
 	/*
 	 * By default allocate the bounce buffer memory from low memory, but
 	 * allow to pick a location everywhere for hypervisors with guest
@@ -254,7 +257,8 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
 	else
 		tlb = memblock_alloc_low(bytes, PAGE_SIZE);
 	if (!tlb) {
-		pr_warn("%s: failed to allocate tlb structure\n", __func__);
+		pr_warn("%s: Failed to allocate %zu bytes tlb structure\n",
+			__func__, bytes);
 		return;
 	}
 
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 4/4] swiotlb: panic if nslabs is too small
  2022-06-11  8:25 ` [PATCH v1 4/4] swiotlb: panic if nslabs is too small Dongli Zhang
@ 2022-06-13  6:49   ` Dongli Zhang
  0 siblings, 0 replies; 7+ messages in thread
From: Dongli Zhang @ 2022-06-13  6:49 UTC (permalink / raw)
  To: iommu, linux-doc, x86
  Cc: corbet, dave.hansen, joe.jin, linux-kernel, hch, mingo, bp, tglx



On 6/11/22 1:25 AM, Dongli Zhang wrote:
> Panic on purpose if nslabs is too small, in order to sync with the remap
> retry logic.
> 
> In addition, print the number of bytes for tlb alloc failure.
> 
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
>  kernel/dma/swiotlb.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index fd21f4162f4b..1758b724c7a8 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
> @@ -242,6 +242,9 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
>  	if (swiotlb_force_disable)
>  		return;
>  
> +	if (nslabs < IO_TLB_MIN_SLABS)
> +		panic("%s: nslabs = %lu too small\n", __func__, nslabs);
> +
>  	/*
>  	 * By default allocate the bounce buffer memory from low memory, but
>  	 * allow to pick a location everywhere for hypervisors with guest
> @@ -254,7 +257,8 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
>  	else
>  		tlb = memblock_alloc_low(bytes, PAGE_SIZE);
>  	if (!tlb) {
> -		pr_warn("%s: failed to allocate tlb structure\n", __func__);
> +		pr_warn("%s: Failed to allocate %zu bytes tlb structure\n",
> +			__func__, bytes);

Indeed I have a question on this pr_warn(). (I was going to send another patch
to retry with nslabs = ALIGN(nslabs >> 1, IO_TLB_SEGSIZE)).

Why not retry with nslabs = ALIGN(nslabs >> 1, IO_TLB_SEGSIZE), or panic here?

If the QEMU machine of my VM is i440fx, the boot is almost failed even here is
pr_warn. Why not sync with the remap failure handling?

1. retry with nslabs = ALIGN(nslabs >> 1, IO_TLB_SEGSIZE))
2. and finally panic if nslabs is too small.

Thank you very much!

Dongli Zhang

>  		return;
>  	}
>  
> 
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/4] swiotlb: some cleanup
  2022-06-11  8:25 [PATCH v1 0/4] swiotlb: some cleanup Dongli Zhang
                   ` (3 preceding siblings ...)
  2022-06-11  8:25 ` [PATCH v1 4/4] swiotlb: panic if nslabs is too small Dongli Zhang
@ 2022-06-22 10:43 ` Christoph Hellwig
  4 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2022-06-22 10:43 UTC (permalink / raw)
  To: Dongli Zhang
  Cc: corbet, dave.hansen, linux-doc, x86, joe.jin, linux-kernel, hch,
	iommu, mingo, bp, tglx

Thanks,

I've applied all 4 to the dma-mapping tree for Linux 5.20.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-22 10:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-11  8:25 [PATCH v1 0/4] swiotlb: some cleanup Dongli Zhang
2022-06-11  8:25 ` [PATCH v1 1/4] swiotlb: remove unused swiotlb_force Dongli Zhang
2022-06-11  8:25 ` [PATCH v1 2/4] swiotlb: remove useless return Dongli Zhang
2022-06-11  8:25 ` [PATCH v1 3/4] x86/swiotlb: fix param usage in boot-options.rst Dongli Zhang
2022-06-11  8:25 ` [PATCH v1 4/4] swiotlb: panic if nslabs is too small Dongli Zhang
2022-06-13  6:49   ` Dongli Zhang
2022-06-22 10:43 ` [PATCH v1 0/4] swiotlb: some cleanup Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox