* [PATCH v3 0/5] brcmfmac: sdio: Deal better w/ transmission errors related to idle @ 2019-06-07 22:37 Douglas Anderson [not found] ` <20190607223716.119277-1-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> 2019-06-07 22:37 ` [PATCH v3 4/5] mmc: core: Export mmc_retune_hold_now() mmc_retune_release() Douglas Anderson 0 siblings, 2 replies; 4+ messages in thread From: Douglas Anderson @ 2019-06-07 22:37 UTC (permalink / raw) To: Ulf Hansson, Kalle Valo, Adrian Hunter, Arend van Spriel Cc: brcm80211-dev-list.pdl, linux-rockchip, Double Lo, briannorris, linux-wireless, Naveen Gupta, Madhan Mohan R, mka, Wright Feng, Chi-Hsien Lin, netdev, brcm80211-dev-list, Douglas Anderson, linux-mmc, Linus Walleij, Shawn Lin, YueHaibing, Rafał Miłecki, Hante Meuleman, Martin Blumenstingl This series attempts to deal better with the expected transmission errors related to the idle states (handled by the Always-On-Subsystem or AOS) on the SDIO-based WiFi on rk3288-veyron-minnie, rk3288-veyron-speedy, and rk3288-veyron-mickey. Some details about those errors can be found in <https://crbug.com/960222>, but to summarize it here: if we try to send the wakeup command to the WiFi card at the same time it has decided to wake up itself then it will behave badly on the SDIO bus. This can cause timeouts or CRC errors. When I tested on 4.19 and 4.20 these CRC errors can be seen to cause re-tuning. Since I am currently developing on 4.19 this was the original problem I attempted to solve. On mainline it turns out that you don't see the retuning errors but you see tons of spam about timeouts trying to wakeup from sleep. I tracked down the commit that was causing that and have partially reverted it here. I have no real knowledge about Broadcom WiFi, but the commit that was causing problems sounds (from the descriptioin) to be a hack commit penalizing all Broadcom WiFi users because of a bug in a Cypress SD controller. I will let others comment if this is truly the case and, if so, what the right solution should be. For v3 of this series I have added 2 patches to the end of the series to address errors that would show up on systems with these same SDIO WiFi cards when used on controllers that do periodic retuning. These systems need an extra fix to prevent the retuning from happening when the card is asleep. Changes in v3: - Took out the spinlock since I believe this is all in one context. - Expect errors for all of brcmf_sdio_kso_control() (Adrian). - ("mmc: core: Export mmc_retune_hold_now() mmc_retune_release()") new for v3. - ("brcmfmac: sdio: Don't tune while the card is off") new for v3. Changes in v2: - A full revert, not just a partial one (Arend). ...with explicit Cc. - Updated commit message to clarify based on discussion of v1. Douglas Anderson (5): Revert "brcmfmac: disable command decode in sdio_aos" mmc: core: API for temporarily disabling auto-retuning due to errors brcmfmac: sdio: Disable auto-tuning around commands expected to fail mmc: core: Export mmc_retune_hold_now() mmc_retune_release() brcmfmac: sdio: Don't tune while the card is off drivers/mmc/core/core.c | 19 +++++++++++++++++-- drivers/mmc/core/host.c | 7 +++++++ drivers/mmc/core/host.h | 7 ------- .../broadcom/brcm80211/brcmfmac/sdio.c | 18 +++++++++++++----- include/linux/mmc/core.h | 4 ++++ include/linux/mmc/host.h | 1 + 6 files changed, 42 insertions(+), 14 deletions(-) -- 2.22.0.rc2.383.gf4fbbf30c2-goog ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20190607223716.119277-1-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>]
* [PATCH v3 2/5] mmc: core: API for temporarily disabling auto-retuning due to errors [not found] ` <20190607223716.119277-1-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> @ 2019-06-07 22:37 ` Douglas Anderson 2019-06-12 13:25 ` Ulf Hansson 0 siblings, 1 reply; 4+ messages in thread From: Douglas Anderson @ 2019-06-07 22:37 UTC (permalink / raw) To: Ulf Hansson, Kalle Valo, Adrian Hunter, Arend van Spriel Cc: Madhan Mohan R, brcm80211-dev-list.pdl-dY08KVG/lbpWk0Htik3J/w, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang, netdev-u79uwXL29TY76Z2rM5mHXA, Chi-Hsien Lin, briannorris-F7+t8E8rja9g9hUCZPvPmw, linux-wireless-u79uwXL29TY76Z2rM5mHXA, Double Lo, Douglas Anderson, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Avri Altman, mka-F7+t8E8rja9g9hUCZPvPmw, Ritesh Harjani, Wright Feng, Jiong Wu, linux-mmc-u79uwXL29TY76Z2rM5mHXA, Shawn Lin, brcm80211-dev-list-+wT8y+m8/X5BDgjK7y7TUQ, Naveen Gupta Normally when the MMC core sees an "-EILSEQ" error returned by a host controller then it will trigger a retuning of the card. This is generally a good idea. However, if a command is expected to sometimes cause transfer errors then these transfer errors shouldn't cause a re-tuning. This re-tuning will be a needless waste of time. One example case where a transfer is expected to cause errors is when transitioning between idle (sometimes referred to as "sleep" in Broadcom code) and active state on certain Broadcom WiFi cards. Specifically if the card was already transitioning between states when the command was sent it could cause an error on the SDIO bus. Let's add an API that the SDIO card drivers can call that will temporarily disable the auto-tuning functionality. Then we can add a call to this in the Broadcom WiFi driver and any other driver that might have similar needs. NOTE: this makes the assumption that the card is already tuned well enough that it's OK to disable the auto-retuning during one of these error-prone situations. Presumably the driver code performing the error-prone transfer knows how to recover / retry from errors. ...and after we can get back to a state where transfers are no longer error-prone then we can enable the auto-retuning again. If we truly find ourselves in a case where the card needs to be retuned sometimes to handle one of these error-prone transfers then we can always try a few transfers first without auto-retuning and then re-try with auto-retuning if the first few fail. Without this change on rk3288-veyron-minnie I periodically see this in the logs of a machine just sitting there idle: dwmmc_rockchip ff0d0000.dwmmc: Successfully tuned phase to XYZ Fixes: bd11e8bd03ca ("mmc: core: Flag re-tuning is needed on CRC errors") Signed-off-by: Douglas Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> --- Note that are are a whole boatload of different ways that we could provide an API for the Broadcom WiFi SDIO driver. This patch illustrates one way but if maintainers feel strongly that this is too ugly and have a better idea then I can give it a shot too. From a purist point of view I kinda felt that the "expect errors" really belonged as part of the mmc_request structure, but getting it into there meant changing a whole pile of core SD/MMC APIs. Simply adding it to the host seemed to match the current style better and was a less intrusive change. Changes in v3: - Took out the spinlock since I believe this is all in one context. Changes in v2: - Updated commit message to clarify based on discussion of v1. drivers/mmc/core/core.c | 19 +++++++++++++++++-- include/linux/mmc/core.h | 2 ++ include/linux/mmc/host.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 6db36dc870b5..bc109ec49406 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -144,8 +144,9 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) int err = cmd->error; /* Flag re-tuning needed on CRC errors */ - if ((cmd->opcode != MMC_SEND_TUNING_BLOCK && - cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200) && + if (cmd->opcode != MMC_SEND_TUNING_BLOCK && + cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200 && + !host->expect_errors && (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) || (mrq->data && mrq->data->error == -EILSEQ) || (mrq->stop && mrq->stop->error == -EILSEQ))) @@ -2163,6 +2164,20 @@ int mmc_sw_reset(struct mmc_host *host) } EXPORT_SYMBOL(mmc_sw_reset); +void mmc_expect_errors_begin(struct mmc_host *host) +{ + WARN_ON(host->expect_errors); + host->expect_errors = true; +} +EXPORT_SYMBOL_GPL(mmc_expect_errors_begin); + +void mmc_expect_errors_end(struct mmc_host *host) +{ + WARN_ON(!host->expect_errors); + host->expect_errors = false; +} +EXPORT_SYMBOL_GPL(mmc_expect_errors_end); + static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) { host->f_init = freq; diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 134a6483347a..02a13abf0cda 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -178,6 +178,8 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int mmc_hw_reset(struct mmc_host *host); int mmc_sw_reset(struct mmc_host *host); +void mmc_expect_errors_begin(struct mmc_host *host); +void mmc_expect_errors_end(struct mmc_host *host); void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card); #endif /* LINUX_MMC_CORE_H */ diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 43d0f0c496f6..8d553fb8c834 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -398,6 +398,7 @@ struct mmc_host { unsigned int retune_now:1; /* do re-tuning at next req */ unsigned int retune_paused:1; /* re-tuning is temporarily disabled */ unsigned int use_blk_mq:1; /* use blk-mq */ + unsigned int expect_errors:1; /* don't trigger retune upon errors */ int rescan_disable; /* disable card detection */ int rescan_entered; /* used with nonremovable devices */ -- 2.22.0.rc2.383.gf4fbbf30c2-goog ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 2/5] mmc: core: API for temporarily disabling auto-retuning due to errors 2019-06-07 22:37 ` [PATCH v3 2/5] mmc: core: API for temporarily disabling auto-retuning due to errors Douglas Anderson @ 2019-06-12 13:25 ` Ulf Hansson 0 siblings, 0 replies; 4+ messages in thread From: Ulf Hansson @ 2019-06-12 13:25 UTC (permalink / raw) To: Douglas Anderson Cc: Kalle Valo, Adrian Hunter, Arend van Spriel, brcm80211-dev-list.pdl, open list:ARM/Rockchip SoC..., Double Lo, Brian Norris, linux-wireless, Naveen Gupta, Madhan Mohan R, Matthias Kaehlcke, Wright Feng, Chi-Hsien Lin, netdev, brcm80211-dev-list, Jiong Wu, Ritesh Harjani, linux-mmc, Linux On Sat, 8 Jun 2019 at 00:37, Douglas Anderson <dianders@chromium.org> wrote: > > Normally when the MMC core sees an "-EILSEQ" error returned by a host > controller then it will trigger a retuning of the card. This is > generally a good idea. > > However, if a command is expected to sometimes cause transfer errors > then these transfer errors shouldn't cause a re-tuning. This > re-tuning will be a needless waste of time. One example case where a > transfer is expected to cause errors is when transitioning between > idle (sometimes referred to as "sleep" in Broadcom code) and active > state on certain Broadcom WiFi cards. Specifically if the card was > already transitioning between states when the command was sent it > could cause an error on the SDIO bus. > > Let's add an API that the SDIO card drivers can call that will > temporarily disable the auto-tuning functionality. Then we can add a > call to this in the Broadcom WiFi driver and any other driver that > might have similar needs. > > NOTE: this makes the assumption that the card is already tuned well > enough that it's OK to disable the auto-retuning during one of these > error-prone situations. Presumably the driver code performing the > error-prone transfer knows how to recover / retry from errors. ...and > after we can get back to a state where transfers are no longer > error-prone then we can enable the auto-retuning again. If we truly > find ourselves in a case where the card needs to be retuned sometimes > to handle one of these error-prone transfers then we can always try a > few transfers first without auto-retuning and then re-try with > auto-retuning if the first few fail. > > Without this change on rk3288-veyron-minnie I periodically see this in > the logs of a machine just sitting there idle: > dwmmc_rockchip ff0d0000.dwmmc: Successfully tuned phase to XYZ > > Fixes: bd11e8bd03ca ("mmc: core: Flag re-tuning is needed on CRC errors") > Signed-off-by: Douglas Anderson <dianders@chromium.org> > --- > Note that are are a whole boatload of different ways that we could > provide an API for the Broadcom WiFi SDIO driver. This patch > illustrates one way but if maintainers feel strongly that this is too > ugly and have a better idea then I can give it a shot too. From a > purist point of view I kinda felt that the "expect errors" really > belonged as part of the mmc_request structure, but getting it into > there meant changing a whole pile of core SD/MMC APIs. Simply adding > it to the host seemed to match the current style better and was a less > intrusive change. > > Changes in v3: > - Took out the spinlock since I believe this is all in one context. This needs to be clarified, preferable also in a function header. If I understand correctly, the SDIO func driver needs the host to be claimed when it calls mmc_expect_errors_begin(). More importantly, it also needs to be keep it claimed until after it had called mmc_expect_errors_end(). Correct? > > Changes in v2: > - Updated commit message to clarify based on discussion of v1. > > drivers/mmc/core/core.c | 19 +++++++++++++++++-- > include/linux/mmc/core.h | 2 ++ > include/linux/mmc/host.h | 1 + > 3 files changed, 20 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c > index 6db36dc870b5..bc109ec49406 100644 > --- a/drivers/mmc/core/core.c > +++ b/drivers/mmc/core/core.c > @@ -144,8 +144,9 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) > int err = cmd->error; > > /* Flag re-tuning needed on CRC errors */ > - if ((cmd->opcode != MMC_SEND_TUNING_BLOCK && > - cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200) && > + if (cmd->opcode != MMC_SEND_TUNING_BLOCK && > + cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200 && > + !host->expect_errors && > (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) || > (mrq->data && mrq->data->error == -EILSEQ) || > (mrq->stop && mrq->stop->error == -EILSEQ))) > @@ -2163,6 +2164,20 @@ int mmc_sw_reset(struct mmc_host *host) > } > EXPORT_SYMBOL(mmc_sw_reset); > > +void mmc_expect_errors_begin(struct mmc_host *host) > +{ > + WARN_ON(host->expect_errors); Please remove the WARN_ON. If you believe there is a need for reference counting, then please add that instead (but likely not in the phase?). > + host->expect_errors = true; > +} > +EXPORT_SYMBOL_GPL(mmc_expect_errors_begin); > + > +void mmc_expect_errors_end(struct mmc_host *host) > +{ > + WARN_ON(!host->expect_errors); Ditto. > + host->expect_errors = false; > +} > +EXPORT_SYMBOL_GPL(mmc_expect_errors_end); These new APIs seems to be useful solely for SDIO. Even if it turns out later that they can be made generic, I suggest to start with a SDIO func API instead. However, using a new host variable (->expect_errors) is fine by me. > + > static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) > { > host->f_init = freq; > diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h > index 134a6483347a..02a13abf0cda 100644 > --- a/include/linux/mmc/core.h > +++ b/include/linux/mmc/core.h > @@ -178,6 +178,8 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, > > int mmc_hw_reset(struct mmc_host *host); > int mmc_sw_reset(struct mmc_host *host); > +void mmc_expect_errors_begin(struct mmc_host *host); > +void mmc_expect_errors_end(struct mmc_host *host); The API prevents a new re-tune to be "scheduled" in case requests are failing with -EILSEQ. To better reflect that, may I suggest to rename this to sdio_retune_crc_disable() and sdio_retune_crc_enable(). Or something along those lines. > void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card); > > #endif /* LINUX_MMC_CORE_H */ > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h > index 43d0f0c496f6..8d553fb8c834 100644 > --- a/include/linux/mmc/host.h > +++ b/include/linux/mmc/host.h > @@ -398,6 +398,7 @@ struct mmc_host { > unsigned int retune_now:1; /* do re-tuning at next req */ > unsigned int retune_paused:1; /* re-tuning is temporarily disabled */ > unsigned int use_blk_mq:1; /* use blk-mq */ > + unsigned int expect_errors:1; /* don't trigger retune upon errors */ > > int rescan_disable; /* disable card detection */ > int rescan_entered; /* used with nonremovable devices */ > -- > 2.22.0.rc2.383.gf4fbbf30c2-goog > Kind regards Uffe ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 4/5] mmc: core: Export mmc_retune_hold_now() mmc_retune_release() 2019-06-07 22:37 [PATCH v3 0/5] brcmfmac: sdio: Deal better w/ transmission errors related to idle Douglas Anderson [not found] ` <20190607223716.119277-1-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> @ 2019-06-07 22:37 ` Douglas Anderson 1 sibling, 0 replies; 4+ messages in thread From: Douglas Anderson @ 2019-06-07 22:37 UTC (permalink / raw) To: Ulf Hansson, Kalle Valo, Adrian Hunter, Arend van Spriel Cc: brcm80211-dev-list.pdl, linux-rockchip, Double Lo, briannorris, linux-wireless, Naveen Gupta, Madhan Mohan R, mka, Wright Feng, Chi-Hsien Lin, netdev, brcm80211-dev-list, Douglas Anderson, Martin Blumenstingl, Pan Bian, Linus Walleij, linux-mmc, linux-kernel, Tony Lindgren, Mathieu Malaterre, Pavel Machek We want SDIO drivers to be able to temporarily stop retuning when the driver knows that the SDIO card is not in a state where retuning will work (maybe because the card is asleep). We'll move the relevant functions to a place where drivers can call them. NOTE: We'll leave the calls with a mmc_ prefix following the lead of the API call mmc_hw_reset(), which is also expected to be called directly by SDIO cards. Signed-off-by: Douglas Anderson <dianders@chromium.org> --- Changes in v3: - ("mmc: core: Export mmc_retune_hold_now() mmc_retune_release()") new for v3. Changes in v2: None drivers/mmc/core/host.c | 7 +++++++ drivers/mmc/core/host.h | 7 ------- include/linux/mmc/core.h | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 6a51f7a06ce7..361f4d151d20 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -111,6 +111,13 @@ void mmc_retune_hold(struct mmc_host *host) host->hold_retune += 1; } +void mmc_retune_hold_now(struct mmc_host *host) +{ + host->retune_now = 0; + host->hold_retune += 1; +} +EXPORT_SYMBOL(mmc_retune_hold_now); + void mmc_retune_release(struct mmc_host *host) { if (host->hold_retune) diff --git a/drivers/mmc/core/host.h b/drivers/mmc/core/host.h index 4805438c02ff..3212afc6c9fe 100644 --- a/drivers/mmc/core/host.h +++ b/drivers/mmc/core/host.h @@ -19,17 +19,10 @@ void mmc_unregister_host_class(void); void mmc_retune_enable(struct mmc_host *host); void mmc_retune_disable(struct mmc_host *host); void mmc_retune_hold(struct mmc_host *host); -void mmc_retune_release(struct mmc_host *host); int mmc_retune(struct mmc_host *host); void mmc_retune_pause(struct mmc_host *host); void mmc_retune_unpause(struct mmc_host *host); -static inline void mmc_retune_hold_now(struct mmc_host *host) -{ - host->retune_now = 0; - host->hold_retune += 1; -} - static inline void mmc_retune_recheck(struct mmc_host *host) { if (host->hold_retune <= 1) diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 02a13abf0cda..53085245383c 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -181,5 +181,7 @@ int mmc_sw_reset(struct mmc_host *host); void mmc_expect_errors_begin(struct mmc_host *host); void mmc_expect_errors_end(struct mmc_host *host); void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card); +void mmc_retune_release(struct mmc_host *host); +void mmc_retune_hold_now(struct mmc_host *host); #endif /* LINUX_MMC_CORE_H */ -- 2.22.0.rc2.383.gf4fbbf30c2-goog ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-12 13:25 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-06-07 22:37 [PATCH v3 0/5] brcmfmac: sdio: Deal better w/ transmission errors related to idle Douglas Anderson [not found] ` <20190607223716.119277-1-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> 2019-06-07 22:37 ` [PATCH v3 2/5] mmc: core: API for temporarily disabling auto-retuning due to errors Douglas Anderson 2019-06-12 13:25 ` Ulf Hansson 2019-06-07 22:37 ` [PATCH v3 4/5] mmc: core: Export mmc_retune_hold_now() mmc_retune_release() Douglas Anderson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).