Introduce the request_atomic() for the host
Subsystems (3)
Baolin Wang
maintainerv5 cover 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.
Note, this patch set is based on Adrian's patch set:
https://www.spinics.net/lists/linux-mmc/msg58529.html
Any comments are welcome. Thanks.
Changes from v4:
- Remove redundant checking when warning the return value of request_atomic().
- Add acked tag from Adrian for patch 1.
- Re-implement the request_atomic() based on the Adrian's patch set.
Changes from v3:
- Move patch 3 of V3 patch set into patch 1.
- Add a warning for unexpected return value of request_atomic().
- Remove redundant checking of ops->request().
Changes from v2:
- Return busy flag if encountering unusual card busy state instead of polling in interrupt context.
- Add a work for HSQ to try again in non-atomic context if the host returns busy flag.
Changes from v1:
- Re-split the changes to make them more clear suggested by Ulf.
- Factor out the auto CMD23 checking into a separate function.
Baolin Wang (3):
mmc: host: Introduce the request_atomic() for the host
mmc: host: sdhci: Implement the request_atomic() API
mmc: host: sdhci-sprd: Implement the request_atomic() API
drivers/mmc/host/mmc_hsq.c | 29 ++++++++++++++++++++++++++++- drivers/mmc/host/mmc_hsq.h | 1 + drivers/mmc/host/sdhci-sprd.c | 23 ++++++++++++++++++++--- drivers/mmc/host/sdhci.c | 34 ++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 6 files changed, 87 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
Baolin Wang
maintainerPATCH v5 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 host software queue to reduce the latency. Thus this patch adds a new API request_atomic() for the host controller, as well as adding support for host software queue to submit a request by the new request_atomic() API.
Moreover there is an unusual case that the card is busy when trying to send a command, and we can not polling the card status in interrupt context by using request_atomic() to dispatch requests. Thus we should queue a work to try again in the non-atomic context in case the host releases the busy signal later.
--- drivers/mmc/host/mmc_hsq.c | 29 ++++++++++++++++++++++++++++- drivers/mmc/host/mmc_hsq.h | 1 + include/linux/mmc/host.h | 3 +++ 3 files changed, 32 insertions(+), 1 deletion(-)
drivers/mmc/host/mmc_hsq.c +28 -1
@@ -16,11 +16,20 @@#define HSQ_NUM_SLOTS 64#define HSQ_INVALID_TAG HSQ_NUM_SLOTS +static void mmc_hsq_retry_handler (struct work_struct *work) +{ + struct mmc_hsq *hsq = container_of(work, struct mmc_hsq, retry_work); +struct mmc_host *mmc = hsq->mmc; + + mmc->ops->request (mmc, hsq->mrq); +} +static void mmc_hsq_pump_requests (struct mmc_hsq *hsq) {struct mmc_host *mmc = hsq->mmc;struct hsq_slot *slot;unsigned long flags; +int ret =0 ;spin_lock_irqsave (&hsq->lock, flags);
@@ -42,7 +51,24 @@ 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) + ret = mmc->ops->request_atomic (mmc, hsq->mrq); +else + mmc->ops->request (mmc, hsq->mrq); + +/* +* If returning BUSY from request_atomic(), which means the card +* may be busy now, and we should change to non-atomic context to +* try again for this unusual case, to avoid time-consuming operations +* in the atomic context. +* +* Note: we just give a warning for other error cases, since the host +* driver will handle them. +*/ +if (ret == -EBUSY ) +schedule_work (&hsq->retry_work); +else +WARN_ON_ONCE (ret); }static void mmc_hsq_update_next_tag (struct mmc_hsq *hsq,int remains)
@@ -325,6 +351,7 @@ int mmc_hsq_init(struct mmc_hsq *hsq, struct mmc_host *mmc) hsq->mmc->cqe_private = hsq; mmc->cqe_ops = &mmc_hsq_ops; +INIT_WORK (&hsq->retry_work, mmc_hsq_retry_handler);spin_lock_init (&hsq->lock);init_waitqueue_head (&hsq->wait_queue);
drivers/mmc/host/mmc_hsq.h +1 -0
@@ -12,6 +12,7 @@ struct mmc_hsq {wait_queue_head_t wait_queue;struct hsq_slot *slot;spinlock_t lock; +struct work_struct retry_work;int next_tag;int num_slots;
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. */ +int (*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
2.17.1
Baolin Wang
maintainerPATCH v5 2/3 mmc: host: sdhci: Implement the request_atomic() API
In reply to Baolin WangImplement the request_atomic() ops for the sdhci driver to process one request in the atomic context if the card is nonremovable.
Moreover, we should return BUSY flag if controller has not released the inhibit bits to allow HSQ trying to send request again in non-atomic context.
--- drivers/mmc/host/sdhci.c | 34 ++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci.h | 1 + 2 files changed, 35 insertions(+)
drivers/mmc/host/sdhci.c +34 -0
@@ -2144,6 +2144,40 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) }EXPORT_SYMBOL_GPL (sdhci_request); +int sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq) +{ +struct sdhci_host *host =mmc_priv (mmc); +struct mmc_command *cmd; +unsigned long flags; +int ret =0 ; + +spin_lock_irqsave (&host->lock, flags); + +if (sdhci_present_error (host, mrq->cmd, true)) { +sdhci_finish_mrq (host, mrq); + goto out_finish; + } + + cmd =sdhci_manual_cmd23 (host, mrq) ? mrq->sbc : mrq->cmd; + +/* +* The HSQ may send a command in interrupt context without polling +* the busy signaling, which means we should return BUSY if controller +* has not released inhibit bits to allow HSQ trying to send request +* again in non-atomic context. So we should not finish this request +* here. +*/ +if (!sdhci_send_command (host, cmd)) + ret = -EBUSY ; +else +sdhci_led_activate (host); + +out_finish: +spin_unlock_irqrestore (&host->lock, flags); +return ret; +} +EXPORT_SYMBOL_GPL (sdhci_request_atomic); +void sdhci_set_bus_width (struct sdhci_host *host,int width) {u8 ctrl;
drivers/mmc/host/sdhci.h +1 -0
@@ -776,6 +776,7 @@ void sdhci_set_power_and_bus_voltage(struct sdhci_host *host,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); +int 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);
Signature · 1 line
2.17.1
Baolin Wang
maintainerPATCH v5 3/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.
Moreover factor out the AUTO CMD23 checking into a separate function to reduce duplicate code.
--- drivers/mmc/host/sdhci-sprd.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-sprd.c +20 -3
@@ -406,7 +406,8 @@ static struct sdhci_ops sdhci_sprd_ops = { .request_done = sdhci_sprd_request_done, }; -static void sdhci_sprd_request (struct mmc_host *mmc,struct mmc_request *mrq) +static void sdhci_sprd_check_auto_cmd23 (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);
@@ -422,10 +423,23 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) mrq->sbc && (mrq->sbc->arg &SDHCI_SPRD_ARG2_STUFF ) && (host->flags & SDHCI_AUTO_CMD23)) host->flags &= ~SDHCI_AUTO_CMD23; +} + +static void sdhci_sprd_request (struct mmc_host *mmc,struct mmc_request *mrq) +{ +sdhci_sprd_check_auto_cmd23 (mmc, mrq);sdhci_request (mmc, mrq); } +static int sdhci_sprd_request_atomic (struct mmc_host *mmc, +struct mmc_request *mrq) +{ +sdhci_sprd_check_auto_cmd23 (mmc, mrq); + +return 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 +575,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 +673,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
2.17.1
kbuild test robot
build botRe: [PATCH v5 2/3] mmc: host: sdhci: Implement the request_atomic() API
In reply to Baolin WangI love your patch! Yet something to improve:
Hi Baolin,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.7-rc1 next-20200412]
[cannot apply to arm-soc/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-the-request_atomic-for-the-host/20200413-105346 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8f3d9f354286745c751374f5f1fcafee6b3f3136 config: riscv-allyesconfig (attached as .config) compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.3.0 make.cross ARCH=riscv
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/mmc/host/sdhci.c: In function 'sdhci_request_atomic':
>> drivers/mmc/host/sdhci.c:2076:6: error: implicit declaration of function 'sdhci_present_error' [-Werror=implicit-function-declaration]
2076 | if (sdhci_present_error(host, mrq->cmd, true)) {
| ^~~~~~~~~~~~~~~~~~~
>> drivers/mmc/host/sdhci.c:2081:8: error: implicit declaration of function 'sdhci_manual_cmd23'; did you mean 'sdhci_auto_cmd12'? [-Werror=implicit-function-declaration]
2081 | cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd;
| ^~~~~~~~~~~~~~~~~~
| sdhci_auto_cmd12
>> drivers/mmc/host/sdhci.c:2090:6: error: invalid use of void expression
2090 | if (!sdhci_send_command(host, cmd))
| ^cc1: some warnings being treated as errors
vim +/sdhci_present_error +2076 drivers/mmc/host/sdhci.c
2066
2067 int sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq)
2068 {
2069 struct sdhci_host *host = mmc_priv(mmc);
2070 struct mmc_command *cmd;
2071 unsigned long flags;
2072 int ret = 0;
2073
2074 spin_lock_irqsave(&host->lock, flags);
2075
> 2076 if (sdhci_present_error(host, mrq->cmd, true)) {
2077 sdhci_finish_mrq(host, mrq);
2078 goto out_finish;
2079 }
2080
> 2081 cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd;
2082
2083 /*
2084 * The HSQ may send a command in interrupt context without polling
2085 * the busy signaling, which means we should return BUSY if controller
2086 * has not released inhibit bits to allow HSQ trying to send request
2087 * again in non-atomic context. So we should not finish this request
2088 * here.
2089 */
> 2090 if (!sdhci_send_command(host, cmd)) 2091 ret = -EBUSY;
2092 else
2093 sdhci_led_activate(host);
2094
2095 out_finish:
2096 spin_unlock_irqrestore(&host->lock, flags);
2097 return ret;
2098 }
2099 EXPORT_SYMBOL_GPL(sdhci_request_atomic);
2100
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kbuild test robot
build botRe: [PATCH v5 2/3] mmc: host: sdhci: Implement the request_atomic() API
In reply to Baolin WangI love your patch! Yet something to improve:
Hi Baolin,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.7-rc1 next-20200412]
[cannot apply to arm-soc/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-the-request_atomic-for-the-host/20200413-105346 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8f3d9f354286745c751374f5f1fcafee6b3f3136 config: x86_64-randconfig-s2-20200413 (attached as .config) compiler: gcc-5 (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
In file included from include/linux/build_bug.h:5:0,
from include/linux/bitfield.h:10,
from drivers/mmc/host/sdhci.c:12:
drivers/mmc/host/sdhci.c: In function 'sdhci_request_atomic':
drivers/mmc/host/sdhci.c:2076:6: error: implicit declaration of function 'sdhci_present_error' [-Werror=implicit-function-declaration]
if (sdhci_present_error(host, mrq->cmd, true)) {
^
include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^
>> drivers/mmc/host/sdhci.c:2076:2: note: in expansion of macro 'if'
if (sdhci_present_error(host, mrq->cmd, true)) {
^
drivers/mmc/host/sdhci.c:2081:8: error: implicit declaration of function 'sdhci_manual_cmd23' [-Werror=implicit-function-declaration]
cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd;
^
drivers/mmc/host/sdhci.c:2090:2: error: invalid use of void expression
if (!sdhci_send_command(host, cmd))
^
drivers/mmc/host/sdhci.c:2090:2: error: invalid use of void expression
In file included from include/linux/build_bug.h:5:0,
from include/linux/bitfield.h:10,
from drivers/mmc/host/sdhci.c:12:
>> include/linux/compiler.h:61:16: error: invalid use of void expression
static struct ftrace_branch_data \
^
include/linux/compiler.h:58:69: note: in expansion of macro '__trace_if_value'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^
include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^ drivers/mmc/host/sdhci.c:2090:2: note: in expansion of macro 'if'
if (!sdhci_send_command(host, cmd))
^
cc1: some warnings being treated as errors
vim +/if +2076 drivers/mmc/host/sdhci.c
2066
2067 int sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq)
2068 {
2069 struct sdhci_host *host = mmc_priv(mmc);
2070 struct mmc_command *cmd;
2071 unsigned long flags;
2072 int ret = 0;
2073
2074 spin_lock_irqsave(&host->lock, flags);
2075
> 2076 if (sdhci_present_error(host, mrq->cmd, true)) { 2077 sdhci_finish_mrq(host, mrq);
2078 goto out_finish;
2079 }
2080
2081 cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd;
2082
2083 /*
2084 * The HSQ may send a command in interrupt context without polling
2085 * the busy signaling, which means we should return BUSY if controller
2086 * has not released inhibit bits to allow HSQ trying to send request
2087 * again in non-atomic context. So we should not finish this request
2088 * here.
2089 */
2090 if (!sdhci_send_command(host, cmd))
2091 ret = -EBUSY;
2092 else
2093 sdhci_led_activate(host);
2094
2095 out_finish:
2096 spin_unlock_irqrestore(&host->lock, flags);
2097 return ret;
2098 }
2099 EXPORT_SYMBOL_GPL(sdhci_request_atomic);
2100
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Baolin Wang
maintainerRe: [PATCH v5 2/3] mmc: host: sdhci: Implement the request_atomic() API
Hi,
Quoted 20 lines · kbuild test robot
Hi Baolin,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.7-rc1 next-20200412]
[cannot apply to arm-soc/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-the-request_atomic-for-the-host/20200413-105346 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8f3d9f354286745c751374f5f1fcafee6b3f3136 config: x86_64-randconfig-s2-20200413 (attached as .config) compiler: gcc-5 (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
Quoted 2 lines
If you fix the issue, kindly add following tag as appropriate
Reported-by kbuild test robot <[email protected]>
This patch set is based on Adrian's patch set. Thanks.
https://www.spinics.net/lists/linux-mmc/msg58529.html
Quoted 81 lines
All error/warnings (new ones prefixed by >>):
In file included from
include/linux/build_bug.h:5:0,
frominclude/linux/bitfield.h:10, fromdrivers/mmc/host/sdhci.c:12:drivers/mmc/host/sdhci.c: In function 'sdhci_request_atomic': drivers/mmc/host/sdhci.c:2076:6: error: implicit declaration of function 'sdhci_present_error' [-Werror=implicit-function-declaration] if (sdhci_present_error(host, mrq->cmd, true)) { ^ include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var' #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) ^Quoted 1 line
Quoted 1 line
drivers/mmc/host/sdhci.c:2076:2: note: in expansion of macro 'if'if (sdhci_present_error(host, mrq->cmd, true)) { ^ drivers/mmc/host/sdhci.c:2081:8: error: implicit declaration of function 'sdhci_manual_cmd23' [-Werror=implicit-function-declaration] cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd; ^
drivers/mmc/host/sdhci.c:2090:2: error: invalid use of void expression
if (!sdhci_send_command(host, cmd))
^
drivers/mmc/host/sdhci.c:2090:2: error: invalid use of void expression In file included frominclude/linux/build_bug.h:5:0,
frominclude/linux/bitfield.h:10,
fromdrivers/mmc/host/sdhci.c:12:Quoted 1 line
Quoted 1 line
include/linux/compiler.h:61:16: error: invalid use of void expressionstatic struct ftrace_branch_data \ ^ include/linux/compiler.h:58:69: note: in expansion of macro '__trace_if_value' #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) ^ include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var' #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) ^
drivers/mmc/host/sdhci.c:2090:2: note: in expansion of macro 'if'
if (!sdhci_send_command(host, cmd))
^
cc1: some warnings being treated as errorsvim +/if +2076
drivers/mmc/host/sdhci.c2066
2067 intsdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq)2068 {2069 struct sdhci_host *host = mmc_priv(mmc); 2070 struct mmc_command *cmd; 2071 unsigned long flags; 2072 int ret = 0;2073
2074spin_lock_irqsave(&host->lock, flags);
2075Quoted 1 line
2076 if (
sdhci_present_error(host, mrq->cmd, true)) {2077
sdhci_finish_mrq(host, mrq);
2078 gotoout_finish;
2079 }
2080
2081 cmd =sdhci_manual_cmd23(host, mrq)?mrq->sbc:mrq->cmd;
2082
2083 /*2084 * The HSQ may send a command in interrupt context without polling 2085 * the busy signaling, which means we should return BUSY if controller 2086 * has not released inhibit bits to allow HSQ trying to send request 2087 * again in non-atomic context. So we should not finish this request 2088 * here. 2089 */2090 if (!sdhci_send_command(host, cmd))
2091 ret =-EBUSY;
2092 else
2093sdhci_led_activate(host);
2094
2095out_finish:
2096spin_unlock_irqrestore(&host->lock, flags);
2097 return ret;
2098 }
2099EXPORT_SYMBOL_GPL(sdhci_request_atomic);
2100---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
Signature · 1 line
Baolin Wang
Re: [PATCH v5 2/3] mmc: host: sdhci: Implement the request_atomic() API
In reply to Baolin WangQuoted 9 lines · Baolin Wang
Implement the
request_atomic()ops for the sdhci driver to process one request in the atomic context if the card is nonremovable.Moreover, we should return BUSY flag if controller has not released the inhibit bits to allow HSQ trying to send request again in non-atomic context.
Suggested-by Adrian Hunter <[email protected]>Signed-off-by Baolin Wang <[email protected]>
Quoted 63 lines
--- drivers/mmc/host/sdhci.c | 34 ++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci.h | 1 + 2 files changed, 35 insertions(+)drivers/mmc/host/sdhci.c +34
-0@@ -2144,6 +2144,40 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) }EXPORT_SYMBOL_GPL (sdhci_request); +int sdhci_request_atomic (struct mmc_host *mmc,struct mmc_request *mrq) +{ +struct sdhci_host *host =mmc_priv (mmc); +struct mmc_command *cmd; +unsigned long flags; +int ret =0 ; + +spin_lock_irqsave (&host->lock, flags); + +if (sdhci_present_error (host, mrq->cmd, true)) { +sdhci_finish_mrq (host, mrq); + goto out_finish; + } + + cmd =sdhci_manual_cmd23 (host, mrq) ? mrq->sbc : mrq->cmd; + +/* +* The HSQ may send a command in interrupt context without polling +* the busy signaling, which means we should return BUSY if controller +* has not released inhibit bits to allow HSQ trying to send request +* again in non-atomic context. So we should not finish this request +* here. +*/ +if (!sdhci_send_command (host, cmd)) + ret = -EBUSY ; +else +sdhci_led_activate (host); + +out_finish: +spin_unlock_irqrestore (&host->lock, flags); +return ret; +} +EXPORT_SYMBOL_GPL (sdhci_request_atomic); +void sdhci_set_bus_width (struct sdhci_host *host,int width) {u8 ctrl;drivers/mmc/host/sdhci.h +1
-0@@ -776,6 +776,7 @@ void sdhci_set_power_and_bus_voltage(struct sdhci_host *host,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); +int 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);
Re: [PATCH v5 3/3] mmc: host: sdhci-sprd: Implement the request_atomic() API
In reply to Baolin WangQuoted 8 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.Moreover factor out the AUTO CMD23 checking into a separate function to reduce duplicate code.
Signed-off-by Baolin Wang <[email protected]>
Quoted 64 lines
--- drivers/mmc/host/sdhci-sprd.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)drivers/mmc/host/sdhci-sprd.c +20
-3@@ -406,7 +406,8 @@ static struct sdhci_ops sdhci_sprd_ops = { .request_done = sdhci_sprd_request_done, }; -static void sdhci_sprd_request (struct mmc_host *mmc,struct mmc_request *mrq) +static void sdhci_sprd_check_auto_cmd23 (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);@@ -422,10 +423,23 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) mrq->sbc && (mrq->sbc->arg &SDHCI_SPRD_ARG2_STUFF ) && (host->flags & SDHCI_AUTO_CMD23)) host->flags &= ~SDHCI_AUTO_CMD23; +} + +static void sdhci_sprd_request (struct mmc_host *mmc,struct mmc_request *mrq) +{ +sdhci_sprd_check_auto_cmd23 (mmc, mrq);sdhci_request (mmc, mrq); } +static int sdhci_sprd_request_atomic (struct mmc_host *mmc, +struct mmc_request *mrq) +{ +sdhci_sprd_check_auto_cmd23 (mmc, mrq); + +return 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 +575,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 +673,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 44 lines · Baolin Wang
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.Note, this patch set is based on Adrian's patch set:
https://www.spinics.net/lists/linux-mmc/msg58529.htmlAny comments are welcome. Thanks.
Changes from v4:
- Remove redundant checking when warning the return value ofrequest_atomic().
- Add acked tag from Adrian for patch 1.
- Re-implement therequest_atomic()based on the Adrian's patch set.Changes from v3:
- Move patch 3 of V3 patch set into patch 1.
- Add a warning for unexpected return value ofrequest_atomic().
- Remove redundant checking ofops->request().Changes from v2:
- Return busy flag if encountering unusual card busy state instead of polling in interrupt context.
- Add a work for HSQ to try again in non-atomic context if the host returns busy flag.Changes from v1:
- Re-split the changes to make them more clear suggested by Ulf.
- Factor out the auto CMD23 checking into a separate function.Baolin Wang (3):
mmc: host: Introduce therequest_atomic()for the host
mmc: host: sdhci: Implement therequest_atomic()API
mmc: host: sdhci-sprd: Implement therequest_atomic()APIdrivers/mmc/host/mmc_hsq.c | 29 ++++++++++++++++++++++++++++- drivers/mmc/host/mmc_hsq.h | 1 + drivers/mmc/host/sdhci-sprd.c | 23 ++++++++++++++++++++--- drivers/mmc/host/sdhci.c | 34 ++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci.h | 1 + include/linux/mmc/host.h | 3 +++ 6 files changed, 87 insertions(+), 4 deletions(-)
Quoted 3 lines
--
2.17.1
Applied for next, thanks!
Kind regards
Uffe