From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Tejun Heo <tj@kernel.org>,
devicetree <devicetree@vger.kernel.org>,
linux-ide@vger.kernel.org, Oliver Schinagl <oliver@schinagl.nl>,
Richard Zhu <Hong-Xing.Zhu@freescale.com>,
linux-sunxi@googlegroups.com,
Maxime Ripard <maxime.ripard@free-electrons.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC v3 09/13] ARM: sunxi: Add support for Allwinner SUNXi SoCs sata to ahci_platform
Date: Sun, 19 Jan 2014 19:56:42 +0000 [thread overview]
Message-ID: <20140119195642.GU15937@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <52DC2282.4040702@redhat.com>
On Sun, Jan 19, 2014 at 08:07:46PM +0100, Hans de Goede wrote:
> Hi,
>
> On 01/19/2014 01:22 PM, Russell King - ARM Linux wrote:
>> On Sun, Jan 19, 2014 at 12:48:51AM +0100, Hans de Goede wrote:
>>> + timeout = 0x100000;
>>> + do {
>>> + reg_val = sunxi_getbits(reg_base + AHCI_PHYCS0R, 0x7, 28);
>>> + } while (--timeout && (reg_val != 0x2));
>>> + if (!timeout) {
>>> + dev_err(dev, "PHY power up failed.\n");
>>> + return -EIO;
>>> + }
>>
>> This is not a good way to detect failure - there's several things wrong
>> here.
>>
>> First, how long does sunxi_getbits() take? What does that depend on?
>> Therefore, how long does it take to time out?
>
> You're interpreting the timeout in the above code as an actual timeout, but
> that is not what it is, it is a means to avoid looping forever if something
> is seriously amiss. The only time I've ever seen the timeout trigger is when
> I forgot to enable some clks iirc.
>
> I can rename the variable from timeout to max_tries to make this more clear.
>
>> Secondly, what if the success condition becomes true at the same time that
>> a timeout occurs?
>
> We should never get anywhere near timeout becoming 0, so if both happen at
> the same time, then something is pretty seriously broken and the returning of
> an error as the code does now is the right thing to do.
Yes... and if we look back in history, there's been lots of stuff just
like this where the loop has had to have the number of iterations
increased as CPUs have become faster and compilers become better?
So... my question stands: but let me put it a different way in two parts:
1. What is the maximum expected time for the success condition to be
satisfied?
2. How long does it actually take for the loop to time out in existing
CPUs/compilers?
--
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up. Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was "up to 13.2Mbit".
next prev parent reply other threads:[~2014-01-19 19:56 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-18 23:48 [RFC v3 00/13] ahci: add sunxi driver and cleanup imx driver Hans de Goede
[not found] ` <1390088935-7193-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-18 23:48 ` [RFC v3 01/13] libahci: Allow drivers to override start_engine Hans de Goede
[not found] ` <1390088935-7193-2-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 4:46 ` Tejun Heo
[not found] ` <20140119044643.GH3640-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2014-01-19 18:48 ` Hans de Goede
2014-01-18 23:48 ` [RFC v3 02/13] sata-highbank: Remove unnecessary ahci_platform.h include Hans de Goede
[not found] ` <1390088935-7193-3-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 11:15 ` Tejun Heo
2014-01-18 23:48 ` [RFC v3 03/13] ahci-platform: Fix clk enable/disable unbalance on suspend/resume Hans de Goede
[not found] ` <1390088935-7193-4-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 11:14 ` Tejun Heo
[not found] ` <20140119111412.GA11123-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2014-01-19 18:47 ` Hans de Goede
[not found] ` <52DC1DAA.3010403-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 19:15 ` Tejun Heo
[not found] ` <20140119191554.GB32165-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2014-01-19 19:52 ` Hans de Goede
[not found] ` <52DC2CF5.5080109-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-20 12:26 ` Tejun Heo
2014-01-18 23:48 ` [RFC v3 04/13] ahci-platform: Undo pdata->resume on resume failure Hans de Goede
[not found] ` <1390088935-7193-5-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 11:27 ` Tejun Heo
[not found] ` <20140119112737.GC11123-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2014-01-19 18:40 ` Hans de Goede
[not found] ` <52DC1C15.1030107-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 19:13 ` Tejun Heo
[not found] ` <20140119191349.GA32165-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2014-01-19 19:34 ` Hans de Goede
[not found] ` <52DC28DB.7070804-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 19:42 ` Tejun Heo
[not found] ` <20140119194226.GE32165-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2014-01-19 19:53 ` Hans de Goede
2014-01-18 23:48 ` [RFC v3 05/13] ahci-platform: Pass ahci_host_priv ptr to ahci_platform_data init method Hans de Goede
[not found] ` <1390088935-7193-6-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 11:30 ` Tejun Heo
[not found] ` <20140119113051.GD11123-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2014-01-19 18:51 ` Hans de Goede
[not found] ` <52DC1EC4.3090807-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 19:17 ` Tejun Heo
[not found] ` <20140119191706.GC32165-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2014-01-19 19:56 ` Hans de Goede
[not found] ` <52DC2DD9.7070403-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-20 12:28 ` Tejun Heo
2014-01-18 23:48 ` [RFC v3 06/13] ahci-platform: Add support for devices with more then 1 clock Hans de Goede
[not found] ` <1390088935-7193-7-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 12:38 ` Russell King - ARM Linux
[not found] ` <20140119123854.GP15937-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-01-19 19:20 ` Hans de Goede
2014-01-18 23:48 ` [RFC v3 07/13] ahci-platform: Add support for an optional regulator for sata-target power Hans de Goede
2014-01-18 23:48 ` [RFC v3 08/13] ahci-platform: Allow specifying platform_data through of_device_id Hans de Goede
[not found] ` <1390088935-7193-9-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 11:38 ` Tejun Heo
2014-01-19 12:30 ` Russell King - ARM Linux
[not found] ` <20140119123055.GO15937-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-01-19 13:19 ` Tejun Heo
[not found] ` <20140119113838.GE11123-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2014-01-19 18:56 ` Hans de Goede
[not found] ` <52DC1FF5.80101-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 19:22 ` Tejun Heo
2014-01-20 8:24 ` Sascha Hauer
[not found] ` <20140120082438.GH16215-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-01-20 8:35 ` Hans de Goede
2014-01-20 9:09 ` Sascha Hauer
[not found] ` <20140120090950.GI16215-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-01-20 9:17 ` Hans de Goede
2014-01-20 9:57 ` Sascha Hauer
2014-01-18 23:48 ` [RFC v3 09/13] ARM: sunxi: Add support for Allwinner SUNXi SoCs sata to ahci_platform Hans de Goede
2014-01-19 12:22 ` Russell King - ARM Linux
[not found] ` <20140119122216.GM15937-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-01-19 19:07 ` Hans de Goede
2014-01-19 19:56 ` Russell King - ARM Linux [this message]
[not found] ` <20140119195642.GU15937-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-01-19 20:01 ` Hans de Goede
2014-01-18 23:48 ` [RFC v3 10/13] ahci_imx: Adjust for ahci_platform managing the clocks Hans de Goede
[not found] ` <1390088935-7193-11-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 12:41 ` Russell King - ARM Linux
[not found] ` <20140119124134.GQ15937-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-01-19 19:30 ` Hans de Goede
[not found] ` <52DC27DD.5030309-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 19:32 ` Russell King - ARM Linux
[not found] ` <20140119193258.GT15937-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-01-19 19:38 ` Hans de Goede
2014-01-18 23:48 ` [RFC v3 11/13] ahci-imx: Don't create a nested platform device from probe Hans de Goede
[not found] ` <1390088935-7193-12-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-19 12:25 ` Russell King - ARM Linux
[not found] ` <20140119122540.GN15937-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-01-19 19:08 ` Hans de Goede
2014-01-18 23:48 ` [RFC v3 12/13] ARM: sun4i: dts: Add ahci / sata support Hans de Goede
2014-01-18 23:48 ` [RFC v3 13/13] ARM: sun7i: " Hans de Goede
2014-01-19 9:52 ` [RFC v3 00/13] ahci: add sunxi driver and cleanup imx driver Russell King - ARM Linux
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=20140119195642.GU15937@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=Hong-Xing.Zhu@freescale.com \
--cc=devicetree@vger.kernel.org \
--cc=hdegoede@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=maxime.ripard@free-electrons.com \
--cc=oliver@schinagl.nl \
--cc=tj@kernel.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 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).