diff mbox series

sdhci: stop poking into swiotlb internals

Message ID 20210205162346.2847165-1-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series sdhci: stop poking into swiotlb internals | expand

Commit Message

Christoph Hellwig Feb. 5, 2021, 4:23 p.m. UTC
Use the proper API to query the max mapping size instead of guessing
it based on swiotlb internals.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/mmc/host/sdhci.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Jiri Slaby Feb. 17, 2021, 12:10 p.m. UTC | #1
On 05. 02. 21, 19:43, Adrian Hunter wrote:
> + Jiri Slaby <jslaby@suse.cz>
> 
> On 5/02/21 6:23 pm, Christoph Hellwig wrote:
>> Use the proper API to query the max mapping size instead of guessing
>> it based on swiotlb internals.
>>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>> ---
>>   drivers/mmc/host/sdhci.c | 9 ++-------
>>   1 file changed, 2 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>> index 646823ddd31715..2d73407ee52ec7 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -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)));

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,
Christoph Hellwig Feb. 17, 2021, 1:39 p.m. UTC | #2
On Wed, Feb 17, 2021 at 01:10:48PM +0100, Jiri Slaby wrote:
> dma_max_mapping_size() should return the same for swiotlb 
> (swiotlb_max_mapping_size()), right?

Yes.
Adrian Hunter Feb. 17, 2021, 1:59 p.m. UTC | #3
On 5/02/21 6:23 pm, Christoph Hellwig wrote:
> Use the proper API to query the max mapping size instead of guessing
> it based on swiotlb internals.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 646823ddd31715..2d73407ee52ec7 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -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;
>  	}
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 646823ddd31715..2d73407ee52ec7 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -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;
 	}