* [PATCH] mmc: sdhci: Avoid swiotlb buffer being full
@ 2017-11-27 10:28 Ulf Hansson
2017-11-27 12:42 ` Adrian Hunter
2017-12-01 10:01 ` Linus Walleij
0 siblings, 2 replies; 4+ messages in thread
From: Ulf Hansson @ 2017-11-27 10:28 UTC (permalink / raw)
To: linux-mmc, Adrian Hunter, Linus Walleij
Cc: Ulf Hansson, Linus, Yoshihiro Shimoda, Geert Uytterhoeven,
Konrad Rzeszutek Wilk, Jiri Slaby, # v4 . 14+
The commit de3ee99b097d ("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: de3ee99b097d ("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>
---
drivers/mmc/host/sdhci.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 2f14334..e9290a3 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -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>
@@ -3651,22 +3652,29 @@ int sdhci_setup_host(struct sdhci_host *host)
spin_lock_init(&host->lock);
/*
+ * Maximum number of sectors in one transfer. Limited by SDMA boundary
+ * size (512KiB). Note some tuning modes impose a 4MiB limit, but this
+ * is less anyway.
+ */
+ 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)
+ if (host->flags & SDHCI_USE_ADMA) {
mmc->max_segs = SDHCI_MAX_SEGS;
- else if (host->flags & SDHCI_USE_SDMA)
+ } else if (host->flags & SDHCI_USE_SDMA) {
mmc->max_segs = 1;
- else /* PIO */
+ 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 number of sectors in one transfer. Limited by SDMA boundary
- * size (512KiB). Note some tuning modes impose a 4MiB limit, but this
- * is less anyway.
- */
- mmc->max_req_size = 524288;
+ }
/*
* Maximum segment size. Could be one segment with the maximum number
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: sdhci: Avoid swiotlb buffer being full
2017-11-27 10:28 [PATCH] mmc: sdhci: Avoid swiotlb buffer being full Ulf Hansson
@ 2017-11-27 12:42 ` Adrian Hunter
2017-12-01 10:01 ` Linus Walleij
1 sibling, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2017-11-27 12:42 UTC (permalink / raw)
To: Ulf Hansson, linux-mmc, Linus Walleij
Cc: Linus, Yoshihiro Shimoda, Geert Uytterhoeven,
Konrad Rzeszutek Wilk, Jiri Slaby
On 27/11/17 12:28, Ulf Hansson wrote:
> The commit de3ee99b097d ("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: de3ee99b097d ("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>
> ---
> drivers/mmc/host/sdhci.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 2f14334..e9290a3 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -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>
> @@ -3651,22 +3652,29 @@ int sdhci_setup_host(struct sdhci_host *host)
> spin_lock_init(&host->lock);
>
> /*
> + * Maximum number of sectors in one transfer. Limited by SDMA boundary
> + * size (512KiB). Note some tuning modes impose a 4MiB limit, but this
> + * is less anyway.
> + */
> + 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)
> + if (host->flags & SDHCI_USE_ADMA) {
> mmc->max_segs = SDHCI_MAX_SEGS;
> - else if (host->flags & SDHCI_USE_SDMA)
> + } else if (host->flags & SDHCI_USE_SDMA) {
> mmc->max_segs = 1;
> - else /* PIO */
> + 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 number of sectors in one transfer. Limited by SDMA boundary
> - * size (512KiB). Note some tuning modes impose a 4MiB limit, but this
> - * is less anyway.
> - */
> - mmc->max_req_size = 524288;
> + }
>
> /*
> * Maximum segment size. Could be one segment with the maximum number
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: sdhci: Avoid swiotlb buffer being full
2017-11-27 10:28 [PATCH] mmc: sdhci: Avoid swiotlb buffer being full Ulf Hansson
2017-11-27 12:42 ` Adrian Hunter
@ 2017-12-01 10:01 ` Linus Walleij
2017-12-01 10:28 ` Ulf Hansson
1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2017-12-01 10:01 UTC (permalink / raw)
To: Ulf Hansson
Cc: linux-mmc, Adrian Hunter, Linus, Yoshihiro Shimoda,
Geert Uytterhoeven, Konrad Rzeszutek Wilk, Jiri Slaby, # v4 . 14+
On Mon, Nov 27, 2017 at 11:28 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> The commit de3ee99b097d ("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: de3ee99b097d ("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>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Thank you for fixing my screwups :/
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: sdhci: Avoid swiotlb buffer being full
2017-12-01 10:01 ` Linus Walleij
@ 2017-12-01 10:28 ` Ulf Hansson
0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2017-12-01 10:28 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-mmc, Adrian Hunter, Linus, Yoshihiro Shimoda,
Geert Uytterhoeven, Konrad Rzeszutek Wilk, Jiri Slaby, # v4 . 14+
On 1 December 2017 at 11:01, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Mon, Nov 27, 2017 at 11:28 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
>> The commit de3ee99b097d ("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: de3ee99b097d ("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>
>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Sorry, but this was too late, I just sent the PR to Linus.
Thanks anyway!
[...]
Kind regards
Uffe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-01 10:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-27 10:28 [PATCH] mmc: sdhci: Avoid swiotlb buffer being full Ulf Hansson
2017-11-27 12:42 ` Adrian Hunter
2017-12-01 10:01 ` Linus Walleij
2017-12-01 10:28 ` Ulf Hansson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.