From: Adrian Hunter <adrian.hunter@intel.com>
To: Judith Mendez <jm@ti.com>
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: [PATCH v2 1/7] mmc: sdhci_am654: Add tuning algorithm for delay chain
Date: Wed, 28 Feb 2024 15:21:46 +0200 [thread overview]
Message-ID: <4618f19d-0b7d-4844-83f7-ff2f4be083d9@intel.com> (raw)
In-Reply-To: <6d939482-9a3a-4923-b74b-ceb31b0ba7e9@ti.com>
On 20/02/24 22:10, Judith Mendez wrote:
> On 2/16/24 11:09 AM, Adrian Hunter wrote:
>> On 7/02/24 03:15, Judith Mendez wrote:
>>> +
>>> + if (!num_fails)
>>> + return ITAPDLY_LAST_INDEX >> 1;
>>> +
>>> + if (fail_window->length == ITAPDLY_LENGTH) {
>>> + dev_err(dev, "No passing ITAPDLY, return 0\n");
>>> + return 0;
>>> + }
>>> +
>>> + first_fail_start = fail_window->start;
>>> + last_fail_end = fail_window[num_fails - 1].end;
>>> +
>>> + for (i = 0; i < num_fails; i++) {
>>> + start_fail = fail_window[i].start;
>>> + end_fail = fail_window[i].end;
>>> + pass_length = start_fail - (prev_fail_end + 1);
>>> +
>>> + if (pass_length > pass_window.length) {
>>> + pass_window.start = prev_fail_end + 1;
>>> + pass_window.length = pass_length;
>>> + }
>>> + prev_fail_end = end_fail;
>>> + }
>>> +
>>> + if (!circular_buffer)
>>> + pass_length = ITAPDLY_LAST_INDEX - last_fail_end;
>>> + else
>>> + pass_length = ITAPDLY_LAST_INDEX - last_fail_end + first_fail_start;
>>> +
>>> + if (pass_length > pass_window.length) {
>>> + pass_window.start = last_fail_end + 1;
>>> + pass_window.length = pass_length;
>>> + }
>>> +
>>> + if (!circular_buffer)
>>> + itap = pass_window.start + (pass_window.length >> 1);
>>> + else
>>> + itap = (pass_window.start + (pass_window.length >> 1)) % ITAPDLY_LENGTH;
>>> +
>>> + return (itap < 0 || itap > ITAPDLY_LAST_INDEX ? 0 : itap);
>>
>> Parentheses are not needed where they are but putting
>> them around the condition would make it more readable e.g.
>>
>> return (itap < 0 || itap > ITAPDLY_LAST_INDEX) ? 0 : itap;
>>
>> However (itap < 0) is not possible because itap is an unsigned type
>> and if (itap > ITAPDLY_LAST_INDEX) then maybe it would be better
>> to return ITAPDLY_LAST_INDEX
>
> You are right about itap < 0, thanks will fix.
>
> About itap > ITAPDLY_LAST_INDEX, this is an error. Why
> return ITAPDLY_LAST_INDEX instead of 0?
It doesn't matter. Just if a value has a better chance to work
if the calculation fails, like maybe ITAPDLY_LAST_INDEX / 2, but
presumably it should not fail.
next prev parent reply other threads:[~2024-02-28 13:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-07 1:15 [PATCH v2 0/7] Add tuning algorithm for delay chain Judith Mendez
2024-02-07 1:15 ` [PATCH v2 1/7] mmc: sdhci_am654: " Judith Mendez
2024-02-16 17:09 ` Adrian Hunter
2024-02-20 20:10 ` Judith Mendez
2024-02-28 13:21 ` Adrian Hunter [this message]
2024-02-28 15:38 ` Judith Mendez
2024-02-07 1:15 ` [PATCH v2 2/7] mmc: sdhci_am654: Write ITAPDLY for DDR52 timing Judith Mendez
2024-02-12 17:13 ` Andrew Davis
2024-02-12 17:33 ` Judith Mendez
2024-02-16 17:09 ` Adrian Hunter
2024-02-20 21:05 ` Judith Mendez
2024-02-28 13:21 ` Adrian Hunter
2024-02-28 15:40 ` Judith Mendez
2024-02-07 1:15 ` [PATCH v2 3/7] mmc: sdhci_am654: Add missing OTAP/ITAP enable Judith Mendez
2024-02-07 1:15 ` [PATCH v2 4/7] mmc: sdhci_am654: Fix itapdly/otapdly array type Judith Mendez
2024-02-16 17:10 ` Adrian Hunter
2024-02-20 20:14 ` Judith Mendez
2024-02-07 1:15 ` [PATCH v2 5/7] mmc: sdhci_am654: Update comments in sdhci_am654_set_clock Judith Mendez
2024-02-16 17:11 ` Adrian Hunter
2024-02-20 20:14 ` Judith Mendez
2024-02-07 1:15 ` [PATCH v2 6/7] mmc: sdhci_am654: Add ITAPDLYSEL in sdhci_j721e_4bit_set_clock Judith Mendez
2024-02-07 1:15 ` [PATCH v2 7/7] mmc: sdhci_am654: Fix ITAPDLY for HS400 timing Judith Mendez
2024-02-11 16:02 ` [PATCH v2 0/7] Add tuning algorithm for delay chain Francesco Dolcini
2024-02-12 16:33 ` Judith Mendez
2024-02-12 17:32 ` Francesco Dolcini
2024-02-12 17:56 ` Judith Mendez
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=4618f19d-0b7d-4844-83f7-ff2f4be083d9@intel.com \
--to=adrian.hunter@intel.com \
--cc=jm@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.