Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1533675
| From | Andrew Lunn <andrew@lunn.ch> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH net-next 5/6] net: dsa: mv88e6xxx: add helper for switch ready |
| Date | 2016-12-01 00:40 +0100 |
| Message-ID | <sJmDM-4jD-13@gated-at.bofh.it> (permalink) |
| References | <sJmaJ-472-7@gated-at.bofh.it> <sJmaJ-472-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
> +static int mv88e6xxx_wait_switch_ready(struct mv88e6xxx_chip *chip)
> +{
> + const unsigned long timeout = jiffies + 1 * HZ;
> + bool ready;
> + int err;
> +
> + /* Wait up to 1 second for switch to be ready.
> + * The switch is ready when all units inside the device (ATU, VTU, etc.)
> + * have finished their initialization and are ready to accept frames.
> + */
> + while (time_before(jiffies, timeout)) {
> + err = mv88e6xxx_g1_init_ready(chip, &ready);
> + if (err)
> + return err;
> +
> + if (ready)
> + break;
> +
> + usleep_range(1000, 2000);
> + }
> +
> + if (time_after(jiffies, timeout))
> + return -ETIMEDOUT;
As we have seen in the past, this sort of loop is broken if we end up
sleeping for a long time. Please take the opportunity to replace it
with one of our _wait() helpers, e.g. mv88e6xxx_g1_wait()
> +int mv88e6xxx_g1_init_ready(struct mv88e6xxx_chip *chip, bool *ready)
> +{
> + u16 val;
> + int err;
> +
> + /* Check the value of the InitReady bit 11 */
> + err = mv88e6xxx_g1_read(chip, GLOBAL_STATUS, &val);
> + if (err)
> + return err;
> +
> + *ready = !!(val & GLOBAL_STATUS_INIT_READY);
I would actually do the wait here.
> +
> + return 0;
> +}
> +
Thanks
Andrew
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH net-next 0/6] net: dsa: mv88e6xxx: rework reset and PPU code Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-01 00:10 +0100
[PATCH net-next 6/6] net: dsa: mv88e6xxx: add PPU enable/disable ops Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-01 00:10 +0100
[PATCH net-next 2/6] net: dsa: mv88e6xxx: add helper to hardware reset Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-01 00:10 +0100
Re: [PATCH net-next 2/6] net: dsa: mv88e6xxx: add helper to hardware reset Andrew Lunn <andrew@lunn.ch> - 2016-12-01 00:30 +0100
[PATCH net-next 1/6] net: dsa: mv88e6xxx: add helper to disable ports Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-01 00:10 +0100
Re: [PATCH net-next 1/6] net: dsa: mv88e6xxx: add helper to disable ports Andrew Lunn <andrew@lunn.ch> - 2016-12-01 00:30 +0100
[PATCH net-next 3/6] net: dsa: mv88e6xxx: add a software reset op Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-01 00:10 +0100
Re: [PATCH net-next 3/6] net: dsa: mv88e6xxx: add a software reset op Andrew Lunn <andrew@lunn.ch> - 2016-12-01 00:30 +0100
Re: [PATCH net-next 3/6] net: dsa: mv88e6xxx: add a software reset op Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-01 21:50 +0100
Re: [PATCH net-next 3/6] net: dsa: mv88e6xxx: add a software reset op Andrew Lunn <andrew@lunn.ch> - 2016-12-02 16:50 +0100
Re: [PATCH net-next 3/6] net: dsa: mv88e6xxx: add a software reset op Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-02 18:40 +0100
Re: [PATCH net-next 3/6] net: dsa: mv88e6xxx: add a software reset op David Miller <davem@davemloft.net> - 2016-12-02 18:30 +0100
[PATCH net-next 5/6] net: dsa: mv88e6xxx: add helper for switch ready Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-01 00:10 +0100
Re: [PATCH net-next 5/6] net: dsa: mv88e6xxx: add helper for switch ready Andrew Lunn <andrew@lunn.ch> - 2016-12-01 00:40 +0100
Re: [PATCH net-next 5/6] net: dsa: mv88e6xxx: add helper for switch ready Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-01 21:40 +0100
[PATCH net-next 4/6] net: dsa: mv88e6xxx: add a PPU polling op Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-01 00:10 +0100
csiph-web