public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: moxart-mmc: Fix APP_CMD flag set on non-application commands
@ 2016-06-07  8:53 Michal Kadlic
  2016-06-07  8:59 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Kadlic @ 2016-06-07  8:53 UTC (permalink / raw)
  To: linux-mmc

Moxart MMC host controller has an APP_CMD flag, that's set when sending 
an ACMD. This was set by checking command opcode instead of CMD55->ACMDx 
sequence, which could lead to regular commands like CMD6,CMD13,CMD23 and 
CMD42 flagged as application commands.

Patch is against kernel version 4.6

Signed-off-by: Michal Kadlic <michal.kadlic@spinet.sk>

---

diff -purN a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
--- a/drivers/mmc/host/moxart-mmc.c     2016-06-01 14:39:12.000000000 +0200
+++ b/drivers/mmc/host/moxart-mmc.c     2016-06-07 10:12:38.428539771 +0200
@@ -60,6 +60,7 @@
  #define CMD_LONG_RSP           BIT(7)
  #define CMD_NEED_RSP           BIT(6)
  #define CMD_IDX_MASK           0x3f
+#define CMD_MMC_APP_CMD        55

  /* REG_RESPONSE_COMMAND */
  #define RSP_CMD_APP            BIT(6)
@@ -146,6 +147,7 @@ struct moxart_host {

         bool                            have_dma;
         bool                            is_removed;
+       bool                            app_cmd_flag;
  };

  static inline void moxart_init_sg(struct moxart_host *host,
@@ -211,10 +213,11 @@ static void moxart_send_command(struct m
         writel(cmd->arg, host->base + REG_ARGUMENT);

         cmdctrl = cmd->opcode & CMD_IDX_MASK;
-       if (cmdctrl == SD_APP_SET_BUS_WIDTH    || cmdctrl == 
SD_APP_OP_COND   ||
-           cmdctrl == SD_APP_SEND_SCR         || cmdctrl == 
SD_APP_SD_STATUS ||
-           cmdctrl == SD_APP_SEND_NUM_WR_BLKS)
+
+       // If previous command was CMD55 set APP_CMD flag, except for 
CMD0(Reset)
+       if ((host->app_cmd_flag) && cmd->opcode)
                 cmdctrl |= CMD_APP_CMD;
+       host->app_cmd_flag = false;

         if (cmd->flags & MMC_RSP_PRESENT)
                 cmdctrl |= CMD_NEED_RSP;
@@ -244,6 +248,11 @@ static void moxart_send_command(struct m
                 } else {
                         cmd->resp[0] = readl(host->base + REG_RESPONSE0);
                 }
+
+               // CMD55 sent sucessfully - next command will be 
interpreted as ACMD
+               if ((!cmd->error) && (cmd->opcode==CMD_MMC_APP_CMD)) {
+                       host->app_cmd_flag = true;
+               }
         }
  }

@@ -611,6 +621,7 @@ static int moxart_probe(struct platform_
         host->fifo_width = readl(host->base + REG_FEATURE) << 2;
         host->dma_chan_tx = dma_request_slave_channel_reason(dev, "tx");
         host->dma_chan_rx = dma_request_slave_channel_reason(dev, "rx");
+       host->app_cmd_flag=false;

         spin_lock_init(&host->lock);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: moxart-mmc: Fix APP_CMD flag set on non-application commands
  2016-06-07  8:53 [PATCH] mmc: moxart-mmc: Fix APP_CMD flag set on non-application commands Michal Kadlic
@ 2016-06-07  8:59 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2016-06-07  8:59 UTC (permalink / raw)
  To: Michal Kadlic; +Cc: linux-mmc

On Tuesday, June 7, 2016 10:53:01 AM CEST Michal Kadlic wrote:
> Moxart MMC host controller has an APP_CMD flag, that's set when sending 
> an ACMD. This was set by checking command opcode instead of CMD55->ACMDx 
> sequence, which could lead to regular commands like CMD6,CMD13,CMD23 and 
> CMD42 flagged as application commands.
> 
> Patch is against kernel version 4.6
> 
> Signed-off-by: Michal Kadlic <michal.kadlic@spinet.sk>

Is this needed for backports to stable kernels as well?

>   static inline void moxart_init_sg(struct moxart_host *host,
> @@ -211,10 +213,11 @@ static void moxart_send_command(struct m
>          writel(cmd->arg, host->base + REG_ARGUMENT);
> 
>          cmdctrl = cmd->opcode & CMD_IDX_MASK;
> -       if (cmdctrl == SD_APP_SET_BUS_WIDTH    || cmdctrl == 
> SD_APP_OP_COND   ||
> -           cmdctrl == SD_APP_SEND_SCR         || cmdctrl == 
> SD_APP_SD_STATUS ||
> -           cmdctrl == SD_APP_SEND_NUM_WR_BLKS)
> +

You seem to have an incorrect word wrapping setting in your email
client, so the patch won't apply. I'd recommend using 'git send-email',
which tends to be easier than figuring out the right settings for your
mailer.

> +       // If previous command was CMD55 set APP_CMD flag, except for 
> CMD0(Reset)

Please use /* ... */ comments.

	Arnd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-07  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-07  8:53 [PATCH] mmc: moxart-mmc: Fix APP_CMD flag set on non-application commands Michal Kadlic
2016-06-07  8:59 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox