Introduce the request_atomic() for the host
Subsystems (3)
Baolin Wang
maintainercover Introduce the request_atomic() for the host
This patch set introduces a new request_atomic() interface for the MMC host controller, which is used to submit a request to host in the atomic context, such as in the irq hard handler, to reduce the request latency.
Any comments are welcome. Thanks.
Baolin Wang (3):
mmc: host: Introduce the request_atomic() for the host
mmc: host: sdhci-sprd: Implement the request_atomic() API
mmc: host: hsq: Support request_atomic() API
drivers/mmc/host/mmc_hsq.c | 5 ++++- drivers/mmc/host/sdhci-sprd.c | 28 ++++++++++++++++++++++++++-- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 5 files changed, 53 insertions(+), 11 deletions(-)
Signature · 1 line
1.9.1
Baolin Wang
maintainerPATCH RESEND 1/3 mmc: host: Introduce the request_atomic() for the host
The SD host controller can process one request in the atomic context if the card is nonremovable, which means we can submit next request in the irq hard handler when using the MMC software queue to reduce the latency. Thus this patch adds a new API request_atomic() for the host controller and implement it for the SD host controller.
--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 3 files changed, 23 insertions(+), 8 deletions(-)
drivers/mmc/host/sdhci.c +19 -8
@@ -2016,17 +2016,12 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,* * \*****************************************************************************/ -void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +static void sdhci_start_request (struct mmc_host *mmc,struct mmc_request *mrq, +int present) { -struct sdhci_host *host; -int present; +struct sdhci_host *host =mmc_priv (mmc);unsigned long flags; - host =mmc_priv (mmc); - -/* Firstly check card presence */ - present = mmc->ops->get_cd (mmc); -spin_lock_irqsave (&host->lock, flags);sdhci_led_activate (host);
@@ -2043,6 +2038,22 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)spin_unlock_irqrestore (&host->lock, flags); } + +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq) +{ +sdhci_start_request (mmc, mrq,1 ); +} +EXPORT_SYMBOL_GPL (sdhci_request_atomic); + +void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +{ +int present; + +/* Firstly check card presence */ + present = mmc->ops->get_cd (mmc); + +sdhci_start_request (mmc, mrq, present); +}EXPORT_SYMBOL_GPL (sdhci_request);void sdhci_set_bus_width (struct sdhci_host *host,int width)
drivers/mmc/host/sdhci.h +1 -0
@@ -775,6 +775,7 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,void sdhci_set_power_noreg (struct sdhci_host *host,unsigned char mode,unsigned short vdd);void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq); +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq);void sdhci_set_bus_width (struct sdhci_host *host,int width);void sdhci_reset (struct sdhci_host *host,u8 mask);void sdhci_set_uhs_signaling (struct sdhci_host *host,unsigned timing);
include/linux/mmc/host.h +3 -0
@@ -92,6 +92,9 @@ struct mmc_host_ops { int err);void (*pre_req)(struct mmc_host *host,struct mmc_request *req);void (*request)(struct mmc_host *host,struct mmc_request *req); +/* Submit one request to host in atomic context. */ +void (*request_atomic)(struct mmc_host *host, +struct mmc_request *req);/* * Avoid calling the next three functions too often or in a "fast
Signature · 1 line
1.9.1
Baolin Wang
maintainerPATCH RESEND 2/3 mmc: host: sdhci-sprd: Implement the request_atomic() API
In reply to Baolin WangImplement the request_atomic() API for nonremovable cards, that means we can submit next request in the irq hard handler context to reduce latency.
--- drivers/mmc/host/sdhci-sprd.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-sprd.c +26 -2
@@ -426,6 +426,27 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)sdhci_request (mmc, mrq); } +static void sdhci_sprd_request_atomic (struct mmc_host *mmc, +struct mmc_request *mrq) +{ +struct sdhci_host *host =mmc_priv (mmc); +struct sdhci_sprd_host *sprd_host =TO_SPRD_HOST (host); + + host->flags |= sprd_host->flags &SDHCI_AUTO_CMD23 ; + +/* +* From version 4.10 onward, ARGUMENT2 register is also as 32-bit +* block count register which doesn't support stuff bits of +* CMD23 argument on Spreadtrum's sd host controller. +*/ +if (host->version >=SDHCI_SPEC_410 && + mrq->sbc && (mrq->sbc->arg &SDHCI_SPRD_ARG2_STUFF ) && + (host->flags &SDHCI_AUTO_CMD23 )) + host->flags &= ~SDHCI_AUTO_CMD23 ; + +sdhci_request_atomic (mmc, mrq); +} +static int sdhci_sprd_voltage_switch (struct mmc_host *mmc,struct mmc_ios *ios) {struct sdhci_host *host =mmc_priv (mmc);
@@ -561,6 +582,11 @@ static int sdhci_sprd_probe(struct platform_device *pdev)if (ret) goto pltfm_free; +if (!mmc_card_is_removable (host->mmc)) + host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic; +else + host->always_defer_done = true; + sprd_host =TO_SPRD_HOST (host);sdhci_sprd_phy_param_parse (sprd_host, pdev->dev.of_node);
@@ -654,8 +680,6 @@ static int sdhci_sprd_probe(struct platform_device *pdev)if (ret) goto err_cleanup_host; - host->always_defer_done = true; - ret =__sdhci_add_host (host);if (ret) goto err_cleanup_host;
Signature · 1 line
1.9.1
Baolin Wang
maintainerPATCH RESEND 3/3 mmc: host: hsq: Support request_atomic() API
In reply to Baolin WangAdd support to submit a request by request_atomic() API.
--- drivers/mmc/host/mmc_hsq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/host/mmc_hsq.c +4 -1
@@ -41,7 +41,10 @@ static void mmc_hsq_pump_requests(struct mmc_hsq *hsq)spin_unlock_irqrestore (&hsq->lock, flags); - mmc->ops->request (mmc, hsq->mrq); +if (mmc->ops->request_atomic) + mmc->ops->request_atomic (mmc, hsq->mrq); +else + mmc->ops->request (mmc, hsq->mrq); }static void mmc_hsq_update_next_tag (struct mmc_hsq *hsq,int remains)
Signature · 1 line
1.9.1
Re: [RESEND PATCH 2/3] mmc: host: sdhci-sprd: Implement the request_atomic() API
In reply to Baolin WangQuoted 25 lines · Baolin Wang
Implement the
request_atomic()API for nonremovable cards, that means we can submit next request in the irq hard handler context to reduce latency.Signed-off-by Baolin Wang <[email protected]>--- drivers/mmc/host/sdhci-sprd.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-sprd.c +7
-0@@ -426,6 +426,27 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)sdhci_request (mmc, mrq); } +static void sdhci_sprd_request_atomic (struct mmc_host *mmc, +struct mmc_request *mrq) +{ +struct sdhci_host *host =mmc_priv (mmc); +struct sdhci_sprd_host *sprd_host =TO_SPRD_HOST (host); + + host->flags |= sprd_host->flags &SDHCI_AUTO_CMD23 ;
drivers/mmc/host/sdhci-sprd.c static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) · line 445
Quoted 10 lines
drivers/mmc/host/sdhci-sprd.c +10
-0+ +/* +* From version 4.10 onward, ARGUMENT2 register is also as 32-bit +* block count register which doesn't support stuff bits of +* CMD23 argument on Spreadtrum's sd host controller. +*/ +if (host->version >=SDHCI_SPEC_410 && + mrq->sbc && (mrq->sbc->arg &SDHCI_SPRD_ARG2_STUFF ) && + (host->flags &SDHCI_AUTO_CMD23 )) + host->flags &= ~SDHCI_AUTO_CMD23 ;
Looks like the above code is a copy of what is done in sdhci_sprd_request(). Perhaps add a helper function that deals with this to avoid open coding?
Quoted 29 lines
drivers/mmc/host/sdhci-sprd.c +9
-3+ +sdhci_request_atomic (mmc, mrq); +} +static int sdhci_sprd_voltage_switch (struct mmc_host *mmc,struct mmc_ios *ios) {struct sdhci_host *host =mmc_priv (mmc);@@ -561,6 +582,11 @@ static int sdhci_sprd_probe(struct platform_device *pdev)if (ret) goto pltfm_free; +if (!mmc_card_is_removable (host->mmc)) + host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic; +else + host->always_defer_done = true; + sprd_host =TO_SPRD_HOST (host);sdhci_sprd_phy_param_parse (sprd_host, pdev->dev.of_node);@@ -654,8 +680,6 @@ static int sdhci_sprd_probe(struct platform_device *pdev)if (ret) goto err_cleanup_host; - host->always_defer_done = true; - ret =__sdhci_add_host (host);if (ret) goto err_cleanup_host; --
Quoted 2 lines
1.9.1
Kind regards
Uffe
Re: [RESEND PATCH 1/3] mmc: host: Introduce the request_atomic() for the host
In reply to Baolin WangQuoted 7 lines · Baolin Wang
The SD host controller can process one request in the atomic context if the card is nonremovable, which means we can submit next request in the irq hard handler when using the MMC software queue to reduce the latency. Thus this patch adds a new API
request_atomic()for the host controller and implement it for the SD host controller.
Quoted 7 lines
Suggested-by Adrian Hunter <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 3 files changed, 23 insertions(+), 8 deletions(-)
I think the code split of the changes in the series can be improved a bit, so I suggest you move the code around in the series to reach this:
1. A patch that adds the new host ops callback, combined with the change you have in patch3.
2. The sdhci core specific changes, from $subject patch.
3. The sdhci-sprd changes, as in patch2.
Other than that, I think the code looks good to me, besides a minor comment on patch2, see separate reply.
Kind regards
Uffe
Quoted 78 lines
drivers/mmc/host/sdhci.c +19
-8@@ -2016,17 +2016,12 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,* * \*****************************************************************************/ -void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +static void sdhci_start_request (struct mmc_host *mmc,struct mmc_request *mrq, +int present) { -struct sdhci_host *host; -int present; +struct sdhci_host *host =mmc_priv (mmc);unsigned long flags; - host =mmc_priv (mmc); - -/* Firstly check card presence */ - present = mmc->ops->get_cd (mmc); -spin_lock_irqsave (&host->lock, flags);sdhci_led_activate (host);@@ -2043,6 +2038,22 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)spin_unlock_irqrestore (&host->lock, flags); } + +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq) +{ +sdhci_start_request (mmc, mrq,1 ); +} +EXPORT_SYMBOL_GPL (sdhci_request_atomic); + +void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +{ +int present; + +/* Firstly check card presence */ + present = mmc->ops->get_cd (mmc); + +sdhci_start_request (mmc, mrq, present); +}EXPORT_SYMBOL_GPL (sdhci_request);void sdhci_set_bus_width (struct sdhci_host *host,int width)drivers/mmc/host/sdhci.h +1
-0@@ -775,6 +775,7 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,void sdhci_set_power_noreg (struct sdhci_host *host,unsigned char mode,unsigned short vdd);void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq); +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq);void sdhci_set_bus_width (struct sdhci_host *host,int width);void sdhci_reset (struct sdhci_host *host,u8 mask);void sdhci_set_uhs_signaling (struct sdhci_host *host,unsigned timing);include/linux/mmc/host.h +3
-1@@ -92,6 +92,9 @@ struct mmc_host_ops { int err);void (*pre_req)(struct mmc_host *host,struct mmc_request *req);void (*request)(struct mmc_host *host,struct mmc_request *req); +/* Submit one request to host in atomic context. */ +void (*request_atomic)(struct mmc_host *host, +struct mmc_request *req);/* * Avoid calling the next three functions too often or in a "fast -- 1.9.1
Adrian Hunter
maintainerRe: [RESEND PATCH 1/3] mmc: host: Introduce the request_atomic() for the host
In reply to Baolin WangQuoted 79 lines · Baolin Wang
The SD host controller can process one request in the atomic context if the card is nonremovable, which means we can submit next request in the irq hard handler when using the MMC software queue to reduce the latency. Thus this patch adds a new API
request_atomic()for the host controller and implement it for the SD host controller.Suggested-by Adrian Hunter <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 3 files changed, 23 insertions(+), 8 deletions(-)drivers/mmc/host/sdhci.c +19
-8@@ -2016,17 +2016,12 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,* * \*****************************************************************************/ -void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +static void sdhci_start_request (struct mmc_host *mmc,struct mmc_request *mrq, +int present) { -struct sdhci_host *host; -int present; +struct sdhci_host *host =mmc_priv (mmc);unsigned long flags; - host =mmc_priv (mmc); - -/* Firstly check card presence */ - present = mmc->ops->get_cd (mmc); -spin_lock_irqsave (&host->lock, flags);sdhci_led_activate (host);@@ -2043,6 +2038,22 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)spin_unlock_irqrestore (&host->lock, flags); } + +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq) +{ +sdhci_start_request (mmc, mrq,1 ); +} +EXPORT_SYMBOL_GPL (sdhci_request_atomic); + +void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +{ +int present; + +/* Firstly check card presence */ + present = mmc->ops->get_cd (mmc); + +sdhci_start_request (mmc, mrq, present); +}EXPORT_SYMBOL_GPL (sdhci_request);void sdhci_set_bus_width (struct sdhci_host *host,int width)drivers/mmc/host/sdhci.h +1
-0@@ -775,6 +775,7 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,void sdhci_set_power_noreg (struct sdhci_host *host,unsigned char mode,unsigned short vdd);void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq); +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq);void sdhci_set_bus_width (struct sdhci_host *host,int width);void sdhci_reset (struct sdhci_host *host,u8 mask);void sdhci_set_uhs_signaling (struct sdhci_host *host,unsigned timing);include/linux/mmc/host.h +0
-0
include/linux/mmc/host.h struct mmc_host_ops { · line 97
Quoted 6 lines
include/linux/mmc/host.h +3
-0@@ -92,6 +92,9 @@ struct mmc_host_ops { int err);void (*pre_req)(struct mmc_host *host,struct mmc_request *req);void (*request)(struct mmc_host *host,struct mmc_request *req); +/* Submit one request to host in atomic context. */ +void (*request_atomic)(struct mmc_host *host, +struct mmc_request *req);
This doesn't have the flexibility to return "busy". For example, sdhci_send_command() will potentially wait quite some time if the inhibit bits are set. That is not good in interrupt context. It would be better to return immediately in that case and have the caller fall back to a non-atomic context. Thoughts?
Quoted 4 lines
include/linux/mmc/host.h +0
-0/* * Avoid calling the next three functions too often or in a "fast
Baolin Wang
maintainerRe: [RESEND PATCH 1/3] mmc: host: Introduce the request_atomic() for the host
In reply to Ulf HanssonQuoted 21 lines · Ulf Hansson
Quoted 7 lines · Baolin Wang
The SD host controller can process one request in the atomic context if the card is nonremovable, which means we can submit next request in the irq hard handler when using the MMC software queue to reduce the latency. Thus this patch adds a new API
request_atomic()for the host controller and implement it for the SD host controller.Quoted 7 lines
Suggested-by Adrian Hunter <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 3 files changed, 23 insertions(+), 8 deletions(-)I think the code split of the changes in the series can be improved a bit, so I suggest you move the code around in the series to reach this:
Quoted 7 lines
1. A patch that adds the new host ops callback, combined with the change you have in patch3.
2. The sdhci core specific changes, from $subject patch.
3. The sdhci-sprd changes, as in patch2.Other than that, I think the code looks good to me, besides a minor comment on patch2, see separate reply.
Sure. Will do as you suggested. Thanks.
Signature · 1 line
Baolin Wang
Baolin Wang
maintainerRe: [RESEND PATCH 2/3] mmc: host: sdhci-sprd: Implement the request_atomic() API
In reply to Ulf HanssonQuoted 33 lines · Ulf Hansson
Quoted 31 lines · Baolin Wang
Implement the
request_atomic()API for nonremovable cards, that means we can submit next request in the irq hard handler context to reduce latency.Signed-off-by Baolin Wang <[email protected]>--- drivers/mmc/host/sdhci-sprd.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-sprd.c +13
-0@@ -426,6 +426,27 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)sdhci_request (mmc, mrq); } +static void sdhci_sprd_request_atomic (struct mmc_host *mmc, +struct mmc_request *mrq) +{ +struct sdhci_host *host =mmc_priv (mmc); +struct sdhci_sprd_host *sprd_host =TO_SPRD_HOST (host); + + host->flags |= sprd_host->flags &SDHCI_AUTO_CMD23 ; + +/* +* From version 4.10 onward, ARGUMENT2 register is also as 32-bit +* block count register which doesn't support stuff bits of +* CMD23 argument on Spreadtrum's sd host controller. +*/
Quoted 8 lines
drivers/mmc/host/sdhci-sprd.c static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) · line 445
Quoted 4 lines
drivers/mmc/host/sdhci-sprd.c +4
-0+if (host->version >=SDHCI_SPEC_410 && + mrq->sbc && (mrq->sbc->arg &SDHCI_SPRD_ARG2_STUFF ) && + (host->flags &SDHCI_AUTO_CMD23 )) + host->flags &= ~SDHCI_AUTO_CMD23 ;Looks like the above code is a copy of what is done in
sdhci_sprd_request(). Perhaps add a helper function that deals with this to avoid open coding?
Sure. Will do in next version. Thanks.
Quoted 35 lines
Quoted 30 lines
drivers/mmc/host/sdhci-sprd.c +9
-3+ +sdhci_request_atomic (mmc, mrq); +} +static int sdhci_sprd_voltage_switch (struct mmc_host *mmc,struct mmc_ios *ios) {struct sdhci_host *host =mmc_priv (mmc);@@ -561,6 +582,11 @@ static int sdhci_sprd_probe(struct platform_device *pdev)if (ret) goto pltfm_free; +if (!mmc_card_is_removable (host->mmc)) + host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic; +else + host->always_defer_done = true; + sprd_host =TO_SPRD_HOST (host);sdhci_sprd_phy_param_parse (sprd_host, pdev->dev.of_node);@@ -654,8 +680,6 @@ static int sdhci_sprd_probe(struct platform_device *pdev)if (ret) goto err_cleanup_host; - host->always_defer_done = true; - ret =__sdhci_add_host (host);if (ret) goto err_cleanup_host; --Quoted 2 lines
1.9.1
Kind regards
Uffe
Signature · 1 line
Baolin Wang
Baolin Wang
maintainerRe: [RESEND PATCH 1/3] mmc: host: Introduce the request_atomic() for the host
In reply to Adrian HunterQuoted 85 lines · Adrian Hunter
Quoted 83 lines · Baolin Wang
The SD host controller can process one request in the atomic context if the card is nonremovable, which means we can submit next request in the irq hard handler when using the MMC software queue to reduce the latency. Thus this patch adds a new API
request_atomic()for the host controller and implement it for the SD host controller.Suggested-by Adrian Hunter <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 3 files changed, 23 insertions(+), 8 deletions(-)drivers/mmc/host/sdhci.c +19
-8@@ -2016,17 +2016,12 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,* * \*****************************************************************************/ -void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +static void sdhci_start_request (struct mmc_host *mmc,struct mmc_request *mrq, +int present) { -struct sdhci_host *host; -int present; +struct sdhci_host *host =mmc_priv (mmc);unsigned long flags; - host =mmc_priv (mmc); - -/* Firstly check card presence */ - present = mmc->ops->get_cd (mmc); -spin_lock_irqsave (&host->lock, flags);sdhci_led_activate (host);@@ -2043,6 +2038,22 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)spin_unlock_irqrestore (&host->lock, flags); } + +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq) +{ +sdhci_start_request (mmc, mrq,1 ); +} +EXPORT_SYMBOL_GPL (sdhci_request_atomic); + +void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +{ +int present; + +/* Firstly check card presence */ + present = mmc->ops->get_cd (mmc); + +sdhci_start_request (mmc, mrq, present); +}EXPORT_SYMBOL_GPL (sdhci_request);void sdhci_set_bus_width (struct sdhci_host *host,int width)drivers/mmc/host/sdhci.h +1
-0@@ -775,6 +775,7 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,void sdhci_set_power_noreg (struct sdhci_host *host,unsigned char mode,unsigned short vdd);void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq); +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq);void sdhci_set_bus_width (struct sdhci_host *host,int width);void sdhci_reset (struct sdhci_host *host,u8 mask);void sdhci_set_uhs_signaling (struct sdhci_host *host,unsigned timing);include/linux/mmc/host.h +1
-0@@ -92,6 +92,9 @@ struct mmc_host_ops { int err);void (*pre_req)(struct mmc_host *host,struct mmc_request *req);void (*request)(struct mmc_host *host,struct mmc_request *req); +/* Submit one request to host in atomic context. */
Quoted 8 lines
include/linux/mmc/host.h struct mmc_host_ops { · line 97
Quoted 2 lines
include/linux/mmc/host.h +2
-0+void (*request_atomic)(struct mmc_host *host, +struct mmc_request *req);This doesn't have the flexibility to return "busy". For example,
sdhci_send_command()will potentially wait quite some time if the inhibit bits are set. That is not good in interrupt context. It would be better to return immediately in that case and have the caller fall back to a non-atomic context. Thoughts?
Yes, I unserstood your concern. But the sdhci_send_command() is already under the spin_lock_irqsave() protection, which will also disable the interrupt for some time if the inhibit bits are set. That is same with moving it in interrupt context.
Moreover, if the previous command complete interrupt and transfer complete interrupt are normal, we should not meet this issue of polling inhibit bits (I have not met this issue on my platform). So I think we can remove the polling here? If the inhibit bits are set, I think the command complete interrupt or the transfer complete interrupt have been abnormal, so we can just return the error here. What do you think? Thanks.
Signature · 1 line
Baolin Wang
Adrian Hunter
maintainerRe: [RESEND PATCH 1/3] mmc: host: Introduce the request_atomic() for the host
Quoted 95 lines · Baolin Wang
Quoted 85 lines · Adrian Hunter
Quoted 83 lines · Baolin Wang
The SD host controller can process one request in the atomic context if the card is nonremovable, which means we can submit next request in the irq hard handler when using the MMC software queue to reduce the latency. Thus this patch adds a new API
request_atomic()for the host controller and implement it for the SD host controller.Suggested-by Adrian Hunter <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 3 files changed, 23 insertions(+), 8 deletions(-)drivers/mmc/host/sdhci.c +19
-8@@ -2016,17 +2016,12 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,* * \*****************************************************************************/ -void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +static void sdhci_start_request (struct mmc_host *mmc,struct mmc_request *mrq, +int present) { -struct sdhci_host *host; -int present; +struct sdhci_host *host =mmc_priv (mmc);unsigned long flags; - host =mmc_priv (mmc); - -/* Firstly check card presence */ - present = mmc->ops->get_cd (mmc); -spin_lock_irqsave (&host->lock, flags);sdhci_led_activate (host);@@ -2043,6 +2038,22 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)spin_unlock_irqrestore (&host->lock, flags); } + +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq) +{ +sdhci_start_request (mmc, mrq,1 ); +} +EXPORT_SYMBOL_GPL (sdhci_request_atomic); + +void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +{ +int present; + +/* Firstly check card presence */ + present = mmc->ops->get_cd (mmc); + +sdhci_start_request (mmc, mrq, present); +}EXPORT_SYMBOL_GPL (sdhci_request);void sdhci_set_bus_width (struct sdhci_host *host,int width)drivers/mmc/host/sdhci.h +1
-0@@ -775,6 +775,7 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,void sdhci_set_power_noreg (struct sdhci_host *host,unsigned char mode,unsigned short vdd);void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq); +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq);void sdhci_set_bus_width (struct sdhci_host *host,int width);void sdhci_reset (struct sdhci_host *host,u8 mask);void sdhci_set_uhs_signaling (struct sdhci_host *host,unsigned timing);include/linux/mmc/host.h +1
-0@@ -92,6 +92,9 @@ struct mmc_host_ops { int err);void (*pre_req)(struct mmc_host *host,struct mmc_request *req);void (*request)(struct mmc_host *host,struct mmc_request *req); +/* Submit one request to host in atomic context. */ Quoted 8 lines
include/linux/mmc/host.h struct mmc_host_ops { · line 97
Quoted 2 lines
include/linux/mmc/host.h +2
-0+void (*request_atomic)(struct mmc_host *host, +struct mmc_request *req);This doesn't have the flexibility to return "busy". For example,
sdhci_send_command()will potentially wait quite some time if the inhibit bits are set. That is not good in interrupt context. It would be better to return immediately in that case and have the caller fall back to a non-atomic context. Thoughts?
Quoted 4 lines
Yes, I unserstood your concern. But the
sdhci_send_command()is already under thespin_lock_irqsave()protection, which will also disable the interrupt for some time if the inhibit bits are set. That is same with moving it in interrupt context.
It is, but I would like to fix that too.
Quoted 9 lines
Moreover, if the previous command complete interrupt and transfer complete interrupt are normal, we should not meet this issue of polling inhibit bits (I have not met this issue on my platform). So I think we can remove the polling here? If the inhibit bits are set, I think the command complete interrupt or the transfer complete interrupt have been abnormal, so we can just return the error here. What do you think? Thanks.
I suspect the inhibit polling might be needed for some host controllers in some situations. ie. taking it out would likely break things.
Baolin Wang
maintainerRe: [RESEND PATCH 1/3] mmc: host: Introduce the request_atomic() for the host
Quoted 97 lines · Adrian Hunter
Quoted 95 lines · Baolin Wang
Quoted 93 lines · Adrian Hunter
Quoted 79 lines · Baolin Wang
The SD host controller can process one request in the atomic context if the card is nonremovable, which means we can submit next request in the irq hard handler when using the MMC software queue to reduce the latency. Thus this patch adds a new API
request_atomic()for the host controller and implement it for the SD host controller.Suggested-by Adrian Hunter <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 3 files changed, 23 insertions(+), 8 deletions(-)drivers/mmc/host/sdhci.c +19
-8@@ -2016,17 +2016,12 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,* * \*****************************************************************************/ -void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +static void sdhci_start_request (struct mmc_host *mmc,struct mmc_request *mrq, +int present) { -struct sdhci_host *host; -int present; +struct sdhci_host *host =mmc_priv (mmc);unsigned long flags; - host =mmc_priv (mmc); - -/* Firstly check card presence */ - present = mmc->ops->get_cd (mmc); -spin_lock_irqsave (&host->lock, flags);sdhci_led_activate (host);@@ -2043,6 +2038,22 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)spin_unlock_irqrestore (&host->lock, flags); } + +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq) +{ +sdhci_start_request (mmc, mrq,1 ); +} +EXPORT_SYMBOL_GPL (sdhci_request_atomic); + +void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) +{ +int present; + +/* Firstly check card presence */ + present = mmc->ops->get_cd (mmc); + +sdhci_start_request (mmc, mrq, present); +}EXPORT_SYMBOL_GPL (sdhci_request);void sdhci_set_bus_width (struct sdhci_host *host,int width)drivers/mmc/host/sdhci.h +1
-0@@ -775,6 +775,7 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,void sdhci_set_power_noreg (struct sdhci_host *host,unsigned char mode,unsigned short vdd);void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq); +void sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq);void sdhci_set_bus_width (struct sdhci_host *host,int width);void sdhci_reset (struct sdhci_host *host,u8 mask);void sdhci_set_uhs_signaling (struct sdhci_host *host,unsigned timing);include/linux/mmc/host.h +0
-0include/linux/mmc/host.h struct mmc_host_ops { · line 97
Quoted 6 lines
include/linux/mmc/host.h +3
-0@@ -92,6 +92,9 @@ struct mmc_host_ops { int err);void (*pre_req)(struct mmc_host *host,struct mmc_request *req);void (*request)(struct mmc_host *host,struct mmc_request *req); +/* Submit one request to host in atomic context. */ +void (*request_atomic)(struct mmc_host *host, +struct mmc_request *req);This doesn't have the flexibility to return "busy". For example,
sdhci_send_command()will potentially wait quite some time if the inhibit bits are set. That is not good in interrupt context. It would be better to return immediately in that case and have the caller fall back to a non-atomic context. Thoughts?
Quoted 6 lines
Quoted 4 lines
Yes, I unserstood your concern. But the
sdhci_send_command()is already under thespin_lock_irqsave()protection, which will also disable the interrupt for some time if the inhibit bits are set. That is same with moving it in interrupt context.It is, but I would like to fix that too.
OK. Like you suggested, cause we've aleady decided how to complete a request by sdhci_defer_done(), I need think about how to change to a non-atomic context for this unusual case.
And since the original sdhci_send_command() has the same problem as I said, I perfer to create another patch set to fix this issue.
Quoted 11 lines
Quoted 8 lines
Moreover, if the previous command complete interrupt and transfer complete interrupt are normal, we should not meet this issue of polling inhibit bits (I have not met this issue on my platform). So I think we can remove the polling here? If the inhibit bits are set, I think the command complete interrupt or the transfer complete interrupt have been abnormal, so we can just return the error here. What do you think? Thanks.
I suspect the inhibit polling might be needed for some host controllers in some situations. ie. taking it out would likely break things.
Make sense.
--
Baolin Wang