mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-05 23:16:42 +07:00
mmc: sdhci: Avoid swiotlb buffer being full
The commitde3ee99b09
("mmc: Delete bounce buffer handling") deletes the bounce buffer handling, but also causes the max_req_size for sdhci to be increased, in case when max_segs == 1. This causes errors for sdhci-pci Ricoh variant, about the swiotlb buffer to become full. Fix the issue, by taking IO_TLB_SEGSIZE and IO_TLB_SHIFT into account when deciding the max_req_size for sdhci. Reported-by: Jiri Slaby <jslaby@suse.cz> Fixes:de3ee99b09
("mmc: Delete bounce buffer handling") Cc: <stable@vger.kernel.org> # v4.14+ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
This commit is contained in:
parent
52884f8f66
commit
250dcd1146
@ -21,6 +21,7 @@
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/swiotlb.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/of.h>
|
||||
@ -3650,17 +3651,6 @@ int sdhci_setup_host(struct sdhci_host *host)
|
||||
|
||||
spin_lock_init(&host->lock);
|
||||
|
||||
/*
|
||||
* Maximum number of segments. Depends on if the hardware
|
||||
* can do scatter/gather or not.
|
||||
*/
|
||||
if (host->flags & SDHCI_USE_ADMA)
|
||||
mmc->max_segs = SDHCI_MAX_SEGS;
|
||||
else if (host->flags & SDHCI_USE_SDMA)
|
||||
mmc->max_segs = 1;
|
||||
else /* PIO */
|
||||
mmc->max_segs = SDHCI_MAX_SEGS;
|
||||
|
||||
/*
|
||||
* Maximum number of sectors in one transfer. Limited by SDMA boundary
|
||||
* size (512KiB). Note some tuning modes impose a 4MiB limit, but this
|
||||
@ -3668,6 +3658,24 @@ int sdhci_setup_host(struct sdhci_host *host)
|
||||
*/
|
||||
mmc->max_req_size = 524288;
|
||||
|
||||
/*
|
||||
* Maximum number of segments. Depends on if the hardware
|
||||
* can do scatter/gather or not.
|
||||
*/
|
||||
if (host->flags & SDHCI_USE_ADMA) {
|
||||
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);
|
||||
}
|
||||
} else { /* PIO */
|
||||
mmc->max_segs = SDHCI_MAX_SEGS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Maximum segment size. Could be one segment with the maximum number
|
||||
* of bytes. When doing hardware scatter/gather, each entry cannot
|
||||
|
Loading…
Reference in New Issue
Block a user