From: Colin Foster <colin.foster@in-advantage.com>
To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
"David S. Miller" <davem@davemloft.net>,
UNGLinuxDriver@microchip.com,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: Re: [PATCH v1 net-next 1/2] net: mscc: ocelot: utilize readx_poll_timeout() for chip reset
Date: Fri, 16 Sep 2022 15:42:48 -0700 [thread overview]
Message-ID: <YyT76OIgNiJBH1Dm@euler> (raw)
In-Reply-To: <20220916191349.1659269-2-colin.foster@in-advantage.com>
On Fri, Sep 16, 2022 at 12:13:48PM -0700, Colin Foster wrote:
> Clean up the reset code by utilizing readx_poll_timeout instead of a custom
> loop.
>
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
> drivers/net/ethernet/mscc/ocelot_vsc7514.c | 32 ++++++++++++++++------
> 1 file changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> index ae42bbba5747..79b7af36b4f4 100644
> --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> @@ -6,6 +6,7 @@
> */
> #include <linux/dsa/ocelot.h>
> #include <linux/interrupt.h>
> +#include <linux/iopoll.h>
> #include <linux/module.h>
> #include <linux/of_net.h>
> #include <linux/netdevice.h>
> @@ -25,6 +26,9 @@
> #define VSC7514_VCAP_POLICER_BASE 128
> #define VSC7514_VCAP_POLICER_MAX 191
>
> +#define MEM_INIT_SLEEP_US 1000
> +#define MEM_INIT_TIMEOUT_US 100000
> +
> static const u32 *ocelot_regmap[TARGET_MAX] = {
> [ANA] = vsc7514_ana_regmap,
> [QS] = vsc7514_qs_regmap,
> @@ -191,22 +195,32 @@ static const struct of_device_id mscc_ocelot_match[] = {
> };
> MODULE_DEVICE_TABLE(of, mscc_ocelot_match);
>
> +static int ocelot_mem_init_status(struct ocelot *ocelot)
> +{
> + unsigned int val;
> + int err;
> +
> + err = regmap_field_read(ocelot->regfields[SYS_RESET_CFG_MEM_INIT],
> + &val);
> +
> + return err ?: val;
> +}
> +
> static int ocelot_reset(struct ocelot *ocelot)
> {
> - int retries = 100;
> + int err;
> u32 val;
>
> regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], 1);
> regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1);
>
> - do {
> - msleep(1);
> - regmap_field_read(ocelot->regfields[SYS_RESET_CFG_MEM_INIT],
> - &val);
> - } while (val && --retries);
> -
> - if (!retries)
> - return -ETIMEDOUT;
> + /* MEM_INIT is a self-clearing bit. Wait for it to be cleared (should be
> + * 100us) before enabling the switch core.
> + */
> + err = readx_poll_timeout(ocelot_mem_init_status, ocelot, val, !val,
> + MEM_INIT_SLEEP_US, MEM_INIT_TIMEOUT_US);
> + if (IS_ERR_VALUE(err))
I see patchwork is complaining about IS_ERR_VALUE. I think it should
just be if (err). I'll test before sending v2 after the weekend.
> + return err;
>
> regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1);
> regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1);
> --
> 2.25.1
>
next prev parent reply other threads:[~2022-09-16 22:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 19:13 [PATCH v1 net-next 0/2] clean up ocelot_reset() routine Colin Foster
2022-09-16 19:13 ` [PATCH v1 net-next 1/2] net: mscc: ocelot: utilize readx_poll_timeout() for chip reset Colin Foster
2022-09-16 22:38 ` Vladimir Oltean
2022-09-16 22:42 ` Colin Foster [this message]
2022-09-17 4:05 ` kernel test robot
2022-09-16 19:13 ` [PATCH v1 net-next 2/2] net: mscc: ocelot: check return values of writes during reset Colin Foster
2022-09-16 22:40 ` Vladimir Oltean
2022-09-16 23:12 ` Colin Foster
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=YyT76OIgNiJBH1Dm@euler \
--to=colin.foster@in-advantage.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
/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.