From: sebastian.hesselbarth@gmail.com (Sebastian Hesselbarth)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC 1/4] net: mvmdio: make orion_mdio_wait_ready consistent
Date: Mon, 21 Oct 2013 08:13:07 +0100 [thread overview]
Message-ID: <5264D403.1090606@gmail.com> (raw)
In-Reply-To: <3acbec7a5077d1375777e26cd808b787eb677fb3.1382199042.git.leigh@solinno.co.uk>
On 10/19/2013 05:23 PM, Leigh Brown wrote:
> Amend orion_mdio_wait_ready so that the same timeout is used when
> polling or using wait_event_timeout. Set the timeout to 10ms.
>
> Generate the same log message at timeout when polling or using
> wait_event_timeout.
>
> Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
> ---
> drivers/net/ethernet/marvell/mvmdio.c | 41 ++++++++++++++++++---------------
> 1 file changed, 22 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index e2f6626..11e6415 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -44,6 +44,13 @@
> #define MVMDIO_ERR_INT_SMI_DONE 0x00000010
> #define MVMDIO_ERR_INT_MASK 0x0080
>
> +/*
> + * Testing on a Dreamplug showed that the SMI interface took an average of
> + * 3.2ms to respond, with a maximum time of 4.9ms.
> + */
> +#define MVMDIO_SMI_TIMEOUT 10000 /* 10000us = 10ms */
> +#define MVMDIO_SMI_POLL_INTERVAL 10
> +
> struct orion_mdio_dev {
> struct mutex lock;
> void __iomem *regs;
> @@ -70,32 +77,28 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
> struct orion_mdio_dev *dev = bus->priv;
> int count;
>
> - if (dev->err_interrupt <= 0) {
> - count = 0;
> - while (1) {
> + if (dev->err_interrupt <= 0)
> + for (count = MVMDIO_SMI_TIMEOUT / MVMDIO_SMI_POLL_INTERVAL;
> + count > 0;
> + --count) {
> if (orion_mdio_smi_is_done(dev))
> - break;
> -
> - if (count > 100) {
> - dev_err(bus->parent,
> - "Timeout: SMI busy for too long\n");
> - return -ETIMEDOUT;
> - }
> + return 0;
>
> - udelay(10);
> - count++;
> + udelay(MVMDIO_SMI_POLL_INTERVAL);
Leigh,
this isn't happening in interrupt context, is it? According to
Documentation/timers/timers-howto.txt starting from 10us you
should use usleep_range instead. I guess it isn't really critical
but IMHO sleeping is always better than delay.
Sebastian
> }
> - } else {
> - if (!orion_mdio_smi_is_done(dev)) {
> + else {
> + if (!orion_mdio_smi_is_done(dev))
> wait_event_timeout(dev->smi_busy_wait,
> orion_mdio_smi_is_done(dev),
> - msecs_to_jiffies(100));
> - if (!orion_mdio_smi_is_done(dev))
> - return -ETIMEDOUT;
> - }
> + usecs_to_jiffies(MVMDIO_SMI_TIMEOUT));
> +
> + if (orion_mdio_smi_is_done(dev))
> + return 0;
> }
>
> - return 0;
> + dev_err(bus->parent,
> + "Timeout: SMI busy for too long\n");
> + return -ETIMEDOUT;
> }
>
> static int orion_mdio_read(struct mii_bus *bus, int mii_id,
>
next prev parent reply other threads:[~2013-10-21 7:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-19 16:23 [PATCH RFC 0/4] MDIO bus timeout issues on Dreamplug Leigh Brown
2013-10-19 16:23 ` [PATCH RFC 1/4] net: mvmdio: make orion_mdio_wait_ready consistent Leigh Brown
2013-10-21 7:13 ` Sebastian Hesselbarth [this message]
2013-10-19 16:23 ` [PATCH RFC 2/4] net: mvmdio: orion_mdio_ready: remove manual poll Leigh Brown
2013-10-19 16:23 ` [PATCH RFC 3/4] net: mvmdio: slight optimisation of orion_mdio_write Leigh Brown
2013-10-19 16:23 ` [PATCH RFC 4/4] net: mvmdio: doc: mvmdio now used by mv643xx_eth Leigh Brown
2013-10-24 18:09 ` [PATCH RFC v2 0/4] MDIO bus timeout issues on Dreamplug Leigh Brown
2013-10-24 18:09 ` [PATCH RFC v2 1/4] net: mvmdio: make orion_mdio_wait_ready consistent Leigh Brown
2013-10-26 5:44 ` David Miller
2013-10-24 18:09 ` [PATCH RFC v2 2/4] net: mvmdio: orion_mdio_ready: remove manual poll Leigh Brown
2013-10-24 18:09 ` [PATCH RFC v2 3/4] net: mvmdio: slight optimisation of orion_mdio_write Leigh Brown
2013-10-26 5:45 ` David Miller
2013-10-24 18:09 ` [PATCH RFC v2 4/4] net: mvmdio: doc: mvmdio now used by mv643xx_eth Leigh Brown
2013-10-24 21:25 ` [PATCH RFC v2 0/4] MDIO bus timeout issues on Dreamplug Jason Cooper
2013-10-29 9:33 ` [PATCH v3 0/4] Fix " Leigh Brown
2013-10-29 9:33 ` [PATCH v3 1/4] net: mvmdio: make orion_mdio_wait_ready consistent Leigh Brown
2013-10-29 9:33 ` [PATCH v3 2/4] net: mvmdio: orion_mdio_ready: remove manual poll Leigh Brown
2013-10-29 9:33 ` [PATCH v3 3/4] net: mvmdio: slight optimisation of orion_mdio_write Leigh Brown
2013-10-29 9:33 ` [PATCH v3 4/4] net: mvmdio: doc: mvmdio now used by mv643xx_eth Leigh Brown
2013-10-29 22:54 ` [PATCH v3 0/4] Fix MDIO bus timeout issues on Dreamplug David Miller
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=5264D403.1090606@gmail.com \
--to=sebastian.hesselbarth@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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).