diff mbox series

[v4,6/9] mmc: host: Add close-ended Ext memory addressing

Message ID 20240825074141.3171549-7-avri.altman@wdc.com (mailing list archive)
State New
Headers show
Series Add SDUC Support | expand

Commit Message

Avri Altman Aug. 25, 2024, 7:41 a.m. UTC
In a close-ended multi-block data transfer, CMD23 shall precede CMD22.
Handle that logic once the sbc is done.

Host drivers that handle their own sbc logic, e.g. bcm2835 etc. are out
of scope of this change.

Tested-by: Ricky WU <ricky_wu@realtek.com>
Signed-off-by: Avri Altman <avri.altman@wdc.com>
---
 drivers/mmc/host/sdhci.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

Comments

Avri Altman Aug. 25, 2024, 1:33 p.m. UTC | #1
> In a close-ended multi-block data transfer, CMD23 shall precede CMD22.
> Handle that logic once the sbc is done.
> 
> Host drivers that handle their own sbc logic, e.g. bcm2835 etc. are out of scope of
> this change.
> 
> Tested-by: Ricky WU <ricky_wu@realtek.com>
> Signed-off-by: Avri Altman <avri.altman@wdc.com>
> ---
>  drivers/mmc/host/sdhci.c | 36 ++++++++++++++++++++++++++++++++----
>  1 file changed, 32 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index
> f62b489c9e9c..70c967029fe3 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1791,9 +1791,38 @@ static void sdhci_read_rsp_136(struct sdhci_host
> *host, struct mmc_command *cmd)
>  	}
>  }
> 
> +static struct mmc_command *sdhci_get_sbc_ext(struct sdhci_host *host,
> +					     struct mmc_command *cmd)
> +{
> +	bool is_sduc = mmc_card_ult_capacity(host->mmc->card);
At this point, better move mmc_card_ult_capacity to include/linux/mmc/card.h.
Also better check host->mmc->card != NULL as it can be until mmc_sd_init_card() concludes.

Thanks,
Avri

> +
> +	if (is_sduc) {
> +		/*  Finished CMD22, now send actual command */
> +		if (cmd == cmd->mrq->ext)
> +			return cmd->mrq->cmd;
> +	}
> +
> +	/* Finished CMD23 */
> +	if (cmd == cmd->mrq->sbc) {
> +		if (is_sduc) {
> +			/* send CMD22 after CMD23 */
> +			if (WARN_ON(!cmd->mrq->ext))
> +				return NULL;
> +			else
> +				return cmd->mrq->ext;
> +		} else {
> +			/* Finished CMD23, now send actual command */
> +			return cmd->mrq->cmd;
> +		}
> +	}
> +
> +	return NULL;
> +}
> +
>  static void sdhci_finish_command(struct sdhci_host *host)  {
>  	struct mmc_command *cmd = host->cmd;
> +	struct mmc_command *sbc_ext = NULL;
> 
>  	host->cmd = NULL;
> 
> @@ -1828,14 +1857,13 @@ static void sdhci_finish_command(struct sdhci_host
> *host)
>  		}
>  	}
> 
> -	/* Finished CMD23, now send actual command. */
> -	if (cmd == cmd->mrq->sbc) {
> -		if (!sdhci_send_command(host, cmd->mrq->cmd)) {
> +	sbc_ext = sdhci_get_sbc_ext(host, cmd);
> +	if (sbc_ext) {
> +		if (!sdhci_send_command(host, sbc_ext)) {
>  			WARN_ON(host->deferred_cmd);
>  			host->deferred_cmd = cmd->mrq->cmd;
>  		}
>  	} else {
> -
>  		/* Processed actual command. */
>  		if (host->data && host->data_early)
>  			sdhci_finish_data(host);
> --
> 2.25.1
kernel test robot Aug. 26, 2024, 7:31 p.m. UTC | #2
Hi Avri,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.11-rc5 next-20240826]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Avri-Altman/mmc-sd-SDUC-Support-Recognition/20240826-161527
base:   linus/master
patch link:    https://lore.kernel.org/r/20240825074141.3171549-7-avri.altman%40wdc.com
patch subject: [PATCH v4 6/9] mmc: host: Add close-ended Ext memory addressing
config: arc-randconfig-002-20240827 (https://download.01.org/0day-ci/archive/20240827/202408270315.TTjSYp25-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240827/202408270315.TTjSYp25-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408270315.TTjSYp25-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/mmc/host/sdhci.c: In function 'sdhci_get_sbc_ext':
>> drivers/mmc/host/sdhci.c:1797:24: error: implicit declaration of function 'mmc_card_ult_capacity' [-Werror=implicit-function-declaration]
    1797 |         bool is_sduc = mmc_card_ult_capacity(host->mmc->card);
         |                        ^~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/mmc_card_ult_capacity +1797 drivers/mmc/host/sdhci.c

  1793	
  1794	static struct mmc_command *sdhci_get_sbc_ext(struct sdhci_host *host,
  1795						     struct mmc_command *cmd)
  1796	{
> 1797		bool is_sduc = mmc_card_ult_capacity(host->mmc->card);
  1798	
  1799		if (is_sduc) {
  1800			/*  Finished CMD22, now send actual command */
  1801			if (cmd == cmd->mrq->ext)
  1802				return cmd->mrq->cmd;
  1803		}
  1804	
  1805		/* Finished CMD23 */
  1806		if (cmd == cmd->mrq->sbc) {
  1807			if (is_sduc) {
  1808				/* send CMD22 after CMD23 */
  1809				if (WARN_ON(!cmd->mrq->ext))
  1810					return NULL;
  1811				else
  1812					return cmd->mrq->ext;
  1813			} else {
  1814				/* Finished CMD23, now send actual command */
  1815				return cmd->mrq->cmd;
  1816			}
  1817		}
  1818	
  1819		return NULL;
  1820	}
  1821
kernel test robot Aug. 26, 2024, 10:28 p.m. UTC | #3
Hi Avri,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.11-rc5 next-20240826]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Avri-Altman/mmc-sd-SDUC-Support-Recognition/20240826-161527
base:   linus/master
patch link:    https://lore.kernel.org/r/20240825074141.3171549-7-avri.altman%40wdc.com
patch subject: [PATCH v4 6/9] mmc: host: Add close-ended Ext memory addressing
config: arm-defconfig (https://download.01.org/0day-ci/archive/20240827/202408270619.qJDzvXzO-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240827/202408270619.qJDzvXzO-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408270619.qJDzvXzO-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/mmc/host/sdhci.c:1797:17: error: implicit declaration of function 'mmc_card_ult_capacity' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           bool is_sduc = mmc_card_ult_capacity(host->mmc->card);
                          ^
   1 error generated.


vim +/mmc_card_ult_capacity +1797 drivers/mmc/host/sdhci.c

  1793	
  1794	static struct mmc_command *sdhci_get_sbc_ext(struct sdhci_host *host,
  1795						     struct mmc_command *cmd)
  1796	{
> 1797		bool is_sduc = mmc_card_ult_capacity(host->mmc->card);
  1798	
  1799		if (is_sduc) {
  1800			/*  Finished CMD22, now send actual command */
  1801			if (cmd == cmd->mrq->ext)
  1802				return cmd->mrq->cmd;
  1803		}
  1804	
  1805		/* Finished CMD23 */
  1806		if (cmd == cmd->mrq->sbc) {
  1807			if (is_sduc) {
  1808				/* send CMD22 after CMD23 */
  1809				if (WARN_ON(!cmd->mrq->ext))
  1810					return NULL;
  1811				else
  1812					return cmd->mrq->ext;
  1813			} else {
  1814				/* Finished CMD23, now send actual command */
  1815				return cmd->mrq->cmd;
  1816			}
  1817		}
  1818	
  1819		return NULL;
  1820	}
  1821
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index f62b489c9e9c..70c967029fe3 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1791,9 +1791,38 @@  static void sdhci_read_rsp_136(struct sdhci_host *host, struct mmc_command *cmd)
 	}
 }
 
+static struct mmc_command *sdhci_get_sbc_ext(struct sdhci_host *host,
+					     struct mmc_command *cmd)
+{
+	bool is_sduc = mmc_card_ult_capacity(host->mmc->card);
+
+	if (is_sduc) {
+		/*  Finished CMD22, now send actual command */
+		if (cmd == cmd->mrq->ext)
+			return cmd->mrq->cmd;
+	}
+
+	/* Finished CMD23 */
+	if (cmd == cmd->mrq->sbc) {
+		if (is_sduc) {
+			/* send CMD22 after CMD23 */
+			if (WARN_ON(!cmd->mrq->ext))
+				return NULL;
+			else
+				return cmd->mrq->ext;
+		} else {
+			/* Finished CMD23, now send actual command */
+			return cmd->mrq->cmd;
+		}
+	}
+
+	return NULL;
+}
+
 static void sdhci_finish_command(struct sdhci_host *host)
 {
 	struct mmc_command *cmd = host->cmd;
+	struct mmc_command *sbc_ext = NULL;
 
 	host->cmd = NULL;
 
@@ -1828,14 +1857,13 @@  static void sdhci_finish_command(struct sdhci_host *host)
 		}
 	}
 
-	/* Finished CMD23, now send actual command. */
-	if (cmd == cmd->mrq->sbc) {
-		if (!sdhci_send_command(host, cmd->mrq->cmd)) {
+	sbc_ext = sdhci_get_sbc_ext(host, cmd);
+	if (sbc_ext) {
+		if (!sdhci_send_command(host, sbc_ext)) {
 			WARN_ON(host->deferred_cmd);
 			host->deferred_cmd = cmd->mrq->cmd;
 		}
 	} else {
-
 		/* Processed actual command. */
 		if (host->data && host->data_early)
 			sdhci_finish_data(host);