mmc: meson-gx: set segment host parameters
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/18 mmc: meson-gx: set segment host parameters
Setting the segment parameters boosted the read performance from 13 MB/s to 32 MB/s in my case.
Default for segment size is only 4k (PAGE_SIZE).
--- drivers/mmc/host/meson-gx-mmc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/meson-gx-mmc.c +3 -0
@@ -118,6 +118,7 @@#define SD_EMMC_CFG_RESP_TIMEOUT 256/* in clock cycles */ #define SD_EMMC_CFG_CMD_GAP 16/* in clock cycles */ #define MUX_CLK_NUM_PARENTS 2 +#define MESON_MMC_MAX_SEGS 512struct meson_host {struct device *dev;
@@ -789,8 +790,10 @@ static int meson_mmc_probe(struct platform_device *pdev)if (ret) goto free_host; + mmc->max_segs =MESON_MMC_MAX_SEGS ; mmc->max_blk_count =CMD_CFG_LENGTH_MASK ; mmc->max_req_size = mmc->max_blk_count * mmc->max_blk_size; + mmc->max_seg_size = mmc->max_req_size;/* data bounce buffer */ host->bounce_buf_size = mmc->max_req_size;
Signature · 1 line
2.11.1
PATCH 2/18 mmc: meson-gx: remove code for unsupported CMD23
In reply to a message not in the archiveCMD23 isn't supported on meson-gx and therefore the "set block count" command isn't used. So remove this dead code.
--- drivers/mmc/host/meson-gx-mmc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +2 -6
@@ -555,11 +555,7 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)writel (0 , host->regs +SD_EMMC_START ); host->mrq = mrq; - -if (mrq->sbc) -meson_mmc_start_cmd (mmc, mrq->sbc); -else -meson_mmc_start_cmd (mmc, mrq->cmd); +meson_mmc_start_cmd (mmc, mrq->cmd); }static int meson_mmc_read_resp (struct mmc_host *mmc,struct mmc_command *cmd)
@@ -690,7 +686,7 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) }meson_mmc_read_resp (host->mmc, cmd); -if (!data || !data->stop || mrq->sbc) +if (!data || !data->stop)meson_mmc_request_done (host->mmc, mrq);else meson_mmc_start_cmd (host->mmc, data->stop);
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 2/18 mmc: meson-gx: remove code for unsupported CMD23
Quoted 2 lines · Heiner Kallweit
CMD23 isn't supported on meson-gx and therefore the "set block count" command isn't used. So remove this dead code.
I'm admittedly a bit unfamiliar with the MMC spec and wrote this driver mostly by looking at the vendor driver, so forgive the silly questions...
Why isn't CMD23 supported, and should we support instead of deleting this support?
Kevin
Quoted 31 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/mmc/host/meson-gx-mmc.c +2
-6@@ -555,11 +555,7 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)writel (0 , host->regs +SD_EMMC_START ); host->mrq = mrq; - -if (mrq->sbc) -meson_mmc_start_cmd (mmc, mrq->sbc); -else -meson_mmc_start_cmd (mmc, mrq->cmd); +meson_mmc_start_cmd (mmc, mrq->cmd); }static int meson_mmc_read_resp (struct mmc_host *mmc,struct mmc_command *cmd)@@ -690,7 +686,7 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) }meson_mmc_read_resp (host->mmc, cmd); -if (!data || !data->stop || mrq->sbc) +if (!data || !data->stop)meson_mmc_request_done (host->mmc, mrq);else meson_mmc_start_cmd (host->mmc, data->stop);
PATCH 2/18 mmc: meson-gx: remove code for unsupported CMD23
Am 15.02.2017 um 17:54 schrieb Kevin Hilman:
Quoted 5 lines
Quoted 2 lines · Heiner Kallweit
CMD23 isn't supported on meson-gx and therefore the "set block count" command isn't used. So remove this dead code.
Quoted 7 lines
I'm admittedly a bit unfamiliar with the MMC spec and wrote this driver mostly by looking at the vendor driver, so forgive the silly questions...
Why isn't CMD23 supported, and should we support instead of deleting this support?
As far as I understand this needs to be supported by the host controller. And setting the respective host flag to enable CMD23 mode lead to a non-working driver when testing on my system.
Quoted 34 lines
Kevin
Quoted 31 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/mmc/host/meson-gx-mmc.c +2
-6@@ -555,11 +555,7 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)writel (0 , host->regs +SD_EMMC_START ); host->mrq = mrq; - -if (mrq->sbc) -meson_mmc_start_cmd (mmc, mrq->sbc); -else -meson_mmc_start_cmd (mmc, mrq->cmd); +meson_mmc_start_cmd (mmc, mrq->cmd); }static int meson_mmc_read_resp (struct mmc_host *mmc,struct mmc_command *cmd)@@ -690,7 +686,7 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) }meson_mmc_read_resp (host->mmc, cmd); -if (!data || !data->stop || mrq->sbc) +if (!data || !data->stop)meson_mmc_request_done (host->mmc, mrq);else meson_mmc_start_cmd (host->mmc, data->stop);
PATCH 2/18 mmc: meson-gx: remove code for unsupported CMD23
Quoted 10 lines · Heiner Kallweit
Am 15.02.2017 um 17:54 schrieb Kevin Hilman:
Quoted 9 lines
Quoted 2 lines · Heiner Kallweit
CMD23 isn't supported on meson-gx and therefore the "set block count" command isn't used. So remove this dead code.
I'm admittedly a bit unfamiliar with the MMC spec and wrote this driver mostly by looking at the vendor driver, so forgive the silly questions...
Quoted 6 lines
Quoted 3 lines
Why isn't CMD23 supported, and should we support instead of deleting this support?
As far as I understand this needs to be supported by the host controller. And setting the respective host flag to enable CMD23 mode lead to a non-working driver when testing on my system.
CMD23 can be supported by the host *driver*, you don't need HW-support to implement this.
You may for example be inspired by the mmci.c driver to understand how to implement this. Looks for "mrq->sbc".
[...]
Kind regards
Uffe
PATCH 2/18 mmc: meson-gx: remove code for unsupported CMD23
Am 16.02.2017 um 09:14 schrieb Ulf Hansson:
Quoted 14 lines · Heiner Kallweit
Quoted 13 lines
Am 15.02.2017 um 17:54 schrieb Kevin Hilman:
Quoted 12 lines
Quoted 2 lines · Heiner Kallweit
CMD23 isn't supported on meson-gx and therefore the "set block count" command isn't used. So remove this dead code.
I'm admittedly a bit unfamiliar with the MMC spec and wrote this driver mostly by looking at the vendor driver, so forgive the silly questions...
Why isn't CMD23 supported, and should we support instead of deleting this support?
Quoted 7 lines
Quoted 3 lines
As far as I understand this needs to be supported by the host controller. And setting the respective host flag to enable CMD23 mode lead to a non-working driver when testing on my system.
CMD23 can be supported by the host *driver*, you don't need HW-support to implement this.
Thanks for the explanation. I think I got confused by this comment in core/block.c: "If CMD23 is supported by card and host, [..]" I interpreted this as "host controller needs to support this feature".
Quoted 8 lines
You may for example be inspired by the
mmci.cdriver to understand how to implement this. Looks for "mrq->sbc".[...]
Kind regards
Uffe
PATCH 2/18 mmc: meson-gx: remove code for unsupported CMD23
In reply to Kevin HilmanAm 15.02.2017 um 17:54 schrieb Kevin Hilman:
Quoted 5 lines
Quoted 2 lines · Heiner Kallweit
CMD23 isn't supported on meson-gx and therefore the "set block count" command isn't used. So remove this dead code.
Quoted 7 lines
I'm admittedly a bit unfamiliar with the MMC spec and wrote this driver mostly by looking at the vendor driver, so forgive the silly questions...
Why isn't CMD23 supported, and should we support instead of deleting this support?
After clarification by Ulf that CMD23 is not a host feature but a host driver feature I added this feature to the driver.
I will submit it once the smaller refactorings are applied.
Heiner
Quoted 34 lines
Kevin
Quoted 31 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/mmc/host/meson-gx-mmc.c +2
-6@@ -555,11 +555,7 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)writel (0 , host->regs +SD_EMMC_START ); host->mrq = mrq; - -if (mrq->sbc) -meson_mmc_start_cmd (mmc, mrq->sbc); -else -meson_mmc_start_cmd (mmc, mrq->cmd); +meson_mmc_start_cmd (mmc, mrq->cmd); }static int meson_mmc_read_resp (struct mmc_host *mmc,struct mmc_command *cmd)@@ -690,7 +686,7 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) }meson_mmc_read_resp (host->mmc, cmd); -if (!data || !data->stop || mrq->sbc) +if (!data || !data->stop)meson_mmc_request_done (host->mmc, mrq);else meson_mmc_start_cmd (host->mmc, data->stop);
PATCH 3/18 mmc: meson-gx: explicitely call stop command for multi-block commands only
In reply to a message not in the archiveExplicitely call stop command for multi-block commands only.
--- drivers/mmc/host/meson-gx-mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +3 -3
@@ -686,10 +686,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) }meson_mmc_read_resp (host->mmc, cmd); -if (!data || !data->stop) -meson_mmc_request_done (host->mmc, mrq); -else +if (mmc_op_multi (cmd->opcode))meson_mmc_start_cmd (host->mmc, data->stop); +else +meson_mmc_request_done (host->mmc, mrq);return IRQ_HANDLED ; }
Signature · 1 line
2.11.1
PATCH 4/18 mmc: meson-gx: improve meson_mmc_start_cmd
In reply to a message not in the archiveRemove use of unneeded members cmd_arg and cmd_resp. Setting SD_EMMC_CMD_RSP is only needed if CMD_CFG_RESP_NUM is set, so don't write this register in all other cases.
--- drivers/mmc/host/meson-gx-mmc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +2 -4
@@ -456,7 +456,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) <<CMD_CFG_CMD_INDEX_SHIFT ; desc->cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ - desc->cmd_arg = cmd->arg;/* Response */ if (cmd->flags &MMC_RSP_PRESENT ) {
@@ -464,7 +463,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)if (cmd->flags &MMC_RSP_136 ) desc->cmd_cfg |=CMD_CFG_RESP_128 ; desc->cmd_cfg |=CMD_CFG_RESP_NUM ; - desc->cmd_resp =0 ; +writel (0 , host->regs +SD_EMMC_CMD_RSP );if (!(cmd->flags &MMC_RSP_CRC )) desc->cmd_cfg |=CMD_CFG_RESP_NOCRC ;
@@ -540,9 +539,8 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |=CMD_CFG_END_OF_CHAIN ;writel (desc->cmd_cfg, host->regs +SD_EMMC_CMD_CFG );writel (desc->cmd_data, host->regs +SD_EMMC_CMD_DAT ); -writel (desc->cmd_resp, host->regs +SD_EMMC_CMD_RSP );wmb ();/* ensure descriptor is written before kicked */ -writel (desc->cmd_arg, host->regs +SD_EMMC_CMD_ARG ); +writel (cmd->arg, host->regs +SD_EMMC_CMD_ARG ); }static void meson_mmc_request (struct mmc_host *mmc,struct mmc_request *mrq)
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 4/18 mmc: meson-gx: improve meson_mmc_start_cmd
Quoted 5 lines · Heiner Kallweit
Remove use of unneeded members
cmd_argandcmd_resp. SettingSD_EMMC_CMD_RSPis only needed ifCMD_CFG_RESP_NUMis set, so don't write this register in all other cases.Signed-off-by Heiner Kallweit <[email protected]>
I'm not sure I like this change. This works now because there is only one descriptor used, but one of the next things to work on in this driver is taking advantage of the internal DMA capabilities, which means having a chain of descriptorsall filled out in memory.
Kevin
Quoted 36 lines
--- drivers/mmc/host/meson-gx-mmc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/mmc/host/meson-gx-mmc.c +2
-4@@ -456,7 +456,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) <<CMD_CFG_CMD_INDEX_SHIFT ; desc->cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ - desc->cmd_arg = cmd->arg;/* Response */ if (cmd->flags &MMC_RSP_PRESENT ) {@@ -464,7 +463,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)if (cmd->flags &MMC_RSP_136 ) desc->cmd_cfg |=CMD_CFG_RESP_128 ; desc->cmd_cfg |=CMD_CFG_RESP_NUM ; - desc->cmd_resp =0 ; +writel (0 , host->regs +SD_EMMC_CMD_RSP );if (!(cmd->flags &MMC_RSP_CRC )) desc->cmd_cfg |=CMD_CFG_RESP_NOCRC ;@@ -540,9 +539,8 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |=CMD_CFG_END_OF_CHAIN ;writel (desc->cmd_cfg, host->regs +SD_EMMC_CMD_CFG );writel (desc->cmd_data, host->regs +SD_EMMC_CMD_DAT ); -writel (desc->cmd_resp, host->regs +SD_EMMC_CMD_RSP );wmb ();/* ensure descriptor is written before kicked */ -writel (desc->cmd_arg, host->regs +SD_EMMC_CMD_ARG ); +writel (cmd->arg, host->regs +SD_EMMC_CMD_ARG ); }static void meson_mmc_request (struct mmc_host *mmc,struct mmc_request *mrq)
PATCH 4/18 mmc: meson-gx: improve meson_mmc_start_cmd
Am 15.02.2017 um 18:04 schrieb Kevin Hilman:
Quoted 6 lines
Quoted 4 lines · Heiner Kallweit
Remove use of unneeded members
cmd_argandcmd_resp. SettingSD_EMMC_CMD_RSPis only needed ifCMD_CFG_RESP_NUMis set, so don't write this register in all other cases.
Quoted 7 lines
Quoted 1 line
Signed-off-by Heiner Kallweit <[email protected]>I'm not sure I like this change. This works now because there is only one descriptor used, but one of the next things to work on in this driver is taking advantage of the internal DMA capabilities, which means having a chain of descriptorsall filled out in memory.
For testing purposes I temporarily changed the driver from passing the descriptor in registers to passing the descriptor via DMA and it worked.
I'm not very familiar (yet) with descriptor chains and have to check the MMC core code a little bit more ..
If we can actually benefit from it then I'd agree with you.
Quoted 39 lines
Kevin
Quoted 36 lines
--- drivers/mmc/host/meson-gx-mmc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/mmc/host/meson-gx-mmc.c +2
-4@@ -456,7 +456,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) <<CMD_CFG_CMD_INDEX_SHIFT ; desc->cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ - desc->cmd_arg = cmd->arg;/* Response */ if (cmd->flags &MMC_RSP_PRESENT ) {@@ -464,7 +463,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)if (cmd->flags &MMC_RSP_136 ) desc->cmd_cfg |=CMD_CFG_RESP_128 ; desc->cmd_cfg |=CMD_CFG_RESP_NUM ; - desc->cmd_resp =0 ; +writel (0 , host->regs +SD_EMMC_CMD_RSP );if (!(cmd->flags &MMC_RSP_CRC )) desc->cmd_cfg |=CMD_CFG_RESP_NOCRC ;@@ -540,9 +539,8 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |=CMD_CFG_END_OF_CHAIN ;writel (desc->cmd_cfg, host->regs +SD_EMMC_CMD_CFG );writel (desc->cmd_data, host->regs +SD_EMMC_CMD_DAT ); -writel (desc->cmd_resp, host->regs +SD_EMMC_CMD_RSP );wmb ();/* ensure descriptor is written before kicked */ -writel (desc->cmd_arg, host->regs +SD_EMMC_CMD_ARG ); +writel (cmd->arg, host->regs +SD_EMMC_CMD_ARG ); }static void meson_mmc_request (struct mmc_host *mmc,struct mmc_request *mrq)
PATCH 4/18 mmc: meson-gx: improve meson_mmc_start_cmd
Am 15.02.2017 um 20:43 schrieb Heiner Kallweit:
Quoted 14 lines
Am 15.02.2017 um 18:04 schrieb Kevin Hilman:
Quoted 6 lines
Quoted 4 lines · Heiner Kallweit
Remove use of unneeded members
cmd_argandcmd_resp. SettingSD_EMMC_CMD_RSPis only needed ifCMD_CFG_RESP_NUMis set, so don't write this register in all other cases.Quoted 7 lines
Quoted 1 line
Signed-off-by Heiner Kallweit <[email protected]>I'm not sure I like this change. This works now because there is only one descriptor used, but one of the next things to work on in this driver is taking advantage of the internal DMA capabilities, which means having a chain of descriptorsall filled out in memory.
Quoted 7 lines
For testing purposes I temporarily changed the driver from passing the descriptor in registers to passing the descriptor via DMA and it worked.
I'm not very familiar (yet) with descriptor chains and have to check the MMC core code a little bit more ..
If we can actually benefit from it then I'd agree with you.
After having had a little bit closer look at the MMC core and descriptor chains in general:
I'm not really sure where descriptor chains would help us. SG lists in read / write commands are linearized by the driver via sg_copy_[to,from]_buffer already.
Beyond that I don't see any command chaining support in the core (prerequisite for command chaining most likely would be that a subsequent command must not depend on the response of a previous one).
Maybe somebody with more knowledge about the MMC core and MMC in general can shed some light on this ..
Heiner
Quoted 41 lines
Quoted 40 lines
Kevin
Quoted 36 lines
--- drivers/mmc/host/meson-gx-mmc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/mmc/host/meson-gx-mmc.c +2
-4@@ -456,7 +456,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) <<CMD_CFG_CMD_INDEX_SHIFT ; desc->cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ - desc->cmd_arg = cmd->arg;/* Response */ if (cmd->flags &MMC_RSP_PRESENT ) {@@ -464,7 +463,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)if (cmd->flags &MMC_RSP_136 ) desc->cmd_cfg |=CMD_CFG_RESP_128 ; desc->cmd_cfg |=CMD_CFG_RESP_NUM ; - desc->cmd_resp =0 ; +writel (0 , host->regs +SD_EMMC_CMD_RSP );if (!(cmd->flags &MMC_RSP_CRC )) desc->cmd_cfg |=CMD_CFG_RESP_NOCRC ;@@ -540,9 +539,8 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |=CMD_CFG_END_OF_CHAIN ;writel (desc->cmd_cfg, host->regs +SD_EMMC_CMD_CFG );writel (desc->cmd_data, host->regs +SD_EMMC_CMD_DAT ); -writel (desc->cmd_resp, host->regs +SD_EMMC_CMD_RSP );wmb ();/* ensure descriptor is written before kicked */ -writel (desc->cmd_arg, host->regs +SD_EMMC_CMD_ARG ); +writel (cmd->arg, host->regs +SD_EMMC_CMD_ARG ); }static void meson_mmc_request (struct mmc_host *mmc,struct mmc_request *mrq)
Kevin Hilman
maintainerPATCH 4/18 mmc: meson-gx: improve meson_mmc_start_cmd
Quoted 22 lines · Heiner Kallweit
Am 15.02.2017 um 20:43 schrieb Heiner Kallweit:
Quoted 14 lines
Am 15.02.2017 um 18:04 schrieb Kevin Hilman:
Quoted 6 lines
Quoted 4 lines · Heiner Kallweit
Remove use of unneeded members
cmd_argandcmd_resp. SettingSD_EMMC_CMD_RSPis only needed ifCMD_CFG_RESP_NUMis set, so don't write this register in all other cases.Quoted 7 lines
Quoted 1 line
Signed-off-by Heiner Kallweit <[email protected]>I'm not sure I like this change. This works now because there is only one descriptor used, but one of the next things to work on in this driver is taking advantage of the internal DMA capabilities, which means having a chain of descriptorsall filled out in memory.
Quoted 7 lines
For testing purposes I temporarily changed the driver from passing the descriptor in registers to passing the descriptor via DMA and it worked.
I'm not very familiar (yet) with descriptor chains and have to check the MMC core code a little bit more ..
If we can actually benefit from it then I'd agree with you.
Quoted 5 lines
After having had a little bit closer look at the MMC core and descriptor chains in general:
I'm not really sure where descriptor chains would help us. SG lists in read / write commands are linearized by the driver via sg_copy_[to,from]_buffer already.
Copying to the bounce buffer would be replaced by creating a descriptor for each SG entry, and creating a descriptor chain.
Quoted 6 lines
Beyond that I don't see any command chaining support in the core (prerequisite for command chaining most likely would be that a subsequent command must not depend on the response of a previous one).
Maybe somebody with more knowledge about the MMC core and MMC in general can shed some light on this ..
I don't know if it's a feature of the core, but the Amlogic vendor driver does the chained descriptor handling in the driver itself.
Kevin
Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
Kevin
Quoted 36 lines
--- drivers/mmc/host/meson-gx-mmc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/mmc/host/meson-gx-mmc.c +2
-4@@ -456,7 +456,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) <<CMD_CFG_CMD_INDEX_SHIFT ; desc->cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ - desc->cmd_arg = cmd->arg;/* Response */ if (cmd->flags &MMC_RSP_PRESENT ) {@@ -464,7 +463,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)if (cmd->flags &MMC_RSP_136 ) desc->cmd_cfg |=CMD_CFG_RESP_128 ; desc->cmd_cfg |=CMD_CFG_RESP_NUM ; - desc->cmd_resp =0 ; +writel (0 , host->regs +SD_EMMC_CMD_RSP );if (!(cmd->flags &MMC_RSP_CRC )) desc->cmd_cfg |=CMD_CFG_RESP_NOCRC ;@@ -540,9 +539,8 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |=CMD_CFG_END_OF_CHAIN ;writel (desc->cmd_cfg, host->regs +SD_EMMC_CMD_CFG );writel (desc->cmd_data, host->regs +SD_EMMC_CMD_DAT ); -writel (desc->cmd_resp, host->regs +SD_EMMC_CMD_RSP );wmb ();/* ensure descriptor is written before kicked */ -writel (desc->cmd_arg, host->regs +SD_EMMC_CMD_ARG ); +writel (cmd->arg, host->regs +SD_EMMC_CMD_ARG ); }static void meson_mmc_request (struct mmc_host *mmc,struct mmc_request *mrq)
PATCH 4/18 mmc: meson-gx: improve meson_mmc_start_cmd
In reply to Kevin HilmanAm 15.02.2017 um 18:04 schrieb Kevin Hilman:
Quoted 6 lines
Quoted 4 lines · Heiner Kallweit
Remove use of unneeded members
cmd_argandcmd_resp. SettingSD_EMMC_CMD_RSPis only needed ifCMD_CFG_RESP_NUMis set, so don't write this register in all other cases.
Quoted 7 lines
Quoted 1 line
Signed-off-by Heiner Kallweit <[email protected]>I'm not sure I like this change. This works now because there is only one descriptor used, but one of the next things to work on in this driver is taking advantage of the internal DMA capabilities, which means having a chain of descriptorsall filled out in memory.
I implemented the descriptor chain mode and tests (together with CMD23 mode) resulted in 140 MB/s read performance (from a 128GB eMMC card). So I will submit this extension together with the CMD23 mode extension.
Heiner
Quoted 39 lines
Kevin
Quoted 36 lines
--- drivers/mmc/host/meson-gx-mmc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/mmc/host/meson-gx-mmc.c +2
-4@@ -456,7 +456,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) <<CMD_CFG_CMD_INDEX_SHIFT ; desc->cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ - desc->cmd_arg = cmd->arg;/* Response */ if (cmd->flags &MMC_RSP_PRESENT ) {@@ -464,7 +463,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)if (cmd->flags &MMC_RSP_136 ) desc->cmd_cfg |=CMD_CFG_RESP_128 ; desc->cmd_cfg |=CMD_CFG_RESP_NUM ; - desc->cmd_resp =0 ; +writel (0 , host->regs +SD_EMMC_CMD_RSP );if (!(cmd->flags &MMC_RSP_CRC )) desc->cmd_cfg |=CMD_CFG_RESP_NOCRC ;@@ -540,9 +539,8 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) desc->cmd_cfg |=CMD_CFG_END_OF_CHAIN ;writel (desc->cmd_cfg, host->regs +SD_EMMC_CMD_CFG );writel (desc->cmd_data, host->regs +SD_EMMC_CMD_DAT ); -writel (desc->cmd_resp, host->regs +SD_EMMC_CMD_RSP );wmb ();/* ensure descriptor is written before kicked */ -writel (desc->cmd_arg, host->regs +SD_EMMC_CMD_ARG ); +writel (cmd->arg, host->regs +SD_EMMC_CMD_ARG ); }static void meson_mmc_request (struct mmc_host *mmc,struct mmc_request *mrq)
PATCH 5/18 mmc: meson-gx: eliminate struct sd_emmc_data
In reply to a message not in the archiveStruct sd_emmc_data is used in meson_mmc_start_cmd only, so we can get rid of this struct and replace the two used members with local variables.
--- drivers/mmc/host/meson-gx-mmc.c | 69 +++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 40 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +29 -40
@@ -146,12 +146,6 @@ struct meson_host {bool vqmmc_enabled; }; -struct sd_emmc_desc { -u32 cmd_cfg; -u32 cmd_arg; -u32 cmd_data; -u32 cmd_resp; -};#define CMD_CFG_LENGTH_SHIFT 0#define CMD_CFG_LENGTH_MASK 0x1ff#define CMD_CFG_BLOCK_MODE BIT(9)
@@ -443,45 +437,41 @@ static int meson_mmc_request_done(struct mmc_host *mmc, struct mmc_request *mrq)static void meson_mmc_start_cmd (struct mmc_host *mmc,struct mmc_command *cmd) {struct meson_host *host =mmc_priv (mmc); -struct sd_emmc_desc *desc, desc_tmp; -u32 cfg; +u32 cfg, cmd_cfg =0 , cmd_data =0 ;u8 blk_len, cmd_cfg_timeout;unsigned int xfer_bytes =0 ;/* Setup descriptors */ dma_rmb (); - desc = &desc_tmp; -memset (desc,0 ,sizeof (struct sd_emmc_desc )); - desc->cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) << -CMD_CFG_CMD_INDEX_SHIFT ; - desc->cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ + cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) << +CMD_CFG_CMD_INDEX_SHIFT ; + cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ /* Response */ if (cmd->flags &MMC_RSP_PRESENT ) { - desc->cmd_cfg &= ~CMD_CFG_NO_RESP ; + cmd_cfg &= ~CMD_CFG_NO_RESP ;if (cmd->flags &MMC_RSP_136 ) - desc->cmd_cfg |=CMD_CFG_RESP_128 ; - desc->cmd_cfg |=CMD_CFG_RESP_NUM ; + cmd_cfg |=CMD_CFG_RESP_128 ; + cmd_cfg |=CMD_CFG_RESP_NUM ;writel (0 , host->regs +SD_EMMC_CMD_RSP );if (!(cmd->flags &MMC_RSP_CRC )) - desc->cmd_cfg |=CMD_CFG_RESP_NOCRC ; + cmd_cfg |=CMD_CFG_RESP_NOCRC ;if (cmd->flags &MMC_RSP_BUSY ) - desc->cmd_cfg |=CMD_CFG_R1B ; + cmd_cfg |=CMD_CFG_R1B ; }else { - desc->cmd_cfg |=CMD_CFG_NO_RESP ; + cmd_cfg |=CMD_CFG_NO_RESP ; }/* data? */ if (cmd->data) { - desc->cmd_cfg |=CMD_CFG_DATA_IO ; + cmd_cfg |=CMD_CFG_DATA_IO ;if (cmd->data->blocks >1 ) { - desc->cmd_cfg |=CMD_CFG_BLOCK_MODE ; - desc->cmd_cfg |= - (cmd->data->blocks &CMD_CFG_LENGTH_MASK ) << -CMD_CFG_LENGTH_SHIFT ; + cmd_cfg |=CMD_CFG_BLOCK_MODE ; + cmd_cfg |= (cmd->data->blocks &CMD_CFG_LENGTH_MASK ) << +CMD_CFG_LENGTH_SHIFT ;/* check if block-size matches, if not update */ cfg =readl (host->regs +SD_EMMC_CFG );
@@ -497,48 +487,47 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)writel (cfg, host->regs +SD_EMMC_CFG ); } }else { - desc->cmd_cfg &= ~CMD_CFG_BLOCK_MODE ; - desc->cmd_cfg |= - (cmd->data->blksz &CMD_CFG_LENGTH_MASK ) << -CMD_CFG_LENGTH_SHIFT ; + cmd_cfg &= ~CMD_CFG_BLOCK_MODE ; + cmd_cfg |= (cmd->data->blksz &CMD_CFG_LENGTH_MASK ) << +CMD_CFG_LENGTH_SHIFT ; } cmd->data->bytes_xfered =0 ; xfer_bytes = cmd->data->blksz * cmd->data->blocks;if (cmd->data->flags &MMC_DATA_WRITE ) { - desc->cmd_cfg |=CMD_CFG_DATA_WR ; + cmd_cfg |=CMD_CFG_DATA_WR ;WARN_ON (xfer_bytes > host->bounce_buf_size);sg_copy_to_buffer (cmd->data->sg, cmd->data->sg_len, host->bounce_buf, xfer_bytes); cmd->data->bytes_xfered = xfer_bytes;dma_wmb (); }else { - desc->cmd_cfg &= ~CMD_CFG_DATA_WR ; + cmd_cfg &= ~CMD_CFG_DATA_WR ; }if (xfer_bytes >0 ) { - desc->cmd_cfg &= ~CMD_CFG_DATA_NUM ; - desc->cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ; + cmd_cfg &= ~CMD_CFG_DATA_NUM ; + cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ; }else {/* write data to data_addr */ - desc->cmd_cfg |=CMD_CFG_DATA_NUM ; - desc->cmd_data =0 ; + cmd_cfg |=CMD_CFG_DATA_NUM ; + cmd_data =0 ; } cmd_cfg_timeout =12 ; }else { - desc->cmd_cfg &= ~CMD_CFG_DATA_IO ; + cmd_cfg &= ~CMD_CFG_DATA_IO ; cmd_cfg_timeout =10 ; } - desc->cmd_cfg |= (cmd_cfg_timeout &CMD_CFG_TIMEOUT_MASK ) << -CMD_CFG_TIMEOUT_SHIFT ; + cmd_cfg |= (cmd_cfg_timeout &CMD_CFG_TIMEOUT_MASK ) << +CMD_CFG_TIMEOUT_SHIFT ; host->cmd = cmd;/* Last descriptor */ - desc->cmd_cfg |=CMD_CFG_END_OF_CHAIN ; -writel (desc->cmd_cfg, host->regs +SD_EMMC_CMD_CFG ); -writel (desc->cmd_data, host->regs +SD_EMMC_CMD_DAT ); + cmd_cfg |=CMD_CFG_END_OF_CHAIN ; +writel (cmd_cfg, host->regs +SD_EMMC_CMD_CFG ); +writel (cmd_data, host->regs +SD_EMMC_CMD_DAT );wmb ();/* ensure descriptor is written before kicked */ writel (cmd->arg, host->regs +SD_EMMC_CMD_ARG ); }
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 5/18 mmc: meson-gx: eliminate struct sd_emmc_data
Quoted 4 lines · Heiner Kallweit
Struct
sd_emmc_datais used inmeson_mmc_start_cmdonly, so we can get rid of this struct and replace the two used members with local variables.Signed-off-by Heiner Kallweit <[email protected]>
For the same reasons as the previous patch, I don't like this change as I think it will be much cleaner code if we keep this descriptor struct and use it to fill out multiple descriptors in a chain.
Kevin
Quoted 145 lines
--- drivers/mmc/host/meson-gx-mmc.c | 69 +++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 40 deletions(-)drivers/mmc/host/meson-gx-mmc.c +29
-40@@ -146,12 +146,6 @@ struct meson_host {bool vqmmc_enabled; }; -struct sd_emmc_desc { -u32 cmd_cfg; -u32 cmd_arg; -u32 cmd_data; -u32 cmd_resp; -};#define CMD_CFG_LENGTH_SHIFT 0#define CMD_CFG_LENGTH_MASK 0x1ff#define CMD_CFG_BLOCK_MODE BIT(9)@@ -443,45 +437,41 @@ static int meson_mmc_request_done(struct mmc_host *mmc, struct mmc_request *mrq)static void meson_mmc_start_cmd (struct mmc_host *mmc,struct mmc_command *cmd) {struct meson_host *host =mmc_priv (mmc); -struct sd_emmc_desc *desc, desc_tmp; -u32 cfg; +u32 cfg, cmd_cfg =0 , cmd_data =0 ;u8 blk_len, cmd_cfg_timeout;unsigned int xfer_bytes =0 ;/* Setup descriptors */ dma_rmb (); - desc = &desc_tmp; -memset (desc,0 ,sizeof (struct sd_emmc_desc )); - desc->cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) << -CMD_CFG_CMD_INDEX_SHIFT ; - desc->cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ + cmd_cfg |= (cmd->opcode &CMD_CFG_CMD_INDEX_MASK ) << +CMD_CFG_CMD_INDEX_SHIFT ; + cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ /* Response */ if (cmd->flags &MMC_RSP_PRESENT ) { - desc->cmd_cfg &= ~CMD_CFG_NO_RESP ; + cmd_cfg &= ~CMD_CFG_NO_RESP ;if (cmd->flags &MMC_RSP_136 ) - desc->cmd_cfg |=CMD_CFG_RESP_128 ; - desc->cmd_cfg |=CMD_CFG_RESP_NUM ; + cmd_cfg |=CMD_CFG_RESP_128 ; + cmd_cfg |=CMD_CFG_RESP_NUM ;writel (0 , host->regs +SD_EMMC_CMD_RSP );if (!(cmd->flags &MMC_RSP_CRC )) - desc->cmd_cfg |=CMD_CFG_RESP_NOCRC ; + cmd_cfg |=CMD_CFG_RESP_NOCRC ;if (cmd->flags &MMC_RSP_BUSY ) - desc->cmd_cfg |=CMD_CFG_R1B ; + cmd_cfg |=CMD_CFG_R1B ; }else { - desc->cmd_cfg |=CMD_CFG_NO_RESP ; + cmd_cfg |=CMD_CFG_NO_RESP ; }/* data? */ if (cmd->data) { - desc->cmd_cfg |=CMD_CFG_DATA_IO ; + cmd_cfg |=CMD_CFG_DATA_IO ;if (cmd->data->blocks >1 ) { - desc->cmd_cfg |=CMD_CFG_BLOCK_MODE ; - desc->cmd_cfg |= - (cmd->data->blocks &CMD_CFG_LENGTH_MASK ) << -CMD_CFG_LENGTH_SHIFT ; + cmd_cfg |=CMD_CFG_BLOCK_MODE ; + cmd_cfg |= (cmd->data->blocks &CMD_CFG_LENGTH_MASK ) << +CMD_CFG_LENGTH_SHIFT ;/* check if block-size matches, if not update */ cfg =readl (host->regs +SD_EMMC_CFG );@@ -497,48 +487,47 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)writel (cfg, host->regs +SD_EMMC_CFG ); } }else { - desc->cmd_cfg &= ~CMD_CFG_BLOCK_MODE ; - desc->cmd_cfg |= - (cmd->data->blksz &CMD_CFG_LENGTH_MASK ) << -CMD_CFG_LENGTH_SHIFT ; + cmd_cfg &= ~CMD_CFG_BLOCK_MODE ; + cmd_cfg |= (cmd->data->blksz &CMD_CFG_LENGTH_MASK ) << +CMD_CFG_LENGTH_SHIFT ; } cmd->data->bytes_xfered =0 ; xfer_bytes = cmd->data->blksz * cmd->data->blocks;if (cmd->data->flags &MMC_DATA_WRITE ) { - desc->cmd_cfg |=CMD_CFG_DATA_WR ; + cmd_cfg |=CMD_CFG_DATA_WR ;WARN_ON (xfer_bytes > host->bounce_buf_size);sg_copy_to_buffer (cmd->data->sg, cmd->data->sg_len, host->bounce_buf, xfer_bytes); cmd->data->bytes_xfered = xfer_bytes;dma_wmb (); }else { - desc->cmd_cfg &= ~CMD_CFG_DATA_WR ; + cmd_cfg &= ~CMD_CFG_DATA_WR ; }if (xfer_bytes >0 ) { - desc->cmd_cfg &= ~CMD_CFG_DATA_NUM ; - desc->cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ; + cmd_cfg &= ~CMD_CFG_DATA_NUM ; + cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ; }else {/* write data to data_addr */ - desc->cmd_cfg |=CMD_CFG_DATA_NUM ; - desc->cmd_data =0 ; + cmd_cfg |=CMD_CFG_DATA_NUM ; + cmd_data =0 ; } cmd_cfg_timeout =12 ; }else { - desc->cmd_cfg &= ~CMD_CFG_DATA_IO ; + cmd_cfg &= ~CMD_CFG_DATA_IO ; cmd_cfg_timeout =10 ; } - desc->cmd_cfg |= (cmd_cfg_timeout &CMD_CFG_TIMEOUT_MASK ) << -CMD_CFG_TIMEOUT_SHIFT ; + cmd_cfg |= (cmd_cfg_timeout &CMD_CFG_TIMEOUT_MASK ) << +CMD_CFG_TIMEOUT_SHIFT ; host->cmd = cmd;/* Last descriptor */ - desc->cmd_cfg |=CMD_CFG_END_OF_CHAIN ; -writel (desc->cmd_cfg, host->regs +SD_EMMC_CMD_CFG ); -writel (desc->cmd_data, host->regs +SD_EMMC_CMD_DAT ); + cmd_cfg |=CMD_CFG_END_OF_CHAIN ; +writel (cmd_cfg, host->regs +SD_EMMC_CMD_CFG ); +writel (cmd_data, host->regs +SD_EMMC_CMD_DAT );wmb ();/* ensure descriptor is written before kicked */ writel (cmd->arg, host->regs +SD_EMMC_CMD_ARG ); }
PATCH 6/18 mmc: meson-gx: simplify bounce buffer setting in meson_mmc_start_cmd
In reply to a message not in the archiveIf xfer_bytes is zero we can configure the chip to use the bounce buffer as well because it won't get used anyway.
And we don't have to reset bit CMD_CFG_DATA_NUM because cmd_cfg was zero-initialized and this bit isn't set.
--- drivers/mmc/host/meson-gx-mmc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +1 -9
@@ -505,15 +505,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) cmd_cfg &= ~CMD_CFG_DATA_WR ; } -if (xfer_bytes >0 ) { - cmd_cfg &= ~CMD_CFG_DATA_NUM ; - cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ; - }else { -/* write data to data_addr */ - cmd_cfg |=CMD_CFG_DATA_NUM ; - cmd_data =0 ; - } - + cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ; cmd_cfg_timeout =12 ; }else { cmd_cfg &= ~CMD_CFG_DATA_IO ;
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 6/18 mmc: meson-gx: simplify bounce buffer setting in meson_mmc_start_cmd
Quoted 18 lines · Heiner Kallweit
If
xfer_bytesis zero we can configure the chip to use the bounce buffer as well because it won't get used anyway.
And we don't have to reset bitCMD_CFG_DATA_NUMbecausecmd_cfgwas zero-initialized and this bit isn't set.Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/mmc/host/meson-gx-mmc.c +0
-0@@ -505,15 +505,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) cmd_cfg &= ~CMD_CFG_DATA_WR ; }
drivers/mmc/host/meson-gx-mmc.c static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) · line 508
Quoted 10 lines
drivers/mmc/host/meson-gx-mmc.c +1
-9-if (xfer_bytes >0 ) { - cmd_cfg &= ~CMD_CFG_DATA_NUM ; - cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ; - }else { -/* write data to data_addr */ - cmd_cfg |=CMD_CFG_DATA_NUM ; - cmd_data =0 ; - } - + cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ;
Could use a comment above this, mentioning (similar to the changelog) that when CMD_CFG_DATA_NUM is set, this isn't used.
Otherwise:
PATCH 7/18 mmc: meson-gx: check return value of sg_copy_[from,to]_buffer
In reply to a message not in the archiveSo far it's only checked whether the requested transfer length exceeds the bounce buffer size. Instead let's check that sg_copy_[from,to]_buffer transferred exactly the number of requested bytes.
--- drivers/mmc/host/meson-gx-mmc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +10 -9
@@ -495,14 +495,14 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) cmd->data->bytes_xfered =0 ; xfer_bytes = cmd->data->blksz * cmd->data->blocks;if (cmd->data->flags &MMC_DATA_WRITE ) { - cmd_cfg |=CMD_CFG_DATA_WR ; -WARN_ON (xfer_bytes > host->bounce_buf_size); -sg_copy_to_buffer (cmd->data->sg, cmd->data->sg_len, - host->bounce_buf, xfer_bytes); +size_t len =sg_copy_to_buffer (cmd->data->sg, + cmd->data->sg_len, + host->bounce_buf, + host->bounce_buf_size); +WARN_ON (len != xfer_bytes); cmd->data->bytes_xfered = xfer_bytes; + cmd_cfg |=CMD_CFG_DATA_WR ;dma_wmb (); - }else { - cmd_cfg &= ~CMD_CFG_DATA_WR ; } cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ;
@@ -657,10 +657,11 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) data = cmd->data;if (data && data->flags &MMC_DATA_READ ) { +size_t len =sg_copy_from_buffer (data->sg, data->sg_len, + host->bounce_buf, + host->bounce_buf_size); xfer_bytes = data->blksz * data->blocks; -WARN_ON (xfer_bytes > host->bounce_buf_size); -sg_copy_from_buffer (data->sg, data->sg_len, - host->bounce_buf, xfer_bytes); +WARN_ON (len != xfer_bytes); data->bytes_xfered = xfer_bytes; }
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 7/18 mmc: meson-gx: check return value of sg_copy_[from, to]_buffer
Quoted 5 lines · Heiner Kallweit
So far it's only checked whether the requested transfer length exceeds the bounce buffer size. Instead let's check that sg_copy_[from,to]_buffer transferred exactly the number of requested bytes.
Signed-off-by Heiner Kallweit <[email protected]>
Quoted 43 lines
--- drivers/mmc/host/meson-gx-mmc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)drivers/mmc/host/meson-gx-mmc.c +10
-9@@ -495,14 +495,14 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) cmd->data->bytes_xfered =0 ; xfer_bytes = cmd->data->blksz * cmd->data->blocks;if (cmd->data->flags &MMC_DATA_WRITE ) { - cmd_cfg |=CMD_CFG_DATA_WR ; -WARN_ON (xfer_bytes > host->bounce_buf_size); -sg_copy_to_buffer (cmd->data->sg, cmd->data->sg_len, - host->bounce_buf, xfer_bytes); +size_t len =sg_copy_to_buffer (cmd->data->sg, + cmd->data->sg_len, + host->bounce_buf, + host->bounce_buf_size); +WARN_ON (len != xfer_bytes); cmd->data->bytes_xfered = xfer_bytes; + cmd_cfg |=CMD_CFG_DATA_WR ;dma_wmb (); - }else { - cmd_cfg &= ~CMD_CFG_DATA_WR ; } cmd_data = host->bounce_dma_addr &CMD_DATA_MASK ;@@ -657,10 +657,11 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) data = cmd->data;if (data && data->flags &MMC_DATA_READ ) { +size_t len =sg_copy_from_buffer (data->sg, data->sg_len, + host->bounce_buf, + host->bounce_buf_size); xfer_bytes = data->blksz * data->blocks; -WARN_ON (xfer_bytes > host->bounce_buf_size); -sg_copy_from_buffer (data->sg, data->sg_len, - host->bounce_buf, xfer_bytes); +WARN_ON (len != xfer_bytes); data->bytes_xfered = xfer_bytes; }
PATCH 8/18 mmc: meson-gx: make two functions return void
In reply to a message not in the archiveThe return value of meson_mmc_request_done and meson_mmc_read_resp isn't used, so make both functions return void.
--- drivers/mmc/host/meson-gx-mmc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +3 -6
@@ -421,7 +421,8 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) __func__, orig, val); } -static int meson_mmc_request_done (struct mmc_host *mmc,struct mmc_request *mrq) +static void meson_mmc_request_done (struct mmc_host *mmc, +struct mmc_request *mrq) {struct meson_host *host =mmc_priv (mmc);
@@ -430,8 +431,6 @@ static int meson_mmc_request_done(struct mmc_host *mmc, struct mmc_request *mrq) host->mrq =NULL ; host->cmd =NULL ;mmc_request_done (host->mmc, mrq); - -return 0 ; }static void meson_mmc_start_cmd (struct mmc_host *mmc,struct mmc_command *cmd)
@@ -537,7 +536,7 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)meson_mmc_start_cmd (mmc, mrq->cmd); } -static int meson_mmc_read_resp (struct mmc_host *mmc,struct mmc_command *cmd) +static void meson_mmc_read_resp (struct mmc_host *mmc,struct mmc_command *cmd) {struct meson_host *host =mmc_priv (mmc);
@@ -549,8 +548,6 @@ static int meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd) }else if (cmd->flags &MMC_RSP_PRESENT ) { cmd->resp[0 ] =readl (host->regs +SD_EMMC_CMD_RSP ); } - -return 0 ; }static irqreturn_t meson_mmc_irq (int irq,void *dev_id)
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 8/18 mmc: meson-gx: make two functions return void
Quoted 4 lines · Heiner Kallweit
The return value of
meson_mmc_request_doneandmeson_mmc_read_respisn't used, so make both functions return void.Signed-off-by Heiner Kallweit <[email protected]>
Quoted 45 lines
--- drivers/mmc/host/meson-gx-mmc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/mmc/host/meson-gx-mmc.c +3
-6@@ -421,7 +421,8 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) __func__, orig, val); } -static int meson_mmc_request_done (struct mmc_host *mmc,struct mmc_request *mrq) +static void meson_mmc_request_done (struct mmc_host *mmc, +struct mmc_request *mrq) {struct meson_host *host =mmc_priv (mmc);@@ -430,8 +431,6 @@ static int meson_mmc_request_done(struct mmc_host *mmc, struct mmc_request *mrq) host->mrq =NULL ; host->cmd =NULL ;mmc_request_done (host->mmc, mrq); - -return 0 ; }static void meson_mmc_start_cmd (struct mmc_host *mmc,struct mmc_command *cmd)@@ -537,7 +536,7 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)meson_mmc_start_cmd (mmc, mrq->cmd); } -static int meson_mmc_read_resp (struct mmc_host *mmc,struct mmc_command *cmd) +static void meson_mmc_read_resp (struct mmc_host *mmc,struct mmc_command *cmd) {struct meson_host *host =mmc_priv (mmc);@@ -549,8 +548,6 @@ static int meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd) }else if (cmd->flags &MMC_RSP_PRESENT ) { cmd->resp[0 ] =readl (host->regs +SD_EMMC_CMD_RSP ); } - -return 0 ; }static irqreturn_t meson_mmc_irq (int irq,void *dev_id)
PATCH 9/18 mmc: meson-gx: change interrupt name
In reply to a message not in the archiveSo far the driver name is used for the interrupt. Therefore in /proc/interrupts we can't tell which interrupt belongs to which SD_EMMC port.
So let's use the device name instead (what is the OF node name).
--- drivers/mmc/host/meson-gx-mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +3 -3
@@ -757,9 +757,9 @@ static int meson_mmc_probe(struct platform_device *pdev)writel (IRQ_EN_MASK , host->regs +SD_EMMC_STATUS );writel (IRQ_EN_MASK , host->regs +SD_EMMC_IRQ_EN ); - ret =devm_request_threaded_irq (&pdev->dev, host->irq, - meson_mmc_irq, meson_mmc_irq_thread, -IRQF_SHARED ,DRIVER_NAME , host); + ret =devm_request_threaded_irq (&pdev->dev, host->irq, meson_mmc_irq, + meson_mmc_irq_thread,IRQF_SHARED , +dev_name (&pdev->dev), host);if (ret) goto free_host;
Signature · 1 line
2.11.1
PATCH 9/18 mmc: meson-gx: change interrupt name
Quoted 17 lines · Heiner Kallweit
So far the driver name is used for the interrupt. Therefore in
/proc/interruptswe can't tell which interrupt belongs to whichSD_EMMCport.
So let's use the device name instead (what is the OF node name).Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/mmc/host/meson-gx-mmc.c +0
-0@@ -757,9 +757,9 @@ static int meson_mmc_probe(struct platform_device *pdev)writel (IRQ_EN_MASK , host->regs +SD_EMMC_STATUS );writel (IRQ_EN_MASK , host->regs +SD_EMMC_IRQ_EN );
drivers/mmc/host/meson-gx-mmc.c static int meson_mmc_probe(struct platform_device *pdev) · line 765
Quoted 10 lines
drivers/mmc/host/meson-gx-mmc.c +3
-3- ret =devm_request_threaded_irq (&pdev->dev, host->irq, - meson_mmc_irq, meson_mmc_irq_thread, -IRQF_SHARED ,DRIVER_NAME , host); + ret =devm_request_threaded_irq (&pdev->dev, host->irq, meson_mmc_irq, + meson_mmc_irq_thread,IRQF_SHARED , +dev_name (&pdev->dev), host);if (ret) goto free_host;
I am surpised that the default is not to use dev_name(dev), I wonder if that should be something that devm_request_threaded_irq() could be updated to do.
Signature · 2 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius
PATCH 9/18 mmc: meson-gx: change interrupt name
Am 15.02.2017 um 13:34 schrieb Ben Dooks:
Quoted 19 lines · Heiner Kallweit
Quoted 18 lines
So far the driver name is used for the interrupt. Therefore in
/proc/interruptswe can't tell which interrupt belongs to whichSD_EMMCport.
So let's use the device name instead (what is the OF node name).Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/mmc/host/meson-gx-mmc.c +0
-0@@ -757,9 +757,9 @@ static int meson_mmc_probe(struct platform_device *pdev)writel (IRQ_EN_MASK , host->regs +SD_EMMC_STATUS );writel (IRQ_EN_MASK , host->regs +SD_EMMC_IRQ_EN );
Quoted 14 lines
drivers/mmc/host/meson-gx-mmc.c static int meson_mmc_probe(struct platform_device *pdev) · line 765
Quoted 9 lines
drivers/mmc/host/meson-gx-mmc.c +3
-3- ret =devm_request_threaded_irq (&pdev->dev, host->irq, - meson_mmc_irq, meson_mmc_irq_thread, -IRQF_SHARED ,DRIVER_NAME , host); + ret =devm_request_threaded_irq (&pdev->dev, host->irq, meson_mmc_irq, + meson_mmc_irq_thread,IRQF_SHARED , +dev_name (&pdev->dev), host);if (ret) goto free_host;I am surpised that the default is not to use
dev_name(dev), I wonder if that should be something thatdevm_request_threaded_irq()could be updated to do.
I asked myself the same question and submitted a patch:
https://lkml.org/lkml/2017/2/12/80
Quoted 1 line
Kevin Hilman
maintainerPATCH 9/18 mmc: meson-gx: change interrupt name
In reply to Heiner KallweitQuoted 6 lines · Heiner Kallweit
So far the driver name is used for the interrupt. Therefore in
/proc/interruptswe can't tell which interrupt belongs to whichSD_EMMCport.
So let's use the device name instead (what is the OF node name).Signed-off-by Heiner Kallweit <[email protected]>
Quoted 20 lines
--- drivers/mmc/host/meson-gx-mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/mmc/host/meson-gx-mmc.c +3
-3@@ -757,9 +757,9 @@ static int meson_mmc_probe(struct platform_device *pdev)writel (IRQ_EN_MASK , host->regs +SD_EMMC_STATUS );writel (IRQ_EN_MASK , host->regs +SD_EMMC_IRQ_EN ); - ret =devm_request_threaded_irq (&pdev->dev, host->irq, - meson_mmc_irq, meson_mmc_irq_thread, -IRQF_SHARED ,DRIVER_NAME , host); + ret =devm_request_threaded_irq (&pdev->dev, host->irq, meson_mmc_irq, + meson_mmc_irq_thread,IRQF_SHARED , +dev_name (&pdev->dev), host);if (ret) goto free_host;
PATCH 10/18 mmc: meson-gx: remove unused members irq, ocr_mask from struct meson_host
In reply to a message not in the archiveMember ocr_mask is never used and member irq we can replace with a local variable in meson_mmc_probe. So let's remove both members.
--- drivers/mmc/host/meson-gx-mmc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +4 -6
@@ -128,8 +128,6 @@ struct meson_host {spinlock_t lock;void __iomem *regs; -int irq; -u32 ocr_mask;struct clk *core_clk;struct clk_mux mux;struct clk *mux_clk;
@@ -696,7 +694,7 @@ static int meson_mmc_probe(struct platform_device *pdev)struct resource *res;struct meson_host *host;struct mmc_host *mmc; -int ret; +int ret, irq; mmc =mmc_alloc_host (sizeof (struct meson_host ), &pdev->dev);if (!mmc)
@@ -728,8 +726,8 @@ static int meson_mmc_probe(struct platform_device *pdev) goto free_host; } - host->irq =platform_get_irq (pdev,0 ); -if (host->irq ==0 ) { + irq =platform_get_irq (pdev,0 ); +if (!irq) {dev_err (&pdev->dev,"failed to get interrupt resource.\n" ); ret = -EINVAL ; goto free_host;
@@ -757,7 +755,7 @@ static int meson_mmc_probe(struct platform_device *pdev)writel (IRQ_EN_MASK , host->regs +SD_EMMC_STATUS );writel (IRQ_EN_MASK , host->regs +SD_EMMC_IRQ_EN ); - ret =devm_request_threaded_irq (&pdev->dev, host->irq, meson_mmc_irq, + ret =devm_request_threaded_irq (&pdev->dev, irq, meson_mmc_irq, meson_mmc_irq_thread,IRQF_SHARED ,dev_name (&pdev->dev), host);if (ret)
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 10/18 mmc: meson-gx: remove unused members irq, ocr_mask from struct meson_host
Quoted 4 lines · Heiner Kallweit
Member
ocr_maskis never used and member irq we can replace with a local variable inmeson_mmc_probe. So let's remove both members.Signed-off-by Heiner Kallweit <[email protected]>
Quoted 46 lines
--- drivers/mmc/host/meson-gx-mmc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/mmc/host/meson-gx-mmc.c +4
-6@@ -128,8 +128,6 @@ struct meson_host {spinlock_t lock;void __iomem *regs; -int irq; -u32 ocr_mask;struct clk *core_clk;struct clk_mux mux;struct clk *mux_clk;@@ -696,7 +694,7 @@ static int meson_mmc_probe(struct platform_device *pdev)struct resource *res;struct meson_host *host;struct mmc_host *mmc; -int ret; +int ret, irq; mmc =mmc_alloc_host (sizeof (struct meson_host ), &pdev->dev);if (!mmc)@@ -728,8 +726,8 @@ static int meson_mmc_probe(struct platform_device *pdev) goto free_host; } - host->irq =platform_get_irq (pdev,0 ); -if (host->irq ==0 ) { + irq =platform_get_irq (pdev,0 ); +if (!irq) {dev_err (&pdev->dev,"failed to get interrupt resource.\n" ); ret = -EINVAL ; goto free_host;@@ -757,7 +755,7 @@ static int meson_mmc_probe(struct platform_device *pdev)writel (IRQ_EN_MASK , host->regs +SD_EMMC_STATUS );writel (IRQ_EN_MASK , host->regs +SD_EMMC_IRQ_EN ); - ret =devm_request_threaded_irq (&pdev->dev, host->irq, meson_mmc_irq, + ret =devm_request_threaded_irq (&pdev->dev, irq, meson_mmc_irq, meson_mmc_irq_thread,IRQF_SHARED ,dev_name (&pdev->dev), host);if (ret)
PATCH 11/18 mmc: meson-gx: remove unneeded variable in meson_mmc_clk_init
In reply to a message not in the archiveVariable mux_parent_count can be replaced with constant MUX_CLK_NUM_PARENTS, so remove it.
--- drivers/mmc/host/meson-gx-mmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +1 -3
@@ -237,7 +237,6 @@ static int meson_mmc_clk_init(struct meson_host *host)char clk_name[32 ];int i, ret =0 ;const char *mux_parent_names[MUX_CLK_NUM_PARENTS ]; -unsigned int mux_parent_count =0 ;const char *clk_div_parents[1 ];u32 clk_reg, cfg;
@@ -256,7 +255,6 @@ static int meson_mmc_clk_init(struct meson_host *host) } mux_parent_names[i] =__clk_get_name (host->mux_parent[i]); - mux_parent_count++; }/* create the mux */
@@ -265,7 +263,7 @@ static int meson_mmc_clk_init(struct meson_host *host) init.ops = &clk_mux_ops; init.flags =0 ; init.parent_names = mux_parent_names; - init.num_parents = mux_parent_count; + init.num_parents =MUX_CLK_NUM_PARENTS ; host->mux.reg = host->regs +SD_EMMC_CLOCK ; host->mux.shift =CLK_SRC_SHIFT ;
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 11/18 mmc: meson-gx: remove unneeded variable in meson_mmc_clk_init
Quoted 2 lines · Heiner Kallweit
Variable
mux_parent_countcan be replaced with constantMUX_CLK_NUM_PARENTS, so remove it.
Before the above sentence, add "Because the DT requires a fixed number of mux parent clocks, ..."
Quoted 1 line
Signed-off-by Heiner Kallweit <[email protected]>
With that,
Quoted 33 lines
--- drivers/mmc/host/meson-gx-mmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/mmc/host/meson-gx-mmc.c +1
-3@@ -237,7 +237,6 @@ static int meson_mmc_clk_init(struct meson_host *host)char clk_name[32 ];int i, ret =0 ;const char *mux_parent_names[MUX_CLK_NUM_PARENTS ]; -unsigned int mux_parent_count =0 ;const char *clk_div_parents[1 ];u32 clk_reg, cfg;@@ -256,7 +255,6 @@ static int meson_mmc_clk_init(struct meson_host *host) } mux_parent_names[i] =__clk_get_name (host->mux_parent[i]); - mux_parent_count++; }/* create the mux */ @@ -265,7 +263,7 @@ static int meson_mmc_clk_init(struct meson_host *host) init.ops = &clk_mux_ops; init.flags =0 ; init.parent_names = mux_parent_names; - init.num_parents = mux_parent_count; + init.num_parents =MUX_CLK_NUM_PARENTS ; host->mux.reg = host->regs +SD_EMMC_CLOCK ; host->mux.shift =CLK_SRC_SHIFT ;
PATCH 12/18 mmc: meson-gx: remove member parent_mux from struct meson_host
In reply to a message not in the archiveMember mux_parent isn't used outside meson_mmc_clk_init. So remove it and replace it with a local variable in meson_mmc_clk_init.
--- drivers/mmc/host/meson-gx-mmc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +6 -8
@@ -131,7 +131,6 @@ struct meson_host {struct clk *core_clk;struct clk_mux mux;struct clk *mux_clk; -struct clk *mux_parent[MUX_CLK_NUM_PARENTS ];unsigned long current_clock;struct clk_divider cfg_div;
@@ -242,19 +241,18 @@ static int meson_mmc_clk_init(struct meson_host *host)/* get the mux parents */ for (i =0 ; i <MUX_CLK_NUM_PARENTS ; i++) { +struct clk *clk;char name[16 ];snprintf (name,sizeof (name),"clkin%d" , i); - host->mux_parent[i] =devm_clk_get (host->dev, name); -if (IS_ERR (host->mux_parent[i])) { - ret =PTR_ERR (host->mux_parent[i]); -if (PTR_ERR (host->mux_parent[i]) != -EPROBE_DEFER ) + clk =devm_clk_get (host->dev, name); +if (IS_ERR (clk)) { +if (clk !=ERR_PTR (-EPROBE_DEFER ))dev_err (host->dev,"Missing clock %s\n" , name); - host->mux_parent[i] =NULL ; -return ret; +return PTR_ERR (clk); } - mux_parent_names[i] =__clk_get_name (host->mux_parent[i]); + mux_parent_names[i] =__clk_get_name (clk); }/* create the mux */
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 12/18 mmc: meson-gx: remove member parent_mux from struct meson_host
Quoted 4 lines · Heiner Kallweit
Member
mux_parentisn't used outsidemeson_mmc_clk_init. So remove it and replace it with a local variable inmeson_mmc_clk_init.Signed-off-by Heiner Kallweit <[email protected]>
Quoted 42 lines
--- drivers/mmc/host/meson-gx-mmc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)drivers/mmc/host/meson-gx-mmc.c +6
-8@@ -131,7 +131,6 @@ struct meson_host {struct clk *core_clk;struct clk_mux mux;struct clk *mux_clk; -struct clk *mux_parent[MUX_CLK_NUM_PARENTS ];unsigned long current_clock;struct clk_divider cfg_div;@@ -242,19 +241,18 @@ static int meson_mmc_clk_init(struct meson_host *host)/* get the mux parents */ for (i =0 ; i <MUX_CLK_NUM_PARENTS ; i++) { +struct clk *clk;char name[16 ];snprintf (name,sizeof (name),"clkin%d" , i); - host->mux_parent[i] =devm_clk_get (host->dev, name); -if (IS_ERR (host->mux_parent[i])) { - ret =PTR_ERR (host->mux_parent[i]); -if (PTR_ERR (host->mux_parent[i]) != -EPROBE_DEFER ) + clk =devm_clk_get (host->dev, name); +if (IS_ERR (clk)) { +if (clk !=ERR_PTR (-EPROBE_DEFER ))dev_err (host->dev,"Missing clock %s\n" , name); - host->mux_parent[i] =NULL ; -return ret; +return PTR_ERR (clk); } - mux_parent_names[i] =__clk_get_name (host->mux_parent[i]); + mux_parent_names[i] =__clk_get_name (clk); }/* create the mux */
PATCH 13/18 mmc: meson-gx: remove unneeded meson_mmc_clk_set in meson_mmc_clk_init
In reply to a message not in the archiveI don't think this clk_disable_unprepare is right here. We do this in meson_mmc_remove what should be sufficient.
--- drivers/mmc/host/meson-gx-mmc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +1 -5
@@ -315,11 +315,7 @@ static int meson_mmc_clk_init(struct meson_host *host)/* Get the nearest minimum clock to 400KHz */ host->mmc->f_min =clk_round_rate (host->cfg_div_clk,400000 ); - ret =meson_mmc_clk_set (host, host->mmc->f_min); -if (!ret) -clk_disable_unprepare (host->cfg_div_clk); - -return ret; +return meson_mmc_clk_set (host, host->mmc->f_min); }static void meson_mmc_set_ios (struct mmc_host *mmc,struct mmc_ios *ios)
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 13/18 mmc: meson-gx: remove unneeded meson_mmc_clk_set in meson_mmc_clk_init
Quoted 2 lines · Heiner Kallweit
I don't think this
clk_disable_unprepareis right here. We do this inmeson_mmc_removewhat should be sufficient.
I don't think so, because if _clk_init() fails, then _probe will fail, and the driver's ->remove() will not be called.
Kevin
Quoted 22 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/mmc/host/meson-gx-mmc.c +1
-5@@ -315,11 +315,7 @@ static int meson_mmc_clk_init(struct meson_host *host)/* Get the nearest minimum clock to 400KHz */ host->mmc->f_min =clk_round_rate (host->cfg_div_clk,400000 ); - ret =meson_mmc_clk_set (host, host->mmc->f_min); -if (!ret) -clk_disable_unprepare (host->cfg_div_clk); - -return ret; +return meson_mmc_clk_set (host, host->mmc->f_min); }static void meson_mmc_set_ios (struct mmc_host *mmc,struct mmc_ios *ios)
PATCH 13/18 mmc: meson-gx: remove unneeded meson_mmc_clk_set in meson_mmc_clk_init
Am 15.02.2017 um 20:27 schrieb Kevin Hilman:
Quoted 8 lines
Quoted 2 lines · Heiner Kallweit
I don't think this
clk_disable_unprepareis right here. We do this inmeson_mmc_removewhat should be sufficient.I don't think so, because if
_clk_init()fails, then_probewill fail, and the driver's ->remove() will not be called.
In general, then the condition should be "if (ret)", not "if (!ret)". And if _clk_init() fails, then probe jumps to label free_host, where we have exactly this clk_disable_unprepare(host->cfg_div_clk)
Heiner
Quoted 25 lines
Kevin
Quoted 22 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/mmc/host/meson-gx-mmc.c +1
-5@@ -315,11 +315,7 @@ static int meson_mmc_clk_init(struct meson_host *host)/* Get the nearest minimum clock to 400KHz */ host->mmc->f_min =clk_round_rate (host->cfg_div_clk,400000 ); - ret =meson_mmc_clk_set (host, host->mmc->f_min); -if (!ret) -clk_disable_unprepare (host->cfg_div_clk); - -return ret; +return meson_mmc_clk_set (host, host->mmc->f_min); }static void meson_mmc_set_ios (struct mmc_host *mmc,struct mmc_ios *ios)
Kevin Hilman
maintainerPATCH 13/18 mmc: meson-gx: remove unneeded meson_mmc_clk_set in meson_mmc_clk_init
Quoted 6 lines · Heiner Kallweit
Am 15.02.2017 um 20:27 schrieb Kevin Hilman:
Quoted 5 lines
Quoted 2 lines · Heiner Kallweit
I don't think this
clk_disable_unprepareis right here. We do this inmeson_mmc_removewhat should be sufficient.
Quoted 6 lines
Quoted 3 lines
I don't think so, because if
_clk_init()fails, then_probewill fail, and the driver's ->remove() will not be called.In general, then the condition should be "if (ret)", not "if (!ret)". And if
_clk_init()fails, then probe jumps to labelfree_host, where we have exactly thisclk_disable_unprepare(host->cfg_div_clk)
Then you need to update the changelog, which refers to remove, not the cleanup in probe.
Kevin
Quoted 25 lines
Quoted 25 lines
Kevin
Quoted 22 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/mmc/host/meson-gx-mmc.c +1
-5@@ -315,11 +315,7 @@ static int meson_mmc_clk_init(struct meson_host *host)/* Get the nearest minimum clock to 400KHz */ host->mmc->f_min =clk_round_rate (host->cfg_div_clk,400000 ); - ret =meson_mmc_clk_set (host, host->mmc->f_min); -if (!ret) -clk_disable_unprepare (host->cfg_div_clk); - -return ret; +return meson_mmc_clk_set (host, host->mmc->f_min); }static void meson_mmc_set_ios (struct mmc_host *mmc,struct mmc_ios *ios)
PATCH 13/18 mmc: meson-gx: remove unneeded meson_mmc_clk_set in meson_mmc_clk_init
Am 16.02.2017 um 00:56 schrieb Kevin Hilman:
Quoted 11 lines
Quoted 9 lines · Heiner Kallweit
Am 15.02.2017 um 20:27 schrieb Kevin Hilman:
Quoted 8 lines
Quoted 2 lines · Heiner Kallweit
I don't think this
clk_disable_unprepareis right here. We do this inmeson_mmc_removewhat should be sufficient.I don't think so, because if
_clk_init()fails, then_probewill fail, and the driver's ->remove() will not be called.
Quoted 7 lines
Quoted 3 lines
In general, then the condition should be "if (ret)", not "if (!ret)". And if
_clk_init()fails, then probe jumps to labelfree_host, where we have exactly thisclk_disable_unprepare(host->cfg_div_clk)Then you need to update the changelog, which refers to remove, not the cleanup in probe.
Sure ..
Quoted 28 lines
Kevin
Quoted 25 lines
Quoted 25 lines
Kevin
Quoted 22 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/host/meson-gx-mmc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/mmc/host/meson-gx-mmc.c +1
-5@@ -315,11 +315,7 @@ static int meson_mmc_clk_init(struct meson_host *host)/* Get the nearest minimum clock to 400KHz */ host->mmc->f_min =clk_round_rate (host->cfg_div_clk,400000 ); - ret =meson_mmc_clk_set (host, host->mmc->f_min); -if (!ret) -clk_disable_unprepare (host->cfg_div_clk); - -return ret; +return meson_mmc_clk_set (host, host->mmc->f_min); }static void meson_mmc_set_ios (struct mmc_host *mmc,struct mmc_ios *ios)
PATCH 14/18 mmc: meson-gx: remove unneeded devm_kstrdup in meson_mmc_clk_init
In reply to a message not in the archiveMMC core does a deep copy of init.name, therefore it's fully ok to provide a local variable.
--- drivers/mmc/host/meson-gx-mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/meson-gx-mmc.c +1 -1
@@ -276,7 +276,7 @@ static int meson_mmc_clk_init(struct meson_host *host)/* create the divider */ snprintf (clk_name,sizeof (clk_name),"%s#div" ,dev_name (host->dev)); - init.name =devm_kstrdup (host->dev, clk_name,GFP_KERNEL ); + init.name = clk_name; init.ops = &clk_divider_ops; init.flags =CLK_SET_RATE_PARENT ; clk_div_parents[0 ] =__clk_get_name (host->mux_clk);
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 14/18 mmc: meson-gx: remove unneeded devm_kstrdup in meson_mmc_clk_init
Quoted 1 line · Heiner Kallweit
MMC core does a deep copy of init.name, therefore it's fully ok to
I assume you mean the clock framework, not the MMC core, right?
Quoted 3 lines
provide a local variable.
Signed-off-by Heiner Kallweit <[email protected]>
With the changelog fixed,
Quoted 17 lines
--- drivers/mmc/host/meson-gx-mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mmc/host/meson-gx-mmc.c +1
-1@@ -276,7 +276,7 @@ static int meson_mmc_clk_init(struct meson_host *host)/* create the divider */ snprintf (clk_name,sizeof (clk_name),"%s#div" ,dev_name (host->dev)); - init.name =devm_kstrdup (host->dev, clk_name,GFP_KERNEL ); + init.name = clk_name; init.ops = &clk_divider_ops; init.flags =CLK_SET_RATE_PARENT ; clk_div_parents[0 ] =__clk_get_name (host->mux_clk);
PATCH 14/18 mmc: meson-gx: remove unneeded devm_kstrdup in meson_mmc_clk_init
Am 15.02.2017 um 20:30 schrieb Kevin Hilman:
Quoted 6 lines
Quoted 1 line · Heiner Kallweit
MMC core does a deep copy of init.name, therefore it's fully ok to
I assume you mean the clock framework, not the MMC core, right?
Uups, of course.
Quoted 26 lines
Quoted 3 lines
provide a local variable.
Signed-off-by Heiner Kallweit <[email protected]>With the changelog fixed,
Acked-by Kevin Hilman <[email protected]>Quoted 17 lines
--- drivers/mmc/host/meson-gx-mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mmc/host/meson-gx-mmc.c +1
-1@@ -276,7 +276,7 @@ static int meson_mmc_clk_init(struct meson_host *host)/* create the divider */ snprintf (clk_name,sizeof (clk_name),"%s#div" ,dev_name (host->dev)); - init.name =devm_kstrdup (host->dev, clk_name,GFP_KERNEL ); + init.name = clk_name; init.ops = &clk_divider_ops; init.flags =CLK_SET_RATE_PARENT ; clk_div_parents[0 ] =__clk_get_name (host->mux_clk);
PATCH 15/18 mmc: meson-gx: improve initial configuration
In reply to a message not in the archiveConfig values which are not changed during runtime we can set in the probe function already.
The block size setting is overwritten later in meson_mmc_start_cmd anyway if needed, so it doesn't harm if we remove this setting in meson_mmc_set_ios.
In addition:
- write config register only if configuration changed
- Initialize clocks after other config registers have been initialized
--- drivers/mmc/host/meson-gx-mmc.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +21 -16
@@ -385,15 +385,6 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) val &= ~(CFG_BUS_WIDTH_MASK <<CFG_BUS_WIDTH_SHIFT ); val |= bus_width <<CFG_BUS_WIDTH_SHIFT ; - val &= ~(CFG_BLK_LEN_MASK <<CFG_BLK_LEN_SHIFT ); - val |=ilog2 (SD_EMMC_CFG_BLK_SIZE ) <<CFG_BLK_LEN_SHIFT ; - - val &= ~(CFG_RESP_TIMEOUT_MASK <<CFG_RESP_TIMEOUT_SHIFT ); - val |=ilog2 (SD_EMMC_CFG_RESP_TIMEOUT ) <<CFG_RESP_TIMEOUT_SHIFT ; - - val &= ~(CFG_RC_CC_MASK <<CFG_RC_CC_SHIFT ); - val |=ilog2 (SD_EMMC_CFG_CMD_GAP ) <<CFG_RC_CC_SHIFT ; - val &= ~CFG_DDR ; if (ios->timing == MMC_TIMING_UHS_DDR50 || ios->timing == MMC_TIMING_MMC_DDR52 ||
@@ -404,11 +395,11 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)if (ios->timing ==MMC_TIMING_MMC_HS400 ) val |=CFG_CHK_DS ; -writel (val, host->regs +SD_EMMC_CFG ); - -if (val != orig) +if (val != orig) { +writel (val, host->regs +SD_EMMC_CFG );dev_dbg (host->dev,"%s: SD_EMMC_CFG: 0x%08x -> 0x%08x\n" , __func__, orig, val); + } } static void meson_mmc_request_done(struct mmc_host *mmc,
@@ -675,6 +666,17 @@ static int meson_mmc_get_cd(struct mmc_host *mmc)return status; } +static void meson_mmc_cfg_init (struct meson_host *host) +{ +u32 cfg =0 ; + + cfg |=ilog2 (SD_EMMC_CFG_RESP_TIMEOUT ) <<CFG_RESP_TIMEOUT_SHIFT ; + cfg |=ilog2 (SD_EMMC_CFG_CMD_GAP ) <<CFG_RC_CC_SHIFT ; + cfg |=ilog2 (SD_EMMC_CFG_BLK_SIZE ) <<CFG_BLK_LEN_SHIFT ; + +writel (cfg, host->regs +SD_EMMC_CFG ); +} +static const struct mmc_host_ops meson_mmc_ops = { .request = meson_mmc_request, .set_ios = meson_mmc_set_ios,
@@ -735,10 +737,6 @@ static int meson_mmc_probe(struct platform_device *pdev)if (ret) goto free_host; - ret =meson_mmc_clk_init (host); -if (ret) - goto free_host; -/* Stop execution */ writel (0 , host->regs +SD_EMMC_START );
@@ -747,6 +745,13 @@ static int meson_mmc_probe(struct platform_device *pdev)writel (IRQ_EN_MASK , host->regs +SD_EMMC_STATUS );writel (IRQ_EN_MASK , host->regs +SD_EMMC_IRQ_EN ); +/* set config to sane default */ +meson_mmc_cfg_init (host); + + ret =meson_mmc_clk_init (host); +if (ret) + goto free_host; + ret =devm_request_threaded_irq (&pdev->dev, irq, meson_mmc_irq, meson_mmc_irq_thread,IRQF_SHARED ,dev_name (&pdev->dev), host);
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 15/18 mmc: meson-gx: improve initial configuration
Quoted 11 lines · Heiner Kallweit
Config values which are not changed during runtime we can set in the probe function already.
The block size setting is overwritten later inmeson_mmc_start_cmdanyway if needed, so it doesn't harm if we remove this setting inmeson_mmc_set_ios.In addition:
- write config register only if configuration changed
- Initialize clocks after other config registers have been initializedSigned-off-by Heiner Kallweit <[email protected]>
Quoted 82 lines
--- drivers/mmc/host/meson-gx-mmc.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-)drivers/mmc/host/meson-gx-mmc.c +21
-16@@ -385,15 +385,6 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) val &= ~(CFG_BUS_WIDTH_MASK <<CFG_BUS_WIDTH_SHIFT ); val |= bus_width <<CFG_BUS_WIDTH_SHIFT ; - val &= ~(CFG_BLK_LEN_MASK <<CFG_BLK_LEN_SHIFT ); - val |=ilog2 (SD_EMMC_CFG_BLK_SIZE ) <<CFG_BLK_LEN_SHIFT ; - - val &= ~(CFG_RESP_TIMEOUT_MASK <<CFG_RESP_TIMEOUT_SHIFT ); - val |=ilog2 (SD_EMMC_CFG_RESP_TIMEOUT ) <<CFG_RESP_TIMEOUT_SHIFT ; - - val &= ~(CFG_RC_CC_MASK <<CFG_RC_CC_SHIFT ); - val |=ilog2 (SD_EMMC_CFG_CMD_GAP ) <<CFG_RC_CC_SHIFT ; - val &= ~CFG_DDR ; if (ios->timing == MMC_TIMING_UHS_DDR50 || ios->timing == MMC_TIMING_MMC_DDR52 ||@@ -404,11 +395,11 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)if (ios->timing ==MMC_TIMING_MMC_HS400 ) val |=CFG_CHK_DS ; -writel (val, host->regs +SD_EMMC_CFG ); - -if (val != orig) +if (val != orig) { +writel (val, host->regs +SD_EMMC_CFG );dev_dbg (host->dev,"%s: SD_EMMC_CFG: 0x%08x -> 0x%08x\n" , __func__, orig, val); + } } static void meson_mmc_request_done(struct mmc_host *mmc,@@ -675,6 +666,17 @@ static int meson_mmc_get_cd(struct mmc_host *mmc)return status; } +static void meson_mmc_cfg_init (struct meson_host *host) +{ +u32 cfg =0 ; + + cfg |=ilog2 (SD_EMMC_CFG_RESP_TIMEOUT ) <<CFG_RESP_TIMEOUT_SHIFT ; + cfg |=ilog2 (SD_EMMC_CFG_CMD_GAP ) <<CFG_RC_CC_SHIFT ; + cfg |=ilog2 (SD_EMMC_CFG_BLK_SIZE ) <<CFG_BLK_LEN_SHIFT ; + +writel (cfg, host->regs +SD_EMMC_CFG ); +} +static const struct mmc_host_ops meson_mmc_ops = { .request = meson_mmc_request, .set_ios = meson_mmc_set_ios,@@ -735,10 +737,6 @@ static int meson_mmc_probe(struct platform_device *pdev)if (ret) goto free_host; - ret =meson_mmc_clk_init (host); -if (ret) - goto free_host; -/* Stop execution */ writel (0 , host->regs +SD_EMMC_START );@@ -747,6 +745,13 @@ static int meson_mmc_probe(struct platform_device *pdev)writel (IRQ_EN_MASK , host->regs +SD_EMMC_STATUS );writel (IRQ_EN_MASK , host->regs +SD_EMMC_IRQ_EN ); +/* set config to sane default */ +meson_mmc_cfg_init (host); + + ret =meson_mmc_clk_init (host); +if (ret) + goto free_host; + ret =devm_request_threaded_irq (&pdev->dev, irq, meson_mmc_irq, meson_mmc_irq_thread,IRQF_SHARED ,dev_name (&pdev->dev), host);
PATCH 16/18 mmc: meson-gx: improve response reading and sending stop command
In reply to a message not in the archiveStopping execution at the beginning of command processing (again) is not needed as reading SD_EMMC_CMD_RSP implicitely stops execution. We just have to take care of the case that a command doesn't return a response. Therefore read SD_EMMC_CMD_RSP always.
In addition we can read the response in the main irq handler already, we don't have to do this in the threaded handler.
--- drivers/mmc/host/meson-gx-mmc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +8 -8
@@ -510,9 +510,6 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)WARN_ON (host->mrq !=NULL ); -/* Stop execution */ -writel (0 , host->regs +SD_EMMC_START ); - host->mrq = mrq;meson_mmc_start_cmd (mmc, mrq->cmd); }
@@ -521,12 +518,16 @@ static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd) {struct meson_host *host =mmc_priv (mmc); +/* +* reading SD_EMMC_CMD_RSP stops processing, therefore read +* this register even if command has no response +*/ if (cmd->flags &MMC_RSP_136 ) { cmd->resp[0 ] =readl (host->regs +SD_EMMC_CMD_RSP3 ); cmd->resp[1 ] =readl (host->regs +SD_EMMC_CMD_RSP2 ); cmd->resp[2 ] =readl (host->regs +SD_EMMC_CMD_RSP1 ); cmd->resp[3 ] =readl (host->regs +SD_EMMC_CMD_RSP ); - }else if (cmd->flags &MMC_RSP_PRESENT ) { + }else { cmd->resp[0 ] =readl (host->regs +SD_EMMC_CMD_RSP ); } }
@@ -564,6 +565,8 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) goto out; } +meson_mmc_read_resp (host->mmc, cmd); + cmd->error =0 ;if (status &IRQ_RXD_ERR_MASK ) {dev_dbg (host->dev,"Unhandled IRQ: RXD error\n" );
@@ -610,10 +613,8 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)/* ack all (enabled) interrupts */ writel (status, host->regs +SD_EMMC_STATUS ); -if (ret ==IRQ_HANDLED ) { -meson_mmc_read_resp (host->mmc, cmd); +if (ret ==IRQ_HANDLED )meson_mmc_request_done (host->mmc, cmd->mrq); - }spin_unlock (&host->lock);return ret;
@@ -643,7 +644,6 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) data->bytes_xfered = xfer_bytes; } -meson_mmc_read_resp (host->mmc, cmd);if (mmc_op_multi (cmd->opcode))meson_mmc_start_cmd (host->mmc, data->stop);else
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 16/18 mmc: meson-gx: improve response reading and sending stop command
Quoted 9 lines · Heiner Kallweit
Stopping execution at the beginning of command processing (again) is not needed as reading
SD_EMMC_CMD_RSPimplicitely stops execution. We just have to take care of the case that a command doesn't return a response. Therefore readSD_EMMC_CMD_RSPalways.In addition we can read the response in the main irq handler already, we don't have to do this in the threaded handler.
Signed-off-by Heiner Kallweit <[email protected]>
Quoted 65 lines
--- drivers/mmc/host/meson-gx-mmc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/mmc/host/meson-gx-mmc.c +8
-8@@ -510,9 +510,6 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)WARN_ON (host->mrq !=NULL ); -/* Stop execution */ -writel (0 , host->regs +SD_EMMC_START ); - host->mrq = mrq;meson_mmc_start_cmd (mmc, mrq->cmd); }@@ -521,12 +518,16 @@ static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd) {struct meson_host *host =mmc_priv (mmc); +/* +* reading SD_EMMC_CMD_RSP stops processing, therefore read +* this register even if command has no response +*/ if (cmd->flags &MMC_RSP_136 ) { cmd->resp[0 ] =readl (host->regs +SD_EMMC_CMD_RSP3 ); cmd->resp[1 ] =readl (host->regs +SD_EMMC_CMD_RSP2 ); cmd->resp[2 ] =readl (host->regs +SD_EMMC_CMD_RSP1 ); cmd->resp[3 ] =readl (host->regs +SD_EMMC_CMD_RSP ); - }else if (cmd->flags &MMC_RSP_PRESENT ) { + }else { cmd->resp[0 ] =readl (host->regs +SD_EMMC_CMD_RSP ); } }@@ -564,6 +565,8 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) goto out; } +meson_mmc_read_resp (host->mmc, cmd); + cmd->error =0 ;if (status &IRQ_RXD_ERR_MASK ) {dev_dbg (host->dev,"Unhandled IRQ: RXD error\n" );@@ -610,10 +613,8 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)/* ack all (enabled) interrupts */ writel (status, host->regs +SD_EMMC_STATUS ); -if (ret ==IRQ_HANDLED ) { -meson_mmc_read_resp (host->mmc, cmd); +if (ret ==IRQ_HANDLED )meson_mmc_request_done (host->mmc, cmd->mrq); - }spin_unlock (&host->lock);return ret;@@ -643,7 +644,6 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) data->bytes_xfered = xfer_bytes; } -meson_mmc_read_resp (host->mmc, cmd);if (mmc_op_multi (cmd->opcode))meson_mmc_start_cmd (host->mmc, data->stop);else
PATCH 17/18 mmc: meson-gx: remove member mrq from struct meson_host
In reply to a message not in the archiveStruct mmc_command includes a reference to the related mmc_request. Therefore we don't have to store mrq separately in struct meson_host.
--- drivers/mmc/host/meson-gx-mmc.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +2 -21
@@ -123,7 +123,6 @@struct meson_host {struct device *dev;struct mmc_host *mmc; -struct mmc_request *mrq;struct mmc_command *cmd;spinlock_t lock;
@@ -407,9 +406,6 @@ static void meson_mmc_request_done(struct mmc_host *mmc, {struct meson_host *host =mmc_priv (mmc); -WARN_ON (host->mrq != mrq); - - host->mrq =NULL ; host->cmd =NULL ;mmc_request_done (host->mmc, mrq); }
@@ -506,11 +502,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)static void meson_mmc_request (struct mmc_host *mmc,struct mmc_request *mrq) { -struct meson_host *host =mmc_priv (mmc); - -WARN_ON (host->mrq !=NULL ); - - host->mrq = mrq;meson_mmc_start_cmd (mmc, mrq->cmd); }
@@ -535,7 +526,6 @@ static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd)static irqreturn_t meson_mmc_irq (int irq,void *dev_id) {struct meson_host *host = dev_id; -struct mmc_request *mrq;struct mmc_command *cmd;u32 irq_en, status, raw_status;irqreturn_t ret =IRQ_HANDLED ;
@@ -545,11 +535,6 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) cmd = host->cmd; - mrq = host->mrq; - -if (WARN_ON (!mrq)) -return IRQ_NONE ; -if (WARN_ON (!cmd))return IRQ_NONE ;
@@ -598,7 +583,7 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)else {dev_warn (host->dev,"Unknown IRQ! status=0x%04x: MMC CMD%u arg=0x%08x flags=0x%08x stop=%d\n" , status, cmd->opcode, cmd->arg, - cmd->flags, mrq->stop ?1 :0 ); + cmd->flags, cmd->mrq->stop ?1 :0 );if (cmd->data) {struct mmc_data *data = cmd->data;
@@ -623,14 +608,10 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)static irqreturn_t meson_mmc_irq_thread (int irq,void *dev_id) {struct meson_host *host = dev_id; -struct mmc_request *mrq = host->mrq;struct mmc_command *cmd = host->cmd;struct mmc_data *data;unsigned int xfer_bytes; -if (WARN_ON (!mrq)) -return IRQ_NONE ; -if (WARN_ON (!cmd))return IRQ_NONE ;
@@ -647,7 +628,7 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)if (mmc_op_multi (cmd->opcode))meson_mmc_start_cmd (host->mmc, data->stop);else -meson_mmc_request_done (host->mmc, mrq); +meson_mmc_request_done (host->mmc, cmd->mrq);return IRQ_HANDLED ; }
Signature · 1 line
2.11.1
Kevin Hilman
maintainerPATCH 17/18 mmc: meson-gx: remove member mrq from struct meson_host
Quoted 2 lines · Heiner Kallweit
Struct
mmc_commandincludes a reference to the relatedmmc_request. Therefore we don't have to store mrq separately in structmeson_host.
This patch also removes a bunch of WARNs also, which shoulc be mentioned here as well. Those were quite handy during development, but now that things have stabilized, I'm OK with them being removed.
Quoted 1 line
Signed-off-by Heiner Kallweit <[email protected]>
With the changelog update,
Quoted 91 lines
--- drivers/mmc/host/meson-gx-mmc.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)drivers/mmc/host/meson-gx-mmc.c +2
-21@@ -123,7 +123,6 @@struct meson_host {struct device *dev;struct mmc_host *mmc; -struct mmc_request *mrq;struct mmc_command *cmd;spinlock_t lock;@@ -407,9 +406,6 @@ static void meson_mmc_request_done(struct mmc_host *mmc, {struct meson_host *host =mmc_priv (mmc); -WARN_ON (host->mrq != mrq); - - host->mrq =NULL ; host->cmd =NULL ;mmc_request_done (host->mmc, mrq); }@@ -506,11 +502,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)static void meson_mmc_request (struct mmc_host *mmc,struct mmc_request *mrq) { -struct meson_host *host =mmc_priv (mmc); - -WARN_ON (host->mrq !=NULL ); - - host->mrq = mrq;meson_mmc_start_cmd (mmc, mrq->cmd); }@@ -535,7 +526,6 @@ static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd)static irqreturn_t meson_mmc_irq (int irq,void *dev_id) {struct meson_host *host = dev_id; -struct mmc_request *mrq;struct mmc_command *cmd;u32 irq_en, status, raw_status;irqreturn_t ret =IRQ_HANDLED ;@@ -545,11 +535,6 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) cmd = host->cmd; - mrq = host->mrq; - -if (WARN_ON (!mrq)) -return IRQ_NONE ; -if (WARN_ON (!cmd))return IRQ_NONE ;@@ -598,7 +583,7 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)else {dev_warn (host->dev,"Unknown IRQ! status=0x%04x: MMC CMD%u arg=0x%08x flags=0x%08x stop=%d\n" , status, cmd->opcode, cmd->arg, - cmd->flags, mrq->stop ?1 :0 ); + cmd->flags, cmd->mrq->stop ?1 :0 );if (cmd->data) {struct mmc_data *data = cmd->data;@@ -623,14 +608,10 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)static irqreturn_t meson_mmc_irq_thread (int irq,void *dev_id) {struct meson_host *host = dev_id; -struct mmc_request *mrq = host->mrq;struct mmc_command *cmd = host->cmd;struct mmc_data *data;unsigned int xfer_bytes; -if (WARN_ON (!mrq)) -return IRQ_NONE ; -if (WARN_ON (!cmd))return IRQ_NONE ;@@ -647,7 +628,7 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)if (mmc_op_multi (cmd->opcode))meson_mmc_start_cmd (host->mmc, data->stop);else -meson_mmc_request_done (host->mmc, mrq); +meson_mmc_request_done (host->mmc, cmd->mrq);return IRQ_HANDLED ; }
PATCH 18/18 mmc: meson-gx: move handling of one case from threaded handler to main irq
In reply to a message not in the archiveIf cmd->data is NULL there's nothing to do in the threaded handler. So we can handle this case in the main irq handler already.
--- drivers/mmc/host/meson-gx-mmc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/mmc/host/meson-gx-mmc.c +6 -5
@@ -578,9 +578,10 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)if (status &IRQ_SDIO )dev_dbg (host->dev,"Unhandled IRQ: SDIO.\n" ); -if (status & (IRQ_END_OF_CHAIN |IRQ_RESP_STATUS )) - ret =IRQ_WAKE_THREAD ; -else { +if (status & (IRQ_END_OF_CHAIN |IRQ_RESP_STATUS )) { +if (cmd->data) + ret =IRQ_WAKE_THREAD ; + }else {dev_warn (host->dev,"Unknown IRQ! status=0x%04x: MMC CMD%u arg=0x%08x flags=0x%08x stop=%d\n" , status, cmd->opcode, cmd->arg, cmd->flags, cmd->mrq->stop ?1 :0 );
@@ -612,11 +613,11 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)struct mmc_data *data;unsigned int xfer_bytes; -if (WARN_ON (!cmd)) +if (WARN_ON (!cmd || !cmd->data))return IRQ_NONE ; data = cmd->data; -if (data && data->flags &MMC_DATA_READ ) { +if (data->flags &MMC_DATA_READ ) {size_t len =sg_copy_from_buffer (data->sg, data->sg_len, host->bounce_buf, host->bounce_buf_size);
Signature · 1 line
2.11.1