From: Adrian Hunter <adrian.hunter@intel.com>
To: Victor Shih <victorshihgli@gmail.com>
Cc: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org,
linux-kernel@vger.kernel.org, benchuanggli@gmail.com,
HL.Liu@genesyslogic.com.tw, Greg.tu@genesyslogic.com.tw,
takahiro.akashi@linaro.org, dlunev@chromium.org,
Jason Lai <jason.lai@genesyslogic.com.tw>,
Victor Shih <victor.shih@genesyslogic.com.tw>
Subject: Re: [PATCH V8 06/23] mmc: core: Support UHS-II card control and access
Date: Thu, 20 Jul 2023 11:06:57 +0300 [thread overview]
Message-ID: <047c746f-0787-37ec-7989-cd932f288564@intel.com> (raw)
In-Reply-To: <CAK00qKBX55WVkKRJ4bkXN97VYg0yz72G+osir1AQWALszoGEOQ@mail.gmail.com>
On 19/07/23 13:24, Victor Shih wrote:
> On Mon, Jul 10, 2023 at 9:24 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>> On 21/06/23 13:01, Victor Shih wrote:
>>> From: Victor Shih <victor.shih@genesyslogic.com.tw>
>>>
>>> Embed UHS-II access/control functionality into the MMC request
>>> processing flow.
>>>
>>> Updates in V8:
>>> - Add MMC_UHS2_SUPPORT to be cleared in sd_uhs2_detect().
>>> - Modify return value in sd_uhs2_attach().
>>>
>>> Updates in V7:
>>> - Add mmc_uhs2_card_prepare_cmd helper function in sd_ops.h.
>>> - Drop uhs2_state in favor of ios->timing.
>>> - Remove unnecessary functions.
>>>
>>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>>> Signed-off-by: Jason Lai <jason.lai@genesyslogic.com.tw>
>>> Signed-off-by: Victor Shih <victor.shih@genesyslogic.com.tw>
>>> ---
>>> drivers/mmc/core/block.c | 18 +-
>>> drivers/mmc/core/core.c | 8 +
>>> drivers/mmc/core/mmc_ops.c | 25 +-
>>> drivers/mmc/core/mmc_ops.h | 1 +
>>> drivers/mmc/core/sd.c | 13 +-
>>> drivers/mmc/core/sd.h | 4 +
>>> drivers/mmc/core/sd_ops.c | 11 +
>>> drivers/mmc/core/sd_ops.h | 18 +
>>> drivers/mmc/core/sd_uhs2.c | 1137 +++++++++++++++++++++++++++++++++++-
>>> 9 files changed, 1176 insertions(+), 59 deletions(-)
>>>
>>> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
>>> index 2e9d3760c202..013ab071db9b 100644
>>> --- a/drivers/mmc/core/block.c
>>> +++ b/drivers/mmc/core/block.c
>>> @@ -918,15 +918,9 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks)
>>>
>>> struct scatterlist sg;
>>>
>>> - cmd.opcode = MMC_APP_CMD;
>>> - cmd.arg = card->rca << 16;
>>> - cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
>>> -
>>> - err = mmc_wait_for_cmd(card->host, &cmd, 0);
>>> - if (err)
>>> - return err;
>>> - if (!mmc_host_is_spi(card->host) && !(cmd.resp[0] & R1_APP_CMD))
>>> - return -EIO;
>>> + err = mmc_app_cmd(card->host, card);
>>> + if (err)
>>> + return err;
>>>
>>> memset(&cmd, 0, sizeof(struct mmc_command));
>>>
>>> @@ -1612,6 +1606,9 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
>>> struct request *req = mmc_queue_req_to_req(mqrq);
>>> struct mmc_blk_data *md = mq->blkdata;
>>> bool do_rel_wr, do_data_tag;
>>> + bool do_multi;
>>> +
>>> + do_multi = (card->host->flags & MMC_UHS2_SD_TRAN) ? true : false;
>>>
>>> mmc_blk_data_prep(mq, mqrq, recovery_mode, &do_rel_wr, &do_data_tag);
>>>
>>> @@ -1622,7 +1619,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
>>> brq->cmd.arg <<= 9;
>>> brq->cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
>>>
>>> - if (brq->data.blocks > 1 || do_rel_wr) {
>>> + if (brq->data.blocks > 1 || do_rel_wr || do_multi) {
>>> /* SPI multiblock writes terminate using a special
>>> * token, not a STOP_TRANSMISSION request.
>>> */
>>> @@ -1635,6 +1632,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
>>> brq->mrq.stop = NULL;
>>> readcmd = MMC_READ_SINGLE_BLOCK;
>>> writecmd = MMC_WRITE_BLOCK;
>>> + brq->cmd.uhs2_tmode0_flag = 1;
>>> }
>>> brq->cmd.opcode = rq_data_dir(req) == READ ? readcmd : writecmd;
>>>
>>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>>> index 7b8227e7ed26..04783f37da92 100644
>>> --- a/drivers/mmc/core/core.c
>>> +++ b/drivers/mmc/core/core.c
>>> @@ -334,6 +334,8 @@ static int mmc_mrq_prep(struct mmc_host *host, struct mmc_request *mrq)
>>>
>>> int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
>>> {
>>> + struct uhs2_command uhs2_cmd;
>>> + __be32 payload[4]; /* for maximum size */
>>> int err;
>>>
>>> init_completion(&mrq->cmd_completion);
>>> @@ -351,6 +353,8 @@ int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
>>> if (err)
>>> return err;
>>>
>>> + mmc_uhs2_card_prepare_cmd(host, mrq, uhs2_cmd, payload);
>>> +
>>> led_trigger_event(host->led, LED_FULL);
>>> __mmc_start_request(host, mrq);
>>
>> __mmc_start_request() is also called by mmc_wait_for_req_done()
>> but uhs2_cmd is local to mmc_start_request(), so if mmc_wait_for_req_done()
>> is ever called in UHS2 case with cmd->retries, it looks like
>> host controller might try to access uhs2_cmd which is no
>> longer valid?
>>
>>
>
> Hi, Adrian
>
> I traced the code between the SD card initialization process and
> found that
> __mmc_start_request() is only called by mmc_start_request in the
> UHS2 case.
> I'm not sure if there's anything I'm missing, could you help me
> with more comments?
Perhaps mmc_send_status() used in block.c ?
> Or may you have any ideas on how to avoid this situation?
>
Need to get Ulf's view, but putting "struct uhs2_command uhs2_cmd"
and "__be32 payload[4]" in struct mmc_command or struct mmc_request
would seem to be options. If size is a concern, some optimization
to reduce the size of struct uhs2_command looks possible, and is
max payload len actually only 2 at the moment.
next prev parent reply other threads:[~2023-07-20 8:07 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-21 10:01 [PATCH V8 00/23] Add support UHS-II for GL9755 Victor Shih
2023-06-21 10:01 ` [PATCH V8 01/23] mmc: core: Cleanup printing of speed mode at card insertion Victor Shih
2023-06-21 13:44 ` Ulf Hansson
2023-06-29 10:24 ` Victor Shih
2023-06-21 10:01 ` [PATCH V8 02/23] mmc: core: Prepare to support SD UHS-II cards Victor Shih
2023-07-10 6:43 ` Adrian Hunter
2023-07-21 10:11 ` Victor Shih
2023-06-21 10:01 ` [PATCH V8 03/23] mmc: core: Announce successful insertion of an SD UHS-II card Victor Shih
2023-06-21 10:01 ` [PATCH V8 04/23] mmc: core: Extend support for mmc regulators with a vqmmc2 Victor Shih
2023-06-21 10:01 ` [PATCH V8 05/23] mmc: core: Add definitions for SD UHS-II cards Victor Shih
2023-06-21 10:01 ` [PATCH V8 06/23] mmc: core: Support UHS-II card control and access Victor Shih
2023-07-10 13:24 ` Adrian Hunter
2023-07-19 10:24 ` Victor Shih
2023-07-20 8:06 ` Adrian Hunter [this message]
2023-06-21 10:01 ` [PATCH V8 07/23] mmc: sdhci: add UHS-II related definitions in headers Victor Shih
2023-07-10 16:00 ` Adrian Hunter
2023-07-21 10:11 ` Victor Shih
2023-06-21 10:01 ` [PATCH V8 08/23] mmc: sdhci: add UHS-II module and add a kernel configuration Victor Shih
2023-07-10 16:01 ` Adrian Hunter
2023-07-21 10:11 ` Victor Shih
2023-06-21 10:01 ` [PATCH V8 09/23] mmc: sdhci-uhs2: dump UHS-II registers Victor Shih
2023-06-21 10:01 ` [PATCH V8 10/23] mmc: sdhci-uhs2: add reset function and uhs2_mode function Victor Shih
2023-06-21 10:01 ` [PATCH V8 11/23] mmc: sdhci-uhs2: add set_power() to support vdd2 Victor Shih
2023-07-10 16:01 ` Adrian Hunter
2023-07-21 10:11 ` Victor Shih
2023-06-21 10:01 ` [PATCH V8 12/23] mmc: sdhci-uhs2: skip signal_voltage_switch() Victor Shih
2023-06-21 10:01 ` [PATCH V8 13/23] mmc: sdhci-uhs2: add set_timeout() Victor Shih
2023-06-21 10:01 ` [PATCH V8 14/23] mmc: sdhci-uhs2: add set_ios() Victor Shih
2023-07-10 16:02 ` Adrian Hunter
2023-07-21 10:11 ` Victor Shih
2023-06-21 10:01 ` [PATCH V8 15/23] mmc: sdhci-uhs2: add detect_init() to detect the interface Victor Shih
2023-06-21 10:01 ` [PATCH V8 16/23] mmc: sdhci-uhs2: add clock operations Victor Shih
2023-06-21 10:01 ` [PATCH V8 17/23] mmc: sdhci-uhs2: add uhs2_control() to initialise the interface Victor Shih
2023-06-21 10:01 ` [PATCH V8 18/23] mmc: sdhci-uhs2: add request() and others Victor Shih
2023-07-10 16:02 ` Adrian Hunter
2023-07-21 10:11 ` Victor Shih
2023-06-21 10:01 ` [PATCH V8 19/23] mmc: sdhci-uhs2: add irq() " Victor Shih
2023-07-10 16:03 ` Adrian Hunter
2023-07-21 10:12 ` Victor Shih
2023-06-21 10:01 ` [PATCH V8 20/23] mmc: sdhci-uhs2: add add_host() and others to set up the driver Victor Shih
2023-06-21 10:01 ` [PATCH V8 21/23] mmc: sdhci-uhs2: add pre-detect_init hook Victor Shih
2023-06-21 10:01 ` [PATCH V8 22/23] mmc: sdhci-pci: add UHS-II support framework Victor Shih
2023-06-21 10:01 ` [PATCH V8 23/23] mmc: sdhci-pci-gli: enable UHS-II mode for GL9755 Victor Shih
2023-06-29 10:24 ` [PATCH V8 00/23] Add support UHS-II " Victor Shih
2023-06-29 14:51 ` Ulf Hansson
2023-07-10 16:06 ` Adrian Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=047c746f-0787-37ec-7989-cd932f288564@intel.com \
--to=adrian.hunter@intel.com \
--cc=Greg.tu@genesyslogic.com.tw \
--cc=HL.Liu@genesyslogic.com.tw \
--cc=benchuanggli@gmail.com \
--cc=dlunev@chromium.org \
--cc=jason.lai@genesyslogic.com.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=takahiro.akashi@linaro.org \
--cc=ulf.hansson@linaro.org \
--cc=victor.shih@genesyslogic.com.tw \
--cc=victorshihgli@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome