Skip to contentSkip to conversation

mmc: meson-gx: make replace WARN_ONCE with dev_warn_once about scatterlist offset alignment

PATCH In review Neil Armstrong 3 participants 5 messages Apr 26, 2021 – May 11, 2021

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

PATCH 1/2 mmc: meson-gx: make replace WARN_ONCE with dev_warn_once about scatterlist offset alignment

Some drivers like ath10k can sometimg give an sg buffer with an offset whose alignment is not compatible with the Amlogic DMA descriptor engine requirements.

Simply replace with dev_warn_once() to inform user this should be fixed to avoid degraded performance.

This should be ultimately fixed in ath10k, but since it's only a performance issue the warning should be removed.

Fixes 79ed05e329c3 ("mmc: meson-gx: add support for descriptor chain mode")
---
 drivers/mmc/host/meson-gx-mmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/meson-gx-mmc.c +3 -1
index b8b771b643cc..1c61f0f24c09 100644
@@ -258,7 +258,9 @@ static void meson_mmc_get_transfer_mode(struct mmc_host *mmc,
 	for_each_sg(data->sg, sg, data->sg_len, i) {
 		/* check for 8 byte alignment */
 		if (sg->offset % 8) {
-			WARN_ONCE(1, "unaligned scatterlist buffer\n");
+			dev_warn_once(mmc_dev(mmc),
+				      "unaligned sg offset %u, disabling descriptor DMA for transfer\n",
+				      sg->offset);
 			return;
 		}
 	}
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 mmc: meson-gx: also check SD_IO_RW_EXTENDED for scatterlist size alignment

The brcmfmac driver can generate a scatterlist from a skb with each packets not aligned to the block size. This is not supported by the Amlogic Descriptor dma engine where each descriptor must match a multiple of the block size.

The sg list is valid, since the sum of the sg buffers is a multiple of the block size, but we must discard those when in SD_IO_RW_EXTENDED mode since SDIO block mode can be used under the hood even with data->blocks == 1.

Those transfers are very rare, thus can be replaced by a bounce buffer without real performance loss.

Fixes 7412dee9f1fd ("mmc: meson-gx: replace WARN_ONCE with dev_warn_once about scatterlist size alignment in block mode")
---
 drivers/mmc/host/meson-gx-mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/meson-gx-mmc.c +2 -1
index 1c61f0f24c09..016a6106151a 100644
@@ -236,7 +236,8 @@ static void meson_mmc_get_transfer_mode(struct mmc_host *mmc,
 	if (host->dram_access_quirk)
 		return;
 
-	if (data->blocks > 1) {
+	/* SD_IO_RW_EXTENDED (CMD53) can also use block mode under the hood */
+	if (data->blocks > 1 || mrq->cmd->opcode == SD_IO_RW_EXTENDED) {
 		/*
 		 * In block mode DMA descriptor format, "length" field indicates
 		 * number of blocks and there is no way to pass DMA size that
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 2/2] mmc: meson-gx: also check SD_IO_RW_EXTENDED for scatterlist size alignment

Quoted 9 lines · Neil Armstrong

The brcmfmac driver can generate a scatterlist from a skb with each packets not aligned to the block size. This is not supported by the Amlogic Descriptor dma engine where each descriptor must match a multiple of the block size.

The sg list is valid, since the sum of the sg buffers is a multiple of the block size, but we must discard those when in SD_IO_RW_EXTENDED mode since SDIO block mode can be used under the hood even with data->blocks == 1.

Quoted 6 lines

Those transfers are very rare, thus can be replaced by a bounce buffer without real performance loss.

Fixes 7412dee9f1fd ("mmc: meson-gx: replace WARN_ONCE with dev_warn_once about scatterlist size alignment in block mode")

Applied for fixes and by adding a stable tag, thanks!

Kind regards
Uffe

Quoted 21 lines
---
 drivers/mmc/host/meson-gx-mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/meson-gx-mmc.c +2 -2
index 1c61f0f24c09..016a6106151a 100644
@@ -236,7 +236,8 @@ static void meson_mmc_get_transfer_mode(struct mmc_host *mmc,
        if (host->dram_access_quirk)
                return;
 
-       if (data->blocks > 1) {
+       /* SD_IO_RW_EXTENDED (CMD53) can also use block mode under the hood */
+       if (data->blocks > 1 || mrq->cmd->opcode == SD_IO_RW_EXTENDED) {
                /*
                 * In block mode DMA descriptor format, "length" field indicates
                 * number of blocks and there is no way to pass DMA size that
--

2.25.1

reviewer Acked-by on v1 1/2
#3 lore raw
In reply to Neil Armstrong

Hi Neil,

Quoted 2 lines · Neil Armstrong

Some drivers like ath10k can sometimg give an sg buffer with an offset whose alignment

sometimg -> sometimes

Quoted 11 lines

is not compatible with the Amlogic DMA descriptor engine requirements.

Simply replace with dev_warn_once() to inform user this should be fixed to avoid degraded performance.

This should be ultimately fixed in ath10k, but since it's only a performance issue the warning should be removed.

Fixes 79ed05e329c3 ("mmc: meson-gx: add support for descriptor chain mode")
#4 lore raw
In reply to Neil Armstrong
Quoted 7 lines · Neil Armstrong

Some drivers like ath10k can sometimg give an sg buffer with an offset whose alignment is not compatible with the Amlogic DMA descriptor engine requirements.

Simply replace with dev_warn_once() to inform user this should be fixed to avoid degraded performance.

Quoted 6 lines

This should be ultimately fixed in ath10k, but since it's only a performance issue the warning should be removed.

Fixes 79ed05e329c3 ("mmc: meson-gx: add support for descriptor chain mode")

Applied for fixes and by adding a stable tag, thanks!

Kind regards
Uffe

Quoted 22 lines
---
 drivers/mmc/host/meson-gx-mmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/meson-gx-mmc.c +3 -2
index b8b771b643cc..1c61f0f24c09 100644
@@ -258,7 +258,9 @@ static void meson_mmc_get_transfer_mode(struct mmc_host *mmc,
        for_each_sg(data->sg, sg, data->sg_len, i) {
                /* check for 8 byte alignment */
                if (sg->offset % 8) {
-                       WARN_ONCE(1, "unaligned scatterlist buffer\n");
+                       dev_warn_once(mmc_dev(mmc),
+                                     "unaligned sg offset %u, disabling descriptor DMA for transfer\n",
+                                     sg->offset);
                        return;
                }
        }
--

2.25.1