From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>,
Grant Likely <grant.likely@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-ide@vger.kernel.org
Subject: Re: [PATCH v2 1/2] phy: qcom: Add driver for QCOM APQ8064 SATA PHY
Date: Fri, 11 Jul 2014 20:42:31 +0100 [thread overview]
Message-ID: <53C03E27.3000003@linaro.org> (raw)
In-Reply-To: <2632799.IFO1aEjqtg@amdc1032>
Thanks Bartlomiej for the advice,
I will give it a try and see.
On 11/07/14 15:33, Bartlomiej Zolnierkiewicz wrote:
>>>> struct qcom_apq8064_sata_phy {
>>>> > >>+ void __iomem *mmio;
>>>> > >>+ struct clk *cfg_clk;
>>>> > >>+ struct device *dev;
>>>> > >>+};
>>>> > >>+
>>>> > >>+/* Helper function to do poll and timeout */
>>>> > >>+static int read_poll_timeout(void __iomem *addr, u32 mask)
>>>> > >>+{
>>>> > >>+ unsigned long timeout = jiffies + msecs_to_jiffies(TIMEOUT_MS);
>>>> > >>+ u32 val;
>>>> > >>+
>>>> > >>+ do {
>>>> > >>+ cpu_relax();
>>>> > >>+ val = readl_relaxed(addr);
>>>> > >>+ if (val & mask)
>>>> > >>+ break;
>>>> > >>+ } while (!time_after(jiffies, timeout));
>>> > >
>>> > >It would be better to use usleep_[range]() (or even msleep() if needed)
>>> > >instead of just using cpu_relax().
>> >
>> >We really want to poll the register here, usleep/msleep would be useful
>> >if we know already know how much delay is required, but in this case the
>> >its not true.
> I don't mean replacing the whole function, you can still do polling with
> i.e. doing usleep_range(1000, 2000) with 1000 retries. The advantage of
> doing it this way would be that processor could do some useful work or
> sleep during wait time instead of just busy waiting.
>
> One example of many how to do it:
>
> drivers/i2c/busses/i2c-s3c2410.c:
>
> static bool is_ack(struct s3c24xx_i2c *i2c)
> {
> int tries;
>
> for (tries = 50; tries; --tries) {
> if (readl(i2c->regs + S3C2410_IICCON)
> & S3C2410_IICCON_IRQPEND) {
> if (!(readl(i2c->regs + S3C2410_IICSTAT)
> & S3C2410_IICSTAT_LASTBIT))
> return true;
> }
> usleep_range(1000, 2000);
> }
> dev_err(i2c->dev, "ack was not recieved\n");
> return false;
> }
thanks,
srini
next prev parent reply other threads:[~2014-07-11 19:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-23 18:00 [PATCH] phy: qcom: Add driver for QCOM APQ8064 SATA PHY Srinivas Kandagatla
2014-06-23 18:12 ` Kumar Gala
2014-06-23 18:38 ` Srinivas Kandagatla
2014-07-09 9:36 ` Srinivas Kandagatla
2014-07-09 10:08 ` Kishon Vijay Abraham I
2014-07-09 11:03 ` [PATCH v2 0/2] Add Qcom AP8064 SATA PHY support Srinivas Kandagatla
2014-07-09 11:04 ` [PATCH v2 1/2] phy: qcom: Add driver for QCOM APQ8064 SATA PHY Srinivas Kandagatla
2014-07-11 12:38 ` Bartlomiej Zolnierkiewicz
2014-07-11 13:39 ` Srinivas Kandagatla
2014-07-11 14:33 ` Bartlomiej Zolnierkiewicz
2014-07-11 19:42 ` Srinivas Kandagatla [this message]
2014-07-09 11:04 ` [PATCH v2 2/2] phy: qcom: Update APQ8064 PHY device tree bindings Srinivas Kandagatla
2014-07-14 8:47 ` [PATCH v3 0/2] phy: qcom: Add driver for QCOM APQ8064 SATA PHY Srinivas Kandagatla
2014-07-14 8:48 ` [PATCH v3 1/2] " Srinivas Kandagatla
2014-07-14 8:48 ` [PATCH v3 2/2] phy: qcom: Update APQ8064 PHY device tree bindings Srinivas Kandagatla
2014-07-14 10:30 ` [PATCH v3 0/2] phy: qcom: Add driver for QCOM APQ8064 SATA PHY Kishon Vijay Abraham I
2014-07-14 10:32 ` Srinivas Kandagatla
2014-07-14 11:17 ` [PATCH v4 " Srinivas Kandagatla
2014-07-14 11:17 ` [PATCH v4 1/2] " Srinivas Kandagatla
2014-07-15 16:56 ` Bartlomiej Zolnierkiewicz
2014-07-16 6:28 ` Srinivas Kandagatla
2014-07-14 11:18 ` [PATCH v4 2/2] phy: qcom: Add APQ8064 SATA PHY device tree bindings Srinivas Kandagatla
2014-07-14 10:53 ` [PATCH] phy: qcom: Add driver for QCOM APQ8064 SATA PHY kiran padwal
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=53C03E27.3000003@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=b.zolnierkie@samsung.com \
--cc=grant.likely@linaro.org \
--cc=kishon@ti.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@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).