Skip to contentSkip to conversation

sdhci: stop poking into swiotlb internals

PATCH In review Christoph Hellwig 3 participants 5 messages Feb 5, 2021 – Feb 17, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sdhci: stop poking into swiotlb internals

Use the proper API to query the max mapping size instead of guessing it based on swiotlb internals.

---
 drivers/mmc/host/sdhci.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci.c +2 -7
index 646823ddd31715..2d73407ee52ec7 100644
@@ -20,7 +20,6 @@
 #include <linux/slab.h>
 #include <linux/scatterlist.h>
 #include <linux/sizes.h>
-#include <linux/swiotlb.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
@@ -4582,12 +4581,8 @@ int sdhci_setup_host(struct sdhci_host *host)
 		mmc->max_segs = SDHCI_MAX_SEGS;
 	} else if (host->flags & SDHCI_USE_SDMA) {
 		mmc->max_segs = 1;
-		if (swiotlb_max_segment()) {
-			unsigned int max_req_size = (1 << IO_TLB_SHIFT) *
-						IO_TLB_SEGSIZE;
-			mmc->max_req_size = min(mmc->max_req_size,
-						max_req_size);
-		}
+		mmc->max_req_size = min_t(size_t, mmc->max_req_size,
+					  dma_max_mapping_size(mmc_dev(mmc)));
 	} else { /* PIO */
 		mmc->max_segs = SDHCI_MAX_SEGS;
 	}
Signature · 1 line
2.29.2
maintainer
#1 lore raw

+ Jiri Slaby <[email protected]>

Quoted 36 lines · Christoph Hellwig

Use the proper API to query the max mapping size instead of guessing it based on swiotlb internals.

---
 drivers/mmc/host/sdhci.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci.c +2 -7
index 646823ddd31715..2d73407ee52ec7 100644
@@ -20,7 +20,6 @@
 #include <linux/slab.h>
 #include <linux/scatterlist.h>
 #include <linux/sizes.h>
-#include <linux/swiotlb.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
@@ -4582,12 +4581,8 @@ int sdhci_setup_host(struct sdhci_host *host)
 		mmc->max_segs = SDHCI_MAX_SEGS;
 	} else if (host->flags & SDHCI_USE_SDMA) {
 		mmc->max_segs = 1;
-		if (swiotlb_max_segment()) {
-			unsigned int max_req_size = (1 << IO_TLB_SHIFT) *
-						IO_TLB_SEGSIZE;
-			mmc->max_req_size = min(mmc->max_req_size,
-						max_req_size);
-		}
+		mmc->max_req_size = min_t(size_t, mmc->max_req_size,
+					  dma_max_mapping_size(mmc_dev(mmc)));
 	} else { /* PIO */
 		mmc->max_segs = SDHCI_MAX_SEGS;
 	}
#2 lore raw
Quoted 27 lines · Adrian Hunter

+ Jiri Slaby <[email protected]>

Quoted 24 lines · Christoph Hellwig

Use the proper API to query the max mapping size instead of guessing it based on swiotlb internals.

---
  drivers/mmc/host/sdhci.c | 9 ++-------
  1 file changed, 2 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci.c +0 -1
index 646823ddd31715..2d73407ee52ec7 100644
@@ -20,7 +20,6 @@
  #include <linux/slab.h>
  #include <linux/scatterlist.h>
  #include <linux/sizes.h>
-#include <linux/swiotlb.h>
  #include <linux/regulator/consumer.h>
  #include <linux/pm_runtime.h>
  #include <linux/of.h>
@@ -4582,12 +4581,8 @@ int sdhci_setup_host(struct sdhci_host *host)
  		mmc->max_segs = SDHCI_MAX_SEGS;
  	} else if (host->flags & SDHCI_USE_SDMA) {
  		mmc->max_segs = 1;
Quoted 8 lines

drivers/mmc/host/sdhci.c int sdhci_setup_host(struct sdhci_host *host) · line 4585

Quoted 8 lines
drivers/mmc/host/sdhci.c +2 -6
-		if (swiotlb_max_segment()) {
-			unsigned int max_req_size = (1 << IO_TLB_SHIFT) *
-						IO_TLB_SEGSIZE;
-			mmc->max_req_size = min(mmc->max_req_size,
-						max_req_size);
-		}
+		mmc->max_req_size = min_t(size_t, mmc->max_req_size,
+					  dma_max_mapping_size(mmc_dev(mmc)));

dma_max_mapping_size() should return the same for swiotlb (swiotlb_max_mapping_size()), right?

I don't have the laptop, it was ThinkPad X230 if anyone wants to test this...

thanks,

Signature · 2 lines
js
suse labs
#3 lore raw
Quoted 2 lines · Jiri Slaby

dma_max_mapping_size() should return the same for swiotlb (swiotlb_max_mapping_size()), right?

Yes.

maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

Use the proper API to query the max mapping size instead of guessing it based on swiotlb internals.

Quoted 32 lines
---
 drivers/mmc/host/sdhci.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci.c +2 -7
index 646823ddd31715..2d73407ee52ec7 100644
@@ -20,7 +20,6 @@
 #include <linux/slab.h>
 #include <linux/scatterlist.h>
 #include <linux/sizes.h>
-#include <linux/swiotlb.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
@@ -4582,12 +4581,8 @@ int sdhci_setup_host(struct sdhci_host *host)
 		mmc->max_segs = SDHCI_MAX_SEGS;
 	} else if (host->flags & SDHCI_USE_SDMA) {
 		mmc->max_segs = 1;
-		if (swiotlb_max_segment()) {
-			unsigned int max_req_size = (1 << IO_TLB_SHIFT) *
-						IO_TLB_SEGSIZE;
-			mmc->max_req_size = min(mmc->max_req_size,
-						max_req_size);
-		}
+		mmc->max_req_size = min_t(size_t, mmc->max_req_size,
+					  dma_max_mapping_size(mmc_dev(mmc)));
 	} else { /* PIO */
 		mmc->max_segs = SDHCI_MAX_SEGS;
 	}