From: Wolfram Sang <wsa@the-dreams.de>
To: Simon Horman <horms+renesas@verge.net.au>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Magnus Damm <magnus.damm@gmail.com>,
linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Ai Kyuse <ai.kyuse.uw@renesas.com>
Subject: Re: [PATCH v3 2/4] mmc: tmio: Add tuning support
Date: Fri, 27 May 2016 13:47:15 +0200 [thread overview]
Message-ID: <20160527114715.GC1663@katana> (raw)
In-Reply-To: <1464057797-29951-3-git-send-email-horms+renesas@verge.net.au>
[-- Attachment #1: Type: text/plain, Size: 2966 bytes --]
> +static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
> +{
> + struct tmio_mmc_host *host = mmc_priv(mmc);
> + unsigned int num = 0;
> + int i, ret = 0;
> + bool *tap;
> +
> + if (host->init_tuning)
> + num = host->init_tuning(host);
> + if (!num) {
> + /* Tuning is not supported */
> + ret = 0;
ret is already 0 here. Not sure to remove the redundancy, though. This
is clearer and easier to read.
> + goto out;
> + }
> +
> + tap = kmalloc(num * 2, GFP_KERNEL);
> + if (!tap) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + /*
> + * Issue CMD19 twice for each tap
> + */
> + for (i = 0; i < 2 * num; i++) {
> + int err;
Maybe drop err here...
> +
> + if (host->prepare_tuning)
> + host->prepare_tuning(host, i);
> +
> + err = mmc_send_tuning(host->mmc, opcode, NULL);
> + if (err && err != -EILSEQ) {
> + ret = err;
> + goto err_free;
... use ret here directly ...
> + }
> + tap[i] = (err == 0);
> +
> + mdelay(1);
> + }
... and set ret = 0 here ?
> +
> + if (host->select_tuning)
> + ret = host->select_tuning(host, tap, num * 2);
I wonder if we shouldn't check the validity of the function pointers
together at the beginning of the function and bail out if some pointer
is missing? The above block skips the OOPS but it doesn't make sense to
not select something, or?
> +
> +err_free:
> + kfree(tap);
> +out:
> + if (ret < 0) {
> + dev_warn(&host->pdev->dev, "Tuning procedure failed\n");
> + tmio_mmc_hw_reset(mmc);
> + } else {
> + host->mmc->retune_period = 0;
> + }
> +
> + return ret;
> +
> +}
> +
> /* Process requests from the MMC layer */
> static void tmio_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
> {
> @@ -781,6 +851,14 @@ static void tmio_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
>
> spin_unlock_irqrestore(&host->lock, flags);
>
> + if (mrq->sbc) {
> + ret = tmio_mmc_start_command(host, mrq->sbc);
> + if (ret)
> + goto fail;
> + host->last_req_ts = jiffies;
> + host->mrq = mrq;
> + }
Is this related? Maybe a comment would help?
> +
> if (mrq->data) {
> ret = tmio_mmc_start_data(host, mrq->data);
> if (ret)
> @@ -978,6 +1056,8 @@ static struct mmc_host_ops tmio_mmc_ops = {
> .enable_sdio_irq = tmio_mmc_enable_sdio_irq,
> .card_busy = tmio_mmc_card_busy,
> .multi_io_quirk = tmio_multi_io_quirk,
> + .execute_tuning = tmio_mmc_execute_tuning,
> + .hw_reset = tmio_mmc_hw_reset,
> };
>
> static int tmio_mmc_init_ocr(struct tmio_mmc_host *host)
> @@ -1202,6 +1282,9 @@ int tmio_mmc_host_runtime_suspend(struct device *dev)
> struct mmc_host *mmc = dev_get_drvdata(dev);
> struct tmio_mmc_host *host = mmc_priv(mmc);
>
> + mmc_retune_timer_stop(host->mmc);
> + mmc_retune_needed(host->mmc);
> +
> tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
All in all, this looks way better now. Thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-05-27 11:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 2:43 [PATCH v3 0/4] UHS-I SDR-104 support for sh_mobile_sdhi Simon Horman
2016-05-24 2:43 ` [PATCH v3 1/4] mmc: tmio: enhance illegal sequence handling Simon Horman
2016-05-27 11:34 ` Wolfram Sang
2016-05-24 2:43 ` [PATCH v3 2/4] mmc: tmio: Add tuning support Simon Horman
2016-05-27 11:47 ` Wolfram Sang [this message]
2016-05-24 2:43 ` [PATCH v3 3/4] mmc: sh_mobile_sdhi: " Simon Horman
2016-05-27 11:59 ` Wolfram Sang
2016-07-20 6:24 ` Simon Horman
2016-05-31 10:39 ` Geert Uytterhoeven
2016-06-06 1:02 ` Simon Horman
2016-05-24 2:43 ` [PATCH v3 4/4] ARM: dts: r8a7790: lager: Enable UHS-I SDR-104 Simon Horman
2016-05-27 12:03 ` [PATCH v3 0/4] UHS-I SDR-104 support for sh_mobile_sdhi Wolfram Sang
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=20160527114715.GC1663@katana \
--to=wsa@the-dreams.de \
--cc=ai.kyuse.uw@renesas.com \
--cc=horms+renesas@verge.net.au \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=ulf.hansson@linaro.org \
--cc=wsa+renesas@sang-engineering.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;
as well as URLs for NNTP newsgroup(s).