* [PATCH 0/4] mmc: mmci_sdmmc: fixes and improvements
@ 2020-02-26 8:40 Ludovic Barre
2020-02-26 8:40 ` [PATCH 1/4] mmc: mmci_sdmmc: fix DMA API warning max segment size Ludovic Barre
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ludovic Barre @ 2020-02-26 8:40 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring
Cc: srinivas.kandagatla, Maxime Coquelin, Alexandre Torgue,
linux-arm-kernel, linux-kernel, devicetree, linux-mmc,
linux-stm32, Ludovic Barre
This patch series fixes some problems:
-dma api debug warning to segment size check.
-dma_unmap_sg missing on not prepared request.
-Clear busyd0end irq flag when a R1B busy is completed.
-Initialize pwr|clk|datactrl_reg with their hardware values at probe.
Ludovic Barre (4):
mmc: mmci_sdmmc: fix DMA API warning max segment size
mmc: mmci_sdmmc: fix DMA API warning overlapping mappings
mmc: mmci_sdmmc: fix clear busyd0end irq flag
mmc: mmci: initialize pwr|clk|datactrl_reg with their hardware values
drivers/mmc/host/mmci.c | 4 ++++
drivers/mmc/host/mmci_stm32_sdmmc.c | 21 +++++++++++++--------
2 files changed, 17 insertions(+), 8 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] mmc: mmci_sdmmc: fix DMA API warning max segment size
2020-02-26 8:40 [PATCH 0/4] mmc: mmci_sdmmc: fixes and improvements Ludovic Barre
@ 2020-02-26 8:40 ` Ludovic Barre
2020-02-26 8:40 ` [PATCH 2/4] mmc: mmci_sdmmc: fix DMA API warning overlapping mappings Ludovic Barre
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ludovic Barre @ 2020-02-26 8:40 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring
Cc: srinivas.kandagatla, Maxime Coquelin, Alexandre Torgue,
linux-arm-kernel, linux-kernel, devicetree, linux-mmc,
linux-stm32, Ludovic Barre
Turning on CONFIG_DMA_API_DEBUG_SG results in the following warning:
WARNING: CPU: 1 PID: 85 at kernel/dma/debug.c:1302 debug_dma_map_sg+0x2a0/0x3cc
mmci-pl18x 58005000.sdmmc: DMA-API: mapping sg segment longer than device claims to support [len=126976] [max=65536]
dma api debug checks and compares the segment size to
dma_get_max_seg_size (dev->dma_parms->max_segment_size),
the sdmmc variant has an internal DMA and should define
its max_segment_size constraint to avoid this warning.
This Patch defines the dev->dma_parms->max_segment_size
with the constraint already set for mmc core
(host->mmc->max_seg_size).
Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
---
drivers/mmc/host/mmci_stm32_sdmmc.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_stm32_sdmmc.c
index f76e82f8f12f..56d9ad7f523e 100644
--- a/drivers/mmc/host/mmci_stm32_sdmmc.c
+++ b/drivers/mmc/host/mmci_stm32_sdmmc.c
@@ -119,20 +119,20 @@ static void sdmmc_idma_unprep_data(struct mmci_host *host,
static int sdmmc_idma_setup(struct mmci_host *host)
{
struct sdmmc_idma *idma;
+ struct device *dev = mmc_dev(host->mmc);
- idma = devm_kzalloc(mmc_dev(host->mmc), sizeof(*idma), GFP_KERNEL);
- if (!idma)
+ idma = devm_kzalloc(dev, sizeof(*idma), GFP_KERNEL);
+ dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL);
+ if (!idma || !dev->dma_parms)
return -ENOMEM;
host->dma_priv = idma;
if (host->variant->dma_lli) {
- idma->sg_cpu = dmam_alloc_coherent(mmc_dev(host->mmc),
- SDMMC_LLI_BUF_LEN,
+ idma->sg_cpu = dmam_alloc_coherent(dev, SDMMC_LLI_BUF_LEN,
&idma->sg_dma, GFP_KERNEL);
if (!idma->sg_cpu) {
- dev_err(mmc_dev(host->mmc),
- "Failed to alloc IDMA descriptor\n");
+ dev_err(dev, "Failed to alloc IDMA descriptor\n");
return -ENOMEM;
}
host->mmc->max_segs = SDMMC_LLI_BUF_LEN /
@@ -143,6 +143,8 @@ static int sdmmc_idma_setup(struct mmci_host *host)
host->mmc->max_seg_size = host->mmc->max_req_size;
}
+ dma_set_max_seg_size(dev, host->mmc->max_seg_size);
+
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] mmc: mmci_sdmmc: fix DMA API warning overlapping mappings
2020-02-26 8:40 [PATCH 0/4] mmc: mmci_sdmmc: fixes and improvements Ludovic Barre
2020-02-26 8:40 ` [PATCH 1/4] mmc: mmci_sdmmc: fix DMA API warning max segment size Ludovic Barre
@ 2020-02-26 8:40 ` Ludovic Barre
2020-02-26 8:40 ` [PATCH 3/4] mmc: mmci_sdmmc: fix clear busyd0end irq flag Ludovic Barre
2020-02-26 8:40 ` [PATCH 4/4] mmc: mmci: initialize pwr|clk|datactrl_reg with their hardware values Ludovic Barre
3 siblings, 0 replies; 5+ messages in thread
From: Ludovic Barre @ 2020-02-26 8:40 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring
Cc: srinivas.kandagatla, Maxime Coquelin, Alexandre Torgue,
linux-arm-kernel, linux-kernel, devicetree, linux-mmc,
linux-stm32, Ludovic Barre
Turning on CONFIG_DMA_API_DEBUG_SG results in the following warning:
WARNING: CPU: 1 PID: 20 at kernel/dma/debug.c:500 add_dma_entry+0x16c/0x17c
DMA-API: exceeded 7 overlapping mappings of cacheline 0x031d2645
Modules linked in:
CPU: 1 PID: 20 Comm: kworker/1:1 Not tainted 5.5.0-rc2-00021-gdeda30999c2b-dirty #49
Hardware name: STM32 (Device Tree Support)
Workqueue: events_freezable mmc_rescan
[<c03138c0>] (unwind_backtrace) from [<c030d760>] (show_stack+0x10/0x14)
[<c030d760>] (show_stack) from [<c0f2eb28>] (dump_stack+0xc0/0xd4)
[<c0f2eb28>] (dump_stack) from [<c034a14c>] (__warn+0xd0/0xf8)
[<c034a14c>] (__warn) from [<c034a530>] (warn_slowpath_fmt+0x94/0xb8)
[<c034a530>] (warn_slowpath_fmt) from [<c03bca0c>] (add_dma_entry+0x16c/0x17c)
[<c03bca0c>] (add_dma_entry) from [<c03bdf54>] (debug_dma_map_sg+0xe4/0x3d4)
[<c03bdf54>] (debug_dma_map_sg) from [<c0d09244>] (sdmmc_idma_prep_data+0x94/0xf8)
[<c0d09244>] (sdmmc_idma_prep_data) from [<c0d05a2c>] (mmci_prep_data+0x2c/0xb0)
[<c0d05a2c>] (mmci_prep_data) from [<c0d073ec>] (mmci_start_data+0x134/0x2f0)
[<c0d073ec>] (mmci_start_data) from [<c0d078d0>] (mmci_request+0xe8/0x154)
[<c0d078d0>] (mmci_request) from [<c0cecb44>] (mmc_start_request+0x94/0xbc)
DMA api debug brings to light leaking dma-mappings, dma_map_sg and
dma_unmap_sg are not correctly balanced.
If a request is prepared, the dma_map/unmap are done in asynchronous
call pre_req (prep_data) and post_req (unprep_data). In this case
the dma-mapping is right balanced.
But if the request was not prepared, the data->host_cookie is
define to zero and the dma_map/unmap must be done in the request.
The dma_map is called by mmci_dma_start (prep_data), but there is
no dma_unmap in this case.
This patch adds dma_unmap_sg when the dma is finalized and
the data cookie is zero (request not prepared).
Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
---
drivers/mmc/host/mmci_stm32_sdmmc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_stm32_sdmmc.c
index 56d9ad7f523e..7b781c897346 100644
--- a/drivers/mmc/host/mmci_stm32_sdmmc.c
+++ b/drivers/mmc/host/mmci_stm32_sdmmc.c
@@ -190,6 +190,9 @@ static int sdmmc_idma_start(struct mmci_host *host, unsigned int *datactrl)
static void sdmmc_idma_finalize(struct mmci_host *host, struct mmc_data *data)
{
writel_relaxed(0, host->base + MMCI_STM32_IDMACTRLR);
+
+ if (!data->host_cookie)
+ sdmmc_idma_unprep_data(host, data, 0);
}
static void mmci_sdmmc_set_clkreg(struct mmci_host *host, unsigned int desired)
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] mmc: mmci_sdmmc: fix clear busyd0end irq flag
2020-02-26 8:40 [PATCH 0/4] mmc: mmci_sdmmc: fixes and improvements Ludovic Barre
2020-02-26 8:40 ` [PATCH 1/4] mmc: mmci_sdmmc: fix DMA API warning max segment size Ludovic Barre
2020-02-26 8:40 ` [PATCH 2/4] mmc: mmci_sdmmc: fix DMA API warning overlapping mappings Ludovic Barre
@ 2020-02-26 8:40 ` Ludovic Barre
2020-02-26 8:40 ` [PATCH 4/4] mmc: mmci: initialize pwr|clk|datactrl_reg with their hardware values Ludovic Barre
3 siblings, 0 replies; 5+ messages in thread
From: Ludovic Barre @ 2020-02-26 8:40 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring
Cc: srinivas.kandagatla, Maxime Coquelin, Alexandre Torgue,
linux-arm-kernel, linux-kernel, devicetree, linux-mmc,
linux-stm32, Ludovic Barre
The busyd0 line transition can be very fast. The busy request
may be completed by busy_d0end without wait the busy_d0 steps.
The busyd0end irq flag must be cleared even if no busy_status.
Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
---
drivers/mmc/host/mmci_stm32_sdmmc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_stm32_sdmmc.c
index 7b781c897346..82b88293e742 100644
--- a/drivers/mmc/host/mmci_stm32_sdmmc.c
+++ b/drivers/mmc/host/mmci_stm32_sdmmc.c
@@ -363,11 +363,11 @@ static bool sdmmc_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
if (host->busy_status) {
writel_relaxed(mask & ~host->variant->busy_detect_mask,
base + MMCIMASK0);
- writel_relaxed(host->variant->busy_detect_mask,
- base + MMCICLEAR);
host->busy_status = 0;
}
+ writel_relaxed(host->variant->busy_detect_mask, base + MMCICLEAR);
+
return true;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] mmc: mmci: initialize pwr|clk|datactrl_reg with their hardware values
2020-02-26 8:40 [PATCH 0/4] mmc: mmci_sdmmc: fixes and improvements Ludovic Barre
` (2 preceding siblings ...)
2020-02-26 8:40 ` [PATCH 3/4] mmc: mmci_sdmmc: fix clear busyd0end irq flag Ludovic Barre
@ 2020-02-26 8:40 ` Ludovic Barre
3 siblings, 0 replies; 5+ messages in thread
From: Ludovic Barre @ 2020-02-26 8:40 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring
Cc: srinivas.kandagatla, Maxime Coquelin, Alexandre Torgue,
linux-arm-kernel, linux-kernel, devicetree, linux-mmc,
linux-stm32, Ludovic Barre
In mmci_write_pwr|clk|datactrlreg functions, if the desired value
is equal to corresponding variable (pwr_reg|clk_reg|datactrl_reg),
the value is not written in the register.
At probe pwr|clk|datactrl_reg of mmci_host structure are initialized
to 0 (kzalloc of mmc_alloc_host). But they does not necessarily reflect
hardware value of these registers, if they are used while boot level.
This is problematic, if we want to write 0 in these registers.
This patch initializes pwr|clk|datactrl_reg variables with their
hardware values while probing.
Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
---
drivers/mmc/host/mmci.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 647567def612..f378ae18d5dc 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -2085,6 +2085,10 @@ static int mmci_probe(struct amba_device *dev,
else if (plat->ocr_mask)
dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n");
+ host->pwr_reg = readl_relaxed(host->base + MMCIPOWER);
+ host->clk_reg = readl_relaxed(host->base + MMCICLOCK);
+ host->datactrl_reg = readl_relaxed(host->base + MMCIDATACTRL);
+
/* We support these capabilities. */
mmc->caps |= MMC_CAP_CMD23;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-02-26 8:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26 8:40 [PATCH 0/4] mmc: mmci_sdmmc: fixes and improvements Ludovic Barre
2020-02-26 8:40 ` [PATCH 1/4] mmc: mmci_sdmmc: fix DMA API warning max segment size Ludovic Barre
2020-02-26 8:40 ` [PATCH 2/4] mmc: mmci_sdmmc: fix DMA API warning overlapping mappings Ludovic Barre
2020-02-26 8:40 ` [PATCH 3/4] mmc: mmci_sdmmc: fix clear busyd0end irq flag Ludovic Barre
2020-02-26 8:40 ` [PATCH 4/4] mmc: mmci: initialize pwr|clk|datactrl_reg with their hardware values Ludovic Barre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).