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 V14 07/21] mmc: core: Support UHS-II card control and access
Date: Wed, 22 May 2024 12:11:22 +0300 [thread overview]
Message-ID: <822f7274-5f34-4186-b859-938e0401caa8@intel.com> (raw)
In-Reply-To: <CAK00qKDzY7gSALrKLqdQg-JdwXDP6NDt17oAX2aoj4P-yfDkPA@mail.gmail.com>
On 22/05/24 12:04, Victor Shih wrote:
> On Tue, Jan 30, 2024 at 5:36 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>> On 27/01/24 10:28, Victor Shih wrote:
>>> On Tue, Jan 23, 2024 at 2:28 PM Victor Shih <victorshihgli@gmail.com> wrote:
>>>>
>>>> From: Victor Shih <victor.shih@genesyslogic.com.tw>
>>>>
>>>> Embed UHS-II access/control functionality into the MMC request
>>>> processing flow.
>>>>
>>>> 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>
>>>> ---
>>>>
>>>> Updates in V13:
>>>> - Separate __mmc_go_idle() into one patch for re-factorring the code.
>>>> - Move mmc_decode_scr declaration to sd.h.
>>>> - Ues uhs2_sd_tran to stead MMC_UHS2_SD_TRAN.
>>>> - Drop unnecessary comment.
>>>>
>>>> Updates in V12:
>>>> - Use mmc_op_multi() to check DCMD which supports multi read/write
>>>> in mmc_uhs2_prepare_cmd().
>>>>
>>>> Updates in V10:
>>>> - Move some definitions of PatchV9[02/23] to PatchV10[06/23].
>>>> - Move some definitions of PatchV9[05/23] to PatchV10[06/23].
>>>> - Drop do_multi in the mmc_blk_rw_rq_prep().
>>>> - Use tmode_half_duplex to instead of uhs2_tmode0_flag.
>>>> - Move entire control of the tmode into mmc_uhs2_prepare_cmd().
>>>>
>>>> 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.
>>>>
>>>> ---
>>>>
>>>> drivers/mmc/core/core.c | 10 +-
>>>> drivers/mmc/core/sd.c | 10 +-
>>>> drivers/mmc/core/sd.h | 5 +
>>>> drivers/mmc/core/sd_ops.c | 9 +
>>>> drivers/mmc/core/sd_ops.h | 17 +
>>>> drivers/mmc/core/sd_uhs2.c | 1115 ++++++++++++++++++++++++++++++++++--
>>>> include/linux/mmc/core.h | 13 +
>>>> include/linux/mmc/host.h | 15 +
>>>> 8 files changed, 1155 insertions(+), 39 deletions(-)
>>>>
>>>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>>>> index 2edf31492a5d..be77cebe1fb8 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);
>>>>
>>>
>>> Hi, Adrian
>>>
>>> I referenced your comments of the V9:
>>>
>>> Refer:
>>> https://patchwork.kernel.org/project/linux-mmc/patch/20230721101349.12387-7-victorshihgli@gmail.com/
>>>
>>> My understanding is as follows, please correct me if there are any mistakes.
>>> There is already "struct uhs2_command *uhs2_cmd" in struct mmc_command.
>>> If I also put "__be32 payload[4]" in struct mmc_command.
>>> The code will become:
>>> mmc_uhs2_card_prepare_cmd(host, mrq, *mrq->cmd->uhs2_cmd, mrq->cmd->payload);
>>> But a null pointer problem occurs when sending commands like COM0(mmc_go_idle).
>>> In this case I just can only plan for the time being as follows:
>>>
>>> if (mrq->cmd->uhs2_cmd)
>>> mmc_uhs2_card_prepare_cmd(host, mrq, *mrq->cmd->uhs2_cmd,
>>> mrq->cmd->payload);
>>> else
>>> mmc_uhs2_card_prepare_cmd(host, mrq, uhs2_cmd, payload);
>>>
>>> Would you give me any other advice?
>>
>> struct uhs2_command uhs2_cmd should not be on the stack local to
>> mmc_start_request(). Probably moving it to struct mmc_request
>> is as good as any other option. So starting like below and
>> then with whatever other changes are needed to make it work.
>>
>>
>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>> index be77cebe1fb8..68496c51a521 100644
>> --- a/drivers/mmc/core/core.c
>> +++ b/drivers/mmc/core/core.c
>> @@ -334,8 +334,6 @@ 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);
>> @@ -353,7 +351,7 @@ 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);
>> + mmc_uhs2_card_prepare_cmd(host, mrq);
>>
>> led_trigger_event(host->led, LED_FULL);
>> __mmc_start_request(host, mrq);
>> @@ -434,8 +432,6 @@ EXPORT_SYMBOL(mmc_wait_for_req_done);
>> */
>> int mmc_cqe_start_req(struct mmc_host *host, struct mmc_request *mrq)
>> {
>> - struct uhs2_command uhs2_cmd;
>> - __be32 payload[4]; /* for maximum size */
>> int err;
>>
>> /*
>> @@ -456,7 +452,7 @@ int mmc_cqe_start_req(struct mmc_host *host, struct mmc_request *mrq)
>> if (err)
>> goto out_err;
>>
>> - mmc_uhs2_card_prepare_cmd(host, mrq, uhs2_cmd, payload);
>> + mmc_uhs2_card_prepare_cmd(host, mrq);
>>
>> err = host->cqe_ops->cqe_request(host, mrq);
>> if (err)
>> diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h
>> index d3a3465c7669..e3af68a52de8 100644
>> --- a/drivers/mmc/core/sd_ops.h
>> +++ b/drivers/mmc/core/sd_ops.h
>> @@ -24,14 +24,10 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr);
>> int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card);
>> void mmc_uhs2_prepare_cmd(struct mmc_host *host, struct mmc_request *mrq);
>>
>> -static inline void mmc_uhs2_card_prepare_cmd(struct mmc_host *host, struct mmc_request *mrq,
>> - struct uhs2_command uhs2_cmd, __be32 payload[4])
>> +static inline void mmc_uhs2_card_prepare_cmd(struct mmc_host *host, struct mmc_request *mrq)
>> {
>> - if (host->uhs2_sd_tran) {
>> - uhs2_cmd.payload = payload;
>> - mrq->cmd->uhs2_cmd = &uhs2_cmd;
>> + if (host->uhs2_sd_tran)
>> mmc_uhs2_prepare_cmd(host, mrq);
>> - }
>> }
>>
>> static inline int mmc_sd_can_poweroff_notify(struct mmc_card *card)
>> diff --git a/drivers/mmc/core/sd_uhs2.c b/drivers/mmc/core/sd_uhs2.c
>> index c46729d85644..9cabb6937dc1 100644
>> --- a/drivers/mmc/core/sd_uhs2.c
>> +++ b/drivers/mmc/core/sd_uhs2.c
>> @@ -1194,6 +1194,7 @@ void mmc_uhs2_prepare_cmd(struct mmc_host *host, struct mmc_request *mrq)
>> u8 plen;
>>
>> cmd = mrq->cmd;
>> + cmd->uhs2_cmd = &mrq->uhs2_cmd;
>> header = host->card->uhs2_config.node_id;
>> if ((cmd->flags & MMC_CMD_MASK) == MMC_CMD_ADTC)
>> header |= UHS2_PACKET_TYPE_DCMD;
>> diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
>> index f30f6be86f66..83c901794c17 100644
>> --- a/include/linux/mmc/core.h
>> +++ b/include/linux/mmc/core.h
>> @@ -23,13 +23,18 @@ enum mmc_blk_status {
>> MMC_BLK_NEW_REQUEST,
>> };
>>
>> +#define UHS2_MAX_PAYLOAD_LEN 2
>> +#define UHS2_MAX_RESP_LEN 20
>> +
>> struct uhs2_command {
>> u16 header;
>> u16 arg;
>> - __be32 *payload;
>> - u32 payload_len;
>> - u32 packet_len;
>> + __be32 payload[UHS2_MAX_PAYLOAD_LEN];
>> + u8 payload_len;
>> + u8 packet_len; // TODO: is this really needed?
>> u8 tmode_half_duplex;
>> + u8 uhs2_resp_len; /* UHS2 native cmd resp len */
>> + u8 uhs2_resp[UHS2_MAX_RESP_LEN]; /* UHS2 native cmd resp */
>> };
>>
>> struct mmc_command {
>> @@ -119,8 +124,6 @@ struct mmc_command {
>> struct mmc_request *mrq; /* associated request */
>>
>> struct uhs2_command *uhs2_cmd; /* UHS2 command */
>> - u8 *uhs2_resp; /* UHS2 native cmd resp */
>> - u8 uhs2_resp_len; /* UHS2 native cmd resp len */
>> };
>>
>> struct mmc_data {
>> @@ -179,6 +182,7 @@ struct mmc_request {
>> const struct bio_crypt_ctx *crypto_ctx;
>> int crypto_key_slot;
>> #endif
>> + struct uhs2_command uhs2_cmd;
>> };
>>
>> struct mmc_card;
>>
>>
>>
>
> Hi, Adrian
>
> I have modified the above into patch#7 and patch#16 in the patch series v15.
> But I will submit the patch series v16 later.
> Please help review the changes in patch series v16.
>
> Thanks, Victor Shih
If you make a V16, please separate the Error Recovery mechanism added in V15
into a separate patch.
next prev parent reply other threads:[~2024-05-22 9:11 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 6:28 [PATCH V14 00/21] Add support UHS-II for GL9755 Victor Shih
2024-01-23 6:28 ` [PATCH V14 01/21] mmc: core: Cleanup printing of speed mode at card insertion Victor Shih
2024-01-23 6:28 ` [PATCH V14 02/21] mmc: core: Prepare to support SD UHS-II cards Victor Shih
2024-01-23 6:28 ` [PATCH V14 03/21] mmc: core: Announce successful insertion of an SD UHS-II card Victor Shih
2024-01-23 6:28 ` [PATCH V14 04/21] mmc: core: Extend support for mmc regulators with a vqmmc2 Victor Shih
2024-01-23 6:28 ` [PATCH V14 05/21] mmc: core: Add definitions for SD UHS-II cards Victor Shih
2024-01-23 6:28 ` [PATCH V14 06/21] mmc: core: Add New function to re-factoring the code Victor Shih
2024-01-23 6:28 ` [PATCH V14 07/21] mmc: core: Support UHS-II card control and access Victor Shih
2024-01-27 8:28 ` Victor Shih
2024-01-30 9:36 ` Adrian Hunter
2024-05-22 9:04 ` Victor Shih
2024-05-22 9:11 ` Adrian Hunter [this message]
2024-05-22 10:46 ` Victor Shih
2024-01-23 6:28 ` [PATCH V14 08/21] mmc: sdhci: add UHS-II related definitions in headers Victor Shih
2024-01-23 6:28 ` [PATCH V14 09/21] mmc: sdhci: add UHS-II module and add a kernel configuration Victor Shih
2024-01-23 6:28 ` [PATCH V14 10/21] mmc: sdhci-uhs2: dump UHS-II registers Victor Shih
2024-01-23 6:28 ` [PATCH V14 11/21] mmc: sdhci-uhs2: add reset function function Victor Shih
2024-01-23 6:28 ` [PATCH V14 12/21] mmc: sdhci-uhs2: add set_power() to support vdd2 Victor Shih
2024-01-23 6:28 ` [PATCH V14 13/21] mmc: sdhci-uhs2: add set_timeout() Victor Shih
2024-01-23 6:28 ` [PATCH V14 14/21] mmc: sdhci-uhs2: add set_ios() Victor Shih
2024-01-23 6:28 ` [PATCH V14 15/21] mmc: sdhci-uhs2: add uhs2_control() to initialise the interface Victor Shih
2024-01-23 6:28 ` [PATCH V14 16/21] mmc: sdhci-uhs2: add request() and others Victor Shih
2024-01-30 15:31 ` Adrian Hunter
2024-05-22 9:04 ` Victor Shih
2024-01-23 6:28 ` [PATCH V14 17/21] mmc: sdhci-uhs2: add irq() " Victor Shih
2024-01-23 6:28 ` [PATCH V14 18/21] mmc: sdhci-uhs2: add add_host() and others to set up the driver Victor Shih
2024-01-23 6:28 ` [PATCH V14 19/21] mmc: sdhci-uhs2: add pre-detect_init hook Victor Shih
2024-01-23 6:28 ` [PATCH V14 20/21] mmc: sdhci-pci: add UHS-II support framework Victor Shih
2024-01-23 6:28 ` [PATCH V14 21/21] mmc: sdhci-pci-gli: enable UHS-II mode for GL9755 Victor Shih
2024-03-16 19:54 ` [PATCH V14 00/21] Add support UHS-II " Victor Shih
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=822f7274-5f34-4186-b859-938e0401caa8@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
all inboxes | Powered by JetHome®